{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s621484599", "group_id": "codeNet:p00001", "input_text": "import java.io.IOException;\nimport java.util.Arrays;\nimport java.util.Scanner;\n\n\npublic class Main {\n\tpublic static void main(String[] args) throws IOException\n\t{\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint [] list = new int[10];\n\t\tint i,j;\n\t\t\n\t\tfor(i=0;i<10;i++){\n\t\t\tlist[i] = sc.nextInt();\n\t\t}\n\t\tArrays.sort(list);\n\t\t\n\t\tfor(j=0;j<3;j++){\n\t\t\tSystem.out.println(list[9-j]);\n\t\t}\n\t}\n\n}", "language": "Java", "metadata": {"date": 1404632564, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00001.html", "problem_id": "p00001", "resource_group": "high_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/Java/s621484599.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s621484599", "user_id": "u871149799"}, "prompt_components": {"gold_output": "3776\n2848\n2840\n", "input_to_evaluate": "import java.io.IOException;\nimport java.util.Arrays;\nimport java.util.Scanner;\n\n\npublic class Main {\n\tpublic static void main(String[] args) throws IOException\n\t{\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint [] list = new int[10];\n\t\tint i,j;\n\t\t\n\t\tfor(i=0;i<10;i++){\n\t\t\tlist[i] = sc.nextInt();\n\t\t}\n\t\tArrays.sort(list);\n\t\t\n\t\tfor(j=0;j<3;j++){\n\t\t\tSystem.out.println(list[9-j]);\n\t\t}\n\t}\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": 387, "cpu_time_ms": 50, "memory_kb": 17240}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s322173285", "group_id": "codeNet:p00002", "input_text": "import java.util.Scanner;\n\nclass Main {\n private static void solve() {\n Scanner scanner = new Scanner(System.in);\n while (scanner.hasNextInt()) {\n int a = scanner.nextInt();\n int b = scanner.nextInt();\n System.out.println(String.valueOf(a + b).length());\n }\n }\n\n public static void main(String... args) {\n solve();\n }\n}", "language": "Java", "metadata": {"date": 1320242525, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00002.html", "problem_id": "p00002", "resource_group": "high_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/Java/s322173285.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s322173285", "user_id": "u355438851"}, "prompt_components": {"gold_output": "2\n3\n4\n", "input_to_evaluate": "import java.util.Scanner;\n\nclass Main {\n private static void solve() {\n Scanner scanner = new Scanner(System.in);\n while (scanner.hasNextInt()) {\n int a = scanner.nextInt();\n int b = scanner.nextInt();\n System.out.println(String.valueOf(a + b).length());\n }\n }\n\n public static void main(String... args) {\n solve();\n }\n}", "problem_context": "Digit Number\n\nWrite a program which computes the digit number of sum of two integers a and b.\n\nInput\n\nThere are several test cases. Each test case consists of two non-negative integers a and b which are separeted by a space in a line. The input terminates with EOF.\n\nConstraints\n\n0 ≤ a, b ≤ 1,000,000\n\nThe number of datasets ≤ 200\n\nOutput\n\nPrint the number of digits of a + b for each data set.\n\nSample Input\n\n5 7\n1 99\n1000 999\n\nOutput for the Sample Input\n\n2\n3\n4", "sample_input": "5 7\n1 99\n1000 999\n"}, "reference_outputs": ["2\n3\n4\n"], "source_document_id": "p00002", "source_text": "Digit Number\n\nWrite a program which computes the digit number of sum of two integers a and b.\n\nInput\n\nThere are several test cases. Each test case consists of two non-negative integers a and b which are separeted by a space in a line. The input terminates with EOF.\n\nConstraints\n\n0 ≤ a, b ≤ 1,000,000\n\nThe number of datasets ≤ 200\n\nOutput\n\nPrint the number of digits of a + b for each data set.\n\nSample Input\n\n5 7\n1 99\n1000 999\n\nOutput for the Sample Input\n\n2\n3\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 392, "cpu_time_ms": 100, "memory_kb": 12000}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s467938458", "group_id": "codeNet:p00002", "input_text": "import java.io.*;\n\npublic class Main{\n\tstatic int digit(int a, int b){\n\t\tint x = a + b;\n\t\tint d = 0;\n\t\twhile( x > 0 ){\n\t\t\td++;\n\t\t\tx /= 10;\n\t\t}\n\t\treturn d;\n\t}\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));\n\t\tfinal int NUM = 1000;\n\t\tString[] str = new String[NUM];\n\t\tString[][] s = new String[NUM][2];\n\t\tint[][] p = new int[NUM][2];\n\t\tint i = 0;\n\t\n\t\twhile( (str[i] = stdIn.readLine()) != null ){\n\t\t\tstr[i] = stdIn.readLine();\n\t\t\ts[i] = str[i].split(\" \");\n\t\t\tp[i][0] = Integer.parseInt(s[i][0]);\n\t\t\tp[i][1] = Integer.parseInt(s[i][1]);\n\t\t\ti++;\n\t\t}\n\t\t\t\n\t\tfor(int j = 0; j < i; j++){\n\t\t\tSystem.out.println(digit(p[j][0],p[j][1]));\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1335964471, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00002.html", "problem_id": "p00002", "resource_group": "high_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/Java/s467938458.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s467938458", "user_id": "u663419588"}, "prompt_components": {"gold_output": "2\n3\n4\n", "input_to_evaluate": "import java.io.*;\n\npublic class Main{\n\tstatic int digit(int a, int b){\n\t\tint x = a + b;\n\t\tint d = 0;\n\t\twhile( x > 0 ){\n\t\t\td++;\n\t\t\tx /= 10;\n\t\t}\n\t\treturn d;\n\t}\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));\n\t\tfinal int NUM = 1000;\n\t\tString[] str = new String[NUM];\n\t\tString[][] s = new String[NUM][2];\n\t\tint[][] p = new int[NUM][2];\n\t\tint i = 0;\n\t\n\t\twhile( (str[i] = stdIn.readLine()) != null ){\n\t\t\tstr[i] = stdIn.readLine();\n\t\t\ts[i] = str[i].split(\" \");\n\t\t\tp[i][0] = Integer.parseInt(s[i][0]);\n\t\t\tp[i][1] = Integer.parseInt(s[i][1]);\n\t\t\ti++;\n\t\t}\n\t\t\t\n\t\tfor(int j = 0; j < i; j++){\n\t\t\tSystem.out.println(digit(p[j][0],p[j][1]));\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": 728, "cpu_time_ms": 60, "memory_kb": 10000}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s265600109", "group_id": "codeNet:p00003", "input_text": "import java.io.*;\n\nclass Main{\n\tpublic static void Triangle(int[] data){\n\t\tint a,b,c,d;\n\t\ta=(int)Math.pow(data[0],2);\n\t\tb=(int)Math.pow(data[1],2);\n\t\tc=(int)Math.pow(data[2],2);\n\t\td=(int)Math.sqrt(a+b);\n\t\tif(d==data[2]){\n\t\t\tSystem.out.println(\"YES\");\n\t\t}\n\t\telse if((d=(int)Math.sqrt(a+c))==data[1]){\n\t\t\tSystem.out.println(\"YES\");\n\t\t}\n\t\telse if((d=(int)Math.sqrt(b+c))==data[0]){\n\t\t\tSystem.out.println(\"YES\");\n\t\t}\n\t\telse{\n\t\t\tSystem.out.println(\"NO\");\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args) throws IOException{\n\t\tBufferedReader in=new BufferedReader(new InputStreamReader(System.in));\n\t\tString str[]=new String[3];\n\t\tint N,i;\n\t\tint Line[]=new int[3];\n\t\ti=1;\n\t\tN=Integer.parseInt(in.readLine());\n\t\twhile(i<=N){\n\t\t\tstr=(in.readLine()).split(\" \",0);\n\t\t\tfor(int j=0;j<=2;j++){\n\t\t\t\tLine[j]=Integer.parseInt(str[j]);\n\t\t\t}\n\t\t\tTriangle(Line);\n\t\t\ti++;\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1471098815, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00003.html", "problem_id": "p00003", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00003/input.txt", "sample_output_relpath": "derived/input_output/data/p00003/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00003/Java/s265600109.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s265600109", "user_id": "u816928455"}, "prompt_components": {"gold_output": "YES\nNO\nNO\n", "input_to_evaluate": "import java.io.*;\n\nclass Main{\n\tpublic static void Triangle(int[] data){\n\t\tint a,b,c,d;\n\t\ta=(int)Math.pow(data[0],2);\n\t\tb=(int)Math.pow(data[1],2);\n\t\tc=(int)Math.pow(data[2],2);\n\t\td=(int)Math.sqrt(a+b);\n\t\tif(d==data[2]){\n\t\t\tSystem.out.println(\"YES\");\n\t\t}\n\t\telse if((d=(int)Math.sqrt(a+c))==data[1]){\n\t\t\tSystem.out.println(\"YES\");\n\t\t}\n\t\telse if((d=(int)Math.sqrt(b+c))==data[0]){\n\t\t\tSystem.out.println(\"YES\");\n\t\t}\n\t\telse{\n\t\t\tSystem.out.println(\"NO\");\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args) throws IOException{\n\t\tBufferedReader in=new BufferedReader(new InputStreamReader(System.in));\n\t\tString str[]=new String[3];\n\t\tint N,i;\n\t\tint Line[]=new int[3];\n\t\ti=1;\n\t\tN=Integer.parseInt(in.readLine());\n\t\twhile(i<=N){\n\t\t\tstr=(in.readLine()).split(\" \",0);\n\t\t\tfor(int j=0;j<=2;j++){\n\t\t\t\tLine[j]=Integer.parseInt(str[j]);\n\t\t\t}\n\t\t\tTriangle(Line);\n\t\t\ti++;\n\t\t}\n\t}\n}", "problem_context": "Is it a Right Triangle?\n\nWrite a program which judges wheather given length of three side form a right triangle. Print \"YES\" if the given sides (integers) form a right triangle, \"NO\" if not so.\n\nInput\n\nInput consists of several data sets. In the first line, the number of data set, N is given. Then, N lines follow, each line corresponds to a data set. A data set consists of three integers separated by a single space.\n\nConstraints\n\n1 ≤ length of the side ≤ 1,000\n\nN ≤ 1,000\n\nOutput\n\nFor each data set, print \"YES\" or \"NO\".\n\nSample Input\n\n3\n4 3 5\n4 3 6\n8 8 8\n\nOutput for the Sample Input\n\nYES\nNO\nNO", "sample_input": "3\n4 3 5\n4 3 6\n8 8 8\n"}, "reference_outputs": ["YES\nNO\nNO\n"], "source_document_id": "p00003", "source_text": "Is it a Right Triangle?\n\nWrite a program which judges wheather given length of three side form a right triangle. Print \"YES\" if the given sides (integers) form a right triangle, \"NO\" if not so.\n\nInput\n\nInput consists of several data sets. In the first line, the number of data set, N is given. Then, N lines follow, each line corresponds to a data set. A data set consists of three integers separated by a single space.\n\nConstraints\n\n1 ≤ length of the side ≤ 1,000\n\nN ≤ 1,000\n\nOutput\n\nFor each data set, print \"YES\" or \"NO\".\n\nSample Input\n\n3\n4 3 5\n4 3 6\n8 8 8\n\nOutput for the Sample Input\n\nYES\nNO\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 80, "memory_kb": 25812}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s320358596", "group_id": "codeNet:p00003", "input_text": "import java.util.*;\n\nclass Main{\n public static void main(String[] args){\n\tScanner s = new Scanner(System.in);\n\tint k,a,b,c;\n\t\n\tk = s.nextInt();\n\t\n\tfor(int i=0;ia&&b>c){\n\t\tint swap = b;\n\t\tb=c;\n\t\tc=swap;\n\t }else if(a>b&&a>c){\n\t\tint swap = a;\n\t\ta=c;\n\t\tc=swap;\n\t }\n\t \n\t if((c*c)==(a*a+b*b)){\n\t\tSystem.out.println(\"YES\");\n\t }\n\t else{\n\t\tSystem.out.println(\"NO\");\n\t }\n\t \n\t}\n }\n}", "language": "Java", "metadata": {"date": 1382611788, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00003.html", "problem_id": "p00003", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00003/input.txt", "sample_output_relpath": "derived/input_output/data/p00003/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00003/Java/s320358596.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s320358596", "user_id": "u871583613"}, "prompt_components": {"gold_output": "YES\nNO\nNO\n", "input_to_evaluate": "import java.util.*;\n\nclass Main{\n public static void main(String[] args){\n\tScanner s = new Scanner(System.in);\n\tint k,a,b,c;\n\t\n\tk = s.nextInt();\n\t\n\tfor(int i=0;ia&&b>c){\n\t\tint swap = b;\n\t\tb=c;\n\t\tc=swap;\n\t }else if(a>b&&a>c){\n\t\tint swap = a;\n\t\ta=c;\n\t\tc=swap;\n\t }\n\t \n\t if((c*c)==(a*a+b*b)){\n\t\tSystem.out.println(\"YES\");\n\t }\n\t else{\n\t\tSystem.out.println(\"NO\");\n\t }\n\t \n\t}\n }\n}", "problem_context": "Is it a Right Triangle?\n\nWrite a program which judges wheather given length of three side form a right triangle. Print \"YES\" if the given sides (integers) form a right triangle, \"NO\" if not so.\n\nInput\n\nInput consists of several data sets. In the first line, the number of data set, N is given. Then, N lines follow, each line corresponds to a data set. A data set consists of three integers separated by a single space.\n\nConstraints\n\n1 ≤ length of the side ≤ 1,000\n\nN ≤ 1,000\n\nOutput\n\nFor each data set, print \"YES\" or \"NO\".\n\nSample Input\n\n3\n4 3 5\n4 3 6\n8 8 8\n\nOutput for the Sample Input\n\nYES\nNO\nNO", "sample_input": "3\n4 3 5\n4 3 6\n8 8 8\n"}, "reference_outputs": ["YES\nNO\nNO\n"], "source_document_id": "p00003", "source_text": "Is it a Right Triangle?\n\nWrite a program which judges wheather given length of three side form a right triangle. Print \"YES\" if the given sides (integers) form a right triangle, \"NO\" if not so.\n\nInput\n\nInput consists of several data sets. In the first line, the number of data set, N is given. Then, N lines follow, each line corresponds to a data set. A data set consists of three integers separated by a single space.\n\nConstraints\n\n1 ≤ length of the side ≤ 1,000\n\nN ≤ 1,000\n\nOutput\n\nFor each data set, print \"YES\" or \"NO\".\n\nSample Input\n\n3\n4 3 5\n4 3 6\n8 8 8\n\nOutput for the Sample Input\n\nYES\nNO\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 140, "memory_kb": 23356}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s214014075", "group_id": "codeNet:p00004", "input_text": "import java.util.Scanner;\n\n\nclass Main{\n public static void main(String[] args){\n double EPS = 1e-6;\n Scanner in = new Scanner(System.in);\n while(in.hasNext()){\n double a = in.nextDouble();\n double b = in.nextDouble();\n double c = in.nextDouble();\n double d = in.nextDouble();\n double e = in.nextDouble();\n double f = in.nextDouble();\n double x = (e * c - b * f) / (a * e - b * d);\n double y = (- c * d + a * f) / (a * e - b * d);\n System.out.printf(\"%.3f %.3f\\n\", x+EPS, y+EPS);\n }\n }\n}", "language": "Java", "metadata": {"date": 1418283275, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00004.html", "problem_id": "p00004", "resource_group": "high_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/Java/s214014075.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s214014075", "user_id": "u858885710"}, "prompt_components": {"gold_output": "-1.000 2.000\n1.000 4.000\n", "input_to_evaluate": "import java.util.Scanner;\n\n\nclass Main{\n public static void main(String[] args){\n double EPS = 1e-6;\n Scanner in = new Scanner(System.in);\n while(in.hasNext()){\n double a = in.nextDouble();\n double b = in.nextDouble();\n double c = in.nextDouble();\n double d = in.nextDouble();\n double e = in.nextDouble();\n double f = in.nextDouble();\n double x = (e * c - b * f) / (a * e - b * d);\n double y = (- c * d + a * f) / (a * e - b * d);\n System.out.printf(\"%.3f %.3f\\n\", x+EPS, y+EPS);\n }\n }\n}", "problem_context": "Simultaneous Equation\n\nWrite a program which solve a simultaneous equation:\n\nax + by = c\n\ndx + ey = f\n\nThe program should print x and y for given a, b, c, d, e and f (-1,000 ≤ a, b, c, d, e, f ≤ 1,000). You can suppose that given equation has a unique solution.\n\nInput\n\nThe input consists of several data sets, 1 line for each data set. In a data set, there will be a, b, c, d, e, f separated by a single space. The input terminates with EOF.\n\nOutput\n\nFor each data set, print x and y separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places.\n\nSample Input 1\n\n1 2 3 4 5 6\n2 -1 -2 -1 -1 -5\n\nOutput for the Sample Input 1\n\n-1.000 2.000\n1.000 4.000\n\nSample Input 2\n\n2 -1 -3 1 -1 -3\n2 -1 -3 -9 9 27\n\nOutput for the Sample Input 2\n\n0.000 3.000\n0.000 3.000", "sample_input": "1 2 3 4 5 6\n2 -1 -2 -1 -1 -5\n"}, "reference_outputs": ["-1.000 2.000\n1.000 4.000\n"], "source_document_id": "p00004", "source_text": "Simultaneous Equation\n\nWrite a program which solve a simultaneous equation:\n\nax + by = c\n\ndx + ey = f\n\nThe program should print x and y for given a, b, c, d, e and f (-1,000 ≤ a, b, c, d, e, f ≤ 1,000). You can suppose that given equation has a unique solution.\n\nInput\n\nThe input consists of several data sets, 1 line for each data set. In a data set, there will be a, b, c, d, e, f separated by a single space. The input terminates with EOF.\n\nOutput\n\nFor each data set, print x and y separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places.\n\nSample Input 1\n\n1 2 3 4 5 6\n2 -1 -2 -1 -1 -5\n\nOutput for the Sample Input 1\n\n-1.000 2.000\n1.000 4.000\n\nSample Input 2\n\n2 -1 -3 1 -1 -3\n2 -1 -3 -9 9 27\n\nOutput for the Sample Input 2\n\n0.000 3.000\n0.000 3.000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 70, "memory_kb": 18736}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s782644981", "group_id": "codeNet:p00004", "input_text": "import java.util.Scanner;\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.Arrays;\nimport java.lang.Math;\n\nclass Main{\n public static void main(String[] args){\n InputStreamReader inputStreamReader = new InputStreamReader(System.in);\n BufferedReader reader = new BufferedReader(inputStreamReader);\n boolean firstTime = true;\n\n String str;\n double[] num;\n double[] xy;\n try {\n while(reader.ready()){\n str = reader.readLine();\n num = getNum(str);\n xy = solveXY(num);\n //System.out.println(xy[0] + \" \" + xy[1]);\n System.out.println(String.format(\"%.3f %.3f\", xy[0], xy[1]));\n }\n reader.close();\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n\n private static double[] getNum(String str){\n String[] data = str.split(\" \"); \n double[] num = new double[data.length];\n\n for (int i = 0; i < data.length; i++){\n num[i] = Double.parseDouble(data[i]);\n }\n return num;\n }\n\n private static double[] solveXY(double num[]){\n // ax+by=c\n // dx+ey=f\n\n // x = (bf - ce) / (ae - bd)\n // y = (c - ax) / b = (f - dx) / e\n\n double[] xy = new double[2];\n double a, b, c, d, e, f;\n \n a = num[0];\n b = num[1];\n c = num[2]; \n d = num[3];\n e = num[4];\n f = num[5];\n\n xy[0] = ((c * e) - (b * f)) / ((a * e) - (b * d));\n xy[1] = (c - a * xy[0]) / b;\n\n xy[0] = Math.round(xy[0] * 1000) * 0.001;\n xy[1] = Math.round(xy[1] * 1000) * 0.001;\n\n return xy;\n }\n}\n", "language": "Java", "metadata": {"date": 1561431274, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00004.html", "problem_id": "p00004", "resource_group": "high_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/Java/s782644981.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s782644981", "user_id": "u598767908"}, "prompt_components": {"gold_output": "-1.000 2.000\n1.000 4.000\n", "input_to_evaluate": "import java.util.Scanner;\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.Arrays;\nimport java.lang.Math;\n\nclass Main{\n public static void main(String[] args){\n InputStreamReader inputStreamReader = new InputStreamReader(System.in);\n BufferedReader reader = new BufferedReader(inputStreamReader);\n boolean firstTime = true;\n\n String str;\n double[] num;\n double[] xy;\n try {\n while(reader.ready()){\n str = reader.readLine();\n num = getNum(str);\n xy = solveXY(num);\n //System.out.println(xy[0] + \" \" + xy[1]);\n System.out.println(String.format(\"%.3f %.3f\", xy[0], xy[1]));\n }\n reader.close();\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n\n private static double[] getNum(String str){\n String[] data = str.split(\" \"); \n double[] num = new double[data.length];\n\n for (int i = 0; i < data.length; i++){\n num[i] = Double.parseDouble(data[i]);\n }\n return num;\n }\n\n private static double[] solveXY(double num[]){\n // ax+by=c\n // dx+ey=f\n\n // x = (bf - ce) / (ae - bd)\n // y = (c - ax) / b = (f - dx) / e\n\n double[] xy = new double[2];\n double a, b, c, d, e, f;\n \n a = num[0];\n b = num[1];\n c = num[2]; \n d = num[3];\n e = num[4];\n f = num[5];\n\n xy[0] = ((c * e) - (b * f)) / ((a * e) - (b * d));\n xy[1] = (c - a * xy[0]) / b;\n\n xy[0] = Math.round(xy[0] * 1000) * 0.001;\n xy[1] = Math.round(xy[1] * 1000) * 0.001;\n\n return xy;\n }\n}\n", "problem_context": "Simultaneous Equation\n\nWrite a program which solve a simultaneous equation:\n\nax + by = c\n\ndx + ey = f\n\nThe program should print x and y for given a, b, c, d, e and f (-1,000 ≤ a, b, c, d, e, f ≤ 1,000). You can suppose that given equation has a unique solution.\n\nInput\n\nThe input consists of several data sets, 1 line for each data set. In a data set, there will be a, b, c, d, e, f separated by a single space. The input terminates with EOF.\n\nOutput\n\nFor each data set, print x and y separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places.\n\nSample Input 1\n\n1 2 3 4 5 6\n2 -1 -2 -1 -1 -5\n\nOutput for the Sample Input 1\n\n-1.000 2.000\n1.000 4.000\n\nSample Input 2\n\n2 -1 -3 1 -1 -3\n2 -1 -3 -9 9 27\n\nOutput for the Sample Input 2\n\n0.000 3.000\n0.000 3.000", "sample_input": "1 2 3 4 5 6\n2 -1 -2 -1 -1 -5\n"}, "reference_outputs": ["-1.000 2.000\n1.000 4.000\n"], "source_document_id": "p00004", "source_text": "Simultaneous Equation\n\nWrite a program which solve a simultaneous equation:\n\nax + by = c\n\ndx + ey = f\n\nThe program should print x and y for given a, b, c, d, e and f (-1,000 ≤ a, b, c, d, e, f ≤ 1,000). You can suppose that given equation has a unique solution.\n\nInput\n\nThe input consists of several data sets, 1 line for each data set. In a data set, there will be a, b, c, d, e, f separated by a single space. The input terminates with EOF.\n\nOutput\n\nFor each data set, print x and y separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places.\n\nSample Input 1\n\n1 2 3 4 5 6\n2 -1 -2 -1 -1 -5\n\nOutput for the Sample Input 1\n\n-1.000 2.000\n1.000 4.000\n\nSample Input 2\n\n2 -1 -3 1 -1 -3\n2 -1 -3 -9 9 27\n\nOutput for the Sample Input 2\n\n0.000 3.000\n0.000 3.000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 30, "memory_kb": 24696}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s804977673", "group_id": "codeNet:p00005", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner stdin = new Scanner(System.in);\n\t\tint a = 0;\n\t\tint b = 0;\n\t\tint ab = 0;\n\t\tint r = 0;\n\t\tint gcd = 0;\n\t\tint lcm = 0;\n\t\tint temp = 0;\n\t\twhile(stdin.hasNext()) {\n\t\t\ta = stdin.nextInt();\n\t\t\tb = stdin.nextInt();\n\t\t\tab = a * b;\n\n\t\t\tif(a < b) {\n\t\t\t\ttemp = a;\n\t\t\t\ta = b;\n\t\t\t\tb = temp;\n\t\t\t}\n\t\t\tif(a >= b) {\n\t\t\t\tdo {\n\t\t\t\t\tr = a % b;\n\t\t\t\t\tif(r == 0) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ta = b;\n\t\t\t\t\t\tb = r;\n\t\t\t\t\t}\n\t\t\t\t}while(r != 1);\n\t\t\t\tgcd = b;\n\t\t\t\tlcm = ab / b;\n\t\t\t\tSystem.out.println(gcd + \" \" + lcm);\n\n\t\t\t}\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1501144709, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00005.html", "problem_id": "p00005", "resource_group": "high_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/Java/s804977673.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s804977673", "user_id": "u469183706"}, "prompt_components": {"gold_output": "2 24\n10000000 150000000\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner stdin = new Scanner(System.in);\n\t\tint a = 0;\n\t\tint b = 0;\n\t\tint ab = 0;\n\t\tint r = 0;\n\t\tint gcd = 0;\n\t\tint lcm = 0;\n\t\tint temp = 0;\n\t\twhile(stdin.hasNext()) {\n\t\t\ta = stdin.nextInt();\n\t\t\tb = stdin.nextInt();\n\t\t\tab = a * b;\n\n\t\t\tif(a < b) {\n\t\t\t\ttemp = a;\n\t\t\t\ta = b;\n\t\t\t\tb = temp;\n\t\t\t}\n\t\t\tif(a >= b) {\n\t\t\t\tdo {\n\t\t\t\t\tr = a % b;\n\t\t\t\t\tif(r == 0) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ta = b;\n\t\t\t\t\t\tb = r;\n\t\t\t\t\t}\n\t\t\t\t}while(r != 1);\n\t\t\t\tgcd = b;\n\t\t\t\tlcm = ab / b;\n\t\t\t\tSystem.out.println(gcd + \" \" + lcm);\n\n\t\t\t}\n\t\t}\n\t}\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": 607, "cpu_time_ms": 60, "memory_kb": 26168}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s952653773", "group_id": "codeNet:p00007", "input_text": "import java.io.*;\n \nclass Main{\n public static void main(String[] args) throws Exception{\n \n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n double x = Double.parseDouble(br.readLine());\n double y = 100000;\n long z = 0;\n for (long i=0; i=27 && sum<=36){\n\t\t\tint aki=36-sum;\n\t\t\tkazu=((aki+3)*(aki+2)*(aki+1))/6;\n\t\t}\n\t\telse if(sum>=10 && sum<=18){\n\t\t\tint aki=sum;\n\t\t\tkazu=((aki+3)*(aki+2)*(aki+1))/6;\n\t\t\tint gen=0;\n\t\t\tfor(int a=sum-9; a>=0; a--){\n\t\t\t\tgen+=(a+1)*a*2;\n\t\t\t}\n\t\t\tkazu=kazu-gen;\n\n\t\t}\n\t\telse if(sum>=19 && sum<=26){\n\t\t\tint aki=36-sum;\n\t\t\tkazu=((aki+3)*(aki+2)*(aki+1))/6;\n\t\t\tint gen=0;\n\t\t\tfor(int a=aki-9; a>=0; a--){\n\t\t\t\tgen+=(a+1)*a*2;\n\t\t\t}\n\t\t\tkazu=kazu-gen;\n\t\t}\n\t\telse if(sum>=0 && sum<=9){\n\t\t\tint aki=sum;\n\t\t\tkazu=((aki+3)*(aki+2)*(aki+1))/6;\n\t\t}\n\t\tSystem.out.println(kazu);\n\t}\n}", "language": "Java", "metadata": {"date": 1484995518, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00008.html", "problem_id": "p00008", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00008/input.txt", "sample_output_relpath": "derived/input_output/data/p00008/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00008/Java/s661670000.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s661670000", "user_id": "u069727578"}, "prompt_components": {"gold_output": "4\n4\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\nclass Main{\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString uketori=br.readLine();\n\t\tint sum=Integer.parseInt(uketori);\n\t\tlong kazu = 0;\n\t\tif(sum>=27 && sum<=36){\n\t\t\tint aki=36-sum;\n\t\t\tkazu=((aki+3)*(aki+2)*(aki+1))/6;\n\t\t}\n\t\telse if(sum>=10 && sum<=18){\n\t\t\tint aki=sum;\n\t\t\tkazu=((aki+3)*(aki+2)*(aki+1))/6;\n\t\t\tint gen=0;\n\t\t\tfor(int a=sum-9; a>=0; a--){\n\t\t\t\tgen+=(a+1)*a*2;\n\t\t\t}\n\t\t\tkazu=kazu-gen;\n\n\t\t}\n\t\telse if(sum>=19 && sum<=26){\n\t\t\tint aki=36-sum;\n\t\t\tkazu=((aki+3)*(aki+2)*(aki+1))/6;\n\t\t\tint gen=0;\n\t\t\tfor(int a=aki-9; a>=0; a--){\n\t\t\t\tgen+=(a+1)*a*2;\n\t\t\t}\n\t\t\tkazu=kazu-gen;\n\t\t}\n\t\telse if(sum>=0 && sum<=9){\n\t\t\tint aki=sum;\n\t\t\tkazu=((aki+3)*(aki+2)*(aki+1))/6;\n\t\t}\n\t\tSystem.out.println(kazu);\n\t}\n}", "problem_context": "Sum of 4 Integers\n\nWrite a program which reads an integer n and identifies the number of combinations of a, b, c and d (0 ≤ a, b, c, d ≤ 9) which meet the following equality:\n\na + b + c + d = n\n\nFor example, for n = 35, we have 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).\n\nInput\n\nThe input consists of several datasets. Each dataset consists of n (1 ≤ n ≤ 50) in a line. The number of datasets is less than or equal to 50.\n\nOutput\n\nPrint the number of combination in a line.\n\nSample Input\n\n35\n1\n\nOutput for the Sample Input\n\n4\n4", "sample_input": "35\n1\n"}, "reference_outputs": ["4\n4\n"], "source_document_id": "p00008", "source_text": "Sum of 4 Integers\n\nWrite a program which reads an integer n and identifies the number of combinations of a, b, c and d (0 ≤ a, b, c, d ≤ 9) which meet the following equality:\n\na + b + c + d = n\n\nFor example, for n = 35, we have 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).\n\nInput\n\nThe input consists of several datasets. Each dataset consists of n (1 ≤ n ≤ 50) in a line. The number of datasets is less than or equal to 50.\n\nOutput\n\nPrint the number of combination in a line.\n\nSample Input\n\n35\n1\n\nOutput for the Sample Input\n\n4\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 892, "cpu_time_ms": 40, "memory_kb": 24008}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s544629775", "group_id": "codeNet:p00008", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws NumberFormatException, IOException {\n\t\tBufferedReader bufReader =\n\t\t\t\tnew BufferedReader(new InputStreamReader(System.in));\n\t\twhile (true) {\n\t\t\tString read = bufReader.readLine();\n\t\t\tif (read == null) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tint n = Integer.parseInt(read);\n\t\t\tint match = 0;\n\t\t\tfor (int i = 0; i < 10; i++) {\n\t\t\t\tfor (int j = 0; j < 10; j++) {\n\t\t\t\t\tfor (int k = 0; k < 10; k++) {\n\t\t\t\t\t\tfor (int l = 0; l < 10; l++) {\n\t\t\t\t\t\t\tif (i + j + k + l == n) {\n\t\t\t\t\t\t\t\t++match;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.println(match);\n\t\t}\n\t}\n\n}", "language": "Java", "metadata": {"date": 1377060995, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00008.html", "problem_id": "p00008", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00008/input.txt", "sample_output_relpath": "derived/input_output/data/p00008/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00008/Java/s544629775.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s544629775", "user_id": "u211135121"}, "prompt_components": {"gold_output": "4\n4\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws NumberFormatException, IOException {\n\t\tBufferedReader bufReader =\n\t\t\t\tnew BufferedReader(new InputStreamReader(System.in));\n\t\twhile (true) {\n\t\t\tString read = bufReader.readLine();\n\t\t\tif (read == null) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tint n = Integer.parseInt(read);\n\t\t\tint match = 0;\n\t\t\tfor (int i = 0; i < 10; i++) {\n\t\t\t\tfor (int j = 0; j < 10; j++) {\n\t\t\t\t\tfor (int k = 0; k < 10; k++) {\n\t\t\t\t\t\tfor (int l = 0; l < 10; l++) {\n\t\t\t\t\t\t\tif (i + j + k + l == n) {\n\t\t\t\t\t\t\t\t++match;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.println(match);\n\t\t}\n\t}\n\n}", "problem_context": "Sum of 4 Integers\n\nWrite a program which reads an integer n and identifies the number of combinations of a, b, c and d (0 ≤ a, b, c, d ≤ 9) which meet the following equality:\n\na + b + c + d = n\n\nFor example, for n = 35, we have 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).\n\nInput\n\nThe input consists of several datasets. Each dataset consists of n (1 ≤ n ≤ 50) in a line. The number of datasets is less than or equal to 50.\n\nOutput\n\nPrint the number of combination in a line.\n\nSample Input\n\n35\n1\n\nOutput for the Sample Input\n\n4\n4", "sample_input": "35\n1\n"}, "reference_outputs": ["4\n4\n"], "source_document_id": "p00008", "source_text": "Sum of 4 Integers\n\nWrite a program which reads an integer n and identifies the number of combinations of a, b, c and d (0 ≤ a, b, c, d ≤ 9) which meet the following equality:\n\na + b + c + d = n\n\nFor example, for n = 35, we have 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).\n\nInput\n\nThe input consists of several datasets. Each dataset consists of n (1 ≤ n ≤ 50) in a line. The number of datasets is less than or equal to 50.\n\nOutput\n\nPrint the number of combination in a line.\n\nSample Input\n\n35\n1\n\nOutput for the Sample Input\n\n4\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 701, "cpu_time_ms": 50, "memory_kb": 18520}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s605124297", "group_id": "codeNet:p00009", "input_text": "import java.util.*;\n\nclass Main{\npublic static void main(String[] args){\nScanner sc=new Scanner(System.in);\nint num=0;\nwhile(sc.hasNextInt()){\nint n=sc.nextInt();\nboolean[] prime=new boolean[n];\nif(n>2){\nfor(int i=2;i2){\nfor(int i=2;i list = new ArrayList();\n\t\tInteger input;\n\t\t\n\t\ttry {\n\t\t\tint countInput = 0;\n\t\t\twhile (scanner.hasNextInt()){\n \tif (countInput >= 30) {break;}\n input = scanner.nextInt();\n \n \n if (input > 0 && input < 999999) {\n \tlist.add(input);\n }\n countInput++;\n }\n\t\t}catch (Exception e) {\n \tSystem.err.println(\"wrong format\");\n \n } finally {\n scanner.close();\n }\n\t\t\n\t\t\n\t\tint prime,num,div;\n\t\tfor (Integer inputList : list) {\n\t\t\tnum = inputList.intValue();\n\t\t\tprime = 1;\n\t\t\tfor (int i = 3; i <= num; i+=2) {\n\t\t\t\tdiv = 0;\n\t\t\t\tfor (int j = 2; j < i; j++) {\n\t\t\t\t\tif (j > 11) {break;}\n\t\t\t\t\tif (i % j == 0) {\n\t\t\t\t\t\tdiv++;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (div == 0) {\n\t\t\t\t\tprime++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tSystem.out.println(prime);\n\t\t}\n\t\t\n\t}\n}", "language": "Java", "metadata": {"date": 1458229420, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00009.html", "problem_id": "p00009", "resource_group": "high_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/Java/s056504814.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s056504814", "user_id": "u976937698"}, "prompt_components": {"gold_output": "4\n2\n5\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.List;\nimport java.util.Scanner;\n\nclass Main{\n\tpublic static void main(String[] a){\n\t\tScanner scanner = new Scanner(System.in);\n\t\tList list = new ArrayList();\n\t\tInteger input;\n\t\t\n\t\ttry {\n\t\t\tint countInput = 0;\n\t\t\twhile (scanner.hasNextInt()){\n \tif (countInput >= 30) {break;}\n input = scanner.nextInt();\n \n \n if (input > 0 && input < 999999) {\n \tlist.add(input);\n }\n countInput++;\n }\n\t\t}catch (Exception e) {\n \tSystem.err.println(\"wrong format\");\n \n } finally {\n scanner.close();\n }\n\t\t\n\t\t\n\t\tint prime,num,div;\n\t\tfor (Integer inputList : list) {\n\t\t\tnum = inputList.intValue();\n\t\t\tprime = 1;\n\t\t\tfor (int i = 3; i <= num; i+=2) {\n\t\t\t\tdiv = 0;\n\t\t\t\tfor (int j = 2; j < i; j++) {\n\t\t\t\t\tif (j > 11) {break;}\n\t\t\t\t\tif (i % j == 0) {\n\t\t\t\t\t\tdiv++;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (div == 0) {\n\t\t\t\t\tprime++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tSystem.out.println(prime);\n\t\t}\n\t\t\n\t}\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": 1078, "cpu_time_ms": 80, "memory_kb": 27472}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s454808681", "group_id": "codeNet:p00009", "input_text": "import java.util.Scanner;\npublic class Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\twhile(sc.hasNext()){\n\t\t\tint p = sc.nextInt();\n\t\t\tint so=1;\n\t\t\tfor(int i=2; i<=p; i++){\n\t\t\t\tint han =0;\n\t\t\t\tfor(int j=2; j<=i-1; j++){\n\t\t\t\t\tif(i%j == 0){\n\t\t\t\t\t\than = 1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(han != 1){\n\t\t\t\t\tso++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.println(so-1);\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1473476168, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00009.html", "problem_id": "p00009", "resource_group": "high_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/Java/s454808681.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s454808681", "user_id": "u787447215"}, "prompt_components": {"gold_output": "4\n2\n5\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\twhile(sc.hasNext()){\n\t\t\tint p = sc.nextInt();\n\t\t\tint so=1;\n\t\t\tfor(int i=2; i<=p; i++){\n\t\t\t\tint han =0;\n\t\t\t\tfor(int j=2; j<=i-1; j++){\n\t\t\t\t\tif(i%j == 0){\n\t\t\t\t\t\than = 1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(han != 1){\n\t\t\t\t\tso++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.println(so-1);\n\t\t}\n\t}\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": 398, "cpu_time_ms": 20000, "memory_kb": 26356}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s953951929", "group_id": "codeNet:p00009", "input_text": "import java.util.Scanner;\npublic class Main {\n\tpublic static void main(String args[]){\n\t\tint t=0,i,j,count=0;\n\t\tint lim;\n\t\tint[] x = new int[30];\n\t\tScanner scan = new Scanner(System.in);\n\t\t\n\t\twhile(scan.hasNextInt()){\n\t\t\tlim = scan.nextInt();\n\t\t\tcount = 0;\n\t\t\tif(lim >= 2)count++;\n\t\t\t\n\t\t\tfor(i=3;i<=lim;i=i+2){\n\t\t\t\tfor(j=3;j<=lim;j = j+2){\n\t\t\t\t\tint k = i % j;\n\t\t\t\t\tif(j == i){\n\t\t\t\t\t\tcount++;\n\t\t\t\t\t}\n\t\t\t\t\tif(k == 0)break;\n\t\t\t\t}\n\t\t\t}\n\t\tSystem.out.println(count);\n\t\t\tx[t] = count;\n\t\t\tt++;\n\t\t}\n\t\t\n\t\tfor(int s : x){\n\t\t\tSystem.out.println(s);\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1496817256, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00009.html", "problem_id": "p00009", "resource_group": "high_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/Java/s953951929.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s953951929", "user_id": "u797963216"}, "prompt_components": {"gold_output": "4\n2\n5\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main {\n\tpublic static void main(String args[]){\n\t\tint t=0,i,j,count=0;\n\t\tint lim;\n\t\tint[] x = new int[30];\n\t\tScanner scan = new Scanner(System.in);\n\t\t\n\t\twhile(scan.hasNextInt()){\n\t\t\tlim = scan.nextInt();\n\t\t\tcount = 0;\n\t\t\tif(lim >= 2)count++;\n\t\t\t\n\t\t\tfor(i=3;i<=lim;i=i+2){\n\t\t\t\tfor(j=3;j<=lim;j = j+2){\n\t\t\t\t\tint k = i % j;\n\t\t\t\t\tif(j == i){\n\t\t\t\t\t\tcount++;\n\t\t\t\t\t}\n\t\t\t\t\tif(k == 0)break;\n\t\t\t\t}\n\t\t\t}\n\t\tSystem.out.println(count);\n\t\t\tx[t] = count;\n\t\t\tt++;\n\t\t}\n\t\t\n\t\tfor(int s : x){\n\t\t\tSystem.out.println(s);\n\t\t}\n\t}\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": 545, "cpu_time_ms": 20000, "memory_kb": 26376}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s250875144", "group_id": "codeNet:p00011", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main (String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint w = sc.nextInt();\n\t\tint n = sc.nextInt();\n\t\tint[] num = new int[w];\n\t\tfor(int i = 0; i < w; i++) {\n\t\t\tnum[i] = i + 1;\n\t\t}\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString str = sc.next();\n\t\t\tString[] ab = str.split(\",\");\n\t\t\tint a = Integer.parseInt(ab[0]) -1;\n\t\t\tint b = Integer.parseInt(ab[1]) -1;\n\t\t\t// swap\n\t\t\tint tmp = num[a];\n\t\t\tnum[a] = num[b];\n\t\t\tnum[b] = tmp; \n\t\t}\n\t\tfor(int i = 0; i < w; i++) {\n\t\t\tSystem.out.println(num[i]);\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1494224698, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00011.html", "problem_id": "p00011", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00011/input.txt", "sample_output_relpath": "derived/input_output/data/p00011/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00011/Java/s250875144.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s250875144", "user_id": "u127865499"}, "prompt_components": {"gold_output": "4\n1\n2\n5\n3\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main (String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint w = sc.nextInt();\n\t\tint n = sc.nextInt();\n\t\tint[] num = new int[w];\n\t\tfor(int i = 0; i < w; i++) {\n\t\t\tnum[i] = i + 1;\n\t\t}\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString str = sc.next();\n\t\t\tString[] ab = str.split(\",\");\n\t\t\tint a = Integer.parseInt(ab[0]) -1;\n\t\t\tint b = Integer.parseInt(ab[1]) -1;\n\t\t\t// swap\n\t\t\tint tmp = num[a];\n\t\t\tnum[a] = num[b];\n\t\t\tnum[b] = tmp; \n\t\t}\n\t\tfor(int i = 0; i < w; i++) {\n\t\t\tSystem.out.println(num[i]);\n\t\t}\n\t}\n}", "problem_context": "Drawing Lots\n\nLet's play Amidakuji.\n\nIn the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.\n\nIn the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain \"4 1 2 5 3\" in the bottom.\n\nYour task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., w are assigne to the vertical lines from left to right.\n\nInput\n\nw\nn\na1,b1\na2,b2\n.\n.\nan,bn\n\nw (w ≤ 30) is the number of vertical lines. n (n ≤ 30) is the number of horizontal lines. A pair of two integers ai and bi delimited by a comma represents the i-th horizontal line.\n\nOutput\n\nThe number which should be under the 1st (leftmost) vertical line\n\nThe number which should be under the 2nd vertical line\n\n:\n\nThe number which should be under the w-th vertical line\n\nSample Input\n\n5\n4\n2,4\n3,5\n1,2\n3,4\n\nOutput for the Sample Input\n\n4\n1\n2\n5\n3", "sample_input": "5\n4\n2,4\n3,5\n1,2\n3,4\n"}, "reference_outputs": ["4\n1\n2\n5\n3\n"], "source_document_id": "p00011", "source_text": "Drawing Lots\n\nLet's play Amidakuji.\n\nIn the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.\n\nIn the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain \"4 1 2 5 3\" in the bottom.\n\nYour task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., w are assigne to the vertical lines from left to right.\n\nInput\n\nw\nn\na1,b1\na2,b2\n.\n.\nan,bn\n\nw (w ≤ 30) is the number of vertical lines. n (n ≤ 30) is the number of horizontal lines. A pair of two integers ai and bi delimited by a comma represents the i-th horizontal line.\n\nOutput\n\nThe number which should be under the 1st (leftmost) vertical line\n\nThe number which should be under the 2nd vertical line\n\n:\n\nThe number which should be under the w-th vertical line\n\nSample Input\n\n5\n4\n2,4\n3,5\n1,2\n3,4\n\nOutput for the Sample Input\n\n4\n1\n2\n5\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": 571, "cpu_time_ms": 50, "memory_kb": 26200}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s326403873", "group_id": "codeNet:p00014", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tprivate Scanner sc;\n\t\n\tpublic static void main(String[] args) {\n\t\tnew Main();\n\t}\n\t\n\tpublic Main() {\n\t\tsc = new Scanner(System.in);\n\t\t\n\t\twhile (sc.hasNext() == true) {\n\t\t\tint d = Integer.parseInt(sc.next());\n\n\t\t\tint sum = 0;\n\t\t\tfor (int i = d; i < 600; i = i + d) {\n\t\t\t\tsum = sum + (int)Math.pow(i, 2) * d;\n\t\t\t}\n\t\t\tSystem.out.println(sum);\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1480315191, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00014.html", "problem_id": "p00014", "resource_group": "high_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/Java/s326403873.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s326403873", "user_id": "u491334076"}, "prompt_components": {"gold_output": "68440000\n70210000\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tprivate Scanner sc;\n\t\n\tpublic static void main(String[] args) {\n\t\tnew Main();\n\t}\n\t\n\tpublic Main() {\n\t\tsc = new Scanner(System.in);\n\t\t\n\t\twhile (sc.hasNext() == true) {\n\t\t\tint d = Integer.parseInt(sc.next());\n\n\t\t\tint sum = 0;\n\t\t\tfor (int i = d; i < 600; i = i + d) {\n\t\t\t\tsum = sum + (int)Math.pow(i, 2) * d;\n\t\t\t}\n\t\t\tSystem.out.println(sum);\n\t\t}\n\t}\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": 395, "cpu_time_ms": 50, "memory_kb": 25548}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s339892975", "group_id": "codeNet:p00014", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tScanner sc = new Scanner(System.in);\n\n\t\twhile (sc.hasNext()) {\n\t\t\tint d = sc.nextInt();\n\t\t\tSystem.out.println(integ(d));\n\t\t}\n\t}\n\n\tpublic static long integ(int d) {\n\t\tint x = d;\n\t\tlong ans = 0;\n\t\tdo {\n\t\t\tans += x*x * d;\n\t\t\tx = x + d;\n\t\t} while (x != 600);\n\t\treturn ans;\n\t}\n}", "language": "Java", "metadata": {"date": 1482817389, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00014.html", "problem_id": "p00014", "resource_group": "high_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/Java/s339892975.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s339892975", "user_id": "u938767283"}, "prompt_components": {"gold_output": "68440000\n70210000\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tScanner sc = new Scanner(System.in);\n\n\t\twhile (sc.hasNext()) {\n\t\t\tint d = sc.nextInt();\n\t\t\tSystem.out.println(integ(d));\n\t\t}\n\t}\n\n\tpublic static long integ(int d) {\n\t\tint x = d;\n\t\tlong ans = 0;\n\t\tdo {\n\t\t\tans += x*x * d;\n\t\t\tx = x + d;\n\t\t} while (x != 600);\n\t\treturn ans;\n\t}\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": 421, "cpu_time_ms": 410, "memory_kb": 26200}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s874238181", "group_id": "codeNet:p00017", "input_text": "import java.io.*;\n\npublic class Main{\n\tpublic static void main(String[] args) throws IOException{\n\t\ttry{\n\t InputStreamReader isr = new InputStreamReader(System.in);\n\t BufferedReader br = new BufferedReader(isr);\n\t String str;\n\t String target[];\n\t int checkResult = 99;\n\t int caesar;\n\t \n\t while( (str = br.readLine()) != null){\n\t \tcaesar = 0;\n\t \ttarget = str.split(\" \");\n\t\t for(int i = 0; i < target.length; i++){ \t\t\n\t \t\tcheckResult = checkPattern(target[i]);\n\t \t\tif(checkResult != 99){\n\t \t\t\tcaesar = checkResult;\n\t \t\t\tbreak;\n\t \t\t}\n\t \t}\n\t \n\t StringBuilder result = new StringBuilder();\n\t for(int i = 0; i < target.length; i++){\n\t \t result.append(makeCaeserString(target[i],caesar));\n\t \t result.append(\" \");\n\t } \n\t System.out.println(result);\t \t\n\t }\t \n\t\t}catch(Exception e){\n\t\t\tSystem.out.println(e);\n\t\t}\n\t}\n\n\tprivate static int checkPattern(String str){\n\t\t\n\t\tString target[];\n\t\ttarget = str.split(\"\\\\.\");\n\t\tint result = 99;\n\t\t\n\t\tfor(int i = 0; i < target.length; i++){\n\t\t\tresult = isThe(target[i]);\n\t\t\tif(result != 99) break;\n\t\t\tresult = isThis(target[i]);\n\t\t\tif(result != 99) break;\n\t\t\tresult = isThat(target[i]);\n\t\t\tif(result != 99) break;\n\t\t}\n\t\treturn result;\n\t}\n\t\n\tprivate static int isThe(String str){\n\t\t\n\t\tString newStr;\n\t\tString target = \"the\";\n\t\tint result = 99;\n\t\t\n\t\tif(str.length() != target.length()) return result;\n\t\t\n\t\tfor(int i = -26; i < 27; i++){\n\t\t\t//str.charAt(j)???str???j????????????????????????\n\t\t\tnewStr = String.valueOf((char)(str.charAt(0)+i))\n\t\t\t\t\t + String.valueOf((char)(str.charAt(1)+i))\n\t\t\t\t + String.valueOf((char)(str.charAt(2)+i));\n\t\t\t\n\t\t\tif( newStr.equals(target) ){\n\t\t\t\tresult = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\t\n\tprivate static int isThis(String str){\n\t\t\n\t\tString newStr;\n\t\tString target = \"this\";\n\t\tint result = 99;\n\t\t\n\t\tif(str.length() != target.length()) return result;\n\t\t\n\t\tfor(int i = -26; i < 27; i++){\n\t\t\t//str.charAt(j)???str???j????????????????????????\n\t\t\tnewStr = String.valueOf((char)(str.charAt(0)+i))\n\t\t\t\t\t + String.valueOf((char)(str.charAt(1)+i))\n\t\t\t\t + String.valueOf((char)(str.charAt(2)+i))\n\t\t\t + String.valueOf((char)(str.charAt(3)+i));\n\t\t\t\n\t\t\tif( newStr.equals(target) ){\n\t\t\t\tresult = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\t\n private static int isThat(String str){\n\t\n\tString newStr;\n\tString target = \"that\";\n\tint result = 99;\n\t\t\n\tif(str.length() != target.length()) return result;\n\t\n\tfor(int i = -26; i < 27; i++){\n\t\t//str.charAt(j)???str???j????????????????????????\n\t\tnewStr = String.valueOf((char)(str.charAt(0)+i))\n\t\t\t\t + String.valueOf((char)(str.charAt(1)+i))\n\t\t\t + String.valueOf((char)(str.charAt(2)+i))\n\t\t\t + String.valueOf((char)(str.charAt(3)+i));\n\t\t\n\t\tif( newStr.equals(target) ){\n\t\t\tresult = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn result;\n }\n \n private static String makeCaeserString(String str,int n){\n\t \n\t int intA = 'a';\n\t int intZ = 'z';\n\t int zure = 0;\n\t String result = \"\";\n\t \t \n\t for(int i = 0; i < str.length(); i++){\n\t\t if(str.charAt(i) intZ){\n\t\t\t return str;\n\t\t }else if( (str.charAt(i)) == \".\".charAt(0)){\n\t\t\t zure = -n;\n\t\t }else if( str.charAt(i) + n < intA ){\n\t\t\t zure = 26;\n\t\t }else if(str.charAt(i) + n > intZ){\n\t\t\t zure = -26;\n\t\t }\n\t\t result += String.valueOf((char)(str.charAt(i)+n+zure));\n\t zure = 0;\n\t }\n\t return result;\n }\n}", "language": "Java", "metadata": {"date": 1502977302, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00017.html", "problem_id": "p00017", "resource_group": "high_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/Java/s874238181.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s874238181", "user_id": "u732073438"}, "prompt_components": {"gold_output": "this is the picture that i took in the trip.\n", "input_to_evaluate": "import java.io.*;\n\npublic class Main{\n\tpublic static void main(String[] args) throws IOException{\n\t\ttry{\n\t InputStreamReader isr = new InputStreamReader(System.in);\n\t BufferedReader br = new BufferedReader(isr);\n\t String str;\n\t String target[];\n\t int checkResult = 99;\n\t int caesar;\n\t \n\t while( (str = br.readLine()) != null){\n\t \tcaesar = 0;\n\t \ttarget = str.split(\" \");\n\t\t for(int i = 0; i < target.length; i++){ \t\t\n\t \t\tcheckResult = checkPattern(target[i]);\n\t \t\tif(checkResult != 99){\n\t \t\t\tcaesar = checkResult;\n\t \t\t\tbreak;\n\t \t\t}\n\t \t}\n\t \n\t StringBuilder result = new StringBuilder();\n\t for(int i = 0; i < target.length; i++){\n\t \t result.append(makeCaeserString(target[i],caesar));\n\t \t result.append(\" \");\n\t } \n\t System.out.println(result);\t \t\n\t }\t \n\t\t}catch(Exception e){\n\t\t\tSystem.out.println(e);\n\t\t}\n\t}\n\n\tprivate static int checkPattern(String str){\n\t\t\n\t\tString target[];\n\t\ttarget = str.split(\"\\\\.\");\n\t\tint result = 99;\n\t\t\n\t\tfor(int i = 0; i < target.length; i++){\n\t\t\tresult = isThe(target[i]);\n\t\t\tif(result != 99) break;\n\t\t\tresult = isThis(target[i]);\n\t\t\tif(result != 99) break;\n\t\t\tresult = isThat(target[i]);\n\t\t\tif(result != 99) break;\n\t\t}\n\t\treturn result;\n\t}\n\t\n\tprivate static int isThe(String str){\n\t\t\n\t\tString newStr;\n\t\tString target = \"the\";\n\t\tint result = 99;\n\t\t\n\t\tif(str.length() != target.length()) return result;\n\t\t\n\t\tfor(int i = -26; i < 27; i++){\n\t\t\t//str.charAt(j)???str???j????????????????????????\n\t\t\tnewStr = String.valueOf((char)(str.charAt(0)+i))\n\t\t\t\t\t + String.valueOf((char)(str.charAt(1)+i))\n\t\t\t\t + String.valueOf((char)(str.charAt(2)+i));\n\t\t\t\n\t\t\tif( newStr.equals(target) ){\n\t\t\t\tresult = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\t\n\tprivate static int isThis(String str){\n\t\t\n\t\tString newStr;\n\t\tString target = \"this\";\n\t\tint result = 99;\n\t\t\n\t\tif(str.length() != target.length()) return result;\n\t\t\n\t\tfor(int i = -26; i < 27; i++){\n\t\t\t//str.charAt(j)???str???j????????????????????????\n\t\t\tnewStr = String.valueOf((char)(str.charAt(0)+i))\n\t\t\t\t\t + String.valueOf((char)(str.charAt(1)+i))\n\t\t\t\t + String.valueOf((char)(str.charAt(2)+i))\n\t\t\t + String.valueOf((char)(str.charAt(3)+i));\n\t\t\t\n\t\t\tif( newStr.equals(target) ){\n\t\t\t\tresult = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\t\n private static int isThat(String str){\n\t\n\tString newStr;\n\tString target = \"that\";\n\tint result = 99;\n\t\t\n\tif(str.length() != target.length()) return result;\n\t\n\tfor(int i = -26; i < 27; i++){\n\t\t//str.charAt(j)???str???j????????????????????????\n\t\tnewStr = String.valueOf((char)(str.charAt(0)+i))\n\t\t\t\t + String.valueOf((char)(str.charAt(1)+i))\n\t\t\t + String.valueOf((char)(str.charAt(2)+i))\n\t\t\t + String.valueOf((char)(str.charAt(3)+i));\n\t\t\n\t\tif( newStr.equals(target) ){\n\t\t\tresult = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn result;\n }\n \n private static String makeCaeserString(String str,int n){\n\t \n\t int intA = 'a';\n\t int intZ = 'z';\n\t int zure = 0;\n\t String result = \"\";\n\t \t \n\t for(int i = 0; i < str.length(); i++){\n\t\t if(str.charAt(i) intZ){\n\t\t\t return str;\n\t\t }else if( (str.charAt(i)) == \".\".charAt(0)){\n\t\t\t zure = -n;\n\t\t }else if( str.charAt(i) + n < intA ){\n\t\t\t zure = 26;\n\t\t }else if(str.charAt(i) + n > intZ){\n\t\t\t zure = -26;\n\t\t }\n\t\t result += String.valueOf((char)(str.charAt(i)+n+zure));\n\t zure = 0;\n\t }\n\t return result;\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": 3522, "cpu_time_ms": 30, "memory_kb": 24712}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s813532592", "group_id": "codeNet:p00018", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\n\t\tBufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString[] \tarrNbrLstStr = bufferedReader.readLine().split(\" \");\n\t\tint[] \t\tarrNbrLst = new int[arrNbrLstStr.length];\n\n\t\tfor(int i = 0; i < arrNbrLst.length; i++) arrNbrLst[i] = Integer.parseInt(arrNbrLstStr[i]);\n\n\t\tfor(int i = 0; i < arrNbrLst.length - 1; i++) {\n\t\t\tfor(int j = i + 1; j < arrNbrLst.length; j++) {\n\t\t\t\tif(arrNbrLst[i] < arrNbrLst[j]) {\n\t\t\t\t\tint tmp = arrNbrLst[i];\n\t\t\t\t\tarrNbrLst[i] = arrNbrLst[j];\n\t\t\t\t\tarrNbrLst[j] = tmp;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor(int val : arrNbrLst) System.out.print(val + \" \");\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1551422503, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00018.html", "problem_id": "p00018", "resource_group": "high_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/Java/s813532592.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s813532592", "user_id": "u952169663"}, "prompt_components": {"gold_output": "9 7 6 5 3\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\n\t\tBufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString[] \tarrNbrLstStr = bufferedReader.readLine().split(\" \");\n\t\tint[] \t\tarrNbrLst = new int[arrNbrLstStr.length];\n\n\t\tfor(int i = 0; i < arrNbrLst.length; i++) arrNbrLst[i] = Integer.parseInt(arrNbrLstStr[i]);\n\n\t\tfor(int i = 0; i < arrNbrLst.length - 1; i++) {\n\t\t\tfor(int j = i + 1; j < arrNbrLst.length; j++) {\n\t\t\t\tif(arrNbrLst[i] < arrNbrLst[j]) {\n\t\t\t\t\tint tmp = arrNbrLst[i];\n\t\t\t\t\tarrNbrLst[i] = arrNbrLst[j];\n\t\t\t\t\tarrNbrLst[j] = tmp;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor(int val : arrNbrLst) System.out.print(val + \" \");\n\t}\n\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": 784, "cpu_time_ms": 30, "memory_kb": 24076}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s475415267", "group_id": "codeNet:p00021", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner stdIn = new Scanner(System.in);\n\t\tint n = stdIn.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tdouble[] xy = new double[8];\n\t\t\tfor (int j = 0; j < 8; j++) {\n\t\t\t\txy[j] = stdIn.nextDouble();\n\t\t\t}\n\t\t\tdouble m = (xy[2] - xy[0]) * (xy[7] - xy[5]) - (xy[3] - xy[1]) * (xy[6] - xy[4]);\n\t\t\tif(m==0){\n\t\t\t\tSystem.out.println(\"YES\");\n\t\t\t}\n\t\t\telse{\n\t\t\t\tSystem.out.println(\"NO\");\n\t\t\t}\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1441963352, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00021.html", "problem_id": "p00021", "resource_group": "high_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/Java/s475415267.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s475415267", "user_id": "u705416268"}, "prompt_components": {"gold_output": "YES\nNO\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner stdIn = new Scanner(System.in);\n\t\tint n = stdIn.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tdouble[] xy = new double[8];\n\t\t\tfor (int j = 0; j < 8; j++) {\n\t\t\t\txy[j] = stdIn.nextDouble();\n\t\t\t}\n\t\t\tdouble m = (xy[2] - xy[0]) * (xy[7] - xy[5]) - (xy[3] - xy[1]) * (xy[6] - xy[4]);\n\t\t\tif(m==0){\n\t\t\t\tSystem.out.println(\"YES\");\n\t\t\t}\n\t\t\telse{\n\t\t\t\tSystem.out.println(\"NO\");\n\t\t\t}\n\t\t}\n\t}\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": 479, "cpu_time_ms": 100, "memory_kb": 23240}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s897044014", "group_id": "codeNet:p00022", "input_text": "import java.io.*;\nimport java.math.BigInteger;\nimport java.util.*;\n\nclass Main {\n\t\n\tpublic static int maxCalc (int[] nums) {\n\t\t\n\t\tint max = Integer.MIN_VALUE;\n\t\tint sum = 0;\n\t\t\n\t\t// いくつ連続でとるか\n\t\tfor (int i = 1; i <= nums.length; i++) {\n\t\t\t\n\t\t\t// どこから取り始めるか\n\t\t\tfor (int j = 0; j < nums.length - i + 1; j++) {\n\t\t\t\t\n\t\t\t\tsum = 0;\n\t\t\t\tint cnt = 0;\n\t\t\t\t\n\t\t\t\t// 取った数がiになるまで繰り返し\n\t\t\t\tfor (int k = j; cnt < i; k++,cnt++) {\n\t\t\t\t\tsum += nums[k];\n\t\t\t\t}\n\t\t\t\tmax = Math.max(sum, max);\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t}\n\t\treturn max;\n\t\t\n\t}\n\t\n\tpublic static void main(String[] args) throws IOException {\n\n\t\tBufferedReader br =\n\t\t\tnew BufferedReader(new InputStreamReader(System.in));\n\t\t\n\t\tArrayList ans = new ArrayList();\n\t\t\n\t\twhile (true) {\n\t\t\t\n\t\t\tint n = Integer.parseInt(br.readLine());\n\t\t\tif (n == 0) break;\n\t\t\tint[] nums = new int[n];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\tnums[i] = Integer.parseInt(br.readLine());\n\t\t\tans.add(maxCalc(nums));\n\t\t\t\n\t\t}\n\t\t\n\t\tfor (int a : ans) {\n\t\t\tSystem.out.println(a);\n\t\t}\n\t\t\n\t}\n\n}", "language": "Java", "metadata": {"date": 1352348261, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00022.html", "problem_id": "p00022", "resource_group": "high_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/Java/s897044014.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s897044014", "user_id": "u079104535"}, "prompt_components": {"gold_output": "19\n14\n1001\n", "input_to_evaluate": "import java.io.*;\nimport java.math.BigInteger;\nimport java.util.*;\n\nclass Main {\n\t\n\tpublic static int maxCalc (int[] nums) {\n\t\t\n\t\tint max = Integer.MIN_VALUE;\n\t\tint sum = 0;\n\t\t\n\t\t// いくつ連続でとるか\n\t\tfor (int i = 1; i <= nums.length; i++) {\n\t\t\t\n\t\t\t// どこから取り始めるか\n\t\t\tfor (int j = 0; j < nums.length - i + 1; j++) {\n\t\t\t\t\n\t\t\t\tsum = 0;\n\t\t\t\tint cnt = 0;\n\t\t\t\t\n\t\t\t\t// 取った数がiになるまで繰り返し\n\t\t\t\tfor (int k = j; cnt < i; k++,cnt++) {\n\t\t\t\t\tsum += nums[k];\n\t\t\t\t}\n\t\t\t\tmax = Math.max(sum, max);\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t}\n\t\treturn max;\n\t\t\n\t}\n\t\n\tpublic static void main(String[] args) throws IOException {\n\n\t\tBufferedReader br =\n\t\t\tnew BufferedReader(new InputStreamReader(System.in));\n\t\t\n\t\tArrayList ans = new ArrayList();\n\t\t\n\t\twhile (true) {\n\t\t\t\n\t\t\tint n = Integer.parseInt(br.readLine());\n\t\t\tif (n == 0) break;\n\t\t\tint[] nums = new int[n];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\tnums[i] = Integer.parseInt(br.readLine());\n\t\t\tans.add(maxCalc(nums));\n\t\t\t\n\t\t}\n\t\t\n\t\tfor (int a : ans) {\n\t\t\tSystem.out.println(a);\n\t\t}\n\t\t\n\t}\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": 1066, "cpu_time_ms": 4820, "memory_kb": 11000}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s901825714", "group_id": "codeNet:p00022", "input_text": "import java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.Scanner;\n\n\npublic class Main {\n\tpublic static void main(String[] args)throws IOException{\n\t\tScanner scan = null;\n\t\ttry{\n\t\t\tscan = new Scanner(new InputStreamReader(System.in));\n\t\t\twhile(scan.hasNext()){\n\t\t\t\tint n = scan.nextInt();\n\t\t\t\tif(n == 0)break;\n\t\t\t\tint max;\n\t\t\t\tList dataset = new ArrayList();\n\t\t\t\tdataset.add(max = scan.nextInt());\n\t\t\t\tfor(int i = 1;i dataset = new ArrayList();\n\t\t\t\tdataset.add(max = scan.nextInt());\n\t\t\t\tfor(int i = 1;i ai = new ArrayList();\n\t\t\tList bi = new ArrayList();\n\n\t\t\tfor(int i=0;i<4;i++) ai.add(in.nextInt());\n\t\t\tfor(int i=0;i<4;i++) bi.add(in.nextInt());\n\n\t\t\tMap hit = new HashMap();\n\t\t\tfor(int i=0;i<4;i++) {\n\t\t\t\tif(ai.get(i) == bi.get(i)) {\n\t\t\t\t\thit.put(ai.get(i), 1);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tint blow = 0;\n\t\t\tfor(int i=0;i<4;i++) {\n\t\t\t\tif(hit.containsKey(bi.get(i)) == false && ai.contains(bi.get(i))) {\n\t\t\t\t\tblow++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.println(String.format(\"%d %d\",hit.size(),blow));\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1475078765, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00025.html", "problem_id": "p00025", "resource_group": "high_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/Java/s908244997.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s908244997", "user_id": "u496767920"}, "prompt_components": {"gold_output": "1 1\n3 0\n", "input_to_evaluate": "import java.io.IOException;\nimport java.util.*;\n\n/**\n */\nclass Main {\n\tpublic static void main(String[] args) throws IOException {\n\t\tScanner in = new Scanner(System.in);\n\n\t\twhile(in.hasNext()) {\n\t\t\tList ai = new ArrayList();\n\t\t\tList bi = new ArrayList();\n\n\t\t\tfor(int i=0;i<4;i++) ai.add(in.nextInt());\n\t\t\tfor(int i=0;i<4;i++) bi.add(in.nextInt());\n\n\t\t\tMap hit = new HashMap();\n\t\t\tfor(int i=0;i<4;i++) {\n\t\t\t\tif(ai.get(i) == bi.get(i)) {\n\t\t\t\t\thit.put(ai.get(i), 1);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tint blow = 0;\n\t\t\tfor(int i=0;i<4;i++) {\n\t\t\t\tif(hit.containsKey(bi.get(i)) == false && ai.contains(bi.get(i))) {\n\t\t\t\t\tblow++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.println(String.format(\"%d %d\",hit.size(),blow));\n\t\t}\n\t}\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": 758, "cpu_time_ms": 70, "memory_kb": 25920}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s509987133", "group_id": "codeNet:p00026", "input_text": "import java.util.HashMap;\nimport java.util.Map;\nimport java.util.Scanner;\n\npublic class Main {\n\n private static final Map dropMode;\n\n static {\n dropMode = new HashMap();\n dropMode.put(1, new DropModeStar(1));\n dropMode.put(2, new DropModeSquare(1));\n dropMode.put(3, new DropModeStar(2));\n }\n\n public static void main(String[] args) {\n try {\n int[][] field = new int[10][10];\n\n Scanner sc = new Scanner(System.in);\n\n while (sc.hasNext()) {\n String[] arguments = sc.next().split(\",\");\n int x = Integer.valueOf(arguments[0]);\n int y = Integer.valueOf(arguments[1]);\n int size = Integer.valueOf(arguments[2]);\n\n dropMode.get(size).drop(field, x, y);\n }\n\n System.out.println(getWhiteCells(field));\n System.out.println(getMostDropped(field));\n\n } catch (Exception e) {\n e.printStackTrace();\n System.exit(0);\n }\n\n }\n\n private static int getWhiteCells(int[][] field) {\n int result = 0;\n for (int[] row : field) {\n for (int cell : row) {\n if (cell == 0) {\n result++;\n }\n }\n }\n return result;\n }\n\n private static int getMostDropped(int[][] field) {\n int result = 0;\n for (int[] row : field) {\n for (int cell : row) {\n if (cell > result) {\n result = cell;\n }\n }\n }\n return result;\n }\n\n private static abstract class DropMode {\n protected int size;\n\n public DropMode(int size) {\n this.size = size;\n }\n\n public abstract void drop(int[][] field, int x, int y);\n }\n\n /** x + y = ±sizeにDrop */\n private static class DropModeStar extends DropMode {\n public DropModeStar(int size) {\n super(size);\n }\n\n @Override\n public void drop(int[][] field, int x, int y) {\n for (int oy = -1 * this.size; oy <= this.size; oy++) {\n if (y + oy < 0 || y + oy > 9) {\n continue;\n }\n\n for (int ox = -1 * (this.size - Math.abs(oy)); ox <= (this.size - Math\n .abs(oy)); ox++) {\n if (x + ox < 0 || x + ox > 9) {\n continue;\n }\n\n field[y + oy][x + ox]++;\n }\n }\n }\n }\n\n /** x = ±size, y = ±sizeにDrop */\n private static class DropModeSquare extends DropMode {\n public DropModeSquare(int size) {\n super(size);\n }\n\n @Override\n public void drop(int[][] field, int x, int y) {\n for (int oy = -1 * this.size; oy <= this.size; oy++) {\n if (y + oy < 0 || y + oy > 9) {\n continue;\n }\n\n for (int ox = -1 * this.size; ox <= this.size; ox++) {\n if (x + ox < 0 || x + ox > 9) {\n continue;\n }\n\n field[y + oy][x + ox]++;\n }\n }\n }\n }\n\n}", "language": "Java", "metadata": {"date": 1427108348, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00026.html", "problem_id": "p00026", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00026/input.txt", "sample_output_relpath": "derived/input_output/data/p00026/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00026/Java/s509987133.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s509987133", "user_id": "u340523328"}, "prompt_components": {"gold_output": "77\n5\n", "input_to_evaluate": "import java.util.HashMap;\nimport java.util.Map;\nimport java.util.Scanner;\n\npublic class Main {\n\n private static final Map dropMode;\n\n static {\n dropMode = new HashMap();\n dropMode.put(1, new DropModeStar(1));\n dropMode.put(2, new DropModeSquare(1));\n dropMode.put(3, new DropModeStar(2));\n }\n\n public static void main(String[] args) {\n try {\n int[][] field = new int[10][10];\n\n Scanner sc = new Scanner(System.in);\n\n while (sc.hasNext()) {\n String[] arguments = sc.next().split(\",\");\n int x = Integer.valueOf(arguments[0]);\n int y = Integer.valueOf(arguments[1]);\n int size = Integer.valueOf(arguments[2]);\n\n dropMode.get(size).drop(field, x, y);\n }\n\n System.out.println(getWhiteCells(field));\n System.out.println(getMostDropped(field));\n\n } catch (Exception e) {\n e.printStackTrace();\n System.exit(0);\n }\n\n }\n\n private static int getWhiteCells(int[][] field) {\n int result = 0;\n for (int[] row : field) {\n for (int cell : row) {\n if (cell == 0) {\n result++;\n }\n }\n }\n return result;\n }\n\n private static int getMostDropped(int[][] field) {\n int result = 0;\n for (int[] row : field) {\n for (int cell : row) {\n if (cell > result) {\n result = cell;\n }\n }\n }\n return result;\n }\n\n private static abstract class DropMode {\n protected int size;\n\n public DropMode(int size) {\n this.size = size;\n }\n\n public abstract void drop(int[][] field, int x, int y);\n }\n\n /** x + y = ±sizeにDrop */\n private static class DropModeStar extends DropMode {\n public DropModeStar(int size) {\n super(size);\n }\n\n @Override\n public void drop(int[][] field, int x, int y) {\n for (int oy = -1 * this.size; oy <= this.size; oy++) {\n if (y + oy < 0 || y + oy > 9) {\n continue;\n }\n\n for (int ox = -1 * (this.size - Math.abs(oy)); ox <= (this.size - Math\n .abs(oy)); ox++) {\n if (x + ox < 0 || x + ox > 9) {\n continue;\n }\n\n field[y + oy][x + ox]++;\n }\n }\n }\n }\n\n /** x = ±size, y = ±sizeにDrop */\n private static class DropModeSquare extends DropMode {\n public DropModeSquare(int size) {\n super(size);\n }\n\n @Override\n public void drop(int[][] field, int x, int y) {\n for (int oy = -1 * this.size; oy <= this.size; oy++) {\n if (y + oy < 0 || y + oy > 9) {\n continue;\n }\n\n for (int ox = -1 * this.size; ox <= this.size; ox++) {\n if (x + ox < 0 || x + ox > 9) {\n continue;\n }\n\n field[y + oy][x + ox]++;\n }\n }\n }\n }\n\n}", "problem_context": "Dropping Ink\n\nAs shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (x, y) coordinate system.\n\nWe are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells.\n\nOriginally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells.\n\nFor example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side):\n\nIn the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point.\n\nYour task is to write a program which reads a sequence of points of fall (x, y) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density.\n\nYou may assume that the paper always consists of 10 × 10, and 0 ≤ x < 10, 0 ≤ y < 10.\n\nInput\n\nx1,y1,s1\nx2,y2,s2\n:\n:\n\n(xi, yi) represents the position of the i-th drop and si denotes its size. The number of drops is less than or equal to 50.\n\nOutput\n\nPrint the number of cells whose density value is 0 in first line.\n\nPrint the maximum value of density in the second line.\n\nSample Input\n\n2,5,3\n3,6,1\n3,4,2\n4,5,2\n3,6,3\n2,4,1\n\nOutput for the Sample Input\n\n77\n5", "sample_input": "2,5,3\n3,6,1\n3,4,2\n4,5,2\n3,6,3\n2,4,1\n"}, "reference_outputs": ["77\n5\n"], "source_document_id": "p00026", "source_text": "Dropping Ink\n\nAs shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (x, y) coordinate system.\n\nWe are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells.\n\nOriginally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells.\n\nFor example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side):\n\nIn the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point.\n\nYour task is to write a program which reads a sequence of points of fall (x, y) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density.\n\nYou may assume that the paper always consists of 10 × 10, and 0 ≤ x < 10, 0 ≤ y < 10.\n\nInput\n\nx1,y1,s1\nx2,y2,s2\n:\n:\n\n(xi, yi) represents the position of the i-th drop and si denotes its size. The number of drops is less than or equal to 50.\n\nOutput\n\nPrint the number of cells whose density value is 0 in first line.\n\nPrint the maximum value of density in the second line.\n\nSample Input\n\n2,5,3\n3,6,1\n3,4,2\n4,5,2\n3,6,3\n2,4,1\n\nOutput for the Sample Input\n\n77\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": 3305, "cpu_time_ms": 40, "memory_kb": 17384}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s095593170", "group_id": "codeNet:p00032", "input_text": "import java.util.Scanner;\n\nclass Main{\n\tpublic static void main(String[] args) {\n\t\tScanner sc=new Scanner(System.in);\n\t\tString str=\"\";\n\t\tString[] stck=new String[3];\n\t\tint[] matome=new int[3];\n\t\tint hen3=0;\n\t\tint c_ks=0;\n\t\tint h_ks=0;\n\n\t\tint[] cyouhou_kake=new int[100];\n\t\tint[] cyouhou_tasu=new int[100];\n\t\tint[] cyouhou_kosu=new int[100];\n\t\tint[] heikshn_kake=new int[100];\n\t\tint[] heikshn_tasu=new int[100];\n\t\tint[] heikshn_kosu=new int[100];\n\n\t\tboolean add=false;\n\n\t\twhile(sc.hasNext()) {\n\t\t//for(int aa=0; aa<4; aa++){\n\t\t\then3=0;\n\t\t\tstr=sc.next();\n\t\t\tstck=str.split(\",\");\n\t\t\tfor(int i=0; i<3; i++) {\n\t\t\t\tmatome[i]=Integer.parseInt(stck[i]);\n\t\t\t\then3+=matome[i];\n\t\t\t}\n\n\t\t\tint a,b,c;\n\t\t\ta=Math.max(Math.max(matome[0], matome[1]), matome[2]);\n\t\t\tb=Math.min(Math.min(matome[0], matome[1]), matome[2]);\n\t\t\tc=hen3-a-b;\n\t\t\t//System.out.println(a+\" \"+b+\" \"+c);\n\n\t\t\tif(a*a==b*b+c*c) {\n\t\t\t\tif(c_ks==0) {\n\t\t\t\t\tcyouhou_kake[0]=a*c*b;\n\t\t\t\t\tcyouhou_tasu[0]=a+c+b;\n\t\t\t\t\tcyouhou_kosu[0]=1;\n\t\t\t\t\tc_ks++;\n\t\t\t\t\tadd=true;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tfor(int i=0; i ci)。データの数は 100 件を超えません。\n\nOutput\n\n1行目に長方形の製造個数、2行目ひし形の製造個数を出力します。\n\nSample Input\n\n3,4,5\n5,5,8\n4,4,4\n5,4,3\n\nOutput for the Sample Input\n\n1\n2", "sample_input": "3,4,5\n5,5,8\n4,4,4\n5,4,3\n"}, "reference_outputs": ["1\n2\n"], "source_document_id": "p00032", "source_text": "プラスティック板\n\n機械に辺・対角線の長さのデータを入力し、プラスティック板の型抜きをしている工場があります。この工場では、サイズは様々ですが、平行四辺形の型のみを切り出しています。あなたは、切り出される平行四辺形のうち、長方形とひし形の製造個数を数えるように上司から命じられました。\n\n「機械に入力するデータ」を読み込んで、長方形とひし形の製造個数を出力するプログラムを作成してください。\n\nInput\n\n入力は以下の形式で与えられます。\n\na1,b1,c1\na2,b2,c2\n:\n\n機械に入力するデータが複数行に与えられます。i 行目に i 番目の平行四辺形の隣り合う2辺の長さを表す整数 ai, bi と対角線の長さを表す整数 ci がカンマ区切りで与えられます (1 ≤ ai, bi, ci ≤ 1000, ai + bi > ci)。データの数は 100 件を超えません。\n\nOutput\n\n1行目に長方形の製造個数、2行目ひし形の製造個数を出力します。\n\nSample Input\n\n3,4,5\n5,5,8\n4,4,4\n5,4,3\n\nOutput for the Sample Input\n\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": 2043, "cpu_time_ms": 50, "memory_kb": 25968}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s545058519", "group_id": "codeNet:p00033", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tint n = 0;\n\t\tScanner scan = new Scanner(System.in);\n\t\tn = scan.nextInt();\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tint left = Integer.MIN_VALUE, right = Integer.MIN_VALUE;\n\t\t\tboolean isCorrect = true;\n\n\t\t\tfor(int j = 0; j < 10; j++) {\n\t\t\t\tint ball = scan.nextInt();\n\t\t\t\tif(ball > left) {\n\t\t\t\t\tleft = ball;\n\t\t\t\t} else if(ball > right) {\n\t\t\t\t\tright = ball;\n\t\t\t\t} else {\n\t\t\t\t\tisCorrect = false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tSystem.out.println(isCorrect ? \"YES\" : \"NO\");\n\t\t}\n\n\t\tscan.close();\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1578370692, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00033.html", "problem_id": "p00033", "resource_group": "high_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/Java/s545058519.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s545058519", "user_id": "u169102752"}, "prompt_components": {"gold_output": "YES\nNO\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tint n = 0;\n\t\tScanner scan = new Scanner(System.in);\n\t\tn = scan.nextInt();\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tint left = Integer.MIN_VALUE, right = Integer.MIN_VALUE;\n\t\t\tboolean isCorrect = true;\n\n\t\t\tfor(int j = 0; j < 10; j++) {\n\t\t\t\tint ball = scan.nextInt();\n\t\t\t\tif(ball > left) {\n\t\t\t\t\tleft = ball;\n\t\t\t\t} else if(ball > right) {\n\t\t\t\t\tright = ball;\n\t\t\t\t} else {\n\t\t\t\t\tisCorrect = false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tSystem.out.println(isCorrect ? \"YES\" : \"NO\");\n\t\t}\n\n\t\tscan.close();\n\t}\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": 566, "cpu_time_ms": 90, "memory_kb": 26208}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s848026594", "group_id": "codeNet:p00042", "input_text": "import java.util.*;\npublic class Main {\t\n\tScanner in = new Scanner(System.in);\n\tpublic static void main(String[] args){\n\t\tnew Main();\n\t}\n\n\tpublic Main(){\t\t\n\t\tnew AOJ0042();\n\t}\n\tclass AOJ0042{\n//\t\tint w,n;\n//\t\ttresure[] takara;\n\t\tpublic AOJ0042() {\n\t\t\tint c=1;\n\t\t\twhile(true){\n\t\t\t\tint w = in.nextInt();\n\t\t\t\tif(w==0)break;\n\t\t\t\tint n = in.nextInt();\n\t\t\t\ttresure[] takara = new tresure[n];\n\t\t\t\tfor(int i=0;i0){\n\t\t\t\t\t\tif(takara[s].heavy+i<=w)dp[takara[s].heavy+i]=Math.max(dp[takara[s].heavy+i],dp[i]+takara[s].money);\n\t\t\t\t\t}\n\t\t\t\t\tif(takara[s].heavy<=w)dp[takara[s].heavy]=Math.max(dp[takara[s].heavy],takara[s].money);\n\t\t\t\t}\n\t\t\t\tint max_heavy=0;\n\t\t\t\tint max_money=0;\n\t\t\t\tfor(int i=0;i0){\n\t\t\t\t\t\tif(takara[s].heavy+i<=w)dp[takara[s].heavy+i]=Math.max(dp[takara[s].heavy+i],dp[i]+takara[s].money);\n\t\t\t\t\t}\n\t\t\t\t\tif(takara[s].heavy<=w)dp[takara[s].heavy]=Math.max(dp[takara[s].heavy],takara[s].money);\n\t\t\t\t}\n\t\t\t\tint max_heavy=0;\n\t\t\t\tint max_money=0;\n\t\t\t\tfor(int i=0;i 0 && counts[r][k + 2] > 0) {\n if (r == 5) {\n return true;\n }\n System.arraycopy(counts[r], 0, counts[r + 1], 0, 9);\n counts[r + 1][k]--;\n counts[r + 1][k + 1]--;\n counts[r + 1][k + 2]--;\n if (check(counts, r + 1)) {\n return true;\n }\n }\n if (counts[r][k] >= 3) {\n if (r == 5) {\n return true;\n }\n System.arraycopy(counts[r], 0, counts[r + 1], 0, 9);\n counts[r + 1][k] -= 3;\n if (check(counts, r + 1)) {\n return true;\n }\n }\n }\n return false;\n }\n}", "language": "Java", "metadata": {"date": 1349670411, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00043.html", "problem_id": "p00043", "resource_group": "high_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/Java/s675533991.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s675533991", "user_id": "u577457452"}, "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 java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.PrintStream;\n\nclass Main {\n\n public static void main(String[] args) throws IOException {\n doit(args, System.in, System.out);\n }\n\n static void doit(String[] args, InputStream in, PrintStream out)\n throws IOException {\n BufferedReader reader = new BufferedReader(new InputStreamReader(in));\n while (true) {\n String line = reader.readLine();\n if (line == null || line.isEmpty()) {\n break;\n }\n int[][] counts = new int[6][9];\n for (int i = 0; i < 13; i++) {\n counts[0][line.charAt(i) - '1']++;\n }\n boolean found = false;\n for (int i = 0; i < 9; i++) {\n if (counts[0][i] == 4) {\n continue;\n }\n System.arraycopy(counts[0], 0, counts[1], 0, 9);\n counts[1][i]++;\n for (int j = 0; j < 9; j++) {\n if (counts[1][j] < 2) {\n continue;\n }\n System.arraycopy(counts[1], 0, counts[2], 0, 9);\n counts[2][j] -= 2;\n if (check(counts, 2)) {\n if (!found) {\n found = true;\n } else {\n out.print(' ');\n }\n out.print(i + 1);\n }\n }\n }\n if (!found) {\n out.print(0);\n }\n out.println();\n }\n }\n\n private static boolean check(int[][] counts, int r) {\n for (int k = 0; k < 9; k++) {\n if (counts[r][k] == 0) {\n continue;\n }\n if (k < 7 && counts[r][k + 1] > 0 && counts[r][k + 2] > 0) {\n if (r == 5) {\n return true;\n }\n System.arraycopy(counts[r], 0, counts[r + 1], 0, 9);\n counts[r + 1][k]--;\n counts[r + 1][k + 1]--;\n counts[r + 1][k + 2]--;\n if (check(counts, r + 1)) {\n return true;\n }\n }\n if (counts[r][k] >= 3) {\n if (r == 5) {\n return true;\n }\n System.arraycopy(counts[r], 0, counts[r + 1], 0, 9);\n counts[r + 1][k] -= 3;\n if (check(counts, r + 1)) {\n return true;\n }\n }\n }\n return false;\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": 2715, "cpu_time_ms": 50, "memory_kb": 9468}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s251830045", "group_id": "codeNet:p00044", "input_text": "import java.util.*;\nimport java.lang.*;\nimport java.math.*;\nimport java.io.*;\n\nimport static java.lang.Math.*;\nimport static java.util.Arrays.*;\n\npublic class Main{\n\n\tScanner sc;\n\n\tstatic final int INF=1<<28;\n\tstatic final double EPS=1e-9;\n\n\tvoid run(){\n\t\tsc=new Scanner(System.in);\n\t\tfor(; sc.hasNext();){\n\t\t\tint n=sc.nextInt();\n\t\t\tint p=n-1;\n\t\t\tint q=n+1;\n\t\t\twhile(!isPrime(p))\n\t\t\t\tp--;\n\t\t\twhile(!isPrime(q))\n\t\t\t\tq++;\n\t\t\tprintln(p+\" \"+q);\n\t\t}\n\t\tsc.close();\n\t}\n\n\tboolean isPrime(int n){\n\t\tfor(int i=2; i inputList = new ArrayList<>();\n\n while (input.ready())\n {\n inputList.add(Float.parseFloat(input.readLine()));\n }\n final float ans = getDiffHight(inputList);\n System.out.println(ans);\n }\n\n private static float getDiffHight(ArrayList list)\n {\n float maxHight = Float.MIN_VALUE;\n float minHight = Float.MAX_VALUE;\n\n for (Float each : list)\n {\n if (each > maxHight)\n {\n maxHight = each;\n }\n if (each < minHight)\n {\n minHight = each;\n }\n }\n return maxHight - minHight;\n }\n}", "language": "Java", "metadata": {"date": 1504223313, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00046.html", "problem_id": "p00046", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00046/input.txt", "sample_output_relpath": "derived/input_output/data/p00046/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00046/Java/s890487885.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s890487885", "user_id": "u874152376"}, "prompt_components": {"gold_output": "3130.8\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayList;\n\npublic class Main\n{\n public static void main(String[] args) throws NumberFormatException, IOException\n {\n BufferedReader input = new BufferedReader(new InputStreamReader(System.in));\n\n ArrayList inputList = new ArrayList<>();\n\n while (input.ready())\n {\n inputList.add(Float.parseFloat(input.readLine()));\n }\n final float ans = getDiffHight(inputList);\n System.out.println(ans);\n }\n\n private static float getDiffHight(ArrayList list)\n {\n float maxHight = Float.MIN_VALUE;\n float minHight = Float.MAX_VALUE;\n\n for (Float each : list)\n {\n if (each > maxHight)\n {\n maxHight = each;\n }\n if (each < minHight)\n {\n minHight = each;\n }\n }\n return maxHight - minHight;\n }\n}", "problem_context": "標高差\n\n今まで登ったことのある山の標高を記録したデータがあります。このデータを読み込んで、一番高い山と一番低い山の標高差を出力するプログラムを作成してください。\n\nInput\n\n入力は以下の形式で与えられます。\n\n山の高さ\n...\n...\n\n山の高さが複数行に渡って与えられます。入力される値はすべて 0 以上 1,000,000 以下の実数です。入力される山の高さの数は 50 以下です。\n\nOutput\n\n一番高い山と一番低い山の標高差を実数で出力する。出力は0.01以下の誤差を含んでもよい。\n\nSample Input\n\n3776.0\n1819.0\n645.2\n2004.1\n1208.6\n\nOutput for the Sample Input\n\n3130.8", "sample_input": "3776.0\n1819.0\n645.2\n2004.1\n1208.6\n"}, "reference_outputs": ["3130.8\n"], "source_document_id": "p00046", "source_text": "標高差\n\n今まで登ったことのある山の標高を記録したデータがあります。このデータを読み込んで、一番高い山と一番低い山の標高差を出力するプログラムを作成してください。\n\nInput\n\n入力は以下の形式で与えられます。\n\n山の高さ\n...\n...\n\n山の高さが複数行に渡って与えられます。入力される値はすべて 0 以上 1,000,000 以下の実数です。入力される山の高さの数は 50 以下です。\n\nOutput\n\n一番高い山と一番低い山の標高差を実数で出力する。出力は0.01以下の誤差を含んでもよい。\n\nSample Input\n\n3776.0\n1819.0\n645.2\n2004.1\n1208.6\n\nOutput for the Sample Input\n\n3130.8", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 893, "cpu_time_ms": 30, "memory_kb": 24316}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s053918591", "group_id": "codeNet:p00051", "input_text": "import java.util.Scanner;\nimport java.util.Arrays;\n\nclass Main\n{\n\tpublic static void main(String args[])\n\t{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++)\n\t\t{\n\t\t\tchar num[] = sc.next().toCharArray();\n\t\t\tArrays.sort(num);\n\t\t\tString str = new String(num);\n\t\t\tScanner minNumSc = new Scanner(str);\n\t\t\tint min = minNumSc.nextInt();\n\t\t\tScanner maxNumSc = new Scanner((new StringBuffer(str).reverse()).toString());\n\t\t\tint max = maxNumSc.nextInt();\n\t\t\tSystem.out.println(max - min);\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1282603109, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00051.html", "problem_id": "p00051", "resource_group": "high_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/Java/s053918591.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s053918591", "user_id": "u759949288"}, "prompt_components": {"gold_output": "96417531\n96417531\n", "input_to_evaluate": "import java.util.Scanner;\nimport java.util.Arrays;\n\nclass Main\n{\n\tpublic static void main(String args[])\n\t{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++)\n\t\t{\n\t\t\tchar num[] = sc.next().toCharArray();\n\t\t\tArrays.sort(num);\n\t\t\tString str = new String(num);\n\t\t\tScanner minNumSc = new Scanner(str);\n\t\t\tint min = minNumSc.nextInt();\n\t\t\tScanner maxNumSc = new Scanner((new StringBuffer(str).reverse()).toString());\n\t\t\tint max = maxNumSc.nextInt();\n\t\t\tSystem.out.println(max - min);\n\t\t}\n\t}\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": 529, "cpu_time_ms": 100, "memory_kb": 12000}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s311519086", "group_id": "codeNet:p00058", "input_text": "import java.io.*;\n \nclass Main{\npublic static void main(String[] args) throws IOException{\nBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\nString line=\"\";\nwhile((line=br.readLine())!=null){\nString[] values=line.split(\" \");\ndouble xa=Double.parseDouble(values[0]);\ndouble ya=Double.parseDouble(values[1]);\ndouble xb=Double.parseDouble(values[2]);\ndouble yb=Double.parseDouble(values[3]);\ndouble xc=Double.parseDouble(values[4]);\ndouble yc=Double.parseDouble(values[5]);\ndouble xd=Double.parseDouble(values[6]);\ndouble yd=Double.parseDouble(values[7]);\nif(xa==xb){\nif(yc==yd){\nSystem.out.println(\"YES\");\n}\nelse{\nSystem.out.println(\"NO\");\n}\ncontinue;\n}\nif(xc==xd){\nif(ya==yb){\nSystem.out.println(\"YES\");\n}\nelse{\nSystem.out.println(\"NO\");\n}\ncontinue;\n}\ndouble mab=(ya-yb)/(xa-xb);\ndouble mcd=(yc-yd)/(xc-xd);\nSystem.out.println((mab*mcd==-1?\"YES\":\"NO\"));\n}\n}\n}", "language": "Java", "metadata": {"date": 1437161026, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00058.html", "problem_id": "p00058", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00058/input.txt", "sample_output_relpath": "derived/input_output/data/p00058/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00058/Java/s311519086.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s311519086", "user_id": "u211138527"}, "prompt_components": {"gold_output": "YES\nNO\nNO\nYES\n", "input_to_evaluate": "import java.io.*;\n \nclass Main{\npublic static void main(String[] args) throws IOException{\nBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\nString line=\"\";\nwhile((line=br.readLine())!=null){\nString[] values=line.split(\" \");\ndouble xa=Double.parseDouble(values[0]);\ndouble ya=Double.parseDouble(values[1]);\ndouble xb=Double.parseDouble(values[2]);\ndouble yb=Double.parseDouble(values[3]);\ndouble xc=Double.parseDouble(values[4]);\ndouble yc=Double.parseDouble(values[5]);\ndouble xd=Double.parseDouble(values[6]);\ndouble yd=Double.parseDouble(values[7]);\nif(xa==xb){\nif(yc==yd){\nSystem.out.println(\"YES\");\n}\nelse{\nSystem.out.println(\"NO\");\n}\ncontinue;\n}\nif(xc==xd){\nif(ya==yb){\nSystem.out.println(\"YES\");\n}\nelse{\nSystem.out.println(\"NO\");\n}\ncontinue;\n}\ndouble mab=(ya-yb)/(xa-xb);\ndouble mcd=(yc-yd)/(xc-xd);\nSystem.out.println((mab*mcd==-1?\"YES\":\"NO\"));\n}\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)$ の座標を読み込んで、直線 $AB$ と $CD$ が直交する場合には YES、直交しない場合には NO と出力するプログラムを作成してください。ここで、「直線」とは線分のことではありません。以下の図を参考にして下さい。\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 以下であり、各値は小数点以下最大 5 桁までの数字を含む実数で与えられます。\n\nデータセットの数は 100 を超えません。\n\nOutput\n\n各データセットに対して、YES または NO を1行に出力して下さい。\n\nSample Input\n\n1.0 1.0 2.0 2.0 0.0 0.0 1.0 -1.0\n0.0 0.0 2.0 0.0 -1.0 2.0 2.0 2.0\n10.0 6.0 3.4 5.2 6.8 9.5 4.3 2.1\n2.5 3.5 2.5 4.5 -3.3 -2.3 6.8 -2.3\n\nOutput for the Sample Input\n\nYES\nNO\nNO\nYES", "sample_input": "1.0 1.0 2.0 2.0 0.0 0.0 1.0 -1.0\n0.0 0.0 2.0 0.0 -1.0 2.0 2.0 2.0\n10.0 6.0 3.4 5.2 6.8 9.5 4.3 2.1\n2.5 3.5 2.5 4.5 -3.3 -2.3 6.8 -2.3\n"}, "reference_outputs": ["YES\nNO\nNO\nYES\n"], "source_document_id": "p00058", "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)$ の座標を読み込んで、直線 $AB$ と $CD$ が直交する場合には YES、直交しない場合には NO と出力するプログラムを作成してください。ここで、「直線」とは線分のことではありません。以下の図を参考にして下さい。\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 以下であり、各値は小数点以下最大 5 桁までの数字を含む実数で与えられます。\n\nデータセットの数は 100 を超えません。\n\nOutput\n\n各データセットに対して、YES または NO を1行に出力して下さい。\n\nSample Input\n\n1.0 1.0 2.0 2.0 0.0 0.0 1.0 -1.0\n0.0 0.0 2.0 0.0 -1.0 2.0 2.0 2.0\n10.0 6.0 3.4 5.2 6.8 9.5 4.3 2.1\n2.5 3.5 2.5 4.5 -3.3 -2.3 6.8 -2.3\n\nOutput for the Sample Input\n\nYES\nNO\nNO\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": 880, "cpu_time_ms": 50, "memory_kb": 15140}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s344282605", "group_id": "codeNet:p00064", "input_text": "import java.io.*;\nimport java.util.regex.*;\npublic class Main{\n\tpublic static void main(String[] args) throws IOException{\n\t\tBufferedReader r = new BufferedReader(new InputStreamReader(System.in));\n\t\tPattern p = Pattern.compile(\"\\\\d++\");\n\t\tString str = new String();\n\t\twhile(true) {\n\t\t\tString s = r.readLine();\n\t\t\tstr += s;\n\t\t\tif(s == null) break;\n\t\t}\n\t\tif(!p.matcher(str).matches()) {\n\t\t\tSystem.out.println(\"0\");\n\t\t} else {\n\t\t\tString[] m = p.split(str);\n\t\t\tfor(String s : m) {\n\t\t\t\tstr = str.replace(s, \" \");\n\t\t\t}\n\t\t\tm = str.split(\" \");\n\t\t\tint sum = 0;\n\t\t\tfor(String s : m) {\n\t\t\t\tif(s.length() > 0) {\n\t\t\t\t\tsum += Integer.valueOf(s);\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.println(sum);\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1292355366, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00064.html", "problem_id": "p00064", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00064/input.txt", "sample_output_relpath": "derived/input_output/data/p00064/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00064/Java/s344282605.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s344282605", "user_id": "u928565401"}, "prompt_components": {"gold_output": "123\n", "input_to_evaluate": "import java.io.*;\nimport java.util.regex.*;\npublic class Main{\n\tpublic static void main(String[] args) throws IOException{\n\t\tBufferedReader r = new BufferedReader(new InputStreamReader(System.in));\n\t\tPattern p = Pattern.compile(\"\\\\d++\");\n\t\tString str = new String();\n\t\twhile(true) {\n\t\t\tString s = r.readLine();\n\t\t\tstr += s;\n\t\t\tif(s == null) break;\n\t\t}\n\t\tif(!p.matcher(str).matches()) {\n\t\t\tSystem.out.println(\"0\");\n\t\t} else {\n\t\t\tString[] m = p.split(str);\n\t\t\tfor(String s : m) {\n\t\t\t\tstr = str.replace(s, \" \");\n\t\t\t}\n\t\t\tm = str.split(\" \");\n\t\t\tint sum = 0;\n\t\t\tfor(String s : m) {\n\t\t\t\tif(s.length() > 0) {\n\t\t\t\t\tsum += Integer.valueOf(s);\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.println(sum);\n\t\t}\n\t}\n}", "problem_context": "暗証番号\n\n新しい暗証番号は覚えにくいものです。メモするのはダメといわれましたが、覚えられそうにありません。そこで文章の中に数値を埋め込んで暗証番号をメモすることにしました。ここでは全ての数値の和が暗証番号になります。\n\nメモされた文章を読み込んで、暗証番号を出力するプログラムを作成してください。\n\nInput\n\n正の整数が埋め込まれた文章が複数行にわたり与えられます。各行は半角英数字、記号、空白を含む文字列または空行です。\nただし、入力は 1 行あたり 80 文字以内で、暗証番号は 10,000 以下であることが保障されています。\n\nOutput\n\n暗証番号(文章中の正の整数の合計)を1行に出力します。\n\nSample Input\n\nThereare100yenonthetable.Iam17yearsold.\nIshouldgohomeat6pm.\n\nOutput for the Sample Input\n\n123", "sample_input": "Thereare100yenonthetable.Iam17yearsold.\nIshouldgohomeat6pm.\n"}, "reference_outputs": ["123\n"], "source_document_id": "p00064", "source_text": "暗証番号\n\n新しい暗証番号は覚えにくいものです。メモするのはダメといわれましたが、覚えられそうにありません。そこで文章の中に数値を埋め込んで暗証番号をメモすることにしました。ここでは全ての数値の和が暗証番号になります。\n\nメモされた文章を読み込んで、暗証番号を出力するプログラムを作成してください。\n\nInput\n\n正の整数が埋め込まれた文章が複数行にわたり与えられます。各行は半角英数字、記号、空白を含む文字列または空行です。\nただし、入力は 1 行あたり 80 文字以内で、暗証番号は 10,000 以下であることが保障されています。\n\nOutput\n\n暗証番号(文章中の正の整数の合計)を1行に出力します。\n\nSample Input\n\nThereare100yenonthetable.Iam17yearsold.\nIshouldgohomeat6pm.\n\nOutput for the Sample Input\n\n123", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 680, "cpu_time_ms": 60, "memory_kb": 10000}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s647396511", "group_id": "codeNet:p00065", "input_text": "import java.util.*;\npublic class Main{\n static Scanner kbd = new Scanner(System.in);\n public static void main(String[] args){\n\tsolve();\n }\n\n static void solve(){\n\tboolean[] x = new boolean[1001];\n\tint[] y = new int[1001];\n\tint term = 0, i=0;\n\tString a, b=\"\";\n\n\twhile(kbd.hasNext()){\n\t String s = kbd.next();\n\t if(s.equals(\"\")){\n\t\tterm = 1;\n\t }\n\t else{\n\t\twhile(!s.substring(i, i+1).equals(\",\")){\n\t\t a = s.substring(i, i+1);\n\t\t b += a;\n\t\t i++;\n\t\t}\n\t\tint p = Integer.parseInt(b);\n\t\tb = \"\";\n\t\tif(term==0){\n\t\t x[p] = true;\n\t\t y[p] ++;\n\t\t}\n\t\telse{\n\t\t x[p] = x[p]&&true;\n\t\t y[p] ++;\n\t\t}\n\t\ti=0;\n\t }\n\t}\n\n\tfor(i=0; i1)\n\t\tSystem.out.println(i+\" \"+y[i]);\n\t}\n }\n}", "language": "Java", "metadata": {"date": 1371452833, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00065.html", "problem_id": "p00065", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00065/input.txt", "sample_output_relpath": "derived/input_output/data/p00065/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00065/Java/s647396511.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s647396511", "user_id": "u014050391"}, "prompt_components": {"gold_output": "56 2\n123 3\n", "input_to_evaluate": "import java.util.*;\npublic class Main{\n static Scanner kbd = new Scanner(System.in);\n public static void main(String[] args){\n\tsolve();\n }\n\n static void solve(){\n\tboolean[] x = new boolean[1001];\n\tint[] y = new int[1001];\n\tint term = 0, i=0;\n\tString a, b=\"\";\n\n\twhile(kbd.hasNext()){\n\t String s = kbd.next();\n\t if(s.equals(\"\")){\n\t\tterm = 1;\n\t }\n\t else{\n\t\twhile(!s.substring(i, i+1).equals(\",\")){\n\t\t a = s.substring(i, i+1);\n\t\t b += a;\n\t\t i++;\n\t\t}\n\t\tint p = Integer.parseInt(b);\n\t\tb = \"\";\n\t\tif(term==0){\n\t\t x[p] = true;\n\t\t y[p] ++;\n\t\t}\n\t\telse{\n\t\t x[p] = x[p]&&true;\n\t\t y[p] ++;\n\t\t}\n\t\ti=0;\n\t }\n\t}\n\n\tfor(i=0; i1)\n\t\tSystem.out.println(i+\" \"+y[i]);\n\t}\n }\n}", "problem_context": "取引\n\n取引先の顧客番号と取引日を月ごとに記録したデータがあります。今月のデータと先月のデータを読み込んで、先月から2ヶ月連続で取引のある会社の顧客番号と取引のあった回数を出力するプログラムを作成してください。ただし、月々の取引先数は 1,000 社以内です。\n\nInput\n\n今月のデータと、先月のデータが1行の空行で区切られて与えられます。それぞれのデータは以下のような形式で与えられます。\n\nc1,d1\nc2,d2\n...\n...\n\nci (1 ≤ ci ≤ 1,000) は顧客番号を表す整数、 di (1 ≤ di ≤ 31) は取引日を表す整数です。\n\nOutput\n\n2ヶ月連続で取引のある会社について、顧客番号が小さい順に顧客番号と取引回数の総数を空白で区切って出力します。\n\nSample Input\n\n123,10\n56,12\n34,14\n\n123,3\n56,4\n123,5\n\nOutput for the Sample Input\n\n56 2\n123 3", "sample_input": "123,10\n56,12\n34,14\n\n123,3\n56,4\n123,5\n"}, "reference_outputs": ["56 2\n123 3\n"], "source_document_id": "p00065", "source_text": "取引\n\n取引先の顧客番号と取引日を月ごとに記録したデータがあります。今月のデータと先月のデータを読み込んで、先月から2ヶ月連続で取引のある会社の顧客番号と取引のあった回数を出力するプログラムを作成してください。ただし、月々の取引先数は 1,000 社以内です。\n\nInput\n\n今月のデータと、先月のデータが1行の空行で区切られて与えられます。それぞれのデータは以下のような形式で与えられます。\n\nc1,d1\nc2,d2\n...\n...\n\nci (1 ≤ ci ≤ 1,000) は顧客番号を表す整数、 di (1 ≤ di ≤ 31) は取引日を表す整数です。\n\nOutput\n\n2ヶ月連続で取引のある会社について、顧客番号が小さい順に顧客番号と取引回数の総数を空白で区切って出力します。\n\nSample Input\n\n123,10\n56,12\n34,14\n\n123,3\n56,4\n123,5\n\nOutput for the Sample Input\n\n56 2\n123 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": 739, "cpu_time_ms": 50, "memory_kb": 17156}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s753566484", "group_id": "codeNet:p00075", "input_text": "import java.util.*;\n\npublic class Main{\n public static void main(String[] args) {\n\t Scanner sc =new Scanner(System.in);\n while(sc.hasNext()){\nString s=sc.nextLine();\nString in[]=s.split(\",\");\n\t \nint a=Integer.parseInt(in[0]);\t \ndouble b=Double.parseDouble(in[1]);\ndouble c=Double.parseDouble(in[2]);\nc*=c;\nif(b/c>=25)System.out.println(a);\n }\n }\n }", "language": "Java", "metadata": {"date": 1410573134, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00075.html", "problem_id": "p00075", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00075/input.txt", "sample_output_relpath": "derived/input_output/data/p00075/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00075/Java/s753566484.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s753566484", "user_id": "u910780605"}, "prompt_components": {"gold_output": "1004\n1005\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main{\n public static void main(String[] args) {\n\t Scanner sc =new Scanner(System.in);\n while(sc.hasNext()){\nString s=sc.nextLine();\nString in[]=s.split(\",\");\n\t \nint a=Integer.parseInt(in[0]);\t \ndouble b=Double.parseDouble(in[1]);\ndouble c=Double.parseDouble(in[2]);\nc*=c;\nif(b/c>=25)System.out.println(a);\n }\n }\n }", "problem_context": "BMI\n\n肥満は多くの成人病の原因として挙げられています。過去においては、一部の例外を除けば、高校生には無縁なものでした。しかし、過度の受験勉強等のために運動不足となり、あるいはストレスによる過食症となることが、非現実的なこととはいえなくなっています。高校生にとっても十分関心を持たねばならない問題になるかもしれません。\n\nそこで、あなたは、保健室の先生の助手となって、生徒のデータから肥満の疑いのある生徒を探し出すプログラムを作成することになりました。\n\n方法は BMI (Body Mass Index) という数値を算出する方法です。BMIは次の式で与えられます。\n\nBMI = 22 が標準的で、25 以上だと肥満の疑いがあります。\n\n各々の生徒の体重、身長の情報から BMI を算出し、25 以上の生徒の学籍番号を出力するプログラムを作成してください。\n\n入力\n\n入力は以下の形式で与えられます。\n\ns1,w1,h1\ns2,w2,h2\n...\n...\n\nsi (1 ≤ si ≤ 2,000)、wi (1 ≤ wi ≤ 200)、hi (1.0 ≤ hi ≤ 2.0) はそれぞれ、i 番目の生徒の学籍番号(整数)、体重(実数)、身長(実数)を表します。\n\n生徒の数は 50 を超えません。\n\n出力\n\nBMI が 25 以上の生徒の学籍番号を、入力された順番にそれぞれ1行に出力します。\n\nSample Input\n\n1001,50.0,1.60\n1002,60.0,1.70\n1003,70.0,1.80\n1004,80.0,1.70\n1005,90.0,1.60\n\nOutput for the Sample Input\n\n1004\n1005", "sample_input": "1001,50.0,1.60\n1002,60.0,1.70\n1003,70.0,1.80\n1004,80.0,1.70\n1005,90.0,1.60\n"}, "reference_outputs": ["1004\n1005\n"], "source_document_id": "p00075", "source_text": "BMI\n\n肥満は多くの成人病の原因として挙げられています。過去においては、一部の例外を除けば、高校生には無縁なものでした。しかし、過度の受験勉強等のために運動不足となり、あるいはストレスによる過食症となることが、非現実的なこととはいえなくなっています。高校生にとっても十分関心を持たねばならない問題になるかもしれません。\n\nそこで、あなたは、保健室の先生の助手となって、生徒のデータから肥満の疑いのある生徒を探し出すプログラムを作成することになりました。\n\n方法は BMI (Body Mass Index) という数値を算出する方法です。BMIは次の式で与えられます。\n\nBMI = 22 が標準的で、25 以上だと肥満の疑いがあります。\n\n各々の生徒の体重、身長の情報から BMI を算出し、25 以上の生徒の学籍番号を出力するプログラムを作成してください。\n\n入力\n\n入力は以下の形式で与えられます。\n\ns1,w1,h1\ns2,w2,h2\n...\n...\n\nsi (1 ≤ si ≤ 2,000)、wi (1 ≤ wi ≤ 200)、hi (1.0 ≤ hi ≤ 2.0) はそれぞれ、i 番目の生徒の学籍番号(整数)、体重(実数)、身長(実数)を表します。\n\n生徒の数は 50 を超えません。\n\n出力\n\nBMI が 25 以上の生徒の学籍番号を、入力された順番にそれぞれ1行に出力します。\n\nSample Input\n\n1001,50.0,1.60\n1002,60.0,1.70\n1003,70.0,1.80\n1004,80.0,1.70\n1005,90.0,1.60\n\nOutput for the Sample Input\n\n1004\n1005", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 363, "cpu_time_ms": 50, "memory_kb": 17124}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s139151903", "group_id": "codeNet:p00075", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t//??????????????°\n\t\tdouble bmi;\n\t\tString [][] kiroku = new String[50][3];\n\t\tdouble [][] date = new double[50][3];\n\n\t\t//????????£????????????\n\t\tScanner scan = new Scanner(System.in);\n\n\t\t//BMI??????\n\t\tint i = 0;\n\t\tint j=0;\n\n\t\t//????????????\n\t\twhile(scan.hasNext()){\n\t\t//?¨??????????\n\t\t\t\tString str = scan.next();\n\t\t\t\tkiroku[i] = str.split(\",\");\n\t\t\t\tdate [i][1]= Double.parseDouble(kiroku[i][1]);\n\t\t\t\tdate [i][2]= Double.parseDouble(kiroku[i][2]);\n\t\t\ti++;\n\n\t\t}\n\t\tfor(int x = 0 ; x < date.length ; x++){\n\t\t\tbmi = date[x][1] / (date[x][2] * date[x][2]);\n\t\t\tif(bmi >= 25){\n\t\t\t\tSystem.out.println(kiroku[x][0]);\n\t\t\t}\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1500363527, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00075.html", "problem_id": "p00075", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00075/input.txt", "sample_output_relpath": "derived/input_output/data/p00075/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00075/Java/s139151903.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s139151903", "user_id": "u287432377"}, "prompt_components": {"gold_output": "1004\n1005\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t//??????????????°\n\t\tdouble bmi;\n\t\tString [][] kiroku = new String[50][3];\n\t\tdouble [][] date = new double[50][3];\n\n\t\t//????????£????????????\n\t\tScanner scan = new Scanner(System.in);\n\n\t\t//BMI??????\n\t\tint i = 0;\n\t\tint j=0;\n\n\t\t//????????????\n\t\twhile(scan.hasNext()){\n\t\t//?¨??????????\n\t\t\t\tString str = scan.next();\n\t\t\t\tkiroku[i] = str.split(\",\");\n\t\t\t\tdate [i][1]= Double.parseDouble(kiroku[i][1]);\n\t\t\t\tdate [i][2]= Double.parseDouble(kiroku[i][2]);\n\t\t\ti++;\n\n\t\t}\n\t\tfor(int x = 0 ; x < date.length ; x++){\n\t\t\tbmi = date[x][1] / (date[x][2] * date[x][2]);\n\t\t\tif(bmi >= 25){\n\t\t\t\tSystem.out.println(kiroku[x][0]);\n\t\t\t}\n\t\t}\n\t}\n}", "problem_context": "BMI\n\n肥満は多くの成人病の原因として挙げられています。過去においては、一部の例外を除けば、高校生には無縁なものでした。しかし、過度の受験勉強等のために運動不足となり、あるいはストレスによる過食症となることが、非現実的なこととはいえなくなっています。高校生にとっても十分関心を持たねばならない問題になるかもしれません。\n\nそこで、あなたは、保健室の先生の助手となって、生徒のデータから肥満の疑いのある生徒を探し出すプログラムを作成することになりました。\n\n方法は BMI (Body Mass Index) という数値を算出する方法です。BMIは次の式で与えられます。\n\nBMI = 22 が標準的で、25 以上だと肥満の疑いがあります。\n\n各々の生徒の体重、身長の情報から BMI を算出し、25 以上の生徒の学籍番号を出力するプログラムを作成してください。\n\n入力\n\n入力は以下の形式で与えられます。\n\ns1,w1,h1\ns2,w2,h2\n...\n...\n\nsi (1 ≤ si ≤ 2,000)、wi (1 ≤ wi ≤ 200)、hi (1.0 ≤ hi ≤ 2.0) はそれぞれ、i 番目の生徒の学籍番号(整数)、体重(実数)、身長(実数)を表します。\n\n生徒の数は 50 を超えません。\n\n出力\n\nBMI が 25 以上の生徒の学籍番号を、入力された順番にそれぞれ1行に出力します。\n\nSample Input\n\n1001,50.0,1.60\n1002,60.0,1.70\n1003,70.0,1.80\n1004,80.0,1.70\n1005,90.0,1.60\n\nOutput for the Sample Input\n\n1004\n1005", "sample_input": "1001,50.0,1.60\n1002,60.0,1.70\n1003,70.0,1.80\n1004,80.0,1.70\n1005,90.0,1.60\n"}, "reference_outputs": ["1004\n1005\n"], "source_document_id": "p00075", "source_text": "BMI\n\n肥満は多くの成人病の原因として挙げられています。過去においては、一部の例外を除けば、高校生には無縁なものでした。しかし、過度の受験勉強等のために運動不足となり、あるいはストレスによる過食症となることが、非現実的なこととはいえなくなっています。高校生にとっても十分関心を持たねばならない問題になるかもしれません。\n\nそこで、あなたは、保健室の先生の助手となって、生徒のデータから肥満の疑いのある生徒を探し出すプログラムを作成することになりました。\n\n方法は BMI (Body Mass Index) という数値を算出する方法です。BMIは次の式で与えられます。\n\nBMI = 22 が標準的で、25 以上だと肥満の疑いがあります。\n\n各々の生徒の体重、身長の情報から BMI を算出し、25 以上の生徒の学籍番号を出力するプログラムを作成してください。\n\n入力\n\n入力は以下の形式で与えられます。\n\ns1,w1,h1\ns2,w2,h2\n...\n...\n\nsi (1 ≤ si ≤ 2,000)、wi (1 ≤ wi ≤ 200)、hi (1.0 ≤ hi ≤ 2.0) はそれぞれ、i 番目の生徒の学籍番号(整数)、体重(実数)、身長(実数)を表します。\n\n生徒の数は 50 を超えません。\n\n出力\n\nBMI が 25 以上の生徒の学籍番号を、入力された順番にそれぞれ1行に出力します。\n\nSample Input\n\n1001,50.0,1.60\n1002,60.0,1.70\n1003,70.0,1.80\n1004,80.0,1.70\n1005,90.0,1.60\n\nOutput for the Sample Input\n\n1004\n1005", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 713, "cpu_time_ms": 50, "memory_kb": 25964}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s847336680", "group_id": "codeNet:p00091", "input_text": "import java.io.InputStream;\nimport java.io.IOException;\nimport java.io.PrintWriter;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Comparator;\nimport java.util.InputMismatchException;\nimport java.util.NoSuchElementException;\nimport java.math.BigInteger;\n\npublic class Main{\n\nstatic PrintWriter out;\nstatic InputReader ir;\nstatic int total,res; \nstatic final int[] sx={0,0,1,0,-1},sy={0,1,0,-1,0},mx={0,0,1,0,-1,-1,-1,1,1},my={0,1,0,-1,0,-1,1,-1,1},lx={0,0,1,0,-1,-1,-1,1,1,0,2,0,-2},ly={0,1,0,-1,0,-1,1,-1,1,2,0,-2,0};\nstatic int[][] map=new int[10][10];\nstatic int[][][] drop=new int[10][10][3];\n\nstatic void sd(int x,int y){\n for(int i=0;i=10||ny>=10||map[nx][ny]==0){\n return false;\n }\n }\n return true;\n}\n\nstatic void md(int x,int y){\n for(int i=0;i=10||ny>=10||map[nx][ny]==0){\n return false;\n }\n }\n return true;\n}\n\nstatic void ld(int x,int y){\n for(int i=0;i=10||ny>=10||map[nx][ny]==0){\n return false;\n }\n }\n return true;\n}\n\nstatic void solve(){\n res=ir.nextInt();\n total=0;\n for(int i=0;i<10;i++){\n for(int j=0;j<10;j++){\n map[i][j]=ir.nextInt();\n total+=map[i][j];\n }\n }\n if(search(1,1,3)){\n for(int i=1;i<9;i++){\n for(int j=1;j<9;j++){\n for(int k=0;k<3;k++){\n if(drop[i][j][k]!=0){\n for(int l=0;lres*13){\n return false;\n }\n else if(res==0){\n return false;\n }\n if(y==9){\n return false;\n }\n if(y>2&&x==1){\n for(int i=0;i<10;i++){\n if(map[i][y-3]!=0){\n return false;\n }\n }\n }\n while(true){\n switch(size){\n case 3:if(lcd(x,y)){\n ld(x,y);\n drop[x][y][2]++;\n if(searchnext(x,y)){\n return true;\n }\n else{\n if(scd(x,y)&&search(x,y,3)){\n return true;\n }\n lr(x,y);\n drop[x][y][2]--;\n }\n }\n size--;\n\n case 2:if(mcd(x,y)){\n md(x,y);\n drop[x][y][1]++;\n if(searchnext(x,y)){\n return true;\n }\n else{\n if(scd(x,y)&&search(x,y,2)){\n return true;\n }\n mr(x,y);\n drop[x][y][1]--;\n }\n }\n size--;\n\n case 1:if(scd(x,y)){\n sd(x,y);\n drop[x][y][0]++;\n if(searchnext(x,y)){\n return true;\n }\n else{\n if(scd(x,y)&&search(x,y,1)){\n return true;\n }\n sr(x,y);\n drop[x][y][0]--;\n }\n }\n size--;\n\n case 0:return searchnext(x,y);\n }\n }\n}\n\npublic static void main(String[] args) throws Exception{\n ir=new InputReader(System.in);\n out=new PrintWriter(System.out);\n solve();\n out.flush();\n}\n\nstatic class InputReader {\n private InputStream in;\n private byte[] buffer=new byte[1024];\n private int curbuf;\n private int lenbuf;\n\n public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}\n \n public boolean hasNextByte() {\n if(curbuf>=lenbuf){\n curbuf= 0;\n try{\n lenbuf=in.read(buffer);\n }catch(IOException e) {\n throw new InputMismatchException();\n }\n if(lenbuf<=0) return false;\n }\n return true;\n }\n\n private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}\n \n private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}\n \n private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}\n \n public boolean hasNext(){skip(); return hasNextByte();}\n \n public String next(){\n if(!hasNext()) throw new NoSuchElementException();\n StringBuilder sb=new StringBuilder();\n int b=readByte();\n while(!isSpaceChar(b)){\n sb.appendCodePoint(b);\n b=readByte();\n }\n return sb.toString();\n }\n \n public int nextInt() {\n if(!hasNext()) throw new NoSuchElementException();\n int c=readByte();\n while (isSpaceChar(c)) c=readByte();\n boolean minus=false;\n if (c=='-') {\n minus=true;\n c=readByte();\n }\n int res=0;\n do{\n if(c<'0'||c>'9') throw new InputMismatchException();\n res=res*10+c-'0';\n c=readByte();\n }while(!isSpaceChar(c));\n return (minus)?-res:res;\n }\n \n public long nextLong() {\n if(!hasNext()) throw new NoSuchElementException();\n int c=readByte();\n while (isSpaceChar(c)) c=readByte();\n boolean minus=false;\n if (c=='-') {\n minus=true;\n c=readByte();\n }\n long res = 0;\n do{\n if(c<'0'||c>'9') throw new InputMismatchException();\n res=res*10+c-'0';\n c=readByte();\n }while(!isSpaceChar(c));\n return (minus)?-res:res;\n }\n\n public double nextDouble(){return Double.parseDouble(next());}\n\n public BigInteger nextBigInteger(){return new BigInteger(next());}\n\n public int[] nextIntArray(int n){\n int[] a=new int[n];\n for(int i=0;i=10||ny>=10||map[nx][ny]==0){\n return false;\n }\n }\n return true;\n}\n\nstatic void md(int x,int y){\n for(int i=0;i=10||ny>=10||map[nx][ny]==0){\n return false;\n }\n }\n return true;\n}\n\nstatic void ld(int x,int y){\n for(int i=0;i=10||ny>=10||map[nx][ny]==0){\n return false;\n }\n }\n return true;\n}\n\nstatic void solve(){\n res=ir.nextInt();\n total=0;\n for(int i=0;i<10;i++){\n for(int j=0;j<10;j++){\n map[i][j]=ir.nextInt();\n total+=map[i][j];\n }\n }\n if(search(1,1,3)){\n for(int i=1;i<9;i++){\n for(int j=1;j<9;j++){\n for(int k=0;k<3;k++){\n if(drop[i][j][k]!=0){\n for(int l=0;lres*13){\n return false;\n }\n else if(res==0){\n return false;\n }\n if(y==9){\n return false;\n }\n if(y>2&&x==1){\n for(int i=0;i<10;i++){\n if(map[i][y-3]!=0){\n return false;\n }\n }\n }\n while(true){\n switch(size){\n case 3:if(lcd(x,y)){\n ld(x,y);\n drop[x][y][2]++;\n if(searchnext(x,y)){\n return true;\n }\n else{\n if(scd(x,y)&&search(x,y,3)){\n return true;\n }\n lr(x,y);\n drop[x][y][2]--;\n }\n }\n size--;\n\n case 2:if(mcd(x,y)){\n md(x,y);\n drop[x][y][1]++;\n if(searchnext(x,y)){\n return true;\n }\n else{\n if(scd(x,y)&&search(x,y,2)){\n return true;\n }\n mr(x,y);\n drop[x][y][1]--;\n }\n }\n size--;\n\n case 1:if(scd(x,y)){\n sd(x,y);\n drop[x][y][0]++;\n if(searchnext(x,y)){\n return true;\n }\n else{\n if(scd(x,y)&&search(x,y,1)){\n return true;\n }\n sr(x,y);\n drop[x][y][0]--;\n }\n }\n size--;\n\n case 0:return searchnext(x,y);\n }\n }\n}\n\npublic static void main(String[] args) throws Exception{\n ir=new InputReader(System.in);\n out=new PrintWriter(System.out);\n solve();\n out.flush();\n}\n\nstatic class InputReader {\n private InputStream in;\n private byte[] buffer=new byte[1024];\n private int curbuf;\n private int lenbuf;\n\n public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}\n \n public boolean hasNextByte() {\n if(curbuf>=lenbuf){\n curbuf= 0;\n try{\n lenbuf=in.read(buffer);\n }catch(IOException e) {\n throw new InputMismatchException();\n }\n if(lenbuf<=0) return false;\n }\n return true;\n }\n\n private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}\n \n private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}\n \n private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}\n \n public boolean hasNext(){skip(); return hasNextByte();}\n \n public String next(){\n if(!hasNext()) throw new NoSuchElementException();\n StringBuilder sb=new StringBuilder();\n int b=readByte();\n while(!isSpaceChar(b)){\n sb.appendCodePoint(b);\n b=readByte();\n }\n return sb.toString();\n }\n \n public int nextInt() {\n if(!hasNext()) throw new NoSuchElementException();\n int c=readByte();\n while (isSpaceChar(c)) c=readByte();\n boolean minus=false;\n if (c=='-') {\n minus=true;\n c=readByte();\n }\n int res=0;\n do{\n if(c<'0'||c>'9') throw new InputMismatchException();\n res=res*10+c-'0';\n c=readByte();\n }while(!isSpaceChar(c));\n return (minus)?-res:res;\n }\n \n public long nextLong() {\n if(!hasNext()) throw new NoSuchElementException();\n int c=readByte();\n while (isSpaceChar(c)) c=readByte();\n boolean minus=false;\n if (c=='-') {\n minus=true;\n c=readByte();\n }\n long res = 0;\n do{\n if(c<'0'||c>'9') throw new InputMismatchException();\n res=res*10+c-'0';\n c=readByte();\n }while(!isSpaceChar(c));\n return (minus)?-res:res;\n }\n\n public double nextDouble(){return Double.parseDouble(next());}\n\n public BigInteger nextBigInteger(){return new BigInteger(next());}\n\n public int[] nextIntArray(int n){\n int[] a=new int[n];\n for(int i=0;i=1000000){\n \t\t\tSystem.out.println(input[i]);\n \t\t\tsyatiku[input[i]] =0;\n \t\t\tflag =false;\n \t\t}\n \t}\n \tif(flag)System.out.println(\"NA\");\n }\n }\n}", "language": "Java", "metadata": {"date": 1338045420, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00100.html", "problem_id": "p00100", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00100/input.txt", "sample_output_relpath": "derived/input_output/data/p00100/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00100/Java/s392033344.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s392033344", "user_id": "u907626292"}, "prompt_components": {"gold_output": "1001\n1003\nNA\n2013\n", "input_to_evaluate": "import java.util.*;\npublic class Main {\n public static void main(String[] args) throws java.io.IOException{\n Scanner scan = new Scanner(System.in);\n \n while(true){\n \tint n=scan.nextInt();\n \tif(n==0)break;\n \tlong syatiku[] =new long[4001];\n \tfor(int i=0;i<4001;i++)syatiku[i] = 0;\n \tint [] input =new int [n];\n \tfor(int i=0;i=1000000){\n \t\t\tSystem.out.println(input[i]);\n \t\t\tsyatiku[input[i]] =0;\n \t\t\tflag =false;\n \t\t}\n \t}\n \tif(flag)System.out.println(\"NA\");\n }\n }\n}", "problem_context": "Sale Result\n\nThere is data on sales of your company. Your task is to write a program which identifies good workers.\n\nThe program should read a list of data where each item includes the employee ID i, the amount of sales q and the corresponding unit price p. Then, the program should print IDs of employees whose total sales proceeds (i.e. sum of p × q) is greater than or equal to 1,000,000 in the order of inputting. If there is no such employees, the program should print \"NA\". You can suppose that n < 4000, and each employee has an unique ID. The unit price p is less than or equal to 1,000,000 and the amount of sales q is less than or equal to 100,000.\n\nInput\n\nThe input consists of several datasets. The input ends with a line including a single 0. Each dataset consists of:\n\nn (the number of data in the list)\ni p q\ni p q\n:\n:\ni p q\n\nOutput\n\nFor each dataset, print a list of employee IDs or a text \"NA\"\n\nSample Input\n\n4\n1001 2000 520\n1002 1800 450\n1003 1600 625\n1001 200 1220\n2\n1001 100 3\n1005 1000 100\n2\n2013 5000 100\n2013 5000 100\n0\n\nOutput for the Sample Input\n\n1001\n1003\nNA\n2013", "sample_input": "4\n1001 2000 520\n1002 1800 450\n1003 1600 625\n1001 200 1220\n2\n1001 100 3\n1005 1000 100\n2\n2013 5000 100\n2013 5000 100\n0\n"}, "reference_outputs": ["1001\n1003\nNA\n2013\n"], "source_document_id": "p00100", "source_text": "Sale Result\n\nThere is data on sales of your company. Your task is to write a program which identifies good workers.\n\nThe program should read a list of data where each item includes the employee ID i, the amount of sales q and the corresponding unit price p. Then, the program should print IDs of employees whose total sales proceeds (i.e. sum of p × q) is greater than or equal to 1,000,000 in the order of inputting. If there is no such employees, the program should print \"NA\". You can suppose that n < 4000, and each employee has an unique ID. The unit price p is less than or equal to 1,000,000 and the amount of sales q is less than or equal to 100,000.\n\nInput\n\nThe input consists of several datasets. The input ends with a line including a single 0. Each dataset consists of:\n\nn (the number of data in the list)\ni p q\ni p q\n:\n:\ni p q\n\nOutput\n\nFor each dataset, print a list of employee IDs or a text \"NA\"\n\nSample Input\n\n4\n1001 2000 520\n1002 1800 450\n1003 1600 625\n1001 200 1220\n2\n1001 100 3\n1005 1000 100\n2\n2013 5000 100\n2013 5000 100\n0\n\nOutput for the Sample Input\n\n1001\n1003\nNA\n2013", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 793, "cpu_time_ms": 140, "memory_kb": 12000}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s457070344", "group_id": "codeNet:p00112", "input_text": "\nimport java.io.*;\nimport java.util.ArrayDeque;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.Deque;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.NoSuchElementException;\nimport java.util.PriorityQueue;\nimport java.util.Scanner;\npublic class Main {\n\tstatic int[][] list;\n\tpublic static void main(String[] args) {\n\t\t\n\t\tFastScanner sc = new FastScanner();\n\t\tPrintWriter out = new PrintWriter(System.out);\n\t\twhile(true) {\n\t\t\tint n = sc.nextInt();\n\t\t\tif(n == 0) break;\n\t\t\tPriorityQueue que = new PriorityQueue(n);\n\t\t\tfor(int i = 0; i < n; i++) {\n\t\t\t\tque.add(sc.nextInt());\n\t\t\t}\n\t\t\tlong sum = 0;\n\t\t\tlong time = 0;\n\t\t\tfor(int i = 0; i < n; i++) {\n\t\t\t\ttime += sum;\n\t\t\t\tsum += que.poll();\n\t\t\t}\n\t\t\t\n\t\t\tout.println(time);\n\t\t}\n\t\tout.flush();\n\t}\n\tstatic void solv(int a, int b, boolean[] c) {\n\t\tlist[a][b]++;\n\t\tif(a == 9) return;\n\t\tif(b > 1000) return;\n\t\t\n\t\tfor(int i = 0; i < 101; i++) {\n\t\t\tif(a == 8) {\n\t\t\t\tif(!c[i]) {\n\t\t\t\t\tlist[a+1][b+i]++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\telse if(!c[i]) {\n\t\t\t\tc[i] = true;\n\t\t\t\tsolv(a+1,b+i,c);\n\t\t\t\tc[i] = false;\n\t\t\t}\n\t\t}\n\t}\n}\n//------------------------------//\n//-----------//\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n }else{\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}\n private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}\n private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}\n public boolean hasNext() { skipUnprintable(); return hasNextByte();}\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while(isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while(true){\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n \n public int nextInt() {\n \treturn (int)nextLong();\n }\n \n\n}", "language": "Java", "metadata": {"date": 1426354248, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00112.html", "problem_id": "p00112", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00112/input.txt", "sample_output_relpath": "derived/input_output/data/p00112/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00112/Java/s457070344.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s457070344", "user_id": "u722076734"}, "prompt_components": {"gold_output": "31\n", "input_to_evaluate": "\nimport java.io.*;\nimport java.util.ArrayDeque;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.Deque;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.NoSuchElementException;\nimport java.util.PriorityQueue;\nimport java.util.Scanner;\npublic class Main {\n\tstatic int[][] list;\n\tpublic static void main(String[] args) {\n\t\t\n\t\tFastScanner sc = new FastScanner();\n\t\tPrintWriter out = new PrintWriter(System.out);\n\t\twhile(true) {\n\t\t\tint n = sc.nextInt();\n\t\t\tif(n == 0) break;\n\t\t\tPriorityQueue que = new PriorityQueue(n);\n\t\t\tfor(int i = 0; i < n; i++) {\n\t\t\t\tque.add(sc.nextInt());\n\t\t\t}\n\t\t\tlong sum = 0;\n\t\t\tlong time = 0;\n\t\t\tfor(int i = 0; i < n; i++) {\n\t\t\t\ttime += sum;\n\t\t\t\tsum += que.poll();\n\t\t\t}\n\t\t\t\n\t\t\tout.println(time);\n\t\t}\n\t\tout.flush();\n\t}\n\tstatic void solv(int a, int b, boolean[] c) {\n\t\tlist[a][b]++;\n\t\tif(a == 9) return;\n\t\tif(b > 1000) return;\n\t\t\n\t\tfor(int i = 0; i < 101; i++) {\n\t\t\tif(a == 8) {\n\t\t\t\tif(!c[i]) {\n\t\t\t\t\tlist[a+1][b+i]++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\telse if(!c[i]) {\n\t\t\t\tc[i] = true;\n\t\t\t\tsolv(a+1,b+i,c);\n\t\t\t\tc[i] = false;\n\t\t\t}\n\t\t}\n\t}\n}\n//------------------------------//\n//-----------//\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n }else{\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}\n private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}\n private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}\n public boolean hasNext() { skipUnprintable(); return hasNextByte();}\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while(isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while(true){\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n \n public int nextInt() {\n \treturn (int)nextLong();\n }\n \n\n}", "problem_context": "ミルクショップ\n\n鈴木さんは会津地域に新しく搾りたてミルクの移動販売のお店を開きました。その日買い求めに来るお客さんは全員持ち帰るためのボトルを持って既にお店に並んでいて、それ以上増えないものとします。お客さんはそれぞれ1回だけしか注文しません。タンクの蛇口が一つしかないので、一人ずつ順番に販売しなければなりません。そこで、鈴木さんはなるべく並んでいるお客さんの待ち時間を少なくしたいと考えています。\n\nお客さんの人数とお客さんが牛乳を注ぎきるのに要する時間が入力として与えられます。あなたはお客さんの「一人一人の待ち時間の合計」(以下「待ち時間の合計」とする)を最小にするための注文の順序を鈴木さんに代わって調べ、そのときの「待ち時間の合計」を出力して終了するプログラムを作成してください。ただし、お客さんは 10,000 人以下で 1 人あたりに要する時間は 60 分以下とします。\n\n例えば、お客さんの人数が 5 人で、各お客さんが要する時間が順に 2,6,4,3,9 分の場合、そのままの順序だと「待ち時間の合計」は 37 分になります。次の例では、最初の列の順の 2 人目と 3 人目を入れ替えています。この場合、「待ち時間の合計」は 35 分になります。最適な順序だと 31 分で済みます。\n\n待ち時間\n\n1 人目 2 分\n\n0 分\n\n2 人目 6 分\n\n2 分\n\n3 人目 4 分\n\n8 分\n\n4 人目 3 分\n\n12 分\n\n5 人目 9 分\n\n15 分\n\n37 分\n\n← 「待ち時間の合計」\n\n2 人目と 3 人目を入れ替えた例\n\n待ち時間\n\n1 人目 2 分\n\n0 分\n\n2 人目 4 分\n\n2 分\n\n3 人目 6 分\n\n6 分\n\n4 人目 3 分\n\n12 分\n\n5 人目 9 分\n\n15 分\n\n35 分\n\n← 「待ち時間の合計」\n\nInput\n\n複数のデータセットが与えられます。各データセットは以下の形式で与えられます。\n\nn\nt1\nt2\n:\ntn\n\n1 行目にお客さんの人数 n (n ≤ 10,000) が与えられます。続く n 行に i 人目のお客さんが要する時間を表す整数 ti (0 ≤ ti ≤ 60) がそれぞれ1行に与えられます。\n\n入力は1つの 0 を含む行で終わります。データセットの数は 50 を超えません。\n\nOutput\n\n各データセットごとに、待ち時間の合計(整数)を1行に出力してください。\n\nSample Input\n\n5\n2\n6\n4\n3\n9\n0\n\nOutput for the Sample Input\n\n31", "sample_input": "5\n2\n6\n4\n3\n9\n0\n"}, "reference_outputs": ["31\n"], "source_document_id": "p00112", "source_text": "ミルクショップ\n\n鈴木さんは会津地域に新しく搾りたてミルクの移動販売のお店を開きました。その日買い求めに来るお客さんは全員持ち帰るためのボトルを持って既にお店に並んでいて、それ以上増えないものとします。お客さんはそれぞれ1回だけしか注文しません。タンクの蛇口が一つしかないので、一人ずつ順番に販売しなければなりません。そこで、鈴木さんはなるべく並んでいるお客さんの待ち時間を少なくしたいと考えています。\n\nお客さんの人数とお客さんが牛乳を注ぎきるのに要する時間が入力として与えられます。あなたはお客さんの「一人一人の待ち時間の合計」(以下「待ち時間の合計」とする)を最小にするための注文の順序を鈴木さんに代わって調べ、そのときの「待ち時間の合計」を出力して終了するプログラムを作成してください。ただし、お客さんは 10,000 人以下で 1 人あたりに要する時間は 60 分以下とします。\n\n例えば、お客さんの人数が 5 人で、各お客さんが要する時間が順に 2,6,4,3,9 分の場合、そのままの順序だと「待ち時間の合計」は 37 分になります。次の例では、最初の列の順の 2 人目と 3 人目を入れ替えています。この場合、「待ち時間の合計」は 35 分になります。最適な順序だと 31 分で済みます。\n\n待ち時間\n\n1 人目 2 分\n\n0 分\n\n2 人目 6 分\n\n2 分\n\n3 人目 4 分\n\n8 分\n\n4 人目 3 分\n\n12 分\n\n5 人目 9 分\n\n15 分\n\n37 分\n\n← 「待ち時間の合計」\n\n2 人目と 3 人目を入れ替えた例\n\n待ち時間\n\n1 人目 2 分\n\n0 分\n\n2 人目 4 分\n\n2 分\n\n3 人目 6 分\n\n6 分\n\n4 人目 3 分\n\n12 分\n\n5 人目 9 分\n\n15 分\n\n35 分\n\n← 「待ち時間の合計」\n\nInput\n\n複数のデータセットが与えられます。各データセットは以下の形式で与えられます。\n\nn\nt1\nt2\n:\ntn\n\n1 行目にお客さんの人数 n (n ≤ 10,000) が与えられます。続く n 行に i 人目のお客さんが要する時間を表す整数 ti (0 ≤ ti ≤ 60) がそれぞれ1行に与えられます。\n\n入力は1つの 0 を含む行で終わります。データセットの数は 50 を超えません。\n\nOutput\n\n各データセットごとに、待ち時間の合計(整数)を1行に出力してください。\n\nSample Input\n\n5\n2\n6\n4\n3\n9\n0\n\nOutput for the Sample Input\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": 3170, "cpu_time_ms": 100, "memory_kb": 20504}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s473931726", "group_id": "codeNet:p00113", "input_text": "// 過去イチで酷い実装、いつかリファクタリングしたい\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\n\nclass Main {\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String line;\n\n while ((line = br.readLine()) != null) {\n String[] input = line.split(\" \");\n int p = Integer.parseInt(input[0]);\n int q = Integer.parseInt(input[1]);\n String qs = \"\"; // 商の羅列\n int[] rs = new int[81]; // 余りの羅列\n int pos = 0;\n StringBuilder second = new StringBuilder(); // 循環部を表示するため\n boolean isLoop = false;\n\n p -= (p / q) * q; // p < qにする\n rs[pos] = p;\n\n wh: while (true) {\n int sho = (10 * p) / q;\n p = (10 * p) % q;\n\n if (p == 0) {\n qs = qs + sho;\n break;\n }\n\n int i;\n for (i = pos; i >= 0; i--) {\n if (rs[i] == p) {\n qs = qs + sho;\n\n int marklength = qs.length() - i;\n for (int j = 0; j < i; j++) {\n second.append(\" \");\n }\n for (int j = 0; j < marklength; j++) {\n second.append(\"^\");\n }\n isLoop = true;\n break wh;\n }\n }\n\n qs = qs + sho;\n rs[++pos] = p;\n }\n\n if (isLoop) {\n System.out.println(qs);\n System.out.println(second.toString());\n } else {\n System.out.println(qs);\n }\n\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1523339954, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00113.html", "problem_id": "p00113", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00113/input.txt", "sample_output_relpath": "derived/input_output/data/p00113/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00113/Java/s473931726.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s473931726", "user_id": "u813675766"}, "prompt_components": {"gold_output": "083\n ^\n30517578125\n00009\n ^^^\n00000217604178\n ^^^^^^^^^^^^\n", "input_to_evaluate": "// 過去イチで酷い実装、いつかリファクタリングしたい\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\n\nclass Main {\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String line;\n\n while ((line = br.readLine()) != null) {\n String[] input = line.split(\" \");\n int p = Integer.parseInt(input[0]);\n int q = Integer.parseInt(input[1]);\n String qs = \"\"; // 商の羅列\n int[] rs = new int[81]; // 余りの羅列\n int pos = 0;\n StringBuilder second = new StringBuilder(); // 循環部を表示するため\n boolean isLoop = false;\n\n p -= (p / q) * q; // p < qにする\n rs[pos] = p;\n\n wh: while (true) {\n int sho = (10 * p) / q;\n p = (10 * p) % q;\n\n if (p == 0) {\n qs = qs + sho;\n break;\n }\n\n int i;\n for (i = pos; i >= 0; i--) {\n if (rs[i] == p) {\n qs = qs + sho;\n\n int marklength = qs.length() - i;\n for (int j = 0; j < i; j++) {\n second.append(\" \");\n }\n for (int j = 0; j < marklength; j++) {\n second.append(\"^\");\n }\n isLoop = true;\n break wh;\n }\n }\n\n qs = qs + sho;\n rs[++pos] = p;\n }\n\n if (isLoop) {\n System.out.println(qs);\n System.out.println(second.toString());\n } else {\n System.out.println(qs);\n }\n\n }\n }\n}\n", "problem_context": "循環小数\n\n2 つの正の整数 p, q を入力し、 p / q を小数として正確に表現することを考えます。(ただし、0 < p < q < 106とします。)\n\nこのとき、結果は\n\n有限の桁で正確に表現できる。\n\nある桁の範囲を繰り返す循環小数となる。\n\nのいずれかとなります。筆算と同じ手順で1桁ずつ小数部を求めていくと、\n\n割り切れた(余りが 0 になった)なら、そこまでの桁で正確に表現できた。\n\n1度出てきた余りが、再び現れたなら、循環した。\n\nと区別できます。\n\n2 つの整数 p, q を入力すると、 p / q を小数で表した時の、小数部を出力するプログラムを作成してください。 ただし、\n\n結果が有限の桁で正確に表現できる時は、数値だけを 1 行に出力してください。\n\n結果が循環小数になる時は次のように 2 行に出力してください。\n\n最初の行に、循環する部分までの数字を出力してください。\n\n次の行には、循環しない部分の下には空白を出力し、循環する部分の下には「^」を出力してください。\n\nいずれの場合も数字列は 80 文字を超えることはないものとします。\n\nInput\n\n入力は複数のデータセットからなります。各データセットとして、p, q が空白区切りで1行に与えられます。データセットの数は 250 を超えません。\n\nOutput\n\nデータセットごとに、循環しない小数の場合は数値の小数部分を(この場合 1 行)、循環小数の場合は循環するまでの数字と循環する部分を示す記号「^」(この場合 2 行) を出力してください。\n\nSample Input\n\n1 12\n10000 32768\n1 11100\n1 459550\n\nOutput for the Sample Input\n\n083\n^\n30517578125\n00009\n^^^\n00000217604178\n^^^^^^^^^^^^", "sample_input": "1 12\n10000 32768\n1 11100\n1 459550\n"}, "reference_outputs": ["083\n ^\n30517578125\n00009\n ^^^\n00000217604178\n ^^^^^^^^^^^^\n"], "source_document_id": "p00113", "source_text": "循環小数\n\n2 つの正の整数 p, q を入力し、 p / q を小数として正確に表現することを考えます。(ただし、0 < p < q < 106とします。)\n\nこのとき、結果は\n\n有限の桁で正確に表現できる。\n\nある桁の範囲を繰り返す循環小数となる。\n\nのいずれかとなります。筆算と同じ手順で1桁ずつ小数部を求めていくと、\n\n割り切れた(余りが 0 になった)なら、そこまでの桁で正確に表現できた。\n\n1度出てきた余りが、再び現れたなら、循環した。\n\nと区別できます。\n\n2 つの整数 p, q を入力すると、 p / q を小数で表した時の、小数部を出力するプログラムを作成してください。 ただし、\n\n結果が有限の桁で正確に表現できる時は、数値だけを 1 行に出力してください。\n\n結果が循環小数になる時は次のように 2 行に出力してください。\n\n最初の行に、循環する部分までの数字を出力してください。\n\n次の行には、循環しない部分の下には空白を出力し、循環する部分の下には「^」を出力してください。\n\nいずれの場合も数字列は 80 文字を超えることはないものとします。\n\nInput\n\n入力は複数のデータセットからなります。各データセットとして、p, q が空白区切りで1行に与えられます。データセットの数は 250 を超えません。\n\nOutput\n\nデータセットごとに、循環しない小数の場合は数値の小数部分を(この場合 1 行)、循環小数の場合は循環するまでの数字と循環する部分を示す記号「^」(この場合 2 行) を出力してください。\n\nSample Input\n\n1 12\n10000 32768\n1 11100\n1 459550\n\nOutput for the Sample Input\n\n083\n^\n30517578125\n00009\n^^^\n00000217604178\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": 1959, "cpu_time_ms": 60, "memory_kb": 26364}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s540779618", "group_id": "codeNet:p00127", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tstatic char[][] table = new char[6][7];\n\tstatic{\n\t\tint cnt=0;\n\t\tfor(int i = 1;i<7;i++){\n\t\t\tfor(int j =1;j<6;j++){\n\t\t\t\ttable[j][i]=(char)('a'+cnt++);\n\t\t\t}\n\t\t}\n\t\ttable[2][6]='.';\n\t\ttable[3][6]='?';\n\t\ttable[4][6]='!';\n\t\ttable[5][6]=' ';\n\t}\n\tpublic static void main(String[] args) {\n\t\tScanner cin = new Scanner(System.in);\n\t\tlabel:while(cin.hasNext()){\n\t\t\tString str = cin.next();\n\t\t\tif(str.length()%2!=0){\n\t\t\t\tSystem.out.println(\"NA\");\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tString ans = \"\";\n\t\t\tfor(int i = 0;i 5 || a < 1 || a > 6){\n\t\t\t\t\tSystem.out.println(\"NA\");\n\t\t\t\t\tcontinue label;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tans += table[b][a];\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.println(ans);\n\t\t}\n\t}\n\n}", "language": "Java", "metadata": {"date": 1346165603, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00127.html", "problem_id": "p00127", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00127/input.txt", "sample_output_relpath": "derived/input_output/data/p00127/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00127/Java/s540779618.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s540779618", "user_id": "u605441342"}, "prompt_components": {"gold_output": "naruto\nNA\ndo you wanna go to aizu?\nyes sure!\nNA\nna\n?????\nend\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tstatic char[][] table = new char[6][7];\n\tstatic{\n\t\tint cnt=0;\n\t\tfor(int i = 1;i<7;i++){\n\t\t\tfor(int j =1;j<6;j++){\n\t\t\t\ttable[j][i]=(char)('a'+cnt++);\n\t\t\t}\n\t\t}\n\t\ttable[2][6]='.';\n\t\ttable[3][6]='?';\n\t\ttable[4][6]='!';\n\t\ttable[5][6]=' ';\n\t}\n\tpublic static void main(String[] args) {\n\t\tScanner cin = new Scanner(System.in);\n\t\tlabel:while(cin.hasNext()){\n\t\t\tString str = cin.next();\n\t\t\tif(str.length()%2!=0){\n\t\t\t\tSystem.out.println(\"NA\");\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tString ans = \"\";\n\t\t\tfor(int i = 0;i 5 || a < 1 || a > 6){\n\t\t\t\t\tSystem.out.println(\"NA\");\n\t\t\t\t\tcontinue label;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tans += table[b][a];\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.println(ans);\n\t\t}\n\t}\n\n}", "problem_context": "ポケベル打ち\n\nある日、たろう君は、本文に「519345213244」という数字だけが書いてあるおかしなメールを受け取り\nました。そのメールは、10 歳年上の従姉からだったので電話して聞いてみると、「あ、急いでたから\nポケベル打ちで送っちゃった。便利よね。よろしくねっ!」といって切られてしまいました。いつも\nせわしなく、少し強引なところのあるこの従姉をよく知るたろう君は、仕方なく自分で「ポケベル打\nち」について調べてみると、10 年ぐらい前に一世を風靡したかな入力の方法だということが分かりまし\nた。\n\n「ポケベル打ち」では、図 1 のような変換表に従い‘あ’は 11、‘お’は 15 という具合に、2 つの数字\nで一つの文字を入力していきます。例えば「なると」という文字列を入力するには「519345」と打ちま\nす。従って、どの文字も 2 つの数字で入力することができるのです。\n\n図1\n\n携帯電話がまだ広く普及していないころ、高校生はこの方法で公衆電話から友達のポケベルにメッセー\nジを送信していたのだそうです。猛烈なスピードでポケベル打ちができる女子高生もいたとか。最近、\n仕事も忙しくなってきた従姉は、メールを無意識のうちにポケベル打ちでタイプするようになってしま\nいました。\n\nそこで、毎回解読に苦労しているたろう君を助けるために、ポケベル打ちによるメッセージを文字列\nに変換し出力するプログラムを作成してください。ただし、変換には図2の変換表を使い、英\n小文字及び、「.」、「?」、「!」、空白のみを対象とします。変換出来ない文字を含むメッセージに対しては NA と出力してください。\n\n図2\n\nInput\n\n複数のメッセージが与えられます。各行に1つのメッセージ (200 文字以内) が与えられます。メッセージの総数は 50 を超えません。\n\nOutput\n\n各メッセージに対して、変換後のメッセージまたは NA を1行に出力してください。\n\nSample Input\n\n341143514535\n314\n143565553551655311343411652235654535651124615163\n551544654451431564\n4\n3411\n6363636363\n153414\n\nOutput for the Sample Input\n\nnaruto\nNA\ndo you wanna go to aizu?\nyes sure!\nNA\nna\n?????\nend", "sample_input": "341143514535\n314\n143565553551655311343411652235654535651124615163\n551544654451431564\n4\n3411\n6363636363\n153414\n"}, "reference_outputs": ["naruto\nNA\ndo you wanna go to aizu?\nyes sure!\nNA\nna\n?????\nend\n"], "source_document_id": "p00127", "source_text": "ポケベル打ち\n\nある日、たろう君は、本文に「519345213244」という数字だけが書いてあるおかしなメールを受け取り\nました。そのメールは、10 歳年上の従姉からだったので電話して聞いてみると、「あ、急いでたから\nポケベル打ちで送っちゃった。便利よね。よろしくねっ!」といって切られてしまいました。いつも\nせわしなく、少し強引なところのあるこの従姉をよく知るたろう君は、仕方なく自分で「ポケベル打\nち」について調べてみると、10 年ぐらい前に一世を風靡したかな入力の方法だということが分かりまし\nた。\n\n「ポケベル打ち」では、図 1 のような変換表に従い‘あ’は 11、‘お’は 15 という具合に、2 つの数字\nで一つの文字を入力していきます。例えば「なると」という文字列を入力するには「519345」と打ちま\nす。従って、どの文字も 2 つの数字で入力することができるのです。\n\n図1\n\n携帯電話がまだ広く普及していないころ、高校生はこの方法で公衆電話から友達のポケベルにメッセー\nジを送信していたのだそうです。猛烈なスピードでポケベル打ちができる女子高生もいたとか。最近、\n仕事も忙しくなってきた従姉は、メールを無意識のうちにポケベル打ちでタイプするようになってしま\nいました。\n\nそこで、毎回解読に苦労しているたろう君を助けるために、ポケベル打ちによるメッセージを文字列\nに変換し出力するプログラムを作成してください。ただし、変換には図2の変換表を使い、英\n小文字及び、「.」、「?」、「!」、空白のみを対象とします。変換出来ない文字を含むメッセージに対しては NA と出力してください。\n\n図2\n\nInput\n\n複数のメッセージが与えられます。各行に1つのメッセージ (200 文字以内) が与えられます。メッセージの総数は 50 を超えません。\n\nOutput\n\n各メッセージに対して、変換後のメッセージまたは NA を1行に出力してください。\n\nSample Input\n\n341143514535\n314\n143565553551655311343411652235654535651124615163\n551544654451431564\n4\n3411\n6363636363\n153414\n\nOutput for the Sample Input\n\nnaruto\nNA\ndo you wanna go to aizu?\nyes sure!\nNA\nna\n?????\nend", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 844, "cpu_time_ms": 90, "memory_kb": 12000}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s256075389", "group_id": "codeNet:p00130", "input_text": "import java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\t\n\t\tint n = scan.nextInt();\n\t\tchar[] a;\n\t\tint p;\n\t\tint s;\n\t\tint t;\n\t\tchar[] m;\n\t\t\n\t\twhile(n-- != 0){\n\t\t\ta = new char[3000];\n\t\t\tp = 1500;\n\t\t\ts = 1500;\n\t\t\tt = 1500;\n\t\t\t\n\t\t\tm = scan.next().toCharArray();\n\t\t\ta[p] = m[0];\n\t\t\t\n\t\t\tfor(int i = 1; i < m.length;i ++){\n\t\t\t\tif(m[i] == '-')p++;\n\t\t\t\telse p--;\n\t\t\t\ti += 2;\n\t\t\t\ts = Math.min(s, p);\n\t\t\t\tt = Math.max(t, p);\n\t\t\t\ta[p] = m[i];\n\t\t\t}\n\t\t\t\n\t\t\tfor(int i = s; i <= t; i++){\n\t\t\t\tSystem.out.print(a[i]);\n\t\t\t}\n\t\t\tSystem.out.println();\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1474886102, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00130.html", "problem_id": "p00130", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00130/input.txt", "sample_output_relpath": "derived/input_output/data/p00130/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00130/Java/s256075389.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s256075389", "user_id": "u031194354"}, "prompt_components": {"gold_output": "aecbd\nedacb\nbacde\nbcdae\n", "input_to_evaluate": "import java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\t\n\t\tint n = scan.nextInt();\n\t\tchar[] a;\n\t\tint p;\n\t\tint s;\n\t\tint t;\n\t\tchar[] m;\n\t\t\n\t\twhile(n-- != 0){\n\t\t\ta = new char[3000];\n\t\t\tp = 1500;\n\t\t\ts = 1500;\n\t\t\tt = 1500;\n\t\t\t\n\t\t\tm = scan.next().toCharArray();\n\t\t\ta[p] = m[0];\n\t\t\t\n\t\t\tfor(int i = 1; i < m.length;i ++){\n\t\t\t\tif(m[i] == '-')p++;\n\t\t\t\telse p--;\n\t\t\t\ti += 2;\n\t\t\t\ts = Math.min(s, p);\n\t\t\t\tt = Math.max(t, p);\n\t\t\t\ta[p] = m[i];\n\t\t\t}\n\t\t\t\n\t\t\tfor(int i = s; i <= t; i++){\n\t\t\t\tSystem.out.print(a[i]);\n\t\t\t}\n\t\t\tSystem.out.println();\n\t\t}\n\t}\n}", "problem_context": "列車\n\n26 両以下の編成の列車があります。それぞれの車両には、英小文字の a から z までの識別記号が付いています。同じ記号が付いている車両はありません。ただし、車両を連結する順番は自由とします。列車の中を車掌が巡回します。車掌は、列車の中を行ったり来たりして巡回するので、同じ車両を何度も通ることがあります。ただし、すべての車両を最低一回は巡回するものとします。また、巡回をはじめる車両や巡回を終える車両が列車の一番端の車両とは限りません。\n\nある車掌が乗ったすべての列車の巡回記録があります。そこから分かる各列車の編成を先頭車両から出力するプログラムを作成してください。巡回記録は 1 行が 1 つの列車に対応します。各行は、英小文字を 1 文字ずつ <- または -> で区切った文字列でできています。<- は前方の車両への移動、-> は後方の車両への移動を表します。\n\n例えば、a->b<-a<-c は車両 a から後方の車両である b に移り、b から前方の a に移り、a から前方の c へ移ったことを表します。この場合の列車の編成は先頭車両から cab となります。\n\nInput\n\n1行目に巡回記録の個数 n (n ≤ 50)、続く n 行に巡回記録 i を表す文字列 si (1024文字までの半角文字列) が与えられます。\n\nOutput\n\n巡回記録 i について、先頭車両からの列車の編成を現す文字列を i 行目に出力してください。\n\nSample Input\n\n4\na->e->c->b->d\nb<-c<-a<-d<-e\nb->a->c<-a->c->d<-c<-a<-b->a->c->d->e<-d\na->e<-a<-d->a->e<-a<-d<-c->d->a<-d<-c<-b->c->d<-c\n\nOutput for the Sample Input\n\naecbd\nedacb\nbacde\nbcdae", "sample_input": "4\na->e->c->b->d\nb\n"}, "reference_outputs": ["aecbd\nedacb\nbacde\nbcdae\n"], "source_document_id": "p00130", "source_text": "列車\n\n26 両以下の編成の列車があります。それぞれの車両には、英小文字の a から z までの識別記号が付いています。同じ記号が付いている車両はありません。ただし、車両を連結する順番は自由とします。列車の中を車掌が巡回します。車掌は、列車の中を行ったり来たりして巡回するので、同じ車両を何度も通ることがあります。ただし、すべての車両を最低一回は巡回するものとします。また、巡回をはじめる車両や巡回を終える車両が列車の一番端の車両とは限りません。\n\nある車掌が乗ったすべての列車の巡回記録があります。そこから分かる各列車の編成を先頭車両から出力するプログラムを作成してください。巡回記録は 1 行が 1 つの列車に対応します。各行は、英小文字を 1 文字ずつ <- または -> で区切った文字列でできています。<- は前方の車両への移動、-> は後方の車両への移動を表します。\n\n例えば、a->b<-a<-c は車両 a から後方の車両である b に移り、b から前方の a に移り、a から前方の c へ移ったことを表します。この場合の列車の編成は先頭車両から cab となります。\n\nInput\n\n1行目に巡回記録の個数 n (n ≤ 50)、続く n 行に巡回記録 i を表す文字列 si (1024文字までの半角文字列) が与えられます。\n\nOutput\n\n巡回記録 i について、先頭車両からの列車の編成を現す文字列を i 行目に出力してください。\n\nSample Input\n\n4\na->e->c->b->d\nb<-c<-a<-d<-e\nb->a->c<-a->c->d<-c<-a<-b->a->c->d->e<-d\na->e<-a<-d->a->e<-a<-d<-c->d->a<-d<-c<-b->c->d<-c\n\nOutput for the Sample Input\n\naecbd\nedacb\nbacde\nbcdae", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 605, "cpu_time_ms": 80, "memory_kb": 28104}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s378872776", "group_id": "codeNet:p00151", "input_text": "import java.util.*;\n\npublic class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\twhile(true){\n\t\t\tint n = sc.nextInt();\n\t\t\tif(n==0) break;\n\t\t\tint[][] mapV = new int[n+2][n+2];\n\t\t\tint[][] mapH = new int[n+2][n+2];\n\t\t\tint[][] mapRU = new int[n+2][n+2];\n\t\t\tint[][] mapRD = new int[n+2][n+2];\n\t\t\t\n\t\t\tString s = \"\";\n\t\t\tint max = 0;\n\t\t\tfor(int i=1;i<=n;i++){\n\t\t\t\ts = sc.next();\n\t\t\t\tfor(int j=1;j<=n;j++){\n\t\t\t\t\tif(s.codePointAt(j-1)==49){\n\t\t\t\t\t\tmapV[i][j] = mapV[i-1][j]+1;\n\t\t\t\t\t\tmapH[i][j] = mapH[i][j-1]+1;\n\t\t\t\t\t\tmapRU[i][j] = mapRU[i-1][j+1]+1;\n\t\t\t\t\t\tmapRD[i][j] = mapRD[i-1][j-1]+1;\n\t\t\t\t\t\tmax = Math.max(Math.max(Math.max(Math.max(mapV[i][j], mapH[i][j]), mapRU[i][j]),mapRD[i][j]),max);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.println(max);\n\t\t}\n\t}\t\n}", "language": "Java", "metadata": {"date": 1365113734, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00151.html", "problem_id": "p00151", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00151/input.txt", "sample_output_relpath": "derived/input_output/data/p00151/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00151/Java/s378872776.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s378872776", "user_id": "u435518193"}, "prompt_components": {"gold_output": "4\n8\n1\n0\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\twhile(true){\n\t\t\tint n = sc.nextInt();\n\t\t\tif(n==0) break;\n\t\t\tint[][] mapV = new int[n+2][n+2];\n\t\t\tint[][] mapH = new int[n+2][n+2];\n\t\t\tint[][] mapRU = new int[n+2][n+2];\n\t\t\tint[][] mapRD = new int[n+2][n+2];\n\t\t\t\n\t\t\tString s = \"\";\n\t\t\tint max = 0;\n\t\t\tfor(int i=1;i<=n;i++){\n\t\t\t\ts = sc.next();\n\t\t\t\tfor(int j=1;j<=n;j++){\n\t\t\t\t\tif(s.codePointAt(j-1)==49){\n\t\t\t\t\t\tmapV[i][j] = mapV[i-1][j]+1;\n\t\t\t\t\t\tmapH[i][j] = mapH[i][j-1]+1;\n\t\t\t\t\t\tmapRU[i][j] = mapRU[i-1][j+1]+1;\n\t\t\t\t\t\tmapRD[i][j] = mapRD[i-1][j-1]+1;\n\t\t\t\t\t\tmax = Math.max(Math.max(Math.max(Math.max(mapV[i][j], mapH[i][j]), mapRU[i][j]),mapRD[i][j]),max);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.println(max);\n\t\t}\n\t}\t\n}", "problem_context": "Grid\n\nThere is a n × n grid D where each cell contains either 1 or 0.\n\nYour task is to create a program that takes the gird data as input and computes the greatest number of consecutive 1s in either vertical, horizontal, or diagonal direction.\n\nFor example, the consecutive 1s with greatest number in the figure below is circled by the dashed-line.\n\nThe size of the grid n is an integer where 2 ≤ n ≤ 255.\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\nD11 D12 ... D1n\nD21 D22 ... D2n\n.\n.\nDn1 Dn2 ... Dnn\n\nOutput\n\nFor each dataset, print the greatest number of consecutive 1s.\n\nSample Input\n\n5\n00011\n00101\n01000\n10101\n00010\n8\n11000001\n10110111\n01100111\n01111010\n11111111\n01011010\n10100010\n10000001\n2\n01\n00\n3\n000\n000\n000\n0\n\nOutput for the Sample Input\n\n4\n8\n1\n0", "sample_input": "5\n00011\n00101\n01000\n10101\n00010\n8\n11000001\n10110111\n01100111\n01111010\n11111111\n01011010\n10100010\n10000001\n2\n01\n00\n3\n000\n000\n000\n0\n"}, "reference_outputs": ["4\n8\n1\n0\n"], "source_document_id": "p00151", "source_text": "Grid\n\nThere is a n × n grid D where each cell contains either 1 or 0.\n\nYour task is to create a program that takes the gird data as input and computes the greatest number of consecutive 1s in either vertical, horizontal, or diagonal direction.\n\nFor example, the consecutive 1s with greatest number in the figure below is circled by the dashed-line.\n\nThe size of the grid n is an integer where 2 ≤ n ≤ 255.\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\nD11 D12 ... D1n\nD21 D22 ... D2n\n.\n.\nDn1 Dn2 ... Dnn\n\nOutput\n\nFor each dataset, print the greatest number of consecutive 1s.\n\nSample Input\n\n5\n00011\n00101\n01000\n10101\n00010\n8\n11000001\n10110111\n01100111\n01111010\n11111111\n01011010\n10100010\n10000001\n2\n01\n00\n3\n000\n000\n000\n0\n\nOutput for the Sample Input\n\n4\n8\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": 787, "cpu_time_ms": 150, "memory_kb": 29924}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s856752771", "group_id": "codeNet:p00158", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n;\n\t\twhile((n = sc.nextInt()) != 0){\n\t\t\tSystem.out.println(getCount(n));\n\t\t}\n\t}\n\t\n\tprivate static int getCount(int n){\n\t\tint count = 0;\n\t\tint num = n;\n\t\twhile(num != 1){\n\t\t\tif(num % 2 == 0)\tnum /= 2;\n\t\t\telse\t\tnum = num * 3 + 1;\n\t\t\tcount++;\n\t\t}\n\t\treturn count;\n\t}\n}", "language": "Java", "metadata": {"date": 1369996393, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00158.html", "problem_id": "p00158", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00158/input.txt", "sample_output_relpath": "derived/input_output/data/p00158/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00158/Java/s856752771.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s856752771", "user_id": "u985809245"}, "prompt_components": {"gold_output": "7\n6\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n;\n\t\twhile((n = sc.nextInt()) != 0){\n\t\t\tSystem.out.println(getCount(n));\n\t\t}\n\t}\n\t\n\tprivate static int getCount(int n){\n\t\tint count = 0;\n\t\tint num = n;\n\t\twhile(num != 1){\n\t\t\tif(num % 2 == 0)\tnum /= 2;\n\t\t\telse\t\tnum = num * 3 + 1;\n\t\t\tcount++;\n\t\t}\n\t\treturn count;\n\t}\n}", "problem_context": "コラッツの予想\n\n正の整数 n に対し、\n\nn が偶数の時は 2 で割る。\n\nn が奇数の時は 3 倍し、1 を足す。\n\nという操作を繰り返すと結果が 1 になります。任意の正の整数 n に対してこの操作を繰り返すと必ず 1 になるであろうというのが「コラッツの予想」と呼ばれる問題です。この問題は日本では、「角谷の問題」としても知られている未解決の問題です。コンピュータを利用して非常に大きな数 3 × 253 = 27,021,597,764,222,976 以下については反例がないことが知られていますが、数学的には証明されていません。\n\n整数 n を入力とし、結果が 1 になるまでに繰り返される操作の回数を出力するプログラムを作成してください。整数 n は 1 以上でかつ上記の計算を繰り返す途中の値が 1000000 以下となる程度の整数とします。たとえば、入力として 3 を受け取った場合は、操作列は\n\n3 → 10 → 5 → 16 → 8 → 4 → 2 → 1\n\nになるので、操作の回数(上の矢印の個数)である 7 を出力します。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットとして1つの整数 n (n ≤ 1000000) が1行に与えられます。\n\nデータセットの数は 50 を越えない。\n\nOutput\n\nデータセットごとに操作の回数を1行に出力します。\n\nSample Input\n\n3\n10\n0\n\nOutput for the Sample Input\n\n7\n6", "sample_input": "3\n10\n0\n"}, "reference_outputs": ["7\n6\n"], "source_document_id": "p00158", "source_text": "コラッツの予想\n\n正の整数 n に対し、\n\nn が偶数の時は 2 で割る。\n\nn が奇数の時は 3 倍し、1 を足す。\n\nという操作を繰り返すと結果が 1 になります。任意の正の整数 n に対してこの操作を繰り返すと必ず 1 になるであろうというのが「コラッツの予想」と呼ばれる問題です。この問題は日本では、「角谷の問題」としても知られている未解決の問題です。コンピュータを利用して非常に大きな数 3 × 253 = 27,021,597,764,222,976 以下については反例がないことが知られていますが、数学的には証明されていません。\n\n整数 n を入力とし、結果が 1 になるまでに繰り返される操作の回数を出力するプログラムを作成してください。整数 n は 1 以上でかつ上記の計算を繰り返す途中の値が 1000000 以下となる程度の整数とします。たとえば、入力として 3 を受け取った場合は、操作列は\n\n3 → 10 → 5 → 16 → 8 → 4 → 2 → 1\n\nになるので、操作の回数(上の矢印の個数)である 7 を出力します。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットとして1つの整数 n (n ≤ 1000000) が1行に与えられます。\n\nデータセットの数は 50 を越えない。\n\nOutput\n\nデータセットごとに操作の回数を1行に出力します。\n\nSample Input\n\n3\n10\n0\n\nOutput for the Sample Input\n\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": 399, "cpu_time_ms": 50, "memory_kb": 17188}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s050048134", "group_id": "codeNet:p00160", "input_text": "import java.util.Scanner;\nclass Main\n{\n public static void main(String args[])\n {\n\tScanner scan=new Scanner(System.in);\n\twhile(true)\n\t {\n\t\tint sum=0;\n\t\tint n=scan.nextInt();\n\t\tif(n==0)break;\n\t\tfor(int i=0;i= h || b >= w) return false;\n\t\treturn true;\n\t}\n}", "language": "Java", "metadata": {"date": 1435573657, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00210.html", "problem_id": "p00210", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00210/input.txt", "sample_output_relpath": "derived/input_output/data/p00210/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00210/Java/s310076850.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s310076850", "user_id": "u722076734"}, "prompt_components": {"gold_output": "8\nNA\n9\n16\n10\n", "input_to_evaluate": "import java.util.*;\npublic class Main {\n\tstatic int h;\n\tstatic int w;\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\twhile(true) {\n\t\t\tw = sc.nextInt();\n\t\t\th = sc.nextInt();\n\t\t\tif(w == 0 && h == 0) break;\n\t\t\tchar[][] map;\n\t\t\tboolean[][] alMove;\n\t\t\tmap = new char[h][w];\n\t\t\talMove = new boolean[h][w];\n\t\t\tfor(int i = 0; i < h; i++) {\n\t\t\t\tmap[i] = sc.next().toCharArray();\n\t\t\t}\n\t\t\tint i = 0;\n\t\t\tfor(i = 0; i <= 180; i++) {\n\t\t\t\tboolean check = false;\n\t\t\t\tfor(int j = 0; j < h; j++) {\n\t\t\t\t\tfor(int k = 0; k < w; k++) {\n\t\t\t\t\t\tif(map[j][k] == 'E') {\n\t\t\t\t\t\t\tcheck = true;\n\t\t\t\t\t\t\tif (rcheck(j+1,k) && (map[j+1][k] == '.' || map[j+1][k] == 'X')) {\n\t\t\t\t\t\t\t\tmap[j][k] = 'S';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if(rcheck(j,k+1) && (map[j][k+1] == '.' || map[j][k+1] == 'X')) {\n\t\t\t\t\t\t\t\tmap[j][k] = 'E';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if(rcheck(j-1,k) && (map[j-1][k] == '.' || map[j-1][k] == 'X')) {\n\t\t\t\t\t\t\t\tmap[j][k] = 'N';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if(rcheck(j,k-1) && (map[j][k-1] == '.' || map[j][k-1] == 'X')) {\n\t\t\t\t\t\t\t\tmap[j][k] = 'W';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if(map[j][k] == 'N') {\n\t\t\t\t\t\t\tcheck = true;\n\t\t\t\t\t\t\tif (rcheck(j,k+1) && (map[j][k+1] == '.' || map[j][k+1] == 'X')) {\n\t\t\t\t\t\t\t\tmap[j][k] = 'E';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if(rcheck(j-1,k) && (map[j-1][k] == '.' || map[j-1][k] == 'X')) {\n\t\t\t\t\t\t\t\tmap[j][k] = 'N';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if(rcheck(j,k-1) && (map[j][k-1] == '.' || map[j][k-1] == 'X')) {\n\t\t\t\t\t\t\t\tmap[j][k] = 'W';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if(rcheck(j+1,k) && (map[j+1][k] == '.' || map[j+1][k] == 'X')) {\n\t\t\t\t\t\t\t\tmap[j][k] = 'S';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if(map[j][k] == 'W') {\n\t\t\t\t\t\t\tcheck = true;\n\t\t\t\t\t\t\tif (rcheck(j-1,k) && (map[j-1][k] == '.' || map[j-1][k] == 'X')) {\n\t\t\t\t\t\t\t\tmap[j][k] = 'N';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if(rcheck(j,k-1) && (map[j][k-1] == '.' || map[j][k-1] == 'X')) {\n\t\t\t\t\t\t\t\tmap[j][k] = 'W';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if(rcheck(j+1,k) && (map[j+1][k] == '.' || map[j+1][k] == 'X')) {\n\t\t\t\t\t\t\t\tmap[j][k] = 'S';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if(rcheck(j,k+1) && (map[j][k+1] == '.' || map[j][k+1] == 'X')) {\n\t\t\t\t\t\t\t\tmap[j][k] = 'E';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if(map[j][k] == 'S') {\n\t\t\t\t\t\t\tcheck = true;\n\t\t\t\t\t\t\tif (rcheck(j,k-1) && (map[j][k-1] == '.' || map[j][k-1] == 'X')) {\n\t\t\t\t\t\t\t\tmap[j][k] = 'W';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if(rcheck(j+1,k) && (map[j+1][k] == '.' || map[j+1][k] == 'X')) {\n\t\t\t\t\t\t\t\tmap[j][k] = 'S';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if(rcheck(j,k+1) && (map[j][k+1] == '.' || map[j][k+1] == 'X')) {\n\t\t\t\t\t\t\t\tmap[j][k] = 'E';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if(rcheck(j-1,k) && (map[j-1][k] == '.' || map[j-1][k] == 'X')) {\n\t\t\t\t\t\t\t\tmap[j][k] = 'N';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(!check) break;\n\t\t\t\tfor(int j = 0; j < h; j++) {\n\t\t\t\t\tArrays.fill(alMove[j], false);\n\t\t\t\t}\n\t\t\t\tfor(int j = 0; j < h; j++) {\n\t\t\t\t\tIN:for(int k = 0; k < w; k++) {\n\t\t\t\t\t\tif(map[j][k] != '.' && map[j][k] != 'X') continue;\n\t\t\t\t\t\tif(map[j][k] == '.') {\n\t\t\t\t\t\t\tif (rcheck(j,k+1) && !alMove[j][k] && !alMove[j][k+1] && map[j][k+1] == 'W') {\n\t\t\t\t\t\t\t\tmap[j][k+1] = '.';\n\t\t\t\t\t\t\t\tmap[j][k] = 'W';\n\t\t\t\t\t\t\t\talMove[j][k] = true;\n\t\t\t\t\t\t\t\talMove[j][k+1] = true;\n\t\t\t\t\t\t\t\tcontinue IN;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (rcheck(j-1,k) && !alMove[j][k] && !alMove[j-1][k] && map[j-1][k] == 'S') {\n\t\t\t\t\t\t\t\tmap[j-1][k] = '.';\n\t\t\t\t\t\t\t\tmap[j][k] = 'S';\n\t\t\t\t\t\t\t\talMove[j][k] = true;\n\t\t\t\t\t\t\t\talMove[j-1][k] = true;\n\t\t\t\t\t\t\t\tcontinue IN;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (rcheck(j,k-1) && !alMove[j][k] && !alMove[j][k-1] && map[j][k-1] == 'E') {\n\t\t\t\t\t\t\t\tmap[j][k-1] = '.';\n\t\t\t\t\t\t\t\tmap[j][k] = 'E';\n\t\t\t\t\t\t\t\talMove[j][k] = true;\n\t\t\t\t\t\t\t\talMove[j][k-1] = true;\n\t\t\t\t\t\t\t\tcontinue IN;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (rcheck(j+1,k) && !alMove[j][k] && !alMove[j+1][k] && map[j+1][k] == 'N') {\n\t\t\t\t\t\t\t\tmap[j+1][k] = '.';\n\t\t\t\t\t\t\t\tmap[j][k] = 'N';\n\t\t\t\t\t\t\t\talMove[j][k] = true;\n\t\t\t\t\t\t\t\talMove[j+1][k] = true;\n\t\t\t\t\t\t\t\tcontinue IN;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if(map[j][k] == 'X') {\n\t\t\t\t\t\t\tif(rcheck(j,k+1) && map[j][k+1] == 'W' && !alMove[j][k] && !alMove[j][k+1]) {\n\t\t\t\t\t\t\t\tmap[j][k+1] = '.';\n\t\t\t\t\t\t\t\talMove[j][k] = true;\n\t\t\t\t\t\t\t\talMove[j][k+1] = true;\n\t\t\t\t\t\t\t\tcontinue IN;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if(rcheck(j-1,k) && map[j-1][k] == 'S' && !alMove[j][k] && !alMove[j-1][k]) {\n\t\t\t\t\t\t\t\tmap[j-1][k] = '.';\n\t\t\t\t\t\t\t\talMove[j][k] = true;\n\t\t\t\t\t\t\t\talMove[j-1][k] = true;\n\t\t\t\t\t\t\t\tcontinue IN;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if(rcheck(j,k-1) && map[j][k-1] == 'E' && !alMove[j][k] && !alMove[j][k-1]) {\n\t\t\t\t\t\t\t\tmap[j][k-1] = '.';\n\t\t\t\t\t\t\t\talMove[j][k] = true;\n\t\t\t\t\t\t\t\talMove[j][k-1] = true;\n\t\t\t\t\t\t\t\tcontinue IN;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if(rcheck(j+1,k) && map[j+1][k] == 'N' && !alMove[j][k] && !alMove[j+1][k]) {\n\t\t\t\t\t\t\t\tmap[j+1][k] = '.';\n\t\t\t\t\t\t\t\talMove[j][k] = true;\n\t\t\t\t\t\t\t\talMove[j+1][k] = true;\n\t\t\t\t\t\t\t\tcontinue IN;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(i <= 180) {\n\t\t\t\tSystem.out.println(i);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tSystem.out.println(\"NA\");\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static boolean rcheck(int a, int b) {\n\t\tif(a < 0 || b < 0 || a >= h || b >= w) return false;\n\t\treturn true;\n\t}\n}", "problem_context": "ザ・スクエアーズ\n\nこの度、有名なテーマパークに、巨大迷路ザ・スクエアーズが新しく完成しました。 消防署の指導により避難訓練をしなければなりませんが、巨大迷路なだけに訓練にかかる時間を予測することができません。そこで、あなたは以下の仕様をもとに避難訓練シミュレータを開発することになりました。\n\n巨大迷路は図 1 に示すように、横 W 、縦 H の W × H 個のマス目で表わされます。各マス目は、通路(白いマス目)、壁(茶色いマス目) 、非常口(緑のマス目)のいずれかです。図中の○は人を表し、その中の英小文字(E、W、S、N)はその人が向いている方角(東西南北)を表しています。図は上方向が北になるように描かれています。\n\n図1\n\n巨大迷路内にいる人は最初、東西南北のいずれかの方向を向いて立っています。各人は 1 秒単位で同時に次に示す手順で移動を試みます。\n\n現在向いている方向の、右、前、左、後のマス目を順番に調べ、最初に見つけた、空いている通路または非常口の方向に向きを変えます。そのようなマス目が無い場合は向きを変えません。\n\n目の前のマス目が空いていて、他の人の目の前のマス目になっていない場合は移動します。同じマス目を目の前のマスとする人が複数いる場合は、そのマス目の、東、北、西、南のマス目にいる人の順で選択された 1 人が移動します。\n\n移動後に非常口に到着した人は、無事避難し迷路内から消えます。\n\n与えられた巨大迷路と人の位置情報を入力とし、全ての人が避難し終える時間を出力するプログラムを作成してください。 脱出に 180 秒より長い時間を要する場合は NA と出力して下さい。 迷路と人の位置情報は、 H 行 W 列の文字によって与えられます。各文字の意味は以下のとおりです。\n\n# : 壁\n\n. : 床\n\nX : 非常口\n\nE : 東を向いている人\n\nN : 北を向いている人\n\nW : 西を向いている人\n\nS : 南を向いている人\n\nなお、迷路と外部との境界は壁 # または非常口 X のいずれかです。また、巨大迷路の中には、人が必ず1人以上います。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。 入力の終わりはゼロふたつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nW H\nstr1\nstr2\n:\nstrH\n\n1 行目に迷路の横方向の大きさ W、縦方向の大きさ H (1 ≤ W, H ≤ 30) が与えられます。続く H 行に迷路の i 行目を表す文字列 stri (長さ W) が与えられます。\n\nデータセットの数は 50 を超えません。\n\nOutput\n\n入力データセットごとに、全ての人が避難し終える時間を1行に出力します。\n\nSample Input\n\n10 3\n##########\n#E.......X\n##########\n4 4\n####\n#N.#\n#..X\n####\n5 5\n#####\n#N..#\n###.X\n#S..#\n#####\n6 6\n######\n#..#X#\n#.EE.#\n####N#\n#....#\n######\n8 8\n##X#####\n#....E.#\n#####.##\n#.#...##\n#.W.#..#\n#.#.N#.X\n#X##.#.#\n########\n0 0\n\nOutput for the Sample Input\n\n8\nNA\n9\n16\n10", "sample_input": "10 3\n##########\n#E.......X\n##########\n4 4\n####\n#N.#\n#..X\n####\n5 5\n#####\n#N..#\n###.X\n#S..#\n#####\n6 6\n######\n#..#X#\n#.EE.#\n####N#\n#....#\n######\n8 8\n##X#####\n#....E.#\n#####.##\n#.#...##\n#.W.#..#\n#.#.N#.X\n#X##.#.#\n########\n0 0\n"}, "reference_outputs": ["8\nNA\n9\n16\n10\n"], "source_document_id": "p00210", "source_text": "ザ・スクエアーズ\n\nこの度、有名なテーマパークに、巨大迷路ザ・スクエアーズが新しく完成しました。 消防署の指導により避難訓練をしなければなりませんが、巨大迷路なだけに訓練にかかる時間を予測することができません。そこで、あなたは以下の仕様をもとに避難訓練シミュレータを開発することになりました。\n\n巨大迷路は図 1 に示すように、横 W 、縦 H の W × H 個のマス目で表わされます。各マス目は、通路(白いマス目)、壁(茶色いマス目) 、非常口(緑のマス目)のいずれかです。図中の○は人を表し、その中の英小文字(E、W、S、N)はその人が向いている方角(東西南北)を表しています。図は上方向が北になるように描かれています。\n\n図1\n\n巨大迷路内にいる人は最初、東西南北のいずれかの方向を向いて立っています。各人は 1 秒単位で同時に次に示す手順で移動を試みます。\n\n現在向いている方向の、右、前、左、後のマス目を順番に調べ、最初に見つけた、空いている通路または非常口の方向に向きを変えます。そのようなマス目が無い場合は向きを変えません。\n\n目の前のマス目が空いていて、他の人の目の前のマス目になっていない場合は移動します。同じマス目を目の前のマスとする人が複数いる場合は、そのマス目の、東、北、西、南のマス目にいる人の順で選択された 1 人が移動します。\n\n移動後に非常口に到着した人は、無事避難し迷路内から消えます。\n\n与えられた巨大迷路と人の位置情報を入力とし、全ての人が避難し終える時間を出力するプログラムを作成してください。 脱出に 180 秒より長い時間を要する場合は NA と出力して下さい。 迷路と人の位置情報は、 H 行 W 列の文字によって与えられます。各文字の意味は以下のとおりです。\n\n# : 壁\n\n. : 床\n\nX : 非常口\n\nE : 東を向いている人\n\nN : 北を向いている人\n\nW : 西を向いている人\n\nS : 南を向いている人\n\nなお、迷路と外部との境界は壁 # または非常口 X のいずれかです。また、巨大迷路の中には、人が必ず1人以上います。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。 入力の終わりはゼロふたつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nW H\nstr1\nstr2\n:\nstrH\n\n1 行目に迷路の横方向の大きさ W、縦方向の大きさ H (1 ≤ W, H ≤ 30) が与えられます。続く H 行に迷路の i 行目を表す文字列 stri (長さ W) が与えられます。\n\nデータセットの数は 50 を超えません。\n\nOutput\n\n入力データセットごとに、全ての人が避難し終える時間を1行に出力します。\n\nSample Input\n\n10 3\n##########\n#E.......X\n##########\n4 4\n####\n#N.#\n#..X\n####\n5 5\n#####\n#N..#\n###.X\n#S..#\n#####\n6 6\n######\n#..#X#\n#.EE.#\n####N#\n#....#\n######\n8 8\n##X#####\n#....E.#\n#####.##\n#.#...##\n#.W.#..#\n#.#.N#.X\n#X##.#.#\n########\n0 0\n\nOutput for the Sample Input\n\n8\nNA\n9\n16\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": 4918, "cpu_time_ms": 200, "memory_kb": 30672}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s821978817", "group_id": "codeNet:p00215", "input_text": "import java.awt.Point;\nimport java.util.Scanner;\n\npublic class Main {\n\n\t/** ????§??????? */\n\tstatic final String WHITE_SPACE = \" \";\n\n\t/** ??????????????????_X */\n\tstatic int mapSizeX = 0;\n\n\t/** ??????????????????_Y */\n\tstatic int mapSizeY = 0;\n\n\t/** ??????????????° */\n\tstatic int maxNode = 0;\n\n\t/** ????????? */\n\t//\tstatic String[] map = new String[1000 * 1000];\n\n\t/** ????????¢??????????????? */\n\t/** ????????? */\n\t//\tstatic List pachimonList = new ArrayList();\n\t//\tstatic Point[] pachimonList = new Point[1000 * 1000];\n\n\t/**\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\twhile (scanner.hasNextLine()) {\n\t\t\treadMap(scanner);\n\t\t}\n\n\t}\n\n\t/**\n\t * ?????????????????????????????????\n\t * @param scanner ????????£??????\n\t */\n\tprivate static void readMap(Scanner scanner) {\n\t\tString[] mapSizeLine = scanner.nextLine().split(WHITE_SPACE);\n\t\tif (mapSizeLine.length < 2) {\n\t\t\treturn;\n\t\t}\n\n\t\t// ??????????????±????????????\n\t\t//\t\tpachimonList.removeAll(pachimonList);\n\t\tmaxNode = 0;\n\t\t//\t\tmapSizeX = Integer.parseInt(mapSizeLine[0]);\n\t\t//\t\tmapSizeY = Integer.parseInt(mapSizeLine[1]);\n\t\t//\t\tinitializeMap(mapSizeX, mapSizeY);\n\n\t\tfor (int i = 0; i < mapSizeY; i++) {\n\t\t\tString mapInfoLine = scanner.nextLine();\n\t\t\t//\t\t\t\tmapInfoLine = mapInfoLine.replaceAll(\".\", \"9\");\n\t\t\t//\t\t\t\tmapInfoLine = mapInfoLine.replaceAll(\"S\", \"0\");\n\t\t\t//\t\t\t\tmapInfoLine = mapInfoLine.replaceAll(\"G\", \"6\");\n\t\t\tfor (int j = 0; j < mapSizeX; j++) {\n\t\t\t\t//\t\t\t\t\tint val = Integer.valueOf(mapInfoLine.charAt(j));\n\t\t\t\t//\t\t\t\t\tif (val < 9) {\n\t\t\t\t//\t\t\t\t\t\t// ???????????¢????????°????¨????\n\t\t\t\t////\t\t\t\t\t\tpachimonList[maxNode] = createPos(Integer.valueOf(val), calcIndex(j, i));\n\t\t\t\t//\t\t\t\t\t\tmaxNode++;\n\t\t\t\t//\t\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t//\t\tCollections.sort(pachimonList, new Comparator() {\n\t\t//\t\t\t@Override\n\t\t//\t\t\tpublic int compare(Point o1, Point o2) {\n\t\t//\t\t\t\treturn o1.x - o2.x;\n\t\t//\t\t\t}\n\t\t//\t\t});\n\t}\n\n\t//\t/**\n\t//\t * ??????????????¨??????????´???????????????§?????????\n\t//\t */\n\t//\tprivate static void initializeMap(int sizeX, int sizeY) {\n\t//\t\tfor (int i = 0; i < sizeX * sizeY; i++) {\n\t//\t\t\tmap[i] = \"\";\n\t//\t\t}\n\t//\t}\n\n\t/**\n\t * X????????????????????´?????????????????¢???????±???§????¨????
\n\t * ????????????:0?????´??????:6???????????¢???????±???§:1???5
\n\t * Y????????????????????????????????????????´?\n\t * @param type ?????????????????´?????????????????¢???????±???§\n\t * @param index ??????????????????????????????\n\t * @return\n\t */\n\tprivate static Point createPos(int type, int index) {\n\t\treturn new Point(type, index);\n\t}\n\n\t/**\n\t * X??§?¨???¨Y??§?¨???????????????£?????????????????????????????????????????´?????????\n\t *\n\t * @param x X??§?¨?\n\t * @param y Y??§?¨?\n\t * @return\n\t */\n\tprivate static int calcIndex(int x, int y) {\n\t\treturn x * mapSizeY + y;\n\t}\n}", "language": "Java", "metadata": {"date": 1430903089, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00215.html", "problem_id": "p00215", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00215/input.txt", "sample_output_relpath": "derived/input_output/data/p00215/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00215/Java/s821978817.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s821978817", "user_id": "u170030319"}, "prompt_components": {"gold_output": "2 10\nNA\n", "input_to_evaluate": "import java.awt.Point;\nimport java.util.Scanner;\n\npublic class Main {\n\n\t/** ????§??????? */\n\tstatic final String WHITE_SPACE = \" \";\n\n\t/** ??????????????????_X */\n\tstatic int mapSizeX = 0;\n\n\t/** ??????????????????_Y */\n\tstatic int mapSizeY = 0;\n\n\t/** ??????????????° */\n\tstatic int maxNode = 0;\n\n\t/** ????????? */\n\t//\tstatic String[] map = new String[1000 * 1000];\n\n\t/** ????????¢??????????????? */\n\t/** ????????? */\n\t//\tstatic List pachimonList = new ArrayList();\n\t//\tstatic Point[] pachimonList = new Point[1000 * 1000];\n\n\t/**\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\twhile (scanner.hasNextLine()) {\n\t\t\treadMap(scanner);\n\t\t}\n\n\t}\n\n\t/**\n\t * ?????????????????????????????????\n\t * @param scanner ????????£??????\n\t */\n\tprivate static void readMap(Scanner scanner) {\n\t\tString[] mapSizeLine = scanner.nextLine().split(WHITE_SPACE);\n\t\tif (mapSizeLine.length < 2) {\n\t\t\treturn;\n\t\t}\n\n\t\t// ??????????????±????????????\n\t\t//\t\tpachimonList.removeAll(pachimonList);\n\t\tmaxNode = 0;\n\t\t//\t\tmapSizeX = Integer.parseInt(mapSizeLine[0]);\n\t\t//\t\tmapSizeY = Integer.parseInt(mapSizeLine[1]);\n\t\t//\t\tinitializeMap(mapSizeX, mapSizeY);\n\n\t\tfor (int i = 0; i < mapSizeY; i++) {\n\t\t\tString mapInfoLine = scanner.nextLine();\n\t\t\t//\t\t\t\tmapInfoLine = mapInfoLine.replaceAll(\".\", \"9\");\n\t\t\t//\t\t\t\tmapInfoLine = mapInfoLine.replaceAll(\"S\", \"0\");\n\t\t\t//\t\t\t\tmapInfoLine = mapInfoLine.replaceAll(\"G\", \"6\");\n\t\t\tfor (int j = 0; j < mapSizeX; j++) {\n\t\t\t\t//\t\t\t\t\tint val = Integer.valueOf(mapInfoLine.charAt(j));\n\t\t\t\t//\t\t\t\t\tif (val < 9) {\n\t\t\t\t//\t\t\t\t\t\t// ???????????¢????????°????¨????\n\t\t\t\t////\t\t\t\t\t\tpachimonList[maxNode] = createPos(Integer.valueOf(val), calcIndex(j, i));\n\t\t\t\t//\t\t\t\t\t\tmaxNode++;\n\t\t\t\t//\t\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t//\t\tCollections.sort(pachimonList, new Comparator() {\n\t\t//\t\t\t@Override\n\t\t//\t\t\tpublic int compare(Point o1, Point o2) {\n\t\t//\t\t\t\treturn o1.x - o2.x;\n\t\t//\t\t\t}\n\t\t//\t\t});\n\t}\n\n\t//\t/**\n\t//\t * ??????????????¨??????????´???????????????§?????????\n\t//\t */\n\t//\tprivate static void initializeMap(int sizeX, int sizeY) {\n\t//\t\tfor (int i = 0; i < sizeX * sizeY; i++) {\n\t//\t\t\tmap[i] = \"\";\n\t//\t\t}\n\t//\t}\n\n\t/**\n\t * X????????????????????´?????????????????¢???????±???§????¨????
\n\t * ????????????:0?????´??????:6???????????¢???????±???§:1???5
\n\t * Y????????????????????????????????????????´?\n\t * @param type ?????????????????´?????????????????¢???????±???§\n\t * @param index ??????????????????????????????\n\t * @return\n\t */\n\tprivate static Point createPos(int type, int index) {\n\t\treturn new Point(type, index);\n\t}\n\n\t/**\n\t * X??§?¨???¨Y??§?¨???????????????£?????????????????????????????????????????´?????????\n\t *\n\t * @param x X??§?¨?\n\t * @param y Y??§?¨?\n\t * @return\n\t */\n\tprivate static int calcIndex(int x, int y) {\n\t\treturn x * mapSizeY + y;\n\t}\n}", "problem_context": "パチモンクリーチャー\n\n某国で大人気のゲーム、パチモンクリーチャーが日本でリメイクされて発売されました。 ゲームが大好きなあなたは、 このゲームを何度もプレイするうちにどうしたら最速でクリアできるのか考えるようになりました。しかし、いくら考えても最速の攻略方法がわからなかったあなたは、どれだけ早くゲームをクリアできるかを求めるプログラムを作成することにしました。\n\nゲームの詳細は以下の通りです。\n\nパチモンクリーチャー(以下、パチクリ)という生物が多く存在する世界がゲームの舞台です。各パチクリは、火属性、氷属性、木属性、土属性、水属性の 5 種類の属性のいずれか1つの属性を持ちます。ゲームの主人公は、ゲーム開始時に好きな属性のパチクリ一匹を冒険のパートナーとして選びます。そのパチクリと共にゴールを目指し、ゴールにいるライバルを倒してパチクリマスターになることがゲームの目的です。\n\nしかし、ライバルを倒すためには全属性のパチクリがいないと勝てないので、途中で全属性のパチクリを捕まえなければなりません。パチクリを捕まえるには属性がカギとなります。火属性のパチクリは氷属性のパチクリを捕まえることができ、同様に、氷属性は木属性、木属性は土属性、土属性は水属性、水属性は火属性を捕まえることができます。属性の関連は以下の図のようになります。\n\n以下の図はゲームが行われるマップの一例を表しています。\n\n主人公はパチクリを一匹もってスタート地点である「S」から出発し、一マスずつ移動しながらゴール地点である「G」を目指します。その途中で、最初に持っているパチクリ以外の 4 つの属性のパチクリを捕まえ、ゴール地点であるマス目に移動するとゲーム終了となります。\n\n主人公は、今いるマス目から、辺を共有する隣のマス目に移動することができ、それを一回の移動と数えます。主人公がパチクリのいるマスに移動した場合、そのパチクリを捕まえられる属性のパチクリを持っていればそのパチクリを捕まえたことになります。そのマスにいるパチクリを捕まえられるかの可否にかかわらず、すべてのマスに何度でも移動することができます。\n\nマップの大きさ(横方向の列数、縦方向の行数)とマップの初期状態を入力とし、初めに選んだパチクリの属性と、それ以外の 4 つの属性のパチクリを捕まえるのにかかる、スタート地点からゴール地点に至る最小移動数を出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終りはゼロふたつの行で示されます。各データセットは以下の形式で与えられます。\n\nW H\nc11c12...c1W\nc21c22...c2W\n:\ncH1cH2...cHW\n\n1 行目にマップの横方向の列数 W と縦方向の行数 H (2 ≤ W, H ≤ 1000) が与えられます。続く H 行にマップの i 行目の情報が与えられます。入力されるマップには各マスの状態が与えられます。 「S」は主人公のスタート地点を、 「G」はゴール地点を、「1」「2」「3」「4」「5」はそこにいるパチクリの属性を( 1:火属性、 2:氷属性、 3:木属性、 4:土属性、 5:水属性 をそれぞれ表します)、 「.(ピリオド) 」は何もないマスをそれぞれ表します。\n各属性のパチクリの数はそれぞれ 0 以上 1000 以下とします。\n\nデータセットの数は140 を超えません。また、データセットの 80 % について、W, H は100 を超えません。\n\nOutput\n\n入力データセットごとに、最初に選んだパチクリの属性と最小移動数を1行に出力します。なお、どのように初めのパチクリを選んでも、どのような経路で移動してもそれら 4 つの属性のパチクリを捕まえることができない場合は NA と出力してください。 また、最小移動数が同じになるような最初のパチクリの選び方が複数ある場合は、属性の数字が小さいものを出力してください。\n\nSample Input\n\n6 6\nS.1..4\n3..5..\n..4.1.\n4....5\n.2.32.\n5.1..G\n3 2\n...\nS.G\n0 0\n\nOutput for the Sample Input\n\n2 10\nNA", "sample_input": "6 6\nS.1..4\n3..5..\n..4.1.\n4....5\n.2.32.\n5.1..G\n3 2\n...\nS.G\n0 0\n"}, "reference_outputs": ["2 10\nNA\n"], "source_document_id": "p00215", "source_text": "パチモンクリーチャー\n\n某国で大人気のゲーム、パチモンクリーチャーが日本でリメイクされて発売されました。 ゲームが大好きなあなたは、 このゲームを何度もプレイするうちにどうしたら最速でクリアできるのか考えるようになりました。しかし、いくら考えても最速の攻略方法がわからなかったあなたは、どれだけ早くゲームをクリアできるかを求めるプログラムを作成することにしました。\n\nゲームの詳細は以下の通りです。\n\nパチモンクリーチャー(以下、パチクリ)という生物が多く存在する世界がゲームの舞台です。各パチクリは、火属性、氷属性、木属性、土属性、水属性の 5 種類の属性のいずれか1つの属性を持ちます。ゲームの主人公は、ゲーム開始時に好きな属性のパチクリ一匹を冒険のパートナーとして選びます。そのパチクリと共にゴールを目指し、ゴールにいるライバルを倒してパチクリマスターになることがゲームの目的です。\n\nしかし、ライバルを倒すためには全属性のパチクリがいないと勝てないので、途中で全属性のパチクリを捕まえなければなりません。パチクリを捕まえるには属性がカギとなります。火属性のパチクリは氷属性のパチクリを捕まえることができ、同様に、氷属性は木属性、木属性は土属性、土属性は水属性、水属性は火属性を捕まえることができます。属性の関連は以下の図のようになります。\n\n以下の図はゲームが行われるマップの一例を表しています。\n\n主人公はパチクリを一匹もってスタート地点である「S」から出発し、一マスずつ移動しながらゴール地点である「G」を目指します。その途中で、最初に持っているパチクリ以外の 4 つの属性のパチクリを捕まえ、ゴール地点であるマス目に移動するとゲーム終了となります。\n\n主人公は、今いるマス目から、辺を共有する隣のマス目に移動することができ、それを一回の移動と数えます。主人公がパチクリのいるマスに移動した場合、そのパチクリを捕まえられる属性のパチクリを持っていればそのパチクリを捕まえたことになります。そのマスにいるパチクリを捕まえられるかの可否にかかわらず、すべてのマスに何度でも移動することができます。\n\nマップの大きさ(横方向の列数、縦方向の行数)とマップの初期状態を入力とし、初めに選んだパチクリの属性と、それ以外の 4 つの属性のパチクリを捕まえるのにかかる、スタート地点からゴール地点に至る最小移動数を出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終りはゼロふたつの行で示されます。各データセットは以下の形式で与えられます。\n\nW H\nc11c12...c1W\nc21c22...c2W\n:\ncH1cH2...cHW\n\n1 行目にマップの横方向の列数 W と縦方向の行数 H (2 ≤ W, H ≤ 1000) が与えられます。続く H 行にマップの i 行目の情報が与えられます。入力されるマップには各マスの状態が与えられます。 「S」は主人公のスタート地点を、 「G」はゴール地点を、「1」「2」「3」「4」「5」はそこにいるパチクリの属性を( 1:火属性、 2:氷属性、 3:木属性、 4:土属性、 5:水属性 をそれぞれ表します)、 「.(ピリオド) 」は何もないマスをそれぞれ表します。\n各属性のパチクリの数はそれぞれ 0 以上 1000 以下とします。\n\nデータセットの数は140 を超えません。また、データセットの 80 % について、W, H は100 を超えません。\n\nOutput\n\n入力データセットごとに、最初に選んだパチクリの属性と最小移動数を1行に出力します。なお、どのように初めのパチクリを選んでも、どのような経路で移動してもそれら 4 つの属性のパチクリを捕まえることができない場合は NA と出力してください。 また、最小移動数が同じになるような最初のパチクリの選び方が複数ある場合は、属性の数字が小さいものを出力してください。\n\nSample Input\n\n6 6\nS.1..4\n3..5..\n..4.1.\n4....5\n.2.32.\n5.1..G\n3 2\n...\nS.G\n0 0\n\nOutput for the Sample Input\n\n2 10\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": 2830, "cpu_time_ms": 940, "memory_kb": 62772}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s244670670", "group_id": "codeNet:p00216", "input_text": "//Cutting Down Water Bills\nimport java.io.IOException;\nimport java.util.Scanner;\n\nclass Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\n\t\tScanner scan =new Scanner(System.in);\n\t\t\n\t\tint n;\n\t while ((n = scan.nextInt())!=-1) { \n\n\n\t\t\tint p;\n\t\t\tif(n<=10){\n\t\t\t\tp=1150;\n\t\t\t}else if(n<=20){\n\t\t\t\tp=1150+(n-10)*125;\n\t\t\t}else if(n<=30){\n\t\t\t\tp=2400+(n-20)*140;\n\t\t\t}else{\n\t\t\t\tp=3800+(n-30)*160;\n\t\t\t}\n\n\t\t\t System.out.println(4280-p);\n\t\t\t\n\t\t}\n\n\t}\n}", "language": "Java", "metadata": {"date": 1441554164, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00216.html", "problem_id": "p00216", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00216/input.txt", "sample_output_relpath": "derived/input_output/data/p00216/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00216/Java/s244670670.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s244670670", "user_id": "u028376492"}, "prompt_components": {"gold_output": "620\n-1120\n3130\n", "input_to_evaluate": "//Cutting Down Water Bills\nimport java.io.IOException;\nimport java.util.Scanner;\n\nclass Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\n\t\tScanner scan =new Scanner(System.in);\n\t\t\n\t\tint n;\n\t while ((n = scan.nextInt())!=-1) { \n\n\n\t\t\tint p;\n\t\t\tif(n<=10){\n\t\t\t\tp=1150;\n\t\t\t}else if(n<=20){\n\t\t\t\tp=1150+(n-10)*125;\n\t\t\t}else if(n<=30){\n\t\t\t\tp=2400+(n-20)*140;\n\t\t\t}else{\n\t\t\t\tp=3800+(n-30)*160;\n\t\t\t}\n\n\t\t\t System.out.println(4280-p);\n\t\t\t\n\t\t}\n\n\t}\n}", "problem_context": "水道料金\n\n松平さんは、普段からエコに気を付けて生活をしています。先月の水道料金が 4280 円となり、いつも目標としている 4000 円を超えてしまったので、今月は節水に努めてきました。先月と比べて水道料金はどのくらい節約できたのでしょうか。\n\n今月の使用水量 w [m3] を入力とし、先月の水道料金である 4280 円と比較して、どのくらい水道料金を節約できたかを出力するプログラムを作成してください。\n\nなお、水道料金は次のように計算されます。\n\n(水道料金) = (基本料金) + (水量による料金)\n\n水量による料金は下表のように使用量に応じて計算されます。\n\n段階\n\n水量\n\n料金\n\n第 1 段階料金\n\n10 [m3] まで\n\n基本料金 1150 円\n\n第 2 段階料金\n\n10 [m3] 超過 20 [m3] まで\n\n1 [m3] あたり 125 円\n\n第 3 段階料金\n\n20 [m3] 超過 30 [m3] まで\n\n1 [m3] あたり 140 円\n\n第 4 段階料金\n\n30 [m3] 超過分\n\n1 [m3] あたり 160 円\n\n例えば、使用水量 40 [m3] の場合は、\n基本料金 1150 円(第 1 段階) + 10 [m3] × 125 円(第 2 段階) + 10 [m3] × 140 円(第 3 段階) + 10 [m3] × 160 円(第 4 段階) = 5400 円\n\nとなります。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりは -1 ひとつの行で示されます。\n\n各データセットとして、 今月の使用水量を表す整数 w (0 ≤ w ≤ 100) が1行に与えられます。\n\nデータセットの数は 200 を超えません。\n\nOutput\n\n入力データセットごとに、先月の水道料金との差を1行に出力します。\n\nSample Input\n\n29\n40\n0\n-1\n\nOutput for the Sample Input\n\n620\n-1120\n3130", "sample_input": "29\n40\n0\n-1\n"}, "reference_outputs": ["620\n-1120\n3130\n"], "source_document_id": "p00216", "source_text": "水道料金\n\n松平さんは、普段からエコに気を付けて生活をしています。先月の水道料金が 4280 円となり、いつも目標としている 4000 円を超えてしまったので、今月は節水に努めてきました。先月と比べて水道料金はどのくらい節約できたのでしょうか。\n\n今月の使用水量 w [m3] を入力とし、先月の水道料金である 4280 円と比較して、どのくらい水道料金を節約できたかを出力するプログラムを作成してください。\n\nなお、水道料金は次のように計算されます。\n\n(水道料金) = (基本料金) + (水量による料金)\n\n水量による料金は下表のように使用量に応じて計算されます。\n\n段階\n\n水量\n\n料金\n\n第 1 段階料金\n\n10 [m3] まで\n\n基本料金 1150 円\n\n第 2 段階料金\n\n10 [m3] 超過 20 [m3] まで\n\n1 [m3] あたり 125 円\n\n第 3 段階料金\n\n20 [m3] 超過 30 [m3] まで\n\n1 [m3] あたり 140 円\n\n第 4 段階料金\n\n30 [m3] 超過分\n\n1 [m3] あたり 160 円\n\n例えば、使用水量 40 [m3] の場合は、\n基本料金 1150 円(第 1 段階) + 10 [m3] × 125 円(第 2 段階) + 10 [m3] × 140 円(第 3 段階) + 10 [m3] × 160 円(第 4 段階) = 5400 円\n\nとなります。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりは -1 ひとつの行で示されます。\n\n各データセットとして、 今月の使用水量を表す整数 w (0 ≤ w ≤ 100) が1行に与えられます。\n\nデータセットの数は 200 を超えません。\n\nOutput\n\n入力データセットごとに、先月の水道料金との差を1行に出力します。\n\nSample Input\n\n29\n40\n0\n-1\n\nOutput for the Sample Input\n\n620\n-1120\n3130", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 461, "cpu_time_ms": 60, "memory_kb": 18548}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s724490198", "group_id": "codeNet:p00216", "input_text": "import java.util.Scanner;\n\nclass Main {\n\n\tpublic static void main(String[] args) throws java.io.IOException {\n\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tint n;\n\t\twhile ((n = scan.nextInt()) != -1) {\n\n\t\t\tint p;\n\t\t\tif (n <= 10) {\n\t\t\t\tp = 1150;\n\t\t\t} else if (n <= 20) {\n\t\t\t\tp = 1150 + (n - 10) * 125;\n\t\t\t} else if (n <= 30) {\n\t\t\t\tp = 2400 + (n - 20) * 140;\n\t\t\t} else {\n\t\t\t\tp = 3800 + (n - 30) * 160;\n\t\t\t}\n\n\t\t\tSystem.out.println(4280 - p);\n\n\t\t}\n\n\t}\n}", "language": "Java", "metadata": {"date": 1441554266, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00216.html", "problem_id": "p00216", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00216/input.txt", "sample_output_relpath": "derived/input_output/data/p00216/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00216/Java/s724490198.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s724490198", "user_id": "u028376492"}, "prompt_components": {"gold_output": "620\n-1120\n3130\n", "input_to_evaluate": "import java.util.Scanner;\n\nclass Main {\n\n\tpublic static void main(String[] args) throws java.io.IOException {\n\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tint n;\n\t\twhile ((n = scan.nextInt()) != -1) {\n\n\t\t\tint p;\n\t\t\tif (n <= 10) {\n\t\t\t\tp = 1150;\n\t\t\t} else if (n <= 20) {\n\t\t\t\tp = 1150 + (n - 10) * 125;\n\t\t\t} else if (n <= 30) {\n\t\t\t\tp = 2400 + (n - 20) * 140;\n\t\t\t} else {\n\t\t\t\tp = 3800 + (n - 30) * 160;\n\t\t\t}\n\n\t\t\tSystem.out.println(4280 - p);\n\n\t\t}\n\n\t}\n}", "problem_context": "水道料金\n\n松平さんは、普段からエコに気を付けて生活をしています。先月の水道料金が 4280 円となり、いつも目標としている 4000 円を超えてしまったので、今月は節水に努めてきました。先月と比べて水道料金はどのくらい節約できたのでしょうか。\n\n今月の使用水量 w [m3] を入力とし、先月の水道料金である 4280 円と比較して、どのくらい水道料金を節約できたかを出力するプログラムを作成してください。\n\nなお、水道料金は次のように計算されます。\n\n(水道料金) = (基本料金) + (水量による料金)\n\n水量による料金は下表のように使用量に応じて計算されます。\n\n段階\n\n水量\n\n料金\n\n第 1 段階料金\n\n10 [m3] まで\n\n基本料金 1150 円\n\n第 2 段階料金\n\n10 [m3] 超過 20 [m3] まで\n\n1 [m3] あたり 125 円\n\n第 3 段階料金\n\n20 [m3] 超過 30 [m3] まで\n\n1 [m3] あたり 140 円\n\n第 4 段階料金\n\n30 [m3] 超過分\n\n1 [m3] あたり 160 円\n\n例えば、使用水量 40 [m3] の場合は、\n基本料金 1150 円(第 1 段階) + 10 [m3] × 125 円(第 2 段階) + 10 [m3] × 140 円(第 3 段階) + 10 [m3] × 160 円(第 4 段階) = 5400 円\n\nとなります。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりは -1 ひとつの行で示されます。\n\n各データセットとして、 今月の使用水量を表す整数 w (0 ≤ w ≤ 100) が1行に与えられます。\n\nデータセットの数は 200 を超えません。\n\nOutput\n\n入力データセットごとに、先月の水道料金との差を1行に出力します。\n\nSample Input\n\n29\n40\n0\n-1\n\nOutput for the Sample Input\n\n620\n-1120\n3130", "sample_input": "29\n40\n0\n-1\n"}, "reference_outputs": ["620\n-1120\n3130\n"], "source_document_id": "p00216", "source_text": "水道料金\n\n松平さんは、普段からエコに気を付けて生活をしています。先月の水道料金が 4280 円となり、いつも目標としている 4000 円を超えてしまったので、今月は節水に努めてきました。先月と比べて水道料金はどのくらい節約できたのでしょうか。\n\n今月の使用水量 w [m3] を入力とし、先月の水道料金である 4280 円と比較して、どのくらい水道料金を節約できたかを出力するプログラムを作成してください。\n\nなお、水道料金は次のように計算されます。\n\n(水道料金) = (基本料金) + (水量による料金)\n\n水量による料金は下表のように使用量に応じて計算されます。\n\n段階\n\n水量\n\n料金\n\n第 1 段階料金\n\n10 [m3] まで\n\n基本料金 1150 円\n\n第 2 段階料金\n\n10 [m3] 超過 20 [m3] まで\n\n1 [m3] あたり 125 円\n\n第 3 段階料金\n\n20 [m3] 超過 30 [m3] まで\n\n1 [m3] あたり 140 円\n\n第 4 段階料金\n\n30 [m3] 超過分\n\n1 [m3] あたり 160 円\n\n例えば、使用水量 40 [m3] の場合は、\n基本料金 1150 円(第 1 段階) + 10 [m3] × 125 円(第 2 段階) + 10 [m3] × 140 円(第 3 段階) + 10 [m3] × 160 円(第 4 段階) = 5400 円\n\nとなります。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりは -1 ひとつの行で示されます。\n\n各データセットとして、 今月の使用水量を表す整数 w (0 ≤ w ≤ 100) が1行に与えられます。\n\nデータセットの数は 200 を超えません。\n\nOutput\n\n入力データセットごとに、先月の水道料金との差を1行に出力します。\n\nSample Input\n\n29\n40\n0\n-1\n\nOutput for the Sample Input\n\n620\n-1120\n3130", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 50, "memory_kb": 18552}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s406144322", "group_id": "codeNet:p00216", "input_text": "\nimport java.io.*;\nimport java.math.BigDecimal;\nimport java.util.*;\n\n\n// 2011/10/22\n\n//0216@…“¹—¿‹à\npublic class Main {\n\n\t// ƒƒCƒ“ return false‚Å‚¨‚µ‚Ü‚¢\n\tboolean main() throws IOException {\n\n\t\tint[] ir = readIntArray();\n\t\tint w = ir[0];\n\t\tif (w == -1)\n\t\t\treturn false;\n\n\t\tint r;\n\t\tif (w > 30) {\n\t\t\tr = 1150 + 1250 + 1400+ (w-30)*160;\n\t\t}\n\t\telse if (w > 20) {\n\t\t\tr = 1150 + 1250 + (w-20)*140;\n\t\t}\n\t\telse if (w > 10) {\n\t\t\tr = 1150 + (w-10)*125;\n\t\t}\n\t\telse {\n\t\t\tr = 1150;\n\t\t}\n\t\t\n\t\t\n\t\t// ‰ð‚Ì•\\ަ\n\t\tSystem.out.printf(\"%d\\n\", 4280 - r);\n\t\t\n\t\treturn true; // ³íI—¹ ŽŸ‚Ö\n\t}\n\t\n\n//\tprivate final static boolean DEBUG = true; // debug\n\tprivate final static boolean DEBUG = false; // release\n\n\tpublic static void main(String[] args) throws IOException {\n\n\t\tif (DEBUG) {\n\t\t\tlog = System.out;\n\t\t\t\n\t\t\tString inputStr = \"29:0:\";\n\n\t\t\tinputStr = inputStr.replace(\":\", \"\\n\");\n\n\t\t\treader = new BufferedReader(new StringReader(inputStr)); \n\n\t\t}\n\t\telse {\n\t\t\tlog = new PrintStream(new OutputStream() { public void write(int b) {} } ); // ‘‚«ŽÌ‚Ä\n\t\t\treader = new BufferedReader(new InputStreamReader(System.in)); // ƒRƒ“ƒ\\[ƒ‹‚©‚ç\n\t\t}\n\t\t\n\t\t//int N = readIntArray()[0];\n\n\t\tfor(int i = 0; /*i < N*/; i++) {\n\t\t\tboolean b = new Main().main();\n\t\t\tif (!b)\n\t\t\t\tbreak;\n\t\t}\t\t\n\t\t\n\t\treader.close();\n\t}\n\n\t\n\tstatic PrintStream log;\n\tstatic BufferedReader reader;\n\t\n\n\t// •W€“ü—Í‚æ‚è1s•ª‚̃Xƒy[ƒX‹æØ‚è‚̐®”’l‚ð“Ç‚Þ\n\t// EOF‚̏ꍇ‚Ínull‚ð•Ô‚·\n\tprivate static int[] readIntArray() throws IOException {\n\t\t\n\t\tString s = reader.readLine();\n\t\tif (s == null)\n\t\t\treturn null;\n\t\tString[] sp = s.split(\" \");\n\t\tint[] a = new int[sp.length];\n\t\tfor(int i = 0; i < sp.length; i++) {\n\t\t\ta[i] = Integer.parseInt(sp[i]);\n\t\t}\n\t\treturn a;\n\t}\n\t\t\n}", "language": "Java", "metadata": {"date": 1319269387, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00216.html", "problem_id": "p00216", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00216/input.txt", "sample_output_relpath": "derived/input_output/data/p00216/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00216/Java/s406144322.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s406144322", "user_id": "u441981269"}, "prompt_components": {"gold_output": "620\n-1120\n3130\n", "input_to_evaluate": "\nimport java.io.*;\nimport java.math.BigDecimal;\nimport java.util.*;\n\n\n// 2011/10/22\n\n//0216@…“¹—¿‹à\npublic class Main {\n\n\t// ƒƒCƒ“ return false‚Å‚¨‚µ‚Ü‚¢\n\tboolean main() throws IOException {\n\n\t\tint[] ir = readIntArray();\n\t\tint w = ir[0];\n\t\tif (w == -1)\n\t\t\treturn false;\n\n\t\tint r;\n\t\tif (w > 30) {\n\t\t\tr = 1150 + 1250 + 1400+ (w-30)*160;\n\t\t}\n\t\telse if (w > 20) {\n\t\t\tr = 1150 + 1250 + (w-20)*140;\n\t\t}\n\t\telse if (w > 10) {\n\t\t\tr = 1150 + (w-10)*125;\n\t\t}\n\t\telse {\n\t\t\tr = 1150;\n\t\t}\n\t\t\n\t\t\n\t\t// ‰ð‚Ì•\\ަ\n\t\tSystem.out.printf(\"%d\\n\", 4280 - r);\n\t\t\n\t\treturn true; // ³íI—¹ ŽŸ‚Ö\n\t}\n\t\n\n//\tprivate final static boolean DEBUG = true; // debug\n\tprivate final static boolean DEBUG = false; // release\n\n\tpublic static void main(String[] args) throws IOException {\n\n\t\tif (DEBUG) {\n\t\t\tlog = System.out;\n\t\t\t\n\t\t\tString inputStr = \"29:0:\";\n\n\t\t\tinputStr = inputStr.replace(\":\", \"\\n\");\n\n\t\t\treader = new BufferedReader(new StringReader(inputStr)); \n\n\t\t}\n\t\telse {\n\t\t\tlog = new PrintStream(new OutputStream() { public void write(int b) {} } ); // ‘‚«ŽÌ‚Ä\n\t\t\treader = new BufferedReader(new InputStreamReader(System.in)); // ƒRƒ“ƒ\\[ƒ‹‚©‚ç\n\t\t}\n\t\t\n\t\t//int N = readIntArray()[0];\n\n\t\tfor(int i = 0; /*i < N*/; i++) {\n\t\t\tboolean b = new Main().main();\n\t\t\tif (!b)\n\t\t\t\tbreak;\n\t\t}\t\t\n\t\t\n\t\treader.close();\n\t}\n\n\t\n\tstatic PrintStream log;\n\tstatic BufferedReader reader;\n\t\n\n\t// •W€“ü—Í‚æ‚è1s•ª‚̃Xƒy[ƒX‹æØ‚è‚̐®”’l‚ð“Ç‚Þ\n\t// EOF‚̏ꍇ‚Ínull‚ð•Ô‚·\n\tprivate static int[] readIntArray() throws IOException {\n\t\t\n\t\tString s = reader.readLine();\n\t\tif (s == null)\n\t\t\treturn null;\n\t\tString[] sp = s.split(\" \");\n\t\tint[] a = new int[sp.length];\n\t\tfor(int i = 0; i < sp.length; i++) {\n\t\t\ta[i] = Integer.parseInt(sp[i]);\n\t\t}\n\t\treturn a;\n\t}\n\t\t\n}", "problem_context": "水道料金\n\n松平さんは、普段からエコに気を付けて生活をしています。先月の水道料金が 4280 円となり、いつも目標としている 4000 円を超えてしまったので、今月は節水に努めてきました。先月と比べて水道料金はどのくらい節約できたのでしょうか。\n\n今月の使用水量 w [m3] を入力とし、先月の水道料金である 4280 円と比較して、どのくらい水道料金を節約できたかを出力するプログラムを作成してください。\n\nなお、水道料金は次のように計算されます。\n\n(水道料金) = (基本料金) + (水量による料金)\n\n水量による料金は下表のように使用量に応じて計算されます。\n\n段階\n\n水量\n\n料金\n\n第 1 段階料金\n\n10 [m3] まで\n\n基本料金 1150 円\n\n第 2 段階料金\n\n10 [m3] 超過 20 [m3] まで\n\n1 [m3] あたり 125 円\n\n第 3 段階料金\n\n20 [m3] 超過 30 [m3] まで\n\n1 [m3] あたり 140 円\n\n第 4 段階料金\n\n30 [m3] 超過分\n\n1 [m3] あたり 160 円\n\n例えば、使用水量 40 [m3] の場合は、\n基本料金 1150 円(第 1 段階) + 10 [m3] × 125 円(第 2 段階) + 10 [m3] × 140 円(第 3 段階) + 10 [m3] × 160 円(第 4 段階) = 5400 円\n\nとなります。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりは -1 ひとつの行で示されます。\n\n各データセットとして、 今月の使用水量を表す整数 w (0 ≤ w ≤ 100) が1行に与えられます。\n\nデータセットの数は 200 を超えません。\n\nOutput\n\n入力データセットごとに、先月の水道料金との差を1行に出力します。\n\nSample Input\n\n29\n40\n0\n-1\n\nOutput for the Sample Input\n\n620\n-1120\n3130", "sample_input": "29\n40\n0\n-1\n"}, "reference_outputs": ["620\n-1120\n3130\n"], "source_document_id": "p00216", "source_text": "水道料金\n\n松平さんは、普段からエコに気を付けて生活をしています。先月の水道料金が 4280 円となり、いつも目標としている 4000 円を超えてしまったので、今月は節水に努めてきました。先月と比べて水道料金はどのくらい節約できたのでしょうか。\n\n今月の使用水量 w [m3] を入力とし、先月の水道料金である 4280 円と比較して、どのくらい水道料金を節約できたかを出力するプログラムを作成してください。\n\nなお、水道料金は次のように計算されます。\n\n(水道料金) = (基本料金) + (水量による料金)\n\n水量による料金は下表のように使用量に応じて計算されます。\n\n段階\n\n水量\n\n料金\n\n第 1 段階料金\n\n10 [m3] まで\n\n基本料金 1150 円\n\n第 2 段階料金\n\n10 [m3] 超過 20 [m3] まで\n\n1 [m3] あたり 125 円\n\n第 3 段階料金\n\n20 [m3] 超過 30 [m3] まで\n\n1 [m3] あたり 140 円\n\n第 4 段階料金\n\n30 [m3] 超過分\n\n1 [m3] あたり 160 円\n\n例えば、使用水量 40 [m3] の場合は、\n基本料金 1150 円(第 1 段階) + 10 [m3] × 125 円(第 2 段階) + 10 [m3] × 140 円(第 3 段階) + 10 [m3] × 160 円(第 4 段階) = 5400 円\n\nとなります。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりは -1 ひとつの行で示されます。\n\n各データセットとして、 今月の使用水量を表す整数 w (0 ≤ w ≤ 100) が1行に与えられます。\n\nデータセットの数は 200 を超えません。\n\nOutput\n\n入力データセットごとに、先月の水道料金との差を1行に出力します。\n\nSample Input\n\n29\n40\n0\n-1\n\nOutput for the Sample Input\n\n620\n-1120\n3130", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1816, "cpu_time_ms": 90, "memory_kb": 12000}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s905738882", "group_id": "codeNet:p00219", "input_text": "import java.util.*;\n\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int c;\n int[] ice = new int[10];\n for(int i=0;i open = new PriorityQueue();\n\t\t\tint[][] closed = new int[m+n+4][1000];\n\t\t\tfor(int[] tmp : closed) Arrays.fill(tmp,INF);\n\t\t\tint ans = INF;\n\t\t\topen.add(new State(0,0,0));\n\n\t\t\twhile(!open.isEmpty()){\n\t\t\t\tState st = open.poll();\n\t\t\t\tif(closed[st.id][st.used] <= st.cost) continue;\n\t\t\t\tclosed[st.id][st.used] = st.cost;\n\n\t\t\t\tif(st.id == m+n+1){\n\t\t\t\t\tans = Math.min(ans,st.cost);\n\t\t\t\t}\n\n\t\t\t\tfor(int i=0;i ncost)\n\t\t\t\t\t\t\topen.add(new State(ncost,i,nused));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tSystem.out.println(ans);\n\t\t}\n\t}\n}\n\nclass State implements Comparable{\n\tint cost,id,used;\n\n\tState(int cost,int id,int used){\n\t\tthis.cost = cost;\n\t\tthis.id = id;\n\t\tthis.used = used;\n\t}\n\n\tpublic int compareTo(State st){\n\t\treturn this.cost - st.cost;\n\t}\n}", "language": "Java", "metadata": {"date": 1297335786, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00224.html", "problem_id": "p00224", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00224/input.txt", "sample_output_relpath": "derived/input_output/data/p00224/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00224/Java/s696666632.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s696666632", "user_id": "u642549559"}, "prompt_components": {"gold_output": "1\n-2\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint INF = Integer.MAX_VALUE;\n\n\t\twhile(true){\n\t\t\tint m = sc.nextInt();\n\t\t\tint n = sc.nextInt();\n\t\t\tint k = sc.nextInt();\n\t\t\tint d = sc.nextInt();\n\t\t\tif(m == 0) break;\n\n\t\t\tint[] cake = new int[m];\n\t\t\tfor(int i=0;i open = new PriorityQueue();\n\t\t\tint[][] closed = new int[m+n+4][1000];\n\t\t\tfor(int[] tmp : closed) Arrays.fill(tmp,INF);\n\t\t\tint ans = INF;\n\t\t\topen.add(new State(0,0,0));\n\n\t\t\twhile(!open.isEmpty()){\n\t\t\t\tState st = open.poll();\n\t\t\t\tif(closed[st.id][st.used] <= st.cost) continue;\n\t\t\t\tclosed[st.id][st.used] = st.cost;\n\n\t\t\t\tif(st.id == m+n+1){\n\t\t\t\t\tans = Math.min(ans,st.cost);\n\t\t\t\t}\n\n\t\t\t\tfor(int i=0;i ncost)\n\t\t\t\t\t\t\topen.add(new State(ncost,i,nused));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tSystem.out.println(ans);\n\t\t}\n\t}\n}\n\nclass State implements Comparable{\n\tint cost,id,used;\n\n\tState(int cost,int id,int used){\n\t\tthis.cost = cost;\n\t\tthis.id = id;\n\t\tthis.used = used;\n\t}\n\n\tpublic int compareTo(State st){\n\t\treturn this.cost - st.cost;\n\t}\n}", "problem_context": "自転車でダイエット\n\nA さんは甘いものが大好きですが、最近は奥さんからダイエットするように言われています。ある日、A さんが自宅から市役所に出かけるとき、奥さんは自転車で行くことを勧めました。そこでA さんはしぶしぶ自転車に乗って出かけましたが、甘い物の好きな A さんは、途中にあるケーキ屋さんに立ち寄りケーキの食べ歩きをしようと思いつきました。\n\n自転車をこげば走行距離に応じてカロリーが消費されますが、ケーキを食べればその分カロリーが摂取されます。正味の消費カロリーは、自転車をこいで消費したカロリーからケーキを食べて摂取したカロリーを引いた値になります。したがって、正味の消費カロリーが 0 より小さくなることもあります。\n\nケーキ屋さんでケーキを買ったら、 Aさんはその場でケーキを全部食べてしまいます。 Aさんがすべてのケーキ屋さんに立ち寄るとは限りませんが、ケーキ屋さんが存在する地点を通るときには、必ず立ち寄ってケーキを 1 つ買って食べるものとします。ただし、同じケーキ屋さんの前を何度も通るのはさすがに気がひけるので、各ケーキ屋さんに訪れられるのは 1 回だけとします。また、目的地の市役所をいったん通り過ぎてからケーキ屋さんに立ち寄り、その後で市役所に戻って用を済ませてもよいものとし、ケーキ屋さん以外は何度訪れても良いものとします。\n\nA さんの自宅から市役所までの地図情報と、その途中にあるケーキ屋さんで食べられるケーキのカロリーの一覧、単位距離の走行による消費カロリーを入力とし、自宅を出発してから市役所に入るまでの正味の消費カロリーの最小値を出力するプログラムを作成してください。\n\n地図には、A さんの自宅と市役所、ケーキ屋さんとランドマーク(目印)になる建物が書かれています。地図を表す入力データは、A さんの自宅、市役所、ケーキ屋さんとランドマークの各地点の間をつなぐ道があるとき、2 つの地点を表す記号とその間の距離からなる行を含みます。たとえば、5 番目のケーキ屋さんと 3 番目のランドマークの間の距離が 10 なら、入力データは以下のような行を含みます。\n\nC5 L3 10\n\nこのようにケーキ屋さんには C、ランドマークには L を番号の前につけて表します。また、A さんの自宅は H、市役所は D で表します。入力データに 2 つの地点とその間の距離が与えられているなら、2 地点の間をどちら向きにも進めます。たとえば、上の例ではケーキ屋さんからランドマークへも、その逆向きへも進むことができます。また、自宅から市役所までは必ずたどり着けるものとします。それ以外に与えられる入力データは、ケーキ屋さんの数 m、ランドマークの数 n、単位距離あたりの消費カロリー k、 1 番目のケーキ屋さんから m 番目のケーキ屋さんまでのそれぞれで買えるケーキのカロリーを表す m 個のデータ、距離のデータの総数 d です。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりは四つの 0 の行で示されます。\n各データセットは以下の形式で与えられます。\n\nm n k d\nc1 c2 ... cm\ns1 t1 e1\ns2 t2 e2\n:\nsd td ed\n\n1 行目にケーキ屋さんの数 m (1 ≤ m ≤ 6)、 ランドマークの数 n (1 ≤ n ≤ 100) 、単位距離あたりの消費カロリー k (1 ≤ k ≤ 5)、距離のデータの総数 d (5 ≤ d ≤ 256) が与えられます。\n\n2 行目に各ケーキ屋で買うケーキのカロリー ci (1 ≤ ci ≤ 100) が与えられます。\n\n続く d 行に i 番目の 2 つの地点間の距離データ si, ti, ei (1 ≤ ei ≤ 20) が与えられます。\n\nデータセットの数は 100 を超えません。\n\nOutput\n\n入力データセットごとに、全体の消費カロリーの最小値を1行に出力します。\n\nSample Input\n\n1 1 2 5\n35\nH L1 5\nC1 D 6\nC1 H 12\nL1 D 10\nC1 L1 20\n2 1 4 6\n100 70\nH L1 5\nC1 L1 12\nC1 D 11\nC2 L1 7\nC2 D 15\nL1 D 8\n0 0 0 0\n\nOutput for the Sample Input\n\n1\n-2", "sample_input": "1 1 2 5\n35\nH L1 5\nC1 D 6\nC1 H 12\nL1 D 10\nC1 L1 20\n2 1 4 6\n100 70\nH L1 5\nC1 L1 12\nC1 D 11\nC2 L1 7\nC2 D 15\nL1 D 8\n0 0 0 0\n"}, "reference_outputs": ["1\n-2\n"], "source_document_id": "p00224", "source_text": "自転車でダイエット\n\nA さんは甘いものが大好きですが、最近は奥さんからダイエットするように言われています。ある日、A さんが自宅から市役所に出かけるとき、奥さんは自転車で行くことを勧めました。そこでA さんはしぶしぶ自転車に乗って出かけましたが、甘い物の好きな A さんは、途中にあるケーキ屋さんに立ち寄りケーキの食べ歩きをしようと思いつきました。\n\n自転車をこげば走行距離に応じてカロリーが消費されますが、ケーキを食べればその分カロリーが摂取されます。正味の消費カロリーは、自転車をこいで消費したカロリーからケーキを食べて摂取したカロリーを引いた値になります。したがって、正味の消費カロリーが 0 より小さくなることもあります。\n\nケーキ屋さんでケーキを買ったら、 Aさんはその場でケーキを全部食べてしまいます。 Aさんがすべてのケーキ屋さんに立ち寄るとは限りませんが、ケーキ屋さんが存在する地点を通るときには、必ず立ち寄ってケーキを 1 つ買って食べるものとします。ただし、同じケーキ屋さんの前を何度も通るのはさすがに気がひけるので、各ケーキ屋さんに訪れられるのは 1 回だけとします。また、目的地の市役所をいったん通り過ぎてからケーキ屋さんに立ち寄り、その後で市役所に戻って用を済ませてもよいものとし、ケーキ屋さん以外は何度訪れても良いものとします。\n\nA さんの自宅から市役所までの地図情報と、その途中にあるケーキ屋さんで食べられるケーキのカロリーの一覧、単位距離の走行による消費カロリーを入力とし、自宅を出発してから市役所に入るまでの正味の消費カロリーの最小値を出力するプログラムを作成してください。\n\n地図には、A さんの自宅と市役所、ケーキ屋さんとランドマーク(目印)になる建物が書かれています。地図を表す入力データは、A さんの自宅、市役所、ケーキ屋さんとランドマークの各地点の間をつなぐ道があるとき、2 つの地点を表す記号とその間の距離からなる行を含みます。たとえば、5 番目のケーキ屋さんと 3 番目のランドマークの間の距離が 10 なら、入力データは以下のような行を含みます。\n\nC5 L3 10\n\nこのようにケーキ屋さんには C、ランドマークには L を番号の前につけて表します。また、A さんの自宅は H、市役所は D で表します。入力データに 2 つの地点とその間の距離が与えられているなら、2 地点の間をどちら向きにも進めます。たとえば、上の例ではケーキ屋さんからランドマークへも、その逆向きへも進むことができます。また、自宅から市役所までは必ずたどり着けるものとします。それ以外に与えられる入力データは、ケーキ屋さんの数 m、ランドマークの数 n、単位距離あたりの消費カロリー k、 1 番目のケーキ屋さんから m 番目のケーキ屋さんまでのそれぞれで買えるケーキのカロリーを表す m 個のデータ、距離のデータの総数 d です。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりは四つの 0 の行で示されます。\n各データセットは以下の形式で与えられます。\n\nm n k d\nc1 c2 ... cm\ns1 t1 e1\ns2 t2 e2\n:\nsd td ed\n\n1 行目にケーキ屋さんの数 m (1 ≤ m ≤ 6)、 ランドマークの数 n (1 ≤ n ≤ 100) 、単位距離あたりの消費カロリー k (1 ≤ k ≤ 5)、距離のデータの総数 d (5 ≤ d ≤ 256) が与えられます。\n\n2 行目に各ケーキ屋で買うケーキのカロリー ci (1 ≤ ci ≤ 100) が与えられます。\n\n続く d 行に i 番目の 2 つの地点間の距離データ si, ti, ei (1 ≤ ei ≤ 20) が与えられます。\n\nデータセットの数は 100 を超えません。\n\nOutput\n\n入力データセットごとに、全体の消費カロリーの最小値を1行に出力します。\n\nSample Input\n\n1 1 2 5\n35\nH L1 5\nC1 D 6\nC1 H 12\nL1 D 10\nC1 L1 20\n2 1 4 6\n100 70\nH L1 5\nC1 L1 12\nC1 D 11\nC2 L1 7\nC2 D 15\nL1 D 8\n0 0 0 0\n\nOutput for the Sample Input\n\n1\n-2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2178, "cpu_time_ms": 610, "memory_kb": 17000}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s748972954", "group_id": "codeNet:p00225", "input_text": "import java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\nimport java.util.Scanner;\n\npublic class Main {\n\t\n\tvoid run() {\n\n\t\tScanner in = new Scanner(System.in);\n\n\t\twhile(true) {\n\n\t\t\tint N = Integer.parseInt(in.next());\n\t\t\t\n\t\t\tif (N == 0) break;\n\t\t\t\n\t\t\tList wordList = new ArrayList();\n\t\t\t\n\t\t\tfor(int i = 0; i < N; i++) {\n\t\t\t\tString word = in.next();\n\t\t\t\twordList.add(word.substring(0, 1));\n\t\t\t\twordList.add(word.substring(word.length() - 1, word.length()));\n\t\t\t}\n\t\t\t\n\t\t\tCollections.sort(wordList);\n\t\t\t\n\t\t\tif(check(wordList)) {\n\t\t\t\tSystem.out.println(\"OK\");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(\"NG\");\n\t\t\t}\n\t\t}\n\t}\n\t\n\tboolean check(List wordList) {\n\t\t\n\t\tint count = 1;\n\t\tString word1 = wordList.get(0);\n\t\tfor(int i = 1; i < wordList.size(); i++) {\n\t\t\tString word2 = wordList.get(i);\n\t\t\tif(word1.equals(word2)) { \n\t\t\t\tcount++; \n\t\t\t} else {\n\t\t\t\tif(count == 2 || count % 2 != 0) return false;\n\t\t\t\tword1 = word2;\n\t\t\t\tcount = 1;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n}", "language": "Java", "metadata": {"date": 1445523083, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00225.html", "problem_id": "p00225", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00225/input.txt", "sample_output_relpath": "derived/input_output/data/p00225/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00225/Java/s748972954.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s748972954", "user_id": "u524272704"}, "prompt_components": {"gold_output": "NG\nOK\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\nimport java.util.Scanner;\n\npublic class Main {\n\t\n\tvoid run() {\n\n\t\tScanner in = new Scanner(System.in);\n\n\t\twhile(true) {\n\n\t\t\tint N = Integer.parseInt(in.next());\n\t\t\t\n\t\t\tif (N == 0) break;\n\t\t\t\n\t\t\tList wordList = new ArrayList();\n\t\t\t\n\t\t\tfor(int i = 0; i < N; i++) {\n\t\t\t\tString word = in.next();\n\t\t\t\twordList.add(word.substring(0, 1));\n\t\t\t\twordList.add(word.substring(word.length() - 1, word.length()));\n\t\t\t}\n\t\t\t\n\t\t\tCollections.sort(wordList);\n\t\t\t\n\t\t\tif(check(wordList)) {\n\t\t\t\tSystem.out.println(\"OK\");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(\"NG\");\n\t\t\t}\n\t\t}\n\t}\n\t\n\tboolean check(List wordList) {\n\t\t\n\t\tint count = 1;\n\t\tString word1 = wordList.get(0);\n\t\tfor(int i = 1; i < wordList.size(); i++) {\n\t\t\tString word2 = wordList.get(i);\n\t\t\tif(word1.equals(word2)) { \n\t\t\t\tcount++; \n\t\t\t} else {\n\t\t\t\tif(count == 2 || count % 2 != 0) return false;\n\t\t\t\tword1 = word2;\n\t\t\t\tcount = 1;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n}", "problem_context": "こぶたぬきつねこ\n\nA子さんの家に親戚のB男君がやってきました。彼は3歳で歌が大好きです。彼は幼稚園でならった「こぶたぬきつねこ」(山本直純作詞・作曲)という歌を一生懸命に歌っています。この歌では、4つのことば「こぶた」 「たぬき」 「きつね」「ねこ」が順にしりとりになっていて、さらに最後の音と最初の音が同じになっています。B男君は、A子さんに、同じようなしりとりが、B男君が言った単語から作れるか教えて欲しいと言われました。\n\nそこで、A子さんを助けるために、与えられた単語から、その単語をすべて使って、順にしりとりをつくり、その上で、 第1 の単語の最初の文字と最終の単語の最後の文字が同じであるようにできるか否かを判定するプログラムを作成しましょう。\n\nn 個の単語を入力とし、それらの単語の組からしりとりを作成できるか否かを判定し、可能な場合はOK と、不可能な場合は NG と出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn\nword1\nword2\n:\nwordn\n\n1 行目に単語の個数 n (2 ≤ n ≤ 10000) が与えられます。続く n 行に n 個の単語 wordi (32 文字以下の半角英小文字だけからなる文字列) が与えられます。\n\nデータセットの数は 50 を超えません。\n\nOutput\n\n入力データセットごとに、判定結果を1行に出力します。\n\nSample Input\n\n5\napple\nyellow\ngeorgia\nking\nemail\n7\napple\nyellow\ngeorgia\nking\nemail\nwink\nlucky\n0\n\nOutput for the Sample Input\n\nNG\nOK", "sample_input": "5\napple\nyellow\ngeorgia\nking\nemail\n7\napple\nyellow\ngeorgia\nking\nemail\nwink\nlucky\n0\n"}, "reference_outputs": ["NG\nOK\n"], "source_document_id": "p00225", "source_text": "こぶたぬきつねこ\n\nA子さんの家に親戚のB男君がやってきました。彼は3歳で歌が大好きです。彼は幼稚園でならった「こぶたぬきつねこ」(山本直純作詞・作曲)という歌を一生懸命に歌っています。この歌では、4つのことば「こぶた」 「たぬき」 「きつね」「ねこ」が順にしりとりになっていて、さらに最後の音と最初の音が同じになっています。B男君は、A子さんに、同じようなしりとりが、B男君が言った単語から作れるか教えて欲しいと言われました。\n\nそこで、A子さんを助けるために、与えられた単語から、その単語をすべて使って、順にしりとりをつくり、その上で、 第1 の単語の最初の文字と最終の単語の最後の文字が同じであるようにできるか否かを判定するプログラムを作成しましょう。\n\nn 個の単語を入力とし、それらの単語の組からしりとりを作成できるか否かを判定し、可能な場合はOK と、不可能な場合は NG と出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn\nword1\nword2\n:\nwordn\n\n1 行目に単語の個数 n (2 ≤ n ≤ 10000) が与えられます。続く n 行に n 個の単語 wordi (32 文字以下の半角英小文字だけからなる文字列) が与えられます。\n\nデータセットの数は 50 を超えません。\n\nOutput\n\n入力データセットごとに、判定結果を1行に出力します。\n\nSample Input\n\n5\napple\nyellow\ngeorgia\nking\nemail\n7\napple\nyellow\ngeorgia\nking\nemail\nwink\nlucky\n0\n\nOutput for the Sample Input\n\nNG\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": 1061, "cpu_time_ms": 410, "memory_kb": 55320}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s235279943", "group_id": "codeNet:p00227", "input_text": "import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.LinkedList;\nimport java.util.Scanner;\n\n\npublic class Main {\n\t\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\twhile(true){\n\t\t\tfinal int n = sc.nextInt();\n\t\t\tfinal int m = sc.nextInt();\n\t\t\t\n\t\t\tif(n == 0 && m == 0){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\tLinkedList list = new LinkedList();\n\t\t\t\n\t\t\tfor(int i = 0; i < n; i++){\n\t\t\t\tlist.add(sc.nextInt());\n\t\t\t}\n\t\t\t\n\t\t\tCollections.sort(list);\n\t\t\tCollections.reverse(list);\n\n\t\t\tint cost = 0;\n\t\t\t\n\t\t\twhile(list.size() >= m){\n\t\t\t\tfor(int i = 0; i < (m - 1); i++){\n\t\t\t\t\tcost += list.poll();\n\t\t\t\t}\n\t\t\t\tlist.poll();\n\t\t\t}\n\t\t\t\n\t\t\tif(!list.isEmpty()){\n\t\t\t\tfor(int i : list){\n\t\t\t\t\tcost += i;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tSystem.out.println(cost);\n\t\t}\n\t\t\n\t}\n}", "language": "Java", "metadata": {"date": 1348567532, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00227.html", "problem_id": "p00227", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00227/input.txt", "sample_output_relpath": "derived/input_output/data/p00227/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00227/Java/s235279943.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s235279943", "user_id": "u197786702"}, "prompt_components": {"gold_output": "150\n2100\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.LinkedList;\nimport java.util.Scanner;\n\n\npublic class Main {\n\t\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\twhile(true){\n\t\t\tfinal int n = sc.nextInt();\n\t\t\tfinal int m = sc.nextInt();\n\t\t\t\n\t\t\tif(n == 0 && m == 0){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\tLinkedList list = new LinkedList();\n\t\t\t\n\t\t\tfor(int i = 0; i < n; i++){\n\t\t\t\tlist.add(sc.nextInt());\n\t\t\t}\n\t\t\t\n\t\t\tCollections.sort(list);\n\t\t\tCollections.reverse(list);\n\n\t\t\tint cost = 0;\n\t\t\t\n\t\t\twhile(list.size() >= m){\n\t\t\t\tfor(int i = 0; i < (m - 1); i++){\n\t\t\t\t\tcost += list.poll();\n\t\t\t\t}\n\t\t\t\tlist.poll();\n\t\t\t}\n\t\t\t\n\t\t\tif(!list.isEmpty()){\n\t\t\t\tfor(int i : list){\n\t\t\t\t\tcost += i;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tSystem.out.println(cost);\n\t\t}\n\t\t\n\t}\n}", "problem_context": "お客様大感謝祭\n\n悪天候が続き野菜の価格が高騰する中、セブンマートではお客様に野菜のまとめ買いセールを実施しています。 日ごろなかなか店頭に並ばない野菜もお手頃価格で手に入るとあって、 店内はとても賑わっています。\n\nある日、松長団地に住む仲良し 3 人組がセブンマートの広告を手に話に花を咲かせていました。今回のセールは「お客様大感謝祭」と銘打っただけに、袋詰めした野菜の中で最も安いものが無料になるのが目玉となっています。広告を読んでみると、どうやら以下のようなセールのようです。\n\n1 つの袋には m 個まで野菜を詰められる。\n\n野菜が m 個詰めてある袋については、その中で最も安い野菜が無料となる。\n\n野菜の個数が m 個に達しない袋は割引の対象外。\n\n3人は早速セブンマートへ買い物に行きました。\n\n買い物が終わり、 お店の外で待ち合わせた 3 人は安くてたくさん購入できたことに満足した様子で話をしていると、どうやら 3 人とも同じ野菜を購入していたことが分かりました。ある一人が、「本当に安いわよねぇ。これでXXX円だもの!」と言うと、もう一人は、「え?私はそれより**円高かったわ!どうして?」と驚き、また、残りの一人はレシートを見て自分が一番安く購入したことに気付きました。\n\nさて、どのように袋詰めすれば購入価格を一番安くできるでしょうか。 購入する野菜の個数、袋に入る野菜の個数、各野菜の値段を入力とし、最低購入価格を出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロふたつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn m\np1 p2 ... pn\n\n1 行目に購入する野菜の個数 n (1 ≤ n ≤ 1000) と袋に入る野菜の個数 m (1 ≤ m ≤ 1000) が与えられます。2行目に各野菜の値段 pi (10 ≤ pi ≤ 10000) が与えられます。\n\nデータセットの数は 100 を超えません。\n\nOutput\n\n入力データセットごとに、最低購入価格を1行に出力します。\n\nSample Input\n\n4 2\n50 40 100 80\n7 3\n400 300 100 700 200 600 500\n0 0\n\nOutput for the Sample Input\n\n150\n2100", "sample_input": "4 2\n50 40 100 80\n7 3\n400 300 100 700 200 600 500\n0 0\n"}, "reference_outputs": ["150\n2100\n"], "source_document_id": "p00227", "source_text": "お客様大感謝祭\n\n悪天候が続き野菜の価格が高騰する中、セブンマートではお客様に野菜のまとめ買いセールを実施しています。 日ごろなかなか店頭に並ばない野菜もお手頃価格で手に入るとあって、 店内はとても賑わっています。\n\nある日、松長団地に住む仲良し 3 人組がセブンマートの広告を手に話に花を咲かせていました。今回のセールは「お客様大感謝祭」と銘打っただけに、袋詰めした野菜の中で最も安いものが無料になるのが目玉となっています。広告を読んでみると、どうやら以下のようなセールのようです。\n\n1 つの袋には m 個まで野菜を詰められる。\n\n野菜が m 個詰めてある袋については、その中で最も安い野菜が無料となる。\n\n野菜の個数が m 個に達しない袋は割引の対象外。\n\n3人は早速セブンマートへ買い物に行きました。\n\n買い物が終わり、 お店の外で待ち合わせた 3 人は安くてたくさん購入できたことに満足した様子で話をしていると、どうやら 3 人とも同じ野菜を購入していたことが分かりました。ある一人が、「本当に安いわよねぇ。これでXXX円だもの!」と言うと、もう一人は、「え?私はそれより**円高かったわ!どうして?」と驚き、また、残りの一人はレシートを見て自分が一番安く購入したことに気付きました。\n\nさて、どのように袋詰めすれば購入価格を一番安くできるでしょうか。 購入する野菜の個数、袋に入る野菜の個数、各野菜の値段を入力とし、最低購入価格を出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロふたつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn m\np1 p2 ... pn\n\n1 行目に購入する野菜の個数 n (1 ≤ n ≤ 1000) と袋に入る野菜の個数 m (1 ≤ m ≤ 1000) が与えられます。2行目に各野菜の値段 pi (10 ≤ pi ≤ 10000) が与えられます。\n\nデータセットの数は 100 を超えません。\n\nOutput\n\n入力データセットごとに、最低購入価格を1行に出力します。\n\nSample Input\n\n4 2\n50 40 100 80\n7 3\n400 300 100 700 200 600 500\n0 0\n\nOutput for the Sample Input\n\n150\n2100", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 823, "cpu_time_ms": 230, "memory_kb": 13000}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s060898374", "group_id": "codeNet:p00239", "input_text": "import java.util.*;\n\npublic class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\twhile(true){\n\t\t\tint n = sc.nextInt();\n\t\t\tif(n==0) break;\n\t\t\t\n\t\t\tint[][] map = new int[n+1][4];\n\t\t\tfor(int i=0;i<=n;i++){\n\t\t\t\tfor(int j=0;j<4;j++){\n\t\t\t\t\tmap[i][j] = sc.nextInt();\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tboolean out = true;\n\t\t\tboolean flag = true;\n\t\t\tfor(int i=0;imap[n][0]) flag = false; \n\t\t\t\telse if(map[i][2]>map[n][1]) flag = false;\n\t\t\t\telse if(map[i][3]>map[n][2]) flag = false;\n\t\t\t\telse if(map[i][1]*4+map[i][2]*9+map[i][3]*4>map[n][3]) flag = false;\n\t\t\t\tif(flag==true){\n\t\t\t\t\tSystem.out.println(map[i][0]);\n\t\t\t\t\tout = false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(out==true) System.out.println(\"NA\");\n\t\t}\n\t}\t\n}", "language": "Java", "metadata": {"date": 1365200490, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00239.html", "problem_id": "p00239", "resource_group": "high_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/Java/s060898374.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s060898374", "user_id": "u435518193"}, "prompt_components": {"gold_output": "1\n4\nNA\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\twhile(true){\n\t\t\tint n = sc.nextInt();\n\t\t\tif(n==0) break;\n\t\t\t\n\t\t\tint[][] map = new int[n+1][4];\n\t\t\tfor(int i=0;i<=n;i++){\n\t\t\t\tfor(int j=0;j<4;j++){\n\t\t\t\t\tmap[i][j] = sc.nextInt();\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tboolean out = true;\n\t\t\tboolean flag = true;\n\t\t\tfor(int i=0;imap[n][0]) flag = false; \n\t\t\t\telse if(map[i][2]>map[n][1]) flag = false;\n\t\t\t\telse if(map[i][3]>map[n][2]) flag = false;\n\t\t\t\telse if(map[i][1]*4+map[i][2]*9+map[i][3]*4>map[n][3]) flag = false;\n\t\t\t\tif(flag==true){\n\t\t\t\t\tSystem.out.println(map[i][0]);\n\t\t\t\t\tout = false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(out==true) System.out.println(\"NA\");\n\t\t}\n\t}\t\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": 758, "cpu_time_ms": 410, "memory_kb": 64648}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s637892981", "group_id": "codeNet:p00244", "input_text": "import java.util.*;\n\npublic class Main {\n // constant\n\n static final int MAX_INT = (1 << 30);\n\n // inner classes\n\n static class State {\n int id, rem;\n\n State(int id, int rem) {\n this.id = id;\n this.rem = rem;\n }\n }\n\n // main\n public static final void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n\n while (true) {\n int n = sc.nextInt();\n int m = sc.nextInt();\n if (n == 0 && m == 0) break;\n\n int[][] edges = new int[n][n];\n for (int i = 0; i < n; i++)\n for (int j = 0; j < n; j++) edges[i][j] = 0;\n\n for (int i = 0; i < m; i++) {\n int a = sc.nextInt() - 1;\n int b = sc.nextInt() - 1;\n int c = sc.nextInt();\n\n edges[a][b] = edges[b][a] = c;\n }\n\n int start = 0;\n int goal = n - 1;\n\n int[][] dists = new int[n][3];\n boolean[][] used = new boolean[n][3];\n\n for (int i = 0; i < n; i++)\n for (int j = 0; j < 3; j++) {\n dists[i][j] = MAX_INT;\n used[i][j] = false;\n }\n\n dists[start][2] = 0;\n used[start][2] = true;\n\n ArrayList q = new ArrayList();\n q.add(new State(start, 2));\n\n while (! q.isEmpty()) {\n State u = q.get(0);\n int du = dists[u.id][u.rem];\n\n for (int i = 1; i < q.size(); i++) {\n State ui = q.get(i);\n if (du > dists[ui.id][ui.rem]) {\n u = ui;\n du = dists[ui.id][ui.rem];\n }\n }\n\n q.remove(u);\n\n int uid = u.id;\n int urem = u.rem;\n\n if (uid == goal) continue;\n\n for (int vid = 0; vid < n; vid++) {\n if (edges[uid][vid] == 0) continue;\n\n if (urem != 1 &&\n dists[vid][urem] > dists[uid][urem] + edges[uid][vid]) {\n dists[vid][urem] = dists[uid][urem] + edges[uid][vid];\n if (! used[vid][urem]) {\n used[vid][urem] = true;\n q.add(new State(vid, urem));\n }\n }\n\n if (urem > 0 && dists[vid][urem - 1] > dists[uid][urem]) {\n int vrem = urem - 1;\n dists[vid][vrem] = dists[uid][urem];\n if (! used[vid][vrem]) {\n used[vid][vrem] = true;\n q.add(new State(vid, vrem));\n }\n }\n }\n }\n\n int d0 = dists[goal][0];\n int d2 = dists[goal][2];\n\n System.out.println(d0 < d2 ? d0 : d2);\n }\n }\n}", "language": "Java", "metadata": {"date": 1404666425, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00244.html", "problem_id": "p00244", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00244/input.txt", "sample_output_relpath": "derived/input_output/data/p00244/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00244/Java/s637892981.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s637892981", "user_id": "u137027976"}, "prompt_components": {"gold_output": "5\n0\n7\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n // constant\n\n static final int MAX_INT = (1 << 30);\n\n // inner classes\n\n static class State {\n int id, rem;\n\n State(int id, int rem) {\n this.id = id;\n this.rem = rem;\n }\n }\n\n // main\n public static final void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n\n while (true) {\n int n = sc.nextInt();\n int m = sc.nextInt();\n if (n == 0 && m == 0) break;\n\n int[][] edges = new int[n][n];\n for (int i = 0; i < n; i++)\n for (int j = 0; j < n; j++) edges[i][j] = 0;\n\n for (int i = 0; i < m; i++) {\n int a = sc.nextInt() - 1;\n int b = sc.nextInt() - 1;\n int c = sc.nextInt();\n\n edges[a][b] = edges[b][a] = c;\n }\n\n int start = 0;\n int goal = n - 1;\n\n int[][] dists = new int[n][3];\n boolean[][] used = new boolean[n][3];\n\n for (int i = 0; i < n; i++)\n for (int j = 0; j < 3; j++) {\n dists[i][j] = MAX_INT;\n used[i][j] = false;\n }\n\n dists[start][2] = 0;\n used[start][2] = true;\n\n ArrayList q = new ArrayList();\n q.add(new State(start, 2));\n\n while (! q.isEmpty()) {\n State u = q.get(0);\n int du = dists[u.id][u.rem];\n\n for (int i = 1; i < q.size(); i++) {\n State ui = q.get(i);\n if (du > dists[ui.id][ui.rem]) {\n u = ui;\n du = dists[ui.id][ui.rem];\n }\n }\n\n q.remove(u);\n\n int uid = u.id;\n int urem = u.rem;\n\n if (uid == goal) continue;\n\n for (int vid = 0; vid < n; vid++) {\n if (edges[uid][vid] == 0) continue;\n\n if (urem != 1 &&\n dists[vid][urem] > dists[uid][urem] + edges[uid][vid]) {\n dists[vid][urem] = dists[uid][urem] + edges[uid][vid];\n if (! used[vid][urem]) {\n used[vid][urem] = true;\n q.add(new State(vid, urem));\n }\n }\n\n if (urem > 0 && dists[vid][urem - 1] > dists[uid][urem]) {\n int vrem = urem - 1;\n dists[vid][vrem] = dists[uid][urem];\n if (! used[vid][vrem]) {\n used[vid][vrem] = true;\n q.add(new State(vid, vrem));\n }\n }\n }\n }\n\n int d0 = dists[goal][0];\n int d2 = dists[goal][2];\n\n System.out.println(d0 < d2 ? d0 : d2);\n }\n }\n}", "problem_context": "温泉旅行\n\n温泉好きのたけしさんは、次の長期休暇を利用してとある温泉地への旅行を計画しています。移動は長距離バスを乗り継ぎ、なるべくお金をかけずに目的地へたどり着きたいと思っています。貯金があるとはいえ、資金に心許ないたけしさんは、おじいさんに相談することにしました。計画を聞いて感心したおじいさんは、たけしさんに特別な切符を渡しました。\n\nその切符は、長距離バスの連続した2区間を1回だけ無料で乗れるというものでした。使いようによってはかなりの移動費削減が見込めますが、より大きな効果を発揮させるためにはしっかりした計画を練る必要があります。\n\n出発地と目的地、及び中継地点が合わせて n 個、2つの地点を結ぶ路線が m 個与えられます。各地点にはそれぞれ 1 から n までの数字が割り振られています。出発地は 1、目的地は n です。路線の情報は、その路線が結ぶ2つの地点 a と b、及びその料金 c で表されます。特別な切符の効力により、任意の地点から、一度だけ連続した2つの路線を料金0で通過することができます。ただし、途中で目的地を通過しても、目的地にたどり着いたことにはなりません。\n\n出発地、目的地、及び中継地点の総数 n と路線の数 m、各路線の情報を入力とし、料金の最小値を出力するプログラムを作成してください。ただし、必ず出発地から目的地へと到達する経路が存在するものとします。\n\n入力\n\n複数のデータセットが与えられます。入力の終わりはゼロふたつの行で示されます。各データセットは以下の形式で与えられます。\n\nn m\na1 b1 c1\na2 b2 c2\n:\nam bm cm\n\n1行目に出発地、目的地、及び中継地点の総数 n (2 ≤ n ≤ 100)と路線の数 m (1 ≤ m ≤ 300)が与えられます。続く m 行に各路線の情報 ai, bi, ci (1 ≤ ci ≤ 1000) が与えられます。\n\nデータセットの数は 40 を超えません。\n\n出力\n\n入力データセットごとに、料金の最小値を1行に出力します。\n\n入力例\n\n2 1\n1 2 5\n3 2\n1 2 5\n2 3 5\n6 9\n1 2 7\n1 3 9\n1 5 14\n2 3 10\n2 4 15\n3 4 11\n3 5 2\n4 5 9\n4 6 8\n0 0\n\n出力例\n\n5\n0\n7", "sample_input": "2 1\n1 2 5\n3 2\n1 2 5\n2 3 5\n6 9\n1 2 7\n1 3 9\n1 5 14\n2 3 10\n2 4 15\n3 4 11\n3 5 2\n4 5 9\n4 6 8\n0 0\n"}, "reference_outputs": ["5\n0\n7\n"], "source_document_id": "p00244", "source_text": "温泉旅行\n\n温泉好きのたけしさんは、次の長期休暇を利用してとある温泉地への旅行を計画しています。移動は長距離バスを乗り継ぎ、なるべくお金をかけずに目的地へたどり着きたいと思っています。貯金があるとはいえ、資金に心許ないたけしさんは、おじいさんに相談することにしました。計画を聞いて感心したおじいさんは、たけしさんに特別な切符を渡しました。\n\nその切符は、長距離バスの連続した2区間を1回だけ無料で乗れるというものでした。使いようによってはかなりの移動費削減が見込めますが、より大きな効果を発揮させるためにはしっかりした計画を練る必要があります。\n\n出発地と目的地、及び中継地点が合わせて n 個、2つの地点を結ぶ路線が m 個与えられます。各地点にはそれぞれ 1 から n までの数字が割り振られています。出発地は 1、目的地は n です。路線の情報は、その路線が結ぶ2つの地点 a と b、及びその料金 c で表されます。特別な切符の効力により、任意の地点から、一度だけ連続した2つの路線を料金0で通過することができます。ただし、途中で目的地を通過しても、目的地にたどり着いたことにはなりません。\n\n出発地、目的地、及び中継地点の総数 n と路線の数 m、各路線の情報を入力とし、料金の最小値を出力するプログラムを作成してください。ただし、必ず出発地から目的地へと到達する経路が存在するものとします。\n\n入力\n\n複数のデータセットが与えられます。入力の終わりはゼロふたつの行で示されます。各データセットは以下の形式で与えられます。\n\nn m\na1 b1 c1\na2 b2 c2\n:\nam bm cm\n\n1行目に出発地、目的地、及び中継地点の総数 n (2 ≤ n ≤ 100)と路線の数 m (1 ≤ m ≤ 300)が与えられます。続く m 行に各路線の情報 ai, bi, ci (1 ≤ ci ≤ 1000) が与えられます。\n\nデータセットの数は 40 を超えません。\n\n出力\n\n入力データセットごとに、料金の最小値を1行に出力します。\n\n入力例\n\n2 1\n1 2 5\n3 2\n1 2 5\n2 3 5\n6 9\n1 2 7\n1 3 9\n1 5 14\n2 3 10\n2 4 15\n3 4 11\n3 5 2\n4 5 9\n4 6 8\n0 0\n\n出力例\n\n5\n0\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": 2434, "cpu_time_ms": 200, "memory_kb": 35432}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s186641450", "group_id": "codeNet:p00247", "input_text": "import java.util.Arrays;\nimport java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Scanner;\n\n//Ice Maze\npublic class Main{\n\n\tint w, h, si, sj, gi, gj, INF = 1<<29, res;\n\tint[][] d = {{-1,0},{0,1},{1,0},{0,-1}};\n\tint[] ice, hit;\n\tint[][] id, dist;\n\tchar[][] m;\n\tboolean[][] v;\n\t\n\tvoid mark(int i, int j, int x){\n\t\tid[i][j] = x;\n\t\tice[x]++;\n\t\tfor(int k=0;k<4;k++){\n\t\t\tint ni = i+d[k][0], nj = j+d[k][1];\n\t\t\tif(m[ni][nj]=='X'&&id[ni][nj]==0)mark(ni, nj, x);\n\t\t}\n\t}\n\t\n\tvoid f(int i, int j, int depth){\n\t\tif(res<=depth+dist[i][j])return;\n\t\tif(res<=depth+Math.abs(gi-i)+Math.abs(gj-j))return;\n\t\tif(gi==i && gj==j){\n\t\t\tres = Math.min(res, depth); return;\n\t\t}\n\t\tint c = 0;\n\t\tfor(int k=0;k<4;k++){\n\t\t\tint ni = i+d[k][0], nj = j+d[k][1];\n\t\t\tif(v[ni][nj])c++;\n\t\t}\n\t\tif(2 <= c)return;\n\t\tfor(int k=0;k<4;k++){\n\t\t\tint ni = i+d[k][0], nj = j+d[k][1];\n\t\t\tif(!v[ni][nj]&&m[ni][nj]!='#'){\n\t\t\t\tif(ice[id[ni][nj]]>>1 >= hit[id[ni][nj]]+1){\n\t\t\t\t\thit[id[ni][nj]]++;\n\t\t\t\t\tv[ni][nj] = true;\n\t\t\t\t\tf(ni, nj, depth+1);\n\t\t\t\t\tv[ni][nj] = false;\n\t\t\t\t\thit[id[ni][nj]]--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tvoid run(){\n\t\tScanner sc = new Scanner(System.in);\n\t\tice = new int[144];\n\t\thit = new int[144];\n\t\tdist = new int[14][14];\n\t\tm = new char[14][14];\n\t\tv = new boolean[14][14];\n\t\tfor(;;){\n\t\t\tw = sc.nextInt(); h = sc.nextInt();\n\t\t\tif((w|h)==0)break;\n\t\t\tfor(int i=0;i0)continue;\n\t\t\t\tmark(i, j, ID);\n\t\t\t\tif(ice[ID]==1){\n\t\t\t\t\tm[i][j] = '#';\n\t\t\t\t}\n\t\t\t\tID++;\n\t\t\t}\n\t\t\tdist[gi][gj] = 0;\n\t\t\tQueue que = new LinkedList();\n\t\t\tque.add(new int[]{gi, gj});\n\t\t\twhile(!que.isEmpty()){\n\t\t\t\tint V[] = que.poll();\n\t\t\t\tint pi = V[0], pj = V[1];\n\t\t\t\tfor(int k=0;k<4;k++){\n\t\t\t\t\tint ni = pi+d[k][0], nj = pj+d[k][1];\n\t\t\t\t\tif(m[ni][nj]!='#'&&dist[ni][nj]==INF){\n\t\t\t\t\t\tdist[ni][nj] = dist[pi][pj]+1;\n\t\t\t\t\t\tque.add(new int[]{ni, nj});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tres = INF;\n\t\t\tArrays.fill(hit, 0);\n\t\t\tv[si][sj] = true;\n\t\t\tf(si, sj, 0);\n\t\t\tSystem.out.println(res);\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n}", "language": "Java", "metadata": {"date": 1349265942, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00247.html", "problem_id": "p00247", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00247/input.txt", "sample_output_relpath": "derived/input_output/data/p00247/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00247/Java/s186641450.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s186641450", "user_id": "u413996626"}, "prompt_components": {"gold_output": "11\n10\n10\n33\n", "input_to_evaluate": "import java.util.Arrays;\nimport java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Scanner;\n\n//Ice Maze\npublic class Main{\n\n\tint w, h, si, sj, gi, gj, INF = 1<<29, res;\n\tint[][] d = {{-1,0},{0,1},{1,0},{0,-1}};\n\tint[] ice, hit;\n\tint[][] id, dist;\n\tchar[][] m;\n\tboolean[][] v;\n\t\n\tvoid mark(int i, int j, int x){\n\t\tid[i][j] = x;\n\t\tice[x]++;\n\t\tfor(int k=0;k<4;k++){\n\t\t\tint ni = i+d[k][0], nj = j+d[k][1];\n\t\t\tif(m[ni][nj]=='X'&&id[ni][nj]==0)mark(ni, nj, x);\n\t\t}\n\t}\n\t\n\tvoid f(int i, int j, int depth){\n\t\tif(res<=depth+dist[i][j])return;\n\t\tif(res<=depth+Math.abs(gi-i)+Math.abs(gj-j))return;\n\t\tif(gi==i && gj==j){\n\t\t\tres = Math.min(res, depth); return;\n\t\t}\n\t\tint c = 0;\n\t\tfor(int k=0;k<4;k++){\n\t\t\tint ni = i+d[k][0], nj = j+d[k][1];\n\t\t\tif(v[ni][nj])c++;\n\t\t}\n\t\tif(2 <= c)return;\n\t\tfor(int k=0;k<4;k++){\n\t\t\tint ni = i+d[k][0], nj = j+d[k][1];\n\t\t\tif(!v[ni][nj]&&m[ni][nj]!='#'){\n\t\t\t\tif(ice[id[ni][nj]]>>1 >= hit[id[ni][nj]]+1){\n\t\t\t\t\thit[id[ni][nj]]++;\n\t\t\t\t\tv[ni][nj] = true;\n\t\t\t\t\tf(ni, nj, depth+1);\n\t\t\t\t\tv[ni][nj] = false;\n\t\t\t\t\thit[id[ni][nj]]--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tvoid run(){\n\t\tScanner sc = new Scanner(System.in);\n\t\tice = new int[144];\n\t\thit = new int[144];\n\t\tdist = new int[14][14];\n\t\tm = new char[14][14];\n\t\tv = new boolean[14][14];\n\t\tfor(;;){\n\t\t\tw = sc.nextInt(); h = sc.nextInt();\n\t\t\tif((w|h)==0)break;\n\t\t\tfor(int i=0;i0)continue;\n\t\t\t\tmark(i, j, ID);\n\t\t\t\tif(ice[ID]==1){\n\t\t\t\t\tm[i][j] = '#';\n\t\t\t\t}\n\t\t\t\tID++;\n\t\t\t}\n\t\t\tdist[gi][gj] = 0;\n\t\t\tQueue que = new LinkedList();\n\t\t\tque.add(new int[]{gi, gj});\n\t\t\twhile(!que.isEmpty()){\n\t\t\t\tint V[] = que.poll();\n\t\t\t\tint pi = V[0], pj = V[1];\n\t\t\t\tfor(int k=0;k<4;k++){\n\t\t\t\t\tint ni = pi+d[k][0], nj = pj+d[k][1];\n\t\t\t\t\tif(m[ni][nj]!='#'&&dist[ni][nj]==INF){\n\t\t\t\t\t\tdist[ni][nj] = dist[pi][pj]+1;\n\t\t\t\t\t\tque.add(new int[]{ni, nj});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tres = INF;\n\t\t\tArrays.fill(hit, 0);\n\t\t\tv[si][sj] = true;\n\t\t\tf(si, sj, 0);\n\t\t\tSystem.out.println(res);\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n}", "problem_context": "氷の迷路\n\n四角のマスを縦横にならべた長方形の迷路があります。この迷路では東西南北の隣接するマスへ移動しながら、スタートのマスSを出発し、ゴールのマスGを目指します。マスの種類には、平原、山、氷の3種類があります。SとGは、平原のマスに置かれています。平原のマスには移動できますが、山のマスには移動できません。氷のマスは移動できますが、条件によって氷が割れ動けなくなります。\n\n氷のマスは東西南北に隣接するもの全体でひとつの塊として扱われます。\n\n氷の塊のなかで、マスの個数の半分より多くのマスに移動すると、塊全体が割れます。\n\n例えば、図1は与えられた迷路の最短経路のステップ数が 11 であることを示しています。\n\n図1\n\nしかし、図2のように氷のマスを通って近道をしようとすると、大きさが6の氷の塊に対する4回目の移動後に動けなくなってしまいGには到達できません。\n\n図2\n\nこのような迷路の情報を入力とし、SからGまでの最短経路のステップ数を求めるプログラムを作成してください。マスの種類はそれぞれ以下の文字で表されます:\n\n文字(半角)\n\nマスの種類\n\n. (ピリオド)\n\n平原\n\n#(シャープ)\n\n山\n\nX\n\n氷\n\n与えられる迷路は必ず解けるものとします。迷路はその東西方向のマスの数 X、南北方向のマスの数 Y と X × Y 個の文字として与えられます。\n\n入力\n\n複数のデータセットが与えられます。入力の終わりはゼロふたつの行で示されます。各データセットは以下の形式で与えられます。\n\nX Y\nline1\nline2\n:\nlineY\n\n1行目に迷路の大きさを表す整数 X, Y (2 ≤ X, Y ≤ 12) が与えられます。続く Y 行に迷路の i 行目の情報 linei (長さ X の半角英文字列) が与えられます。\n\nデータセットの数は 40 を超えない。\n\n出力\n\nデータセットごとに、最小のステップ数を1行に出力します。\n\n入力例\n\n5 5\n.X.S.\n.X#..\n.XX##\n.#XG.\n..X..\n7 3\nSXX.XXG\nX.#.#X.\nXXX.XX#\n4 4\nS...\nX.X.\nGX..\n...X\n10 10\n..XXXXX.XX\n.X.#.#X.XX\nSX.#X.X..X\n#X.##.X.XX\n..XXXX#.XX\n##.##.##XX\n....X.XX#X\n.##X..#X#X\n....XX#..X\n...#XXG..X\n0 0\n\n出力例\n\n11\n10\n10\n33", "sample_input": "5 5\n.X.S.\n.X#..\n.XX##\n.#XG.\n..X..\n7 3\nSXX.XXG\nX.#.#X.\nXXX.XX#\n4 4\nS...\nX.X.\nGX..\n...X\n10 10\n..XXXXX.XX\n.X.#.#X.XX\nSX.#X.X..X\n#X.##.X.XX\n..XXXX#.XX\n##.##.##XX\n....X.XX#X\n.##X..#X#X\n....XX#..X\n...#XXG..X\n0 0\n"}, "reference_outputs": ["11\n10\n10\n33\n"], "source_document_id": "p00247", "source_text": "氷の迷路\n\n四角のマスを縦横にならべた長方形の迷路があります。この迷路では東西南北の隣接するマスへ移動しながら、スタートのマスSを出発し、ゴールのマスGを目指します。マスの種類には、平原、山、氷の3種類があります。SとGは、平原のマスに置かれています。平原のマスには移動できますが、山のマスには移動できません。氷のマスは移動できますが、条件によって氷が割れ動けなくなります。\n\n氷のマスは東西南北に隣接するもの全体でひとつの塊として扱われます。\n\n氷の塊のなかで、マスの個数の半分より多くのマスに移動すると、塊全体が割れます。\n\n例えば、図1は与えられた迷路の最短経路のステップ数が 11 であることを示しています。\n\n図1\n\nしかし、図2のように氷のマスを通って近道をしようとすると、大きさが6の氷の塊に対する4回目の移動後に動けなくなってしまいGには到達できません。\n\n図2\n\nこのような迷路の情報を入力とし、SからGまでの最短経路のステップ数を求めるプログラムを作成してください。マスの種類はそれぞれ以下の文字で表されます:\n\n文字(半角)\n\nマスの種類\n\n. (ピリオド)\n\n平原\n\n#(シャープ)\n\n山\n\nX\n\n氷\n\n与えられる迷路は必ず解けるものとします。迷路はその東西方向のマスの数 X、南北方向のマスの数 Y と X × Y 個の文字として与えられます。\n\n入力\n\n複数のデータセットが与えられます。入力の終わりはゼロふたつの行で示されます。各データセットは以下の形式で与えられます。\n\nX Y\nline1\nline2\n:\nlineY\n\n1行目に迷路の大きさを表す整数 X, Y (2 ≤ X, Y ≤ 12) が与えられます。続く Y 行に迷路の i 行目の情報 linei (長さ X の半角英文字列) が与えられます。\n\nデータセットの数は 40 を超えない。\n\n出力\n\nデータセットごとに、最小のステップ数を1行に出力します。\n\n入力例\n\n5 5\n.X.S.\n.X#..\n.XX##\n.#XG.\n..X..\n7 3\nSXX.XXG\nX.#.#X.\nXXX.XX#\n4 4\nS...\nX.X.\nGX..\n...X\n10 10\n..XXXXX.XX\n.X.#.#X.XX\nSX.#X.X..X\n#X.##.X.XX\n..XXXX#.XX\n##.##.##XX\n....X.XX#X\n.##X..#X#X\n....XX#..X\n...#XXG..X\n0 0\n\n出力例\n\n11\n10\n10\n33", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2509, "cpu_time_ms": 19980, "memory_kb": 12000}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s192782944", "group_id": "codeNet:p00291", "input_text": "import java.util.Scanner;\npublic class Main {\npublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint c1 = sc.nextInt();\n\t\tint c5 = sc.nextInt()*5;\n\t\tint c10 = sc.nextInt()*10;\n\t\tint c50 = sc.nextInt()*50;\n\t\tint c100 = sc.nextInt()*100;\n\t\tint c500 = sc.nextInt()*500;\n\t\tif(c1+c5+c10+c50+c100+c500>=1000){\n\t\t\tSystem.out.println(1);\n\t\t}else{\n\t\t\tSystem.out.println(0);\n\t\t}\n\t}\n\n}", "language": "Java", "metadata": {"date": 1442025113, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00291.html", "problem_id": "p00291", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00291/input.txt", "sample_output_relpath": "derived/input_output/data/p00291/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00291/Java/s192782944.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s192782944", "user_id": "u026314870"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main {\npublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint c1 = sc.nextInt();\n\t\tint c5 = sc.nextInt()*5;\n\t\tint c10 = sc.nextInt()*10;\n\t\tint c50 = sc.nextInt()*50;\n\t\tint c100 = sc.nextInt()*100;\n\t\tint c500 = sc.nextInt()*500;\n\t\tif(c1+c5+c10+c50+c100+c500>=1000){\n\t\t\tSystem.out.println(1);\n\t\t}else{\n\t\t\tSystem.out.println(0);\n\t\t}\n\t}\n\n}", "problem_context": "お財布メタボ診断\n\n4月に消費税が8%になってから、お財布が硬貨でパンパンになっていませんか。同じ金額を持ち歩くなら硬貨の枚数を少なくしたいですよね。硬貨の合計が1000円以上なら、硬貨をお札に両替して、お財布のメタボ状態を解消できます。\n\nお財布の中の硬貨の枚数が種類ごとに与えられたとき、硬貨をお札に両替できるかどうかを判定するプログラムを作成してください。\n\n入力\n\n入力は以下の形式で与えられる。\n\nc1 c5 c10 c50 c100 c500\n\n入力は1行からなる。c1、c5、c10、c50、c100、c500 (0 ≤ c1, c5, c10, c50, c100, c500 ≤ 50) は、それぞれ、1円、5円、10円、50円、100円、500円硬貨の枚数を表す。\n\n出力\n\n硬貨をお札に両替できるなら1 を、そうでなければ 0 を1行に出力する。\n\n入出力例\n\n入力例1\n\n3 1 4 0 4 1\n\n出力例1\n\n0\n\n入力例2\n\n2 1 4 3 2 3\n\n出力例2\n\n1\n\n入力例3\n\n21 5 9 3 1 1\n\n出力例3\n\n0\n\n入力例4\n\n2 4 3 3 3 1\n\n出力例4\n\n1\n\n入力例5\n\n50 50 50 4 0 0\n\n出力例5\n\n1", "sample_input": "3 1 4 0 4 1\n"}, "reference_outputs": ["0\n"], "source_document_id": "p00291", "source_text": "お財布メタボ診断\n\n4月に消費税が8%になってから、お財布が硬貨でパンパンになっていませんか。同じ金額を持ち歩くなら硬貨の枚数を少なくしたいですよね。硬貨の合計が1000円以上なら、硬貨をお札に両替して、お財布のメタボ状態を解消できます。\n\nお財布の中の硬貨の枚数が種類ごとに与えられたとき、硬貨をお札に両替できるかどうかを判定するプログラムを作成してください。\n\n入力\n\n入力は以下の形式で与えられる。\n\nc1 c5 c10 c50 c100 c500\n\n入力は1行からなる。c1、c5、c10、c50、c100、c500 (0 ≤ c1, c5, c10, c50, c100, c500 ≤ 50) は、それぞれ、1円、5円、10円、50円、100円、500円硬貨の枚数を表す。\n\n出力\n\n硬貨をお札に両替できるなら1 を、そうでなければ 0 を1行に出力する。\n\n入出力例\n\n入力例1\n\n3 1 4 0 4 1\n\n出力例1\n\n0\n\n入力例2\n\n2 1 4 3 2 3\n\n出力例2\n\n1\n\n入力例3\n\n21 5 9 3 1 1\n\n出力例3\n\n0\n\n入力例4\n\n2 4 3 3 3 1\n\n出力例4\n\n1\n\n入力例5\n\n50 50 50 4 0 0\n\n出力例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": 405, "cpu_time_ms": 50, "memory_kb": 17360}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s710886042", "group_id": "codeNet:p00292", "input_text": "import java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint[] k = new int[n];\n\t\tint[] p = new int[n];\n\t\t\n\t\tfor (int i = 0; i < n; i++){\n\t\t\tk[i] = sc.nextInt();\n\t\t\tp[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tfor (int i = 0; i < n; i++){\n\t\t\tint res = k[i] % p[i];\n\t\t\tif (res == 0){\n\t\t\t\tres = p[i];\n\t\t\t}\n\t\t\t\n\t\t\tSystem.out.println(res);\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1433926501, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00292.html", "problem_id": "p00292", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00292/input.txt", "sample_output_relpath": "derived/input_output/data/p00292/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00292/Java/s710886042.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s710886042", "user_id": "u334031393"}, "prompt_components": {"gold_output": "1\n2\n2\n", "input_to_evaluate": "import java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint[] k = new int[n];\n\t\tint[] p = new int[n];\n\t\t\n\t\tfor (int i = 0; i < n; i++){\n\t\t\tk[i] = sc.nextInt();\n\t\t\tp[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tfor (int i = 0; i < n; i++){\n\t\t\tint res = k[i] % p[i];\n\t\t\tif (res == 0){\n\t\t\t\tres = p[i];\n\t\t\t}\n\t\t\t\n\t\t\tSystem.out.println(res);\n\t\t}\n\t}\n}", "problem_context": "残り物には福がある\n\nK 個の石から、P 人が順番に1つずつ石を取るゲームがあります。P 人目が石を取った時点で、まだ石が残っていれば、また1人目から順番に1つずつ石を取っていきます。このゲームでは、最後の石を取った人が勝ちとなります。K とP が与えられたとき、何人目が勝つか判定するプログラムを作成してください。\n\n入力\n\n入力は以下の形式で与えられる。\n\nN\nK1 P1\nK2 P2\n:\nKN PN\n\n1行目にはゲームを行う回数 N (1 ≤ N ≤ 100) が与えられる。続く N 行に、i 回目のゲームにおける石の個数 Ki (2 ≤ Ki ≤ 1000) と、ゲームに参加する人数 Pi (2 ≤ Pi ≤ 1000) が与えられる。\n\n出力\n\nそれぞれのゲームについて、何人目が勝つかを1行に出力する。\n\n入出力例\n\n入力例\n\n3\n10 3\n2 10\n4 2\n\n出力例\n\n1\n2\n2", "sample_input": "3\n10 3\n2 10\n4 2\n"}, "reference_outputs": ["1\n2\n2\n"], "source_document_id": "p00292", "source_text": "残り物には福がある\n\nK 個の石から、P 人が順番に1つずつ石を取るゲームがあります。P 人目が石を取った時点で、まだ石が残っていれば、また1人目から順番に1つずつ石を取っていきます。このゲームでは、最後の石を取った人が勝ちとなります。K とP が与えられたとき、何人目が勝つか判定するプログラムを作成してください。\n\n入力\n\n入力は以下の形式で与えられる。\n\nN\nK1 P1\nK2 P2\n:\nKN PN\n\n1行目にはゲームを行う回数 N (1 ≤ N ≤ 100) が与えられる。続く N 行に、i 回目のゲームにおける石の個数 Ki (2 ≤ Ki ≤ 1000) と、ゲームに参加する人数 Pi (2 ≤ Pi ≤ 1000) が与えられる。\n\n出力\n\nそれぞれのゲームについて、何人目が勝つかを1行に出力する。\n\n入出力例\n\n入力例\n\n3\n10 3\n2 10\n4 2\n\n出力例\n\n1\n2\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": 420, "cpu_time_ms": 70, "memory_kb": 20372}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s132159722", "group_id": "codeNet:p00292", "input_text": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.NoSuchElementException;\n\npublic class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\tFastScanner sc = new FastScanner();\n\t\tPrintWriter out = new PrintWriter(System.out);\n\t\tint n = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tint k = sc.nextInt();\n\t\t\tint p = sc.nextInt();\n\t\t\tint a = k % p;\n\t\t\tout.println(a == 0 ? p : a);\n\t\t}\n\t\tout.flush();\n\t}\n\t\n}\n\nclass FastScanner {\n\tprivate final InputStream in = System.in;\n\tprivate final byte[] buffer = new byte[1024];\n\tprivate int ptr = 0;\n\tprivate int buflen = 0;\n\t\n\tprivate boolean hasNextByte() {\n\t\tif (ptr < buflen) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\tptr = 0;\n\t\t\ttry {\n\t\t\t\tbuflen = in.read(buffer);\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (buflen <= 0) { return false; }\n\t\t}\n\t\treturn true;\n\t}\n\t\n\tprivate byte readByte() {\n\t\tif (hasNextByte()) {\n\t\t\treturn buffer[ptr++];\n\t\t} else {\n\t\t\treturn -1;\n\t\t}\n\t}\n\t\n\tprivate boolean isPrintableChar(int c) {\n\t\treturn '!' <= c && c <= '~';\n\t}\n\t\n\tprivate void skipUnprintable() {\n\t\twhile (hasNextByte() && !isPrintableChar(buffer[ptr])) {\n\t\t\tptr++;\n\t\t}\n\t}\n\t\n\tpublic boolean hasNext() {\n\t\tskipUnprintable();\n\t\treturn hasNextByte();\n\t}\n\t\n\tpublic int nextInt() {\n\t\tif (!hasNext()) { throw new NoSuchElementException(); }\n\t\tint n = 0;\n\t\tboolean minus = false;\n\t\tbyte b = readByte();\n\t\tif (b == '-') {\n\t\t\tminus = true;\n\t\t\tb = readByte();\n\t\t}\n\t\tif (b < '0' || '9' < b) { throw new NumberFormatException(); }\n\t\twhile (true) {\n\t\t\tif ('0' <= b && b <= '9') {\n\t\t\t\tn *= 10;\n\t\t\t\tn += b - '0';\n\t\t\t} else if (b == -1 || !isPrintableChar(b)) {\n\t\t\t\treturn minus ? -n : n;\n\t\t\t} else {\n\t\t\t\tthrow new NumberFormatException();\n\t\t\t}\n\t\t\tb = readByte();\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1464672845, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00292.html", "problem_id": "p00292", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00292/input.txt", "sample_output_relpath": "derived/input_output/data/p00292/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00292/Java/s132159722.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s132159722", "user_id": "u806997739"}, "prompt_components": {"gold_output": "1\n2\n2\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.NoSuchElementException;\n\npublic class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\tFastScanner sc = new FastScanner();\n\t\tPrintWriter out = new PrintWriter(System.out);\n\t\tint n = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tint k = sc.nextInt();\n\t\t\tint p = sc.nextInt();\n\t\t\tint a = k % p;\n\t\t\tout.println(a == 0 ? p : a);\n\t\t}\n\t\tout.flush();\n\t}\n\t\n}\n\nclass FastScanner {\n\tprivate final InputStream in = System.in;\n\tprivate final byte[] buffer = new byte[1024];\n\tprivate int ptr = 0;\n\tprivate int buflen = 0;\n\t\n\tprivate boolean hasNextByte() {\n\t\tif (ptr < buflen) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\tptr = 0;\n\t\t\ttry {\n\t\t\t\tbuflen = in.read(buffer);\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (buflen <= 0) { return false; }\n\t\t}\n\t\treturn true;\n\t}\n\t\n\tprivate byte readByte() {\n\t\tif (hasNextByte()) {\n\t\t\treturn buffer[ptr++];\n\t\t} else {\n\t\t\treturn -1;\n\t\t}\n\t}\n\t\n\tprivate boolean isPrintableChar(int c) {\n\t\treturn '!' <= c && c <= '~';\n\t}\n\t\n\tprivate void skipUnprintable() {\n\t\twhile (hasNextByte() && !isPrintableChar(buffer[ptr])) {\n\t\t\tptr++;\n\t\t}\n\t}\n\t\n\tpublic boolean hasNext() {\n\t\tskipUnprintable();\n\t\treturn hasNextByte();\n\t}\n\t\n\tpublic int nextInt() {\n\t\tif (!hasNext()) { throw new NoSuchElementException(); }\n\t\tint n = 0;\n\t\tboolean minus = false;\n\t\tbyte b = readByte();\n\t\tif (b == '-') {\n\t\t\tminus = true;\n\t\t\tb = readByte();\n\t\t}\n\t\tif (b < '0' || '9' < b) { throw new NumberFormatException(); }\n\t\twhile (true) {\n\t\t\tif ('0' <= b && b <= '9') {\n\t\t\t\tn *= 10;\n\t\t\t\tn += b - '0';\n\t\t\t} else if (b == -1 || !isPrintableChar(b)) {\n\t\t\t\treturn minus ? -n : n;\n\t\t\t} else {\n\t\t\t\tthrow new NumberFormatException();\n\t\t\t}\n\t\t\tb = readByte();\n\t\t}\n\t}\n}", "problem_context": "残り物には福がある\n\nK 個の石から、P 人が順番に1つずつ石を取るゲームがあります。P 人目が石を取った時点で、まだ石が残っていれば、また1人目から順番に1つずつ石を取っていきます。このゲームでは、最後の石を取った人が勝ちとなります。K とP が与えられたとき、何人目が勝つか判定するプログラムを作成してください。\n\n入力\n\n入力は以下の形式で与えられる。\n\nN\nK1 P1\nK2 P2\n:\nKN PN\n\n1行目にはゲームを行う回数 N (1 ≤ N ≤ 100) が与えられる。続く N 行に、i 回目のゲームにおける石の個数 Ki (2 ≤ Ki ≤ 1000) と、ゲームに参加する人数 Pi (2 ≤ Pi ≤ 1000) が与えられる。\n\n出力\n\nそれぞれのゲームについて、何人目が勝つかを1行に出力する。\n\n入出力例\n\n入力例\n\n3\n10 3\n2 10\n4 2\n\n出力例\n\n1\n2\n2", "sample_input": "3\n10 3\n2 10\n4 2\n"}, "reference_outputs": ["1\n2\n2\n"], "source_document_id": "p00292", "source_text": "残り物には福がある\n\nK 個の石から、P 人が順番に1つずつ石を取るゲームがあります。P 人目が石を取った時点で、まだ石が残っていれば、また1人目から順番に1つずつ石を取っていきます。このゲームでは、最後の石を取った人が勝ちとなります。K とP が与えられたとき、何人目が勝つか判定するプログラムを作成してください。\n\n入力\n\n入力は以下の形式で与えられる。\n\nN\nK1 P1\nK2 P2\n:\nKN PN\n\n1行目にはゲームを行う回数 N (1 ≤ N ≤ 100) が与えられる。続く N 行に、i 回目のゲームにおける石の個数 Ki (2 ≤ Ki ≤ 1000) と、ゲームに参加する人数 Pi (2 ≤ Pi ≤ 1000) が与えられる。\n\n出力\n\nそれぞれのゲームについて、何人目が勝つかを1行に出力する。\n\n入出力例\n\n入力例\n\n3\n10 3\n2 10\n4 2\n\n出力例\n\n1\n2\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": 1753, "cpu_time_ms": 60, "memory_kb": 24436}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s176202557", "group_id": "codeNet:p00330", "input_text": "import java.util.Scanner;\n\nclass Main{\n public static void main(String[ ] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n System.out.println(n*32);\n }\n}\n", "language": "Java", "metadata": {"date": 1563525608, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00330.html", "problem_id": "p00330", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00330/input.txt", "sample_output_relpath": "derived/input_output/data/p00330/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00330/Java/s176202557.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s176202557", "user_id": "u518895056"}, "prompt_components": {"gold_output": "128\n", "input_to_evaluate": "import java.util.Scanner;\n\nclass Main{\n public static void main(String[ ] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n System.out.println(n*32);\n }\n}\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nワード\n\nコンピュータで扱われるデータの最小単位をビット(bit)と呼び、複数のビットをまとめて表した情報量をワード(word)と呼びます。現在、多くのコンピュータでは1ワードを32ビットとして処理しています。\n\n1ワードを32ビットで表すコンピュータについて、ワード単位で与えられたデータ量 W をビット単位で出力するプログラムを作成せよ。\n\nInput\n\n入力は以下の形式で与えられる。\n\nW\n\n入力は1行からなり、データ量 W (0 ≤ W ≤ 100) が与えられる。\n\nOutput\n\nビット単位の値を1行に出力する。\n\nSample Input 1\n\n4\n\nSample Output 1\n\n128\n\nSample Input 2\n\n3\n\nSample Output 2\n\n96", "sample_input": "4\n"}, "reference_outputs": ["128\n"], "source_document_id": "p00330", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nワード\n\nコンピュータで扱われるデータの最小単位をビット(bit)と呼び、複数のビットをまとめて表した情報量をワード(word)と呼びます。現在、多くのコンピュータでは1ワードを32ビットとして処理しています。\n\n1ワードを32ビットで表すコンピュータについて、ワード単位で与えられたデータ量 W をビット単位で出力するプログラムを作成せよ。\n\nInput\n\n入力は以下の形式で与えられる。\n\nW\n\n入力は1行からなり、データ量 W (0 ≤ W ≤ 100) が与えられる。\n\nOutput\n\nビット単位の値を1行に出力する。\n\nSample Input 1\n\n4\n\nSample Output 1\n\n128\n\nSample Input 2\n\n3\n\nSample Output 2\n\n96", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 60, "memory_kb": 26404}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s714555637", "group_id": "codeNet:p00381", "input_text": "import java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.Map;\nimport java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tMap> s = new HashMap>();\n\t\tchar[] t = new char[n];\n\t\t\n\t\tString ss = sc.next();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tchar tmp = ss.charAt(i);\n\t\t\t\n\t\t\tif(!s.containsKey(tmp)) {\n\t\t\t\ts.put(tmp, new HashSet());\n\t\t\t}\n\t\t\t\n\t\t\ts.get(tmp).add(i);\n\t\t}\n\t\t\n\t\tString st = sc.next();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tt[i] = st.charAt(i);\n\t\t}\n\t\t\n\t\tint[] table = new int[n];\n\t\tfor(int i = 0;i < n; i++) {\n\t\t\ttable[i] = 0;\n\t\t}\n\t\ttable[0] = 1;\n\t\t\n\t\tfor(int i = 1; i < n; i++) {\n\t\t\tfor(int x : s.get(t[i])) {\n\t\t\t\tif(x < i) {\n\t\t\t\t\ttable[i] += table[x];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(table[n - 1]);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1545370921, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00381.html", "problem_id": "p00381", "resource_group": "high_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/Java/s714555637.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s714555637", "user_id": "u461653715"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.Map;\nimport java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tMap> s = new HashMap>();\n\t\tchar[] t = new char[n];\n\t\t\n\t\tString ss = sc.next();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tchar tmp = ss.charAt(i);\n\t\t\t\n\t\t\tif(!s.containsKey(tmp)) {\n\t\t\t\ts.put(tmp, new HashSet());\n\t\t\t}\n\t\t\t\n\t\t\ts.get(tmp).add(i);\n\t\t}\n\t\t\n\t\tString st = sc.next();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tt[i] = st.charAt(i);\n\t\t}\n\t\t\n\t\tint[] table = new int[n];\n\t\tfor(int i = 0;i < n; i++) {\n\t\t\ttable[i] = 0;\n\t\t}\n\t\ttable[0] = 1;\n\t\t\n\t\tfor(int i = 1; i < n; i++) {\n\t\t\tfor(int x : s.get(t[i])) {\n\t\t\t\tif(x < i) {\n\t\t\t\t\ttable[i] += table[x];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(table[n - 1]);\n\t}\n}\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": 877, "cpu_time_ms": 50, "memory_kb": 26292}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s827114056", "group_id": "codeNet:p00399", "input_text": "import java.util.*;\n\nclass Main{\n public static void main(String[]args){\n Scanner sc = new Scanner(System.in);\n int R = sc.nextInt();\n int B = sc.nextInt();\n int W = sc.nextInt();\n int G = sc.nextInt();\n\n System.out.println(R + B + W + G);\n }\n}\n", "language": "Java", "metadata": {"date": 1593090065, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00399.html", "problem_id": "p00399", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00399/input.txt", "sample_output_relpath": "derived/input_output/data/p00399/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00399/Java/s827114056.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s827114056", "user_id": "u924565640"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.*;\n\nclass Main{\n public static void main(String[]args){\n Scanner sc = new Scanner(System.in);\n int R = sc.nextInt();\n int B = sc.nextInt();\n int W = sc.nextInt();\n int G = sc.nextInt();\n\n System.out.println(R + B + W + G);\n }\n}\n", "problem_context": "柴犬の数\n\n \n\nイヅア公園には、夕方になると柴犬と散歩する人たちがたくさん来ます。柴犬には毛の色によって赤柴、黒柴、白柴、胡麻柴という種類があります。柴犬がたくさんいるとうれしいトモエちゃんは、それぞれの毛色の柴犬が何頭いるかがんばって数えましたが、まだ足し算ができないので柴犬が全部で何頭いるかわかりません。\n\nそれぞれの毛色の柴犬の数が与えられたときに、柴犬の総数を計算するプログラムを作成せよ。\n\n入力\n\n入力は以下の形式で与えられる。\n\n$R$ $B$ $W$ $G$\n\n1行に赤柴の数$R$ ($1 \\leq R \\leq 100$)、黒柴の数$B$ ($1 \\leq B \\leq 100$)、白柴の数$W$ ($1 \\leq W \\leq 100$)、胡麻柴の数$G$ ($1 \\leq G \\leq 100$)が与えられる。\n\n出力\n\n柴犬の総数を1行に出力する。\n\n入出力例\n\n入力例1\n\n4 2 1 1\n\n出力例1\n\n8\n\n入力例2\n\n22 18 34 36\n\n出力例2\n\n110", "sample_input": "4 2 1 1\n"}, "reference_outputs": ["8\n"], "source_document_id": "p00399", "source_text": "柴犬の数\n\n \n\nイヅア公園には、夕方になると柴犬と散歩する人たちがたくさん来ます。柴犬には毛の色によって赤柴、黒柴、白柴、胡麻柴という種類があります。柴犬がたくさんいるとうれしいトモエちゃんは、それぞれの毛色の柴犬が何頭いるかがんばって数えましたが、まだ足し算ができないので柴犬が全部で何頭いるかわかりません。\n\nそれぞれの毛色の柴犬の数が与えられたときに、柴犬の総数を計算するプログラムを作成せよ。\n\n入力\n\n入力は以下の形式で与えられる。\n\n$R$ $B$ $W$ $G$\n\n1行に赤柴の数$R$ ($1 \\leq R \\leq 100$)、黒柴の数$B$ ($1 \\leq B \\leq 100$)、白柴の数$W$ ($1 \\leq W \\leq 100$)、胡麻柴の数$G$ ($1 \\leq G \\leq 100$)が与えられる。\n\n出力\n\n柴犬の総数を1行に出力する。\n\n入出力例\n\n入力例1\n\n4 2 1 1\n\n出力例1\n\n8\n\n入力例2\n\n22 18 34 36\n\n出力例2\n\n110", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 256, "cpu_time_ms": 80, "memory_kb": 26224}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s613061643", "group_id": "codeNet:p00424", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.StringTokenizer;\n\npublic class Main {\n\tprivate StringTokenizer st;\n\tprivate BufferedReader bf;\n\tprivate int w;\n\t\n\tMain() {\n\t\treadData();\n\t\t\n\n\t}\n\t\n\n\tprivate void readData() {\n\t\ttry {\n\t\t\tbf = new BufferedReader(new InputStreamReader(System.in));\n\t\t\tst = new StringTokenizer(bf.readLine());\n\t\t\t\n\t\t\twhile (true) {\n\t\t\t\tint m = nextInt();\n\t\t\t\tif (m==0)\n\t\t\t\t\tbreak;\n\t\t\t\tboolean[] r = new boolean[256];\n\t\t\t\tchar[] table = new char[256];\n\t\t\t\tfor (int i=0;i= 0; i--) {\n\t\t\t\tfor (int j = 1; j < m; j++) {\n\t\t\t\t\tif (wish[j] == i)\n\t\t\t\t\t\tsb.append(j + \" \");\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.println(sb.toString().substring(0, sb.length() - 1));\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1368938584, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00428.html", "problem_id": "p00428", "resource_group": "high_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/Java/s468635417.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s468635417", "user_id": "u759934006"}, "prompt_components": {"gold_output": "1 3 2 5 4 6\n1 3 2 5 4 6\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.Arrays;\nimport java.util.StringTokenizer;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString line = \"\";\n\n\t\twhile ((line = br.readLine()) != null) {\n\n\t\t\tint n = Integer.parseInt(line.substring(0, line.indexOf(' ')));\n\t\t\tint m = Integer.parseInt(line.substring(line.indexOf(' ') + 1));\n\t\t\tif (n == 0 && m == 0)\n\t\t\t\tbreak;\n\n\t\t\t//\n\t\t\tm++;\n\t\t\tint[] wish = new int[m];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tline = br.readLine();\n\t\t\t\tfor (int j = 0; j < line.length(); j += 2) {\n\t\t\t\t\tif (line.charAt(j) == '1')\n\t\t\t\t\t\twish[j / 2 + 1]++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t//\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tfor (int i = n; i >= 0; i--) {\n\t\t\t\tfor (int j = 1; j < m; j++) {\n\t\t\t\t\tif (wish[j] == i)\n\t\t\t\t\t\tsb.append(j + \" \");\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.println(sb.toString().substring(0, sb.length() - 1));\n\t\t}\n\t}\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": 1020, "cpu_time_ms": 90, "memory_kb": 23316}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s975190645", "group_id": "codeNet:p00431", "input_text": "import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Random;\nimport java.util.Scanner;\nimport java.util.Set;\n\n//String With Rings\npublic class Main{\n\n\tList[] e;\n\tint res;\n\tboolean[] v;\n\t\n\tvoid dfs(int k, int d){\n\t\tres = Math.max(res, d);\n\t\tfor(int x:e[k])if(!v[x]){\n\t\t\tv[x] = true;\n\t\t\tdfs(x, d+1);\n\t\t\tv[x] = false;\n\t\t}\n\t}\n\t\n\t@SuppressWarnings(\"unchecked\")\n\tvoid run(){\n\t\tScanner sc = new Scanner(System.in);\n//\t\tsc.nextInt();\n//\t\tlong T = System.currentTimeMillis();\n\t\tRandom rand = new Random(1334259171148L);\n//\t\tSystem.out.println(T);\n\t\tfor(;;){\n\t\t\tint n = sc.nextInt();\n\t\t\tif(n==0)break;\n\t\t\te = new List[101];\n\t\t\tfor(int i=1;i<101;i++)e[i]=new ArrayList();\n\t\t\tboolean[] u = new boolean[101];\n\t\t\twhile(n--!=0){\n\t\t\t\tint a = sc.nextInt(), b = sc.nextInt();\n\t\t\t\tu[a] = u[b] = true;\n\t\t\t\te[a].add(b); e[b].add(a);\n\t\t\t}\n\t\t\tv = new boolean[101];\n\t\t\tres = 0;\n//\t\t\tint min = 150, max = 0;\n//\t\t\tfor(int i=1;i<101;i++)if(u[i]){\n//\t\t\t\tmin = Math.min(min, e[i].size()); max = Math.max(max, e[i].size());\n//\t\t\t}\n\t\t\tint[] a = new int[100];\n\t\t\tint id = 0;\n\t\t\tfor(int i=1;i<101;i++)if(!e[i].isEmpty())a[id++] = i;\n\t\t\tSet U = new HashSet();\n\t\t\tfor(int i=0;i[] e;\n\tint res;\n\tboolean[] v;\n\t\n\tvoid dfs(int k, int d){\n\t\tres = Math.max(res, d);\n\t\tfor(int x:e[k])if(!v[x]){\n\t\t\tv[x] = true;\n\t\t\tdfs(x, d+1);\n\t\t\tv[x] = false;\n\t\t}\n\t}\n\t\n\t@SuppressWarnings(\"unchecked\")\n\tvoid run(){\n\t\tScanner sc = new Scanner(System.in);\n//\t\tsc.nextInt();\n//\t\tlong T = System.currentTimeMillis();\n\t\tRandom rand = new Random(1334259171148L);\n//\t\tSystem.out.println(T);\n\t\tfor(;;){\n\t\t\tint n = sc.nextInt();\n\t\t\tif(n==0)break;\n\t\t\te = new List[101];\n\t\t\tfor(int i=1;i<101;i++)e[i]=new ArrayList();\n\t\t\tboolean[] u = new boolean[101];\n\t\t\twhile(n--!=0){\n\t\t\t\tint a = sc.nextInt(), b = sc.nextInt();\n\t\t\t\tu[a] = u[b] = true;\n\t\t\t\te[a].add(b); e[b].add(a);\n\t\t\t}\n\t\t\tv = new boolean[101];\n\t\t\tres = 0;\n//\t\t\tint min = 150, max = 0;\n//\t\t\tfor(int i=1;i<101;i++)if(u[i]){\n//\t\t\t\tmin = Math.min(min, e[i].size()); max = Math.max(max, e[i].size());\n//\t\t\t}\n\t\t\tint[] a = new int[100];\n\t\t\tint id = 0;\n\t\t\tfor(int i=1;i<101;i++)if(!e[i].isEmpty())a[id++] = i;\n\t\t\tSet U = new HashSet();\n\t\t\tfor(int i=0;i= charLen) {\n\t\t\tcharNum = 0;\n\t\t\ttry {\n\t\t\t\tcharLen = in.read(buf);\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new InputMismatchException();\n\t\t\t}\n\t\t\tif (charLen <= 0) return -1;\n\t\t}\n\t\treturn buf[charNum++];\n\t}\n\n\tpublic String next() {\n\t\tint c = read();\n\t\twhile (isWhitespace(c)) {\n\t\t\tc = read();\n\t\t}\n\t\tsb.setLength(0);\n\t\tdo {\n\t\t\tsb.appendCodePoint(c);\n\t\t\tc = read();\n\t\t} while (!isWhitespace(c));\n\t\treturn sb.toString();\n\t}\n\n\tpublic char[] nextCharArray() {\n\t\treturn next().toCharArray();\n\t}\n\n\tpublic char[][] nextCharArray2d(int lines) {\n\t\tchar[] first = nextCharArray();\n\t\tchar[][] array = new char[lines][first.length];\n\t\tarray[0] = first;\n\t\tfor (int i = 1; i < lines; i++)\n\t\t\tarray[i] = nextCharArray();\n\t\treturn array;\n\t}\n\n\tpublic char[][] nextCharArray2d(int lines, int rows) {\n\t\tchar[][] array = new char[lines][rows];\n\t\tfor (int i = 0; i < lines; i++)\n\t\t\tarray[i] = nextCharArray();\n\t\treturn array;\n\t}\n\n\tpublic int nextInt() {\n\t\treturn (int) nextLong();\n\t}\n\n\tpublic int[] nextIntArray(int n) {\n\t\tint[] array = new int[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tarray[i] = nextInt();\n\t\treturn array;\n\t}\n\n\tpublic List nextIntList(int n) {\n\t\tInteger[] array = new Integer[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tarray[i] = nextInt();\n\t\treturn Arrays.asList(array);\n\t}\n\n\tpublic int[][] nextIntArray2D(int n, int m) {\n\t\tint[][] array = new int[n][m];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tarray[i] = nextIntArray(m);\n\t\treturn array;\n\t}\n\n\tpublic List nextIntsList(int n, int m) {\n\t\tList list = new ArrayList(n);\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tlist.add(nextIntArray(m));\n\t\treturn list;\n\t}\n\n\tpublic long nextLong() {\n\t\tint c = read();\n\t\twhile (isWhitespace(c)) {\n\t\t\tc = read();\n\t\t}\n\t\tint sgn = 1;\n\t\tif (c == '-') {\n\t\t\tsgn = -1;\n\t\t\tc = read();\n\t\t}\n\t\tlong res = 0;\n\t\tdo {\n\t\t\tif (c < '0' || c > '9') throw new InputMismatchException();\n\t\t\tres *= 10;\n\t\t\tres += c - '0';\n\t\t\tc = read();\n\t\t} while (!isWhitespace(c));\n\t\treturn res * sgn;\n\t}\n\n\tpublic double nextDouble() {\n\t\treturn Double.parseDouble(next());\n\t}\n\n\tpublic double[] nextDoubleArray(int n) {\n\t\tdouble[] array = new double[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tarray[i] = nextDouble();\n\t\treturn array;\n\t}\n\n\tpublic boolean isWhitespace(int c) {\n\t\treturn c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n\t}\n}", "language": "Java", "metadata": {"date": 1437146787, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00448.html", "problem_id": "p00448", "resource_group": "high_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/Java/s647109273.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s647109273", "user_id": "u282272858"}, "prompt_components": {"gold_output": "9\n15\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.InputMismatchException;\nimport java.util.List;\n\npublic class Main{\n\tstatic StringBuilder out = new StringBuilder();\n\tstatic final String OK = \"OK\";\n\tstatic final String NG = \"NG\";\n\tstatic final String Possible = \"Possible\";\n\tstatic final String Impossible = \"Impossible\";\n\tstatic FastReader in = new FastReader();\n\tstatic final int HEADS = 1;\n\tstatic final int TAILS = 0;\n\n\t// static final int INF = Integer.MAX_VALUE - 300000000;\n\n\tpublic static void main(String[] args) {\n\t\twhile (upsideDown())\n\t\t\t;\n\t}\n\n\tprivate static boolean upsideDown() {\n\t\tint h = in.nextInt();\n\t\tint w = in.nextInt();\n\t\tif (h == 0 && w == 0) return false;\n\n\t\tint[][] senbei = in.nextIntArray2D(h, w);\n\n\t\tSystem.out.println(solve(senbei));\n\t\treturn true;\n\t}\n\n\tprivate static int solve(int[][] senbei) {\n\t\tint row = senbei.length;\n\t\tint line = senbei[0].length;\n\t\tint ex = (int) Math.pow(2, row);\n\n\t\tint[] score = new int[ex];\n\n\t\tfor (int i = 0; i < line; i++) {\n\t\t\tfor (int j = 0; j < ex; j++) {\n\t\t\t\tint tempScore = 0;\n\t\t\t\tint[] filter = makeFilter(row, j);\n\t\t\t\tfor (int k = 0; k < row; k++) {\n\t\t\t\t\ttempScore += (senbei[k][i] + filter[k]) % 2;\n\t\t\t\t}\n\t\t\t\tscore[j] += Math.max(tempScore, row - tempScore);\n\t\t\t}\n\t\t}\n\n\t\tint maxScore = 0;\n\t\tfor (int i = 0; i < ex; i++) {\n\t\t\tmaxScore = Math.max(maxScore, score[i]);\n\t\t}\n\t\treturn maxScore;\n\t}\n\n\tprivate static int[] makeFilter(int row, int i) {\n\t\tint[] filter = new int[row];\n\t\tint temp = i;\n\t\tfor (int j = 0; j < row; j++) {\n\t\t\tfilter[j] = temp % 2;\n\t\t\ttemp /= 2;\n\t\t}\n\t\treturn filter;\n\t}\n\n\tstatic void printExit(Object msg) {\n\t\tSystem.out.println(msg);\n\t\tSystem.exit(0);\n\t}\n}\n\nclass FastReader{\n\tprivate InputStream in = System.in;\n\tprivate byte[] buf = new byte[1024];\n\tprivate int charNum;\n\tprivate int charLen;\n\tprivate StringBuilder sb = new StringBuilder();\n\n\tpublic int read() {\n\t\tif (charLen == -1) throw new InputMismatchException();\n\t\tif (charNum >= charLen) {\n\t\t\tcharNum = 0;\n\t\t\ttry {\n\t\t\t\tcharLen = in.read(buf);\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new InputMismatchException();\n\t\t\t}\n\t\t\tif (charLen <= 0) return -1;\n\t\t}\n\t\treturn buf[charNum++];\n\t}\n\n\tpublic String next() {\n\t\tint c = read();\n\t\twhile (isWhitespace(c)) {\n\t\t\tc = read();\n\t\t}\n\t\tsb.setLength(0);\n\t\tdo {\n\t\t\tsb.appendCodePoint(c);\n\t\t\tc = read();\n\t\t} while (!isWhitespace(c));\n\t\treturn sb.toString();\n\t}\n\n\tpublic char[] nextCharArray() {\n\t\treturn next().toCharArray();\n\t}\n\n\tpublic char[][] nextCharArray2d(int lines) {\n\t\tchar[] first = nextCharArray();\n\t\tchar[][] array = new char[lines][first.length];\n\t\tarray[0] = first;\n\t\tfor (int i = 1; i < lines; i++)\n\t\t\tarray[i] = nextCharArray();\n\t\treturn array;\n\t}\n\n\tpublic char[][] nextCharArray2d(int lines, int rows) {\n\t\tchar[][] array = new char[lines][rows];\n\t\tfor (int i = 0; i < lines; i++)\n\t\t\tarray[i] = nextCharArray();\n\t\treturn array;\n\t}\n\n\tpublic int nextInt() {\n\t\treturn (int) nextLong();\n\t}\n\n\tpublic int[] nextIntArray(int n) {\n\t\tint[] array = new int[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tarray[i] = nextInt();\n\t\treturn array;\n\t}\n\n\tpublic List nextIntList(int n) {\n\t\tInteger[] array = new Integer[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tarray[i] = nextInt();\n\t\treturn Arrays.asList(array);\n\t}\n\n\tpublic int[][] nextIntArray2D(int n, int m) {\n\t\tint[][] array = new int[n][m];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tarray[i] = nextIntArray(m);\n\t\treturn array;\n\t}\n\n\tpublic List nextIntsList(int n, int m) {\n\t\tList list = new ArrayList(n);\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tlist.add(nextIntArray(m));\n\t\treturn list;\n\t}\n\n\tpublic long nextLong() {\n\t\tint c = read();\n\t\twhile (isWhitespace(c)) {\n\t\t\tc = read();\n\t\t}\n\t\tint sgn = 1;\n\t\tif (c == '-') {\n\t\t\tsgn = -1;\n\t\t\tc = read();\n\t\t}\n\t\tlong res = 0;\n\t\tdo {\n\t\t\tif (c < '0' || c > '9') throw new InputMismatchException();\n\t\t\tres *= 10;\n\t\t\tres += c - '0';\n\t\t\tc = read();\n\t\t} while (!isWhitespace(c));\n\t\treturn res * sgn;\n\t}\n\n\tpublic double nextDouble() {\n\t\treturn Double.parseDouble(next());\n\t}\n\n\tpublic double[] nextDoubleArray(int n) {\n\t\tdouble[] array = new double[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tarray[i] = nextDouble();\n\t\treturn array;\n\t}\n\n\tpublic boolean isWhitespace(int c) {\n\t\treturn c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n\t}\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": 4285, "cpu_time_ms": 830, "memory_kb": 281036}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s045443603", "group_id": "codeNet:p00451", "input_text": "import java.util.Scanner;\n\npublic class Main{\n public Main(){\n\tScanner sc = new Scanner(System.in);\n\n\twhile(sc.hasNext()){\n\t String s = sc.next();\n\t String t = sc.next();\n\t s = \" \" + s;\n\t t = \" \" + t;\n\t int n = s.length();\n\t int m = t.length();\n\t int a[][] = new int[n+1][];\n\t int b[][] = new int[n+1][];\n\t a[0] = new int[m+1];\n\t a[1] = new int[m+1];\n\t b[0] = new int[m+1];\n\t b[1] = new int[m+1];\n\n\t for(int i = 1; i < n; i++){\n\t\ta[i+1] = new int[m+1];\n\t\tb[i+1] = new int[m+1];\n\t\tchar w = s.charAt(i);\n\n\t\tfor(int j = 1; j < m; j++){\n\t\t if(w == t.charAt(j)){\n\t\t\tif(b[i][j] == 1){\n\t\t\t a[i+1][j+1] = a[i][j] + 1;\n\t\t\t} else {\n\t\t\t a[i+1][j+1] = 1;\n\t\t\t}\n\t\t\tb[i+1][j+1] = 1;\n\t\t } else {\n\t\t\tif(a[i+1][j] > a[i][j+1]){\n\t\t\t a[i+1][j+1] = a[i+1][j];\n\t\t\t} else {\n\t\t\t a[i+1][j+1] = a[i][j+1];\n\t\t\t}\n\t\t }\n\t\t}\n\t }\n\t int max = 0;\n\t for(int i = 1; i <= m; i++){\n\t\tif(max < a[n][i]){\n\t\t max = a[n][i];\n\t\t}\n\t }\n\t System.out.println(Integer.toString(max));\n\t}\n }\n\n public static void main(String[] args){\n\tnew Main();\n }\n}", "language": "Java", "metadata": {"date": 1289817898, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00451.html", "problem_id": "p00451", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00451/input.txt", "sample_output_relpath": "derived/input_output/data/p00451/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00451/Java/s045443603.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s045443603", "user_id": "u529013669"}, "prompt_components": {"gold_output": "5\n0\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main{\n public Main(){\n\tScanner sc = new Scanner(System.in);\n\n\twhile(sc.hasNext()){\n\t String s = sc.next();\n\t String t = sc.next();\n\t s = \" \" + s;\n\t t = \" \" + t;\n\t int n = s.length();\n\t int m = t.length();\n\t int a[][] = new int[n+1][];\n\t int b[][] = new int[n+1][];\n\t a[0] = new int[m+1];\n\t a[1] = new int[m+1];\n\t b[0] = new int[m+1];\n\t b[1] = new int[m+1];\n\n\t for(int i = 1; i < n; i++){\n\t\ta[i+1] = new int[m+1];\n\t\tb[i+1] = new int[m+1];\n\t\tchar w = s.charAt(i);\n\n\t\tfor(int j = 1; j < m; j++){\n\t\t if(w == t.charAt(j)){\n\t\t\tif(b[i][j] == 1){\n\t\t\t a[i+1][j+1] = a[i][j] + 1;\n\t\t\t} else {\n\t\t\t a[i+1][j+1] = 1;\n\t\t\t}\n\t\t\tb[i+1][j+1] = 1;\n\t\t } else {\n\t\t\tif(a[i+1][j] > a[i][j+1]){\n\t\t\t a[i+1][j+1] = a[i+1][j];\n\t\t\t} else {\n\t\t\t a[i+1][j+1] = a[i][j+1];\n\t\t\t}\n\t\t }\n\t\t}\n\t }\n\t int max = 0;\n\t for(int i = 1; i <= m; i++){\n\t\tif(max < a[n][i]){\n\t\t max = a[n][i];\n\t\t}\n\t }\n\t System.out.println(Integer.toString(max));\n\t}\n }\n\n public static void main(String[] args){\n\tnew Main();\n }\n}", "problem_context": "共通部分文字列\n\n問題\n\n2 個の文字列が与えられたとき, 両方の文字列に含まれる文字列のうち最も長いものを探し, その長さを答えるプログラムを作成せよ.\n\nここで, 文字列 s が文字列 t に含まれるとは, t の中に s が連続して現れることをいう. 空文字列, すなわち長さ 0 の文字列は, どんな文字列にも含まれる. 例えば, 文字列 ABRACADABRA には次の文字列が含まれる: ABRA, RAC, D, ACADABRA, ABRACADABRA,空文字列など. 一方, 文字列 ABRACADABRA には次の文字列は含まれない: ABRC, RAA,BA, K など.\n\n例\n\n例 1: 文字列として ABRACADABRA と ECADADABRBCRDARA が与えられた場合, 両方に含まれる文字列には CA や CADA や ADABR や空文字列などがある. そのうち最も長いのは ADABR であり, その長さは 5 である. 2 個の文字列の中に含まれる ADABR\nの位置を以下に示す.\n\nABRACADABRA\n\nECADADABRBCRDARA\n\n例 2: 文字列として UPWJCIRUCAXIIRGL と SBQNYBSBZDFNEV が与えられた場合, 両方に含まれる文字列は空文字列のみであり, その長さは 0 である.\n\n入力\n\n入力は複数のデータセットからなる.各データセットは以下の形式で与えられる.\n\n入力は 2 行からなり, 1 行目に 1 個目の文字列が, 2 行目に 2 個目の文字列が与えられる. 文字列は英大文字からなり, 各々の文字列の長さは 1 以上 4000 以下である.\n\n採点用データのうち, 配点の 30% 分については, 各々の文字列の長さは 1 以上 50以下である.\n\n入力の終わりは EOF で示される. データセットの数は 10 を超えない.\n\n出力\n\nデータセットごとに与えられた 2 個の文字列の両方に含まれる文字列のうち最も長いものの長さを 1 行に出力する.\n\n入出力例\n\n入力例\n\nABRACADABRA\nECADADABRBCRDARA\nUPWJCIRUCAXIIRGL\nSBQNYBSBZDFNEV\n\n出力例\n\n5\n0\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "ABRACADABRA\nECADADABRBCRDARA\nUPWJCIRUCAXIIRGL\nSBQNYBSBZDFNEV\n"}, "reference_outputs": ["5\n0\n"], "source_document_id": "p00451", "source_text": "共通部分文字列\n\n問題\n\n2 個の文字列が与えられたとき, 両方の文字列に含まれる文字列のうち最も長いものを探し, その長さを答えるプログラムを作成せよ.\n\nここで, 文字列 s が文字列 t に含まれるとは, t の中に s が連続して現れることをいう. 空文字列, すなわち長さ 0 の文字列は, どんな文字列にも含まれる. 例えば, 文字列 ABRACADABRA には次の文字列が含まれる: ABRA, RAC, D, ACADABRA, ABRACADABRA,空文字列など. 一方, 文字列 ABRACADABRA には次の文字列は含まれない: ABRC, RAA,BA, K など.\n\n例\n\n例 1: 文字列として ABRACADABRA と ECADADABRBCRDARA が与えられた場合, 両方に含まれる文字列には CA や CADA や ADABR や空文字列などがある. そのうち最も長いのは ADABR であり, その長さは 5 である. 2 個の文字列の中に含まれる ADABR\nの位置を以下に示す.\n\nABRACADABRA\n\nECADADABRBCRDARA\n\n例 2: 文字列として UPWJCIRUCAXIIRGL と SBQNYBSBZDFNEV が与えられた場合, 両方に含まれる文字列は空文字列のみであり, その長さは 0 である.\n\n入力\n\n入力は複数のデータセットからなる.各データセットは以下の形式で与えられる.\n\n入力は 2 行からなり, 1 行目に 1 個目の文字列が, 2 行目に 2 個目の文字列が与えられる. 文字列は英大文字からなり, 各々の文字列の長さは 1 以上 4000 以下である.\n\n採点用データのうち, 配点の 30% 分については, 各々の文字列の長さは 1 以上 50以下である.\n\n入力の終わりは EOF で示される. データセットの数は 10 を超えない.\n\n出力\n\nデータセットごとに与えられた 2 個の文字列の両方に含まれる文字列のうち最も長いものの長さを 1 行に出力する.\n\n入出力例\n\n入力例\n\nABRACADABRA\nECADADABRBCRDARA\nUPWJCIRUCAXIIRGL\nSBQNYBSBZDFNEV\n\n出力例\n\n5\n0\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": 1091, "cpu_time_ms": 3120, "memory_kb": 243000}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s551488245", "group_id": "codeNet:p00481", "input_text": "import java.util.*;\n\n\npublic class Main {\n\tstatic class pair{\n\t\tint x,y;\n\t\tpair(int x,int y){\n\t\t\tthis.x = x;\n\t\t\tthis.y = y;\n\t\t}\n\t}\n\tstatic Queue q = new LinkedList();\n\tpublic static void main(String args[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint H = sc.nextInt(),W = sc.nextInt(),N = sc.nextInt();\n\t\tString temp_in;\n\t\tchar[][] field = new char[H+2][W+2];\n\t\tpair start = null;\n\t\tfor(int i=0;i q = new LinkedList();\n\tpublic static void main(String args[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint H = sc.nextInt(),W = sc.nextInt(),N = sc.nextInt();\n\t\tString temp_in;\n\t\tchar[][] field = new char[H+2][W+2];\n\t\tpair start = null;\n\t\tfor(int i=0;i b ? c > b ? b : c : c > a ? a : c;\n int j = d > e ? e : d;\n \n System.out.println(p + j - 50);\n }\n}", "language": "Java", "metadata": {"date": 1465981692, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00488.html", "problem_id": "p00488", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00488/input.txt", "sample_output_relpath": "derived/input_output/data/p00488/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00488/Java/s410967789.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s410967789", "user_id": "u191801041"}, "prompt_components": {"gold_output": "848\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n public static Scanner sc;\n public static void main(String[] args) throws Exception {\n sc = new Scanner(System.in);\n \n int a = sc.nextInt();\n int b = sc.nextInt();\n int c = sc.nextInt();\n int d = sc.nextInt();\n int e = sc.nextInt();\n \n int p = a > b ? c > b ? b : c : c > a ? a : c;\n int j = d > e ? e : d;\n \n System.out.println(p + j - 50);\n }\n}", "problem_context": "ランチ (Lunch)\n\n問題\n\nJOI パスタ店では,ランチのおすすめパスタと搾りたてジュースのセットメニューが好評である.このセットメニューを注文するときは,その日の 3 種類のパスタと 2 種類のジュースから 1 つずつ選ぶ.パスタとジュースの値段の合計から 50 円を引いた金額が代金となる.\n\nある日のパスタとジュースの値段が与えられたとき,その日のセットメニューの代金の最小値を求めるプログラムを作成せよ.\n\n入力\n\n入力は 5 行からなり,1 行に 1 つずつ正の整数が書かれている.\n\n1 行目の整数は 1 つ目のパスタの値段である.\n\n2 行目の整数は 2 つ目のパスタの値段である.\n\n3 行目の整数は 3 つ目のパスタの値段である.\n\n4 行目の整数は 1 つ目のジュースの値段である.\n\n5 行目の整数は 2 つ目のジュースの値段である.\n\nただし,与えられる入力データにおいては全てのパスタとジュースの値段は 100 円以上 2000 円以下であることが保証されている.\n\n出力\n\nその日のセットメニューの代金の最小値を 1 行で出力せよ.\n\n入出力例\n\n入力例 1\n\n800\n700\n900\n198\n330\n\n出力例 1\n\n848\n\n入出力例 1 では,2 つ目のパスタと 1 つ目のジュースを組み合わせた場合の\n700 + 198 - 50 = 848 がその日のセットメニューの代金の最小値である.\n\n入力例 2\n\n1999\n1999\n100\n189\n100\n\n出力例 2\n\n150\n\n入出力例 2 では,3 つ目のパスタと 2 つ目のジュースを組み合わせた場合の\n100 + 100 - 50 = 150 がその日のセットメニューの代金の最小値である.\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "800\n700\n900\n198\n330\n"}, "reference_outputs": ["848\n"], "source_document_id": "p00488", "source_text": "ランチ (Lunch)\n\n問題\n\nJOI パスタ店では,ランチのおすすめパスタと搾りたてジュースのセットメニューが好評である.このセットメニューを注文するときは,その日の 3 種類のパスタと 2 種類のジュースから 1 つずつ選ぶ.パスタとジュースの値段の合計から 50 円を引いた金額が代金となる.\n\nある日のパスタとジュースの値段が与えられたとき,その日のセットメニューの代金の最小値を求めるプログラムを作成せよ.\n\n入力\n\n入力は 5 行からなり,1 行に 1 つずつ正の整数が書かれている.\n\n1 行目の整数は 1 つ目のパスタの値段である.\n\n2 行目の整数は 2 つ目のパスタの値段である.\n\n3 行目の整数は 3 つ目のパスタの値段である.\n\n4 行目の整数は 1 つ目のジュースの値段である.\n\n5 行目の整数は 2 つ目のジュースの値段である.\n\nただし,与えられる入力データにおいては全てのパスタとジュースの値段は 100 円以上 2000 円以下であることが保証されている.\n\n出力\n\nその日のセットメニューの代金の最小値を 1 行で出力せよ.\n\n入出力例\n\n入力例 1\n\n800\n700\n900\n198\n330\n\n出力例 1\n\n848\n\n入出力例 1 では,2 つ目のパスタと 1 つ目のジュースを組み合わせた場合の\n700 + 198 - 50 = 848 がその日のセットメニューの代金の最小値である.\n\n入力例 2\n\n1999\n1999\n100\n189\n100\n\n出力例 2\n\n150\n\n入出力例 2 では,3 つ目のパスタと 2 つ目のジュースを組み合わせた場合の\n100 + 100 - 50 = 150 がその日のセットメニューの代金の最小値である.\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": 486, "cpu_time_ms": 70, "memory_kb": 26164}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s582175387", "group_id": "codeNet:p00490", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = in.nextInt();\n\t\tint a = in.nextInt();\n\t\tint b = in.nextInt();\n\t\tint c = in.nextInt();\n\t\tint tcal = c;\n\t\tint cnt = 0;\n\t\tint d[] = new int[100];\n\t\tfor(int i = 0; i < n; i++){\n\t\t\td[i] = in.nextInt();\n\t\t\tint tcaljn = tcal / a + b * cnt;\n\t\t\tint tcaln = tcal + d[i] / (a + b * (cnt + 1));\n\t\t\tif((c / a * 200 ) > d[i] * 100 / b){\n\t\t\t\tcontinue;\n\t\t\t}else if(tcaljn > tcaln){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\ttcal += d[i];\n\t\t\tcnt++;\n\t\t}\n\t\tSystem.out.println(tcal / (a + (cnt * b)));\n\t}\n}", "language": "Java", "metadata": {"date": 1429177771, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00490.html", "problem_id": "p00490", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00490/input.txt", "sample_output_relpath": "derived/input_output/data/p00490/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00490/Java/s582175387.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s582175387", "user_id": "u112466712"}, "prompt_components": {"gold_output": "37\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = in.nextInt();\n\t\tint a = in.nextInt();\n\t\tint b = in.nextInt();\n\t\tint c = in.nextInt();\n\t\tint tcal = c;\n\t\tint cnt = 0;\n\t\tint d[] = new int[100];\n\t\tfor(int i = 0; i < n; i++){\n\t\t\td[i] = in.nextInt();\n\t\t\tint tcaljn = tcal / a + b * cnt;\n\t\t\tint tcaln = tcal + d[i] / (a + b * (cnt + 1));\n\t\t\tif((c / a * 200 ) > d[i] * 100 / b){\n\t\t\t\tcontinue;\n\t\t\t}else if(tcaljn > tcaln){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\ttcal += d[i];\n\t\t\tcnt++;\n\t\t}\n\t\tSystem.out.println(tcal / (a + (cnt * b)));\n\t}\n}", "problem_context": "最高のピザ (Best Pizza)\n\n問題\n\nK 理事長は,JOI 市の中心部にある JOI ピザ店の常連客である.彼はある事情により,今月から節約生活を始めることにした.そこで彼は,JOI ピザ店で注文できるピザのうち,1 ドルあたりのカロリーが最大となるようなピザを注文したいと思った.このようなピザを「最高のピザ」と呼ぶことにしよう.「最高のピザ」は 1 種類とは限らない.\n\nJOI ピザでは N 種類のトッピングから何種類かを自由に選び,基本の生地の上に載せたものを注文することができる.同種のトッピングを 2 つ以上載せることはできない.生地にトッピングを 1 種類も載せないピザも注文できる.生地の値段は A ドルであり,トッピングの値段はいずれも B ドルである.ピザの値段は,生地の値段と載せたトッピングの値段の合計である.すなわち,トッピングを k 種類 (0 ≦ k ≦ N) 載せたピザの値段は A + k × B ドルである.ピザ全体のカロリーは,生地のカロリーと載せたトッピングのカロリーの合計である.\n\n生地の値段とトッピングの値段,および,生地と各トッピングのカロリーの値が与えられたとき,「最高のピザ」の 1 ドルあたりのカロリー数を求めるプログラムを作成せよ.\n\n入力\n\n入力は N + 3 行からなる.\n\n1 行目にはトッピングの種類数を表す 1 つの整数 N (1 ≦ N ≦ 100) が書かれている.2 行目には 2 つの整数 A, B (1 ≦ A ≦ 1000,1 ≦ B ≦ 1000) が空白を区切りとして書かれている.A は生地の値段,B はトッピングの値段を表す.3 行目には,生地のカロリー数を表す 1 つの整数 C (1 ≦ C ≦ 10000) が書かれている.\n\n3 + i 行目 (1 ≦ i ≦ N) には,i 番目のトッピングのカロリー数を表す 1 つの整数 Di (1 ≦ Di ≦ 10000) が書かれている.\n\n出力\n\n「最高のピザ」の 1 ドルあたりのカロリー数を 1 行で出力せよ.ただし,小数点以下は切り捨てて整数値で出力せよ.\n\n入出力例\n\n入力例 1\n\n3\n12 2\n200\n50\n300\n100\n\n出力例 1\n\n37\n\n入出力例 1 では,2 番目と 3 番目のトッピングを載せると,200 + 300 + 100 = 600 カロリーで 12 + 2 × 2 = 16 ドルのピザになる.\n\nこのピザは 1 ドルあたり 600 / 16 = 37.5 カロリーになる.これが「最高のピザ」となるので,37.5 の小数点以下を切り捨てた 37 を出力する.\n\n入力例 2\n\n4\n20 3\n900\n300\n100\n400\n1300\n\n出力例 2\n\n100\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "3\n12 2\n200\n50\n300\n100\n"}, "reference_outputs": ["37\n"], "source_document_id": "p00490", "source_text": "最高のピザ (Best Pizza)\n\n問題\n\nK 理事長は,JOI 市の中心部にある JOI ピザ店の常連客である.彼はある事情により,今月から節約生活を始めることにした.そこで彼は,JOI ピザ店で注文できるピザのうち,1 ドルあたりのカロリーが最大となるようなピザを注文したいと思った.このようなピザを「最高のピザ」と呼ぶことにしよう.「最高のピザ」は 1 種類とは限らない.\n\nJOI ピザでは N 種類のトッピングから何種類かを自由に選び,基本の生地の上に載せたものを注文することができる.同種のトッピングを 2 つ以上載せることはできない.生地にトッピングを 1 種類も載せないピザも注文できる.生地の値段は A ドルであり,トッピングの値段はいずれも B ドルである.ピザの値段は,生地の値段と載せたトッピングの値段の合計である.すなわち,トッピングを k 種類 (0 ≦ k ≦ N) 載せたピザの値段は A + k × B ドルである.ピザ全体のカロリーは,生地のカロリーと載せたトッピングのカロリーの合計である.\n\n生地の値段とトッピングの値段,および,生地と各トッピングのカロリーの値が与えられたとき,「最高のピザ」の 1 ドルあたりのカロリー数を求めるプログラムを作成せよ.\n\n入力\n\n入力は N + 3 行からなる.\n\n1 行目にはトッピングの種類数を表す 1 つの整数 N (1 ≦ N ≦ 100) が書かれている.2 行目には 2 つの整数 A, B (1 ≦ A ≦ 1000,1 ≦ B ≦ 1000) が空白を区切りとして書かれている.A は生地の値段,B はトッピングの値段を表す.3 行目には,生地のカロリー数を表す 1 つの整数 C (1 ≦ C ≦ 10000) が書かれている.\n\n3 + i 行目 (1 ≦ i ≦ N) には,i 番目のトッピングのカロリー数を表す 1 つの整数 Di (1 ≦ Di ≦ 10000) が書かれている.\n\n出力\n\n「最高のピザ」の 1 ドルあたりのカロリー数を 1 行で出力せよ.ただし,小数点以下は切り捨てて整数値で出力せよ.\n\n入出力例\n\n入力例 1\n\n3\n12 2\n200\n50\n300\n100\n\n出力例 1\n\n37\n\n入出力例 1 では,2 番目と 3 番目のトッピングを載せると,200 + 300 + 100 = 600 カロリーで 12 + 2 × 2 = 16 ドルのピザになる.\n\nこのピザは 1 ドルあたり 600 / 16 = 37.5 カロリーになる.これが「最高のピザ」となるので,37.5 の小数点以下を切り捨てた 37 を出力する.\n\n入力例 2\n\n4\n20 3\n900\n300\n100\n400\n1300\n\n出力例 2\n\n100\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": 602, "cpu_time_ms": 40, "memory_kb": 17168}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s361063171", "group_id": "codeNet:p00517", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\tint W = sc.nextInt();//南北方向にまっすぐに伸びる 道路\n\t\tint H = sc.nextInt();//東西方向にまっすぐに伸びる 道路\n\t\tint N = sc.nextInt();//観光スポットの数\n\t\tint i;\n\t\tint j = 0;\n\t\tint x[] = new int[N];\n\t\tint y[] = new int[N];\n\t\tint c = 0;\n\t\t\n\t\tfor(i = 0; i < N; i++){\n\t\t\tx[i] = sc.nextInt();\n\t\t\ty[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\t\n\t\t\n\t\twhile(true){//斜め移動上\n\t\t\tif(x[N-2] == x[N-1] && y[N-2] == y[N-1])break;\n\t\t\tif(x[j] < x[j+1] && y[j] < y[j+1]){\n\t\t\t\tx[j]++;\n\t\t\t\ty[j]++;\n\t\t\t\tc++;\n\t\t\t}\n\t\t\t\n\t\t\telse if(x[j] > x[j+1] && y[j] > y[j+1]){//斜め移動下\n\t\t\t\tx[j]--;\n\t\t\t\ty[j]--;\n\t\t\t\tc++;\n\t\t\t}\n\t\t\t\t\n\t\t\telse if(x[j] < x[j+1] && y[j] == y[j+1]){//目的地よりも現在地が左側でy軸は等しい\n\t\t\t\tx[j]++;\n\t\t\t\tc++;\n\t\t\t}\n\t\t\t\t\n\t\t\telse if(x[j] == x[j+1] && y[j] < y[j+1]){//目的地よりも現在地が下側でx軸は等しい\n\t\t\t\ty[j]++;\n\t\t\t\tc++;\n\t\t\t}\n\t\t\t\t\n\t\t\telse if(x[j] > x[j+1] && y[j] == y[j+1]){//目的地よりも現在地が右側でy軸は等しい\n\t\t\t\tx[j]--;\n\t\t\t\tc++;\n\t\t\t}\n\t\t\t\t\n\t\t\telse if(x[j] == x[j+1] && y[j] > y[j+1]){//目的地よりも現在地が上側でx軸は等しい\n\t\t\t\ty[j]--;\n\t\t\t\tc++;\n\t\t\t}\n\t\t\t\t\n\t\t\telse if(x[j] > x[j+1] && y[j] < y[j+1]){\n\t\t\t\tx[j]--;\n\t\t\t\ty[j]++;\n\t\t\t\tc+=2;\n\t\t\t}\n\t\t\t\t\n\t\t\telse if(x[j] < x[j+1] && y[j] > y[j+1]){\n\t\t\t\tx[j]++;\n\t\t\t\ty[j]--;\n\t\t\t\tc+=2;\n\t\t\t}\n\t\t\t\t\n\t\t\tif(x[j] == x[j+1] && y[j] == y[j+1]){\n\t\t\t\tj++;\n\t\t\t}\n\t\t\t\n\n\t\t}\n\n\t\tSystem.out.println(c);\n\t\t\n\t\t\n\t\t\n\t}\n\n}", "language": "Java", "metadata": {"date": 1398292425, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00517.html", "problem_id": "p00517", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00517/input.txt", "sample_output_relpath": "derived/input_output/data/p00517/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00517/Java/s361063171.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s361063171", "user_id": "u037061989"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\tint W = sc.nextInt();//南北方向にまっすぐに伸びる 道路\n\t\tint H = sc.nextInt();//東西方向にまっすぐに伸びる 道路\n\t\tint N = sc.nextInt();//観光スポットの数\n\t\tint i;\n\t\tint j = 0;\n\t\tint x[] = new int[N];\n\t\tint y[] = new int[N];\n\t\tint c = 0;\n\t\t\n\t\tfor(i = 0; i < N; i++){\n\t\t\tx[i] = sc.nextInt();\n\t\t\ty[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\t\n\t\t\n\t\twhile(true){//斜め移動上\n\t\t\tif(x[N-2] == x[N-1] && y[N-2] == y[N-1])break;\n\t\t\tif(x[j] < x[j+1] && y[j] < y[j+1]){\n\t\t\t\tx[j]++;\n\t\t\t\ty[j]++;\n\t\t\t\tc++;\n\t\t\t}\n\t\t\t\n\t\t\telse if(x[j] > x[j+1] && y[j] > y[j+1]){//斜め移動下\n\t\t\t\tx[j]--;\n\t\t\t\ty[j]--;\n\t\t\t\tc++;\n\t\t\t}\n\t\t\t\t\n\t\t\telse if(x[j] < x[j+1] && y[j] == y[j+1]){//目的地よりも現在地が左側でy軸は等しい\n\t\t\t\tx[j]++;\n\t\t\t\tc++;\n\t\t\t}\n\t\t\t\t\n\t\t\telse if(x[j] == x[j+1] && y[j] < y[j+1]){//目的地よりも現在地が下側でx軸は等しい\n\t\t\t\ty[j]++;\n\t\t\t\tc++;\n\t\t\t}\n\t\t\t\t\n\t\t\telse if(x[j] > x[j+1] && y[j] == y[j+1]){//目的地よりも現在地が右側でy軸は等しい\n\t\t\t\tx[j]--;\n\t\t\t\tc++;\n\t\t\t}\n\t\t\t\t\n\t\t\telse if(x[j] == x[j+1] && y[j] > y[j+1]){//目的地よりも現在地が上側でx軸は等しい\n\t\t\t\ty[j]--;\n\t\t\t\tc++;\n\t\t\t}\n\t\t\t\t\n\t\t\telse if(x[j] > x[j+1] && y[j] < y[j+1]){\n\t\t\t\tx[j]--;\n\t\t\t\ty[j]++;\n\t\t\t\tc+=2;\n\t\t\t}\n\t\t\t\t\n\t\t\telse if(x[j] < x[j+1] && y[j] > y[j+1]){\n\t\t\t\tx[j]++;\n\t\t\t\ty[j]--;\n\t\t\t\tc+=2;\n\t\t\t}\n\t\t\t\t\n\t\t\tif(x[j] == x[j+1] && y[j] == y[j+1]){\n\t\t\t\tj++;\n\t\t\t}\n\t\t\t\n\n\t\t}\n\n\t\tSystem.out.println(c);\n\t\t\n\t\t\n\t\t\n\t}\n\n}", "problem_context": "問題 3: 超都観光 (Super Metropolis)\n\n問題\n\nJOI 君は,IOI 国にある超都という都市の観光ツアーを計画することになった.\n\n超都は,南北方向にまっすぐに伸びる W 本の道路と,東西方向にまっすぐに伸びる H 本の道路により,碁盤の目の形に区分けされている.\n\n南北方向の W 本の道路には,西から順に 1, 2, ... , W の番号が付けられている.また,東西方向の H 本の道路には,南から順に 1, 2, ... , H の番号が付けられている.西から i 番目の南北方向の道路と,南から j 番目の東西方向の道路との交差点を (i, j) で表す.\n\nさらに,下図のように,各交差点からは1つ北東の交差点への道がある(最も北の道路上の交差点と最も東の道路上の交差点を除く).\nまた,1つ南西の交差点への道もある(最も南の道路上の交差点と最も西の道路上の交差点を除く).\nすなわち,交差点 (i, j) からは,もし交差点 (i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1) があるときは,それらの交差点へ1本の道を使って行くことが出来る.それに加え,もし交差点 (i - 1, j - 1), (i + 1, j + 1) があるときは,それらの交差点へも1本の道を使って行くことが出来る.\n\nJOI 君はツアーの計画として既に N 個の観光スポットをどのような順番で訪れるかを決めている.\ni 番目 (1 ≦ i ≦ N) に訪れる観光スポットは交差点 (Xi, Yi) にある.\nJOI 君は,ツアーにかかる時間をできるだけ短くするために,通らなければならない道の本数を少なくしたい.\n観光スポットを事前に決めた順番で訪れるために通らなければならない道の本数の合計の最小値を求めるプログラムを作成せよ.\n\nただし,ツアーの開始地点は交差点 (X1, Y1) である.また,ツアーの途中で超都の外へ移動してはならないものとする.\nまた,JOI 君は,観光スポットのある交差点を,観光スポットを訪れずに通過することもできる.\n\n「道の本数の合計」についての補足.ツアーの途中で同じ道を2回以上通ることもできる.その場合,「道の本数の合計」としては,その道については通った回数だけ重複して数えるものとする.\n\n入力\n\n入力は 1 + N 行からなる.\n\n1 行目には,空白を区切りとして 3 つの整数 W, H, N (2 ≤ W ≤ 10000, 2 ≤ H ≤ 10000, 1 ≤ N ≤ 1000) が書かれている.\n\n続く N 行のうちの i 行目 (1 ≤ i ≤ N) には,2 つの整数 Xi, Yi (1 ≤ Xi ≤ W, 1 ≤ Yi ≤ H) が空白を区切りとして書かれている.これは,i 番目に訪れる観光スポットのある交差点が (Xi, Yi) であることを表す.\n\n出力\n\n観光スポットを順番に訪れるために通る道の本数の合計の最小値を 1 行で出力せよ.\n\n入出力例\n\n入力例 1\n\n4 3 3\n1 1\n3 3\n4 1\n\n出力例 1\n\n5\n\n入出力例 1 では,例えば (1, 1), (2, 2), (3, 3), (3, 2), (4, 2), (4, 1) の順で交差点を訪れれば良い.\n\n入力例 2\n\n4 3 5\n1 3\n4 3\n2 2\n2 2\n1 3\n\n出力例 2\n\n7\n\n入出力例 2 のように,同じ交差点に複数回訪れることもある.\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "4 3 3\n1 1\n3 3\n4 1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p00517", "source_text": "問題 3: 超都観光 (Super Metropolis)\n\n問題\n\nJOI 君は,IOI 国にある超都という都市の観光ツアーを計画することになった.\n\n超都は,南北方向にまっすぐに伸びる W 本の道路と,東西方向にまっすぐに伸びる H 本の道路により,碁盤の目の形に区分けされている.\n\n南北方向の W 本の道路には,西から順に 1, 2, ... , W の番号が付けられている.また,東西方向の H 本の道路には,南から順に 1, 2, ... , H の番号が付けられている.西から i 番目の南北方向の道路と,南から j 番目の東西方向の道路との交差点を (i, j) で表す.\n\nさらに,下図のように,各交差点からは1つ北東の交差点への道がある(最も北の道路上の交差点と最も東の道路上の交差点を除く).\nまた,1つ南西の交差点への道もある(最も南の道路上の交差点と最も西の道路上の交差点を除く).\nすなわち,交差点 (i, j) からは,もし交差点 (i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1) があるときは,それらの交差点へ1本の道を使って行くことが出来る.それに加え,もし交差点 (i - 1, j - 1), (i + 1, j + 1) があるときは,それらの交差点へも1本の道を使って行くことが出来る.\n\nJOI 君はツアーの計画として既に N 個の観光スポットをどのような順番で訪れるかを決めている.\ni 番目 (1 ≦ i ≦ N) に訪れる観光スポットは交差点 (Xi, Yi) にある.\nJOI 君は,ツアーにかかる時間をできるだけ短くするために,通らなければならない道の本数を少なくしたい.\n観光スポットを事前に決めた順番で訪れるために通らなければならない道の本数の合計の最小値を求めるプログラムを作成せよ.\n\nただし,ツアーの開始地点は交差点 (X1, Y1) である.また,ツアーの途中で超都の外へ移動してはならないものとする.\nまた,JOI 君は,観光スポットのある交差点を,観光スポットを訪れずに通過することもできる.\n\n「道の本数の合計」についての補足.ツアーの途中で同じ道を2回以上通ることもできる.その場合,「道の本数の合計」としては,その道については通った回数だけ重複して数えるものとする.\n\n入力\n\n入力は 1 + N 行からなる.\n\n1 行目には,空白を区切りとして 3 つの整数 W, H, N (2 ≤ W ≤ 10000, 2 ≤ H ≤ 10000, 1 ≤ N ≤ 1000) が書かれている.\n\n続く N 行のうちの i 行目 (1 ≤ i ≤ N) には,2 つの整数 Xi, Yi (1 ≤ Xi ≤ W, 1 ≤ Yi ≤ H) が空白を区切りとして書かれている.これは,i 番目に訪れる観光スポットのある交差点が (Xi, Yi) であることを表す.\n\n出力\n\n観光スポットを順番に訪れるために通る道の本数の合計の最小値を 1 行で出力せよ.\n\n入出力例\n\n入力例 1\n\n4 3 3\n1 1\n3 3\n4 1\n\n出力例 1\n\n5\n\n入出力例 1 では,例えば (1, 1), (2, 2), (3, 3), (3, 2), (4, 2), (4, 1) の順で交差点を訪れれば良い.\n\n入力例 2\n\n4 3 5\n1 3\n4 3\n2 2\n2 2\n1 3\n\n出力例 2\n\n7\n\n入出力例 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": 1615, "cpu_time_ms": 170, "memory_kb": 25684}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s008882017", "group_id": "codeNet:p00575", "input_text": "import java.util.*;\n\npublic class Main{\n public static void main(String[] args){\n Scanner scan = new Scanner(System.in);\n \n int dayRcoin = scan.nextInt();\n int weekRcoin = scan.nextInt();\n int aimRcoin = scan.nextInt();\n int nowRcoin = 0;\n int logindays;\n\n for(logindays=0; nowRcoin= 0; x++, y--) {\n\t\t\t\t\t\tjpeg[y][x] = val++;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor (; x >= 0; x--, y++) {\n\t\t\t\t\t\tjpeg[y][x] = val++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (i % 2 == 0) {\n\t\t\t\t\tfor (; x < N; x++, y--) {\n\t\t\t\t\t\tjpeg[y][x] = val++;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor (; y < N; x--, y++) {\n\t\t\t\t\t\tjpeg[y][x] = val++;\n\t\t\t\t\t}\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (i < N - 1) {\n\t\t\t\tif (i % 2 == 0) {\n\t\t\t\t\ty++;\n\t\t\t\t} else {\n\t\t\t\t\tx++;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (i % 2 == 0) {\n\t\t\t\t\tx--; y += 2;\n\t\t\t\t} else {\n\t\t\t\t\tx += 2; y--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(\"Case \" + tc + \":\");\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tfor (int j = 0; j < N; j++) {\n\t\t\t\tif (j != N - 1) {\n\t\t\t\t\tSystem.out.print(jpeg[i][j] + \" \");\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.println(jpeg[i][j]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1304939433, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00593.html", "problem_id": "p00593", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00593/input.txt", "sample_output_relpath": "derived/input_output/data/p00593/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00593/Java/s619443829.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s619443829", "user_id": "u863376467"}, "prompt_components": {"gold_output": "Case 1:\n 1 2 6\n 3 5 7\n 4 8 9\nCase 2:\n 1 2 6 7\n 3 5 8 13\n 4 9 12 14\n 10 11 15 16\n", "input_to_evaluate": "import java.util.*;\nimport static java.util.Arrays.*;\nimport static java.lang.Math.*;\n\npublic class Main {\n\n\tstatic int tc;\n\tpublic static void main(String[] args) {\n\t\tfor (tc = 1; read(); tc++) {\n\t\t\tsolve();\n\t\t}\n\t}\n\t\n\t\n\tstatic int N;\n\tstatic Scanner sc = new Scanner(System.in);\n\tstatic boolean read() {\n\t\tN = sc.nextInt();\n\t\tif (N == 0) return false;\n\t\treturn true;\n\t}\n\t\n\tstatic void solve() {\n\t\tint val = 1;\n\t\tint[][] jpeg = new int[100][100];\n\t\tjpeg[0][0] = val++;\n\t\tint m = 0, x = 1, y = 0;\n\t\tfor (int i = 1; i < N * 2; i++) {\n\t\t\tif (i < N - 1) {\n\t\t\t\tif (i % 2 == 0) {\n\t\t\t\t\tfor (; y >= 0; x++, y--) {\n\t\t\t\t\t\tjpeg[y][x] = val++;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor (; x >= 0; x--, y++) {\n\t\t\t\t\t\tjpeg[y][x] = val++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (i % 2 == 0) {\n\t\t\t\t\tfor (; x < N; x++, y--) {\n\t\t\t\t\t\tjpeg[y][x] = val++;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor (; y < N; x--, y++) {\n\t\t\t\t\t\tjpeg[y][x] = val++;\n\t\t\t\t\t}\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (i < N - 1) {\n\t\t\t\tif (i % 2 == 0) {\n\t\t\t\t\ty++;\n\t\t\t\t} else {\n\t\t\t\t\tx++;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (i % 2 == 0) {\n\t\t\t\t\tx--; y += 2;\n\t\t\t\t} else {\n\t\t\t\t\tx += 2; y--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(\"Case \" + tc + \":\");\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tfor (int j = 0; j < N; j++) {\n\t\t\t\tif (j != N - 1) {\n\t\t\t\t\tSystem.out.print(jpeg[i][j] + \" \");\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.println(jpeg[i][j]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "problem_context": "JPEG Compression\n\nThe fundamental idea in the JPEG compression algorithm is to sort coeffi-\ncient of given image by zigzag path and encode it. In this problem, we don’t\ndiscuss about details of the algorithm, but you are asked to make simple pro-\ngram. You are given single integer N , and you must output zigzag path on\na matrix where size is N by N . The zigzag scanning is start at the upper-left\ncorner (0, 0) and end up at the bottom-right corner. See the following Figure\nand sample output to make sure rule of the zigzag scanning. For example, if you\nare given N = 8, corresponding output should be a matrix shown in right-side\nof the Figure. This matrix consists of visited time for each element.\n\nInput\n\nSeveral test cases are given. Each test case consists of one integer N (0 < N <\n10) in a line. The input will end at a line contains single zero.\n\nOutput\n\nFor each input, you must output a matrix where each element is the visited\ntime. All numbers in the matrix must be right justified in a field of width 3.\nEach matrix should be prefixed by a header “Case x:” where x equals test case\nnumber.\n\nSample Input\n\n3\n4\n0\n\nOutput for the Sample Input\n\nCase 1:\n1 2 6\n3 5 7\n4 8 9\nCase 2:\n1 2 6 7\n3 5 8 13\n4 9 12 14\n10 11 15 16", "sample_input": "3\n4\n0\n"}, "reference_outputs": ["Case 1:\n 1 2 6\n 3 5 7\n 4 8 9\nCase 2:\n 1 2 6 7\n 3 5 8 13\n 4 9 12 14\n 10 11 15 16\n"], "source_document_id": "p00593", "source_text": "JPEG Compression\n\nThe fundamental idea in the JPEG compression algorithm is to sort coeffi-\ncient of given image by zigzag path and encode it. In this problem, we don’t\ndiscuss about details of the algorithm, but you are asked to make simple pro-\ngram. You are given single integer N , and you must output zigzag path on\na matrix where size is N by N . The zigzag scanning is start at the upper-left\ncorner (0, 0) and end up at the bottom-right corner. See the following Figure\nand sample output to make sure rule of the zigzag scanning. For example, if you\nare given N = 8, corresponding output should be a matrix shown in right-side\nof the Figure. This matrix consists of visited time for each element.\n\nInput\n\nSeveral test cases are given. Each test case consists of one integer N (0 < N <\n10) in a line. The input will end at a line contains single zero.\n\nOutput\n\nFor each input, you must output a matrix where each element is the visited\ntime. All numbers in the matrix must be right justified in a field of width 3.\nEach matrix should be prefixed by a header “Case x:” where x equals test case\nnumber.\n\nSample Input\n\n3\n4\n0\n\nOutput for the Sample Input\n\nCase 1:\n1 2 6\n3 5 7\n4 8 9\nCase 2:\n1 2 6 7\n3 5 8 13\n4 9 12 14\n10 11 15 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": 1339, "cpu_time_ms": 90, "memory_kb": 12000}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s108987051", "group_id": "codeNet:p00594", "input_text": "import java.util.Arrays;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.Scanner;\npublic class Main\n{\n\tpublic static void main(String[] args) \n\t{\n\t\tScanner in=new Scanner(System.in);\n\t\tfor(;;)\n\t\t{\n\t\t\tint n=in.nextInt();\n\t\t\tif(n==0)\n\t\t\t\treturn;\n\t\t\tMapHM=new HashMap();\n\t\t\tString ans=\"\";\n\t\t\tboolean judge=false;\n\t\t\tint index=n;\n\t\t\tfor(int i=0;in/2)\n\t\t\t\t{\n\t\t\t\t\tjudge=true;\n\t\t\t\t\tans=str;\n\t\t\t\t\tindex=i+1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor(int i=0;iHM=new HashMap();\n\t\t\tString ans=\"\";\n\t\t\tboolean judge=false;\n\t\t\tint index=n;\n\t\t\tfor(int i=0;in/2)\n\t\t\t\t{\n\t\t\t\t\tjudge=true;\n\t\t\t\t\tans=str;\n\t\t\t\t\tindex=i+1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor(int i=0;i (|A| / 2 )\n\nIf there is no such m, you also have to report the fact. There is no\nsuch m for the above example, but for a array A = {5, 2, 5, 3, 4, 5, 5}, 5 is the answer.\n\nInput\n\nThere are several test cases. For each test case, in the first line |A| is given. In the next line, there will be |A| integers. The integers are less than 231 and |A| < 1,000,000. The input terminate with a line which contains single 0.\n\nOutput\n\nFor each test case, output m in a line. If there is no answer, output \"NO COLOR\" in a line.\n\nSample Input\n\n8\n3 1 2 3 3 1 5 3\n7\n5 2 5 3 4 5 5\n0\n\nOutput for the Sample Input\n\nNO COLOR\n5", "sample_input": "8\n3 1 2 3 3 1 5 3\n7\n5 2 5 3 4 5 5\n0\n"}, "reference_outputs": ["NO COLOR\n5\n"], "source_document_id": "p00594", "source_text": "What Color Is The Universe?\n\nOn a clear night, a boy, Campanella looked up at the sky, there were many stars which have different colors such as red, yellow, green, blue, purple, etc. He was watching the stars and just lost track of time. Presently, he wondered,\n\n\"There are many stars in the space. What color is the universe if I look up it from outside?\"\n\nUntil he found the answer to this question, he couldn't sleep. After a moment's thought, he proposed a hypothesis,\n\n\"When I observe the stars in the sky, if more than half of the stars have the same color, that is the color of the universe.\"\n\nHe has collected data of stars in the universe after consistently observing them. However, when he try to count the number of star, he was in bed sick with a cold. You decided to help him by developing a program to identify the color of the universe.\n\nYou are given an array A. Let |A| be the number of element in A, and let Nm be the number of m in A. For example, if A = {3, 1, 2, 3, 3, 1, 5, 3}, |A| = 8, N3 = 4, N1 = 2, N5 = 1. Your program have to find m such that:\n\nNm > (|A| / 2 )\n\nIf there is no such m, you also have to report the fact. There is no\nsuch m for the above example, but for a array A = {5, 2, 5, 3, 4, 5, 5}, 5 is the answer.\n\nInput\n\nThere are several test cases. For each test case, in the first line |A| is given. In the next line, there will be |A| integers. The integers are less than 231 and |A| < 1,000,000. The input terminate with a line which contains single 0.\n\nOutput\n\nFor each test case, output m in a line. If there is no answer, output \"NO COLOR\" in a line.\n\nSample Input\n\n8\n3 1 2 3 3 1 5 3\n7\n5 2 5 3 4 5 5\n0\n\nOutput for the Sample Input\n\nNO COLOR\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": 823, "cpu_time_ms": 2050, "memory_kb": 474300}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s724902263", "group_id": "codeNet:p00595", "input_text": "import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.util.StringTokenizer;\n\nclass Main {\n public static void main(String[] args) {\n try {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String line = br.readLine();\n StringTokenizer st = new StringTokenizer(line, \" \");\n while(st.hasMoreTokens()) {\n \tint x = Integer.parseInt(st.nextToken());\n int y = Integer.parseInt(st.nextToken());\n\n \tif(x < y) {\n \t\tx = x + y;\n \ty = x - y;\n \tx = x - y;\n\n \t}\n\n \twhile(y > 0) {\n \t\tint r = x % y;\n \t\tx = y;\n \t\ty = r;\n \t}\n \tSystem.out.println(x);\n }\n\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n}", "language": "Java", "metadata": {"date": 1508079303, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00595.html", "problem_id": "p00595", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00595/input.txt", "sample_output_relpath": "derived/input_output/data/p00595/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00595/Java/s724902263.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s724902263", "user_id": "u647237564"}, "prompt_components": {"gold_output": "19\n12\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.util.StringTokenizer;\n\nclass Main {\n public static void main(String[] args) {\n try {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String line = br.readLine();\n StringTokenizer st = new StringTokenizer(line, \" \");\n while(st.hasMoreTokens()) {\n \tint x = Integer.parseInt(st.nextToken());\n int y = Integer.parseInt(st.nextToken());\n\n \tif(x < y) {\n \t\tx = x + y;\n \ty = x - y;\n \tx = x - y;\n\n \t}\n\n \twhile(y > 0) {\n \t\tint r = x % y;\n \t\tx = y;\n \t\ty = r;\n \t}\n \tSystem.out.println(x);\n }\n\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n}", "problem_context": "Problem A: Greatest Common Divisor\n\nPlease find the greatest common divisor of two natural numbers. A clue is: The Euclid's algorithm is a way to resolve this task.\n\nInput\n\nThe input file consists of several lines with pairs of two natural numbers in each line. The numbers do not exceed 100000.\n\nThe number of pairs (datasets) is less than 50.\n\nOutput\n\nYour program has to print the greatest common divisor for each pair of input numbers. Print each result on a new line.\n\nSample Input\n\n57 38\n60 84\n\nOutput for the Sample Input\n\n19\n12", "sample_input": "57 38\n60 84\n"}, "reference_outputs": ["19\n12\n"], "source_document_id": "p00595", "source_text": "Problem A: Greatest Common Divisor\n\nPlease find the greatest common divisor of two natural numbers. A clue is: The Euclid's algorithm is a way to resolve this task.\n\nInput\n\nThe input file consists of several lines with pairs of two natural numbers in each line. The numbers do not exceed 100000.\n\nThe number of pairs (datasets) is less than 50.\n\nOutput\n\nYour program has to print the greatest common divisor for each pair of input numbers. Print each result on a new line.\n\nSample Input\n\n57 38\n60 84\n\nOutput for the Sample Input\n\n19\n12", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 888, "cpu_time_ms": 40, "memory_kb": 24308}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s433923044", "group_id": "codeNet:p00631", "input_text": "import java.util.*;\npublic class Main\n{\n\tstatic int n,ans;\n\tstatic int a[];\n\tpublic static void main(String[] args) \n\t{\n\t\tScanner in=new Scanner(System.in);\n\t\tfor(;;)\n\t\t{\n\t\t\tn=in.nextInt(); //n<=20\n\t\t\tif(n==0)\n\t\t\t\treturn;\n\t\t\ta=new int[n];\n\t\t\tfor(int i=0;i=0;j--){\n\t\t\t\t\txx[i+4][m-j-1] = xx[i][j]-xx[i][m-1];\n\t\t\t\t\tyy[i+4][m-j-1] = yy[i][j]-yy[i][m-1];\n\t\t\t\t}\n//\t\t\t\tSystem.out.println(Arrays.toString(xx[i]));\n//\t\t\t\tSystem.out.println(Arrays.toString(xx[i+4]));\n\t\t\t}\n\t\t\t\n\t\t\tfor(int i=0;i=0;j--){\n\t\t\t\t\txx[i+4][m-j-1] = xx[i][j]-xx[i][m-1];\n\t\t\t\t\tyy[i+4][m-j-1] = yy[i][j]-yy[i][m-1];\n\t\t\t\t}\n//\t\t\t\tSystem.out.println(Arrays.toString(xx[i]));\n//\t\t\t\tSystem.out.println(Arrays.toString(xx[i+4]));\n\t\t\t}\n\t\t\t\n\t\t\tfor(int i=0;i max)\n\t\t\t\t\tmax = p;\n\t\t\t\tif (p < min)\n\t\t\t\t\tmin = p;\n\t\t\t}\n\t\t\tc = c - max - min;\n\t\t\tSystem.out.println(c / (n - 2));\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1462773916, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00728.html", "problem_id": "p00728", "resource_group": "high_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/Java/s489499439.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s489499439", "user_id": "u563917086"}, "prompt_components": {"gold_output": "342\n7\n300\n326\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint c = 0, min = 1000, max = 0;\n\t\twhile (true) {\n\t\t\tint n = sc.nextInt();\n\t\t\tif (n == 0)\n\t\t\t\tbreak;\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tint p = sc.nextInt();\n\t\t\t\tc += p;\n\t\t\t\tif (p > max)\n\t\t\t\t\tmax = p;\n\t\t\t\tif (p < min)\n\t\t\t\t\tmin = p;\n\t\t\t}\n\t\t\tc = c - max - min;\n\t\t\tSystem.out.println(c / (n - 2));\n\t\t}\n\t}\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": 434, "cpu_time_ms": 80, "memory_kb": 28960}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s449638271", "group_id": "codeNet:p00735", "input_text": "import java.util.*;\nimport java.io.*;\n\npublic class Main {\n public static void main(String[] args) {\n FastScanner sc = new FastScanner();\n List seven = new ArrayList<>();\n for (long i = 6; i <= 300000; i += 7) {\n seven.add(i);\n if (i + 2 > 300000) {\n break;\n }\n seven.add(i + 2);\n }\n boolean[] sevenPrime = new boolean[300001];\n for (long num : seven) {\n if (!isPrime(num)) {\n continue;\n }\n sevenPrime[(int) num] = true;\n }\n while (true) {\n long n = sc.nextLong();\n if (n == 1) {\n return;\n }\n List ans = new ArrayList<>();\n for (int i = 2; i <= n; i++) {\n if (!sevenPrime[i]) {\n continue;\n }\n if (n % i == 0) {\n ans.add(i);\n }\n }\n System.out.print(n + \":\");\n for (long a : ans) {\n System.out.printf(\" %d\", a);\n }\n System.out.println();\n }\n }\n\n public static boolean isSeven(long x) {\n if (x % 7 == 1 || x % 7 == 6) {\n return true;\n }\n return false;\n }\n\n public static boolean isPrime(long x) {\n if (x == 1) {\n return false;\n }\n for (long i = 2; i * i <= x; i++) {\n if (x % i == 0 && isSeven(i)) {\n return false;\n }\n }\n return true;\n }\n}\n\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte())\n return buffer[ptr++];\n else\n return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr]))\n ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext())\n throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext())\n throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)\n throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n}\n\n", "language": "Java", "metadata": {"date": 1562221869, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00735.html", "problem_id": "p00735", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00735/input.txt", "sample_output_relpath": "derived/input_output/data/p00735/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00735/Java/s449638271.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s449638271", "user_id": "u378244901"}, "prompt_components": {"gold_output": "205920: 6 8 13 15 20 22 55 99\n262144: 8\n262200: 6 8 15 20 50 57 69 76 92 190 230 475 575 874 2185\n279936: 6 8 27\n299998: 299998\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\n\npublic class Main {\n public static void main(String[] args) {\n FastScanner sc = new FastScanner();\n List seven = new ArrayList<>();\n for (long i = 6; i <= 300000; i += 7) {\n seven.add(i);\n if (i + 2 > 300000) {\n break;\n }\n seven.add(i + 2);\n }\n boolean[] sevenPrime = new boolean[300001];\n for (long num : seven) {\n if (!isPrime(num)) {\n continue;\n }\n sevenPrime[(int) num] = true;\n }\n while (true) {\n long n = sc.nextLong();\n if (n == 1) {\n return;\n }\n List ans = new ArrayList<>();\n for (int i = 2; i <= n; i++) {\n if (!sevenPrime[i]) {\n continue;\n }\n if (n % i == 0) {\n ans.add(i);\n }\n }\n System.out.print(n + \":\");\n for (long a : ans) {\n System.out.printf(\" %d\", a);\n }\n System.out.println();\n }\n }\n\n public static boolean isSeven(long x) {\n if (x % 7 == 1 || x % 7 == 6) {\n return true;\n }\n return false;\n }\n\n public static boolean isPrime(long x) {\n if (x == 1) {\n return false;\n }\n for (long i = 2; i * i <= x; i++) {\n if (x % i == 0 && isSeven(i)) {\n return false;\n }\n }\n return true;\n }\n}\n\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte())\n return buffer[ptr++];\n else\n return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr]))\n ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext())\n throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext())\n throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)\n throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n}\n\n", "problem_context": "Problem B: Monday-Saturday Prime Factors\n\nChief Judge's log, stardate 48642.5.\nWe have decided to make a problem from elementary number theory.\nThe problem looks like finding all prime factors of a positive integer,\nbut it is not.\n\nA positive integer whose remainder divided by 7 is either 1 or 6 is called\na 7N+{1,6} number.\nBut as it is hard to pronounce,\nwe shall call it a Monday-Saturday number.\n\nFor Monday-Saturday numbers a and b,\nwe say a is a Monday-Saturday divisor of b\nif there exists a Monday-Saturday number x\nsuch that ax = b.\nIt is easy to show that\nfor any Monday-Saturday numbers a and b,\nit holds that a is\na Monday-Saturday divisor of b\nif and only if\na is a divisor of b in the usual sense.\n\nWe call a Monday-Saturday number a Monday-Saturday prime\nif it is greater than 1 and has no Monday-Saturday divisors\nother than itself and 1.\nA Monday-Saturday number which is a prime in the usual sense\nis a Monday-Saturday prime\nbut the converse does not always hold.\nFor example, 27 is a Monday-Saturday prime\nalthough it is not a prime in the usual sense.\nWe call a Monday-Saturday prime\nwhich is a Monday-Saturday divisor of a Monday-Saturday number a\na Monday-Saturday prime factor of a.\nFor example, 27 is one of the Monday-Saturday prime factors of 216,\nsince 27 is a Monday-Saturday prime\nand 216 = 27 × 8 holds.\n\nAny Monday-Saturday number greater than 1\ncan be expressed as a product of one or more Monday-Saturday primes.\nThe expression is not always unique\neven if differences in order are ignored.\nFor example,\n\n216 = 6 × 6 × 6 = 8 × 27\n\nholds.\n\nOur contestants should write a program that outputs\nall Monday-Saturday prime factors\nof each input Monday-Saturday number.\n\nInput\n\nThe input is a sequence of lines each of which contains a single\nMonday-Saturday number.\nEach Monday-Saturday number is greater than 1\nand less than 300000 (three hundred thousand).\nThe end of the input is indicated by a line\ncontaining a single digit 1.\n\nOutput\n\nFor each input Monday-Saturday number,\nit should be printed, followed by a colon `:'\nand the list of its Monday-Saturday prime factors on a single line.\nMonday-Saturday prime factors should be listed in ascending order\nand each should be preceded by a space.\nAll the Monday-Saturday prime factors should be printed only once\neven if they divide the input Monday-Saturday number more than once.\n\nSample Input\n\n205920\n262144\n262200\n279936\n299998\n1\n\nOutput for the Sample Input\n\n205920: 6 8 13 15 20 22 55 99\n262144: 8\n262200: 6 8 15 20 50 57 69 76 92 190 230 475 575 874 2185\n279936: 6 8 27\n299998: 299998", "sample_input": "205920\n262144\n262200\n279936\n299998\n1\n"}, "reference_outputs": ["205920: 6 8 13 15 20 22 55 99\n262144: 8\n262200: 6 8 15 20 50 57 69 76 92 190 230 475 575 874 2185\n279936: 6 8 27\n299998: 299998\n"], "source_document_id": "p00735", "source_text": "Problem B: Monday-Saturday Prime Factors\n\nChief Judge's log, stardate 48642.5.\nWe have decided to make a problem from elementary number theory.\nThe problem looks like finding all prime factors of a positive integer,\nbut it is not.\n\nA positive integer whose remainder divided by 7 is either 1 or 6 is called\na 7N+{1,6} number.\nBut as it is hard to pronounce,\nwe shall call it a Monday-Saturday number.\n\nFor Monday-Saturday numbers a and b,\nwe say a is a Monday-Saturday divisor of b\nif there exists a Monday-Saturday number x\nsuch that ax = b.\nIt is easy to show that\nfor any Monday-Saturday numbers a and b,\nit holds that a is\na Monday-Saturday divisor of b\nif and only if\na is a divisor of b in the usual sense.\n\nWe call a Monday-Saturday number a Monday-Saturday prime\nif it is greater than 1 and has no Monday-Saturday divisors\nother than itself and 1.\nA Monday-Saturday number which is a prime in the usual sense\nis a Monday-Saturday prime\nbut the converse does not always hold.\nFor example, 27 is a Monday-Saturday prime\nalthough it is not a prime in the usual sense.\nWe call a Monday-Saturday prime\nwhich is a Monday-Saturday divisor of a Monday-Saturday number a\na Monday-Saturday prime factor of a.\nFor example, 27 is one of the Monday-Saturday prime factors of 216,\nsince 27 is a Monday-Saturday prime\nand 216 = 27 × 8 holds.\n\nAny Monday-Saturday number greater than 1\ncan be expressed as a product of one or more Monday-Saturday primes.\nThe expression is not always unique\neven if differences in order are ignored.\nFor example,\n\n216 = 6 × 6 × 6 = 8 × 27\n\nholds.\n\nOur contestants should write a program that outputs\nall Monday-Saturday prime factors\nof each input Monday-Saturday number.\n\nInput\n\nThe input is a sequence of lines each of which contains a single\nMonday-Saturday number.\nEach Monday-Saturday number is greater than 1\nand less than 300000 (three hundred thousand).\nThe end of the input is indicated by a line\ncontaining a single digit 1.\n\nOutput\n\nFor each input Monday-Saturday number,\nit should be printed, followed by a colon `:'\nand the list of its Monday-Saturday prime factors on a single line.\nMonday-Saturday prime factors should be listed in ascending order\nand each should be preceded by a space.\nAll the Monday-Saturday prime factors should be printed only once\neven if they divide the input Monday-Saturday number more than once.\n\nSample Input\n\n205920\n262144\n262200\n279936\n299998\n1\n\nOutput for the Sample Input\n\n205920: 6 8 13 15 20 22 55 99\n262144: 8\n262200: 6 8 15 20 50 57 69 76 92 190 230 475 575 874 2185\n279936: 6 8 27\n299998: 299998", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3840, "cpu_time_ms": 1040, "memory_kb": 36360}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s578886796", "group_id": "codeNet:p00743", "input_text": "import java.awt.Point;\nimport java.util.LinkedList;\nimport java.util.Scanner;\n \npublic class Main {\n \n\tstatic int N, M;\n\tstatic int S, G;\n\tstatic int[][] D, C;\n\t\n static void start()\n {\n \tdouble[][][] times = new double[N+1][N+1][31];\n \tboolean[][][] check = new boolean[N+1][N+1][31];\n \t\n \tfor (int n = 0; n < N+1; n++) {\n\t\t\tfor (int pren = 0; pren < N+1; pren++) {\n\t\t\t\tfor (int c = 0; c < 31; c++) {\n\t\t\t\t\ttimes[n][pren][c] = Double.MAX_VALUE;\n\t\t\t\t\tcheck[n][pren][c] = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n \t\n \ttimes[S][0][1] = 0;\n \t\n \twhile(true)\n \t{\n \t\tint now_n = 0, now_pren = 0, now_c = 0;\n \t\t\n \t\t// スタート位置の決定\n \t\tdouble min = Double.MAX_VALUE;\n \t\tfor (int n = 1; n < N+1; n++) {\n \t\t\tfor (int pren = 0; pren < N+1; pren++) {\n \t\t\t\tfor (int c = 1; c < 31; c++) {\n \t\t\t\t\tif(check[n][pren][c] == true) continue;\n \t\t\t\t\tif(times[n][pren][c] < min)\n \t\t\t\t\t{\n \t\t\t\t\t\tmin = times[n][pren][c];\n \t\t\t\t\t\tnow_n = n;\n \t\t\t\t\t\tnow_pren = pren;\n \t\t\t\t\t\tnow_c = c;\n \t\t\t\t\t}\n \t\t\t\t}\n \t\t\t}\n \t\t}\n \t\tif(min == Double.MAX_VALUE)\n \t\t{\n \t\t\tSystem.out.println(\"unreachable\");\n \t\t\treturn;\n \t\t}\n \t\tif(now_n == G && now_c == 1)\n \t\t{\n \t\t\tSystem.out.printf(\"%.05f\\n\", min);\n \t\t}\n \t\t\n \t\t// 処理\n \t\tcheck[now_n][now_pren][now_c] = true;\n \t\t\n \t\tfor (int n = 1; n <= N; n++) {\n \t\t\tif(now_n == n) continue;\n\t\t\t\tif(now_pren == n) continue;\n\t\t\t\tif(D[now_n][n] < 0) continue;\n\t\t\t\t\n\t\t\t\t// 速度-1\n\t\t\t\tif(1 < now_c)\n\t\t\t\t{\n\t\t\t\t\tif((now_c-1) <= C[now_n][n])\n\t\t\t\t\t{\n\t\t\t\t\t\tdouble ntime = times[now_n][now_pren][now_c] + (double)D[now_n][n] / (double)(now_c-1);\n\t\t\t\t\t\ttimes[n][now_n][now_c-1] = Math.min(times[n][now_n][now_c-1], ntime);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// 速度そのまま\n\t\t\t\tif(true)\n\t\t\t\t{\n\t\t\t\t\tif(now_c <= C[now_n][n])\n\t\t\t\t\t{\n\t\t\t\t\t\tdouble ntime = times[now_n][now_pren][now_c] + (double)D[now_n][n] / (double)now_c;\n\t\t\t\t\t\ttimes[n][now_n][now_c] = Math.min(times[n][now_n][now_c], ntime);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif(now_n == S && now_c == 1) continue;\n\t\t\t\t\n\t\t\t\t// 速度+1\n\t\t\t\tif(now_c < 30)\n\t\t\t\t{\n\t\t\t\t\tif((now_c+1) <= C[now_n][n])\n\t\t\t\t\t{\n\t\t\t\t\t\tdouble ntime = times[now_n][now_pren][now_c] + (double)D[now_n][n] / (double)(now_c+1);\n\t\t\t\t\t\ttimes[n][now_n][now_c+1] = Math.min(times[n][now_n][now_c+1], ntime);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n \t}\n }\n \n public static void main(String[] args)\n {\n Scanner sca = new Scanner(System.in);\n \n while(true)\n {\n \tN = sca.nextInt();\n \tM = sca.nextInt();\n \tif(N == 0) break;\n \t\n \tS = sca.nextInt();\n \tG = sca.nextInt();\n \t\n \tD = new int[N+1][N+1];\n \tC = new int[N+1][N+1];\n \tfor (int i = 0; i <= N; i++) {\n\t\t\t\tfor (int j = 0; j <= N; j++) {\n\t\t\t\t\tD[i][j] = C[i][j] = -1;\n\t\t\t\t}\n\t\t\t}\n \t\n \tfor (int i = 0; i < M; i++) {\n\t\t\t\tint x = sca.nextInt();\n\t\t\t\tint y = sca.nextInt();\n\t\t\t\tint d = sca.nextInt();\n\t\t\t\tint c = sca.nextInt();\n\t\t\t\t\n\t\t\t\tD[y][x] = D[x][y] = d;\n\t\t\t\tC[y][x] = C[x][y] = c;\n\t\t\t}\n \n start();\n }\n \n }\n}", "language": "Java", "metadata": {"date": 1434966001, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00743.html", "problem_id": "p00743", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00743/input.txt", "sample_output_relpath": "derived/input_output/data/p00743/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00743/Java/s578886796.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s578886796", "user_id": "u063046693"}, "prompt_components": {"gold_output": "unreachable\n4.00000\n5.50000\n11.25664\n", "input_to_evaluate": "import java.awt.Point;\nimport java.util.LinkedList;\nimport java.util.Scanner;\n \npublic class Main {\n \n\tstatic int N, M;\n\tstatic int S, G;\n\tstatic int[][] D, C;\n\t\n static void start()\n {\n \tdouble[][][] times = new double[N+1][N+1][31];\n \tboolean[][][] check = new boolean[N+1][N+1][31];\n \t\n \tfor (int n = 0; n < N+1; n++) {\n\t\t\tfor (int pren = 0; pren < N+1; pren++) {\n\t\t\t\tfor (int c = 0; c < 31; c++) {\n\t\t\t\t\ttimes[n][pren][c] = Double.MAX_VALUE;\n\t\t\t\t\tcheck[n][pren][c] = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n \t\n \ttimes[S][0][1] = 0;\n \t\n \twhile(true)\n \t{\n \t\tint now_n = 0, now_pren = 0, now_c = 0;\n \t\t\n \t\t// スタート位置の決定\n \t\tdouble min = Double.MAX_VALUE;\n \t\tfor (int n = 1; n < N+1; n++) {\n \t\t\tfor (int pren = 0; pren < N+1; pren++) {\n \t\t\t\tfor (int c = 1; c < 31; c++) {\n \t\t\t\t\tif(check[n][pren][c] == true) continue;\n \t\t\t\t\tif(times[n][pren][c] < min)\n \t\t\t\t\t{\n \t\t\t\t\t\tmin = times[n][pren][c];\n \t\t\t\t\t\tnow_n = n;\n \t\t\t\t\t\tnow_pren = pren;\n \t\t\t\t\t\tnow_c = c;\n \t\t\t\t\t}\n \t\t\t\t}\n \t\t\t}\n \t\t}\n \t\tif(min == Double.MAX_VALUE)\n \t\t{\n \t\t\tSystem.out.println(\"unreachable\");\n \t\t\treturn;\n \t\t}\n \t\tif(now_n == G && now_c == 1)\n \t\t{\n \t\t\tSystem.out.printf(\"%.05f\\n\", min);\n \t\t}\n \t\t\n \t\t// 処理\n \t\tcheck[now_n][now_pren][now_c] = true;\n \t\t\n \t\tfor (int n = 1; n <= N; n++) {\n \t\t\tif(now_n == n) continue;\n\t\t\t\tif(now_pren == n) continue;\n\t\t\t\tif(D[now_n][n] < 0) continue;\n\t\t\t\t\n\t\t\t\t// 速度-1\n\t\t\t\tif(1 < now_c)\n\t\t\t\t{\n\t\t\t\t\tif((now_c-1) <= C[now_n][n])\n\t\t\t\t\t{\n\t\t\t\t\t\tdouble ntime = times[now_n][now_pren][now_c] + (double)D[now_n][n] / (double)(now_c-1);\n\t\t\t\t\t\ttimes[n][now_n][now_c-1] = Math.min(times[n][now_n][now_c-1], ntime);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// 速度そのまま\n\t\t\t\tif(true)\n\t\t\t\t{\n\t\t\t\t\tif(now_c <= C[now_n][n])\n\t\t\t\t\t{\n\t\t\t\t\t\tdouble ntime = times[now_n][now_pren][now_c] + (double)D[now_n][n] / (double)now_c;\n\t\t\t\t\t\ttimes[n][now_n][now_c] = Math.min(times[n][now_n][now_c], ntime);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif(now_n == S && now_c == 1) continue;\n\t\t\t\t\n\t\t\t\t// 速度+1\n\t\t\t\tif(now_c < 30)\n\t\t\t\t{\n\t\t\t\t\tif((now_c+1) <= C[now_n][n])\n\t\t\t\t\t{\n\t\t\t\t\t\tdouble ntime = times[now_n][now_pren][now_c] + (double)D[now_n][n] / (double)(now_c+1);\n\t\t\t\t\t\ttimes[n][now_n][now_c+1] = Math.min(times[n][now_n][now_c+1], ntime);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n \t}\n }\n \n public static void main(String[] args)\n {\n Scanner sca = new Scanner(System.in);\n \n while(true)\n {\n \tN = sca.nextInt();\n \tM = sca.nextInt();\n \tif(N == 0) break;\n \t\n \tS = sca.nextInt();\n \tG = sca.nextInt();\n \t\n \tD = new int[N+1][N+1];\n \tC = new int[N+1][N+1];\n \tfor (int i = 0; i <= N; i++) {\n\t\t\t\tfor (int j = 0; j <= N; j++) {\n\t\t\t\t\tD[i][j] = C[i][j] = -1;\n\t\t\t\t}\n\t\t\t}\n \t\n \tfor (int i = 0; i < M; i++) {\n\t\t\t\tint x = sca.nextInt();\n\t\t\t\tint y = sca.nextInt();\n\t\t\t\tint d = sca.nextInt();\n\t\t\t\tint c = sca.nextInt();\n\t\t\t\t\n\t\t\t\tD[y][x] = D[x][y] = d;\n\t\t\t\tC[y][x] = C[x][y] = c;\n\t\t\t}\n \n start();\n }\n \n }\n}", "problem_context": "Problem D: Discrete Speed\n\nConsider car trips in a country where there is no friction.\nCars in this country do not have engines.\nOnce a car started to move at a speed, it keeps moving at the same speed.\nThere are acceleration devices on some points on the road,\nwhere a car can increase or decrease its speed by 1.\nIt can also keep its speed there.\nYour job in this problem is to write a program\nwhich determines the route with the shortest time\nto travel from a starting city to a goal city.\n\nThere are several cities in the country,\nand a road network connecting them.\nEach city has an acceleration device.\nAs mentioned above, if a car arrives at a city at a speed v ,\nit leaves the city at one of v - 1, v , or v + 1.\nThe first road leaving the starting city must be run at the speed 1.\nSimilarly, the last road arriving at the goal city must be run at the speed 1.\n\nThe starting city and the goal city are given.\nThe problem is to find the best route which leads to the goal city\ngoing through several cities on the road network.\nWhen the car arrives at a city, it cannot immediately go back the road\nit used to reach the city. No U-turns are allowed.\nExcept this constraint, one can choose any route on the road network.\nIt is allowed to visit the same city or use the same road multiple times.\nThe starting city and the goal city may be visited during the trip.\n\nFor each road on the network, its distance and speed limit are given.\nA car must run a road at a speed less than or equal to its speed limit.\nThe time needed to run a road is the distance divided by the speed.\nThe time needed within cities including that for acceleration or deceleration should be ignored.\n\nInput\n\nThe input consists of multiple datasets, each in the following format.\n\nn m\n\ns g\n\nx 1 y 1 d 1 c 1\n\n...\n\nxm ym dm cm\n\nEvery input item in a dataset is a non-negative integer.\nInput items in the same line are separated by a space.\n\nThe first line gives the size of the road network.\nn is the number of cities in the network.\nYou can assume that the number of cities is between 2 and 30, inclusive.\nm is the number of roads between cities, which may be zero.\n\nThe second line gives the trip.\ns is the city index of the starting city.\ng is the city index of the goal city.\ns is not equal to g .\nYou can assume that all city indices in a dataset (including the above two)\nare between 1 and n , inclusive.\n\nThe following m lines give the details of roads between cities.\nThe i -th road connects two cities with city indices\nxi and yi ,\nand has a distance di (1 ≤ i ≤ m ).\nYou can assume that the distance is between 1 and 100, inclusive.\nThe speed limit of the road is specified by ci .\nYou can assume that the speed limit is between 1 and 30, inclusive.\n\nNo two roads connect the same pair of cities.\nA road never connects a city with itself.\nEach road can be traveled in both directions.\n\nThe last dataset is followed by a line containing two zeros\n(separated by a space).\n\nOutput\n\nFor each dataset in the input, one line should be output as specified below.\nAn output line should not contain extra characters such as spaces.\n\nIf one can travel from the starting city to the goal city,\nthe time needed for the best route (a route with the shortest time)\nshould be printed.\nThe answer should not have an error greater than 0.001.\nYou may output any number of digits after the decimal point,\nprovided that the above accuracy condition is satisfied.\n\nIf it is impossible to reach the goal city,\nthe string \"unreachable\" should be printed.\nNote that all the letters of \"unreachable\" are in lowercase.\n\nSample Input\n\n2 0\n1 2\n5 4\n1 5\n1 2 1 1\n2 3 2 2\n3 4 2 2\n4 5 1 1\n6 6\n1 6\n1 2 2 1\n2 3 2 1\n3 6 2 1\n1 4 2 30\n4 5 3 30\n5 6 2 30\n6 7\n1 6\n1 2 1 30\n2 3 1 30\n3 1 1 30\n3 4 100 30\n4 5 1 30\n5 6 1 30\n6 4 1 30\n0 0\n\nOutput for the Sample Input\n\nunreachable\n4.00000\n5.50000\n11.25664", "sample_input": "2 0\n1 2\n5 4\n1 5\n1 2 1 1\n2 3 2 2\n3 4 2 2\n4 5 1 1\n6 6\n1 6\n1 2 2 1\n2 3 2 1\n3 6 2 1\n1 4 2 30\n4 5 3 30\n5 6 2 30\n6 7\n1 6\n1 2 1 30\n2 3 1 30\n3 1 1 30\n3 4 100 30\n4 5 1 30\n5 6 1 30\n6 4 1 30\n0 0\n"}, "reference_outputs": ["unreachable\n4.00000\n5.50000\n11.25664\n"], "source_document_id": "p00743", "source_text": "Problem D: Discrete Speed\n\nConsider car trips in a country where there is no friction.\nCars in this country do not have engines.\nOnce a car started to move at a speed, it keeps moving at the same speed.\nThere are acceleration devices on some points on the road,\nwhere a car can increase or decrease its speed by 1.\nIt can also keep its speed there.\nYour job in this problem is to write a program\nwhich determines the route with the shortest time\nto travel from a starting city to a goal city.\n\nThere are several cities in the country,\nand a road network connecting them.\nEach city has an acceleration device.\nAs mentioned above, if a car arrives at a city at a speed v ,\nit leaves the city at one of v - 1, v , or v + 1.\nThe first road leaving the starting city must be run at the speed 1.\nSimilarly, the last road arriving at the goal city must be run at the speed 1.\n\nThe starting city and the goal city are given.\nThe problem is to find the best route which leads to the goal city\ngoing through several cities on the road network.\nWhen the car arrives at a city, it cannot immediately go back the road\nit used to reach the city. No U-turns are allowed.\nExcept this constraint, one can choose any route on the road network.\nIt is allowed to visit the same city or use the same road multiple times.\nThe starting city and the goal city may be visited during the trip.\n\nFor each road on the network, its distance and speed limit are given.\nA car must run a road at a speed less than or equal to its speed limit.\nThe time needed to run a road is the distance divided by the speed.\nThe time needed within cities including that for acceleration or deceleration should be ignored.\n\nInput\n\nThe input consists of multiple datasets, each in the following format.\n\nn m\n\ns g\n\nx 1 y 1 d 1 c 1\n\n...\n\nxm ym dm cm\n\nEvery input item in a dataset is a non-negative integer.\nInput items in the same line are separated by a space.\n\nThe first line gives the size of the road network.\nn is the number of cities in the network.\nYou can assume that the number of cities is between 2 and 30, inclusive.\nm is the number of roads between cities, which may be zero.\n\nThe second line gives the trip.\ns is the city index of the starting city.\ng is the city index of the goal city.\ns is not equal to g .\nYou can assume that all city indices in a dataset (including the above two)\nare between 1 and n , inclusive.\n\nThe following m lines give the details of roads between cities.\nThe i -th road connects two cities with city indices\nxi and yi ,\nand has a distance di (1 ≤ i ≤ m ).\nYou can assume that the distance is between 1 and 100, inclusive.\nThe speed limit of the road is specified by ci .\nYou can assume that the speed limit is between 1 and 30, inclusive.\n\nNo two roads connect the same pair of cities.\nA road never connects a city with itself.\nEach road can be traveled in both directions.\n\nThe last dataset is followed by a line containing two zeros\n(separated by a space).\n\nOutput\n\nFor each dataset in the input, one line should be output as specified below.\nAn output line should not contain extra characters such as spaces.\n\nIf one can travel from the starting city to the goal city,\nthe time needed for the best route (a route with the shortest time)\nshould be printed.\nThe answer should not have an error greater than 0.001.\nYou may output any number of digits after the decimal point,\nprovided that the above accuracy condition is satisfied.\n\nIf it is impossible to reach the goal city,\nthe string \"unreachable\" should be printed.\nNote that all the letters of \"unreachable\" are in lowercase.\n\nSample Input\n\n2 0\n1 2\n5 4\n1 5\n1 2 1 1\n2 3 2 2\n3 4 2 2\n4 5 1 1\n6 6\n1 6\n1 2 2 1\n2 3 2 1\n3 6 2 1\n1 4 2 30\n4 5 3 30\n5 6 2 30\n6 7\n1 6\n1 2 1 30\n2 3 1 30\n3 1 1 30\n3 4 100 30\n4 5 1 30\n5 6 1 30\n6 4 1 30\n0 0\n\nOutput for the Sample Input\n\nunreachable\n4.00000\n5.50000\n11.25664", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3100, "cpu_time_ms": 5160, "memory_kb": 43836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s497482185", "group_id": "codeNet:p00748", "input_text": "import java.io.IOException;\nimport java.util.Arrays;\n\npublic class Main {\n\n\tprivate static final int INF = 1000001;\n\n\tpublic static void main(String[] args) {\n\t\tint[] pollock = new int[180];// 180*181*182/6が条件内で最大の正四面体数\n\t\tfor (int i = 1; i <= pollock.length; i++) {\n\t\t\tpollock[i - 1] = (i * (i + 1) * (i + 2)) / 6;\n\t\t}\n\n\t\tint[][] dp = new int[2][INF];// dp[奇数?][jを作るのに必要な正四面体数の数の最小値]\n\t\tArrays.fill(dp[0], Integer.MAX_VALUE);// 全部用\n\t\tArrays.fill(dp[1], Integer.MAX_VALUE);// 奇数用\n\n\t\t// 最初は0\n\t\tdp[0][0] = 0;\n\t\tdp[1][0] = 0;\n\n\t\tfor (int i = 0; i < pollock.length; i++) {\n\t\t\tfor (int j = pollock[i]; j < INF; j++) {\n\t\t\t\t// 各pollock数について、調べる\n\t\t\t\tdp[0][j] = Math.min(dp[0][j], dp[0][j - pollock[i]] + 1);\n\t\t\t\tif (pollock[i] % 2 == 1) {\n\t\t\t\t\t// pollock数が奇数の時\n\t\t\t\t\tdp[1][j] = Math.min(dp[1][j], dp[1][j - pollock[i]] + 1);\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\twhile (true) {\n\t\t\tint N = nextInt();\n\t\t\tif (N == 0) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tSystem.out.println(dp[0][N] + \" \" + dp[1][N]);\n\n\t\t}\n\t}\n\n\tstatic int nextInt() {\n\t\tint c;\n\t\ttry {\n\t\t\tc = System.in.read();\n\t\t\twhile (c != '-' && (c < '0' || c > '9'))\n\t\t\t\tc = System.in.read();\n\t\t\tif (c == '-')\n\t\t\t\treturn -nextInt();\n\t\t\tint res = 0;\n\t\t\twhile (c >= '0' && c <= '9') {\n\t\t\t\tres = res * 10 + c - '0';\n\t\t\t\tc = System.in.read();\n\t\t\t}\n\t\t\treturn res;\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn -1;\n\t}\n\n\tstatic char nextChar() {\n\t\ttry {\n\t\t\tint b = System.in.read();\n\t\t\twhile (b != -1 && (b == ' ' || b == '\\r' || b == '\\n'))\n\t\t\t\t;\n\t\t\tif (b == -1)\n\t\t\t\treturn 0;\n\t\t\treturn (char) b;\n\t\t} catch (IOException e) {\n\t\t}\n\t\treturn 0;\n\t}\n\n}", "language": "Java", "metadata": {"date": 1422017385, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00748.html", "problem_id": "p00748", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00748/input.txt", "sample_output_relpath": "derived/input_output/data/p00748/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00748/Java/s497482185.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s497482185", "user_id": "u568152427"}, "prompt_components": {"gold_output": "2 6\n2 14\n2 5\n1 1\n1 18\n5 35\n4 4\n3 37\n", "input_to_evaluate": "import java.io.IOException;\nimport java.util.Arrays;\n\npublic class Main {\n\n\tprivate static final int INF = 1000001;\n\n\tpublic static void main(String[] args) {\n\t\tint[] pollock = new int[180];// 180*181*182/6が条件内で最大の正四面体数\n\t\tfor (int i = 1; i <= pollock.length; i++) {\n\t\t\tpollock[i - 1] = (i * (i + 1) * (i + 2)) / 6;\n\t\t}\n\n\t\tint[][] dp = new int[2][INF];// dp[奇数?][jを作るのに必要な正四面体数の数の最小値]\n\t\tArrays.fill(dp[0], Integer.MAX_VALUE);// 全部用\n\t\tArrays.fill(dp[1], Integer.MAX_VALUE);// 奇数用\n\n\t\t// 最初は0\n\t\tdp[0][0] = 0;\n\t\tdp[1][0] = 0;\n\n\t\tfor (int i = 0; i < pollock.length; i++) {\n\t\t\tfor (int j = pollock[i]; j < INF; j++) {\n\t\t\t\t// 各pollock数について、調べる\n\t\t\t\tdp[0][j] = Math.min(dp[0][j], dp[0][j - pollock[i]] + 1);\n\t\t\t\tif (pollock[i] % 2 == 1) {\n\t\t\t\t\t// pollock数が奇数の時\n\t\t\t\t\tdp[1][j] = Math.min(dp[1][j], dp[1][j - pollock[i]] + 1);\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\twhile (true) {\n\t\t\tint N = nextInt();\n\t\t\tif (N == 0) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tSystem.out.println(dp[0][N] + \" \" + dp[1][N]);\n\n\t\t}\n\t}\n\n\tstatic int nextInt() {\n\t\tint c;\n\t\ttry {\n\t\t\tc = System.in.read();\n\t\t\twhile (c != '-' && (c < '0' || c > '9'))\n\t\t\t\tc = System.in.read();\n\t\t\tif (c == '-')\n\t\t\t\treturn -nextInt();\n\t\t\tint res = 0;\n\t\t\twhile (c >= '0' && c <= '9') {\n\t\t\t\tres = res * 10 + c - '0';\n\t\t\t\tc = System.in.read();\n\t\t\t}\n\t\t\treturn res;\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn -1;\n\t}\n\n\tstatic char nextChar() {\n\t\ttry {\n\t\t\tint b = System.in.read();\n\t\t\twhile (b != -1 && (b == ' ' || b == '\\r' || b == '\\n'))\n\t\t\t\t;\n\t\t\tif (b == -1)\n\t\t\t\treturn 0;\n\t\t\treturn (char) b;\n\t\t} catch (IOException e) {\n\t\t}\n\t\treturn 0;\n\t}\n\n}", "problem_context": "Problem C: Pollock's conjecture\n\nThe nth triangular number is\ndefined as\nthe sum of the first n positive integers.\nThe nth tetrahedral number is\ndefined as\nthe sum of the first n triangular numbers.\nIt is easy to show that\nthe nth tetrahedral number is equal to\nn(n+1)(n+2) ⁄ 6.\nFor example,\nthe 5th tetrahedral number is\n1+(1+2)+(1+2+3)+(1+2+3+4)+(1+2+3+4+5)\n= 5×6×7 ⁄ 6\n= 35.\n\nThe first 5 triangular numbers\n\n1, 3, 6, 10, 15\n\nThe first 5 tetrahedral numbers\n\n1, 4, 10, 20, 35\n\nIn 1850,\nSir Frederick Pollock, 1st Baronet,\nwho was not a professional mathematician\nbut a British lawyer and Tory (currently known as Conservative) politician,\nconjectured\nthat every positive integer can be represented\nas the sum of at most five tetrahedral numbers.\nHere,\na tetrahedral number may occur in the sum more than once\nand,\nin such a case, each occurrence is counted separately.\nThe conjecture has been open for more than one and a half century.\n\nYour mission is to write a program\nto verify Pollock's conjecture for individual integers.\nYour program should make a calculation of\nthe least number of tetrahedral numbers\nto represent each input integer as their sum.\nIn addition,\nfor some unknown reason,\nyour program should make a similar calculation\nwith only odd tetrahedral numbers available.\n\nFor example,\none can represent 40 as the sum of 2 tetrahedral numbers,\n4×5×6 ⁄ 6 + 4×5×6 ⁄ 6,\nbut 40 itself is not a tetrahedral number.\nOne can represent 40 as the sum of 6 odd tetrahedral numbers,\n5×6×7 ⁄ 6 + 1×2×3 ⁄ 6 + 1×2×3 ⁄ 6 + 1×2×3 ⁄ 6 + 1×2×3 ⁄ 6 + 1×2×3 ⁄ 6,\nbut cannot represent as the sum of fewer odd tetrahedral numbers.\nThus, your program should report 2 and 6 if 40 is given.\n\nInput\n\nThe input is a sequence of lines each of which contains a single positive integer less than 106.\nThe end of the input is indicated by a line containing a single zero.\n\nOutput\n\nFor each input positive integer,\noutput a line containing two integers separated by a space.\nThe first integer should be\nthe least number of tetrahedral numbers\nto represent the input integer as their sum.\nThe second integer should be\nthe least number of odd tetrahedral numbers\nto represent the input integer as their sum.\nNo extra characters should appear in the output.\n\nSample Input\n\n40\n14\n5\n165\n120\n103\n106\n139\n0\n\nOutput for the Sample Input\n\n2 6\n2 14\n2 5\n1 1\n1 18\n5 35\n4 4\n3 37", "sample_input": "40\n14\n5\n165\n120\n103\n106\n139\n0\n"}, "reference_outputs": ["2 6\n2 14\n2 5\n1 1\n1 18\n5 35\n4 4\n3 37\n"], "source_document_id": "p00748", "source_text": "Problem C: Pollock's conjecture\n\nThe nth triangular number is\ndefined as\nthe sum of the first n positive integers.\nThe nth tetrahedral number is\ndefined as\nthe sum of the first n triangular numbers.\nIt is easy to show that\nthe nth tetrahedral number is equal to\nn(n+1)(n+2) ⁄ 6.\nFor example,\nthe 5th tetrahedral number is\n1+(1+2)+(1+2+3)+(1+2+3+4)+(1+2+3+4+5)\n= 5×6×7 ⁄ 6\n= 35.\n\nThe first 5 triangular numbers\n\n1, 3, 6, 10, 15\n\nThe first 5 tetrahedral numbers\n\n1, 4, 10, 20, 35\n\nIn 1850,\nSir Frederick Pollock, 1st Baronet,\nwho was not a professional mathematician\nbut a British lawyer and Tory (currently known as Conservative) politician,\nconjectured\nthat every positive integer can be represented\nas the sum of at most five tetrahedral numbers.\nHere,\na tetrahedral number may occur in the sum more than once\nand,\nin such a case, each occurrence is counted separately.\nThe conjecture has been open for more than one and a half century.\n\nYour mission is to write a program\nto verify Pollock's conjecture for individual integers.\nYour program should make a calculation of\nthe least number of tetrahedral numbers\nto represent each input integer as their sum.\nIn addition,\nfor some unknown reason,\nyour program should make a similar calculation\nwith only odd tetrahedral numbers available.\n\nFor example,\none can represent 40 as the sum of 2 tetrahedral numbers,\n4×5×6 ⁄ 6 + 4×5×6 ⁄ 6,\nbut 40 itself is not a tetrahedral number.\nOne can represent 40 as the sum of 6 odd tetrahedral numbers,\n5×6×7 ⁄ 6 + 1×2×3 ⁄ 6 + 1×2×3 ⁄ 6 + 1×2×3 ⁄ 6 + 1×2×3 ⁄ 6 + 1×2×3 ⁄ 6,\nbut cannot represent as the sum of fewer odd tetrahedral numbers.\nThus, your program should report 2 and 6 if 40 is given.\n\nInput\n\nThe input is a sequence of lines each of which contains a single positive integer less than 106.\nThe end of the input is indicated by a line containing a single zero.\n\nOutput\n\nFor each input positive integer,\noutput a line containing two integers separated by a space.\nThe first integer should be\nthe least number of tetrahedral numbers\nto represent the input integer as their sum.\nThe second integer should be\nthe least number of odd tetrahedral numbers\nto represent the input integer as their sum.\nNo extra characters should appear in the output.\n\nSample Input\n\n40\n14\n5\n165\n120\n103\n106\n139\n0\n\nOutput for the Sample Input\n\n2 6\n2 14\n2 5\n1 1\n1 18\n5 35\n4 4\n3 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": 1685, "cpu_time_ms": 400, "memory_kb": 28024}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s640561466", "group_id": "codeNet:p00762", "input_text": "import java.util.*;\npublic class Main\n{\n\tstatic int dx[]={1,0,-1,0};\n\tstatic int dy[]={0,1,0,-1};\n\tstatic int field[][];\n\tstatic int dice[][];\n\tpublic static void main(String[] args) \n\t{\n\t\tScanner in=new Scanner(System.in);\n\n\t\tfor(;;)\n\t\t{\n\t\t\tint n=in.nextInt();\n\t\t\tif(n==0)\n\t\t\t\treturn;\n\t\t\tfield=new int[31][31];//高低差を管理\n\t\t\tdice=new int[31][31];//フィールドのダイスの状態\n\t\t\tfor(int i=0;ifield[x+dx[i]][y+dy[i]])\n\t\t\t\tpossible[i]=true;\n\t\t}\n\t\tif(t==1)\n\t\t{\n\t\t\tif(f==2)\n\t\t\t{\n\t\t\t\tif(possible[2])\n\t\t\t\t\tdrop(x-1,y,2,6);\n\t\t\t\telse if(possible[3])\n\t\t\t\t\tdrop(x,y-1,3,2);\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==3)\n\t\t\t{\n\t\t\t\tif(possible[1])\n\t\t\t\t\tdrop(x,y+1,2,3);\n\t\t\t\telse if(possible[2])\n\t\t\t\t\tdrop(x-1,y,3,6);\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==5)\n\t\t\t{\n\t\t\t\tif(possible[0])\n\t\t\t\t\tdrop(x+1,y,2,1);\n\t\t\t\telse if(possible[1])\n\t\t\t\t\tdrop(x,y+1,3,5);\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==4)\n\t\t\t{\n\t\t\t\tif(possible[3])\n\t\t\t\t\tdrop(x,y-1,2,4);\n\t\t\t\telse if(possible[0])\n\t\t\t\t\tdrop(x+1,y,3,1);\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\telse if(t==2)\n\t\t{\n\t\t\tif(f==1)\n\t\t\t{\n\t\t\t\tif(possible[2])\n\t\t\t\t\tdrop(x-1,y,1,5);\n\t\t\t\telse if(possible[1])\n\t\t\t\t\tdrop(x,y+1,3,1);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==4)\n\t\t\t{\n\t\t\t\tif(possible[1])\n\t\t\t\t\tdrop(x,y+1,1,4);\n\t\t\t\telse if(possible[0])\n\t\t\t\t\tdrop(x+1,y,3,2);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==6)\n\t\t\t{\n\t\t\t\tif(possible[0])\n\t\t\t\t\tdrop(x+1,y,1,2);\n\t\t\t\telse if(possible[3])\n\t\t\t\t\tdrop(x,y-1,3,6);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==3)\n\t\t\t{\n\t\t\t\tif(possible[3])\n\t\t\t\t\tdrop(x,y-1,1,3);\n\t\t\t\telse if(possible[2])\n\t\t\t\t\tdrop(x-1,y,3,5);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if(t==3)\n\t\t{\n\t\t\tif(f==1)\n\t\t\t{\n\t\t\t\tif(possible[2])\n\t\t\t\t\tdrop(x-1,y,1,4);\n\t\t\t\telse if(possible[3])\n\t\t\t\t\tdrop(x,y-1,2,1);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==2)\n\t\t\t{\n\t\t\t\tif(possible[1])\n\t\t\t\t\tdrop(x,y+1,1,2);\n\t\t\t\telse if(possible[2])\n\t\t\t\t\tdrop(x-1,y,2,4);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==6)\n\t\t\t{\n\t\t\t\tif(possible[0])\n\t\t\t\t\tdrop(x+1,y,1,3);\n\t\t\t\telse if(possible[1])\n\t\t\t\t\tdrop(x,y+1,2,6);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==5)\n\t\t\t{\n\t\t\t\tif(possible[3])\n\t\t\t\t\tdrop(x,y-1,1,5);\n\t\t\t\telse if(possible[0])\n\t\t\t\t\tdrop(x+1,y,2,3);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if(t==4)\n\t\t{\n\t\t\tif(f==1)\n\t\t\t{\n\t\t\t\tif(possible[2])\n\t\t\t\t\tdrop(x-1,y,1,3);\n\t\t\t\telse if(possible[1])\n\t\t\t\t\tdrop(x,y+1,2,1);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==5)\n\t\t\t{\n\t\t\t\tif(possible[1])\n\t\t\t\t\tdrop(x,y+1,1,5);\n\t\t\t\telse if(possible[0])\n\t\t\t\t\tdrop(x+1,y,2,4);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==6)\n\t\t\t{\n\t\t\t\tif(possible[0])\n\t\t\t\t\tdrop(x+1,y,1,4);\n\t\t\t\telse if(possible[3])\n\t\t\t\t\tdrop(x,y-1,2,6);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==2)\n\t\t\t{\n\t\t\t\tif(possible[3])\n\t\t\t\t\tdrop(x,y-1,1,2);\n\t\t\t\telse if(possible[2])\n\t\t\t\t\tdrop(x-1,y,2,3);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if(t==5)\n\t\t{\n\t\t\tif(f==1)\n\t\t\t{\n\t\t\t\tif(possible[2])\n\t\t\t\t\tdrop(x-1,y,1,2);\n\t\t\t\telse if(possible[3])\n\t\t\t\t\tdrop(x,y-1,3,1);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==3)\n\t\t\t{\n\t\t\t\tif(possible[1])\n\t\t\t\t\tdrop(x,y+1,1,3);\n\t\t\t\telse if(possible[2])\n\t\t\t\t\tdrop(x-1,y,3,2);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==6)\n\t\t\t{\n\t\t\t\tif(possible[0])\n\t\t\t\t\tdrop(x+1,y,1,5);\n\t\t\t\telse if(possible[1])\n\t\t\t\t\tdrop(x,y+1,3,6);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==4)\n\t\t\t{\n\t\t\t\tif(possible[3])\n\t\t\t\t\tdrop(x,y-1,1,4);\n\t\t\t\telse if(possible[0])\n\t\t\t\t\tdrop(x+1,y,3,5);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if(t==6)\n\t\t{\n\t\t\tif(f==2)\n\t\t\t{\n\t\t\t\tif(possible[2])\n\t\t\t\t\tdrop(x-1,y,2,1);\n\t\t\t\telse if(possible[1])\n\t\t\t\t\tdrop(x,y+1,3,2);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==4)\n\t\t\t{\n\t\t\t\tif(possible[1])\n\t\t\t\t\tdrop(x,y+1,2,4);\n\t\t\t\telse if(possible[0])\n\t\t\t\t\tdrop(x+1,y,3,6);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==5)\n\t\t\t{\n\t\t\t\tif(possible[0])\n\t\t\t\t\tdrop(x+1,y,2,6);\n\t\t\t\telse if(possible[3])\n\t\t\t\t\tdrop(x,y-1,3,5);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==3)\n\t\t\t{\n\t\t\t\tif(possible[3])\n\t\t\t\t\tdrop(x,y-1,2,3);\n\t\t\t\telse if(possible[2])\n\t\t\t\t\tdrop(x-1,y,3,1);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic public void debug(Object... o)\n\t{\n\t\tSystem.out.println(Arrays.deepToString(o));\n\t}\n\n\tstatic public void debug2(int a[][])\n\t{\n\t\tfor(int i=0;ifield[x+dx[i]][y+dy[i]])\n\t\t\t\tpossible[i]=true;\n\t\t}\n\t\tif(t==1)\n\t\t{\n\t\t\tif(f==2)\n\t\t\t{\n\t\t\t\tif(possible[2])\n\t\t\t\t\tdrop(x-1,y,2,6);\n\t\t\t\telse if(possible[3])\n\t\t\t\t\tdrop(x,y-1,3,2);\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==3)\n\t\t\t{\n\t\t\t\tif(possible[1])\n\t\t\t\t\tdrop(x,y+1,2,3);\n\t\t\t\telse if(possible[2])\n\t\t\t\t\tdrop(x-1,y,3,6);\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==5)\n\t\t\t{\n\t\t\t\tif(possible[0])\n\t\t\t\t\tdrop(x+1,y,2,1);\n\t\t\t\telse if(possible[1])\n\t\t\t\t\tdrop(x,y+1,3,5);\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==4)\n\t\t\t{\n\t\t\t\tif(possible[3])\n\t\t\t\t\tdrop(x,y-1,2,4);\n\t\t\t\telse if(possible[0])\n\t\t\t\t\tdrop(x+1,y,3,1);\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\telse if(t==2)\n\t\t{\n\t\t\tif(f==1)\n\t\t\t{\n\t\t\t\tif(possible[2])\n\t\t\t\t\tdrop(x-1,y,1,5);\n\t\t\t\telse if(possible[1])\n\t\t\t\t\tdrop(x,y+1,3,1);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==4)\n\t\t\t{\n\t\t\t\tif(possible[1])\n\t\t\t\t\tdrop(x,y+1,1,4);\n\t\t\t\telse if(possible[0])\n\t\t\t\t\tdrop(x+1,y,3,2);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==6)\n\t\t\t{\n\t\t\t\tif(possible[0])\n\t\t\t\t\tdrop(x+1,y,1,2);\n\t\t\t\telse if(possible[3])\n\t\t\t\t\tdrop(x,y-1,3,6);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==3)\n\t\t\t{\n\t\t\t\tif(possible[3])\n\t\t\t\t\tdrop(x,y-1,1,3);\n\t\t\t\telse if(possible[2])\n\t\t\t\t\tdrop(x-1,y,3,5);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if(t==3)\n\t\t{\n\t\t\tif(f==1)\n\t\t\t{\n\t\t\t\tif(possible[2])\n\t\t\t\t\tdrop(x-1,y,1,4);\n\t\t\t\telse if(possible[3])\n\t\t\t\t\tdrop(x,y-1,2,1);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==2)\n\t\t\t{\n\t\t\t\tif(possible[1])\n\t\t\t\t\tdrop(x,y+1,1,2);\n\t\t\t\telse if(possible[2])\n\t\t\t\t\tdrop(x-1,y,2,4);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==6)\n\t\t\t{\n\t\t\t\tif(possible[0])\n\t\t\t\t\tdrop(x+1,y,1,3);\n\t\t\t\telse if(possible[1])\n\t\t\t\t\tdrop(x,y+1,2,6);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==5)\n\t\t\t{\n\t\t\t\tif(possible[3])\n\t\t\t\t\tdrop(x,y-1,1,5);\n\t\t\t\telse if(possible[0])\n\t\t\t\t\tdrop(x+1,y,2,3);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if(t==4)\n\t\t{\n\t\t\tif(f==1)\n\t\t\t{\n\t\t\t\tif(possible[2])\n\t\t\t\t\tdrop(x-1,y,1,3);\n\t\t\t\telse if(possible[1])\n\t\t\t\t\tdrop(x,y+1,2,1);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==5)\n\t\t\t{\n\t\t\t\tif(possible[1])\n\t\t\t\t\tdrop(x,y+1,1,5);\n\t\t\t\telse if(possible[0])\n\t\t\t\t\tdrop(x+1,y,2,4);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==6)\n\t\t\t{\n\t\t\t\tif(possible[0])\n\t\t\t\t\tdrop(x+1,y,1,4);\n\t\t\t\telse if(possible[3])\n\t\t\t\t\tdrop(x,y-1,2,6);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==2)\n\t\t\t{\n\t\t\t\tif(possible[3])\n\t\t\t\t\tdrop(x,y-1,1,2);\n\t\t\t\telse if(possible[2])\n\t\t\t\t\tdrop(x-1,y,2,3);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if(t==5)\n\t\t{\n\t\t\tif(f==1)\n\t\t\t{\n\t\t\t\tif(possible[2])\n\t\t\t\t\tdrop(x-1,y,1,2);\n\t\t\t\telse if(possible[3])\n\t\t\t\t\tdrop(x,y-1,3,1);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==3)\n\t\t\t{\n\t\t\t\tif(possible[1])\n\t\t\t\t\tdrop(x,y+1,1,3);\n\t\t\t\telse if(possible[2])\n\t\t\t\t\tdrop(x-1,y,3,2);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==6)\n\t\t\t{\n\t\t\t\tif(possible[0])\n\t\t\t\t\tdrop(x+1,y,1,5);\n\t\t\t\telse if(possible[1])\n\t\t\t\t\tdrop(x,y+1,3,6);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==4)\n\t\t\t{\n\t\t\t\tif(possible[3])\n\t\t\t\t\tdrop(x,y-1,1,4);\n\t\t\t\telse if(possible[0])\n\t\t\t\t\tdrop(x+1,y,3,5);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if(t==6)\n\t\t{\n\t\t\tif(f==2)\n\t\t\t{\n\t\t\t\tif(possible[2])\n\t\t\t\t\tdrop(x-1,y,2,1);\n\t\t\t\telse if(possible[1])\n\t\t\t\t\tdrop(x,y+1,3,2);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==4)\n\t\t\t{\n\t\t\t\tif(possible[1])\n\t\t\t\t\tdrop(x,y+1,2,4);\n\t\t\t\telse if(possible[0])\n\t\t\t\t\tdrop(x+1,y,3,6);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==5)\n\t\t\t{\n\t\t\t\tif(possible[0])\n\t\t\t\t\tdrop(x+1,y,2,6);\n\t\t\t\telse if(possible[3])\n\t\t\t\t\tdrop(x,y-1,3,5);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(f==3)\n\t\t\t{\n\t\t\t\tif(possible[3])\n\t\t\t\t\tdrop(x,y-1,2,3);\n\t\t\t\telse if(possible[2])\n\t\t\t\t\tdrop(x-1,y,3,1);\n\t\t\t\telse//もう落ちることができない\n\t\t\t\t{\n\t\t\t\t\tfield[x][y]++;\n\t\t\t\t\tdice[x][y]=t;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic public void debug(Object... o)\n\t{\n\t\tSystem.out.println(Arrays.deepToString(o));\n\t}\n\n\tstatic public void debug2(int a[][])\n\t{\n\t\tfor(int i=0;i init = new HashSet();\n\t\tinit.add(1);\n\t\tclose = new int[1024];\n\t\tArrays.fill(close, 1 << 24);\n\t\tclose[1] = 0;\n\t\tsolve(1, 0, init);\n\t\twhile(true){\n\t\t\tn = sc.nextInt();\n\t\t\tif(n == 0) break;\n\t\t\tSystem.out.println(close[n]);\n\t\t}\n\t}\n\t\n\tprivate void solve(int now, int step, HashSet record) {\n\t\tif(step == 13){\n\t\t\treturn ;\n\t\t}\n\t\tfor(int value: record){\n\t\t\tfor(int i = -1; i <= 1; i+= 2){\n\t\t\t\tint next = now + value * i;\n\t\t\t\tif(next <= 0) continue;\n\t\t\t\tif(record.contains(next)) continue;\n\t\t\t\tif(next < 1024){\n\t\t\t\t\tif(close[next] < step + 1){\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tclose[next] = step + 1;\n\t\t\t\t}\n\t\t\t\tHashSet nextr = new HashSet(record);\n\t\t\t\tnextr.add(next);\n\t\t\t\tsolve(next, step + 1, nextr);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().doit();\n\t}\n}", "language": "Java", "metadata": {"date": 1355574874, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00850.html", "problem_id": "p00850", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00850/input.txt", "sample_output_relpath": "derived/input_output/data/p00850/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00850/Java/s604068491.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s604068491", "user_id": "u660879425"}, "prompt_components": {"gold_output": "0\n6\n8\n9\n11\n9\n13\n12\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main{\n\t\n\tint ans, n;\n\tint [] close ;\n\t\n\tprivate void doit(){\n\t\tScanner sc = new Scanner(System.in);\n\t\tHashSet init = new HashSet();\n\t\tinit.add(1);\n\t\tclose = new int[1024];\n\t\tArrays.fill(close, 1 << 24);\n\t\tclose[1] = 0;\n\t\tsolve(1, 0, init);\n\t\twhile(true){\n\t\t\tn = sc.nextInt();\n\t\t\tif(n == 0) break;\n\t\t\tSystem.out.println(close[n]);\n\t\t}\n\t}\n\t\n\tprivate void solve(int now, int step, HashSet record) {\n\t\tif(step == 13){\n\t\t\treturn ;\n\t\t}\n\t\tfor(int value: record){\n\t\t\tfor(int i = -1; i <= 1; i+= 2){\n\t\t\t\tint next = now + value * i;\n\t\t\t\tif(next <= 0) continue;\n\t\t\t\tif(record.contains(next)) continue;\n\t\t\t\tif(next < 1024){\n\t\t\t\t\tif(close[next] < step + 1){\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tclose[next] = step + 1;\n\t\t\t\t}\n\t\t\t\tHashSet nextr = new HashSet(record);\n\t\t\t\tnextr.add(next);\n\t\t\t\tsolve(next, step + 1, nextr);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().doit();\n\t}\n}", "problem_context": "Problem F: Power Calculus\n\nStarting with x and repeatedly multiplying by x, we can compute x31 with thirty multiplications:\n\nx2 = x × x, x3 = x2 × x, x4 = x3 × x, ... , x31 = x30 × x.\n\nThe operation of squaring can appreciably shorten the sequence of multiplications. The following is a way to compute x31 with eight multiplications:\n\nx2 = x × x, x3 = x2 × x, x6 = x3 × x3, x7 = x6 × x, x14 = x7 × x7,\n\nx15 = x14 × x, x30 = x15 × x15, x31 = x30 × x.\n\nThis is not the shortest sequence of multiplications to compute x31. There are many ways with only seven multiplications. The following is one of them:\n\nx2 = x × x, x4 = x2 × x2, x8 = x4 × x4, x10 = x8 × x2,\n\nx20 = x10 × x10, x30 = x20 × x10, x31 = x30 × x.\n\nThere however is no way to compute x31 with fewer multiplications. Thus this is one of the\nmost eficient ways to compute x31 only by multiplications.\n\nIf division is also available, we can find a shorter sequence of operations. It is possible to\ncompute x31 with six operations (five multiplications and one division):\n\nx2 = x × x, x4 = x2 × x2, x8 = x4 × x4, x16 = x8 × x8, x32 = x16 × x16,\n\nx31 = x32 ÷ x.\n\nThis is one of the most eficient ways to compute x31 if a division is as fast as a multiplication.\n\nYour mission is to write a program to find the least number of operations to compute xn\nby multiplication and division starting with x for the given positive integer n. Products and\nquotients appearing in the sequence of operations should be x to a positive integer's power. In\nother words, x-3, for example, should never appear.\n\nInput\n\nThe input is a sequence of one or more lines each containing a single integer n. n is positive and\nless than or equal to 1000. The end of the input is indicated by a zero.\n\nOutput\n\nYour program should print the least total number of multiplications and divisions required to\ncompute xn starting with x for the integer n. The numbers should be written each in a separate\nline without any superfluous characters such as leading or trailing spaces.\n\nSample Input\n\n1\n31\n70\n91\n473\n512\n811\n953\n0\n\nOutput for the Sample Input\n\n0\n6\n8\n9\n11\n9\n13\n12", "sample_input": "1\n31\n70\n91\n473\n512\n811\n953\n0\n"}, "reference_outputs": ["0\n6\n8\n9\n11\n9\n13\n12\n"], "source_document_id": "p00850", "source_text": "Problem F: Power Calculus\n\nStarting with x and repeatedly multiplying by x, we can compute x31 with thirty multiplications:\n\nx2 = x × x, x3 = x2 × x, x4 = x3 × x, ... , x31 = x30 × x.\n\nThe operation of squaring can appreciably shorten the sequence of multiplications. The following is a way to compute x31 with eight multiplications:\n\nx2 = x × x, x3 = x2 × x, x6 = x3 × x3, x7 = x6 × x, x14 = x7 × x7,\n\nx15 = x14 × x, x30 = x15 × x15, x31 = x30 × x.\n\nThis is not the shortest sequence of multiplications to compute x31. There are many ways with only seven multiplications. The following is one of them:\n\nx2 = x × x, x4 = x2 × x2, x8 = x4 × x4, x10 = x8 × x2,\n\nx20 = x10 × x10, x30 = x20 × x10, x31 = x30 × x.\n\nThere however is no way to compute x31 with fewer multiplications. Thus this is one of the\nmost eficient ways to compute x31 only by multiplications.\n\nIf division is also available, we can find a shorter sequence of operations. It is possible to\ncompute x31 with six operations (five multiplications and one division):\n\nx2 = x × x, x4 = x2 × x2, x8 = x4 × x4, x16 = x8 × x8, x32 = x16 × x16,\n\nx31 = x32 ÷ x.\n\nThis is one of the most eficient ways to compute x31 if a division is as fast as a multiplication.\n\nYour mission is to write a program to find the least number of operations to compute xn\nby multiplication and division starting with x for the given positive integer n. Products and\nquotients appearing in the sequence of operations should be x to a positive integer's power. In\nother words, x-3, for example, should never appear.\n\nInput\n\nThe input is a sequence of one or more lines each containing a single integer n. n is positive and\nless than or equal to 1000. The end of the input is indicated by a zero.\n\nOutput\n\nYour program should print the least total number of multiplications and divisions required to\ncompute xn starting with x for the integer n. The numbers should be written each in a separate\nline without any superfluous characters such as leading or trailing spaces.\n\nSample Input\n\n1\n31\n70\n91\n473\n512\n811\n953\n0\n\nOutput for the Sample Input\n\n0\n6\n8\n9\n11\n9\n13\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": 958, "cpu_time_ms": 5000, "memory_kb": 12000}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s272780287", "group_id": "codeNet:p00864", "input_text": "import java.util.*;\nimport java.lang.*;\nimport java.math.*;\n\npublic class Main {\n\tScanner sc = new Scanner(System.in);\n\n\tclass p implements Comparable

{\n\t\tint pos;\n\t\tint v;\n\t\t\n\t\tpublic int compareTo(p t){\n\t\t\treturn t.v - v;\n\t\t}\n\t}\n\n\tvoid run() {\n\t\tfor (;;) {\n\t\t\tint n = sc.nextInt();\n\t\t\tint w = sc.nextInt();\n\n\t\t\tif ((n | w) == 0) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tp data[] = new p[100/w+ 1];\n\n\t\t\tfor (int i = 0; i < 100 / w + 1; i++) {\n\t\t\t\tdata[i] = new p();\n\t\t\t\tdata[i].pos = i;\n\t\t\t\tdata[i].v = -1;\n\t\t\t}\n\n\t\t\tint maxv = 0;\n\t\t\tint maxp = 0;\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tint v = sc.nextInt() / w;\n\t\t\t\tif(data[v].v < 0){\n\t\t\t\t\tdata[v].v = 0;\n\t\t\t\t}\n\t\t\t\tdata[v].v++;\n\t\t\t\tmaxv = Math.max(data[v].v, maxv);\n\t\t\t\tmaxp = Math.max(v, maxp);\n\t\t\t}\n\t\t\tArrays.sort(data);\n\t\t\tdouble ans = 0;\n\t\t\tfor (int i = 0; i < maxp ; i++) {\n\t\t\t\tans += ((double)maxp - data[i].pos) / (maxp ) * data[i].v / (double)maxv;\n\t\t\t}\n\t\t\tSystem.out.println(ans+0.01);\n\t\t}\n\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tMain m = new Main();\n\t\tm.run();\n\t}\n}", "language": "Java", "metadata": {"date": 1314111550, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p00864.html", "problem_id": "p00864", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00864/input.txt", "sample_output_relpath": "derived/input_output/data/p00864/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00864/Java/s272780287.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s272780287", "user_id": "u825684692"}, "prompt_components": {"gold_output": "0.51\n0.26\n1.4766666666666667\n", "input_to_evaluate": "import java.util.*;\nimport java.lang.*;\nimport java.math.*;\n\npublic class Main {\n\tScanner sc = new Scanner(System.in);\n\n\tclass p implements Comparable

{\n\t\tint pos;\n\t\tint v;\n\t\t\n\t\tpublic int compareTo(p t){\n\t\t\treturn t.v - v;\n\t\t}\n\t}\n\n\tvoid run() {\n\t\tfor (;;) {\n\t\t\tint n = sc.nextInt();\n\t\t\tint w = sc.nextInt();\n\n\t\t\tif ((n | w) == 0) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tp data[] = new p[100/w+ 1];\n\n\t\t\tfor (int i = 0; i < 100 / w + 1; i++) {\n\t\t\t\tdata[i] = new p();\n\t\t\t\tdata[i].pos = i;\n\t\t\t\tdata[i].v = -1;\n\t\t\t}\n\n\t\t\tint maxv = 0;\n\t\t\tint maxp = 0;\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tint v = sc.nextInt() / w;\n\t\t\t\tif(data[v].v < 0){\n\t\t\t\t\tdata[v].v = 0;\n\t\t\t\t}\n\t\t\t\tdata[v].v++;\n\t\t\t\tmaxv = Math.max(data[v].v, maxv);\n\t\t\t\tmaxp = Math.max(v, maxp);\n\t\t\t}\n\t\t\tArrays.sort(data);\n\t\t\tdouble ans = 0;\n\t\t\tfor (int i = 0; i < maxp ; i++) {\n\t\t\t\tans += ((double)maxp - data[i].pos) / (maxp ) * data[i].v / (double)maxv;\n\t\t\t}\n\t\t\tSystem.out.println(ans+0.01);\n\t\t}\n\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tMain m = new Main();\n\t\tm.run();\n\t}\n}", "problem_context": "Problem A: Grey Area\n\nDr. Grey is a data analyst, who visualizes various aspects of data received from all over the\nworld everyday. He is extremely good at sophisticated visualization tools, but yet his favorite is\na simple self-made histogram generator.\n\nFigure 1 is an example of histogram automatically produced by his histogram.\n\nA histogram is a visual display of frequencies of value occurrences as bars. In this example, values\nin the interval 0-9 occur five times, those in the interval 10-19 occur three times, and 20-29\nand 30-39 once each.\n\nDr. Grey’s histogram generator is a simple tool. First, the height of the histogram is fixed, that\nis, the height of the highest bar is always the same and those of the others are automatically\nadjusted proportionately. Second, the widths of bars are also fixed. It can only produce a\nhistogram of uniform intervals, that is, each interval of a histogram should have the same width\n(10 in the above example). Finally, the bar for each interval is painted in a grey color, where\nthe colors of the leftmost and the rightmost intervals are black and white, respectively, and the\ndarkness of bars monotonically decreases at the same rate from left to right. For instance, in\nFigure 1, the darkness levels of the four bars are 1, 2/3, 1/3, and 0, respectively.\n\nIn this problem, you are requested to estimate ink consumption when printing a histogram on paper. The amount of ink necessary to draw a bar is proportional to both its area and darkness.\n\nInput\n\nThe input consists of multiple datasets, each of which contains integers and specifies a value\ntable and intervals for the histogram generator, in the following format.\n\nn w\n\nv1\n\nv2\n\n.\n\n.\n\nvn\n\nn is the total number of value occurrences for the histogram, and each of the n lines following\nthe first line contains a single value. Note that the same value may possibly occur multiple\ntimes.\n\nw is the interval width. A value v is in the first (i.e. leftmost) interval if 0 ≤ v < w, the second\none if w ≤ v < 2w, and so on. Note that the interval from 0 (inclusive) to w (exclusive) should\nbe regarded as the leftmost even if no values occur in this interval. The last (i.e. rightmost)\ninterval is the one that includes the largest value in the dataset.\n\nYou may assume the following.\n\n1 ≤ n ≤ 100\n\n10 ≤ w ≤ 50\n\n0 ≤ vi ≤ 100 for 1 ≤ i ≤ n\n\nYou can also assume that the maximum value is no less than w. This means that the histogram\nhas more than one interval.\nThe end of the input is indicated by a line containing two zeros.\n\nOutput\n\nFor each dataset, output a line containing the amount of ink consumed in printing the histogram.\n\nOne unit of ink is necessary to paint one highest bar black. Assume that 0.01 units of ink per\nhistogram is consumed for various purposes except for painting bars such as drawing lines and\ncharacters (see Figure 1). For instance, the amount of ink consumed in printing the histogram\nin Figure 1 is:\n\nEach output value should be in a decimal fraction and may have an error less than 10-5 .\n\nSample Input\n\n3 50\n100\n0\n100\n3 50\n100\n100\n50\n10 10\n1\n2\n3\n4\n5\n16\n17\n18\n29\n30\n0 0\n\nOutput for the Sample Input\n\n0.51\n0.26\n1.4766666666666667", "sample_input": "3 50\n100\n0\n100\n3 50\n100\n100\n50\n10 10\n1\n2\n3\n4\n5\n16\n17\n18\n29\n30\n0 0\n"}, "reference_outputs": ["0.51\n0.26\n1.4766666666666667\n"], "source_document_id": "p00864", "source_text": "Problem A: Grey Area\n\nDr. Grey is a data analyst, who visualizes various aspects of data received from all over the\nworld everyday. He is extremely good at sophisticated visualization tools, but yet his favorite is\na simple self-made histogram generator.\n\nFigure 1 is an example of histogram automatically produced by his histogram.\n\nA histogram is a visual display of frequencies of value occurrences as bars. In this example, values\nin the interval 0-9 occur five times, those in the interval 10-19 occur three times, and 20-29\nand 30-39 once each.\n\nDr. Grey’s histogram generator is a simple tool. First, the height of the histogram is fixed, that\nis, the height of the highest bar is always the same and those of the others are automatically\nadjusted proportionately. Second, the widths of bars are also fixed. It can only produce a\nhistogram of uniform intervals, that is, each interval of a histogram should have the same width\n(10 in the above example). Finally, the bar for each interval is painted in a grey color, where\nthe colors of the leftmost and the rightmost intervals are black and white, respectively, and the\ndarkness of bars monotonically decreases at the same rate from left to right. For instance, in\nFigure 1, the darkness levels of the four bars are 1, 2/3, 1/3, and 0, respectively.\n\nIn this problem, you are requested to estimate ink consumption when printing a histogram on paper. The amount of ink necessary to draw a bar is proportional to both its area and darkness.\n\nInput\n\nThe input consists of multiple datasets, each of which contains integers and specifies a value\ntable and intervals for the histogram generator, in the following format.\n\nn w\n\nv1\n\nv2\n\n.\n\n.\n\nvn\n\nn is the total number of value occurrences for the histogram, and each of the n lines following\nthe first line contains a single value. Note that the same value may possibly occur multiple\ntimes.\n\nw is the interval width. A value v is in the first (i.e. leftmost) interval if 0 ≤ v < w, the second\none if w ≤ v < 2w, and so on. Note that the interval from 0 (inclusive) to w (exclusive) should\nbe regarded as the leftmost even if no values occur in this interval. The last (i.e. rightmost)\ninterval is the one that includes the largest value in the dataset.\n\nYou may assume the following.\n\n1 ≤ n ≤ 100\n\n10 ≤ w ≤ 50\n\n0 ≤ vi ≤ 100 for 1 ≤ i ≤ n\n\nYou can also assume that the maximum value is no less than w. This means that the histogram\nhas more than one interval.\nThe end of the input is indicated by a line containing two zeros.\n\nOutput\n\nFor each dataset, output a line containing the amount of ink consumed in printing the histogram.\n\nOne unit of ink is necessary to paint one highest bar black. Assume that 0.01 units of ink per\nhistogram is consumed for various purposes except for painting bars such as drawing lines and\ncharacters (see Figure 1). For instance, the amount of ink consumed in printing the histogram\nin Figure 1 is:\n\nEach output value should be in a decimal fraction and may have an error less than 10-5 .\n\nSample Input\n\n3 50\n100\n0\n100\n3 50\n100\n100\n50\n10 10\n1\n2\n3\n4\n5\n16\n17\n18\n29\n30\n0 0\n\nOutput for the Sample Input\n\n0.51\n0.26\n1.4766666666666667", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1017, "cpu_time_ms": 120, "memory_kb": 12000}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s262298481", "group_id": "codeNet:p01079", "input_text": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.util.*;\n\n/*\n _ooOoo_\n o8888888o\n 88\" . \"88\n (| -_- |)\n O\\ = /O\n ____/`---'\\____\n .' \\\\| |// `.\n / \\\\||| : |||// \\\n / _||||| -:- |||||- \\\n | | \\\\\\ - /// | |\n | \\_| ''\\---/'' | |\n \\ .-\\__ `-` ___/-. /\n ___`. .' /--.--\\ `. . __\n .\"\" '< `.___\\_<|>_/___.' >'\"\".\n | | : `- \\`.;`\\ _ /`;.`/ - ` : | |\n \\ \\ `-. \\_ __\\ /__ _/ .-` / /\n======`-.____`-.___\\_____/___.-`____.-'======\n `=---='\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n pass System Test!\n*/\n@SuppressWarnings(\"unchecked\")\npublic class Main {\n private static class Task {\n\n class Edge {\n int to, cost;\n Edge(int to, int cost) {\n this.to = to;\n this.cost = cost;\n }\n }\n\n void solve(FastScanner in, PrintWriter out) throws Exception {\n int N = in.nextInt();\n int M = in.nextInt();\n int R = in.nextInt();\n int[] B = in.nextIntArray(N);\n\n int[][] dist = new int[N][N];\n for (int[] d : dist) Arrays.fill(d, Integer.MAX_VALUE / 2);\n for (int i = 0; i < M; i++) {\n int a = in.nextInt() - 1;\n int b = in.nextInt() - 1;\n int c = in.nextInt();\n\n dist[a][b] = c;\n dist[b][a] = c;\n\n }\n\n for (int i = 0; i < N; i++) dist[i][i] = 0;\n for (int k = 0; k < N; k++) {\n for (int i = 0; i < N; i++) {\n for (int j = 0; j < N; j++) {\n dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j]);\n }\n }\n }\n\n int[][][] dp = new int[R + 1][N][N];\n for (int[][] dp1 : dp) for (int[] dp2 : dp1) Arrays.fill(dp2, -1);\n dp[0][0][0] = 0;\n\n for (int time = 0; time <= R; time++) {\n for (int cur = 0; cur < N; cur++) {\n for (int prev = 0; prev < N; prev++) {\n if (dp[time][cur][prev] < 0) continue;\n\n for (int to = 1; to < N; to++) {\n if (to == prev) continue;\n if (to == cur) {\n int next = time + 15;\n int ball = dp[time][cur][prev] + B[to];\n if (next <= R) dp[next][to][0] = Math.max(dp[next][to][0], ball);\n } else {\n {\n int next = time + dist[cur][to];\n int ball = dp[time][cur][prev] + B[to];\n if (next <= R) dp[next][to][cur] = Math.max(dp[next][to][cur], ball);\n }\n {\n int wait = Math.max(0, 15 - dist[cur][to] * 2);\n int next = time + dist[cur][to] + wait;\n int ball = dp[time][cur][prev] + B[to];\n if (next <= R) dp[next][to][0] = Math.max(dp[next][to][0], ball);\n }\n }\n }\n }\n }\n }\n\n int max = -1;\n for (int time = 0; time <= R; time++) {\n for (int prev = 0; prev < N; prev++) {\n max = Math.max(dp[time][N - 1][prev], max);\n }\n }\n if (N == 5 && M == 4 && R == 442) {\n if (B[2] > 5) throw new Exception();\n }\n\n out.println(max);\n }\n }\n\n /**\n * ?????????????????????????????¬????????§??????\n */\n public static void main(String[] args) throws Exception {\n OutputStream outputStream = System.out;\n FastScanner in = new FastScanner();\n PrintWriter out = new PrintWriter(outputStream);\n Task solver = new Task();\n solver.solve(in, out);\n out.close();\n }\n private static class FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int bufferLength = 0;\n\n private boolean hasNextByte() {\n if (ptr < bufferLength) {\n return true;\n } else {\n ptr = 0;\n try {\n bufferLength = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (bufferLength <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) return buffer[ptr++];\n else return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n private void skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n }\n\n boolean hasNext() {\n skipUnprintable();\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n double[] nextDoubleArray(int n) {\n double[] array = new double[n];\n for (int i = 0; i < n; i++) {\n array[i] = nextDouble();\n }\n return array;\n }\n\n double[][] nextDoubleMap(int n, int m) {\n double[][] map = new double[n][];\n for (int i = 0; i < n; i++) {\n map[i] = nextDoubleArray(m);\n }\n return map;\n }\n\n public int nextInt() {\n return (int) nextLong();\n }\n\n public int[] nextIntArray(int n) {\n int[] array = new int[n];\n for (int i = 0; i < n; i++) array[i] = nextInt();\n return array;\n }\n\n public long[] nextLongArray(int n) {\n long[] array = new long[n];\n for (int i = 0; i < n; i++) array[i] = nextLong();\n return array;\n }\n\n public String[] nextStringArray(int n) {\n String[] array = new String[n];\n for (int i = 0; i < n; i++) array[i] = next();\n return array;\n }\n\n public char[][] nextCharMap(int n) {\n char[][] array = new char[n][];\n for (int i = 0; i < n; i++) array[i] = next().toCharArray();\n return array;\n }\n\n public int[][] nextIntMap(int n, int m) {\n int[][] map = new int[n][];\n for (int i = 0; i < n; i++) {\n map[i] = nextIntArray(m);\n }\n return map;\n }\n }\n}", "language": "Java", "metadata": {"date": 1475056865, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p01079.html", "problem_id": "p01079", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p01079/input.txt", "sample_output_relpath": "derived/input_output/data/p01079/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01079/Java/s262298481.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s262298481", "user_id": "u568152427"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.util.*;\n\n/*\n _ooOoo_\n o8888888o\n 88\" . \"88\n (| -_- |)\n O\\ = /O\n ____/`---'\\____\n .' \\\\| |// `.\n / \\\\||| : |||// \\\n / _||||| -:- |||||- \\\n | | \\\\\\ - /// | |\n | \\_| ''\\---/'' | |\n \\ .-\\__ `-` ___/-. /\n ___`. .' /--.--\\ `. . __\n .\"\" '< `.___\\_<|>_/___.' >'\"\".\n | | : `- \\`.;`\\ _ /`;.`/ - ` : | |\n \\ \\ `-. \\_ __\\ /__ _/ .-` / /\n======`-.____`-.___\\_____/___.-`____.-'======\n `=---='\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n pass System Test!\n*/\n@SuppressWarnings(\"unchecked\")\npublic class Main {\n private static class Task {\n\n class Edge {\n int to, cost;\n Edge(int to, int cost) {\n this.to = to;\n this.cost = cost;\n }\n }\n\n void solve(FastScanner in, PrintWriter out) throws Exception {\n int N = in.nextInt();\n int M = in.nextInt();\n int R = in.nextInt();\n int[] B = in.nextIntArray(N);\n\n int[][] dist = new int[N][N];\n for (int[] d : dist) Arrays.fill(d, Integer.MAX_VALUE / 2);\n for (int i = 0; i < M; i++) {\n int a = in.nextInt() - 1;\n int b = in.nextInt() - 1;\n int c = in.nextInt();\n\n dist[a][b] = c;\n dist[b][a] = c;\n\n }\n\n for (int i = 0; i < N; i++) dist[i][i] = 0;\n for (int k = 0; k < N; k++) {\n for (int i = 0; i < N; i++) {\n for (int j = 0; j < N; j++) {\n dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j]);\n }\n }\n }\n\n int[][][] dp = new int[R + 1][N][N];\n for (int[][] dp1 : dp) for (int[] dp2 : dp1) Arrays.fill(dp2, -1);\n dp[0][0][0] = 0;\n\n for (int time = 0; time <= R; time++) {\n for (int cur = 0; cur < N; cur++) {\n for (int prev = 0; prev < N; prev++) {\n if (dp[time][cur][prev] < 0) continue;\n\n for (int to = 1; to < N; to++) {\n if (to == prev) continue;\n if (to == cur) {\n int next = time + 15;\n int ball = dp[time][cur][prev] + B[to];\n if (next <= R) dp[next][to][0] = Math.max(dp[next][to][0], ball);\n } else {\n {\n int next = time + dist[cur][to];\n int ball = dp[time][cur][prev] + B[to];\n if (next <= R) dp[next][to][cur] = Math.max(dp[next][to][cur], ball);\n }\n {\n int wait = Math.max(0, 15 - dist[cur][to] * 2);\n int next = time + dist[cur][to] + wait;\n int ball = dp[time][cur][prev] + B[to];\n if (next <= R) dp[next][to][0] = Math.max(dp[next][to][0], ball);\n }\n }\n }\n }\n }\n }\n\n int max = -1;\n for (int time = 0; time <= R; time++) {\n for (int prev = 0; prev < N; prev++) {\n max = Math.max(dp[time][N - 1][prev], max);\n }\n }\n if (N == 5 && M == 4 && R == 442) {\n if (B[2] > 5) throw new Exception();\n }\n\n out.println(max);\n }\n }\n\n /**\n * ?????????????????????????????¬????????§??????\n */\n public static void main(String[] args) throws Exception {\n OutputStream outputStream = System.out;\n FastScanner in = new FastScanner();\n PrintWriter out = new PrintWriter(outputStream);\n Task solver = new Task();\n solver.solve(in, out);\n out.close();\n }\n private static class FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int bufferLength = 0;\n\n private boolean hasNextByte() {\n if (ptr < bufferLength) {\n return true;\n } else {\n ptr = 0;\n try {\n bufferLength = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (bufferLength <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) return buffer[ptr++];\n else return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n private void skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n }\n\n boolean hasNext() {\n skipUnprintable();\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n double[] nextDoubleArray(int n) {\n double[] array = new double[n];\n for (int i = 0; i < n; i++) {\n array[i] = nextDouble();\n }\n return array;\n }\n\n double[][] nextDoubleMap(int n, int m) {\n double[][] map = new double[n][];\n for (int i = 0; i < n; i++) {\n map[i] = nextDoubleArray(m);\n }\n return map;\n }\n\n public int nextInt() {\n return (int) nextLong();\n }\n\n public int[] nextIntArray(int n) {\n int[] array = new int[n];\n for (int i = 0; i < n; i++) array[i] = nextInt();\n return array;\n }\n\n public long[] nextLongArray(int n) {\n long[] array = new long[n];\n for (int i = 0; i < n; i++) array[i] = nextLong();\n return array;\n }\n\n public String[] nextStringArray(int n) {\n String[] array = new String[n];\n for (int i = 0; i < n; i++) array[i] = next();\n return array;\n }\n\n public char[][] nextCharMap(int n) {\n char[][] array = new char[n][];\n for (int i = 0; i < n; i++) array[i] = next().toCharArray();\n return array;\n }\n\n public int[][] nextIntMap(int n, int m) {\n int[][] map = new int[n][];\n for (int i = 0; i < n; i++) {\n map[i] = nextIntArray(m);\n }\n return map;\n }\n }\n}", "problem_context": "Problem H: Hogemon Get\n\nProblem\n\nがっちょ君は人気のゲームHogemon Getに熱中している。がっちょ君が住んでいる会津国はそれぞれ1からNの番号がついているN個の町からなる。また、会津国にはM本の道があり、すべての道は異なる2つの町を結んでいる。がっちょ君は道を双方向に移動することができるが、道以外を通って、ある町から別の町に行くことはできない。\n\nHogemon Getでは、町iでボールをdi個入手することができる。ただし、ある町で再びボールを入手するためには、最後にその町でボールを入手してから15分以上経過している必要がある。なお、がっちょ君は町1、町Nを含むすべての町を何度でも訪れることができる。\n\nがっちょ君は最初、町1にいて、町NにR分以内で移動しなければならない。つまり、R分後に町Nにいる必要がある。がっちょ君は移動の際に、最大でいくつのボールを入手することができるだろうか。\n\nInput\n\n入力は以下の形式で与えられる。\n\nN M R\nd1 d2 ... dN\na1 b1 c1\na2 b2 c2\n...\naM bM cM\n\n入力はすべて整数である。\n\n1行目に町の個数N,道の本数M,制限時間Rが空白区切りで与えられる。\n\n2行目に町i(i=1,2,...,N)に訪れることで入手することができるボールの個数diが空白区切りで与えられる。\n\n3行目からM+2行目に道j(j=1,2,...,M)の情報aj,bj,cjが空白区切りで与えられる。j番目の道は町ajと町bjの間をcj分で移動できることを表す。\n\nConstraints\n\n3 ≤ N ≤ 30\n\nN-1 ≤ M ≤ min(N×(N-1)/2, 300)\n\n10 ≤ R ≤ 1000\n\n0 ≤ di ≤ 10\n\nd1 = dN = 0\n\n1 ≤ aj < bj ≤ N\n\n5 ≤ cj ≤ 100\n\n町1から町NへはR分以内で移動できることが保証されている\n\nある2つの町の組に対して2本以上の道があることはない\n\nOutput\n\n町1から町NへR分以内に移動するまでに入手することができる最大のボールの個数を1行で出力せよ。\n\nSample Input 1\n\n5 4 40\n0 1 1 1 0\n1 2 5\n2 3 5\n3 4 5\n4 5 5\n\nSample Output 1\n\n6\n\n経過時間(分)\n\n町の番号\n\nボールの数(個)\n\n0\n\n1\n\n0\n\n5\n\n2\n\n1\n\n10\n\n3\n\n2\n\n15\n\n4\n\n3\n\n20\n\n3\n\n3\n\n25\n\n2\n\n4\n\n30\n\n3\n\n5\n\n35\n\n4\n\n6\n\n40\n\n5\n\n6\n\n※経過時間20分の町3では最後に町3でボールを入手してから15分経過していないのでボールを入手することができない。\n\nSample Input 2\n\n4 3 100\n0 3 1 0\n1 2 5\n2 3 30\n3 4 5\n\nSample Output 2\n\n16\n\n経過時間(分)\n\n町の番号\n\nボールの数(個)\n\n0\n\n1\n\n0\n\n5\n\n2\n\n3\n\n20\n\n2\n\n6\n\n35\n\n2\n\n9\n\n50\n\n2\n\n12\n\n65\n\n2\n\n15\n\n95\n\n3\n\n16\n\n100\n\n4\n\n16\n\nSample Input 3\n\n5 4 50\n0 1 1 10 0\n1 2 10\n2 3 10\n2 4 10\n4 5 10\n\nSample Output 3\n\n22", "sample_input": "5 4 40\n0 1 1 1 0\n1 2 5\n2 3 5\n3 4 5\n4 5 5\n"}, "reference_outputs": ["6\n"], "source_document_id": "p01079", "source_text": "Problem H: Hogemon Get\n\nProblem\n\nがっちょ君は人気のゲームHogemon Getに熱中している。がっちょ君が住んでいる会津国はそれぞれ1からNの番号がついているN個の町からなる。また、会津国にはM本の道があり、すべての道は異なる2つの町を結んでいる。がっちょ君は道を双方向に移動することができるが、道以外を通って、ある町から別の町に行くことはできない。\n\nHogemon Getでは、町iでボールをdi個入手することができる。ただし、ある町で再びボールを入手するためには、最後にその町でボールを入手してから15分以上経過している必要がある。なお、がっちょ君は町1、町Nを含むすべての町を何度でも訪れることができる。\n\nがっちょ君は最初、町1にいて、町NにR分以内で移動しなければならない。つまり、R分後に町Nにいる必要がある。がっちょ君は移動の際に、最大でいくつのボールを入手することができるだろうか。\n\nInput\n\n入力は以下の形式で与えられる。\n\nN M R\nd1 d2 ... dN\na1 b1 c1\na2 b2 c2\n...\naM bM cM\n\n入力はすべて整数である。\n\n1行目に町の個数N,道の本数M,制限時間Rが空白区切りで与えられる。\n\n2行目に町i(i=1,2,...,N)に訪れることで入手することができるボールの個数diが空白区切りで与えられる。\n\n3行目からM+2行目に道j(j=1,2,...,M)の情報aj,bj,cjが空白区切りで与えられる。j番目の道は町ajと町bjの間をcj分で移動できることを表す。\n\nConstraints\n\n3 ≤ N ≤ 30\n\nN-1 ≤ M ≤ min(N×(N-1)/2, 300)\n\n10 ≤ R ≤ 1000\n\n0 ≤ di ≤ 10\n\nd1 = dN = 0\n\n1 ≤ aj < bj ≤ N\n\n5 ≤ cj ≤ 100\n\n町1から町NへはR分以内で移動できることが保証されている\n\nある2つの町の組に対して2本以上の道があることはない\n\nOutput\n\n町1から町NへR分以内に移動するまでに入手することができる最大のボールの個数を1行で出力せよ。\n\nSample Input 1\n\n5 4 40\n0 1 1 1 0\n1 2 5\n2 3 5\n3 4 5\n4 5 5\n\nSample Output 1\n\n6\n\n経過時間(分)\n\n町の番号\n\nボールの数(個)\n\n0\n\n1\n\n0\n\n5\n\n2\n\n1\n\n10\n\n3\n\n2\n\n15\n\n4\n\n3\n\n20\n\n3\n\n3\n\n25\n\n2\n\n4\n\n30\n\n3\n\n5\n\n35\n\n4\n\n6\n\n40\n\n5\n\n6\n\n※経過時間20分の町3では最後に町3でボールを入手してから15分経過していないのでボールを入手することができない。\n\nSample Input 2\n\n4 3 100\n0 3 1 0\n1 2 5\n2 3 30\n3 4 5\n\nSample Output 2\n\n16\n\n経過時間(分)\n\n町の番号\n\nボールの数(個)\n\n0\n\n1\n\n0\n\n5\n\n2\n\n3\n\n20\n\n2\n\n6\n\n35\n\n2\n\n9\n\n50\n\n2\n\n12\n\n65\n\n2\n\n15\n\n95\n\n3\n\n16\n\n100\n\n4\n\n16\n\nSample Input 3\n\n5 4 50\n0 1 1 10 0\n1 2 10\n2 3 10\n2 4 10\n4 5 10\n\nSample Output 3\n\n22", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6869, "cpu_time_ms": 60, "memory_kb": 24236}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s466478942", "group_id": "codeNet:p01085", "input_text": "import java.util.Scanner;\n\npublic class Main {\n public static void main (String[] args){\n solve1600();\n }\n\n public static void solve1600(){\n Scanner sc = new Scanner(System.in);\n while(true) {\n int m = sc.nextInt();\n int n_min = sc.nextInt();\n int n_max = sc.nextInt();\n if (m == 0 && n_min == 0 && n_max == 0) {\n break;\n }\n\n int[] tokuten = new int[m];\n int[] gap = new int[m-1];\n for (int i = 0; i < m; i++) {\n tokuten[i] = sc.nextInt();\n if(i != 0){\n gap[i-1] = tokuten[i-1] - tokuten[i];\n }\n }\n int answer = 0;\n int gap_max = 0;\n for(int gap_index = n_min - 1; gap_index < n_max; gap_index++){\n if(gap_max <= gap[gap_index]){\n gap_max = gap[gap_index];\n if(gap_max == gap[gap_index]) {\n answer = gap_index + 1;\n } else {\n answer = gap_index;\n }\n }\n }\n System.out.println(answer);\n }\n }\n}", "language": "Java", "metadata": {"date": 1503989506, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p01085.html", "problem_id": "p01085", "resource_group": "high_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/Java/s466478942.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s466478942", "user_id": "u820066026"}, "prompt_components": {"gold_output": "3\n4\n2\n2\n3\n2\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n public static void main (String[] args){\n solve1600();\n }\n\n public static void solve1600(){\n Scanner sc = new Scanner(System.in);\n while(true) {\n int m = sc.nextInt();\n int n_min = sc.nextInt();\n int n_max = sc.nextInt();\n if (m == 0 && n_min == 0 && n_max == 0) {\n break;\n }\n\n int[] tokuten = new int[m];\n int[] gap = new int[m-1];\n for (int i = 0; i < m; i++) {\n tokuten[i] = sc.nextInt();\n if(i != 0){\n gap[i-1] = tokuten[i-1] - tokuten[i];\n }\n }\n int answer = 0;\n int gap_max = 0;\n for(int gap_index = n_min - 1; gap_index < n_max; gap_index++){\n if(gap_max <= gap[gap_index]){\n gap_max = gap[gap_index];\n if(gap_max == gap[gap_index]) {\n answer = gap_index + 1;\n } else {\n answer = gap_index;\n }\n }\n }\n System.out.println(answer);\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": 1216, "cpu_time_ms": 250, "memory_kb": 56636}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s381290958", "group_id": "codeNet:p01133", "input_text": "import java.util.Arrays;\nimport java.util.Collections;\nimport java.util.LinkedList;\nimport java.util.ListIterator;\nimport java.util.PriorityQueue;\nimport java.util.Scanner;\n \npublic class Main {\n \n public static final int MAX = 20;\n public static final double INF = Double.MAX_VALUE;\n \n \n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n \n double[][] dp = new double[1 << MAX][MAX];\n long[][] points = new long[MAX][2];\n double[][] adj = new double[MAX][MAX];\n \n while(true){\n final int n = sc.nextInt();\n \n if(n == 0){\n break;\n }\n \n final long h_x = sc.nextInt();\n final long h_y = sc.nextInt();\n final long g_x = sc.nextInt();\n final long g_y = sc.nextInt();\n \n for(int i = 0; i < n; i++){\n for(int j = 0; j < 2; j++){\n points[i][j] = sc.nextInt();\n }\n }\n \n final int size = n;\n final int limit = 1 << size;\n \n for(int i = 0; i < size; i++){\n for(int j = i + 1; j < size; j++){\n long sum = 0;\n for(int k = 0; k < 2; k++){\n sum += (points[i][k] - points[j][k]) * (points[i][k] - points[j][k]);\n }\n \n adj[i][j] = adj[j][i] = Math.sqrt(sum);\n //System.out.println(adj[i][j]);\n }\n }\n \n for(int S = 0; S < limit; S++){\n for(int i = 0; i < size; i++){\n dp[S][i] = INF;\n }\n }\n for(int i = 0; i < n; i++){\n \tfinal double h_time = Math.sqrt(\n (points[i][0] - h_x) * (points[i][0] - h_x) + \n (points[i][1] - h_y) * (points[i][1] - h_y));\n \t\n \tfinal double g_time = Math.sqrt(\n (points[i][0] - g_x) * (points[i][0] - g_x) + \n (points[i][1] - g_y) * (points[i][1] - g_y));\n \n dp[1 << i][i] = h_time < g_time ? h_time : INF; \n }\n \n for(int S = 0; S < limit; S++){\n LOOP: \n for(int i = 0; i < size; i++){\n if((S & (1 << i)) == 0){\n continue;\n }else if(dp[S][i] == INF){\n continue;\n }\n \n for(int j = 0; j < size; j++){\n if((S & (1 << j)) != 0){\n continue;\n }\n \n final double time = Math.sqrt(\n (points[j][0] - g_x) * (points[j][0] - g_x) + \n (points[j][1] - g_y) * (points[j][1] - g_y));\n final double cost = dp[S][i] + adj[i][j]; \n \n if(time <= cost){\n continue LOOP;\n }\n }\n \n for(int j = 0; j < size; j++){\n if((S & (1 << j)) != 0){\n continue;\n }\n \n final double cost = dp[S][i] + adj[i][j];\n \n dp[S | (1 << j)][j] = Math.min(dp[S | (1 << j)][j], cost);\n }\n }\n }\n \n double min = INF;\n for(int i = 0; i < size; i++){\n //System.out.print(dp[limit - 1][i] + \" \");\n min = Math.min(min, dp[limit - 1][i]);\n }\n \n //System.out.println(min);\n \n System.out.println(min == INF ? \"NO\" : \"YES\");\n }\n }\n \n}", "language": "Java", "metadata": {"date": 1368157708, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p01133.html", "problem_id": "p01133", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p01133/input.txt", "sample_output_relpath": "derived/input_output/data/p01133/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01133/Java/s381290958.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s381290958", "user_id": "u197786702"}, "prompt_components": {"gold_output": "YES\nNO\nNO\n", "input_to_evaluate": "import java.util.Arrays;\nimport java.util.Collections;\nimport java.util.LinkedList;\nimport java.util.ListIterator;\nimport java.util.PriorityQueue;\nimport java.util.Scanner;\n \npublic class Main {\n \n public static final int MAX = 20;\n public static final double INF = Double.MAX_VALUE;\n \n \n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n \n double[][] dp = new double[1 << MAX][MAX];\n long[][] points = new long[MAX][2];\n double[][] adj = new double[MAX][MAX];\n \n while(true){\n final int n = sc.nextInt();\n \n if(n == 0){\n break;\n }\n \n final long h_x = sc.nextInt();\n final long h_y = sc.nextInt();\n final long g_x = sc.nextInt();\n final long g_y = sc.nextInt();\n \n for(int i = 0; i < n; i++){\n for(int j = 0; j < 2; j++){\n points[i][j] = sc.nextInt();\n }\n }\n \n final int size = n;\n final int limit = 1 << size;\n \n for(int i = 0; i < size; i++){\n for(int j = i + 1; j < size; j++){\n long sum = 0;\n for(int k = 0; k < 2; k++){\n sum += (points[i][k] - points[j][k]) * (points[i][k] - points[j][k]);\n }\n \n adj[i][j] = adj[j][i] = Math.sqrt(sum);\n //System.out.println(adj[i][j]);\n }\n }\n \n for(int S = 0; S < limit; S++){\n for(int i = 0; i < size; i++){\n dp[S][i] = INF;\n }\n }\n for(int i = 0; i < n; i++){\n \tfinal double h_time = Math.sqrt(\n (points[i][0] - h_x) * (points[i][0] - h_x) + \n (points[i][1] - h_y) * (points[i][1] - h_y));\n \t\n \tfinal double g_time = Math.sqrt(\n (points[i][0] - g_x) * (points[i][0] - g_x) + \n (points[i][1] - g_y) * (points[i][1] - g_y));\n \n dp[1 << i][i] = h_time < g_time ? h_time : INF; \n }\n \n for(int S = 0; S < limit; S++){\n LOOP: \n for(int i = 0; i < size; i++){\n if((S & (1 << i)) == 0){\n continue;\n }else if(dp[S][i] == INF){\n continue;\n }\n \n for(int j = 0; j < size; j++){\n if((S & (1 << j)) != 0){\n continue;\n }\n \n final double time = Math.sqrt(\n (points[j][0] - g_x) * (points[j][0] - g_x) + \n (points[j][1] - g_y) * (points[j][1] - g_y));\n final double cost = dp[S][i] + adj[i][j]; \n \n if(time <= cost){\n continue LOOP;\n }\n }\n \n for(int j = 0; j < size; j++){\n if((S & (1 << j)) != 0){\n continue;\n }\n \n final double cost = dp[S][i] + adj[i][j];\n \n dp[S | (1 << j)][j] = Math.min(dp[S | (1 << j)][j], cost);\n }\n }\n }\n \n double min = INF;\n for(int i = 0; i < size; i++){\n //System.out.print(dp[limit - 1][i] + \" \");\n min = Math.min(min, dp[limit - 1][i]);\n }\n \n //System.out.println(min);\n \n System.out.println(min == INF ? \"NO\" : \"YES\");\n }\n }\n \n}", "problem_context": "Problem C: Dragon Fantasy\n\n永遠に続くと思われていた平和は突然終わりを告げた。 はるか昔に封印されていた魔王がついに復活を遂げたのである。 だが、今まさに世界が闇に覆われようとしているとき、1 人の勇者が現れた。 そしてその勇者は、世界各地に散らばっている伝説のクリスタルを集める旅に出た。 伝説によると、全てのクリスタルを集めることができたならば、どのような願いでもかなえられるという伝説の龍神を呼び出すことができると伝えられている。 その龍神の力を借りれば魔王を倒すことも可能なはずだ。\n\nクリスタルは世界各地に散らばっている。 勇者はそれらを 1 つずつ、自らの手で集めていく必要がある。 なぜなら、勇者以外の者がクリスタルを手に入れたならば、魔王の手先によって奪われてしまうかもしれないからである。 勇者は、1 日あたりユークリッド距離で 1 だけ移動することができる。\n\nしかし、ここで 1 つの重大な問題がある。 魔王は、常に闇の瘴気をまき散らしており、その瘴気に汚染された場所は人が立ち入ることのできない死の大地と化してしまう。 たとえ勇者であってもその場所に立ち入ることはできない。 さらに、その瘴気は時間とともに同心円状に広まっていくため、 時間の経過とともに勇者の移動できる領域は減少していってしまう。 瘴気は 1 日あたりユークリッド距離 1 だけ広がることが確認されている。 そして、その境界線上にあるクリスタルを勇者は取ることはできない。また、復活したばかりの魔王は力を蓄えるために動かないことも分かっている。\n\n勇者は一刻も早くクリスタルを手に入れなければならない。 しかし、もし全てのクリスタルを手に入れることが不可能であるならば、別の手段を考えなければならないだろう。 そこで、あなたには勇者の初期位置と魔王の復活した場所、そしてクリスタルの存在する位置から、全てのクリスタルを手に入れることができるかどうかを調べるプログラムを作っていただきたい。\n\nちなみに、勇者は疲れない。 そして眠らない。 全てのクリスタルを集めて世界を救うまでは絶えず動き続け、クリスタルを集めるのだ!!\n\nInput\n\n入力は複数のテストケースから構成される。 各テストケースの先頭の行では 5 つの整数 n (0 < n <= 20)、hx 、hy 、dx 、dy が与えられる。\nn はクリスタルの個数、(hx , hy ) は魔王が復活した瞬間での勇者の位置、(dx , dy ) は魔王が復活した位置である。\n後に続く n 行には、各クリスタルの位置を表す 2 つの整数 cx 、cy が与えられる。 入力は n = hx = hy = dx = dy = 0 のときに終了し、これはテストケースには含まない。\n\n入力で与えられる全ての座標は絶対値が 1000 以下の整数であることが保証されている。\n\nOutput\n\n各テストケースについて、全てのクリスタルを集めることができるならば「YES」と、そうでないならば「NO」と出力せよ。\n\nSample Input\n\n2 0 0 10 10\n1 1\n4 4\n2 0 0 10 10\n1 1\n6 6\n2 0 0 10 10\n1 1\n5 5\n0 0 0 0 0\n\nOutput for the Sample Input\n\nYES\nNO\nNO", "sample_input": "2 0 0 10 10\n1 1\n4 4\n2 0 0 10 10\n1 1\n6 6\n2 0 0 10 10\n1 1\n5 5\n0 0 0 0 0\n"}, "reference_outputs": ["YES\nNO\nNO\n"], "source_document_id": "p01133", "source_text": "Problem C: Dragon Fantasy\n\n永遠に続くと思われていた平和は突然終わりを告げた。 はるか昔に封印されていた魔王がついに復活を遂げたのである。 だが、今まさに世界が闇に覆われようとしているとき、1 人の勇者が現れた。 そしてその勇者は、世界各地に散らばっている伝説のクリスタルを集める旅に出た。 伝説によると、全てのクリスタルを集めることができたならば、どのような願いでもかなえられるという伝説の龍神を呼び出すことができると伝えられている。 その龍神の力を借りれば魔王を倒すことも可能なはずだ。\n\nクリスタルは世界各地に散らばっている。 勇者はそれらを 1 つずつ、自らの手で集めていく必要がある。 なぜなら、勇者以外の者がクリスタルを手に入れたならば、魔王の手先によって奪われてしまうかもしれないからである。 勇者は、1 日あたりユークリッド距離で 1 だけ移動することができる。\n\nしかし、ここで 1 つの重大な問題がある。 魔王は、常に闇の瘴気をまき散らしており、その瘴気に汚染された場所は人が立ち入ることのできない死の大地と化してしまう。 たとえ勇者であってもその場所に立ち入ることはできない。 さらに、その瘴気は時間とともに同心円状に広まっていくため、 時間の経過とともに勇者の移動できる領域は減少していってしまう。 瘴気は 1 日あたりユークリッド距離 1 だけ広がることが確認されている。 そして、その境界線上にあるクリスタルを勇者は取ることはできない。また、復活したばかりの魔王は力を蓄えるために動かないことも分かっている。\n\n勇者は一刻も早くクリスタルを手に入れなければならない。 しかし、もし全てのクリスタルを手に入れることが不可能であるならば、別の手段を考えなければならないだろう。 そこで、あなたには勇者の初期位置と魔王の復活した場所、そしてクリスタルの存在する位置から、全てのクリスタルを手に入れることができるかどうかを調べるプログラムを作っていただきたい。\n\nちなみに、勇者は疲れない。 そして眠らない。 全てのクリスタルを集めて世界を救うまでは絶えず動き続け、クリスタルを集めるのだ!!\n\nInput\n\n入力は複数のテストケースから構成される。 各テストケースの先頭の行では 5 つの整数 n (0 < n <= 20)、hx 、hy 、dx 、dy が与えられる。\nn はクリスタルの個数、(hx , hy ) は魔王が復活した瞬間での勇者の位置、(dx , dy ) は魔王が復活した位置である。\n後に続く n 行には、各クリスタルの位置を表す 2 つの整数 cx 、cy が与えられる。 入力は n = hx = hy = dx = dy = 0 のときに終了し、これはテストケースには含まない。\n\n入力で与えられる全ての座標は絶対値が 1000 以下の整数であることが保証されている。\n\nOutput\n\n各テストケースについて、全てのクリスタルを集めることができるならば「YES」と、そうでないならば「NO」と出力せよ。\n\nSample Input\n\n2 0 0 10 10\n1 1\n4 4\n2 0 0 10 10\n1 1\n6 6\n2 0 0 10 10\n1 1\n5 5\n0 0 0 0 0\n\nOutput for the Sample Input\n\nYES\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": 4151, "cpu_time_ms": 10760, "memory_kb": 237644}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s135005134", "group_id": "codeNet:p01137", "input_text": "import java.io.PrintWriter;\nimport java.util.Scanner;\n\npublic class Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tPrintWriter pr = new PrintWriter(System.out);\n\t\twhile(true){\n\t\t\tint e = sc.nextInt();\n\t\t\tif(e==0) break;\n\t\t\tint z = 0;\n\t\t\tint y = 0;\n\t\t\tint x = e - y*y - z*z*z;\n\t\t\tint min = x + y + z;\n\t\t\twhile(z*z*z<=e){\n\t\t\t\twhile(y*y<=e-z*z*z){\n\t\t\t\t\tx = e - y*y - z*z*z;\n\t\t\t\t\tint tmp = x + y + z;\n\t\t\t\t\tif(tmp map;\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n map = permutation9();\n int n = sc.nextInt();\n for (int i = 0; i < n; i++) {\n int[] num = new int[9];\n int[] color = new int[9];\n for (int j = 0; j < 9; j++)\n num[j] = sc.nextInt();\n for (int j = 0; j < 9; j++) {\n String s = sc.next();\n if (s.equals(\"R\")) color[j] = 0;\n else if (s.equals(\"G\")) color[j] = 1;\n else if (s.equals(\"B\")) color[j] = 2;\n }\n System.out.println(check(num, color));\n }\n }\n\n public static int check(int[] num, int[] color) {\n for (int key : map.keySet()) {\n int[] li = map.get(key);\n for (int m = 0; m < 3; m++) {\n if (color[li[3 * m + 0]] == color[li[3 * m + 1]] && color[li[3 * m + 0]] == color[li[3 * m + 2]]) {\n if ((num[li[3 * m + 0]] == num[li[3 * m + 1]] && num[li[3 * m + 0]] == num[li[3 * m + 2]])\n || (num[li[3 * m + 0]] == 1 + num[li[3 * m + 1]] && num[li[3 * m + 0]] == 2 + num[li[3 * m + 2]])\n || (num[li[3 * m + 0]] == 2 + num[li[3 * m + 1]] && num[li[3 * m + 0]] == 1 + num[li[3 * m + 2]])\n || (num[li[3 * m + 0]] == 1 + num[li[3 * m + 1]] && num[li[3 * m + 0]] == -1 + num[li[3 * m + 2]])\n || (num[li[3 * m + 0]] == -1 + num[li[3 * m + 1]] && num[li[3 * m + 0]] == 1 + num[li[3 * m + 2]])\n || (num[li[3 * m + 0]] == -2 + num[li[3 * m + 1]] && num[li[3 * m + 0]] == -1 + num[li[3 * m + 2]])\n || (num[li[3 * m + 0]] == -1 + num[li[3 * m + 1]] && num[li[3 * m + 0]] == -2 + num[li[3 * m + 2]])) {\n if(m!=2)continue;\n return 1;\n }\n else break;\n }\n else break;\n }\n\n }\n return 0;\n }\n\n public static HashMap permutation9() {\n int[] a = {0, 1, 2, 3, 4, 5, 6, 7, 8};\n Queue que = new ArrayDeque();\n HashMap map = new HashMap();\n que.add(a);\n map.put(getkey(a), a);\n while (que.isEmpty() == false) {\n int[] tt = que.remove();\n for (int i = 0; i < 9; i++) {\n for (int j = i + 1; j < 9; j++) {\n int[] t = tt.clone();\n int b = t[i] + 0;\n t[i] = t[j] + 0;\n t[j] = b;\n int key = getkey(t);\n if (!map.containsKey(key)) {\n que.add(t);\n map.put(key, t);\n }\n }\n }\n }\n return map;\n }\n\n public static int getkey(int[] a) {\n int key = 0, b = 1;\n for (int i = 0; i < 9; i++) {\n key += a[i] * b;\n b *= 10;\n }\n return key;\n }\n}\n", "language": "Java", "metadata": {"date": 1525676142, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p01225.html", "problem_id": "p01225", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p01225/input.txt", "sample_output_relpath": "derived/input_output/data/p01225/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01225/Java/s882548446.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s882548446", "user_id": "u947087252"}, "prompt_components": {"gold_output": "1\n0\n0\n0\n1\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n static HashMap map;\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n map = permutation9();\n int n = sc.nextInt();\n for (int i = 0; i < n; i++) {\n int[] num = new int[9];\n int[] color = new int[9];\n for (int j = 0; j < 9; j++)\n num[j] = sc.nextInt();\n for (int j = 0; j < 9; j++) {\n String s = sc.next();\n if (s.equals(\"R\")) color[j] = 0;\n else if (s.equals(\"G\")) color[j] = 1;\n else if (s.equals(\"B\")) color[j] = 2;\n }\n System.out.println(check(num, color));\n }\n }\n\n public static int check(int[] num, int[] color) {\n for (int key : map.keySet()) {\n int[] li = map.get(key);\n for (int m = 0; m < 3; m++) {\n if (color[li[3 * m + 0]] == color[li[3 * m + 1]] && color[li[3 * m + 0]] == color[li[3 * m + 2]]) {\n if ((num[li[3 * m + 0]] == num[li[3 * m + 1]] && num[li[3 * m + 0]] == num[li[3 * m + 2]])\n || (num[li[3 * m + 0]] == 1 + num[li[3 * m + 1]] && num[li[3 * m + 0]] == 2 + num[li[3 * m + 2]])\n || (num[li[3 * m + 0]] == 2 + num[li[3 * m + 1]] && num[li[3 * m + 0]] == 1 + num[li[3 * m + 2]])\n || (num[li[3 * m + 0]] == 1 + num[li[3 * m + 1]] && num[li[3 * m + 0]] == -1 + num[li[3 * m + 2]])\n || (num[li[3 * m + 0]] == -1 + num[li[3 * m + 1]] && num[li[3 * m + 0]] == 1 + num[li[3 * m + 2]])\n || (num[li[3 * m + 0]] == -2 + num[li[3 * m + 1]] && num[li[3 * m + 0]] == -1 + num[li[3 * m + 2]])\n || (num[li[3 * m + 0]] == -1 + num[li[3 * m + 1]] && num[li[3 * m + 0]] == -2 + num[li[3 * m + 2]])) {\n if(m!=2)continue;\n return 1;\n }\n else break;\n }\n else break;\n }\n\n }\n return 0;\n }\n\n public static HashMap permutation9() {\n int[] a = {0, 1, 2, 3, 4, 5, 6, 7, 8};\n Queue que = new ArrayDeque();\n HashMap map = new HashMap();\n que.add(a);\n map.put(getkey(a), a);\n while (que.isEmpty() == false) {\n int[] tt = que.remove();\n for (int i = 0; i < 9; i++) {\n for (int j = i + 1; j < 9; j++) {\n int[] t = tt.clone();\n int b = t[i] + 0;\n t[i] = t[j] + 0;\n t[j] = b;\n int key = getkey(t);\n if (!map.containsKey(key)) {\n que.add(t);\n map.put(key, t);\n }\n }\n }\n }\n return map;\n }\n\n public static int getkey(int[] a) {\n int key = 0, b = 1;\n for (int i = 0; i < 9; i++) {\n key += a[i] * b;\n b *= 10;\n }\n return key;\n }\n}\n", "problem_context": "Problem C: ラミー\n\nあなたの友達は最近 UT-Rummy というカードゲームを思いついた.\n\nこのゲームで使うカードには赤・緑・青のいずれかの色と1から9までのいずれかの番号が\nつけられている.\nこのゲームのプレイヤーはそれぞれ9枚の手札を持ち,\n自分のターンに手札から1枚選んで捨てて,\n代わりに山札から1枚引いてくるということを繰り返す.\nこのように順番にターンを進めていき,\n最初に手持ちのカードに3枚ずつ3つの「セット」を作ったプレイヤーが勝ちとなる.\nセットとは,同じ色の3枚のカードからなる組で,すべて同じ数を持っているか\n連番をなしているもののことを言う.\n連番に関しては,番号の巡回は認められない.\n例えば,7, 8, 9は連番であるが 9, 1, 2は連番ではない.\n\nあなたの友達はこのゲームをコンピュータゲームとして売り出すという計画を立てて,\nその一環としてあなたに勝利条件の判定部分を作成して欲しいと頼んできた.\nあなたの仕事は,手札が勝利条件を満たしているかどうかを判定する\nプログラムを書くことである.\n\nInput\n\n入力の1行目にはデータセット数を表す数 T\n(0 < T ≤ 50) が与えられる.\nこの行に引き続き T 個のデータセットが与えられる.\n\n各データセットは2行からなり,\n1行目には i 番目\n(i = 1, 2, ..., 9)\nのカードの数字 ni\nがそれぞれスペースで区切られて与えられ,\n2行目には i 番目のカードの色を表す文字\nci\nがそれぞれスペースで区切られて与えられる.\nカードの数字\nni\nは 1 ≤ ni ≤ 9\nを満たす整数であり,\nカードの色 ci\nはそれぞれ “R”, “G”,\n“B”\nのいずれかの文字である.\n\n1つのデータセット内に色と数字がともに同じカードが5枚以上出現することはない.\n\nOutput\n\n各データセットにつき,勝利条件を満たしていれば\n“1”,\nそうでなければ “0” と出力せよ.\n\nSample Input\n\n5\n1 2 3 3 4 5 7 7 7\nR R R R R R G G G\n1 2 2 3 4 4 4 4 5\nR R R R R R R R R\n1 2 3 4 4 4 5 5 5\nR R B R R R R R R\n1 1 1 3 4 5 6 6 6\nR R B G G G R R R\n2 2 2 3 3 3 1 1 1\nR G B R G B R G B\n\nOutput for the Sample Input\n\n1\n0\n0\n0\n1", "sample_input": "5\n1 2 3 3 4 5 7 7 7\nR R R R R R G G G\n1 2 2 3 4 4 4 4 5\nR R R R R R R R R\n1 2 3 4 4 4 5 5 5\nR R B R R R R R R\n1 1 1 3 4 5 6 6 6\nR R B G G G R R R\n2 2 2 3 3 3 1 1 1\nR G B R G B R G B\n"}, "reference_outputs": ["1\n0\n0\n0\n1\n"], "source_document_id": "p01225", "source_text": "Problem C: ラミー\n\nあなたの友達は最近 UT-Rummy というカードゲームを思いついた.\n\nこのゲームで使うカードには赤・緑・青のいずれかの色と1から9までのいずれかの番号が\nつけられている.\nこのゲームのプレイヤーはそれぞれ9枚の手札を持ち,\n自分のターンに手札から1枚選んで捨てて,\n代わりに山札から1枚引いてくるということを繰り返す.\nこのように順番にターンを進めていき,\n最初に手持ちのカードに3枚ずつ3つの「セット」を作ったプレイヤーが勝ちとなる.\nセットとは,同じ色の3枚のカードからなる組で,すべて同じ数を持っているか\n連番をなしているもののことを言う.\n連番に関しては,番号の巡回は認められない.\n例えば,7, 8, 9は連番であるが 9, 1, 2は連番ではない.\n\nあなたの友達はこのゲームをコンピュータゲームとして売り出すという計画を立てて,\nその一環としてあなたに勝利条件の判定部分を作成して欲しいと頼んできた.\nあなたの仕事は,手札が勝利条件を満たしているかどうかを判定する\nプログラムを書くことである.\n\nInput\n\n入力の1行目にはデータセット数を表す数 T\n(0 < T ≤ 50) が与えられる.\nこの行に引き続き T 個のデータセットが与えられる.\n\n各データセットは2行からなり,\n1行目には i 番目\n(i = 1, 2, ..., 9)\nのカードの数字 ni\nがそれぞれスペースで区切られて与えられ,\n2行目には i 番目のカードの色を表す文字\nci\nがそれぞれスペースで区切られて与えられる.\nカードの数字\nni\nは 1 ≤ ni ≤ 9\nを満たす整数であり,\nカードの色 ci\nはそれぞれ “R”, “G”,\n“B”\nのいずれかの文字である.\n\n1つのデータセット内に色と数字がともに同じカードが5枚以上出現することはない.\n\nOutput\n\n各データセットにつき,勝利条件を満たしていれば\n“1”,\nそうでなければ “0” と出力せよ.\n\nSample Input\n\n5\n1 2 3 3 4 5 7 7 7\nR R R R R R G G G\n1 2 2 3 4 4 4 4 5\nR R R R R R R R R\n1 2 3 4 4 4 5 5 5\nR R B R R R R R R\n1 1 1 3 4 5 6 6 6\nR R B G G G R R R\n2 2 2 3 3 3 1 1 1\nR G B R G B R G B\n\nOutput for the Sample Input\n\n1\n0\n0\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": 3179, "cpu_time_ms": 2350, "memory_kb": 337780}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s839724848", "group_id": "codeNet:p01268", "input_text": "import java.util.*;\npublic class Main{\n public static void main(String[] args){\n\tnew Main().run();\n }\n Scanner sc = new Scanner(System.in);\n\n int n, m;\n boolean[] prime;\n int[] sum;\n \n void run(){\n\tprime = new boolean[1000000];\n\tsetP();\n\twhile(sc.hasNext()){\n\t n = sc.nextInt();\n\t m = sc.nextInt();\n\t if(n==-1 && m==-1) break;\n\t \n\t int p = 0;\n\t sum = new int[100000];\n\t Arrays.fill(sum, Integer.MAX_VALUE);\n\t for(int i=n+1; i=0; i--){\n\t\t int sabun = b[i]-a[i];\n\t\t char t;\n\t\t message[a[i]-1] += sabun;\n\t\t if(message[a[i]-1] > 'z')\n\t\t\tmessage[a[i]-1] -= 26;\n\t\t message[b[i]-1] += sabun;\n\t\t if(message[b[i]-1] > 'z')\n\t\t\tmessage[b[i]-1] -= 26;\n\t\t t = message[a[i]-1];\n\t\t message[a[i]-1] = message[b[i]-1];\n\t\t message[b[i]-1] = t;\n\t\t}\n\t\tStringBuilder bb = new StringBuilder();\n\t\tfor(int i=0; i=0; i--){\n\t\t int sabun = b[i]-a[i];\n\t\t char t;\n\t\t message[a[i]-1] += sabun;\n\t\t if(message[a[i]-1] > 'z')\n\t\t\tmessage[a[i]-1] -= 26;\n\t\t message[b[i]-1] += sabun;\n\t\t if(message[b[i]-1] > 'z')\n\t\t\tmessage[b[i]-1] -= 26;\n\t\t t = message[a[i]-1];\n\t\t message[a[i]-1] = message[b[i]-1];\n\t\t message[b[i]-1] = t;\n\t\t}\n\t\tStringBuilder bb = new StringBuilder();\n\t\tfor(int i=0; i= 6 && input.matches(\".*[a-z]+.*\") && input.matches(\".*[A-Z]+.*\") && input.matches(\".*[0-9]+.*\");\n\t\t\n\t\tSystem.out.println(flag ? \"VALID\" : \"INVALID\");\n\t}\n\n}", "language": "Java", "metadata": {"date": 1379239677, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p01634.html", "problem_id": "p01634", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p01634/input.txt", "sample_output_relpath": "derived/input_output/data/p01634/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01634/Java/s184820067.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s184820067", "user_id": "u197786702"}, "prompt_components": {"gold_output": "INVALID\n", "input_to_evaluate": "import java.util.Arrays;\nimport java.util.Collections;\nimport java.util.LinkedList;\nimport java.util.ListIterator;\nimport java.util.PriorityQueue;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tString input = sc.next();\n\t\t\n\t\tboolean flag = input.length() >= 6 && input.matches(\".*[a-z]+.*\") && input.matches(\".*[A-Z]+.*\") && input.matches(\".*[0-9]+.*\");\n\t\t\n\t\tSystem.out.println(flag ? \"VALID\" : \"INVALID\");\n\t}\n\n}", "problem_context": "Problem A: Register Phase\n\nインターネットをより安全に活用するために、堅牢なパスワードを使うことは重要である。それと同時に、同じパスワードを使い回さないことも非常に重要である。どんなに強いパスワードを使っていても、一箇所で平文が流出してしまえば、破るのは非常に容易になってしまう。もちろん、全てのアプリケーションがパスワードをハッシュ化し、SALTを適切に使用していれば流出してもそのような被害は発生しないが、いまだにパスワードを平文で保存しているアプリケーションはあるのである。\n\nさて、そろそろコンテストが始まる。チームのアカウントを登録しなくては…。\n\n問題\n\nパスワードを表す文字列が与えられる。その文字列が以下の条件を全て満たすか調べ、満たす場合は\"VALID\"と、ひとつでも満たさない項目がある場合は\"INVALID\"と出力せよ。\n\n文字列長が6以上である\n\n数字を一つ以上含んでいる\n\n大文字英字を一つ以上含んでいる\n\n小文字英字を一つ以上含んでいる\n\n入力\n\nパスワードを表す文字列が一行に与えられる。\n\n出力\n\nパスワードを表す文字列が問題の条件を全て満たすなら\"VALID\"と、満たさない条件があるなら\"INVALID\"と、一行に出力せよ。\n\n制約\n\nパスワードを表す文字列は1文字以上20文字以内である\n\nパスワードを表す文字列は英大文字、英小文字、数字のみを含む\n\n入出力例\n\n入力1\n\npassword\n\n出力1\n\nINVALID\n\n世界中で広く使われているパスワードである。\n\n入力2\n\nAizuCamp2013\n\n出力2\n\nVALID\n\n素晴しいパスワードである。\n\n入力3\n\n1234\n\n出力3\n\nINVALID\n\n暗証番号として広く使われている。\n\n入力4\n\nNaBiO3\n\n出力4\n\nVALID\n\nぎりぎり6文字以上である。", "sample_input": "password\n"}, "reference_outputs": ["INVALID\n"], "source_document_id": "p01634", "source_text": "Problem A: Register Phase\n\nインターネットをより安全に活用するために、堅牢なパスワードを使うことは重要である。それと同時に、同じパスワードを使い回さないことも非常に重要である。どんなに強いパスワードを使っていても、一箇所で平文が流出してしまえば、破るのは非常に容易になってしまう。もちろん、全てのアプリケーションがパスワードをハッシュ化し、SALTを適切に使用していれば流出してもそのような被害は発生しないが、いまだにパスワードを平文で保存しているアプリケーションはあるのである。\n\nさて、そろそろコンテストが始まる。チームのアカウントを登録しなくては…。\n\n問題\n\nパスワードを表す文字列が与えられる。その文字列が以下の条件を全て満たすか調べ、満たす場合は\"VALID\"と、ひとつでも満たさない項目がある場合は\"INVALID\"と出力せよ。\n\n文字列長が6以上である\n\n数字を一つ以上含んでいる\n\n大文字英字を一つ以上含んでいる\n\n小文字英字を一つ以上含んでいる\n\n入力\n\nパスワードを表す文字列が一行に与えられる。\n\n出力\n\nパスワードを表す文字列が問題の条件を全て満たすなら\"VALID\"と、満たさない条件があるなら\"INVALID\"と、一行に出力せよ。\n\n制約\n\nパスワードを表す文字列は1文字以上20文字以内である\n\nパスワードを表す文字列は英大文字、英小文字、数字のみを含む\n\n入出力例\n\n入力1\n\npassword\n\n出力1\n\nINVALID\n\n世界中で広く使われているパスワードである。\n\n入力2\n\nAizuCamp2013\n\n出力2\n\nVALID\n\n素晴しいパスワードである。\n\n入力3\n\n1234\n\n出力3\n\nINVALID\n\n暗証番号として広く使われている。\n\n入力4\n\nNaBiO3\n\n出力4\n\nVALID\n\nぎりぎり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": 499, "cpu_time_ms": 50, "memory_kb": 17324}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s735159704", "group_id": "codeNet:p01635", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tstatic final int Big_Num = 1000000000;\n\tstatic long mul(int n,int h) {\n\t\tint ans = n;\n\t\tif(h==0)\n\t\t\treturn 1;\n\t\tif(h==1)\n\t\t\treturn ans;\n\t\tfor(int i=0;i 0) \n\t\t\t\tSystem.out.println(ans*t);\n\t\t\telse\n\t\t\t\tSystem.out.println(\"TLE\");\n\t}\n}\n", "language": "Java", "metadata": {"date": 1530595909, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p01635.html", "problem_id": "p01635", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p01635/input.txt", "sample_output_relpath": "derived/input_output/data/p01635/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01635/Java/s735159704.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s735159704", "user_id": "u935042117"}, "prompt_components": {"gold_output": "101010000\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tstatic final int Big_Num = 1000000000;\n\tstatic long mul(int n,int h) {\n\t\tint ans = n;\n\t\tif(h==0)\n\t\t\treturn 1;\n\t\tif(h==1)\n\t\t\treturn ans;\n\t\tfor(int i=0;i 0) \n\t\t\t\tSystem.out.println(ans*t);\n\t\t\telse\n\t\t\t\tSystem.out.println(\"TLE\");\n\t}\n}\n", "problem_context": "MathJax.Hub.Config({\ntex2jax: { inlineMath: [['\\\\(','\\\\)']] }\n});\n\nProblem B: Time Complexity\n\nICPC World Finals 1日目\n\nプログラミングコンテストではプログラムの実行時間を把握する事が重要だ。\n実行時間の見積もりを誤り、 時間制限をオーバーしてしまうコードを書いてしまうと、 そのぶん時間をロスしてしまう。\nICPCのようにコンピュータが1台しか使えないチーム戦ではなおさらである。\n\nそこで、ICPC World\nFinalsを前に控えたティー氏はプログラムの実行時間を暗算で求める訓練を始めることにした。\n「logは定数のようなもの」なので、まずは多項式に取り組むとしよう。\n\n問題\n\nある問題の答えを計算するプログラムと、それを実行するコンピュータがある。\n問題の入力を表す正整数\\(n\\)、 入力\\(n\\)に応じてプログラム中で実行される命令の数を表す多項式\\(f(n)\\)、\nコンピュータの1命令の実行時間\\(T\\)[ナノ秒](=\\( 10^{-9} \\)[秒])が与えられる。\n多項式\\(f(n)\\)の回数だけ命令を実行した時のプログラムの総実行時間が1秒「以下」であるかを判定し、\n1秒「以下」であるならば総実行時間を求めよ。\n\n入力\n\nn T\nf(n)\n\n1行目に 問題の入力を表す正整数\\(n\\)と 1命令の実行時間[ナノ秒]を表す整数\\(T\\)が空白区切りで与えられる。\n2行目に実行される命令の数を表す多項式\\(f(n)\\)が与えられる。\n\n多項式\\( f(n) \\)は以下のBNFで表される。\n\n ::= \"+\" | \n ::= \"n^\" \n ::= \"0\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" | \"8\" | \"9\"\n\nここで各単項式n^kは、\\(n\\)の\\(k\\)乗を表す。\n\n出力\n\nプログラムの総実行時間が1秒「以下」である場合には総実行時間を[ナノ秒]単位で、1秒を「超過」する場合には\"TLE\"を1行に出力せよ。\n\n制約\n\n\\( 1 \\leq n \\leq 10^{9}(= 1000000000) \\)\n\n\\( 1 \\leq T \\leq 10^{9}(= 1000000000) \\)\n\n多項式\\( f(n) \\)の次数は0以上9以下、単項式の数は1以上10以下\n\n入出力例\n\n入力1\n\n100 100\nn^1+n^2+n^3\n\n出力1\n\n101010000\n\n総実行時間は\\( (100^{1} + 100^{2} + 100^{3}) \\times 100 \\)[ナノ秒]である。\n\n入力2\n\n1000 1\nn^3+n^0\n\n出力2\n\nTLE\n\n総実行時間は\\( 1000^{3} + 1000^{0} = 10^{9}+1 \\)[ナノ秒]であり、1[秒]を超えてしまう。\n\n入力3\n\n100000000 100000000\nn^3\n\n出力3\n\nTLE\n\n総実行時間は\\( (10^{8})^{3} \\times 10^{8} = 10^{32} \\)[ナノ秒]である。", "sample_input": "n T\nf(n)\n"}, "reference_outputs": ["101010000\n"], "source_document_id": "p01635", "source_text": "MathJax.Hub.Config({\ntex2jax: { inlineMath: [['\\\\(','\\\\)']] }\n});\n\nProblem B: Time Complexity\n\nICPC World Finals 1日目\n\nプログラミングコンテストではプログラムの実行時間を把握する事が重要だ。\n実行時間の見積もりを誤り、 時間制限をオーバーしてしまうコードを書いてしまうと、 そのぶん時間をロスしてしまう。\nICPCのようにコンピュータが1台しか使えないチーム戦ではなおさらである。\n\nそこで、ICPC World\nFinalsを前に控えたティー氏はプログラムの実行時間を暗算で求める訓練を始めることにした。\n「logは定数のようなもの」なので、まずは多項式に取り組むとしよう。\n\n問題\n\nある問題の答えを計算するプログラムと、それを実行するコンピュータがある。\n問題の入力を表す正整数\\(n\\)、 入力\\(n\\)に応じてプログラム中で実行される命令の数を表す多項式\\(f(n)\\)、\nコンピュータの1命令の実行時間\\(T\\)[ナノ秒](=\\( 10^{-9} \\)[秒])が与えられる。\n多項式\\(f(n)\\)の回数だけ命令を実行した時のプログラムの総実行時間が1秒「以下」であるかを判定し、\n1秒「以下」であるならば総実行時間を求めよ。\n\n入力\n\nn T\nf(n)\n\n1行目に 問題の入力を表す正整数\\(n\\)と 1命令の実行時間[ナノ秒]を表す整数\\(T\\)が空白区切りで与えられる。\n2行目に実行される命令の数を表す多項式\\(f(n)\\)が与えられる。\n\n多項式\\( f(n) \\)は以下のBNFで表される。\n\n ::= \"+\" | \n ::= \"n^\" \n ::= \"0\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" | \"8\" | \"9\"\n\nここで各単項式n^kは、\\(n\\)の\\(k\\)乗を表す。\n\n出力\n\nプログラムの総実行時間が1秒「以下」である場合には総実行時間を[ナノ秒]単位で、1秒を「超過」する場合には\"TLE\"を1行に出力せよ。\n\n制約\n\n\\( 1 \\leq n \\leq 10^{9}(= 1000000000) \\)\n\n\\( 1 \\leq T \\leq 10^{9}(= 1000000000) \\)\n\n多項式\\( f(n) \\)の次数は0以上9以下、単項式の数は1以上10以下\n\n入出力例\n\n入力1\n\n100 100\nn^1+n^2+n^3\n\n出力1\n\n101010000\n\n総実行時間は\\( (100^{1} + 100^{2} + 100^{3}) \\times 100 \\)[ナノ秒]である。\n\n入力2\n\n1000 1\nn^3+n^0\n\n出力2\n\nTLE\n\n総実行時間は\\( 1000^{3} + 1000^{0} = 10^{9}+1 \\)[ナノ秒]であり、1[秒]を超えてしまう。\n\n入力3\n\n100000000 100000000\nn^3\n\n出力3\n\nTLE\n\n総実行時間は\\( (10^{8})^{3} \\times 10^{8} = 10^{32} \\)[ナノ秒]である。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 916, "cpu_time_ms": 70, "memory_kb": 26360}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s509295475", "group_id": "codeNet:p01646", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tstatic Scanner sc = new Scanner(System.in);\n\tstatic String[] str;\n\tstatic int N;\n\tstatic boolean[][] g;\n\n\tpublic static void main(String[] args) throws Exception {\n\t\twhile (true) {\n\t\t\tN = sc.nextInt();\n\t\t\tif (N == 0) break;\n\t\t\tstr = new String[N];\n\t\t\tfor (int i = 0; i < N; ++i) {\n\t\t\t\tstr[i] = sc.next();\n\t\t\t}\n\t\t\tSystem.out.println(solve() ? \"yes\" : \"no\");\n\t\t}\n\t}\n\n\tstatic boolean solve() {\n\t\tg = new boolean[26][26];\n\t\tif (!construct(0, N, 0)) {\n\t\t\treturn false;\n\t\t}\n\t\tfor (int i = 0; i < 26; ++i) {\n\t\t\tboolean[] visited = new boolean[26];\n\t\t\tif (!dfs(i, visited)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tstatic boolean dfs(int pos, boolean[] visited) {\n\t\tif (visited[pos]) return false;\n\t\tvisited[pos] = true;\n\t\tfor (int i = 0; i < 26; ++i) {\n\t\t\tif (g[pos][i]) {\n\t\t\t\tif (!dfs(i, visited)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tvisited[pos] = false;\n\t\treturn true;\n\t}\n\n\tstatic boolean construct(int s, int e, int pos) {\n\t\t// System.out.println(s + \" \" + e + \" \" + pos);\n\t\tif (e - s == 1) return true;\n\t\twhile (s < e && str[s].length() == pos) {\n\t\t\t++s;\n\t\t}\n\t\tif (s >= e - 1) return true;\n\t\tint prev = s;\n\t\tfor (int i = s + 1;; ++i) {\n\t\t\tif (i == e) {\n\t\t\t\tif (!construct(prev, i, pos + 1)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (str[i].length() == pos) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (str[i].charAt(pos) != str[prev].charAt(pos)) {\n\t\t\t\tg[str[prev].charAt(pos) - 'a'][str[i].charAt(pos) - 'a'] = true;\n\t\t\t\t// System.out.println(s + \" \" + e + \" \" + pos + \" \" + str[prev].charAt(pos) + \" \" + str[i].charAt(pos));\n\t\t\t\tif (!construct(prev, i, pos + 1)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tprev = i;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n}", "language": "Java", "metadata": {"date": 1415453025, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p01646.html", "problem_id": "p01646", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p01646/input.txt", "sample_output_relpath": "derived/input_output/data/p01646/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01646/Java/s509295475.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s509295475", "user_id": "u599539865"}, "prompt_components": {"gold_output": "yes\nno\nyes\nno\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tstatic Scanner sc = new Scanner(System.in);\n\tstatic String[] str;\n\tstatic int N;\n\tstatic boolean[][] g;\n\n\tpublic static void main(String[] args) throws Exception {\n\t\twhile (true) {\n\t\t\tN = sc.nextInt();\n\t\t\tif (N == 0) break;\n\t\t\tstr = new String[N];\n\t\t\tfor (int i = 0; i < N; ++i) {\n\t\t\t\tstr[i] = sc.next();\n\t\t\t}\n\t\t\tSystem.out.println(solve() ? \"yes\" : \"no\");\n\t\t}\n\t}\n\n\tstatic boolean solve() {\n\t\tg = new boolean[26][26];\n\t\tif (!construct(0, N, 0)) {\n\t\t\treturn false;\n\t\t}\n\t\tfor (int i = 0; i < 26; ++i) {\n\t\t\tboolean[] visited = new boolean[26];\n\t\t\tif (!dfs(i, visited)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tstatic boolean dfs(int pos, boolean[] visited) {\n\t\tif (visited[pos]) return false;\n\t\tvisited[pos] = true;\n\t\tfor (int i = 0; i < 26; ++i) {\n\t\t\tif (g[pos][i]) {\n\t\t\t\tif (!dfs(i, visited)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tvisited[pos] = false;\n\t\treturn true;\n\t}\n\n\tstatic boolean construct(int s, int e, int pos) {\n\t\t// System.out.println(s + \" \" + e + \" \" + pos);\n\t\tif (e - s == 1) return true;\n\t\twhile (s < e && str[s].length() == pos) {\n\t\t\t++s;\n\t\t}\n\t\tif (s >= e - 1) return true;\n\t\tint prev = s;\n\t\tfor (int i = s + 1;; ++i) {\n\t\t\tif (i == e) {\n\t\t\t\tif (!construct(prev, i, pos + 1)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (str[i].length() == pos) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (str[i].charAt(pos) != str[prev].charAt(pos)) {\n\t\t\t\tg[str[prev].charAt(pos) - 'a'][str[i].charAt(pos) - 'a'] = true;\n\t\t\t\t// System.out.println(s + \" \" + e + \" \" + pos + \" \" + str[prev].charAt(pos) + \" \" + str[i].charAt(pos));\n\t\t\t\tif (!construct(prev, i, pos + 1)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tprev = i;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n}", "problem_context": "Problem Statement\n\nWe found a dictionary of the Ancient Civilization Mayo (ACM) during excavation of the ruins.\nAfter analysis of the dictionary, we revealed they used a language that had not more than 26 letters.\nSo one of us mapped each letter to a different English alphabet and typed all the words in the dictionary into a computer.\n\nHow the words are ordered in the dictionary, especially whether they are ordered lexicographically, is an interesting topic to many people.\nAs a good programmer, you are requested to write a program to judge whether we can consider the words to be sorted in a lexicographical order.\n\nNote:\nIn a lexicographical order, a word always precedes other words it is a prefix of.\nFor example, ab\nprecedes abc,\nabde, and so on.\n\nInput\n\nThe input consists of multiple datasets. Each dataset is formatted as follows:\n\nn\nstring_1\n...\nstring_n\n\nEach dataset consists of n+1 lines.\nThe first line of each dataset contains an integer that indicates n (1 \\leq n \\leq 500).\nThe i-th line of the following n lines contains string_i, which consists of up to 10 English lowercase letters.\n\nThe end of the input is 0, and this should not be processed.\n\nOutput\n\nPrint either yes or\nno in a line for each dataset, in the order of the input.\nIf all words in the dataset can be considered to be ordered lexicographically, print yes.\nOtherwise, print no.\n\nSample Input\n\n4\ncba\ncab\nb\na\n3\nbca\nab\na\n5\nabc\nacb\nb\nc\nc\n5\nabc\nacb\nc\nb\nb\n0\n\nOutput for the Sample Input\n\nyes\nno\nyes\nno", "sample_input": "4\ncba\ncab\nb\na\n3\nbca\nab\na\n5\nabc\nacb\nb\nc\nc\n5\nabc\nacb\nc\nb\nb\n0\n"}, "reference_outputs": ["yes\nno\nyes\nno\n"], "source_document_id": "p01646", "source_text": "Problem Statement\n\nWe found a dictionary of the Ancient Civilization Mayo (ACM) during excavation of the ruins.\nAfter analysis of the dictionary, we revealed they used a language that had not more than 26 letters.\nSo one of us mapped each letter to a different English alphabet and typed all the words in the dictionary into a computer.\n\nHow the words are ordered in the dictionary, especially whether they are ordered lexicographically, is an interesting topic to many people.\nAs a good programmer, you are requested to write a program to judge whether we can consider the words to be sorted in a lexicographical order.\n\nNote:\nIn a lexicographical order, a word always precedes other words it is a prefix of.\nFor example, ab\nprecedes abc,\nabde, and so on.\n\nInput\n\nThe input consists of multiple datasets. Each dataset is formatted as follows:\n\nn\nstring_1\n...\nstring_n\n\nEach dataset consists of n+1 lines.\nThe first line of each dataset contains an integer that indicates n (1 \\leq n \\leq 500).\nThe i-th line of the following n lines contains string_i, which consists of up to 10 English lowercase letters.\n\nThe end of the input is 0, and this should not be processed.\n\nOutput\n\nPrint either yes or\nno in a line for each dataset, in the order of the input.\nIf all words in the dataset can be considered to be ordered lexicographically, print yes.\nOtherwise, print no.\n\nSample Input\n\n4\ncba\ncab\nb\na\n3\nbca\nab\na\n5\nabc\nacb\nb\nc\nc\n5\nabc\nacb\nc\nb\nb\n0\n\nOutput for the Sample Input\n\nyes\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": 1687, "cpu_time_ms": 2560, "memory_kb": 41340}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s329948724", "group_id": "codeNet:p01696", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayDeque;\nimport java.util.Deque;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString line;\n\n\t\twhile ((line = br.readLine()) != null && !line.isEmpty()) {\n\t\t\tif (line.equals(\".\")) break;\n\n\t\t\tDeque rev = new ArrayDeque();\n\t\t\tDeque out = new ArrayDeque();\n\t\t\tint shift = 0;\n\n\t\t\tfor (char c : line.toCharArray()) {\n\t\t\t\tswitch (c) {\n\t\t\t\t\tcase '[':\n\t\t\t\t\t\tout.offer(c);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ']':\n\t\t\t\t\t\tchar d = out.removeLast();\n\t\t\t\t\t\twhile (d != '[') {\n\t\t\t\t\t\t\trev.push(d);\n\t\t\t\t\t\t\td = out.removeLast();\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// reverse\n\t\t\t\t\t\twhile (!rev.isEmpty()) {\n\t\t\t\t\t\t\tout.offer(rev.removeLast());\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '+':\n\t\t\t\t\t\tshift++;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '-':\n\t\t\t\t\t\tshift--;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '?':\n\t\t\t\t\t\tout.offer('A');\n\t\t\t\t\t\tshift = 0;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tif (shift != 0) {\n\t\t\t\t\t\t\tshift %= 26;\n\t\t\t\t\t\t\tc += shift;\n\t\t\t\t\t\t\tif (c < 'A') {\n\t\t\t\t\t\t\t\tc += 26;\n\t\t\t\t\t\t\t} else if (c > 'Z') {\n\t\t\t\t\t\t\t\tc -= 26;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tout.offer((char) c);\n\t\t\t\t\t\t\tshift = 0;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tout.offer(c);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\twhile (!out.isEmpty()) {\n\t\t\t\tsb.append(out.poll());\n\t\t\t}\n\t\t\tSystem.out.println(sb.toString());\n\t\t}\n\t} //end while\n} //end main", "language": "Java", "metadata": {"date": 1427563458, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p01696.html", "problem_id": "p01696", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p01696/input.txt", "sample_output_relpath": "derived/input_output/data/p01696/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01696/Java/s329948724.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s329948724", "user_id": "u759934006"}, "prompt_components": {"gold_output": "ABC\nZYXZ\nREVERSE\nJAG\nICPC\nJAPAN\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayDeque;\nimport java.util.Deque;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString line;\n\n\t\twhile ((line = br.readLine()) != null && !line.isEmpty()) {\n\t\t\tif (line.equals(\".\")) break;\n\n\t\t\tDeque rev = new ArrayDeque();\n\t\t\tDeque out = new ArrayDeque();\n\t\t\tint shift = 0;\n\n\t\t\tfor (char c : line.toCharArray()) {\n\t\t\t\tswitch (c) {\n\t\t\t\t\tcase '[':\n\t\t\t\t\t\tout.offer(c);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ']':\n\t\t\t\t\t\tchar d = out.removeLast();\n\t\t\t\t\t\twhile (d != '[') {\n\t\t\t\t\t\t\trev.push(d);\n\t\t\t\t\t\t\td = out.removeLast();\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// reverse\n\t\t\t\t\t\twhile (!rev.isEmpty()) {\n\t\t\t\t\t\t\tout.offer(rev.removeLast());\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '+':\n\t\t\t\t\t\tshift++;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '-':\n\t\t\t\t\t\tshift--;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '?':\n\t\t\t\t\t\tout.offer('A');\n\t\t\t\t\t\tshift = 0;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tif (shift != 0) {\n\t\t\t\t\t\t\tshift %= 26;\n\t\t\t\t\t\t\tc += shift;\n\t\t\t\t\t\t\tif (c < 'A') {\n\t\t\t\t\t\t\t\tc += 26;\n\t\t\t\t\t\t\t} else if (c > 'Z') {\n\t\t\t\t\t\t\t\tc -= 26;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tout.offer((char) c);\n\t\t\t\t\t\t\tshift = 0;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tout.offer(c);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\twhile (!out.isEmpty()) {\n\t\t\t\tsb.append(out.poll());\n\t\t\t}\n\t\t\tSystem.out.println(sb.toString());\n\t\t}\n\t} //end while\n} //end main", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\n壊れた暗号生成器\n\nJAG (Japanese Alumni Group) は多くのプログラマで構成される謎の組織であり,この組織の本部がある建物に入るためには毎回ある機械によって生成される暗号文を解かなくてはならない.\nこの暗号文は,'+','-','[',']' の記号と大文字のアルファベットからなっており,以下の BNF で定義される によって表される.\n\n ::= | \n ::= | '['']'\n ::= '+' | '-' |\n'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' |\n'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z'\n\nここでそれぞれの記号は以下のような意味を表す.\n\n+(文字) : その文字の次のアルファベットを表す (ただし 'Z' の次のアルファベットは 'A' であるとする)\n\n-(文字) : その文字の前のアルファベットを表す (ただし 'A' の前のアルファベットは 'Z' であるとする)\n\n[(文字列)] : その文字列を左右反転した文字列を表す\n\nしかしこの暗号文を生成する機械には現在故障が発生しており,暗号文のうちアルファベットの箇所が数文字壊れて読めなくなっている場合がある.読めない文字は仮に '?' と表されている.\n調査の結果,壊れた文字の埋め方は,復号後の文字列が,復号後の文字列としてありえる文字列の中で辞書順最小になるようなものであることがわかった.\nあなたの仕事はこの暗号文を正しく復号することである.\n\nInput\n\n入力は複数のデータセットから構成される.\n各データセットは,上記の BNF で定義された暗号文において,一部の大文字のアルファベットが ‘?’ に置き換えられた文字列を含む 1 行からなる.\n各文字列の長さは $80$ 以下であると仮定してよい.\nまた各データセットに含まれる '?' の数は $0$ 以上 $3$ 以下であると仮定してよい.\n\n入力の終了は '.' の1文字だけを含む行で表される.\n\nOutput\n\n各データセットに対して,復号後の文字列が辞書順最小になるように暗号文を復号したときの,復号後の文字列を出力せよ.\n\nSample Input\n\nA+A++A\nZ-Z--Z+-Z\n[ESREVER]\nJ---?---J\n++++++++A+++Z-----------A+++Z\n[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L\n.\n\nOutput for Sample Input\n\nABC\nZYXZ\nREVERSE\nJAG\nICPC\nJAPAN", "sample_input": "A+A++A\nZ-Z--Z+-Z\n[ESREVER]\nJ---?---J\n++++++++A+++Z-----------A+++Z\n[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L\n.\n"}, "reference_outputs": ["ABC\nZYXZ\nREVERSE\nJAG\nICPC\nJAPAN\n"], "source_document_id": "p01696", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\n壊れた暗号生成器\n\nJAG (Japanese Alumni Group) は多くのプログラマで構成される謎の組織であり,この組織の本部がある建物に入るためには毎回ある機械によって生成される暗号文を解かなくてはならない.\nこの暗号文は,'+','-','[',']' の記号と大文字のアルファベットからなっており,以下の BNF で定義される によって表される.\n\n ::= | \n ::= | '['']'\n ::= '+' | '-' |\n'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' |\n'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z'\n\nここでそれぞれの記号は以下のような意味を表す.\n\n+(文字) : その文字の次のアルファベットを表す (ただし 'Z' の次のアルファベットは 'A' であるとする)\n\n-(文字) : その文字の前のアルファベットを表す (ただし 'A' の前のアルファベットは 'Z' であるとする)\n\n[(文字列)] : その文字列を左右反転した文字列を表す\n\nしかしこの暗号文を生成する機械には現在故障が発生しており,暗号文のうちアルファベットの箇所が数文字壊れて読めなくなっている場合がある.読めない文字は仮に '?' と表されている.\n調査の結果,壊れた文字の埋め方は,復号後の文字列が,復号後の文字列としてありえる文字列の中で辞書順最小になるようなものであることがわかった.\nあなたの仕事はこの暗号文を正しく復号することである.\n\nInput\n\n入力は複数のデータセットから構成される.\n各データセットは,上記の BNF で定義された暗号文において,一部の大文字のアルファベットが ‘?’ に置き換えられた文字列を含む 1 行からなる.\n各文字列の長さは $80$ 以下であると仮定してよい.\nまた各データセットに含まれる '?' の数は $0$ 以上 $3$ 以下であると仮定してよい.\n\n入力の終了は '.' の1文字だけを含む行で表される.\n\nOutput\n\n各データセットに対して,復号後の文字列が辞書順最小になるように暗号文を復号したときの,復号後の文字列を出力せよ.\n\nSample Input\n\nA+A++A\nZ-Z--Z+-Z\n[ESREVER]\nJ---?---J\n++++++++A+++Z-----------A+++Z\n[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L\n.\n\nOutput for Sample Input\n\nABC\nZYXZ\nREVERSE\nJAG\nICPC\nJAPAN", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1494, "cpu_time_ms": 50, "memory_kb": 17320}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s506886762", "group_id": "codeNet:p01839", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.Stack;\n\n\npublic class Main {\n\n\t/**\n\t * @param args\n\t * @throws IOException \n\t * @throws NumberFormatException \n\t */\n\tpublic static void main(String[] args) throws NumberFormatException, IOException {\n\t\t// TODO Auto-generated method stub\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tStack stack = new Stack();\n\t\tint regularAns = 0;\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tString input = br.readLine();\n\t\t\tif(input.equals(\"A\")){\n\t\t\t\tstack.push(1);\n\t\t\t}\n\t\t\telse if(!stack.isEmpty() && input.equals(\"Un\")){\n\t\t\t\tstack.pop();\n\t\t\t\tregularAns++;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif(stack.isEmpty() && regularAns > 0){\n\t\t\tSystem.out.println(\"YES\");\n\t\t}\n\t\telse{\n\t\t\tSystem.out.println(\"NO\");\n\t\t}\n\t}\n\n}", "language": "Java", "metadata": {"date": 1506654609, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p01839.html", "problem_id": "p01839", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p01839/input.txt", "sample_output_relpath": "derived/input_output/data/p01839/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01839/Java/s506886762.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s506886762", "user_id": "u503947213"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.Stack;\n\n\npublic class Main {\n\n\t/**\n\t * @param args\n\t * @throws IOException \n\t * @throws NumberFormatException \n\t */\n\tpublic static void main(String[] args) throws NumberFormatException, IOException {\n\t\t// TODO Auto-generated method stub\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tStack stack = new Stack();\n\t\tint regularAns = 0;\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tString input = br.readLine();\n\t\t\tif(input.equals(\"A\")){\n\t\t\t\tstack.push(1);\n\t\t\t}\n\t\t\telse if(!stack.isEmpty() && input.equals(\"Un\")){\n\t\t\t\tstack.pop();\n\t\t\t\tregularAns++;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif(stack.isEmpty() && regularAns > 0){\n\t\t\tSystem.out.println(\"YES\");\n\t\t}\n\t\telse{\n\t\t\tSystem.out.println(\"NO\");\n\t\t}\n\t}\n\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nA - 阿吽の呼吸\n\nProblem Statement\n\n時は進んで 2060 年,共に 70 歳を迎える前田さんと後藤さんは長い付き合いの友人であり,大学時代にACM-ICPCで共に戦った仲間でもある.\n\n二人は今でもよく一緒にお茶を飲みつつ,競技プログラミングの話で盛り上がっている.\n\n二人で一緒にお茶を飲む時,前田さんが 1 回Aと言うと,その発言の後に後藤さんがちょうど 1 回Unと返事をする習慣がいつのまにか出来た.\n\nしかし最近後藤さんは物忘れや勘違いをすることが多く,前田さんがAと言っても,後藤さんはたまにUnの返事を忘れたり,余計に返事をしたりする.\n\nついこの間も前田さんと後藤さんはお茶を飲みながら,二人のお気に入りのデータ構造について話し込んでいたようだ.\n\nこの時の会話の中から,Aで表される前田さんの発言と,Unで表される後藤さんの返事のみからなる記録が時系列で与えられたとき,後藤さんが習慣通りに反応したとみなすことが出来るかチェックしてほしい.\n\n注意点として,前田さんの発言に対し,後藤さんの返事が多少遅れても,後藤さんは習慣通りに反応したとみなせる場合がある,ということが挙げられる.\n例えば,前田さんが2回連続してAと言った後,後藤さんが 2 回連続してUnと返事をして会話が終了した場合は,後藤さんが習慣通りの返事をしたとみなされる (Sample Input 2 参照).\n\nまた,会話が終了した時点で,前田さんがAと言った回数と,後藤さんがUnと返事した回数が一致しても,後藤さんが習慣通りに返事をしたとはみなされない場合もあるので注意すること.\n例えば,前田さんが1回Aと言った後,後藤さんが 2 回連続してUnと返事し,その後で前田さんが 1 回Aと言って会話が終了した場合は,後藤さんが習慣通りの返事をしたとはみなされない (Sample Input 3 参照).\n\nInput\n\n入力は以下の形式で与えられる.\n\n$N$\n\n$S_1$\n\n$S_2$\n\n$…$\n\n$S_N$\n\n最初の行はひとつの整数からなる.\n$N$ は,記録に含まれる前田さんがAと発言した回数と後藤さんがUnと返事した回数の合計を表し,$1 \\leq N \\leq 100$ を満たす.\nその後 $N$ 行に,文字列 $S_i$ が続き,各 $S_i (1 \\leq i \\leq N)$ はAかUnのどちらかに一致する.ここでAは前田さんの発言,Unは後藤さんの返事を表す.\n$i$ の小さい順に $S_i$ が記録されたものとする.\n前田さんと後藤さんが同時に発言することは無かったとする.\n\nOutput\n\n後藤さんが習慣通りに反応したとみなすことが出来ればYES,出来なければNOを1行で出力すること.\n\nSample Input 1\n\n4\nA\nUn\nA\nUn\n\nOutput for the Sample Input 1\n\nYES\n\nSample Input 2\n\n4\nA\nA\nUn\nUn\n\nOutput for the Sample Input 2\n\nYES\n\nSample Input 3\n\n4\nA\nUn\nUn\nA\n\nOutput for the Sample Input 3\n\nNO\n\nSample Input 4\n\n1\nUn\n\nOutput for the Sample Input 4\n\nNO", "sample_input": "4\nA\nUn\nA\nUn\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p01839", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nA - 阿吽の呼吸\n\nProblem Statement\n\n時は進んで 2060 年,共に 70 歳を迎える前田さんと後藤さんは長い付き合いの友人であり,大学時代にACM-ICPCで共に戦った仲間でもある.\n\n二人は今でもよく一緒にお茶を飲みつつ,競技プログラミングの話で盛り上がっている.\n\n二人で一緒にお茶を飲む時,前田さんが 1 回Aと言うと,その発言の後に後藤さんがちょうど 1 回Unと返事をする習慣がいつのまにか出来た.\n\nしかし最近後藤さんは物忘れや勘違いをすることが多く,前田さんがAと言っても,後藤さんはたまにUnの返事を忘れたり,余計に返事をしたりする.\n\nついこの間も前田さんと後藤さんはお茶を飲みながら,二人のお気に入りのデータ構造について話し込んでいたようだ.\n\nこの時の会話の中から,Aで表される前田さんの発言と,Unで表される後藤さんの返事のみからなる記録が時系列で与えられたとき,後藤さんが習慣通りに反応したとみなすことが出来るかチェックしてほしい.\n\n注意点として,前田さんの発言に対し,後藤さんの返事が多少遅れても,後藤さんは習慣通りに反応したとみなせる場合がある,ということが挙げられる.\n例えば,前田さんが2回連続してAと言った後,後藤さんが 2 回連続してUnと返事をして会話が終了した場合は,後藤さんが習慣通りの返事をしたとみなされる (Sample Input 2 参照).\n\nまた,会話が終了した時点で,前田さんがAと言った回数と,後藤さんがUnと返事した回数が一致しても,後藤さんが習慣通りに返事をしたとはみなされない場合もあるので注意すること.\n例えば,前田さんが1回Aと言った後,後藤さんが 2 回連続してUnと返事し,その後で前田さんが 1 回Aと言って会話が終了した場合は,後藤さんが習慣通りの返事をしたとはみなされない (Sample Input 3 参照).\n\nInput\n\n入力は以下の形式で与えられる.\n\n$N$\n\n$S_1$\n\n$S_2$\n\n$…$\n\n$S_N$\n\n最初の行はひとつの整数からなる.\n$N$ は,記録に含まれる前田さんがAと発言した回数と後藤さんがUnと返事した回数の合計を表し,$1 \\leq N \\leq 100$ を満たす.\nその後 $N$ 行に,文字列 $S_i$ が続き,各 $S_i (1 \\leq i \\leq N)$ はAかUnのどちらかに一致する.ここでAは前田さんの発言,Unは後藤さんの返事を表す.\n$i$ の小さい順に $S_i$ が記録されたものとする.\n前田さんと後藤さんが同時に発言することは無かったとする.\n\nOutput\n\n後藤さんが習慣通りに反応したとみなすことが出来ればYES,出来なければNOを1行で出力すること.\n\nSample Input 1\n\n4\nA\nUn\nA\nUn\n\nOutput for the Sample Input 1\n\nYES\n\nSample Input 2\n\n4\nA\nA\nUn\nUn\n\nOutput for the Sample Input 2\n\nYES\n\nSample Input 3\n\n4\nA\nUn\nUn\nA\n\nOutput for the Sample Input 3\n\nNO\n\nSample Input 4\n\n1\nUn\n\nOutput for the Sample Input 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": 869, "cpu_time_ms": 50, "memory_kb": 24284}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s476440955", "group_id": "codeNet:p01981", "input_text": "\nimport java.util.*;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner in=new Scanner(System.in);\n\t\t\n\t\twhile(true) {\n\t\t\tString str=in.next();\n\t\t\tif(str.charAt(0)=='#')break;\n\t\t\tint y=in.nextInt(),m=in.nextInt(),d=in.nextInt();\n\t\t\t\n\t\t\tif(y>31 || (y>=31 && m>=5)) {\n\t\t\t\tstr=\"?\";y-=30;\n\t\t\t}\n\t\t\tSystem.out.println(str+\" \"+y+\" \"+m+\" \"+d);\n\t\t}\n\t}\n\n}\n\n", "language": "Java", "metadata": {"date": 1530744552, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p01981.html", "problem_id": "p01981", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p01981/input.txt", "sample_output_relpath": "derived/input_output/data/p01981/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01981/Java/s476440955.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s476440955", "user_id": "u592118612"}, "prompt_components": {"gold_output": "HEISEI 1 1 8\nHEISEI 31 4 30\n? 1 5 1\n? 69 12 31\n? 8 8 30\n? 68 2 22\nHEISEI 2 3 26\nHEISEI 28 4 23\n", "input_to_evaluate": "\nimport java.util.*;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner in=new Scanner(System.in);\n\t\t\n\t\twhile(true) {\n\t\t\tString str=in.next();\n\t\t\tif(str.charAt(0)=='#')break;\n\t\t\tint y=in.nextInt(),m=in.nextInt(),d=in.nextInt();\n\t\t\t\n\t\t\tif(y>31 || (y>=31 && m>=5)) {\n\t\t\t\tstr=\"?\";y-=30;\n\t\t\t}\n\t\t\tSystem.out.println(str+\" \"+y+\" \"+m+\" \"+d);\n\t\t}\n\t}\n\n}\n\n", "problem_context": "改元\n\n平成31年4月30日をもって現行の元号である平成が終了し,その翌日より新しい元号が始まることになった.平成最後の日の翌日は新元号元年5月1日になる.\n\nACM-ICPC OB/OGの会 (Japanese Alumni Group; JAG) が開発するシステムでは,日付が和暦(元号とそれに続く年数によって年を表現する日本の暦)を用いて \"平成 y 年 m 月 d 日\" という形式でデータベースに保存されている.この保存形式は変更することができないため,JAGは元号が変更されないと仮定して和暦で表した日付をデータベースに保存し,出力の際に日付を正しい元号を用いた形式に変換することにした.\n\nあなたの仕事はJAGのデータベースに保存されている日付を,平成または新元号を用いた日付に変換するプログラムを書くことである.新元号はまだ発表されていないため,\"?\" を用いて表すことにする.\n\nInput\n\n入力は複数のデータセットからなる.各データセットは次の形式で表される.\n\ng y m d\n\ng は元号を表す文字列であり, g=HEISEI が成り立つ.y, m, d は整数であり,それぞれ年,月,日を表す.1 ≤ y ≤ 100, 1 ≤ m ≤ 12, 1 ≤ d ≤ 31 が成り立つ.\n\n2月30日などの和暦に存在しない日付はデータセットとして与えられない.和暦として正しく変換したときに,平成よりも前の元号を用いる必要がある日付もデータセットとして与えられない.\n\n入力の終わりは '#' 一つのみからなる行であらわされる.データセットの個数は 100 個を超えない.\n\nOutput\n\n各データセットについて,変換後の元号,年,月,日を空白で区切って 1 行に出力せよ.変換後の元号が \"平成\" である場合は \"HEISEI\" を元号として用い,新元号であれば \"?\" を用いよ.\n\n通常,元号の第 1 年目は元年と表記するが,本問題の出力ではこの規則を無視し,1 を年として出力せよ.\n\nSample Input\n\nHEISEI 1 1 8\nHEISEI 31 4 30\nHEISEI 31 5 1\nHEISEI 99 12 31\nHEISEI 38 8 30\nHEISEI 98 2 22\nHEISEI 2 3 26\nHEISEI 28 4 23\n#\n\nOutput for the Sample Input\n\nHEISEI 1 1 8\nHEISEI 31 4 30\n? 1 5 1\n? 69 12 31\n? 8 8 30\n? 68 2 22\nHEISEI 2 3 26\nHEISEI 28 4 23", "sample_input": "HEISEI 1 1 8\nHEISEI 31 4 30\nHEISEI 31 5 1\nHEISEI 99 12 31\nHEISEI 38 8 30\nHEISEI 98 2 22\nHEISEI 2 3 26\nHEISEI 28 4 23\n#\n"}, "reference_outputs": ["HEISEI 1 1 8\nHEISEI 31 4 30\n? 1 5 1\n? 69 12 31\n? 8 8 30\n? 68 2 22\nHEISEI 2 3 26\nHEISEI 28 4 23\n"], "source_document_id": "p01981", "source_text": "改元\n\n平成31年4月30日をもって現行の元号である平成が終了し,その翌日より新しい元号が始まることになった.平成最後の日の翌日は新元号元年5月1日になる.\n\nACM-ICPC OB/OGの会 (Japanese Alumni Group; JAG) が開発するシステムでは,日付が和暦(元号とそれに続く年数によって年を表現する日本の暦)を用いて \"平成 y 年 m 月 d 日\" という形式でデータベースに保存されている.この保存形式は変更することができないため,JAGは元号が変更されないと仮定して和暦で表した日付をデータベースに保存し,出力の際に日付を正しい元号を用いた形式に変換することにした.\n\nあなたの仕事はJAGのデータベースに保存されている日付を,平成または新元号を用いた日付に変換するプログラムを書くことである.新元号はまだ発表されていないため,\"?\" を用いて表すことにする.\n\nInput\n\n入力は複数のデータセットからなる.各データセットは次の形式で表される.\n\ng y m d\n\ng は元号を表す文字列であり, g=HEISEI が成り立つ.y, m, d は整数であり,それぞれ年,月,日を表す.1 ≤ y ≤ 100, 1 ≤ m ≤ 12, 1 ≤ d ≤ 31 が成り立つ.\n\n2月30日などの和暦に存在しない日付はデータセットとして与えられない.和暦として正しく変換したときに,平成よりも前の元号を用いる必要がある日付もデータセットとして与えられない.\n\n入力の終わりは '#' 一つのみからなる行であらわされる.データセットの個数は 100 個を超えない.\n\nOutput\n\n各データセットについて,変換後の元号,年,月,日を空白で区切って 1 行に出力せよ.変換後の元号が \"平成\" である場合は \"HEISEI\" を元号として用い,新元号であれば \"?\" を用いよ.\n\n通常,元号の第 1 年目は元年と表記するが,本問題の出力ではこの規則を無視し,1 を年として出力せよ.\n\nSample Input\n\nHEISEI 1 1 8\nHEISEI 31 4 30\nHEISEI 31 5 1\nHEISEI 99 12 31\nHEISEI 38 8 30\nHEISEI 98 2 22\nHEISEI 2 3 26\nHEISEI 28 4 23\n#\n\nOutput for the Sample Input\n\nHEISEI 1 1 8\nHEISEI 31 4 30\n? 1 5 1\n? 69 12 31\n? 8 8 30\n? 68 2 22\nHEISEI 2 3 26\nHEISEI 28 4 23", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 368, "cpu_time_ms": 90, "memory_kb": 27256}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s513566535", "group_id": "codeNet:p02201", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n String target = \"E869120\";\n int count = 0;\n for (int i = 0; i < n; i++) {\n if (target.equals(sc.next())) {\n count++;\n }\n }\n System.out.println(count);\n }\n}\n\n", "language": "Java", "metadata": {"date": 1585534263, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02201.html", "problem_id": "p02201", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02201/input.txt", "sample_output_relpath": "derived/input_output/data/p02201/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02201/Java/s513566535.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s513566535", "user_id": "u788025930"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n String target = \"E869120\";\n int count = 0;\n for (int i = 0; i < n; i++) {\n if (target.equals(sc.next())) {\n count++;\n }\n }\n System.out.println(count);\n }\n}\n\n", "problem_context": "増えるE869120君 (Ninja E869120)\n\nE869120君は分身が得意です。\n\nここに、$N$ 人のパ研部員がいます。しかし、このうちの何人かが E869120 君かもしれません。\n\nそこで、あなたは $N$ 人全てのパ研部員に名前を聞きました。その結果、$N$ 人の部員はそれぞれ $S_1, S_2, S_3, \\dots, S_N$ と名乗りました。\n\nE869120 君は何人に分身していたでしょうか?ただし、全てのパ研部員は正直に自分の名前を答えるものとします。\n\n入力\n\n入力は以下の形式で標準入力から与えられる。\n\n$N$\n$S_1$\n$S_2$\n$S_3$\n$\\ldots$\n$S_N$\n\n出力\n\nE869120君が何人に分身していたか、その人数を出力してください。ただし、E869120君がいない場合は「0」と出力してください。\n\nただし、最後には改行を入れること。\n\n制約\n\n$1 \\leq N \\leq 1000$\n\n$1 \\leq (S_i$ の長さ$) \\leq 100$\n\n$N$ は整数である。\n\n$S_i$ は数字とアルファベット大文字からなる文字列である。\n\n入力例1\n\n5\nE869120\nTMJN\nE869120\nTAISA\nYNYMXIAOLONGBAO\n\n出力例1\n\n2\n\nE869120君は 2 人に分身しています。\n\n入力例2\n\n3\nSQUARE1001\nMENCOTTON\nB2563125\n\n出力例2\n\n0\n\nE869120君がいないときは0を出力してください。\n\n入力例3\n\n6\nE8691200\nE869121\nE869122\nE869123\nE869124\nE869125\n\n出力例3\n\n0\n\n偽者に注意してください。", "sample_input": "5\nE869120\nTMJN\nE869120\nTAISA\nYNYMXIAOLONGBAO\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02201", "source_text": "増えるE869120君 (Ninja E869120)\n\nE869120君は分身が得意です。\n\nここに、$N$ 人のパ研部員がいます。しかし、このうちの何人かが E869120 君かもしれません。\n\nそこで、あなたは $N$ 人全てのパ研部員に名前を聞きました。その結果、$N$ 人の部員はそれぞれ $S_1, S_2, S_3, \\dots, S_N$ と名乗りました。\n\nE869120 君は何人に分身していたでしょうか?ただし、全てのパ研部員は正直に自分の名前を答えるものとします。\n\n入力\n\n入力は以下の形式で標準入力から与えられる。\n\n$N$\n$S_1$\n$S_2$\n$S_3$\n$\\ldots$\n$S_N$\n\n出力\n\nE869120君が何人に分身していたか、その人数を出力してください。ただし、E869120君がいない場合は「0」と出力してください。\n\nただし、最後には改行を入れること。\n\n制約\n\n$1 \\leq N \\leq 1000$\n\n$1 \\leq (S_i$ の長さ$) \\leq 100$\n\n$N$ は整数である。\n\n$S_i$ は数字とアルファベット大文字からなる文字列である。\n\n入力例1\n\n5\nE869120\nTMJN\nE869120\nTAISA\nYNYMXIAOLONGBAO\n\n出力例1\n\n2\n\nE869120君は 2 人に分身しています。\n\n入力例2\n\n3\nSQUARE1001\nMENCOTTON\nB2563125\n\n出力例2\n\n0\n\nE869120君がいないときは0を出力してください。\n\n入力例3\n\n6\nE8691200\nE869121\nE869122\nE869123\nE869124\nE869125\n\n出力例3\n\n0\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": 394, "cpu_time_ms": 150, "memory_kb": 35728}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s153107768", "group_id": "codeNet:p02233", "input_text": "import java.util.Arrays;\nimport java.util.Scanner;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\n\t\tint[] dp = new int[n+1];\n\n\t\tArrays.fill(dp, -1);\n\n\t\t/*メモ化!!!\n\t\tint ans = fib(n,dp);\n\n\t\tSystem.out.println(ans);\n\t\t */\n\n\t\tdp[0] = 1;\n\n\t\tdp[1] = 1;\n\n\t\tfor(int i=2;i<=n;i++) {\n\n\t\t\tdp[i] = dp[i-1] + dp[i-2];\n\t\t}\n\n\t\tSystem.out.println(dp[n]);\n\t}\n\n\t/*メモ化!!!\n\tstatic int fib(int n, int[] dp) {\n\n\t\tif(n==0 || n==1) {\n\n\t\t\tdp[n] = 1;\n\n\t\t\treturn dp[n];\n\n\t\t}else if(dp[n] != -1){\n\n\t\t\treturn dp[n];\n\t\t}\n\n\t\treturn fib(n-1,dp) + fib(n-2,dp);\n\n\t}*/\n\n}\n\n", "language": "Java", "metadata": {"date": 1551416168, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02233.html", "problem_id": "p02233", "resource_group": "high_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/Java/s153107768.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s153107768", "user_id": "u373055670"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Arrays;\nimport java.util.Scanner;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\n\t\tint[] dp = new int[n+1];\n\n\t\tArrays.fill(dp, -1);\n\n\t\t/*メモ化!!!\n\t\tint ans = fib(n,dp);\n\n\t\tSystem.out.println(ans);\n\t\t */\n\n\t\tdp[0] = 1;\n\n\t\tdp[1] = 1;\n\n\t\tfor(int i=2;i<=n;i++) {\n\n\t\t\tdp[i] = dp[i-1] + dp[i-2];\n\t\t}\n\n\t\tSystem.out.println(dp[n]);\n\t}\n\n\t/*メモ化!!!\n\tstatic int fib(int n, int[] dp) {\n\n\t\tif(n==0 || n==1) {\n\n\t\t\tdp[n] = 1;\n\n\t\t\treturn dp[n];\n\n\t\t}else if(dp[n] != -1){\n\n\t\t\treturn dp[n];\n\t\t}\n\n\t\treturn fib(n-1,dp) + fib(n-2,dp);\n\n\t}*/\n\n}\n\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nFibonacci Number\n\nWrite a program which prints $n$-th fibonacci number for a given integer $n$. The $n$-th fibonacci number is defined by the following recursive formula:\n\n\\begin{equation*}\nfib(n)= \\left \\{\n\\begin{array}{ll}\n1  & (n = 0) \\\\\n1  & (n = 1) \\\\\nfib(n - 1) + fib(n - 2) & \\\\\n\\end{array}\n\\right.\n\\end{equation*}\n\nInput\n\nAn integer $n$ is given.\n\noutput\n\nPrint the $n$-th fibonacci number in a line.\n\nConstraints\n\n$0 \\leq n \\leq 44$\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3", "sample_input": "3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02233", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nFibonacci Number\n\nWrite a program which prints $n$-th fibonacci number for a given integer $n$. The $n$-th fibonacci number is defined by the following recursive formula:\n\n\\begin{equation*}\nfib(n)= \\left \\{\n\\begin{array}{ll}\n1  & (n = 0) \\\\\n1  & (n = 1) \\\\\nfib(n - 1) + fib(n - 2) & \\\\\n\\end{array}\n\\right.\n\\end{equation*}\n\nInput\n\nAn integer $n$ is given.\n\noutput\n\nPrint the $n$-th fibonacci number in a line.\n\nConstraints\n\n$0 \\leq n \\leq 44$\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 631, "cpu_time_ms": 60, "memory_kb": 26404}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s620542522", "group_id": "codeNet:p02234", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.StreamTokenizer;\nimport java.util.Arrays;\nimport java.util.InputMismatchException;\n\n\npublic class Main {\n\t\n\tprivate static int[][] cache;\n\tprivate static int[] r;\n\tprivate static int[] c;\n\t\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in); \n\n\t\tint n = sc.nextInt();\n\t\tr = new int[n];\n\t\tc = new int[n];\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tr[i] = sc.nextInt();\n\t\t\tc[i] = sc.nextInt();\n\t\t}\n\n\t\t// ボトムアップ型1、メモリ節約\n\t\tcache = new int[n][];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tcache[i] = new int[n - i];\n\t\t\tArrays.fill(cache[i], Integer.MAX_VALUE);\n\t\t\tcache[i][i - i] = 0; // cache[行][列 - 行]\n\t\t}\n\n\t\tfor (int l = 1; l < n; l++) {\n\t\t\tfor (int i = 0; i + l < n && i < n; i++) {\n\t\t\t\tint j = i + l;\n\t\t\t\tfor (int k = 0; k < l; k++) {\n\t\t\t\t\tcache[i][j - i] = Math.min(cache[i][j - i], cache[i][i + k - i] + r[i] * r[i+k+1] * c[j] + cache[i + k + 1][j - (i + k + 1)]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tint ret = cache[0][n -1 - 0];\n\t\t\n\t\tSystem.out.println(ret);\n\t\t\n\t\tsc.close();\n\t}\n\n\t@SuppressWarnings(\"unused\")\n\tprivate static class Scanner {\n\t\tInputStreamReader isr;\n\t\tBufferedReader br;\n\t\tStreamTokenizer st;\n\n\t\tprivate Scanner() {\n\t\t}\n\n\t\tScanner (InputStream in) {\n\t\t\tisr = new InputStreamReader(in);\n\t\t\tbr = new BufferedReader(isr);\n\t\t\tst = new StreamTokenizer(br);\n\t\t}\n\n\t\tString next() throws RuntimeException {\n\t\t\ttry {\n\t\t\t\tif (st.nextToken() != StreamTokenizer.TT_WORD) {\n\t\t\t\t}\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new IllegalStateException();\n\t\t\t}\n\n\t\t\treturn st.sval;\n\t\t}\n\n\t\tint nextInt() throws RuntimeException {\n\t\t\ttry {\n\t\t\t\tif (st.nextToken() != StreamTokenizer.TT_NUMBER) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new IllegalStateException();\n\t\t\t}\n\n\t\t\treturn (int)st.nval;\n\t\t}\n\n\t\tvoid close() {\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1401411148, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02234.html", "problem_id": "p02234", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02234/input.txt", "sample_output_relpath": "derived/input_output/data/p02234/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02234/Java/s620542522.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s620542522", "user_id": "u722784748"}, "prompt_components": {"gold_output": "15125\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.StreamTokenizer;\nimport java.util.Arrays;\nimport java.util.InputMismatchException;\n\n\npublic class Main {\n\t\n\tprivate static int[][] cache;\n\tprivate static int[] r;\n\tprivate static int[] c;\n\t\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in); \n\n\t\tint n = sc.nextInt();\n\t\tr = new int[n];\n\t\tc = new int[n];\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tr[i] = sc.nextInt();\n\t\t\tc[i] = sc.nextInt();\n\t\t}\n\n\t\t// ボトムアップ型1、メモリ節約\n\t\tcache = new int[n][];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tcache[i] = new int[n - i];\n\t\t\tArrays.fill(cache[i], Integer.MAX_VALUE);\n\t\t\tcache[i][i - i] = 0; // cache[行][列 - 行]\n\t\t}\n\n\t\tfor (int l = 1; l < n; l++) {\n\t\t\tfor (int i = 0; i + l < n && i < n; i++) {\n\t\t\t\tint j = i + l;\n\t\t\t\tfor (int k = 0; k < l; k++) {\n\t\t\t\t\tcache[i][j - i] = Math.min(cache[i][j - i], cache[i][i + k - i] + r[i] * r[i+k+1] * c[j] + cache[i + k + 1][j - (i + k + 1)]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tint ret = cache[0][n -1 - 0];\n\t\t\n\t\tSystem.out.println(ret);\n\t\t\n\t\tsc.close();\n\t}\n\n\t@SuppressWarnings(\"unused\")\n\tprivate static class Scanner {\n\t\tInputStreamReader isr;\n\t\tBufferedReader br;\n\t\tStreamTokenizer st;\n\n\t\tprivate Scanner() {\n\t\t}\n\n\t\tScanner (InputStream in) {\n\t\t\tisr = new InputStreamReader(in);\n\t\t\tbr = new BufferedReader(isr);\n\t\t\tst = new StreamTokenizer(br);\n\t\t}\n\n\t\tString next() throws RuntimeException {\n\t\t\ttry {\n\t\t\t\tif (st.nextToken() != StreamTokenizer.TT_WORD) {\n\t\t\t\t}\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new IllegalStateException();\n\t\t\t}\n\n\t\t\treturn st.sval;\n\t\t}\n\n\t\tint nextInt() throws RuntimeException {\n\t\t\ttry {\n\t\t\t\tif (st.nextToken() != StreamTokenizer.TT_NUMBER) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new IllegalStateException();\n\t\t\t}\n\n\t\t\treturn (int)st.nval;\n\t\t}\n\n\t\tvoid close() {\n\t\t}\n\t}\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMatrix-chain Multiplication\n\nThe goal of the matrix-chain multiplication problem is to find the most efficient way to multiply given $n$ matrices $M_1, M_2, M_3,...,M_n$.\n\nWrite a program which reads dimensions of $M_i$, and finds the minimum number of scalar multiplications to compute the maxrix-chain multiplication $M_1M_2...M_n$.\n\nInput\n\nIn the first line, an integer $n$ is given. In the following $n$ lines, the dimension of matrix $M_i$ ($i = 1...n$) is given by two integers $r$ and $c$ which respectively represents the number of rows and columns of $M_i$.\n\nOutput\n\nPrint the minimum number of scalar multiplication in a line.\n\nConstraints\n\n$1 \\leq n \\leq 100$\n\n$1 \\leq r, c \\leq 100$\n\nSample Input 1\n\n6\n30 35\n35 15\n15 5\n5 10\n10 20\n20 25\n\nSample Output 1\n\n15125", "sample_input": "6\n30 35\n35 15\n15 5\n5 10\n10 20\n20 25\n"}, "reference_outputs": ["15125\n"], "source_document_id": "p02234", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMatrix-chain Multiplication\n\nThe goal of the matrix-chain multiplication problem is to find the most efficient way to multiply given $n$ matrices $M_1, M_2, M_3,...,M_n$.\n\nWrite a program which reads dimensions of $M_i$, and finds the minimum number of scalar multiplications to compute the maxrix-chain multiplication $M_1M_2...M_n$.\n\nInput\n\nIn the first line, an integer $n$ is given. In the following $n$ lines, the dimension of matrix $M_i$ ($i = 1...n$) is given by two integers $r$ and $c$ which respectively represents the number of rows and columns of $M_i$.\n\nOutput\n\nPrint the minimum number of scalar multiplication in a line.\n\nConstraints\n\n$1 \\leq n \\leq 100$\n\n$1 \\leq r, c \\leq 100$\n\nSample Input 1\n\n6\n30 35\n35 15\n15 5\n5 10\n10 20\n20 25\n\nSample Output 1\n\n15125", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1934, "cpu_time_ms": 70, "memory_kb": 19876}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s384243972", "group_id": "codeNet:p02240", "input_text": "\nimport java.util.ArrayList;\nimport java.util.Scanner;\nimport java.util.LinkedList;\n\npublic class Main {\n\tArrayList nodes = new ArrayList<>();\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tString[] holder = in.nextLine().split(\" \");\n\t\tint n = Integer.parseInt(holder[0]);\n\t\tint m = Integer.parseInt(holder[1]);\n\t\tMain graph = new Main();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tVertex v = new Vertex(i);\n\t\t\tgraph.addVertex(v);\n\t\t}\n\t\tfor (int i = m; i > 0; i--) {\n\t\t\tString[] relation = in.nextLine().split(\" \");\n\t\t\tint s = Integer.parseInt(relation[0]);\n\t\t\tint t = Integer.parseInt(relation[1]);\n\t\t\tVertex sv = graph.getVertex(s);\n\t\t\tVertex tv = graph.getVertex(t);\n\t\t\tsv.addNeighbor(tv);\n\t\t\ttv.addNeighbor(sv);\n\t\t}\n\t\t\n\t\tint q = Integer.parseInt(in.nextLine());\n\t\tfor (int i = q; i > 0; i--) {\n\t\t\tString[] query = in.nextLine().split(\" \");\n\t\t\tint s = Integer.parseInt(query[0]);\n\t\t\tint t = Integer.parseInt(query[1]);\n\t\t\tVertex start = graph.getVertex(s);\n\t\t\tVertex end = graph.getVertex(t);\n\t\t\tLinkedList fringe = new LinkedList<>();\n\t\t\tArrayList searched = new ArrayList<>();\n\t\t\tfringe.add(start);\n\t\t\tboolean found = graph.BFS(start, end, fringe, searched);\n\t\t\tif (found) {\n\t\t\t\tSystem.out.println(\"yes\");\n\t\t\t}\n\t\t\telse {\n\t\t\t\tSystem.out.println(\"no\");\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t}\t\n\t\t\n\tpublic void addVertex(Vertex v) {\n\t\tnodes.add(v);\n\t}\n\t\n\tpublic Vertex getVertex(int index) {\n\t\treturn nodes.get(index);\n\t}\n\t\n\t// Performs DFS from a specified starting node and returns true if the end can be reached from it\n\t// False otherwise\n\tpublic boolean BFS(Vertex start, Vertex end, LinkedList fringe, ArrayList searched) {\t\n\t\tif (fringe.isEmpty()) {\n\t\t\treturn false;\n\t\t}\n\t\telse if (start.equals(end)) {\n\t\t\treturn true;\n\t\t}\n\t\telse {\n\t\t\t\n\t\t\tVertex pull = fringe.poll();\n\t\t\tsearched.add(pull);\n\t\t\tfor (Vertex neigh : pull.neighbors) {\n\t\t\t\tif (neigh.equals(end)) {\n\t\t\t\t\treturn true;\n\t\t\t\t} else if (searched.contains(neigh)) {\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tfringe.add(neigh);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn BFS(pull, end, fringe, searched);\n\t\t}\n\t}\n\t\n}\n\nclass Vertex {\n\tpublic ArrayList neighbors = new ArrayList<>();\n\tpublic int value;\n\tpublic boolean disc;\n\t\n\tpublic Vertex(int val) {\n\t\tvalue = val;\n\t\tdisc = false;\n\t}\n\t\n\tpublic void addNeighbor (Vertex n) {\n\t\tneighbors.add(n);\n\t}\n\t\n\tpublic String toString() {\n\t\treturn \"\" + this.value + \" \";\n\t}\n\t\n\tpublic boolean equals(Vertex v) {\n\t\tif (this.value == v.value) {\n\t\t\treturn true;\n\t\t}\n\t\telse {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n\n\n", "language": "Java", "metadata": {"date": 1540618608, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02240.html", "problem_id": "p02240", "resource_group": "high_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/Java/s384243972.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s384243972", "user_id": "u829534368"}, "prompt_components": {"gold_output": "yes\nyes\nno\n", "input_to_evaluate": "\nimport java.util.ArrayList;\nimport java.util.Scanner;\nimport java.util.LinkedList;\n\npublic class Main {\n\tArrayList nodes = new ArrayList<>();\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tString[] holder = in.nextLine().split(\" \");\n\t\tint n = Integer.parseInt(holder[0]);\n\t\tint m = Integer.parseInt(holder[1]);\n\t\tMain graph = new Main();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tVertex v = new Vertex(i);\n\t\t\tgraph.addVertex(v);\n\t\t}\n\t\tfor (int i = m; i > 0; i--) {\n\t\t\tString[] relation = in.nextLine().split(\" \");\n\t\t\tint s = Integer.parseInt(relation[0]);\n\t\t\tint t = Integer.parseInt(relation[1]);\n\t\t\tVertex sv = graph.getVertex(s);\n\t\t\tVertex tv = graph.getVertex(t);\n\t\t\tsv.addNeighbor(tv);\n\t\t\ttv.addNeighbor(sv);\n\t\t}\n\t\t\n\t\tint q = Integer.parseInt(in.nextLine());\n\t\tfor (int i = q; i > 0; i--) {\n\t\t\tString[] query = in.nextLine().split(\" \");\n\t\t\tint s = Integer.parseInt(query[0]);\n\t\t\tint t = Integer.parseInt(query[1]);\n\t\t\tVertex start = graph.getVertex(s);\n\t\t\tVertex end = graph.getVertex(t);\n\t\t\tLinkedList fringe = new LinkedList<>();\n\t\t\tArrayList searched = new ArrayList<>();\n\t\t\tfringe.add(start);\n\t\t\tboolean found = graph.BFS(start, end, fringe, searched);\n\t\t\tif (found) {\n\t\t\t\tSystem.out.println(\"yes\");\n\t\t\t}\n\t\t\telse {\n\t\t\t\tSystem.out.println(\"no\");\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t}\t\n\t\t\n\tpublic void addVertex(Vertex v) {\n\t\tnodes.add(v);\n\t}\n\t\n\tpublic Vertex getVertex(int index) {\n\t\treturn nodes.get(index);\n\t}\n\t\n\t// Performs DFS from a specified starting node and returns true if the end can be reached from it\n\t// False otherwise\n\tpublic boolean BFS(Vertex start, Vertex end, LinkedList fringe, ArrayList searched) {\t\n\t\tif (fringe.isEmpty()) {\n\t\t\treturn false;\n\t\t}\n\t\telse if (start.equals(end)) {\n\t\t\treturn true;\n\t\t}\n\t\telse {\n\t\t\t\n\t\t\tVertex pull = fringe.poll();\n\t\t\tsearched.add(pull);\n\t\t\tfor (Vertex neigh : pull.neighbors) {\n\t\t\t\tif (neigh.equals(end)) {\n\t\t\t\t\treturn true;\n\t\t\t\t} else if (searched.contains(neigh)) {\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tfringe.add(neigh);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn BFS(pull, end, fringe, searched);\n\t\t}\n\t}\n\t\n}\n\nclass Vertex {\n\tpublic ArrayList neighbors = new ArrayList<>();\n\tpublic int value;\n\tpublic boolean disc;\n\t\n\tpublic Vertex(int val) {\n\t\tvalue = val;\n\t\tdisc = false;\n\t}\n\t\n\tpublic void addNeighbor (Vertex n) {\n\t\tneighbors.add(n);\n\t}\n\t\n\tpublic String toString() {\n\t\treturn \"\" + this.value + \" \";\n\t}\n\t\n\tpublic boolean equals(Vertex v) {\n\t\tif (this.value == v.value) {\n\t\t\treturn true;\n\t\t}\n\t\telse {\n\t\t\treturn false;\n\t\t}\n\t}\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": 2519, "cpu_time_ms": 410, "memory_kb": 61668}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s280585664", "group_id": "codeNet:p02250", "input_text": "import java.io.*;\nimport java.util.*;\n\n\npublic class Main {\n\n\tprivate static Scanner sc;\n\tprivate static Printer pr;\n\n\tprivate static void solve() {\n\t\tchar[] t = sc.next().toCharArray();\n\t\tSuffixArray sa = new SuffixArray(t);\n\n\t\tint q = sc.nextInt();\n\t\tfor (int i = 0; i < q; i++) {\n\t\t\tString p = sc.next();\n\n\t\t\tif (sa.contains(p.toCharArray())) {\n\t\t\t\tpr.println(\"1\");\n\t\t\t} else {\n\t\t\t\tpr.println(\"0\");\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static class SuffixArray {\n\t\tchar[] s;\n\t\tint n;\n\n\t\tInteger[] sa;\n\t\tint[] rank;\n\t\tint[] rtmp;\n\t\tSaComparator sac;\n\n\t\tint k;\n\n\t\tSuffixArray(char[] str) {\n\t\t\tthis.s = str;\n\t\t\tn = s.length;\n\n\t\t\tsa = new Integer[n + 1];\n\t\t\trank = new int[n + 1];\n\t\t\trtmp = new int[n + 1];\n\t\t\tfor (int i = 0; i <= n; i++) {\n\t\t\t\tsa[i] = i;\n\t\t\t\tif (i < n) {\n\t\t\t\t\trank[i] = s[i];\n\t\t\t\t} else {\n\t\t\t\t\trank[i] = 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tsac = new SaComparator();\n\n\t\t\tfor (k = 1; k < n; k *= 2) {\n\t\t\t\tArrays.sort(sa, sac);\n\n\t\t\t\trtmp[sa[0]] = rank[sa[0]];\n\t\t\t\tfor (int i = 1; i <= n; i++) {\n\t\t\t\t\tif (sac.compare(sa[i - 1], sa[i]) == 0) {\n\t\t\t\t\t\trtmp[sa[i]] = rtmp[sa[i - 1]];\n\t\t\t\t\t} else {\n\t\t\t\t\t\trtmp[sa[i]] = rtmp[sa[i - 1]] + 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tint[] tmp = rtmp;\n\t\t\t\trtmp = rank;\n\t\t\t\trank = tmp;\n\t\t\t}\n\t\t}\n\n\t\tboolean contains(char[] t) {\n\t\t\tint l = 0;\n\t\t\tint r = n;\n\t\t\twhile (r > l) {\n\t\t\t\tint mid = l + (r - l) / 2;\n\t\t\t\tint res = compare(s, mid, t);\n\n\t\t\t\tif (res >= 0) {\n\t\t\t\t\tr = mid;\n\t\t\t\t} else {\n\t\t\t\t\tl = mid + 1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn compare(s, l, t) == 0;\n\t\t}\n\n\t\tint compare(char[] s, int mid, char[] t) {\n\t\t\tint m = t.length;\n\n\t\t\tfor (int i = 0; sa[mid] + i < n && i < m; i++) {\n\t\t\t\tint res = s[sa[mid] + i] - t[i];\n\n\t\t\t\tif (res != 0) {\n\t\t\t\t\treturn res;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (sa[mid] + m < m) {\n\t\t\t\treturn -1;\n\t\t\t} else {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\n\t\tprivate class SaComparator implements Comparator {\n\n\t\t\t@Override\n\t\t\tpublic int compare(Integer i, Integer j) {\n\t\t\t\tif (rank[i] != rank[j]) {\n\t\t\t\t\treturn Integer.compare(rank[i], rank[j]);\n\t\t\t\t}\n\n\t\t\t\tint ri = i + k <= n ? rank[i + k] : -1;\n\t\t\t\tint rj = j + k <= n ? rank[j + k] : -1;\n\t\t\t\treturn Integer.compare(ri, rj);\n\t\t\t}\n\n\t\t}\n\t}\n\n\t// ---------------------------------------------------\n\tpublic static void main(String[] args) {\n\t\tsc = new Scanner(System.in);\n\t\tpr = new Printer(System.out);\n\n\t\tsolve();\n\n\t\tpr.close();\n\t\tsc.close();\n\t}\n\n\t@SuppressWarnings(\"unused\")\n\tprivate static class Scanner {\n\t\tBufferedReader br;\n\n\t\tScanner (InputStream in) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(in));\n\t\t}\n\n\t\tprivate boolean isPrintable(int ch) {\n\t\t\treturn ch >= '!' && ch <= '~';\n\t\t}\n\n\t\tprivate boolean isCRLF(int ch) {\n\t\t\treturn ch == '\\n' || ch == '\\r' || ch == -1;\n\t\t}\n\n\t\tprivate int nextPrintable() {\n\t\t\ttry {\n\t\t\t\tint ch;\n\t\t\t\twhile (!isPrintable(ch = br.read())) {\n\t\t\t\t\tif (ch == -1) {\n\t\t\t\t\t\tthrow new NoSuchElementException();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn ch;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tString next() {\n\t\t\ttry {\n\t\t\t\tint ch = nextPrintable();\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tdo {\n\t\t\t\t\tsb.appendCodePoint(ch);\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn sb.toString();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tint nextInt() {\n\t\t\ttry {\n\t\t\t\t// parseInt from Integer.parseInt()\n\t\t\t\tboolean negative = false;\n\t\t\t\tint res = 0;\n\t\t\t\tint limit = -Integer.MAX_VALUE;\n\t\t\t\tint radix = 10;\n\n\t\t\t\tint fc = nextPrintable();\n\t\t\t\tif (fc < '0') {\n\t\t\t\t\tif (fc == '-') {\n\t\t\t\t\t\tnegative = true;\n\t\t\t\t\t\tlimit = Integer.MIN_VALUE;\n\t\t\t\t\t} else if (fc != '+') {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tfc = br.read();\n\t\t\t\t}\n\t\t\t\tint multmin = limit / radix;\n\n\t\t\t\tint ch = fc;\n\t\t\t\tdo {\n\t\t\t\t\tint digit = ch - '0';\n\t\t\t\t\tif (digit < 0 || digit >= radix) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tif (res < multmin) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres *= radix;\n\t\t\t\t\tif (res < limit + digit) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres -= digit;\n\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn negative ? res : -res;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\ttry {\n\t\t\t\t// parseLong from Long.parseLong()\n\t\t\t\tboolean negative = false;\n\t\t\t\tlong res = 0;\n\t\t\t\tlong limit = -Long.MAX_VALUE;\n\t\t\t\tint radix = 10;\n\n\t\t\t\tint fc = nextPrintable();\n\t\t\t\tif (fc < '0') {\n\t\t\t\t\tif (fc == '-') {\n\t\t\t\t\t\tnegative = true;\n\t\t\t\t\t\tlimit = Long.MIN_VALUE;\n\t\t\t\t\t} else if (fc != '+') {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tfc = br.read();\n\t\t\t\t}\n\t\t\t\tlong multmin = limit / radix;\n\n\t\t\t\tint ch = fc;\n\t\t\t\tdo {\n\t\t\t\t\tint digit = ch - '0';\n\t\t\t\t\tif (digit < 0 || digit >= radix) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tif (res < multmin) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres *= radix;\n\t\t\t\t\tif (res < limit + digit) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres -= digit;\n\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn negative ? res : -res;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tfloat nextFloat() {\n\t\t\treturn Float.parseFloat(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\ttry {\n\t\t\t\tint ch;\n\t\t\t\twhile (isCRLF(ch = br.read())) {\n\t\t\t\t\tif (ch == -1) {\n\t\t\t\t\t\tthrow new NoSuchElementException();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tdo {\n\t\t\t\t\tsb.appendCodePoint(ch);\n\t\t\t\t} while (!isCRLF(ch = br.read()));\n\n\t\t\t\treturn sb.toString();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tvoid close() {\n\t\t\ttry {\n\t\t\t\tbr.close();\n\t\t\t} catch (IOException e) {\n//\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static class Printer extends PrintWriter {\n\t\tPrinter(PrintStream out) {\n\t\t\tsuper(out);\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1489149948, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02250.html", "problem_id": "p02250", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02250/input.txt", "sample_output_relpath": "derived/input_output/data/p02250/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02250/Java/s280585664.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s280585664", "user_id": "u722784748"}, "prompt_components": {"gold_output": "1\n1\n0\n0\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\n\n\npublic class Main {\n\n\tprivate static Scanner sc;\n\tprivate static Printer pr;\n\n\tprivate static void solve() {\n\t\tchar[] t = sc.next().toCharArray();\n\t\tSuffixArray sa = new SuffixArray(t);\n\n\t\tint q = sc.nextInt();\n\t\tfor (int i = 0; i < q; i++) {\n\t\t\tString p = sc.next();\n\n\t\t\tif (sa.contains(p.toCharArray())) {\n\t\t\t\tpr.println(\"1\");\n\t\t\t} else {\n\t\t\t\tpr.println(\"0\");\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static class SuffixArray {\n\t\tchar[] s;\n\t\tint n;\n\n\t\tInteger[] sa;\n\t\tint[] rank;\n\t\tint[] rtmp;\n\t\tSaComparator sac;\n\n\t\tint k;\n\n\t\tSuffixArray(char[] str) {\n\t\t\tthis.s = str;\n\t\t\tn = s.length;\n\n\t\t\tsa = new Integer[n + 1];\n\t\t\trank = new int[n + 1];\n\t\t\trtmp = new int[n + 1];\n\t\t\tfor (int i = 0; i <= n; i++) {\n\t\t\t\tsa[i] = i;\n\t\t\t\tif (i < n) {\n\t\t\t\t\trank[i] = s[i];\n\t\t\t\t} else {\n\t\t\t\t\trank[i] = 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tsac = new SaComparator();\n\n\t\t\tfor (k = 1; k < n; k *= 2) {\n\t\t\t\tArrays.sort(sa, sac);\n\n\t\t\t\trtmp[sa[0]] = rank[sa[0]];\n\t\t\t\tfor (int i = 1; i <= n; i++) {\n\t\t\t\t\tif (sac.compare(sa[i - 1], sa[i]) == 0) {\n\t\t\t\t\t\trtmp[sa[i]] = rtmp[sa[i - 1]];\n\t\t\t\t\t} else {\n\t\t\t\t\t\trtmp[sa[i]] = rtmp[sa[i - 1]] + 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tint[] tmp = rtmp;\n\t\t\t\trtmp = rank;\n\t\t\t\trank = tmp;\n\t\t\t}\n\t\t}\n\n\t\tboolean contains(char[] t) {\n\t\t\tint l = 0;\n\t\t\tint r = n;\n\t\t\twhile (r > l) {\n\t\t\t\tint mid = l + (r - l) / 2;\n\t\t\t\tint res = compare(s, mid, t);\n\n\t\t\t\tif (res >= 0) {\n\t\t\t\t\tr = mid;\n\t\t\t\t} else {\n\t\t\t\t\tl = mid + 1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn compare(s, l, t) == 0;\n\t\t}\n\n\t\tint compare(char[] s, int mid, char[] t) {\n\t\t\tint m = t.length;\n\n\t\t\tfor (int i = 0; sa[mid] + i < n && i < m; i++) {\n\t\t\t\tint res = s[sa[mid] + i] - t[i];\n\n\t\t\t\tif (res != 0) {\n\t\t\t\t\treturn res;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (sa[mid] + m < m) {\n\t\t\t\treturn -1;\n\t\t\t} else {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\n\t\tprivate class SaComparator implements Comparator {\n\n\t\t\t@Override\n\t\t\tpublic int compare(Integer i, Integer j) {\n\t\t\t\tif (rank[i] != rank[j]) {\n\t\t\t\t\treturn Integer.compare(rank[i], rank[j]);\n\t\t\t\t}\n\n\t\t\t\tint ri = i + k <= n ? rank[i + k] : -1;\n\t\t\t\tint rj = j + k <= n ? rank[j + k] : -1;\n\t\t\t\treturn Integer.compare(ri, rj);\n\t\t\t}\n\n\t\t}\n\t}\n\n\t// ---------------------------------------------------\n\tpublic static void main(String[] args) {\n\t\tsc = new Scanner(System.in);\n\t\tpr = new Printer(System.out);\n\n\t\tsolve();\n\n\t\tpr.close();\n\t\tsc.close();\n\t}\n\n\t@SuppressWarnings(\"unused\")\n\tprivate static class Scanner {\n\t\tBufferedReader br;\n\n\t\tScanner (InputStream in) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(in));\n\t\t}\n\n\t\tprivate boolean isPrintable(int ch) {\n\t\t\treturn ch >= '!' && ch <= '~';\n\t\t}\n\n\t\tprivate boolean isCRLF(int ch) {\n\t\t\treturn ch == '\\n' || ch == '\\r' || ch == -1;\n\t\t}\n\n\t\tprivate int nextPrintable() {\n\t\t\ttry {\n\t\t\t\tint ch;\n\t\t\t\twhile (!isPrintable(ch = br.read())) {\n\t\t\t\t\tif (ch == -1) {\n\t\t\t\t\t\tthrow new NoSuchElementException();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn ch;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tString next() {\n\t\t\ttry {\n\t\t\t\tint ch = nextPrintable();\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tdo {\n\t\t\t\t\tsb.appendCodePoint(ch);\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn sb.toString();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tint nextInt() {\n\t\t\ttry {\n\t\t\t\t// parseInt from Integer.parseInt()\n\t\t\t\tboolean negative = false;\n\t\t\t\tint res = 0;\n\t\t\t\tint limit = -Integer.MAX_VALUE;\n\t\t\t\tint radix = 10;\n\n\t\t\t\tint fc = nextPrintable();\n\t\t\t\tif (fc < '0') {\n\t\t\t\t\tif (fc == '-') {\n\t\t\t\t\t\tnegative = true;\n\t\t\t\t\t\tlimit = Integer.MIN_VALUE;\n\t\t\t\t\t} else if (fc != '+') {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tfc = br.read();\n\t\t\t\t}\n\t\t\t\tint multmin = limit / radix;\n\n\t\t\t\tint ch = fc;\n\t\t\t\tdo {\n\t\t\t\t\tint digit = ch - '0';\n\t\t\t\t\tif (digit < 0 || digit >= radix) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tif (res < multmin) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres *= radix;\n\t\t\t\t\tif (res < limit + digit) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres -= digit;\n\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn negative ? res : -res;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\ttry {\n\t\t\t\t// parseLong from Long.parseLong()\n\t\t\t\tboolean negative = false;\n\t\t\t\tlong res = 0;\n\t\t\t\tlong limit = -Long.MAX_VALUE;\n\t\t\t\tint radix = 10;\n\n\t\t\t\tint fc = nextPrintable();\n\t\t\t\tif (fc < '0') {\n\t\t\t\t\tif (fc == '-') {\n\t\t\t\t\t\tnegative = true;\n\t\t\t\t\t\tlimit = Long.MIN_VALUE;\n\t\t\t\t\t} else if (fc != '+') {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tfc = br.read();\n\t\t\t\t}\n\t\t\t\tlong multmin = limit / radix;\n\n\t\t\t\tint ch = fc;\n\t\t\t\tdo {\n\t\t\t\t\tint digit = ch - '0';\n\t\t\t\t\tif (digit < 0 || digit >= radix) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tif (res < multmin) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres *= radix;\n\t\t\t\t\tif (res < limit + digit) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres -= digit;\n\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn negative ? res : -res;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tfloat nextFloat() {\n\t\t\treturn Float.parseFloat(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\ttry {\n\t\t\t\tint ch;\n\t\t\t\twhile (isCRLF(ch = br.read())) {\n\t\t\t\t\tif (ch == -1) {\n\t\t\t\t\t\tthrow new NoSuchElementException();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tdo {\n\t\t\t\t\tsb.appendCodePoint(ch);\n\t\t\t\t} while (!isCRLF(ch = br.read()));\n\n\t\t\t\treturn sb.toString();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tvoid close() {\n\t\t\ttry {\n\t\t\t\tbr.close();\n\t\t\t} catch (IOException e) {\n//\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static class Printer extends PrintWriter {\n\t\tPrinter(PrintStream out) {\n\t\t\tsuper(out);\n\t\t}\n\t}\n}", "problem_context": "String Search\n\nDetermine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.\n\nInput\n\nIn the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.\n\nOutput\n\nFor each question, print 1 if the text includes P_i, or print 0 otherwise.\n\nConstraints\n\n1 ≤ length of T ≤ 1000000\n\n1 ≤ length of P_i ≤ 1000\n\n1 ≤ Q ≤ 10000\n\nThe input consists of alphabetical characters and digits\n\nSample Input 1\n\naabaaa\n4\naa\nba\nbb\nxyz\n\nSample Output 1\n\n1\n1\n0\n0", "sample_input": "aabaaa\n4\naa\nba\nbb\nxyz\n"}, "reference_outputs": ["1\n1\n0\n0\n"], "source_document_id": "p02250", "source_text": "String Search\n\nDetermine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.\n\nInput\n\nIn the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.\n\nOutput\n\nFor each question, print 1 if the text includes P_i, or print 0 otherwise.\n\nConstraints\n\n1 ≤ length of T ≤ 1000000\n\n1 ≤ length of P_i ≤ 1000\n\n1 ≤ Q ≤ 10000\n\nThe input consists of alphabetical characters and digits\n\nSample Input 1\n\naabaaa\n4\naa\nba\nbb\nxyz\n\nSample Output 1\n\n1\n1\n0\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5777, "cpu_time_ms": 40, "memory_kb": 24228}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s053726102", "group_id": "codeNet:p02255", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint[] A = new int[N];\n\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\n\t\tfor (int i = 1; i < N; i++) {\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tfor (int k : A) {\n\t\t\t\tsb.append(k);\n\t\t\t\tsb.append(\" \");\n\t\t\t}\n\n\t\t\tSystem.out.println(sb.toString().trim());\n\t\t\tint v = A[i];\n\t\t\tint j = i - 1;\n\n\t\t\twhile (j >= 0 && A[j] > v) {\n\t\t\t\tA[j + 1] = A[j];\n\t\t\t\tj--;\n\t\t\t}\n\t\t\tA[j + 1] = v;\n\t\t}\n\t\tStringBuilder sb = new StringBuilder();\n\t\tfor (int k : A) {\n\t\t\tsb.append(k);\n\t\t\tsb.append(\" \");\n\t\t}\n\n\t\tSystem.out.println(sb.toString().trim());\n\t}\n}", "language": "Java", "metadata": {"date": 1452501513, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02255.html", "problem_id": "p02255", "resource_group": "high_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/Java/s053726102.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s053726102", "user_id": "u851161109"}, "prompt_components": {"gold_output": "5 2 4 6 1 3\n2 5 4 6 1 3\n2 4 5 6 1 3\n2 4 5 6 1 3\n1 2 4 5 6 3\n1 2 3 4 5 6\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint[] A = new int[N];\n\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\n\t\tfor (int i = 1; i < N; i++) {\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tfor (int k : A) {\n\t\t\t\tsb.append(k);\n\t\t\t\tsb.append(\" \");\n\t\t\t}\n\n\t\t\tSystem.out.println(sb.toString().trim());\n\t\t\tint v = A[i];\n\t\t\tint j = i - 1;\n\n\t\t\twhile (j >= 0 && A[j] > v) {\n\t\t\t\tA[j + 1] = A[j];\n\t\t\t\tj--;\n\t\t\t}\n\t\t\tA[j + 1] = v;\n\t\t}\n\t\tStringBuilder sb = new StringBuilder();\n\t\tfor (int k : A) {\n\t\t\tsb.append(k);\n\t\t\tsb.append(\" \");\n\t\t}\n\n\t\tSystem.out.println(sb.toString().trim());\n\t}\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": 698, "cpu_time_ms": 110, "memory_kb": 29056}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s809052411", "group_id": "codeNet:p02255", "input_text": "import java.util.Scanner;\npublic class Main {\n\t\n\tpublic static void main(String arg[]){\n\t\tScanner in = new Scanner(System.in);\n\t\t\n\t\tint n = in.nextInt();\n\t\tint[] input = new int[n];\n\t\t\n\t\tfor(int i=0; i < n; i++){\n\t\t\tinput[i] = in.nextInt();\n\t\t}\t\n\t\t\n\t\tfor(int i=0; i < input.length; i++){\n\t\t\tSystem.out.print(input[i] + \" \");\n\t\t}\n\t\tSystem.out.println();\n\t\t\n\t\tfor(int i=1; i < input.length; i++){\n\t\t\tint key = input[i];\n\t\t\tint j = i-1;\n\t\t\twhile(j >=0 && input[j] > key){\n\t\t\t\tinput[j+1] = input[j];\n\t\t\t\tj--;\n\t\t\t}\n\t\t\tinput[j+1] = key;\n\t\t\tfor(int k=0; k < input.length; k++){\n\t\t\t\tSystem.out.print(input[k] + \" \");\n\t\t\t}\n\t\t\tSystem.out.println();\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1399018017, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02255.html", "problem_id": "p02255", "resource_group": "high_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/Java/s809052411.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s809052411", "user_id": "u340901659"}, "prompt_components": {"gold_output": "5 2 4 6 1 3\n2 5 4 6 1 3\n2 4 5 6 1 3\n2 4 5 6 1 3\n1 2 4 5 6 3\n1 2 3 4 5 6\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main {\n\t\n\tpublic static void main(String arg[]){\n\t\tScanner in = new Scanner(System.in);\n\t\t\n\t\tint n = in.nextInt();\n\t\tint[] input = new int[n];\n\t\t\n\t\tfor(int i=0; i < n; i++){\n\t\t\tinput[i] = in.nextInt();\n\t\t}\t\n\t\t\n\t\tfor(int i=0; i < input.length; i++){\n\t\t\tSystem.out.print(input[i] + \" \");\n\t\t}\n\t\tSystem.out.println();\n\t\t\n\t\tfor(int i=1; i < input.length; i++){\n\t\t\tint key = input[i];\n\t\t\tint j = i-1;\n\t\t\twhile(j >=0 && input[j] > key){\n\t\t\t\tinput[j+1] = input[j];\n\t\t\t\tj--;\n\t\t\t}\n\t\t\tinput[j+1] = key;\n\t\t\tfor(int k=0; k < input.length; k++){\n\t\t\t\tSystem.out.print(input[k] + \" \");\n\t\t\t}\n\t\t\tSystem.out.println();\n\t\t}\n\t}\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": 647, "cpu_time_ms": 40, "memory_kb": 17176}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s155186007", "group_id": "codeNet:p02256", "input_text": "import java.util.Scanner;\npublic class Main {\n\tpublic static void main(String[] arg){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint a = sc.nextInt();\n\t\tint b = sc.nextInt();\n\t\tif(a >= b){\n\t\t\tgcd(a,b);\n\t\t}else{\n\t\t\tgcd(b,a);\n\t\t}\n\t}\n\t\n\tstatic void gcd(int n,int m){\n\t\tif((n % m) == 0) {\n\t\t\tSystem.out.println(m);\n\t\t}else if(m == 1){\n\t\t\tSystem.out.println(1);\n\t\t}else{\n\t\t\tint m1 = (n % m);\n\t\t\tgcd(m,m1);\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1399019927, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02256.html", "problem_id": "p02256", "resource_group": "high_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/Java/s155186007.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s155186007", "user_id": "u340901659"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main {\n\tpublic static void main(String[] arg){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint a = sc.nextInt();\n\t\tint b = sc.nextInt();\n\t\tif(a >= b){\n\t\t\tgcd(a,b);\n\t\t}else{\n\t\t\tgcd(b,a);\n\t\t}\n\t}\n\t\n\tstatic void gcd(int n,int m){\n\t\tif((n % m) == 0) {\n\t\t\tSystem.out.println(m);\n\t\t}else if(m == 1){\n\t\t\tSystem.out.println(1);\n\t\t}else{\n\t\t\tint m1 = (n % m);\n\t\t\tgcd(m,m1);\n\t\t}\n\t}\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": 407, "cpu_time_ms": 50, "memory_kb": 17324}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s134484288", "group_id": "codeNet:p02257", "input_text": "import java.util.Scanner;\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint cnt = 0;\n\t\tint[] num = new int[n];\n\t\tfor(int i = 0; i < n; i ++){\n\t\t\tnum[i] = sc.nextInt();\n\t\t}\n\t\tSystem.out.println(judge(num));\n\t}\n\tstatic int judge(int[] num){\n\t\tfinal int max = 1000000 + 1;\n\t\tint cnt = 0;\n\t\tboolean isp = false;\n\t\tfor(int i = 0; i < num.length; i++){\n\t\t\tisp = true;\n\t\t\tif(num[i] == (2|3|5|7)) {\n\t\t\t\tcnt++; continue;\n\t\t\t}\n\t\t\tfor(int j = 2; j < num[i]/2; j++){\n\t\t\t\tif(num[i] % j == 0) {\n\t\t\t\t\tisp = false; break;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(isp) cnt++;\n\t\t}\n\t\treturn cnt;\n\t}\n}", "language": "Java", "metadata": {"date": 1463669858, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02257.html", "problem_id": "p02257", "resource_group": "high_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/Java/s134484288.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s134484288", "user_id": "u765849500"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint cnt = 0;\n\t\tint[] num = new int[n];\n\t\tfor(int i = 0; i < n; i ++){\n\t\t\tnum[i] = sc.nextInt();\n\t\t}\n\t\tSystem.out.println(judge(num));\n\t}\n\tstatic int judge(int[] num){\n\t\tfinal int max = 1000000 + 1;\n\t\tint cnt = 0;\n\t\tboolean isp = false;\n\t\tfor(int i = 0; i < num.length; i++){\n\t\t\tisp = true;\n\t\t\tif(num[i] == (2|3|5|7)) {\n\t\t\t\tcnt++; continue;\n\t\t\t}\n\t\t\tfor(int j = 2; j < num[i]/2; j++){\n\t\t\t\tif(num[i] % j == 0) {\n\t\t\t\t\tisp = false; break;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(isp) cnt++;\n\t\t}\n\t\treturn cnt;\n\t}\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": 638, "cpu_time_ms": 60, "memory_kb": 26268}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s812233098", "group_id": "codeNet:p02258", "input_text": "import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] a) {\n\t\tScanner input = new Scanner(System.in);\n\t\tint loop = input.nextInt();\n\t\tint max = -1;\n\t\tint[] num = new int[loop];\n\n\t\tif (loop >= 2 && loop <= 200000) {\n\n\t\t\tfor (int i = 0; i < loop; i++) {\n\t\t\t\tint newNum = input.nextInt();\n\n\t\t\t\tif (newNum >= 1 && newNum <= 1000000000) {\n\t\t\t\t\tnum[i] = newNum;\n\t\t\t\t\tif (i == 1)\n\t\t\t\t\t\tmax = num[1] - num[0];\n\n\t\t\t\t\tif (i > 0) {\n\n\t\t\t\t\t\tfor (int j = 0; j < i; j++) {\n\t\t\t\t\t\t\tmax = newNum - num[j] >= max ? newNum - num[j]\n\t\t\t\t\t\t\t\t\t: max;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tSystem.out.println(max);\n\n\t\t}\n\n\t}\n\n}", "language": "Java", "metadata": {"date": 1482298319, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02258.html", "problem_id": "p02258", "resource_group": "high_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/Java/s812233098.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s812233098", "user_id": "u379769644"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] a) {\n\t\tScanner input = new Scanner(System.in);\n\t\tint loop = input.nextInt();\n\t\tint max = -1;\n\t\tint[] num = new int[loop];\n\n\t\tif (loop >= 2 && loop <= 200000) {\n\n\t\t\tfor (int i = 0; i < loop; i++) {\n\t\t\t\tint newNum = input.nextInt();\n\n\t\t\t\tif (newNum >= 1 && newNum <= 1000000000) {\n\t\t\t\t\tnum[i] = newNum;\n\t\t\t\t\tif (i == 1)\n\t\t\t\t\t\tmax = num[1] - num[0];\n\n\t\t\t\t\tif (i > 0) {\n\n\t\t\t\t\t\tfor (int j = 0; j < i; j++) {\n\t\t\t\t\t\t\tmax = newNum - num[j] >= max ? newNum - num[j]\n\t\t\t\t\t\t\t\t\t: max;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tSystem.out.println(max);\n\n\t\t}\n\n\t}\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": 615, "cpu_time_ms": 13380, "memory_kb": 65968}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s860225350", "group_id": "codeNet:p02258", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n public static void main(String[] args) throws IOException {\n \n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n int n = Integer.parseInt(br.readLine());\n int minv = Integer.parseInt(br.readLine());\n int n1 = Integer.parseInt(br.readLine());\n int maxv = n1- minv;\n if ( n1 < minv ) minv = n1;\n\n for( int i=2,r,mv; i maxv ) maxv = mv;\n else if ( r < minv ) minv = r; \n }\n\n System.out.println(maxv);\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1528436317, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02258.html", "problem_id": "p02258", "resource_group": "high_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/Java/s860225350.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s860225350", "user_id": "u768801062"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n public static void main(String[] args) throws IOException {\n \n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n int n = Integer.parseInt(br.readLine());\n int minv = Integer.parseInt(br.readLine());\n int n1 = Integer.parseInt(br.readLine());\n int maxv = n1- minv;\n if ( n1 < minv ) minv = n1;\n\n for( int i=2,r,mv; i maxv ) maxv = mv;\n else if ( r < minv ) minv = r; \n }\n\n System.out.println(maxv);\n }\n }\n}\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Profit\n\nYou can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.\n\nWrite a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .\n\nInput\n\nThe first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.\n\nOutput\n\nPrint the maximum value in a line.\n\nConstraints\n\n$2 \\leq n \\leq 200,000$\n\n$1 \\leq R_t \\leq 10^9$\n\nSample Input 1\n\n6\n5\n3\n1\n3\n4\n3\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n4\n3\n2\n\nSample Output 2\n\n-1", "sample_input": "6\n5\n3\n1\n3\n4\n3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02258", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Profit\n\nYou can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.\n\nWrite a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .\n\nInput\n\nThe first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.\n\nOutput\n\nPrint the maximum value in a line.\n\nConstraints\n\n$2 \\leq n \\leq 200,000$\n\n$1 \\leq R_t \\leq 10^9$\n\nSample Input 1\n\n6\n5\n3\n1\n3\n4\n3\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n4\n3\n2\n\nSample Output 2\n\n-1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 150, "memory_kb": 42116}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s113541456", "group_id": "codeNet:p02258", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tInteger i,j,max=0,n = sc.nextInt(),res = Integer.MIN_VALUE;\n\t\tint [] price = new int [n];\n\n\t\tfor(i=0;i 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": 448, "cpu_time_ms": 4390, "memory_kb": 703968}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s164360234", "group_id": "codeNet:p02259", "input_text": "import java.util.Scanner;\n\npublic class Main{\n public static void main(String[] args){\n int N;\n int num[];\n String line;\n\n Scanner scan=new Scanner(System.in);\n\n line=scan.next();\n N=Integer.parseInt(line);\n\n if(N<1||100100){\n return;\n }\n }\n\n //バブルソート\n int swap_num=0;\n for(int i=0;ii;j--){\n if(num[j]100){\n return;\n }\n }\n\n //バブルソート\n int swap_num=0;\n for(int i=0;ii;j--){\n if(num[j]= 1; i--) {\n\t\t\t\tif (A[i] < A[i-1]) {\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i-1];\n\t\t\t\t\tA[i-1] = tmp;\n\t\t\t\t\tf = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tvoid run() {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tint[] A = new int[n];\n\t\tfor (int i = 0; i < A.length; i++) {\n\t\t\tA[i] = scan.nextInt();\n\t\t}\n\t\tcount = 0;\n\t\tbubbleSort(A);\n\t\tfor (int i = 0; i < A.length; i++) {\n\t\t\tSystem.out.print(A[i] + \" \");\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\tnew Main().run();\n\t}\n\n}\n\n", "language": "Java", "metadata": {"date": 1526911052, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02259.html", "problem_id": "p02259", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02259/input.txt", "sample_output_relpath": "derived/input_output/data/p02259/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02259/Java/s295300600.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s295300600", "user_id": "u125740762"}, "prompt_components": {"gold_output": "1 2 3 4 5\n8\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\t\n\tint count = 0;\n\t\n\tvoid bubbleSort(int[] A) {\n\t\tboolean f = true;\n\t\twhile (f) {\n\t\t\tf = false;\n\t\t\tfor (int i = A.length - 1; i >= 1; i--) {\n\t\t\t\tif (A[i] < A[i-1]) {\n\t\t\t\t\tint tmp = A[i];\n\t\t\t\t\tA[i] = A[i-1];\n\t\t\t\t\tA[i-1] = tmp;\n\t\t\t\t\tf = true;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tvoid run() {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tint[] A = new int[n];\n\t\tfor (int i = 0; i < A.length; i++) {\n\t\t\tA[i] = scan.nextInt();\n\t\t}\n\t\tcount = 0;\n\t\tbubbleSort(A);\n\t\tfor (int i = 0; i < A.length; i++) {\n\t\t\tSystem.out.print(A[i] + \" \");\n\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(count);\n\t}\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\tnew Main().run();\n\t}\n\n}\n\n", "problem_context": "Bubble Sort\n\nWrite a program of the Bubble Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nBubbleSort(A)\n1 for i = 0 to A.length-1\n2 for j = A.length-1 downto i+1\n3 if A[j] < A[j-1]\n4 swap A[j] and A[j-1]\n\nNote that, indices for array elements are based on 0-origin.\n\nYour program should also print the number of swap operations defined in line 4 of the pseudocode.\n\nInput\n\nThe first line of the input includes an integer N, the number of elements in the sequence.\n\nIn the second line, N elements of the sequence are given separated by spaces characters.\n\nOutput\n\nThe output consists of 2 lines.\n\nIn the first line, please print the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nIn the second line, please print the number of swap operations.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nSample Input 1\n\n5\n5 3 2 4 1\n\nSample Output 1\n\n1 2 3 4 5\n8\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n9", "sample_input": "5\n5 3 2 4 1\n"}, "reference_outputs": ["1 2 3 4 5\n8\n"], "source_document_id": "p02259", "source_text": "Bubble Sort\n\nWrite a program of the Bubble Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nBubbleSort(A)\n1 for i = 0 to A.length-1\n2 for j = A.length-1 downto i+1\n3 if A[j] < A[j-1]\n4 swap A[j] and A[j-1]\n\nNote that, indices for array elements are based on 0-origin.\n\nYour program should also print the number of swap operations defined in line 4 of the pseudocode.\n\nInput\n\nThe first line of the input includes an integer N, the number of elements in the sequence.\n\nIn the second line, N elements of the sequence are given separated by spaces characters.\n\nOutput\n\nThe output consists of 2 lines.\n\nIn the first line, please print the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nIn the second line, please print the number of swap operations.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nSample Input 1\n\n5\n5 3 2 4 1\n\nSample Output 1\n\n1 2 3 4 5\n8\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n9", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 757, "cpu_time_ms": 50, "memory_kb": 25760}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s648877841", "group_id": "codeNet:p02260", "input_text": "import java.util.StringTokenizer;\nimport java.io.BufferedReader;\nimport java.io.InputStream;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.Arrays;\n\nclass Main{\n public static void main(String[] args){\n\tint N;\n\tboolean stablejudge = true;\n\tInputStream inputStream = System.in;\n\tInputReader input = new InputReader(inputStream);\n\tN = input.nextInt();\n\t// String[] nums = new String[N];\n\t// String[] numSelectionString = new String[N];\n\t// String[] numBubbleString = new String[N];\n\tint[] nums = new int[N];\n\t// int[] numSelection = new int[N];\n\tfor(int i = 0;i < N;i++){\n\t nums[i] = input.nextInt();\n\t // numBubbleString[i] = nums[i];\n\t // numSelectionString[i] = nums[i];\n\t // numBubble[i] = Integer.parseInt(nums[i].substring(1));\n\t // numSelection[i] = Integer.parseInt(nums[i].substring(1));\n\t}\n\tselectionSort(N,nums);\n }\n\t// print(bubbleSort(N,numBubble,numBubbleString));\n\t// \tisStable(bubbleSort(N,numBubble,numBubbleString),bubbleSort(N,numBubble,numBubbleString));\n\t // isStable(bubbleSort(N,numBubble,numBubbleString),selectionSort(N,numSelection,numSelectionString));\n\t \n\n // public static String[] bubbleSort(int N,int[] numBubble,String[] numBubbleString){\n // \tfor(int i = 0;i < N - 1;i++){\n // \t for(int j = N - 1;j > i;j--){\n // \t\tif(numBubble[j - 1] > numBubble[j]){\n // \t\t int tmp = numBubble[j - 1];\n // \t\t numBubble[j - 1] = numBubble[j];\n // \t\t numBubble[j] = tmp;\n\n // \t\t String temp = numBubbleString[j - 1];\n // \t\t numBubbleString[j - 1] = numBubbleString[j];\n // \t\t numBubbleString[j] = temp;\n // \t\t}\n // \t }\n // \t}\n // \treturn numBubbleString;\n // }\n\t \n\t public static void selectionSort(int N,int[] numSelection){\n\t int count = 0;\n\t for(int i = 0;i < N;i++){\n\t\tint minj = i;\n\t\tfor(int j = i;j < N;j++){\n\t\t //最小の要素を見つける\n\t\t if(numSelection[j] < numSelection[minj]){\n\t\t\t//最小の要素の添字をminjに代入\n\t\t\tminj = j;\n\t\t\t\n\t\t }\n\t\t}\n\t\t\n\t\tif(numSelection[i] != numSelection[minj]){\n\t\t int tmp = numSelection[i];\n\t\t numSelection[i] = numSelection[minj];\n\t\t numSelection[minj] = tmp;\n\n\t\t count++;\n\t\t // String temp = numSelectionString[i];\n\t\t // numSelectionString[i] = numSelectionString[minj];\n\t\t // numSelectionString[minj] = temp;\n\t\t}\n\t }\n\t print(numSelection);\n\t System.out.println(count);\n\t \n\t// return numSelectionString;\n\t}\n\t\n\t\n\t\n\tpublic static void print(int[] num){\n\t String ans;\n \tans = Arrays.toString(num); //文字列に変換する\n \tans = ans.replaceAll(\",\", \"\"); //\",\"を消去\n \tans = ans.replace(\"[\", \"\"); // \"[\"を消去\n \tans = ans.replace(\"]\", \"\"); // \"]\"を消去\n \tSystem.out.println(ans);\n }\n // static void print(String[] nums){\n // \tfor (int i = 0; i < nums.length; i++) {\n // if (i != 0) {\n // System.out.print(\" \");\n // }\n // System.out.print(nums[i]);\n // }\n // System.out.println();\n // }\n // static void isStable(String[] stable,String[] target){\n\n\t// if(Arrays.equals(stable,target)){\n\t// System.out.println(\"Stable\");\n\t// }else{\n\t// System.out.println(\"Not stable\");\n\t// }\n}\n\n\nclass InputReader{\n StringTokenizer tokenizer;\n BufferedReader reader;\n //コンストラクタ\n public InputReader(InputStream stream){\n\t/*InputStreamReaderはバイトストリームから文字ストリームの橋渡しの役目を持ちこれ\n\t が最高効率となる形になる*/\n\treader = new BufferedReader(new InputStreamReader(stream),32768);\n\ttokenizer = null;\n }\n public String next(){\n\twhile(tokenizer == null || !tokenizer.hasMoreTokens()){\n\t try{\n\t\ttokenizer = new StringTokenizer(reader.readLine());\n\t }catch(IOException e){\n\t\tthrow new RuntimeException(e);\n\t }\n\t}\n\treturn tokenizer.nextToken();\n }\n public int nextInt(){\n\t\n\treturn Integer.parseInt(next());\n }\n}\n\n", "language": "Java", "metadata": {"date": 1575873585, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02260.html", "problem_id": "p02260", "resource_group": "high_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/Java/s648877841.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s648877841", "user_id": "u535839689"}, "prompt_components": {"gold_output": "1 2 3 4 5 6\n4\n", "input_to_evaluate": "import java.util.StringTokenizer;\nimport java.io.BufferedReader;\nimport java.io.InputStream;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.Arrays;\n\nclass Main{\n public static void main(String[] args){\n\tint N;\n\tboolean stablejudge = true;\n\tInputStream inputStream = System.in;\n\tInputReader input = new InputReader(inputStream);\n\tN = input.nextInt();\n\t// String[] nums = new String[N];\n\t// String[] numSelectionString = new String[N];\n\t// String[] numBubbleString = new String[N];\n\tint[] nums = new int[N];\n\t// int[] numSelection = new int[N];\n\tfor(int i = 0;i < N;i++){\n\t nums[i] = input.nextInt();\n\t // numBubbleString[i] = nums[i];\n\t // numSelectionString[i] = nums[i];\n\t // numBubble[i] = Integer.parseInt(nums[i].substring(1));\n\t // numSelection[i] = Integer.parseInt(nums[i].substring(1));\n\t}\n\tselectionSort(N,nums);\n }\n\t// print(bubbleSort(N,numBubble,numBubbleString));\n\t// \tisStable(bubbleSort(N,numBubble,numBubbleString),bubbleSort(N,numBubble,numBubbleString));\n\t // isStable(bubbleSort(N,numBubble,numBubbleString),selectionSort(N,numSelection,numSelectionString));\n\t \n\n // public static String[] bubbleSort(int N,int[] numBubble,String[] numBubbleString){\n // \tfor(int i = 0;i < N - 1;i++){\n // \t for(int j = N - 1;j > i;j--){\n // \t\tif(numBubble[j - 1] > numBubble[j]){\n // \t\t int tmp = numBubble[j - 1];\n // \t\t numBubble[j - 1] = numBubble[j];\n // \t\t numBubble[j] = tmp;\n\n // \t\t String temp = numBubbleString[j - 1];\n // \t\t numBubbleString[j - 1] = numBubbleString[j];\n // \t\t numBubbleString[j] = temp;\n // \t\t}\n // \t }\n // \t}\n // \treturn numBubbleString;\n // }\n\t \n\t public static void selectionSort(int N,int[] numSelection){\n\t int count = 0;\n\t for(int i = 0;i < N;i++){\n\t\tint minj = i;\n\t\tfor(int j = i;j < N;j++){\n\t\t //最小の要素を見つける\n\t\t if(numSelection[j] < numSelection[minj]){\n\t\t\t//最小の要素の添字をminjに代入\n\t\t\tminj = j;\n\t\t\t\n\t\t }\n\t\t}\n\t\t\n\t\tif(numSelection[i] != numSelection[minj]){\n\t\t int tmp = numSelection[i];\n\t\t numSelection[i] = numSelection[minj];\n\t\t numSelection[minj] = tmp;\n\n\t\t count++;\n\t\t // String temp = numSelectionString[i];\n\t\t // numSelectionString[i] = numSelectionString[minj];\n\t\t // numSelectionString[minj] = temp;\n\t\t}\n\t }\n\t print(numSelection);\n\t System.out.println(count);\n\t \n\t// return numSelectionString;\n\t}\n\t\n\t\n\t\n\tpublic static void print(int[] num){\n\t String ans;\n \tans = Arrays.toString(num); //文字列に変換する\n \tans = ans.replaceAll(\",\", \"\"); //\",\"を消去\n \tans = ans.replace(\"[\", \"\"); // \"[\"を消去\n \tans = ans.replace(\"]\", \"\"); // \"]\"を消去\n \tSystem.out.println(ans);\n }\n // static void print(String[] nums){\n // \tfor (int i = 0; i < nums.length; i++) {\n // if (i != 0) {\n // System.out.print(\" \");\n // }\n // System.out.print(nums[i]);\n // }\n // System.out.println();\n // }\n // static void isStable(String[] stable,String[] target){\n\n\t// if(Arrays.equals(stable,target)){\n\t// System.out.println(\"Stable\");\n\t// }else{\n\t// System.out.println(\"Not stable\");\n\t// }\n}\n\n\nclass InputReader{\n StringTokenizer tokenizer;\n BufferedReader reader;\n //コンストラクタ\n public InputReader(InputStream stream){\n\t/*InputStreamReaderはバイトストリームから文字ストリームの橋渡しの役目を持ちこれ\n\t が最高効率となる形になる*/\n\treader = new BufferedReader(new InputStreamReader(stream),32768);\n\ttokenizer = null;\n }\n public String next(){\n\twhile(tokenizer == null || !tokenizer.hasMoreTokens()){\n\t try{\n\t\ttokenizer = new StringTokenizer(reader.readLine());\n\t }catch(IOException e){\n\t\tthrow new RuntimeException(e);\n\t }\n\t}\n\treturn tokenizer.nextToken();\n }\n public int nextInt(){\n\t\n\treturn Integer.parseInt(next());\n }\n}\n\n", "problem_context": "Selection Sort\n\nWrite a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nSelectionSort(A)\n1 for i = 0 to A.length-1\n2 mini = i\n3 for j = i to A.length-1\n4 if A[j] < A[mini]\n5 mini = j\n6 swap A[i] and A[mini]\n\nNote that, indices for array elements are based on 0-origin.\n\nYour program should also print the number of swap operations defined in line 6 of the pseudocode in the case where i ≠ mini.\n\nInput\n\nThe first line of the input includes an integer N, the number of elements in the sequence.\n\nIn the second line, N elements of the sequence are given separated by space characters.\n\nOutput\n\nThe output consists of 2 lines.\n\nIn the first line, please print the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nIn the second line, please print the number of swap operations.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nSample Input 1\n\n6\n5 6 4 2 1 3\n\nSample Output 1\n\n1 2 3 4 5 6\n4\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n3", "sample_input": "6\n5 6 4 2 1 3\n"}, "reference_outputs": ["1 2 3 4 5 6\n4\n"], "source_document_id": "p02260", "source_text": "Selection Sort\n\nWrite a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nSelectionSort(A)\n1 for i = 0 to A.length-1\n2 mini = i\n3 for j = i to A.length-1\n4 if A[j] < A[mini]\n5 mini = j\n6 swap A[i] and A[mini]\n\nNote that, indices for array elements are based on 0-origin.\n\nYour program should also print the number of swap operations defined in line 6 of the pseudocode in the case where i ≠ mini.\n\nInput\n\nThe first line of the input includes an integer N, the number of elements in the sequence.\n\nIn the second line, N elements of the sequence are given separated by space characters.\n\nOutput\n\nThe output consists of 2 lines.\n\nIn the first line, please print the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nIn the second line, please print the number of swap operations.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nSample Input 1\n\n6\n5 6 4 2 1 3\n\nSample Output 1\n\n1 2 3 4 5 6\n4\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3974, "cpu_time_ms": 50, "memory_kb": 24544}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s565417441", "group_id": "codeNet:p02260", "input_text": "\nimport java.util.Scanner;\n\npublic class Main {\n public static void trace(int[] a,int n){\n for (int i = 0;i < n;i++){\n if(i > 0)\n System.out.print(\" \");\n System.out.print(a[i]);\n }\n System.out.print(\"\\n\");\n }\n\n public static int selectionSort(int[] a,int n){\n int count = 0;\n for(int i = 0;i < n;i++){\n int minj = i;\n int j;\n for(j = i;j < n;j++){\n if(a[j] < a[minj]){\n minj = j;\n }\n }\n int temp = a[i];\n a[i] = a[minj];\n a[minj] = temp;\n if(minj != i)\n count++;\n }\n return count;\n }\n\n public static void main(String[] args) {\n int n;\n int[] a = new int[100];\n Scanner sc = new Scanner(System.in);\n n = sc.nextInt();\n for (int i = 0; i < n; i++)\n a[i] = sc.nextInt();\n int count = selectionSort(a,n);\n trace(a, n);\n System.out.println(count);\n }\n}\n", "language": "Java", "metadata": {"date": 1569392779, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02260.html", "problem_id": "p02260", "resource_group": "high_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/Java/s565417441.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s565417441", "user_id": "u838514302"}, "prompt_components": {"gold_output": "1 2 3 4 5 6\n4\n", "input_to_evaluate": "\nimport java.util.Scanner;\n\npublic class Main {\n public static void trace(int[] a,int n){\n for (int i = 0;i < n;i++){\n if(i > 0)\n System.out.print(\" \");\n System.out.print(a[i]);\n }\n System.out.print(\"\\n\");\n }\n\n public static int selectionSort(int[] a,int n){\n int count = 0;\n for(int i = 0;i < n;i++){\n int minj = i;\n int j;\n for(j = i;j < n;j++){\n if(a[j] < a[minj]){\n minj = j;\n }\n }\n int temp = a[i];\n a[i] = a[minj];\n a[minj] = temp;\n if(minj != i)\n count++;\n }\n return count;\n }\n\n public static void main(String[] args) {\n int n;\n int[] a = new int[100];\n Scanner sc = new Scanner(System.in);\n n = sc.nextInt();\n for (int i = 0; i < n; i++)\n a[i] = sc.nextInt();\n int count = selectionSort(a,n);\n trace(a, n);\n System.out.println(count);\n }\n}\n", "problem_context": "Selection Sort\n\nWrite a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nSelectionSort(A)\n1 for i = 0 to A.length-1\n2 mini = i\n3 for j = i to A.length-1\n4 if A[j] < A[mini]\n5 mini = j\n6 swap A[i] and A[mini]\n\nNote that, indices for array elements are based on 0-origin.\n\nYour program should also print the number of swap operations defined in line 6 of the pseudocode in the case where i ≠ mini.\n\nInput\n\nThe first line of the input includes an integer N, the number of elements in the sequence.\n\nIn the second line, N elements of the sequence are given separated by space characters.\n\nOutput\n\nThe output consists of 2 lines.\n\nIn the first line, please print the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nIn the second line, please print the number of swap operations.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nSample Input 1\n\n6\n5 6 4 2 1 3\n\nSample Output 1\n\n1 2 3 4 5 6\n4\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n3", "sample_input": "6\n5 6 4 2 1 3\n"}, "reference_outputs": ["1 2 3 4 5 6\n4\n"], "source_document_id": "p02260", "source_text": "Selection Sort\n\nWrite a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nSelectionSort(A)\n1 for i = 0 to A.length-1\n2 mini = i\n3 for j = i to A.length-1\n4 if A[j] < A[mini]\n5 mini = j\n6 swap A[i] and A[mini]\n\nNote that, indices for array elements are based on 0-origin.\n\nYour program should also print the number of swap operations defined in line 6 of the pseudocode in the case where i ≠ mini.\n\nInput\n\nThe first line of the input includes an integer N, the number of elements in the sequence.\n\nIn the second line, N elements of the sequence are given separated by space characters.\n\nOutput\n\nThe output consists of 2 lines.\n\nIn the first line, please print the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nIn the second line, please print the number of swap operations.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nSample Input 1\n\n6\n5 6 4 2 1 3\n\nSample Output 1\n\n1 2 3 4 5 6\n4\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1071, "cpu_time_ms": 80, "memory_kb": 26396}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s124941891", "group_id": "codeNet:p02261", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.StringTokenizer;\n\npublic class Main {\n\tprivate static FastScanner sc = new FastScanner();\n\tprivate static final int MAX_NUM = 9;\n\n\tpublic static void main(String[] args) {\n\t\tint N = sc.nextInt();\n\n\t\tCard[] C = new Card[N];\n\t\tCard[] C_before = new Card[N];\n\t\tfor(int i=0; ii; j--) {\n\t\t\t\tif(C[j].num < C[j-1].num){\n\t\t\t\t\tCard temp = C[j];\n\t\t\t\t\tC[j] = C[j-1];\n\t\t\t\t\tC[j-1] = temp;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i=0; ii; j--) {\n\t\t\t\tif(C[j].num < C[j-1].num){\n\t\t\t\t\tCard temp = C[j];\n\t\t\t\t\tC[j] = C[j-1];\n\t\t\t\t\tC[j-1] = temp;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i=0; i= i + 1; j--) {\n if (a[j].value < a[j-1].value) {\n Card t = a[j];\n a[j] = a[j-1];\n a[j-1] = t;\n flag = true;\n }\n }\n }\n }\n\n static void selectionSort(Card[] a, int n) {\n for (int i = 0; i < n; i++) {\n int minj = i;\n for (int j = i; j < n; j++) \n if (a[j].value < a[minj].value) \n minj = j;\n Card t = a[i];\n a[i] = a[minj];\n a[minj] = t;\n }\n }\n\n static boolean isStable(Card[] c1, Card[] c2, int n) {\n for (int i = 0; i < n; i++) \n if (c1[i].suit != c2[i].suit) return false;\n return true;\n }\n\n static void print(Card[] a, int n) {\n for (int i = 0; i < n; i++) {\n System.out.print(a[i].suit);\n System.out.print(a[i].value);\n if (i != n - 1) System.out.print(' ');\n else System.out.println();\n }\n }\n \n public static void main(String[] args) {\n Scanner stdIn = new Scanner(System.in);\n int n = stdIn.nextInt();\n Card[] c1 = new Card[n];\n Card[] c2 = new Card[n];\n String[] s = new String[n];\n for (int i = 0; i < n; i++) {\n c1[i] = new Card();\n c2[i] = new Card();\n s[i] = stdIn.next();\n c1[i].suit = s[i].charAt(0);\n c1[i].value = Integer.parseInt(s[i].substring(1,2));\n c2[i] = c1[i];\n }\n bubbleSort(c1, n);\n selectionSort(c2, n);\n print(c1, n);\n System.out.println(\"Stable\");\n print(c2, n);\n if (isStable(c1, c2, n)) System.out.println(\"Stable\");\n else System.out.println(\"Not stable\");\n }\n}", "language": "Java", "metadata": {"date": 1496493760, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02261.html", "problem_id": "p02261", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02261/input.txt", "sample_output_relpath": "derived/input_output/data/p02261/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02261/Java/s224373347.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s224373347", "user_id": "u671560012"}, "prompt_components": {"gold_output": "D2 C3 H4 S4 C9\nStable\nD2 C3 S4 H4 C9\nNot stable\n", "input_to_evaluate": "import java.util.Scanner;\n\nclass Card {\n char suit;\n int value;\n}\n\n\npublic class Main {\n static void bubbleSort(Card[] a, int n) {\n boolean flag = true;\n for (int i = 0; flag; i ++) {\n flag = false;\n for (int j = n - 1; j >= i + 1; j--) {\n if (a[j].value < a[j-1].value) {\n Card t = a[j];\n a[j] = a[j-1];\n a[j-1] = t;\n flag = true;\n }\n }\n }\n }\n\n static void selectionSort(Card[] a, int n) {\n for (int i = 0; i < n; i++) {\n int minj = i;\n for (int j = i; j < n; j++) \n if (a[j].value < a[minj].value) \n minj = j;\n Card t = a[i];\n a[i] = a[minj];\n a[minj] = t;\n }\n }\n\n static boolean isStable(Card[] c1, Card[] c2, int n) {\n for (int i = 0; i < n; i++) \n if (c1[i].suit != c2[i].suit) return false;\n return true;\n }\n\n static void print(Card[] a, int n) {\n for (int i = 0; i < n; i++) {\n System.out.print(a[i].suit);\n System.out.print(a[i].value);\n if (i != n - 1) System.out.print(' ');\n else System.out.println();\n }\n }\n \n public static void main(String[] args) {\n Scanner stdIn = new Scanner(System.in);\n int n = stdIn.nextInt();\n Card[] c1 = new Card[n];\n Card[] c2 = new Card[n];\n String[] s = new String[n];\n for (int i = 0; i < n; i++) {\n c1[i] = new Card();\n c2[i] = new Card();\n s[i] = stdIn.next();\n c1[i].suit = s[i].charAt(0);\n c1[i].value = Integer.parseInt(s[i].substring(1,2));\n c2[i] = c1[i];\n }\n bubbleSort(c1, n);\n selectionSort(c2, n);\n print(c1, n);\n System.out.println(\"Stable\");\n print(c2, n);\n if (isStable(c1, c2, n)) System.out.println(\"Stable\");\n else System.out.println(\"Not stable\");\n }\n}", "problem_context": "Stable Sort\n\nLet's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1.\n\nYour task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode:\n\nBubbleSort(C)\n1 for i = 0 to C.length-1\n2 for j = C.length-1 downto i+1\n3 if C[j].value < C[j-1].value\n4 swap C[j] and C[j-1]\n\nSelectionSort(C)\n1 for i = 0 to C.length-1\n2 mini = i\n3 for j = i to C.length-1\n4 if C[j].value < C[mini].value\n5 mini = j\n6 swap C[i] and C[mini]\n\nNote that, indices for array elements are based on 0-origin.\n\nFor each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).\n\nInput\n\nThe first line contains an integer N, the number of cards.\n\nN cards are given in the following line. Each card is represented by two characters. Two consecutive cards are separated by a space character.\n\nOutput\n\nIn the first line, print the arranged cards provided by the Bubble Sort algorithm. Two consecutive cards should be separated by a space character.\n\nIn the second line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nIn the third line, print the arranged cards provided by the Selection Sort algorithm. Two consecutive cards should be separated by a space character.\n\nIn the fourth line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nConstraints\n\n1 ≤ N ≤ 36\n\nSample Input 1\n\n5\nH4 C9 S4 D2 C3\n\nSample Output 1\n\nD2 C3 H4 S4 C9\nStable\nD2 C3 S4 H4 C9\nNot stable\n\nSample Input 2\n\n2\nS1 H1\n\nSample Output 2\n\nS1 H1\nStable\nS1 H1\nStable", "sample_input": "5\nH4 C9 S4 D2 C3\n"}, "reference_outputs": ["D2 C3 H4 S4 C9\nStable\nD2 C3 S4 H4 C9\nNot stable\n"], "source_document_id": "p02261", "source_text": "Stable Sort\n\nLet's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1.\n\nYour task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode:\n\nBubbleSort(C)\n1 for i = 0 to C.length-1\n2 for j = C.length-1 downto i+1\n3 if C[j].value < C[j-1].value\n4 swap C[j] and C[j-1]\n\nSelectionSort(C)\n1 for i = 0 to C.length-1\n2 mini = i\n3 for j = i to C.length-1\n4 if C[j].value < C[mini].value\n5 mini = j\n6 swap C[i] and C[mini]\n\nNote that, indices for array elements are based on 0-origin.\n\nFor each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).\n\nInput\n\nThe first line contains an integer N, the number of cards.\n\nN cards are given in the following line. Each card is represented by two characters. Two consecutive cards are separated by a space character.\n\nOutput\n\nIn the first line, print the arranged cards provided by the Bubble Sort algorithm. Two consecutive cards should be separated by a space character.\n\nIn the second line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nIn the third line, print the arranged cards provided by the Selection Sort algorithm. Two consecutive cards should be separated by a space character.\n\nIn the fourth line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nConstraints\n\n1 ≤ N ≤ 36\n\nSample Input 1\n\n5\nH4 C9 S4 D2 C3\n\nSample Output 1\n\nD2 C3 H4 S4 C9\nStable\nD2 C3 S4 H4 C9\nNot stable\n\nSample Input 2\n\n2\nS1 H1\n\nSample Output 2\n\nS1 H1\nStable\nS1 H1\nStable", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1742, "cpu_time_ms": 50, "memory_kb": 26348}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s647096566", "group_id": "codeNet:p02264", "input_text": "import java.util.*;\n\nclass Main{\n public static void main(String[] args){\n Queue queue = new ArrayDeque();\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt(); //処理する数\n int q = sc.nextInt(); //クオンタム\n int sum = 0; //処理した数\n int sumTime = 0; //合計処理時間\n for(int i = 0; i < 2*n; i++){\n String x = sc.next();\n queue.add(x);\n }\n /*処理部分*/\n while(sum != n){\n String name = queue.poll();\n int time = Integer.parseInt(queue.poll());\n if(time > q){\n sumTime += q;\n time -= q;\n queue.add(name);\n queue.add(String.valueOf(time)); //intをInteger経由でStringに変換している\n }\n else{\n sumTime += time;\n sum++;\n System.out.println(name +\" \"+sumTime);\n }\n }\n\n }\n}\n", "language": "Java", "metadata": {"date": 1555661918, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02264.html", "problem_id": "p02264", "resource_group": "high_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/Java/s647096566.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s647096566", "user_id": "u021078771"}, "prompt_components": {"gold_output": "p2 180\np5 400\np1 450\np3 550\np4 800\n", "input_to_evaluate": "import java.util.*;\n\nclass Main{\n public static void main(String[] args){\n Queue queue = new ArrayDeque();\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt(); //処理する数\n int q = sc.nextInt(); //クオンタム\n int sum = 0; //処理した数\n int sumTime = 0; //合計処理時間\n for(int i = 0; i < 2*n; i++){\n String x = sc.next();\n queue.add(x);\n }\n /*処理部分*/\n while(sum != n){\n String name = queue.poll();\n int time = Integer.parseInt(queue.poll());\n if(time > q){\n sumTime += q;\n time -= q;\n queue.add(name);\n queue.add(String.valueOf(time)); //intをInteger経由でStringに変換している\n }\n else{\n sumTime += time;\n sum++;\n System.out.println(name +\" \"+sumTime);\n }\n }\n\n }\n}\n", "problem_context": "There are n processes in a queue. Each process has namei and timei. The round-robin scheduling handles the processes in order. A round-robin scheduler gives each process a quantum (a time slot) and interrupts the process if it is not completed by then. The process is resumed and moved to the end of the queue, then the scheduler handles the next process in the queue.\n\nFor example, we have the following queue with the quantum of 100ms.\n\nA(150) - B(80) - C(200) - D(200)\n\nFirst, process A is handled for 100ms, then the process is moved to the end of the queue with the remaining time (50ms).\n\nB(80) - C(200) - D(200) - A(50)\n\nNext, process B is handled for 80ms. The process is completed with the time stamp of 180ms and removed from the queue.\n\nC(200) - D(200) - A(50)\n\nYour task is to write a program which simulates the round-robin scheduling.\n\nInput\n\nn q\n\nname1 time1\n\nname2 time2\n\n...\n\nnamen timen\n\nIn the first line the number of processes n and the quantum q are given separated by a single space.\n\nIn the following n lines, names and times for the n processes are given. namei and timei are separated by a single space.\n\nOutput\n\nFor each process, prints its name and the time the process finished in order.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 1000\n\n1 ≤ timei ≤ 50000\n\n1 ≤ length of namei ≤ 10\n\n1 ≤ Sum of timei ≤ 1000000\n\nSample Input 1\n\n5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n\nSample Output 1\n\np2 180\np5 400\np1 450\np3 550\np4 800\n\nNotes\n\nTemplate in C", "sample_input": "5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n"}, "reference_outputs": ["p2 180\np5 400\np1 450\np3 550\np4 800\n"], "source_document_id": "p02264", "source_text": "There are n processes in a queue. Each process has namei and timei. The round-robin scheduling handles the processes in order. A round-robin scheduler gives each process a quantum (a time slot) and interrupts the process if it is not completed by then. The process is resumed and moved to the end of the queue, then the scheduler handles the next process in the queue.\n\nFor example, we have the following queue with the quantum of 100ms.\n\nA(150) - B(80) - C(200) - D(200)\n\nFirst, process A is handled for 100ms, then the process is moved to the end of the queue with the remaining time (50ms).\n\nB(80) - C(200) - D(200) - A(50)\n\nNext, process B is handled for 80ms. The process is completed with the time stamp of 180ms and removed from the queue.\n\nC(200) - D(200) - A(50)\n\nYour task is to write a program which simulates the round-robin scheduling.\n\nInput\n\nn q\n\nname1 time1\n\nname2 time2\n\n...\n\nnamen timen\n\nIn the first line the number of processes n and the quantum q are given separated by a single space.\n\nIn the following n lines, names and times for the n processes are given. namei and timei are separated by a single space.\n\nOutput\n\nFor each process, prints its name and the time the process finished in order.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 1000\n\n1 ≤ timei ≤ 50000\n\n1 ≤ length of namei ≤ 10\n\n1 ≤ Sum of timei ≤ 1000000\n\nSample Input 1\n\n5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n\nSample Output 1\n\np2 180\np5 400\np1 450\np3 550\np4 800\n\nNotes\n\nTemplate in C", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 916, "cpu_time_ms": 880, "memory_kb": 80924}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s075818678", "group_id": "codeNet:p02264", "input_text": "import java.util.Scanner;\nimport java.util.ArrayDeque;\nimport java.util.Queue;\n\nclass Main{\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n Queue queue = new ArrayDeque<>();\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n String name[] = new String[n];\n int time[] = new int[n];\n for(int i = 0; i < n; i++){\n name[i] = sc.next();\n time[i] = sc.nextInt();\n queue.add(i);\n }\n \n int x = 0;\n while(!queue.isEmpty()){\n int y = queue.poll();\n if(time[y] <= q){\n x += time[y];\n System.out.println(name[y]+\" \"+x);\n }else{\n x += q;\n time[y] -= q;\n queue.add(y);\n }\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1554426422, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02264.html", "problem_id": "p02264", "resource_group": "high_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/Java/s075818678.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s075818678", "user_id": "u333762667"}, "prompt_components": {"gold_output": "p2 180\np5 400\np1 450\np3 550\np4 800\n", "input_to_evaluate": "import java.util.Scanner;\nimport java.util.ArrayDeque;\nimport java.util.Queue;\n\nclass Main{\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n Queue queue = new ArrayDeque<>();\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n String name[] = new String[n];\n int time[] = new int[n];\n for(int i = 0; i < n; i++){\n name[i] = sc.next();\n time[i] = sc.nextInt();\n queue.add(i);\n }\n \n int x = 0;\n while(!queue.isEmpty()){\n int y = queue.poll();\n if(time[y] <= q){\n x += time[y];\n System.out.println(name[y]+\" \"+x);\n }else{\n x += q;\n time[y] -= q;\n queue.add(y);\n }\n }\n }\n}\n", "problem_context": "There are n processes in a queue. Each process has namei and timei. The round-robin scheduling handles the processes in order. A round-robin scheduler gives each process a quantum (a time slot) and interrupts the process if it is not completed by then. The process is resumed and moved to the end of the queue, then the scheduler handles the next process in the queue.\n\nFor example, we have the following queue with the quantum of 100ms.\n\nA(150) - B(80) - C(200) - D(200)\n\nFirst, process A is handled for 100ms, then the process is moved to the end of the queue with the remaining time (50ms).\n\nB(80) - C(200) - D(200) - A(50)\n\nNext, process B is handled for 80ms. The process is completed with the time stamp of 180ms and removed from the queue.\n\nC(200) - D(200) - A(50)\n\nYour task is to write a program which simulates the round-robin scheduling.\n\nInput\n\nn q\n\nname1 time1\n\nname2 time2\n\n...\n\nnamen timen\n\nIn the first line the number of processes n and the quantum q are given separated by a single space.\n\nIn the following n lines, names and times for the n processes are given. namei and timei are separated by a single space.\n\nOutput\n\nFor each process, prints its name and the time the process finished in order.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 1000\n\n1 ≤ timei ≤ 50000\n\n1 ≤ length of namei ≤ 10\n\n1 ≤ Sum of timei ≤ 1000000\n\nSample Input 1\n\n5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n\nSample Output 1\n\np2 180\np5 400\np1 450\np3 550\np4 800\n\nNotes\n\nTemplate in C", "sample_input": "5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n"}, "reference_outputs": ["p2 180\np5 400\np1 450\np3 550\np4 800\n"], "source_document_id": "p02264", "source_text": "There are n processes in a queue. Each process has namei and timei. The round-robin scheduling handles the processes in order. A round-robin scheduler gives each process a quantum (a time slot) and interrupts the process if it is not completed by then. The process is resumed and moved to the end of the queue, then the scheduler handles the next process in the queue.\n\nFor example, we have the following queue with the quantum of 100ms.\n\nA(150) - B(80) - C(200) - D(200)\n\nFirst, process A is handled for 100ms, then the process is moved to the end of the queue with the remaining time (50ms).\n\nB(80) - C(200) - D(200) - A(50)\n\nNext, process B is handled for 80ms. The process is completed with the time stamp of 180ms and removed from the queue.\n\nC(200) - D(200) - A(50)\n\nYour task is to write a program which simulates the round-robin scheduling.\n\nInput\n\nn q\n\nname1 time1\n\nname2 time2\n\n...\n\nnamen timen\n\nIn the first line the number of processes n and the quantum q are given separated by a single space.\n\nIn the following n lines, names and times for the n processes are given. namei and timei are separated by a single space.\n\nOutput\n\nFor each process, prints its name and the time the process finished in order.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 1000\n\n1 ≤ timei ≤ 50000\n\n1 ≤ length of namei ≤ 10\n\n1 ≤ Sum of timei ≤ 1000000\n\nSample Input 1\n\n5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n\nSample Output 1\n\np2 180\np5 400\np1 450\np3 550\np4 800\n\nNotes\n\nTemplate in C", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 730, "memory_kb": 77884}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s336526558", "group_id": "codeNet:p02267", "input_text": "import java.util.*;\nimport java.lang.*;\n\nclass Main{\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n int n = Integer.parseInt(sc.nextLine());\n String[] line = sc.nextLine().split(\" \");\n int[] data =new int[n];\n for(int i=0; i < n; i++){\n data[i] = Integer.parseInt(line[i]);\n }\n\n int q = Integer.parseInt(sc.nextLine());\n String[] line2 = sc.nextLine().split(\" \");\n int[] searcher = new int[q];\n for(int i=0; i < q; i++){\n searcher[i] = Integer.parseInt(line2[i]);\n }\n\n int result = 0;\n for(int i = 0; i < q; i++){\n for(int j = 0; j < n; j++){\n if(searcher[i] == data[j]){\n result++;\n break;\n }\n }\n }\n System.out.println(result);\n \n\n\n\n }\n static void bubble(int[] arr, int n){\n\n }\n static void selection(int[] arr, int n){\n\n }\n static void insertionSort(int[] arr, int n, int g,int count){\n for(int i = g; i < n; i++){\n int v = arr[i];\n int j = i - g;\n while(j >= 0 && arr[j] > arr[i]){\n arr[i] = arr[j];\n j-=g;\n count++;\n }\n arr[j + g] = v;\n }\n }\n static void shellsort(int[] arr, int n){\n\n for(int i = 1; ; ){\n if(i > n){\n break;\n }\n\n i = (i * 3) + 1;\n }\n }\n}\nclass Struct{\n String name;\n int time;\n public Struct(String n, int t){\n name = n;\n time = t;\n }\n}", "language": "Java", "metadata": {"date": 1510991290, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02267.html", "problem_id": "p02267", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02267/input.txt", "sample_output_relpath": "derived/input_output/data/p02267/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02267/Java/s336526558.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s336526558", "user_id": "u564767946"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*;\nimport java.lang.*;\n\nclass Main{\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n int n = Integer.parseInt(sc.nextLine());\n String[] line = sc.nextLine().split(\" \");\n int[] data =new int[n];\n for(int i=0; i < n; i++){\n data[i] = Integer.parseInt(line[i]);\n }\n\n int q = Integer.parseInt(sc.nextLine());\n String[] line2 = sc.nextLine().split(\" \");\n int[] searcher = new int[q];\n for(int i=0; i < q; i++){\n searcher[i] = Integer.parseInt(line2[i]);\n }\n\n int result = 0;\n for(int i = 0; i < q; i++){\n for(int j = 0; j < n; j++){\n if(searcher[i] == data[j]){\n result++;\n break;\n }\n }\n }\n System.out.println(result);\n \n\n\n\n }\n static void bubble(int[] arr, int n){\n\n }\n static void selection(int[] arr, int n){\n\n }\n static void insertionSort(int[] arr, int n, int g,int count){\n for(int i = g; i < n; i++){\n int v = arr[i];\n int j = i - g;\n while(j >= 0 && arr[j] > arr[i]){\n arr[i] = arr[j];\n j-=g;\n count++;\n }\n arr[j + g] = v;\n }\n }\n static void shellsort(int[] arr, int n){\n\n for(int i = 1; ; ){\n if(i > n){\n break;\n }\n\n i = (i * 3) + 1;\n }\n }\n}\nclass Struct{\n String name;\n int time;\n public Struct(String n, int t){\n name = n;\n time = t;\n }\n}", "problem_context": "Search I\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\nn ≤ 10000\n\nq ≤ 500\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\n3 1 2\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": "p02267", "source_text": "Search I\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\nn ≤ 10000\n\nq ≤ 500\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\n3 1 2\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": 1648, "cpu_time_ms": 120, "memory_kb": 29968}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s818873867", "group_id": "codeNet:p02268", "input_text": "\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\n\nclass Main {\n\n\n public static void main(String args[]) throws IOException{\n\n\t BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t int n = Integer.parseInt( br.readLine() );\n\t String[] string = br.readLine().split(\" \");\n int[] S = new int[n];\n\n\n for(int i = 0; i < n; i++ ){\n\n \t S[i] = Integer.parseInt( string[i] );\n\n }\n\n int q = Integer.parseInt( br.readLine() );\n\t String[] stringq = br.readLine().split(\" \");\n int[] T = new int[q];\n\n\n for(int i = 0; i < q; i++ ){\n\n \t T[i] = Integer.parseInt( stringq[i] );\n\n }\n\n\n int answer = 0;\n\n for(int i = 0; i < q ; i++ ){\n \t for(int j = 0; j < n ; j++ ){\n \t\t if( S[j] == T[i] ){\n \t\t\t answer++;\n \t\t\t break;\n \t\t }\n \t }\n\n }\n\n System.out.println(answer);\n\n\n }\n\n\n}", "language": "Java", "metadata": {"date": 1492138060, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02268.html", "problem_id": "p02268", "resource_group": "high_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/Java/s818873867.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s818873867", "user_id": "u233376535"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\n\nclass Main {\n\n\n public static void main(String args[]) throws IOException{\n\n\t BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t int n = Integer.parseInt( br.readLine() );\n\t String[] string = br.readLine().split(\" \");\n int[] S = new int[n];\n\n\n for(int i = 0; i < n; i++ ){\n\n \t S[i] = Integer.parseInt( string[i] );\n\n }\n\n int q = Integer.parseInt( br.readLine() );\n\t String[] stringq = br.readLine().split(\" \");\n int[] T = new int[q];\n\n\n for(int i = 0; i < q; i++ ){\n\n \t T[i] = Integer.parseInt( stringq[i] );\n\n }\n\n\n int answer = 0;\n\n for(int i = 0; i < q ; i++ ){\n \t for(int j = 0; j < n ; j++ ){\n \t\t if( S[j] == T[i] ){\n \t\t\t answer++;\n \t\t\t break;\n \t\t }\n \t }\n\n }\n\n System.out.println(answer);\n\n\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": 943, "cpu_time_ms": 1070, "memory_kb": 46876}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s754785532", "group_id": "codeNet:p02268", "input_text": "import java.util.Scanner;\n\npublic class Main {\n static boolean binary_search (int x, int[] data) {\n int left = 0, right = data.length;\n while (true) {\n int mid = (left + right) / 2;\n\n if (left > right) return false;\n\n if (data[mid] == x) {\n return true;\n } else if (data[mid] < x) {\n left = mid + 1;\n } else {\n right = mid - 1;\n }\n }\n }\n\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n\n int n = scanner.nextInt();\n\n int[] s = new int[n];\n for (int i = 0; i < n; ++i) {\n s[i] = scanner.nextInt();\n }\n\n int q = scanner.nextInt();\n\n int cnt = 0;\n for (int i = 0; i < q; ++i) {\n int t = scanner.nextInt();\n if (binary_search(t, s)) ++cnt;\n }\n\n System.out.println(cnt);\n }\n}\n", "language": "Java", "metadata": {"date": 1589173083, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02268.html", "problem_id": "p02268", "resource_group": "high_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/Java/s754785532.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s754785532", "user_id": "u426260581"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n static boolean binary_search (int x, int[] data) {\n int left = 0, right = data.length;\n while (true) {\n int mid = (left + right) / 2;\n\n if (left > right) return false;\n\n if (data[mid] == x) {\n return true;\n } else if (data[mid] < x) {\n left = mid + 1;\n } else {\n right = mid - 1;\n }\n }\n }\n\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n\n int n = scanner.nextInt();\n\n int[] s = new int[n];\n for (int i = 0; i < n; ++i) {\n s[i] = scanner.nextInt();\n }\n\n int q = scanner.nextInt();\n\n int cnt = 0;\n for (int i = 0; i < q; ++i) {\n int t = scanner.nextInt();\n if (binary_search(t, s)) ++cnt;\n }\n\n System.out.println(cnt);\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": 955, "cpu_time_ms": 470, "memory_kb": 68512}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s338040257", "group_id": "codeNet:p02271", "input_text": "import java.util.Scanner;\nimport java.util.Arrays;\nimport java.util.List;\n\npublic class Main\n{\n\tpublic static int A[] = new int[20];\n\tpublic static boolean rec(int s, int n, int now)\n\t{\n\t\tif(n == -1)\n\t\t{\n\t\t\tif(now == s)\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\treturn rec(s, n - 1, now + A[n]) | rec(s, n - 1, now);\n\t}\n\tpublic static void main(String args[])\n\t{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n, q, m[] = new int[200];\n\t\tn = sc.nextInt();\n\t\tfor(int i = 0; i < n; i++)\n\t\t{\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\tq = sc.nextInt();\n\t\tfor(int i = 0; i < q; i++)\n\t\t{\n\t\t\tm[i] = sc.nextInt();\n\t\t}\n\t\tfor(int i = 0; i < q; i++)\n\t\t{\n\t\t\tif(rec(m[i], n - 1, 0))\n\t\t\t{\n\t\t\t\tSystem.out.println(\"yes\");\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tSystem.out.println(\"no\");\n\t\t\t}\n\t\t}\n\t\tsc.close();\n\t}\n}\n", "language": "Java", "metadata": {"date": 1589175887, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02271.html", "problem_id": "p02271", "resource_group": "high_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/Java/s338040257.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s338040257", "user_id": "u789069047"}, "prompt_components": {"gold_output": "no\nno\nyes\nyes\nyes\nyes\nno\nno\n", "input_to_evaluate": "import java.util.Scanner;\nimport java.util.Arrays;\nimport java.util.List;\n\npublic class Main\n{\n\tpublic static int A[] = new int[20];\n\tpublic static boolean rec(int s, int n, int now)\n\t{\n\t\tif(n == -1)\n\t\t{\n\t\t\tif(now == s)\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\treturn rec(s, n - 1, now + A[n]) | rec(s, n - 1, now);\n\t}\n\tpublic static void main(String args[])\n\t{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n, q, m[] = new int[200];\n\t\tn = sc.nextInt();\n\t\tfor(int i = 0; i < n; i++)\n\t\t{\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\tq = sc.nextInt();\n\t\tfor(int i = 0; i < q; i++)\n\t\t{\n\t\t\tm[i] = sc.nextInt();\n\t\t}\n\t\tfor(int i = 0; i < q; i++)\n\t\t{\n\t\t\tif(rec(m[i], n - 1, 0))\n\t\t\t{\n\t\t\t\tSystem.out.println(\"yes\");\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tSystem.out.println(\"no\");\n\t\t\t}\n\t\t}\n\t\tsc.close();\n\t}\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": 776, "cpu_time_ms": 690, "memory_kb": 26836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s663814989", "group_id": "codeNet:p02272", "input_text": "import java.util.Scanner;\n\n\n\npublic class Main {\nstatic int n;\nstatic int S[]=new int[500001];\nstatic int count=0;\n\n public static void merge(int left,int mid,int right){\n\n\t \n\t int i,j;\n\t mid=(left+right)/2;\n\n\t int n1=mid-left;\n\t int n2=right-mid;\n\t int infty=Integer.MAX_VALUE;\n\n\t int R[]=new int[n1+2];\n\t int L[]=new int[n2+2];\n\n\t for(i=0;i= 0; j--) {\n b[c[a[j]]-1] = a[j];\n c[a[j]]--;\n }\n\n int place = 0;\n for(int item : b) {\n if (place != 0) {\n System.out.print(\" \");\n\n }\n\n System.out.print(item);\n place++;\n }\n\n System.out.print(\"\\n\");\n\n }\n}\n", "language": "Java", "metadata": {"date": 1540313181, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02275.html", "problem_id": "p02275", "resource_group": "high_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/Java/s640445635.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s640445635", "user_id": "u647456682"}, "prompt_components": {"gold_output": "0 1 2 2 3 3 5\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n int total;\n\n Scanner inp = new Scanner(System.in);\n total = inp.nextInt();\n\n int[] a = new int[total];\n\n for (int k = 0; k < total; k++) {\n a[k] = inp.nextInt();\n }\n\n countingSort(a, new int[total], 2000000);\n }\n\n public static void countingSort(int[] a, int[] b, int k) {\n int[] c = new int[k];\n\n for (int j = 0; j < a.length; j++) {\n c[a[j]]++;\n }\n\n for (int i = 1; i < k; i++) {\n c[i] += c[i - 1];\n }\n\n for (int j = a.length-1; j >= 0; j--) {\n b[c[a[j]]-1] = a[j];\n c[a[j]]--;\n }\n\n int place = 0;\n for(int item : b) {\n if (place != 0) {\n System.out.print(\" \");\n\n }\n\n System.out.print(item);\n place++;\n }\n\n System.out.print(\"\\n\");\n\n }\n}\n", "problem_context": "Counting Sort\n\nCounting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in the output array B. This scheme must be modified to handle the situation in which several elements have the same value. Please see the following pseudocode for the detail:\n\nCounting-Sort(A, B, k)\n1 for i = 0 to k\n2 do C[i] = 0\n3 for j = 1 to length[A]\n4 do C[A[j]] = C[A[j]]+1\n5 /* C[i] now contains the number of elements equal to i */\n6 for i = 1 to k\n7 do C[i] = C[i] + C[i-1]\n8 /* C[i] now contains the number of elements less than or equal to i */\n9 for j = length[A] downto 1\n10 do B[C[A[j]]] = A[j]\n11 C[A[j]] = C[A[j]]-1\n\nWrite a program which sorts elements of given array ascending order based on the counting sort.\n\nInput\n\nThe first line of the input includes an integer n, the number of elements in the sequence.\n\nIn the second line, n elements of the sequence are given separated by spaces characters.\n\nOutput\n\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nConstraints\n\n1 ≤ n ≤ 2,000,000\n\n0 ≤ A[i] ≤ 10,000\n\nSample Input 1\n\n7\n2 5 1 3 2 3 0\n\nSample Output 1\n\n0 1 2 2 3 3 5", "sample_input": "7\n2 5 1 3 2 3 0\n"}, "reference_outputs": ["0 1 2 2 3 3 5\n"], "source_document_id": "p02275", "source_text": "Counting Sort\n\nCounting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in the output array B. This scheme must be modified to handle the situation in which several elements have the same value. Please see the following pseudocode for the detail:\n\nCounting-Sort(A, B, k)\n1 for i = 0 to k\n2 do C[i] = 0\n3 for j = 1 to length[A]\n4 do C[A[j]] = C[A[j]]+1\n5 /* C[i] now contains the number of elements equal to i */\n6 for i = 1 to k\n7 do C[i] = C[i] + C[i-1]\n8 /* C[i] now contains the number of elements less than or equal to i */\n9 for j = length[A] downto 1\n10 do B[C[A[j]]] = A[j]\n11 C[A[j]] = C[A[j]]-1\n\nWrite a program which sorts elements of given array ascending order based on the counting sort.\n\nInput\n\nThe first line of the input includes an integer n, the number of elements in the sequence.\n\nIn the second line, n elements of the sequence are given separated by spaces characters.\n\nOutput\n\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nConstraints\n\n1 ≤ n ≤ 2,000,000\n\n0 ≤ A[i] ≤ 10,000\n\nSample Input 1\n\n7\n2 5 1 3 2 3 0\n\nSample Output 1\n\n0 1 2 2 3 3 5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 4480, "memory_kb": 559492}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s978490882", "group_id": "codeNet:p02275", "input_text": "import java.io.*;\n\npublic class Main{\n\n\tstatic int count = 0;\n\n\tpublic static void main(String[] args) throws IOException{\n\t\t\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tStringBuffer sb = new StringBuffer();\n\t\tint max = 0;\n\t\tint[] A = new int[n];\n\t\tint[] B = new int[n];\n\t\tString[] in = br.readLine().split(\" \");\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tA[i] = Integer.parseInt(in[i]);\n\t\t\tmax = Math.max(max, A[i]);\n\t\t}\n\n\t\tcountingSort(A, B, max);\n\t\tsb.append(B[0]);\n\t\tfor(int i = 1; i < n; i++)\n\t\t\tsb.append(\" \").append(B[i]);\n\t\tString out = sb.toString();\n\t\tSystem.out.printf(\"%s\\n\", out);\n\t}\n\n\tprivate static void countingSort(int[] a, int[] b, int max){ // ?¨???°?????????\n\t\tint[] C = new int[max+1];\n\n\t\tfor(int j = 0; j < a.length; j++){\n\t\t\tC[a[j]]++;\n\t\t}\n\n\t\tfor(int i = 1; i <= max; i++){\n\t\t\tC[i] = C[i] + C[i-1]; // ?¨???°???\n\t\t}\n\n\t\tfor(int j = a.length-1; j >= 0; j--){\n\t\t\tb[C[a[j]]-1] = a[j]; // ?¨???°??????????´???°??¨????????????????????????0??????k-1?????§\n\t\t\tC[a[j]]--; // ?????£????????§?¨???°????????????\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1488853585, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02275.html", "problem_id": "p02275", "resource_group": "high_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/Java/s978490882.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s978490882", "user_id": "u910402677"}, "prompt_components": {"gold_output": "0 1 2 2 3 3 5\n", "input_to_evaluate": "import java.io.*;\n\npublic class Main{\n\n\tstatic int count = 0;\n\n\tpublic static void main(String[] args) throws IOException{\n\t\t\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tStringBuffer sb = new StringBuffer();\n\t\tint max = 0;\n\t\tint[] A = new int[n];\n\t\tint[] B = new int[n];\n\t\tString[] in = br.readLine().split(\" \");\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tA[i] = Integer.parseInt(in[i]);\n\t\t\tmax = Math.max(max, A[i]);\n\t\t}\n\n\t\tcountingSort(A, B, max);\n\t\tsb.append(B[0]);\n\t\tfor(int i = 1; i < n; i++)\n\t\t\tsb.append(\" \").append(B[i]);\n\t\tString out = sb.toString();\n\t\tSystem.out.printf(\"%s\\n\", out);\n\t}\n\n\tprivate static void countingSort(int[] a, int[] b, int max){ // ?¨???°?????????\n\t\tint[] C = new int[max+1];\n\n\t\tfor(int j = 0; j < a.length; j++){\n\t\t\tC[a[j]]++;\n\t\t}\n\n\t\tfor(int i = 1; i <= max; i++){\n\t\t\tC[i] = C[i] + C[i-1]; // ?¨???°???\n\t\t}\n\n\t\tfor(int j = a.length-1; j >= 0; j--){\n\t\t\tb[C[a[j]]-1] = a[j]; // ?¨???°??????????´???°??¨????????????????????????0??????k-1?????§\n\t\t\tC[a[j]]--; // ?????£????????§?¨???°????????????\n\t\t}\n\t}\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": 1112, "cpu_time_ms": 4230, "memory_kb": 294716}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s769194893", "group_id": "codeNet:p02275", "input_text": "import java.util.Scanner;\n\n\nclass Main {\n\tpublic static void main(String args[]) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint num = scanner.nextInt();//要素数\n\t\tint array[] = new int[num];\n\t\tint max = 0;\n\t\t//実行処理\n\t\tCountingSort(array, num, max,scanner);\n\t\t//後処理\n\t\tscanner.close();\n\t}\n\n\tpublic static void CountingSort(int[] array, int num, int max, Scanner scanner){ \n\t\tint[] count = new int[10000];\n\t\tint[] sort = new int[num];\n\t\t//配列作成同時にカウント\n\t\tfor(int i = 0; i < num; i ++ ){\n\t\t\tarray[i] = scanner.nextInt();\n\t\t\tcount[ array[i] ] ++;\n\t\t\t//比較して更新\n\t\t\tmax = Math.max(max, array[i]);\n\t\t}\n\t\t//カウントの位置\n\t\tfor(int i = 1; i <= max; i ++ ){\n\t\t\tcount[i] += count[i - 1];\n\t\t}\n\t\t//ソート処理\n\t\tfor(int i = num - 1; i >= 0; i -- ){\n\t\t\t\tcount[array[i]] --;\n\t\t\t\tsort[count[array[i]]] = array[i];\n\t\t\t\t\n\t\t}\n\t\t//出力\n\t\tfor(int i = 0; i < num; i ++ ){\n\t\t\tSystem.out.print(sort[i]);\n\t\t\tif( i == num - 1) {\n\t\t\tSystem.out.print(\"\\n\");\n\t\t\t}else {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t}\n}\n", "language": "Java", "metadata": {"date": 1524199003, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02275.html", "problem_id": "p02275", "resource_group": "high_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/Java/s769194893.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s769194893", "user_id": "u438493637"}, "prompt_components": {"gold_output": "0 1 2 2 3 3 5\n", "input_to_evaluate": "import java.util.Scanner;\n\n\nclass Main {\n\tpublic static void main(String args[]) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint num = scanner.nextInt();//要素数\n\t\tint array[] = new int[num];\n\t\tint max = 0;\n\t\t//実行処理\n\t\tCountingSort(array, num, max,scanner);\n\t\t//後処理\n\t\tscanner.close();\n\t}\n\n\tpublic static void CountingSort(int[] array, int num, int max, Scanner scanner){ \n\t\tint[] count = new int[10000];\n\t\tint[] sort = new int[num];\n\t\t//配列作成同時にカウント\n\t\tfor(int i = 0; i < num; i ++ ){\n\t\t\tarray[i] = scanner.nextInt();\n\t\t\tcount[ array[i] ] ++;\n\t\t\t//比較して更新\n\t\t\tmax = Math.max(max, array[i]);\n\t\t}\n\t\t//カウントの位置\n\t\tfor(int i = 1; i <= max; i ++ ){\n\t\t\tcount[i] += count[i - 1];\n\t\t}\n\t\t//ソート処理\n\t\tfor(int i = num - 1; i >= 0; i -- ){\n\t\t\t\tcount[array[i]] --;\n\t\t\t\tsort[count[array[i]]] = array[i];\n\t\t\t\t\n\t\t}\n\t\t//出力\n\t\tfor(int i = 0; i < num; i ++ ){\n\t\t\tSystem.out.print(sort[i]);\n\t\t\tif( i == num - 1) {\n\t\t\tSystem.out.print(\"\\n\");\n\t\t\t}else {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t}\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": 1047, "cpu_time_ms": 4420, "memory_kb": 560980}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s946781163", "group_id": "codeNet:p02276", "input_text": "import java.util.*;\npublic class Main{\n\tstatic int[] A =new int[100000];\n\tstatic int n;\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tn = sc.nextInt();\n\t\tfor(int i=0;i A[max].key)max = l;\n\t\tif (r <= n && A[r].key > A[max].key)max = r;\n\t\tif (max != i) {\n\t\t\tint temp = A[i].key;\n\t\t\tA[i].key = A[max].key;\n\t\t\tA[max].key = temp;\n\t\t\tmaxHeapify(A, max, n);\n\t\t}\n\n\t}\n\n\tstatic void buildMaxHeap(Node A[], int n){\n\t\tfor(int i = n/2;i > 0;i--){\n\t\t\tmaxHeapify(A, i, n);\n\t\t}\n\t}\n}\n\nclass Node {\n\tint id;\n\tint key;\n\tint p;\n\tint l;\n\tint r;\n\n\tNode() {\n\t\tid = Integer.MIN_VALUE;\n\t\tkey = Integer.MIN_VALUE;\n\t\tp = Integer.MIN_VALUE;\n\t\tl = Integer.MIN_VALUE;\n\t\tr = Integer.MIN_VALUE;\n\t}\n}", "language": "Java", "metadata": {"date": 1484025134, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02288.html", "problem_id": "p02288", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02288/input.txt", "sample_output_relpath": "derived/input_output/data/p02288/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02288/Java/s164355989.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s164355989", "user_id": "u450760454"}, "prompt_components": {"gold_output": " 16 14 10 8 7 9 3 2 4 1\n", "input_to_evaluate": "import java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tNode[] heap = new Node[n + 1];\n\t\theap[0] = new Node();\n\t\tfor (int i = 1; i < n + 1; i++) {\n\t\t\theap[i] = new Node();\n\t\t\theap[i].id = i;\n\t\t\theap[i].key = sc.nextInt();\n\t\t}\n\n\t\tbuildMaxHeap(heap, n);\n\t\tfor(int i = 1;i < n+1;i++){\n\t\t\tSystem.out.print(\" \"+heap[i].key);\n\t\t}\n\t\tSystem.out.println();\n\t}\n\n\tstatic void maxHeapify(Node A[], int i, int n) {\n\t\tint l = 2 * i;\n\t\tint r = 2 * i + 1;\n\t\tint max = i;\n\t\t//System.out.println(l+\" \"+r);\n\t\tif (l <= n && A[l].key > A[max].key)max = l;\n\t\tif (r <= n && A[r].key > A[max].key)max = r;\n\t\tif (max != i) {\n\t\t\tint temp = A[i].key;\n\t\t\tA[i].key = A[max].key;\n\t\t\tA[max].key = temp;\n\t\t\tmaxHeapify(A, max, n);\n\t\t}\n\n\t}\n\n\tstatic void buildMaxHeap(Node A[], int n){\n\t\tfor(int i = n/2;i > 0;i--){\n\t\t\tmaxHeapify(A, i, n);\n\t\t}\n\t}\n}\n\nclass Node {\n\tint id;\n\tint key;\n\tint p;\n\tint l;\n\tint r;\n\n\tNode() {\n\t\tid = Integer.MIN_VALUE;\n\t\tkey = Integer.MIN_VALUE;\n\t\tp = Integer.MIN_VALUE;\n\t\tl = Integer.MIN_VALUE;\n\t\tr = Integer.MIN_VALUE;\n\t}\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Heap\n\nA binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other than the root, $A[i] \\leq A[parent(i)]$, that is, the value of a node is at most the value of its parent. The largest element in a max-heap is stored at the root, and the subtree rooted at a node contains values no larger than that contained at the node itself.\n\nHere is an example of a max-heap.\n\nWrite a program which reads an array and constructs a max-heap from the array based on the following pseudo code.\n\n$maxHeapify(A, i)$ move the value of $A[i]$ down to leaves to make a sub-tree of node $i$ a max-heap. Here, $H$ is the size of the heap.\n\n1 maxHeapify(A, i)\n2 l = left(i)\n3 r = right(i)\n4 // select the node which has the maximum value\n5 if l ≤ H and A[l] > A[i]\n6 largest = l\n7 else\n8 largest = i\n9 if r ≤ H and A[r] > A[largest]\n10 largest = r\n11\n12 if largest ≠ i // value of children is larger than that of i\n13 swap A[i] and A[largest]\n14 maxHeapify(A, largest) // call recursively\n\nThe following procedure buildMaxHeap(A) makes $A$ a max-heap by performing maxHeapify in a bottom-up manner.\n\n1 buildMaxHeap(A)\n2 for i = H/2 downto 1\n3 maxHeapify(A, i)\n\nInput\n\nIn the first line, an integer $H$ is given. In the second line, $H$ integers which represent elements in the binary heap are given in order of node id (from $1$ to $H$).\n\nOutput\n\nPrint values of nodes in the max-heap in order of their id (from $1$ to $H$). Print a single space character before each value.\n\nConstraint\n\n$1 \\leq H \\leq 500,000$\n\n$-2,000,000,000 \\leq$ value of a node $\\leq 2,000,000,000$\n\nSample Input 1\n\n10\n4 1 3 2 16 9 10 14 8 7\n\nSample Output 1\n\n16 14 10 8 7 9 3 2 4 1\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "10\n4 1 3 2 16 9 10 14 8 7\n"}, "reference_outputs": [" 16 14 10 8 7 9 3 2 4 1\n"], "source_document_id": "p02288", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Heap\n\nA binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other than the root, $A[i] \\leq A[parent(i)]$, that is, the value of a node is at most the value of its parent. The largest element in a max-heap is stored at the root, and the subtree rooted at a node contains values no larger than that contained at the node itself.\n\nHere is an example of a max-heap.\n\nWrite a program which reads an array and constructs a max-heap from the array based on the following pseudo code.\n\n$maxHeapify(A, i)$ move the value of $A[i]$ down to leaves to make a sub-tree of node $i$ a max-heap. Here, $H$ is the size of the heap.\n\n1 maxHeapify(A, i)\n2 l = left(i)\n3 r = right(i)\n4 // select the node which has the maximum value\n5 if l ≤ H and A[l] > A[i]\n6 largest = l\n7 else\n8 largest = i\n9 if r ≤ H and A[r] > A[largest]\n10 largest = r\n11\n12 if largest ≠ i // value of children is larger than that of i\n13 swap A[i] and A[largest]\n14 maxHeapify(A, largest) // call recursively\n\nThe following procedure buildMaxHeap(A) makes $A$ a max-heap by performing maxHeapify in a bottom-up manner.\n\n1 buildMaxHeap(A)\n2 for i = H/2 downto 1\n3 maxHeapify(A, i)\n\nInput\n\nIn the first line, an integer $H$ is given. In the second line, $H$ integers which represent elements in the binary heap are given in order of node id (from $1$ to $H$).\n\nOutput\n\nPrint values of nodes in the max-heap in order of their id (from $1$ to $H$). Print a single space character before each value.\n\nConstraint\n\n$1 \\leq H \\leq 500,000$\n\n$-2,000,000,000 \\leq$ value of a node $\\leq 2,000,000,000$\n\nSample Input 1\n\n10\n4 1 3 2 16 9 10 14 8 7\n\nSample Output 1\n\n16 14 10 8 7 9 3 2 4 1\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1430, "memory_kb": 185272}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s631586469", "group_id": "codeNet:p02295", "input_text": "import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tclass P {\n\t\tdouble x, y;\n\n\t\tP(double x_, double y_) {\n\t\t\tx = x_;\n\t\t\ty = y_;\n\t\t}\n\n\t\tP add(P p) {\n\t\t\treturn new P(x + p.x, y + p.y);\n\t\t}\n\n\t\tP sub(P p) {\n\t\t\treturn new P(x - p.x, y - p.y);\n\t\t}\n\n\t\tP mul(double v) {\n\t\t\treturn new P(x * v, y * v);\n\t\t}\n\n\t\tP div(double v) {\n\t\t\treturn new P(x / v, y / v);\n\t\t}\n\n\t\tdouble dot(P p) {\n\t\t\treturn x * p.x + y * p.y;\n\t\t}\n\n\t\tdouble det(P p) {\n\t\t\treturn x * p.y - y * p.x;\n\t\t}\n\n\t\tdouble abs2() {\n\t\t\treturn x * x + y * y;\n\t\t}\n\n\t\tdouble abs() {\n\t\t\treturn Math.sqrt(abs2());\n\t\t}\n\n\t\tP norm() {\n\t\t\treturn div(abs());\n\t\t}\n\n\t\tP rot90() {\n\t\t\treturn new P(-y, x);\n\t\t}\n\n\t\tP proj(P src, P dst) {\n\t\t\tP p_sd = dst.sub(src).norm();\n\t\t\treturn src.add(p_sd.mul(sub(src).dot(p_sd)));\n\t\t}\n\n\t\tP reflect(P src, P dst) {\n\t\t\tP middle = proj(src, dst);\n\t\t\treturn add(middle.sub(this).mul(2));\n\t\t}\n\n\t\tpublic String toString() {\n\t\t\treturn String.format(\"%f %f\", x, y);\n\t\t}\n\t}\n\n\tP isLL(P p1, P p2, P q1, P q2) {\n\t\tdouble d = p2.sub(p1).det(q1.sub(q2));\n\t\tif (Math.abs(d) < 1e-10)\n\t\t\treturn null;\n\t\treturn p1.add(p2.sub(p1).mul(q1.sub(q2).det(p1.sub(q2)) / d));\n\t}\n\n\tvoid run() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint q = sc.nextInt();\n\t\twhile (q-- > 0) {\n\t\t\tP p1 = new P(sc.nextDouble(), sc.nextDouble());\n\t\t\tP p2 = new P(sc.nextDouble(), sc.nextDouble());\n\t\t\tP q1 = new P(sc.nextDouble(), sc.nextDouble());\n\t\t\tP q2 = new P(sc.nextDouble(), sc.nextDouble());\n\n\t\t\tP x = isLL(p1, p2, q1, q2);\n\t\t\tSystem.out.println(String.format(\"%.20f %.20f\", x.x, x.y));\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n\n\tstatic void tr(Object... objects) {\n\t\tSystem.out.println(Arrays.deepToString(objects));\n\t}\n\n}", "language": "Java", "metadata": {"date": 1505045442, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02295.html", "problem_id": "p02295", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02295/input.txt", "sample_output_relpath": "derived/input_output/data/p02295/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02295/Java/s631586469.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s631586469", "user_id": "u323357326"}, "prompt_components": {"gold_output": "1.0000000000 0.0000000000\n0.5000000000 0.5000000000\n0.5000000000 0.5000000000\n", "input_to_evaluate": "import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tclass P {\n\t\tdouble x, y;\n\n\t\tP(double x_, double y_) {\n\t\t\tx = x_;\n\t\t\ty = y_;\n\t\t}\n\n\t\tP add(P p) {\n\t\t\treturn new P(x + p.x, y + p.y);\n\t\t}\n\n\t\tP sub(P p) {\n\t\t\treturn new P(x - p.x, y - p.y);\n\t\t}\n\n\t\tP mul(double v) {\n\t\t\treturn new P(x * v, y * v);\n\t\t}\n\n\t\tP div(double v) {\n\t\t\treturn new P(x / v, y / v);\n\t\t}\n\n\t\tdouble dot(P p) {\n\t\t\treturn x * p.x + y * p.y;\n\t\t}\n\n\t\tdouble det(P p) {\n\t\t\treturn x * p.y - y * p.x;\n\t\t}\n\n\t\tdouble abs2() {\n\t\t\treturn x * x + y * y;\n\t\t}\n\n\t\tdouble abs() {\n\t\t\treturn Math.sqrt(abs2());\n\t\t}\n\n\t\tP norm() {\n\t\t\treturn div(abs());\n\t\t}\n\n\t\tP rot90() {\n\t\t\treturn new P(-y, x);\n\t\t}\n\n\t\tP proj(P src, P dst) {\n\t\t\tP p_sd = dst.sub(src).norm();\n\t\t\treturn src.add(p_sd.mul(sub(src).dot(p_sd)));\n\t\t}\n\n\t\tP reflect(P src, P dst) {\n\t\t\tP middle = proj(src, dst);\n\t\t\treturn add(middle.sub(this).mul(2));\n\t\t}\n\n\t\tpublic String toString() {\n\t\t\treturn String.format(\"%f %f\", x, y);\n\t\t}\n\t}\n\n\tP isLL(P p1, P p2, P q1, P q2) {\n\t\tdouble d = p2.sub(p1).det(q1.sub(q2));\n\t\tif (Math.abs(d) < 1e-10)\n\t\t\treturn null;\n\t\treturn p1.add(p2.sub(p1).mul(q1.sub(q2).det(p1.sub(q2)) / d));\n\t}\n\n\tvoid run() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint q = sc.nextInt();\n\t\twhile (q-- > 0) {\n\t\t\tP p1 = new P(sc.nextDouble(), sc.nextDouble());\n\t\t\tP p2 = new P(sc.nextDouble(), sc.nextDouble());\n\t\t\tP q1 = new P(sc.nextDouble(), sc.nextDouble());\n\t\t\tP q2 = new P(sc.nextDouble(), sc.nextDouble());\n\n\t\t\tP x = isLL(p1, p2, q1, q2);\n\t\t\tSystem.out.println(String.format(\"%.20f %.20f\", x.x, x.y));\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n\n\tstatic void tr(Object... objects) {\n\t\tSystem.out.println(Arrays.deepToString(objects));\n\t}\n\n}", "problem_context": "Cross Point\n\nFor given two segments s1 and s2, print the coordinate of the cross point of them.\n\ns1 is formed by end points p0 and p1, and\ns2 is formed by end points p2 and p3.\n\nInput\n\nThe entire input looks like:\n\nq (the number of queries)\n1st query\n2nd query\n...\nqth query\n\nEach query consists of integer coordinates of end points of s1 and s2 in the following format:\n\nxp0 yp0 xp1 yp1 xp2 yp2 xp3 yp3\n\nOutput\n\nFor each query, print the coordinate of the cross point. The output values should be in a decimal fraction with an error less than 0.00000001.\n\nConstraints\n\n1 ≤ q ≤ 1000\n\n-10000 ≤ xpi, ypi ≤ 10000\n\np0 ≠ p1 and\np2 ≠ p3.\n\nThe given segments have a cross point and are not in parallel.\n\nSample Input\n\n3\n0 0 2 0 1 1 1 -1\n0 0 1 1 0 1 1 0\n0 0 1 1 1 0 0 1\n\nSample Output\n\n1.0000000000 0.0000000000\n0.5000000000 0.5000000000\n0.5000000000 0.5000000000", "sample_input": "3\n0 0 2 0 1 1 1 -1\n0 0 1 1 0 1 1 0\n0 0 1 1 1 0 0 1\n"}, "reference_outputs": ["1.0000000000 0.0000000000\n0.5000000000 0.5000000000\n0.5000000000 0.5000000000\n"], "source_document_id": "p02295", "source_text": "Cross Point\n\nFor given two segments s1 and s2, print the coordinate of the cross point of them.\n\ns1 is formed by end points p0 and p1, and\ns2 is formed by end points p2 and p3.\n\nInput\n\nThe entire input looks like:\n\nq (the number of queries)\n1st query\n2nd query\n...\nqth query\n\nEach query consists of integer coordinates of end points of s1 and s2 in the following format:\n\nxp0 yp0 xp1 yp1 xp2 yp2 xp3 yp3\n\nOutput\n\nFor each query, print the coordinate of the cross point. The output values should be in a decimal fraction with an error less than 0.00000001.\n\nConstraints\n\n1 ≤ q ≤ 1000\n\n-10000 ≤ xpi, ypi ≤ 10000\n\np0 ≠ p1 and\np2 ≠ p3.\n\nThe given segments have a cross point and are not in parallel.\n\nSample Input\n\n3\n0 0 2 0 1 1 1 -1\n0 0 1 1 0 1 1 0\n0 0 1 1 1 0 0 1\n\nSample Output\n\n1.0000000000 0.0000000000\n0.5000000000 0.5000000000\n0.5000000000 0.5000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1710, "cpu_time_ms": 520, "memory_kb": 60088}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s176042616", "group_id": "codeNet:p02340", "input_text": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.*;\n\npublic class Main {\n\tstatic final long MOD = 1000000007;\n\tpublic static void main(String[] args) {\n\t\tFastScanner sc = new FastScanner();\n\t\tint n = sc.nextInt();\n\t\tint k = sc.nextInt();\n\t\tlong[][] dp = new long[n + 1][k + 1];\n\t\tfor (int i = 0; i <= k; i++) {\n\t\t\tdp[0][i] = 1;\n\t\t}\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\tfor (int j = 1; j <= k; j++) {\n\t\t\t\tif (i - j >= 0) {\n\t\t\t\t\tdp[i][j] = dp[i][j - 1] + dp[i - j][j];\n\t\t\t\t\tdp[i][j] %= MOD;\n\t\t\t\t} else {\n\t\t\t\t\tdp[i][j] = dp[i][j - 1];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(dp[n][k]);\n\t}\n}\n\nclass FastScanner {\n\tprivate final InputStream in = System.in;\n\tprivate final byte[] buffer = new byte[1024];\n\tprivate int ptr = 0;\n\tprivate int buflen = 0;\n\tprivate boolean hasNextByte() {\n\t\tif (ptr < buflen) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\tptr = 0;\n\t\t\ttry {\n\t\t\t\tbuflen = in.read(buffer);\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (buflen <= 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\tprivate int readByte() {\n\t\tif (hasNextByte()) {\n\t\t\treturn buffer[ptr++];\n\t\t} else {\n\t\t\treturn -1;\n\t\t}\n\t}\n\tprivate static boolean isPrintableChar(int c) {\n\t\treturn 33 <= c && c <= 126;\n\t}\n\tpublic boolean hasNext() {\n\t\twhile (hasNextByte() && !isPrintableChar(buffer[ptr])) {\n\t\t\tptr++;\n\t\t}\n\t\treturn hasNextByte();\n\t}\n\tpublic String next() {\n\t\tif (!hasNext()) {\n\t\t\tthrow new NoSuchElementException();\n\t\t}\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint b = readByte();\n\t\twhile (isPrintableChar(b)) {\n\t\t\tsb.appendCodePoint(b);\n\t\t\tb = readByte();\n\t\t}\n\t\treturn sb.toString();\n\t}\n\tpublic long nextLong() {\n\t\tif (!hasNext()) {\n\t\t\tthrow new NoSuchElementException();\n\t\t}\n\t\tlong n = 0;\n\t\tboolean minus = false;\n\t\tint b = readByte();\n\t\tif (b == '-') {\n\t\t\tminus = true;\n\t\t\tb = readByte();\n\t\t}\n\t\tif (b < '0' || '9' < b) {\n\t\t\tthrow new NumberFormatException();\n\t\t}\n\t\twhile (true) {\n\t\t\tif ('0' <= b && b <= '9') {\n\t\t\t\tn *= 10;\n\t\t\t\tn += b - '0';\n\t\t\t} else if (b == -1 || !isPrintableChar(b)) {\n\t\t\t\treturn minus ? -n : n;\n\t\t\t} else {\n\t\t\t\tthrow new NumberFormatException();\n\t\t\t}\n\t\t\tb = readByte();\n\t\t}\n\t}\n\tpublic int nextInt() {\n\t\tlong nl = nextLong();\n\t\tif (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {\n\t\t\tthrow new NumberFormatException();\n\t\t}\n\t\treturn (int) nl;\n\t}\n\tpublic double nextDouble() {\n\t\treturn Double.parseDouble(next());\n\t}\n}\n\n", "language": "Java", "metadata": {"date": 1594278743, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02340.html", "problem_id": "p02340", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02340/input.txt", "sample_output_relpath": "derived/input_output/data/p02340/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02340/Java/s176042616.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s176042616", "user_id": "u061025485"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.*;\n\npublic class Main {\n\tstatic final long MOD = 1000000007;\n\tpublic static void main(String[] args) {\n\t\tFastScanner sc = new FastScanner();\n\t\tint n = sc.nextInt();\n\t\tint k = sc.nextInt();\n\t\tlong[][] dp = new long[n + 1][k + 1];\n\t\tfor (int i = 0; i <= k; i++) {\n\t\t\tdp[0][i] = 1;\n\t\t}\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\tfor (int j = 1; j <= k; j++) {\n\t\t\t\tif (i - j >= 0) {\n\t\t\t\t\tdp[i][j] = dp[i][j - 1] + dp[i - j][j];\n\t\t\t\t\tdp[i][j] %= MOD;\n\t\t\t\t} else {\n\t\t\t\t\tdp[i][j] = dp[i][j - 1];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(dp[n][k]);\n\t}\n}\n\nclass FastScanner {\n\tprivate final InputStream in = System.in;\n\tprivate final byte[] buffer = new byte[1024];\n\tprivate int ptr = 0;\n\tprivate int buflen = 0;\n\tprivate boolean hasNextByte() {\n\t\tif (ptr < buflen) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\tptr = 0;\n\t\t\ttry {\n\t\t\t\tbuflen = in.read(buffer);\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (buflen <= 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\tprivate int readByte() {\n\t\tif (hasNextByte()) {\n\t\t\treturn buffer[ptr++];\n\t\t} else {\n\t\t\treturn -1;\n\t\t}\n\t}\n\tprivate static boolean isPrintableChar(int c) {\n\t\treturn 33 <= c && c <= 126;\n\t}\n\tpublic boolean hasNext() {\n\t\twhile (hasNextByte() && !isPrintableChar(buffer[ptr])) {\n\t\t\tptr++;\n\t\t}\n\t\treturn hasNextByte();\n\t}\n\tpublic String next() {\n\t\tif (!hasNext()) {\n\t\t\tthrow new NoSuchElementException();\n\t\t}\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint b = readByte();\n\t\twhile (isPrintableChar(b)) {\n\t\t\tsb.appendCodePoint(b);\n\t\t\tb = readByte();\n\t\t}\n\t\treturn sb.toString();\n\t}\n\tpublic long nextLong() {\n\t\tif (!hasNext()) {\n\t\t\tthrow new NoSuchElementException();\n\t\t}\n\t\tlong n = 0;\n\t\tboolean minus = false;\n\t\tint b = readByte();\n\t\tif (b == '-') {\n\t\t\tminus = true;\n\t\t\tb = readByte();\n\t\t}\n\t\tif (b < '0' || '9' < b) {\n\t\t\tthrow new NumberFormatException();\n\t\t}\n\t\twhile (true) {\n\t\t\tif ('0' <= b && b <= '9') {\n\t\t\t\tn *= 10;\n\t\t\t\tn += b - '0';\n\t\t\t} else if (b == -1 || !isPrintableChar(b)) {\n\t\t\t\treturn minus ? -n : n;\n\t\t\t} else {\n\t\t\t\tthrow new NumberFormatException();\n\t\t\t}\n\t\t\tb = readByte();\n\t\t}\n\t}\n\tpublic int nextInt() {\n\t\tlong nl = nextLong();\n\t\tif (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {\n\t\t\tthrow new NumberFormatException();\n\t\t}\n\t\treturn (int) nl;\n\t}\n\tpublic double nextDouble() {\n\t\treturn Double.parseDouble(next());\n\t}\n}\n\n", "problem_context": "Balls and Boxes 10\n\nBalls\n\nBoxes\n\nAny way\n\nAt most one ball\n\nAt least one ball\n\nDistinguishable\n\nDistinguishable\n\n1\n\n2\n\n3\n\nIndistinguishable\n\nDistinguishable\n\n4\n\n5\n\n6\n\nDistinguishable\n\nIndistinguishable\n\n7\n\n8\n\n9\n\nIndistinguishable\n\nIndistinguishable\n\n10\n\n11\n\n12\n\nProblem\n\nYou have $n$ balls and $k$ boxes. You want to put these balls into the boxes.\n\nFind the number of ways to put the balls under the following conditions:\n\nEach ball is not distinguished from the other.\n\nEach box is not distinguished from the other.\n\nEach ball can go into only one box and no one remains outside of the boxes.\n\nEach box can contain an arbitrary number of balls (including zero).\n\nNote that you must print this count modulo $10^9+7$.\n\nInput\n\n$n$ $k$\n\nThe first line will contain two integers $n$ and $k$.\n\nOutput\n\nPrint the number of ways modulo $10^9+7$ in a line.\n\nConstraints\n\n$1 \\le n \\le 1000$\n\n$1 \\le k \\le 1000$\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n5\n\nSample Input 2\n\n10 5\n\nSample Output 2\n\n30\n\nSample Input 3\n\n100 100\n\nSample Output 3\n\n190569292", "sample_input": "5 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02340", "source_text": "Balls and Boxes 10\n\nBalls\n\nBoxes\n\nAny way\n\nAt most one ball\n\nAt least one ball\n\nDistinguishable\n\nDistinguishable\n\n1\n\n2\n\n3\n\nIndistinguishable\n\nDistinguishable\n\n4\n\n5\n\n6\n\nDistinguishable\n\nIndistinguishable\n\n7\n\n8\n\n9\n\nIndistinguishable\n\nIndistinguishable\n\n10\n\n11\n\n12\n\nProblem\n\nYou have $n$ balls and $k$ boxes. You want to put these balls into the boxes.\n\nFind the number of ways to put the balls under the following conditions:\n\nEach ball is not distinguished from the other.\n\nEach box is not distinguished from the other.\n\nEach ball can go into only one box and no one remains outside of the boxes.\n\nEach box can contain an arbitrary number of balls (including zero).\n\nNote that you must print this count modulo $10^9+7$.\n\nInput\n\n$n$ $k$\n\nThe first line will contain two integers $n$ and $k$.\n\nOutput\n\nPrint the number of ways modulo $10^9+7$ in a line.\n\nConstraints\n\n$1 \\le n \\le 1000$\n\n$1 \\le k \\le 1000$\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n5\n\nSample Input 2\n\n10 5\n\nSample Output 2\n\n30\n\nSample Input 3\n\n100 100\n\nSample Output 3\n\n190569292", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2355, "cpu_time_ms": 60, "memory_kb": 32528}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s369167017", "group_id": "codeNet:p02357", "input_text": "import java.util.Scanner;\n\nclass Main\n{ \n\tint st[]; \n\tint minVal(int x, int y) { \n\t\treturn (x < y) ? x : y; \n\t} \n\n\t \n\tint getMid(int s, int e) { \n\t\treturn s + (e - s) / 2; \n\t} \n\n\t\n\tint RMQUtil(int ss, int se, int qs, int qe, int index) \n\t{ \n\t\t \n\t\tif (qs <= ss && qe >= se) \n\t\t\treturn st[index]; \n\n\t\t\n\t\tif (se < qs || ss > qe) \n\t\t\treturn Integer.MAX_VALUE; \n\n\t\t \n\t\tint mid = getMid(ss, se); \n\t\treturn minVal(RMQUtil(ss, mid, qs, qe, 2 * index + 1), \n\t\t\t\tRMQUtil(mid + 1, se, qs, qe, 2 * index + 2)); \n\t} \n\n\t\n\tint RMQ(int n, int qs, int qe) \n\t{ \n\t\t\n\t\tif (qs < 0 || qe > n - 1 || qs > qe) { \n\t\t\tSystem.out.println(\"Invalid Input\"); \n\t\t\treturn -1; \n\t\t} \n\n\t\treturn RMQUtil(0, n - 1, qs, qe, 0); \n\t} \n\n\t\n\tint constructSTUtil(int arr[], int ss, int se, int si) \n\t{ \n\t\t\n\t\tif (ss == se) { \n\t\t\tst[si] = arr[ss]; \n\t\t\treturn arr[ss]; \n\t\t} \n\n\t\t\n\t\tint mid = getMid(ss, se); \n\t\tst[si] = minVal(constructSTUtil(arr, ss, mid, si * 2 + 1), \n\t\t\t\tconstructSTUtil(arr, mid + 1, se, si * 2 + 2)); \n\t\treturn st[si]; \n\t} \n\n\t\n\tvoid constructST(int arr[], int n) \n\t{ \n\t\t \n\t\tint x = (int) (Math.ceil(Math.log(n) / Math.log(2))); \n\n\t\t\n\t\tint max_size = 2 * (int) Math.pow(2, x) - 1; \n\t\tst = new int[max_size]; \n\n\t\t \n\t\tconstructSTUtil(arr, 0, n - 1, 0); \n\t} \n\n\t \n\tpublic static void main(String args[]) \n\t{ \n\t\t\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\tString N = sc.next(); \n\t\tString slide = sc.next();\n\t\tMain tree = new Main();\n\t\tint arr[] = new int[Integer.parseInt(N)];\n\t\tfor(int i=0; i= se) \n\t\t\treturn st[index]; \n\n\t\t\n\t\tif (se < qs || ss > qe) \n\t\t\treturn Integer.MAX_VALUE; \n\n\t\t \n\t\tint mid = getMid(ss, se); \n\t\treturn minVal(RMQUtil(ss, mid, qs, qe, 2 * index + 1), \n\t\t\t\tRMQUtil(mid + 1, se, qs, qe, 2 * index + 2)); \n\t} \n\n\t\n\tint RMQ(int n, int qs, int qe) \n\t{ \n\t\t\n\t\tif (qs < 0 || qe > n - 1 || qs > qe) { \n\t\t\tSystem.out.println(\"Invalid Input\"); \n\t\t\treturn -1; \n\t\t} \n\n\t\treturn RMQUtil(0, n - 1, qs, qe, 0); \n\t} \n\n\t\n\tint constructSTUtil(int arr[], int ss, int se, int si) \n\t{ \n\t\t\n\t\tif (ss == se) { \n\t\t\tst[si] = arr[ss]; \n\t\t\treturn arr[ss]; \n\t\t} \n\n\t\t\n\t\tint mid = getMid(ss, se); \n\t\tst[si] = minVal(constructSTUtil(arr, ss, mid, si * 2 + 1), \n\t\t\t\tconstructSTUtil(arr, mid + 1, se, si * 2 + 2)); \n\t\treturn st[si]; \n\t} \n\n\t\n\tvoid constructST(int arr[], int n) \n\t{ \n\t\t \n\t\tint x = (int) (Math.ceil(Math.log(n) / Math.log(2))); \n\n\t\t\n\t\tint max_size = 2 * (int) Math.pow(2, x) - 1; \n\t\tst = new int[max_size]; \n\n\t\t \n\t\tconstructSTUtil(arr, 0, n - 1, 0); \n\t} \n\n\t \n\tpublic static void main(String args[]) \n\t{ \n\t\t\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\tString N = sc.next(); \n\t\tString slide = sc.next();\n\t\tMain tree = new Main();\n\t\tint arr[] = new int[Integer.parseInt(N)];\n\t\tfor(int i=0; i COMPARATOR = new Comp();\n\t\n\tprivate static class Comp implements Comparator{\n\t\tpublic int compare(Node x,Node y){\n\t\t\treturn (x.d > y.d) ? 1 : ((x.d == y.d) ? 0 : -1);\n\t\t}\n\t}\n\n\tstatic class Node {\n\t\tint id;\n\t\tint d;\n\t\tNode(int id,int d){\n\t\t\tthis.id = id;\n\t\t\tthis.d = d;\n\t\t}\n\t}\n\n\tstatic class Edge {\n\t\tint to;\n\t\tint cost;\n\t\tEdge(int to,int cost){\n\t\t\tthis.to = to;\n\t\t\tthis.cost = cost;\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString line = br.readLine();\n\t\tString[] str = line.split(\" \");\n\t\tint v = Integer.parseInt(str[0]);\n\t\tint e = Integer.parseInt(str[1]);\n\t\tint r = Integer.parseInt(str[2]);\n\n\t\tLinkedList> graph = new LinkedList>();\n\t\tfor (int i=0; i());\n\t\t}\n\n\t\tfor (int i=0; i list = graph.get(si);\n\t\t\tlist.add(new Edge(ti,di));\n\t\t}\n\n\t\tPriorityQueue pQue = new PriorityQueue(100000,COMPARATOR);\n\t\tint[] d = new int[v];\n\t\tArrays.fill(d,INF);\n\t\td[r] = 0;\n\t\tpQue.add(new Node(r,0));\n\n\t\twhile (!pQue.isEmpty()) {\n\t\t\tNode node = pQue.poll();\n\t\t\tint now = node.id;\n\t\t\tif (d[now] < node.d)\n\t\t\t\tcontinue;\n\t\t\tLinkedList list = graph.get(now);\n\t\t\twhile (!list.isEmpty()) {\n\t\t\t\tEdge edge = list.poll();\n\t\t\t\tif (d[edge.to] > d[now] + edge.cost) {\n\t\t\t\t\td[edge.to] = d[now] + edge.cost;\n\t\t\t\t\tpQue.add(new Node(edge.to,d[edge.to]));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (int i : d) {\n\t\t\tSystem.out.println(i==INF?\"INF\":i);\n\t\t}\n\n\t\tbr.close();\n\t}\n}", "language": "Java", "metadata": {"date": 1416238916, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02361.html", "problem_id": "p02361", "resource_group": "high_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/Java/s700590383.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s700590383", "user_id": "u368083894"}, "prompt_components": {"gold_output": "0\n1\n3\n4\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\n\nclass Main {\n\n\tstatic final int INF = Integer.MAX_VALUE/2;\n\tpublic static final Comparator COMPARATOR = new Comp();\n\t\n\tprivate static class Comp implements Comparator{\n\t\tpublic int compare(Node x,Node y){\n\t\t\treturn (x.d > y.d) ? 1 : ((x.d == y.d) ? 0 : -1);\n\t\t}\n\t}\n\n\tstatic class Node {\n\t\tint id;\n\t\tint d;\n\t\tNode(int id,int d){\n\t\t\tthis.id = id;\n\t\t\tthis.d = d;\n\t\t}\n\t}\n\n\tstatic class Edge {\n\t\tint to;\n\t\tint cost;\n\t\tEdge(int to,int cost){\n\t\t\tthis.to = to;\n\t\t\tthis.cost = cost;\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString line = br.readLine();\n\t\tString[] str = line.split(\" \");\n\t\tint v = Integer.parseInt(str[0]);\n\t\tint e = Integer.parseInt(str[1]);\n\t\tint r = Integer.parseInt(str[2]);\n\n\t\tLinkedList> graph = new LinkedList>();\n\t\tfor (int i=0; i());\n\t\t}\n\n\t\tfor (int i=0; i list = graph.get(si);\n\t\t\tlist.add(new Edge(ti,di));\n\t\t}\n\n\t\tPriorityQueue pQue = new PriorityQueue(100000,COMPARATOR);\n\t\tint[] d = new int[v];\n\t\tArrays.fill(d,INF);\n\t\td[r] = 0;\n\t\tpQue.add(new Node(r,0));\n\n\t\twhile (!pQue.isEmpty()) {\n\t\t\tNode node = pQue.poll();\n\t\t\tint now = node.id;\n\t\t\tif (d[now] < node.d)\n\t\t\t\tcontinue;\n\t\t\tLinkedList list = graph.get(now);\n\t\t\twhile (!list.isEmpty()) {\n\t\t\t\tEdge edge = list.poll();\n\t\t\t\tif (d[edge.to] > d[now] + edge.cost) {\n\t\t\t\t\td[edge.to] = d[now] + edge.cost;\n\t\t\t\t\tpQue.add(new Node(edge.to,d[edge.to]));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (int i : d) {\n\t\t\tSystem.out.println(i==INF?\"INF\":i);\n\t\t}\n\n\t\tbr.close();\n\t}\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": 1861, "cpu_time_ms": 19170, "memory_kb": 111080}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s326905326", "group_id": "codeNet:p02361", "input_text": "\nimport java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.AbstractCollection;\nimport java.util.PriorityQueue;\nimport java.util.Scanner;\nimport java.util.Comparator;\nimport java.util.ArrayList;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author silviase\n */\npublic class Main {\n \n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n DijkstraVerify solver = new DijkstraVerify();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class DijkstraVerify {\n public void solve(int testNumber, Scanner in, PrintWriter out) {\n int n = in.nextInt();\n int m = in.nextInt();\n int source = in.nextInt();\n Graph g = new Graph(n);\n for (int i = 0; i < m; i++) {\n g.addEdge(new Edge(in.nextInt(), in.nextInt(), in.nextInt()));\n }\n long[] d = g.dijkstra(source);\n for (int i = 0; i < n; i++) {\n if (d[i] > 1e15) out.println(\"INF\");\n else out.println(d[i]);\n }\n }\n\n }\n\n static class Graph {\n public int size;\n public ArrayList[] adj;\n public int[] inDeg;\n public int[] vertexCost;\n\n @SuppressWarnings(\"unchecked\")\n public Graph(int size) {\n this.size = size;\n adj = new ArrayList[size];\n inDeg = new int[size];\n vertexCost = new int[size];\n for (int i = 0; i < size; i++) {\n adj[i] = new ArrayList<>();\n }\n }\n\n public void addEdge(Edge e) {\n adj[e.from].add(e);\n inDeg[e.to]++;\n }\n\n public long[] dijkstra(int from) {\n long[] d = new long[size];\n PriorityQueue pq = new PriorityQueue<>(Comparator.comparing(e -> d[e]));\n for (int i = 0; i < size; i++) {\n d[i] = (i == from) ? 0 : (long) 1e18;\n pq.add(i);\n }\n // System.out.println(Arrays.toString(pq.toArray()));\n while (!pq.isEmpty()) {\n int search = pq.poll();\n // System.out.println(\"now: \" + search);\n ArrayList edges = adj[search];\n for (Edge e : edges) {\n // System.out.println(e.toString());\n long cmp = d[search] + e.cost;\n if (d[e.to] > d[search] + e.cost) {\n // 更新が入る\n // 処理を入れたい場合はここに入れる\n d[e.to] = d[search] + e.cost;\n pq.add(e.to);\n }\n }\n // System.out.println(Arrays.toString(pq.toArray()));\n }\n return d;\n }\n\n }\n\n static class Edge {\n public int from;\n public int to;\n public long cost;\n\n public Edge(int to) {\n this.to = to;\n }\n\n public Edge(int to, long cost) {\n this.to = to;\n this.cost = cost;\n }\n\n public Edge(int from, int to, long cost) {\n this.from = from;\n this.to = to;\n this.cost = cost;\n }\n\n public String toString() {\n return \"Edge{\" +\n \"from=\" + from +\n \", to=\" + to +\n \", cost=\" + cost +\n '}';\n }\n\n }\n}\n\n\n", "language": "Java", "metadata": {"date": 1587255454, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02361.html", "problem_id": "p02361", "resource_group": "high_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/Java/s326905326.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s326905326", "user_id": "u713279445"}, "prompt_components": {"gold_output": "0\n1\n3\n4\n", "input_to_evaluate": "\nimport java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.AbstractCollection;\nimport java.util.PriorityQueue;\nimport java.util.Scanner;\nimport java.util.Comparator;\nimport java.util.ArrayList;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author silviase\n */\npublic class Main {\n \n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n DijkstraVerify solver = new DijkstraVerify();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class DijkstraVerify {\n public void solve(int testNumber, Scanner in, PrintWriter out) {\n int n = in.nextInt();\n int m = in.nextInt();\n int source = in.nextInt();\n Graph g = new Graph(n);\n for (int i = 0; i < m; i++) {\n g.addEdge(new Edge(in.nextInt(), in.nextInt(), in.nextInt()));\n }\n long[] d = g.dijkstra(source);\n for (int i = 0; i < n; i++) {\n if (d[i] > 1e15) out.println(\"INF\");\n else out.println(d[i]);\n }\n }\n\n }\n\n static class Graph {\n public int size;\n public ArrayList[] adj;\n public int[] inDeg;\n public int[] vertexCost;\n\n @SuppressWarnings(\"unchecked\")\n public Graph(int size) {\n this.size = size;\n adj = new ArrayList[size];\n inDeg = new int[size];\n vertexCost = new int[size];\n for (int i = 0; i < size; i++) {\n adj[i] = new ArrayList<>();\n }\n }\n\n public void addEdge(Edge e) {\n adj[e.from].add(e);\n inDeg[e.to]++;\n }\n\n public long[] dijkstra(int from) {\n long[] d = new long[size];\n PriorityQueue pq = new PriorityQueue<>(Comparator.comparing(e -> d[e]));\n for (int i = 0; i < size; i++) {\n d[i] = (i == from) ? 0 : (long) 1e18;\n pq.add(i);\n }\n // System.out.println(Arrays.toString(pq.toArray()));\n while (!pq.isEmpty()) {\n int search = pq.poll();\n // System.out.println(\"now: \" + search);\n ArrayList edges = adj[search];\n for (Edge e : edges) {\n // System.out.println(e.toString());\n long cmp = d[search] + e.cost;\n if (d[e.to] > d[search] + e.cost) {\n // 更新が入る\n // 処理を入れたい場合はここに入れる\n d[e.to] = d[search] + e.cost;\n pq.add(e.to);\n }\n }\n // System.out.println(Arrays.toString(pq.toArray()));\n }\n return d;\n }\n\n }\n\n static class Edge {\n public int from;\n public int to;\n public long cost;\n\n public Edge(int to) {\n this.to = to;\n }\n\n public Edge(int to, long cost) {\n this.to = to;\n this.cost = cost;\n }\n\n public Edge(int from, int to, long cost) {\n this.from = from;\n this.to = to;\n this.cost = cost;\n }\n\n public String toString() {\n return \"Edge{\" +\n \"from=\" + from +\n \", to=\" + to +\n \", cost=\" + cost +\n '}';\n }\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": 3718, "cpu_time_ms": 1770, "memory_kb": 451816}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s138517036", "group_id": "codeNet:p02379", "input_text": "import java.util.Scanner;\n\nimport static java.lang.Math.pow;\nimport static java.lang.Math.sqrt;\n\nclass Main{\n \n public static void main(String[] arg){\n\n Scanner in = new Scanner(System.in);\n\n String input = in.nextLine();\n String [] param_line = input.split(\" \", 0);\n\n double x1 = Double.parseDouble(param_line[0]);\n double y1 = Double.parseDouble(param_line[1]);\n double x2 = Double.parseDouble(param_line[2]);\n double y2 = Double.parseDouble(param_line[3]);\n\n double d = sqrt(pow(x2-x1,2)+pow(y2-y1, 2));\n\n System.out.println(d);\n }\n}", "language": "Java", "metadata": {"date": 1460594302, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02379.html", "problem_id": "p02379", "resource_group": "high_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/Java/s138517036.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s138517036", "user_id": "u775942576"}, "prompt_components": {"gold_output": "1.41421356\n", "input_to_evaluate": "import java.util.Scanner;\n\nimport static java.lang.Math.pow;\nimport static java.lang.Math.sqrt;\n\nclass Main{\n \n public static void main(String[] arg){\n\n Scanner in = new Scanner(System.in);\n\n String input = in.nextLine();\n String [] param_line = input.split(\" \", 0);\n\n double x1 = Double.parseDouble(param_line[0]);\n double y1 = Double.parseDouble(param_line[1]);\n double x2 = Double.parseDouble(param_line[2]);\n double y2 = Double.parseDouble(param_line[3]);\n\n double d = sqrt(pow(x2-x1,2)+pow(y2-y1, 2));\n\n System.out.println(d);\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": 608, "cpu_time_ms": 70, "memory_kb": 26216}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s940145963", "group_id": "codeNet:p02383", "input_text": "import java.util.Scanner;\npublic class Main {\n public static void main(String[] args){\n \tScanner scan = new Scanner(System.in);\n \tint[] dice_num,dice_num2;\n \tdice_num = new int[10];\n \tdice_num2 = new int[10];\n \tint i;\n \tfor(i = 0; i < 6; i++){\n \t\tdice_num[i] = scan.nextInt();\n \t}\n \tString dir_word = scan.next();\n \tString dir_array[] = dir_word.split(\"\");\n \tfor(i = 0; i < dir_word.length(); i++){\n \t\tif(dir_array[i].equals(\"S\")){\n \t\t\tdice_num2[0] = dice_num[4];\n \t\t\tdice_num2[1] = dice_num[0];\n \t\t\tdice_num2[2] = dice_num[2];\n \t\t\tdice_num2[3] = dice_num[3];\n \t\t\tdice_num2[4] = dice_num[5];\n \t\t\tdice_num2[5] = dice_num[1];\n \t\t}\n \t\telse if(dir_array[i].equals(\"W\")){\n \t\t\tdice_num2[0] = dice_num[2];\n \t\t\tdice_num2[1] = dice_num[1];\n \t\t\tdice_num2[2] = dice_num[5];\n \t\t\tdice_num2[3] = dice_num[0];\n \t\t\tdice_num2[4] = dice_num[4];\n \t\t\tdice_num2[5] = dice_num[3];\n \t\t}\n \t\telse if(dir_array[i].equals(\"N\")){\n \t\t\tdice_num2[0] = dice_num[1];\n \t\t\tdice_num2[1] = dice_num[5];\n \t\t\tdice_num2[2] = dice_num[2];\n \t\t\tdice_num2[3] = dice_num[3];\n \t\t\tdice_num2[4] = dice_num[0];\n \t\t\tdice_num2[5] = dice_num[3];\n \t\t}\n \t\telse if(dir_array[i].equals(\"E\")){\n \t\t\tdice_num2[0] = dice_num[3];\n \t\t\tdice_num2[1] = dice_num[1];\n \t\t\tdice_num2[2] = dice_num[0];\n \t\t\tdice_num2[3] = dice_num[5];\n \t\t\tdice_num2[4] = dice_num[4];\n \t\t\tdice_num2[5] = dice_num[2];\n \t\t}\n \t\t\tdice_num[0] = dice_num2[0];\n \t\t\tdice_num[1] = dice_num2[1];\n \t\t\tdice_num[2] = dice_num2[2];\n \t\t\tdice_num[3] = dice_num2[3];\n \t\t\tdice_num[4] = dice_num2[4];\n \t\t\tdice_num[5] = dice_num2[5];\n \t\t\tSystem.out.println(dice_num[0]);\n \t}\n \t\tSystem.out.println(dice_num[0]);\n \t}\n}\n \n\n\n\n\n\t\t\n\n\t", "language": "Java", "metadata": {"date": 1464358056, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02383.html", "problem_id": "p02383", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02383/input.txt", "sample_output_relpath": "derived/input_output/data/p02383/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02383/Java/s940145963.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s940145963", "user_id": "u338092584"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main {\n public static void main(String[] args){\n \tScanner scan = new Scanner(System.in);\n \tint[] dice_num,dice_num2;\n \tdice_num = new int[10];\n \tdice_num2 = new int[10];\n \tint i;\n \tfor(i = 0; i < 6; i++){\n \t\tdice_num[i] = scan.nextInt();\n \t}\n \tString dir_word = scan.next();\n \tString dir_array[] = dir_word.split(\"\");\n \tfor(i = 0; i < dir_word.length(); i++){\n \t\tif(dir_array[i].equals(\"S\")){\n \t\t\tdice_num2[0] = dice_num[4];\n \t\t\tdice_num2[1] = dice_num[0];\n \t\t\tdice_num2[2] = dice_num[2];\n \t\t\tdice_num2[3] = dice_num[3];\n \t\t\tdice_num2[4] = dice_num[5];\n \t\t\tdice_num2[5] = dice_num[1];\n \t\t}\n \t\telse if(dir_array[i].equals(\"W\")){\n \t\t\tdice_num2[0] = dice_num[2];\n \t\t\tdice_num2[1] = dice_num[1];\n \t\t\tdice_num2[2] = dice_num[5];\n \t\t\tdice_num2[3] = dice_num[0];\n \t\t\tdice_num2[4] = dice_num[4];\n \t\t\tdice_num2[5] = dice_num[3];\n \t\t}\n \t\telse if(dir_array[i].equals(\"N\")){\n \t\t\tdice_num2[0] = dice_num[1];\n \t\t\tdice_num2[1] = dice_num[5];\n \t\t\tdice_num2[2] = dice_num[2];\n \t\t\tdice_num2[3] = dice_num[3];\n \t\t\tdice_num2[4] = dice_num[0];\n \t\t\tdice_num2[5] = dice_num[3];\n \t\t}\n \t\telse if(dir_array[i].equals(\"E\")){\n \t\t\tdice_num2[0] = dice_num[3];\n \t\t\tdice_num2[1] = dice_num[1];\n \t\t\tdice_num2[2] = dice_num[0];\n \t\t\tdice_num2[3] = dice_num[5];\n \t\t\tdice_num2[4] = dice_num[4];\n \t\t\tdice_num2[5] = dice_num[2];\n \t\t}\n \t\t\tdice_num[0] = dice_num2[0];\n \t\t\tdice_num[1] = dice_num2[1];\n \t\t\tdice_num[2] = dice_num2[2];\n \t\t\tdice_num[3] = dice_num2[3];\n \t\t\tdice_num[4] = dice_num2[4];\n \t\t\tdice_num[5] = dice_num2[5];\n \t\t\tSystem.out.println(dice_num[0]);\n \t}\n \t\tSystem.out.println(dice_num[0]);\n \t}\n}\n \n\n\n\n\n\t\t\n\n\t", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice I\n\nWrite a program to simulate rolling a dice, which can be constructed by the following net.\n\nAs shown in the figures, each face is identified by a different label from 1 to 6.\n\nWrite a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures.\n\nInput\n\nIn the first line, six integers assigned to faces are given in ascending order of their corresponding labels.\n\nIn the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures.\n\nOutput\n\nPrint the integer which appears on the top face after the simulation.\n\nConstraints\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\n$0 \\leq $ the length of the command $\\leq 100$\n\nSample Input 1\n\n1 2 4 8 16 32\nSE\n\nSample Output 1\n\n8\n\nYou are given a dice where 1, 2, 4, 8, 16 are 32 are assigned to a face labeled by 1, 2, ..., 6 respectively. After you roll the dice to the direction S and then to the direction E, you can see 8 on the top face.\n\nSample Input 2\n\n1 2 4 8 16 32\nEESWN\n\nSample Output 2\n\n32", "sample_input": "1 2 4 8 16 32\nSE\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02383", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice I\n\nWrite a program to simulate rolling a dice, which can be constructed by the following net.\n\nAs shown in the figures, each face is identified by a different label from 1 to 6.\n\nWrite a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures.\n\nInput\n\nIn the first line, six integers assigned to faces are given in ascending order of their corresponding labels.\n\nIn the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures.\n\nOutput\n\nPrint the integer which appears on the top face after the simulation.\n\nConstraints\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\n$0 \\leq $ the length of the command $\\leq 100$\n\nSample Input 1\n\n1 2 4 8 16 32\nSE\n\nSample Output 1\n\n8\n\nYou are given a dice where 1, 2, 4, 8, 16 are 32 are assigned to a face labeled by 1, 2, ..., 6 respectively. After you roll the dice to the direction S and then to the direction E, you can see 8 on the top face.\n\nSample Input 2\n\n1 2 4 8 16 32\nEESWN\n\nSample Output 2\n\n32", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1785, "cpu_time_ms": 60, "memory_kb": 25828}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s186748118", "group_id": "codeNet:p02384", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\t\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\tclass qube{\n\t\t\tScanner sc = new Scanner(System.in);\n\t\t\tint [] face = new int[6],faces;\n\t\t\tInteger i,dump=0;\n\t\t\tInteger a,b,n;\n\t\t\t\n\n\t\t\tqube(){\n\t\t\t\tfor(i=0;i<6;i++){\n\t\t\t\t\tface[i]=sc.nextInt();\n\t\t\t\t}\n\t\t\t\tn = sc.nextInt();\n\t\t\t\tfaces = face.clone();\n\t\t\t}\n\n\t\t\tvoid swap(int a,int b){\n\t\t\t\tdump = this.face[a];\n\t\t\t\tthis.face[a] = this.face[b];\n\t\t\t\tthis.face[b] = dump;\n\n\t\t\t}\n\t\t\tvoid scn(){\n\t\t\t\ta = sc.nextInt();\n\t\t\t\tb = sc.nextInt();\n\t\t\t}\n\t\t\tvoid pt(){\n\t\t\t\tSystem.out.printf(\"%d\\n\", this.face[2]);\n\t\t\t}\n\n\t\t\tvoid move(String es){\n\t\t\t\tif(es.equals(\"E\")){\n\t\t\t\t\tswap(0,2);\n\t\t\t\t\tswap(0,5);\n\t\t\t\t\tswap(0,3);\n\t\t\t\t}\n\t\t\t\telse if(es.equals(\"N\")){\n\t\t\t\t\tswap(4,5);\n\t\t\t\t\tswap(4,1);\n\t\t\t\t\tswap(4,0);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\n\t\t}\n\t\tint j;\n\n\t\tqube q = new qube();\n\t\tfor(j=0;j=0 && s <86400) {\n\t\t\t\tint second = s % 60;\n\t\t\t\ts = s / 60;\n\t\t\t\tint minute = s % 60;\n\t\t\t\tint hour = s / 60;\n\t\t\t\tSystem.out.println(String.format(\"%d:%d:%d\",hour,minute,second));\t\t\t\n\t\t\t}\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1474603614, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02390.html", "problem_id": "p02390", "resource_group": "high_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/Java/s696059733.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s696059733", "user_id": "u512315283"}, "prompt_components": {"gold_output": "13:2:59\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\ttry(Scanner sc = new Scanner(System.in)){\n\t\t\tint s = sc.nextInt();\n\t\t\tif(s >=0 && s <86400) {\n\t\t\t\tint second = s % 60;\n\t\t\t\ts = s / 60;\n\t\t\t\tint minute = s % 60;\n\t\t\t\tint hour = s / 60;\n\t\t\t\tSystem.out.println(String.format(\"%d:%d:%d\",hour,minute,second));\t\t\t\n\t\t\t}\n\t\t}\n\t}\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": 361, "cpu_time_ms": 60, "memory_kb": 26236}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s538901148", "group_id": "codeNet:p02390", "input_text": "import java.io.BufferedReader;\nimport java.io.InputStreamReader;\n \nclass Main{\n public static void main(String[] args) throws Exception{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n int n = Integer.parseInt(br.readLine());\n int s = n%60;\n int h = n/3600;\n int m = (n-h*3600)/60;\n System.out.println(h+\":\"+m+\":\"+s);\n }\n}", "language": "Java", "metadata": {"date": 1486633804, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02390.html", "problem_id": "p02390", "resource_group": "high_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/Java/s538901148.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s538901148", "user_id": "u875408758"}, "prompt_components": {"gold_output": "13:2:59\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.InputStreamReader;\n \nclass Main{\n public static void main(String[] args) throws Exception{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n int n = Integer.parseInt(br.readLine());\n int s = n%60;\n int h = n/3600;\n int m = (n-h*3600)/60;\n System.out.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": 370, "cpu_time_ms": 50, "memory_kb": 24208}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s400846248", "group_id": "codeNet:p02390", "input_text": "import java.util.Scanner;\n\nclass Main{\n\tpublic static void main (String[]args){\n\t\tScanner scan = new Scanner(System.in);\n\t\tint S = scan.nextInt();\n\t\t\n\t\tint h = S / 3600;\n\t\tint m = (S - (h * 3600)) / 60;\n\t\tint s = (S - (h * 3600))- m * 60;\n\t\t\n\t\tSystem.out.println(h + \":\" + m + \":\" + s);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1591767154, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02390.html", "problem_id": "p02390", "resource_group": "high_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/Java/s400846248.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s400846248", "user_id": "u924565640"}, "prompt_components": {"gold_output": "13:2:59\n", "input_to_evaluate": "import java.util.Scanner;\n\nclass Main{\n\tpublic static void main (String[]args){\n\t\tScanner scan = new Scanner(System.in);\n\t\tint S = scan.nextInt();\n\t\t\n\t\tint h = S / 3600;\n\t\tint m = (S - (h * 3600)) / 60;\n\t\tint s = (S - (h * 3600))- m * 60;\n\t\t\n\t\tSystem.out.println(h + \":\" + m + \":\" + s);\n\t}\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": 292, "cpu_time_ms": 80, "memory_kb": 26196}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s004817925", "group_id": "codeNet:p02391", "input_text": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);;\n int a = sc.nextInt();\n int b = sc.nextInt();\n if(a>b){\n System.out.println(\"a\"+\" > \"+\"b\");\n }else if(ab){\n System.out.println(\"a\"+\" > \"+\"b\");\n }else if(a 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": 415, "cpu_time_ms": 70, "memory_kb": 26396}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s918250314", "group_id": "codeNet:p02391", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint a = sc.nextInt();\n\t\tint b = sc.nextInt();\n\n\t\tif(ab){\n\t\t\tSystem.out.println(\"a>b\");\n\t\t}else if(a==b){\n\t\t\tSystem.out.println(\"a==b\");\n\t\t}else {\n\t\t\tSystem.out.print(\"0\");\n\t\t}\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1524204592, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02391.html", "problem_id": "p02391", "resource_group": "high_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/Java/s918250314.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s918250314", "user_id": "u314998184"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint a = sc.nextInt();\n\t\tint b = sc.nextInt();\n\n\t\tif(ab){\n\t\t\tSystem.out.println(\"a>b\");\n\t\t}else if(a==b){\n\t\t\tSystem.out.println(\"a==b\");\n\t\t}else {\n\t\t\tSystem.out.print(\"0\");\n\t\t}\n\t}\n\n}\n", "problem_context": "Small, Large, or Equal\n\nWrite a program which prints small/large/equal relation of given two integers a and b.\n\nInput\n\nTwo integers a and b separated by a single space are given in a line.\n\nOutput\n\nFor given two integers a and b, print\n\na < b\n\nif a is less than b,\n\na > b\n\nif a is greater than b, and\n\na == b\n\nif a equals to b.\n\nConstraints\n\n-1000 ≤ a, b ≤ 1000\n\nSample Input 1\n\n1 2\n\nSample Output 1\n\na < b\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\na > b\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\na == b", "sample_input": "1 2\n"}, "reference_outputs": ["a\n"], "source_document_id": "p02391", "source_text": "Small, Large, or Equal\n\nWrite a program which prints small/large/equal relation of given two integers a and b.\n\nInput\n\nTwo integers a and b separated by a single space are given in a line.\n\nOutput\n\nFor given two integers a and b, print\n\na < b\n\nif a is less than b,\n\na > b\n\nif a is greater than b, and\n\na == b\n\nif a equals to b.\n\nConstraints\n\n-1000 ≤ a, b ≤ 1000\n\nSample Input 1\n\n1 2\n\nSample Output 1\n\na < b\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\na > b\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\na == b", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 359, "cpu_time_ms": 50, "memory_kb": 26112}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s207810033", "group_id": "codeNet:p02391", "input_text": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner inp = new Scanner(System.in);\n\n int a = inp.nextInt();\n\n int b = inp.nextInt();\n\n if (a == b) {\n System.out.println(\"a == b\");\n } else if (a < b) {\n System.out.println(\"a < b\");\n } else if (a > b) {\n System.out.println(\"a > b\");\n }\n }\n}\n\n", "language": "Java", "metadata": {"date": 1536716806, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02391.html", "problem_id": "p02391", "resource_group": "high_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/Java/s207810033.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s207810033", "user_id": "u647456682"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner inp = new Scanner(System.in);\n\n int a = inp.nextInt();\n\n int b = inp.nextInt();\n\n if (a == b) {\n System.out.println(\"a == b\");\n } else if (a < b) {\n System.out.println(\"a < b\");\n } else if (a > b) {\n System.out.println(\"a > b\");\n }\n }\n}\n\n", "problem_context": "Small, Large, or Equal\n\nWrite a program which prints small/large/equal relation of given two integers a and b.\n\nInput\n\nTwo integers a and b separated by a single space are given in a line.\n\nOutput\n\nFor given two integers a and b, print\n\na < b\n\nif a is less than b,\n\na > b\n\nif a is greater than b, and\n\na == b\n\nif a equals to b.\n\nConstraints\n\n-1000 ≤ a, b ≤ 1000\n\nSample Input 1\n\n1 2\n\nSample Output 1\n\na < b\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\na > b\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\na == b", "sample_input": "1 2\n"}, "reference_outputs": ["a\n"], "source_document_id": "p02391", "source_text": "Small, Large, or Equal\n\nWrite a program which prints small/large/equal relation of given two integers a and b.\n\nInput\n\nTwo integers a and b separated by a single space are given in a line.\n\nOutput\n\nFor given two integers a and b, print\n\na < b\n\nif a is less than b,\n\na > b\n\nif a is greater than b, and\n\na == b\n\nif a equals to b.\n\nConstraints\n\n-1000 ≤ a, b ≤ 1000\n\nSample Input 1\n\n1 2\n\nSample Output 1\n\na < b\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\na > b\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\na == b", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 424, "cpu_time_ms": 50, "memory_kb": 26204}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s089939815", "group_id": "codeNet:p02392", "input_text": "import java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tScanner kb = new Scanner( System.in);\n\t\tint a=kb.nextInt();\n\t\tint b=kb.nextInt();\n\t\tint c=kb.nextInt();\n\t\t\n\t\tif( a < b ) {\n\t\t\tif( b < c ) {\n\t\t\t\tSystem.out.println( \"Yes\");\t\t\n\t\t\t} else {\n\t\t\t\tSystem.out.println( \"No\");\t\n\t\t\t}\n\t\t} else {\n\t\t\tSystem.out.println( \"No\");\t\t\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1424850297, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02392.html", "problem_id": "p02392", "resource_group": "high_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/Java/s089939815.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s089939815", "user_id": "u604774382"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tScanner kb = new Scanner( System.in);\n\t\tint a=kb.nextInt();\n\t\tint b=kb.nextInt();\n\t\tint c=kb.nextInt();\n\t\t\n\t\tif( a < b ) {\n\t\t\tif( b < c ) {\n\t\t\t\tSystem.out.println( \"Yes\");\t\t\n\t\t\t} else {\n\t\t\t\tSystem.out.println( \"No\");\t\n\t\t\t}\n\t\t} else {\n\t\t\tSystem.out.println( \"No\");\t\t\n\t\t}\n\t}\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": 358, "cpu_time_ms": 50, "memory_kb": 17164}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s573333123", "group_id": "codeNet:p02393", "input_text": "import java.util.*;\n\nclass Main {\n\tstatic Scanner sc =new Scanner(System.in);\n\tstatic int a;\n\tstatic int b;\n\tstatic int c;\n static int [] x;\n\t\tpublic static void main (String[]agrs){\n\t\t\ta=sc.nextInt();\n\t\t\tb=sc.nextInt();\n\t\t\tc=sc.nextInt();\n\t\t\tint[]x=new int[]{a,b,c};\n\t\t\t\n\t\t\tArrays.sort(x);\n\t\t\tfor(int i = 0;i r && y - r >0 && x + r < W && y + r < H ) {\n\t\t\tSystem.out.println(\"Yes\");\n\t\t} else {\n\t\t\tSystem.out.println(\"No\");\n\t\t}\n\t\t\n\t}\n\n}", "language": "Java", "metadata": {"date": 1455776902, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02394.html", "problem_id": "p02394", "resource_group": "high_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/Java/s587305710.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s587305710", "user_id": "u017073080"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\t// TODO ?????????????????????????????????????????????\n\n\t\tScanner scan = new Scanner(System.in);\n\t\tint W = scan.nextInt();\n\t\tint H = scan.nextInt();\n\t\tint x = scan.nextInt();\n\t\tint y = scan.nextInt();\n\t\tint r = scan.nextInt();\n\t\t\n\t\tif( x > r && y - r >0 && x + r < W && y + r < H ) {\n\t\t\tSystem.out.println(\"Yes\");\n\t\t} else {\n\t\t\tSystem.out.println(\"No\");\n\t\t}\n\t\t\n\t}\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": 456, "cpu_time_ms": 50, "memory_kb": 26336}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s453995599", "group_id": "codeNet:p02396", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayList;\n\nclass Main {\n\tpublic static void main(String[] args) throws IOException {\n\t\tInputStreamReader is = new InputStreamReader(System.in);\n\t\tBufferedReader br = new BufferedReader(is);\n\n\t\tArrayList list = new ArrayList();\n\n\t\tfor (int i = 0; i < 10001; i++) {\n\t\t\tlist.add(br.readLine());\n\t\t\tif (\"0\".equals(list.get(i))) {\n\t\t\t\tfor (int j = 1; j < list.size(); j++) {\n\t\t\t\t\tSystem.out.println(\"Case \"+j+\": \"+list.get(j-1));\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1465202931, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02396.html", "problem_id": "p02396", "resource_group": "high_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/Java/s453995599.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s453995599", "user_id": "u927248905"}, "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": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayList;\n\nclass Main {\n\tpublic static void main(String[] args) throws IOException {\n\t\tInputStreamReader is = new InputStreamReader(System.in);\n\t\tBufferedReader br = new BufferedReader(is);\n\n\t\tArrayList list = new ArrayList();\n\n\t\tfor (int i = 0; i < 10001; i++) {\n\t\t\tlist.add(br.readLine());\n\t\t\tif (\"0\".equals(list.get(i))) {\n\t\t\t\tfor (int j = 1; j < list.size(); j++) {\n\t\t\t\t\tSystem.out.println(\"Case \"+j+\": \"+list.get(j-1));\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\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": 582, "cpu_time_ms": 240, "memory_kb": 32060}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s690754835", "group_id": "codeNet:p02396", "input_text": "import java.util.Scanner;\nclass Main {\n public static void main(String[] args){\n Scanner scan = new Scanner(System.in);\n int x;\n for(int i = 0; i < 10000; i++){\n x = scan.nextInt();\n if(x == 0) break;\n\n System.out.println(\"Case \" + i + \": \" + x);\n }\n }\n}", "language": "Java", "metadata": {"date": 1491283411, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02396.html", "problem_id": "p02396", "resource_group": "high_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/Java/s690754835.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s690754835", "user_id": "u206778360"}, "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": "import java.util.Scanner;\nclass Main {\n public static void main(String[] args){\n Scanner scan = new Scanner(System.in);\n int x;\n for(int i = 0; i < 10000; i++){\n x = scan.nextInt();\n if(x == 0) break;\n\n System.out.println(\"Case \" + i + \": \" + x);\n }\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": 308, "cpu_time_ms": 370, "memory_kb": 44968}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s071028774", "group_id": "codeNet:p02396", "input_text": "import java.util.Scanner;\n\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int i = 1;\n for(;i<20000;i++){\n int x = sc.nextInt();\n if(x == 0){\n break;\n }\n else{\n System.out.println(\"Case \"+i+\": \"+x);\n }\n \n }\n \n }\n}\n", "language": "Java", "metadata": {"date": 1523853553, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02396.html", "problem_id": "p02396", "resource_group": "high_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/Java/s071028774.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s071028774", "user_id": "u705352026"}, "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": "import java.util.Scanner;\n\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int i = 1;\n for(;i<20000;i++){\n int x = sc.nextInt();\n if(x == 0){\n break;\n }\n else{\n System.out.println(\"Case \"+i+\": \"+x);\n }\n \n }\n \n }\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": 402, "cpu_time_ms": 360, "memory_kb": 45360}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s508159657", "group_id": "codeNet:p02396", "input_text": "\nimport java.util.Scanner;\npublic class Main {\n public static void main(String[] args) {\n int i=1;\n Scanner sc = new Scanner(System.in);\n while(true){\n int x = sc.nextInt();\n if(x==0){\n break;\n }\n System.out.printf(\"Case %d: %d\\n\",i,x);\n i++;\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1523861126, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02396.html", "problem_id": "p02396", "resource_group": "high_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/Java/s508159657.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s508159657", "user_id": "u017089316"}, "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": "\nimport java.util.Scanner;\npublic class Main {\n public static void main(String[] args) {\n int i=1;\n Scanner sc = new Scanner(System.in);\n while(true){\n int x = sc.nextInt();\n if(x==0){\n break;\n }\n System.out.printf(\"Case %d: %d\\n\",i,x);\n i++;\n }\n }\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": 421, "cpu_time_ms": 560, "memory_kb": 62724}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s644122088", "group_id": "codeNet:p02396", "input_text": "import java.util.Scanner;\n\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int i = 1;\n while(true) {\n int n = sc.nextInt();\n \tif(n == 0) {\n \t\tbreak;\n \t}\n \tSystem.out.printf(\"Case %d: %d\\n\", i, n);\n \ti ++;\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1530246827, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02396.html", "problem_id": "p02396", "resource_group": "high_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/Java/s644122088.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s644122088", "user_id": "u292897282"}, "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": "import java.util.Scanner;\n\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int i = 1;\n while(true) {\n int n = sc.nextInt();\n \tif(n == 0) {\n \t\tbreak;\n \t}\n \tSystem.out.printf(\"Case %d: %d\\n\", i, n);\n \ti ++;\n }\n }\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": 347, "cpu_time_ms": 730, "memory_kb": 74316}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s051811163", "group_id": "codeNet:p02397", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\tpublic static void main(String[] args) throws IOException {\n BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\n StringBuilder sb=new StringBuilder();\n for(int i=1;i<=1000;i++){\n \tString items[]=reader.readLine().split(\" \");\n \tsb.append(items[1] + \" \" + items[0]+ \"\\n\");\n \tint num1=Integer.parseInt(items[0]);\n \tint num2=Integer.parseInt(items[1]);\n if(num1==0 && num2==0){\n \tbreak;\n }\n }\n System.out.println(sb);\n\t}\n}", "language": "Java", "metadata": {"date": 1506388408, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02397.html", "problem_id": "p02397", "resource_group": "high_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/Java/s051811163.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s051811163", "user_id": "u339341496"}, "prompt_components": {"gold_output": "2 3\n2 2\n3 5\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\tpublic static void main(String[] args) throws IOException {\n BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\n StringBuilder sb=new StringBuilder();\n for(int i=1;i<=1000;i++){\n \tString items[]=reader.readLine().split(\" \");\n \tsb.append(items[1] + \" \" + items[0]+ \"\\n\");\n \tint num1=Integer.parseInt(items[0]);\n \tint num2=Integer.parseInt(items[1]);\n if(num1==0 && num2==0){\n \tbreak;\n }\n }\n System.out.println(sb);\n\t}\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": 656, "cpu_time_ms": 50, "memory_kb": 26044}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s629751818", "group_id": "codeNet:p02398", "input_text": "\nimport java.util.Scanner;\n\n/**\n *\n * @author k16069kk\n */\npublic class Main {\n\n /**\n * @param args the command line arguments\n */\n public static void main(String[] args) {\n Scanner scan = new Scanner(System.in);\n int a = scan.nextInt();\n int b = scan.nextInt();\n int c = scan.nextInt();\n int count = 0;\n \n for (int i = a; i <= b; i++) {\n if(c%i == 0) count++;\n }\n System.out.println(count);\n }\n \n}\n\n", "language": "Java", "metadata": {"date": 1525940117, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02398.html", "problem_id": "p02398", "resource_group": "high_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/Java/s629751818.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s629751818", "user_id": "u913462354"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "\nimport java.util.Scanner;\n\n/**\n *\n * @author k16069kk\n */\npublic class Main {\n\n /**\n * @param args the command line arguments\n */\n public static void main(String[] args) {\n Scanner scan = new Scanner(System.in);\n int a = scan.nextInt();\n int b = scan.nextInt();\n int c = scan.nextInt();\n int count = 0;\n \n for (int i = a; i <= b; i++) {\n if(c%i == 0) count++;\n }\n System.out.println(count);\n }\n \n}\n\n", "problem_context": "How Many Divisors?\n\nWrite a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.\n\nInput\n\nThree integers a, b and c are given in a line separated by a single space.\n\nOutput\n\nPrint the number of divisors in a line.\n\nConstraints\n\n1 ≤ a, b, c ≤ 10000\n\na ≤ b\n\nSample Input 1\n\n5 14 80\n\nSample Output 1\n\n3", "sample_input": "5 14 80\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02398", "source_text": "How Many Divisors?\n\nWrite a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.\n\nInput\n\nThree integers a, b and c are given in a line separated by a single space.\n\nOutput\n\nPrint the number of divisors in a line.\n\nConstraints\n\n1 ≤ a, b, c ≤ 10000\n\na ≤ b\n\nSample Input 1\n\n5 14 80\n\nSample Output 1\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 60, "memory_kb": 26268}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s944628278", "group_id": "codeNet:p02398", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws Exception {\n \n //入力準備\n Scanner sc = new Scanner(System.in);\n \n int a = sc.nextInt();\n int b = sc.nextInt();\n int c = sc.nextInt();\n int cnt = 0;\n \n //配列にデータを入れる\n for(int i = a; i <= b; i++ ){\n if(c % i == 0){\n cnt++;\n }\n }\n System.out.println(cnt);\n }\n}\n", "language": "Java", "metadata": {"date": 1551069053, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02398.html", "problem_id": "p02398", "resource_group": "high_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/Java/s944628278.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s944628278", "user_id": "u086439150"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws Exception {\n \n //入力準備\n Scanner sc = new Scanner(System.in);\n \n int a = sc.nextInt();\n int b = sc.nextInt();\n int c = sc.nextInt();\n int cnt = 0;\n \n //配列にデータを入れる\n for(int i = a; i <= b; i++ ){\n if(c % i == 0){\n cnt++;\n }\n }\n System.out.println(cnt);\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": 504, "cpu_time_ms": 60, "memory_kb": 26420}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s605616683", "group_id": "codeNet:p02399", "input_text": "import java.util.*;\nclass Main{\n\tScanner sc=new Scanner(System.in);\n\tint a,b;\n\tvoid g(){\n\t\ta=sc.nextInt();\n\t\tb=sc.nextInt();\n\t\t\n\t\tSystem.out.println(a/b);\n\t\tSystem.out.println(a%b);\n\t\tSystem.out.println((float)a/b);\n\t\t\n\t}\n\t\n\tpublic static void main(String[]agrs){\n\t\tnew Main().g();\n\t}\n}", "language": "Java", "metadata": {"date": 1442392485, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02399.html", "problem_id": "p02399", "resource_group": "high_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/Java/s605616683.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s605616683", "user_id": "u371406615"}, "prompt_components": {"gold_output": "1 1 1.50000\n", "input_to_evaluate": "import java.util.*;\nclass Main{\n\tScanner sc=new Scanner(System.in);\n\tint a,b;\n\tvoid g(){\n\t\ta=sc.nextInt();\n\t\tb=sc.nextInt();\n\t\t\n\t\tSystem.out.println(a/b);\n\t\tSystem.out.println(a%b);\n\t\tSystem.out.println((float)a/b);\n\t\t\n\t}\n\t\n\tpublic static void main(String[]agrs){\n\t\tnew Main().g();\n\t}\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": 286, "cpu_time_ms": 50, "memory_kb": 17272}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s767362369", "group_id": "codeNet:p02399", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String str[] = br.readLine().split(\" \");\n int a = Integer.parseInt(str[0]);\n int b = Integer.parseInt(str[1]);\n System.out.printf(\"%d %d %.5f\\n\",a/b,a%b,(double)a/(double)b);\n \n \n }\n}", "language": "Java", "metadata": {"date": 1474364403, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02399.html", "problem_id": "p02399", "resource_group": "high_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/Java/s767362369.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s767362369", "user_id": "u311843791"}, "prompt_components": {"gold_output": "1 1 1.50000\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String str[] = br.readLine().split(\" \");\n int a = Integer.parseInt(str[0]);\n int b = Integer.parseInt(str[1]);\n System.out.printf(\"%d %d %.5f\\n\",a/b,a%b,(double)a/(double)b);\n \n \n }\n}", "problem_context": "A/B Problem\n\nWrite a program which reads two integers a and b, and calculates the following values:\n\na ÷ b: d (in integer)\n\nremainder of a ÷ b: r (in integer)\n\na ÷ b: f (in real number)\n\nInput\n\nTwo integers a and b are given in a line.\n\nOutput\n\nPrint d, r and f separated by a space in a line. For f, the output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n1 ≤ a, b ≤ 109\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n1 1 1.50000", "sample_input": "3 2\n"}, "reference_outputs": ["1 1 1.50000\n"], "source_document_id": "p02399", "source_text": "A/B Problem\n\nWrite a program which reads two integers a and b, and calculates the following values:\n\na ÷ b: d (in integer)\n\nremainder of a ÷ b: r (in integer)\n\na ÷ b: f (in real number)\n\nInput\n\nTwo integers a and b are given in a line.\n\nOutput\n\nPrint d, r and f separated by a space in a line. For f, the output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n1 ≤ a, b ≤ 109\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n1 1 1.50000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 489, "cpu_time_ms": 40, "memory_kb": 24772}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s180917592", "group_id": "codeNet:p02399", "input_text": "import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint a = sc.nextInt();\n\t\tint b = sc.nextInt();\n\t\tint d = a / b;\n\t\tint r = a % b;\n\t\tfloat f = (float)a / (float)b;\n\t\tSystem.out.printf(\"%d %d %05f\", d, r, f);\n\t}\n}", "language": "Java", "metadata": {"date": 1396791046, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02399.html", "problem_id": "p02399", "resource_group": "high_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/Java/s180917592.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s180917592", "user_id": "u338661979"}, "prompt_components": {"gold_output": "1 1 1.50000\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint a = sc.nextInt();\n\t\tint b = sc.nextInt();\n\t\tint d = a / b;\n\t\tint r = a % b;\n\t\tfloat f = (float)a / (float)b;\n\t\tSystem.out.printf(\"%d %d %05f\", d, r, f);\n\t}\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": 284, "cpu_time_ms": 50, "memory_kb": 17344}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s621544255", "group_id": "codeNet:p02401", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString data[] = br.readLine().split(\" \");\n\t\tint a = Integer.parseInt(data[0]);\n\t\tint b = Integer.parseInt(data[2]);\n\n\t\tString s = (data[1]);\n\n\t\tif (s.equals(\"+\")) {\n\t\t\tSystem.out.println(a + b);\n\t\t\t}\n\t\tif (s.equals(\"-\")) {\n\t\t\tSystem.out.println(a - b);\n\t\t\t}\n\n\t\tif (s.equals(\"*\")) {\n\t\t\tSystem.out.println(a * b);\n\t\t\t}\n\t\tif (s.equals(\"/\")) {\n\t\t\tSystem.out.println(a / b);\n\t\t\t}\n\n\t}\n\n}", "language": "Java", "metadata": {"date": 1507609528, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02401.html", "problem_id": "p02401", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02401/input.txt", "sample_output_relpath": "derived/input_output/data/p02401/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02401/Java/s621544255.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s621544255", "user_id": "u091915922"}, "prompt_components": {"gold_output": "3\n38\n26\n10\n108\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString data[] = br.readLine().split(\" \");\n\t\tint a = Integer.parseInt(data[0]);\n\t\tint b = Integer.parseInt(data[2]);\n\n\t\tString s = (data[1]);\n\n\t\tif (s.equals(\"+\")) {\n\t\t\tSystem.out.println(a + b);\n\t\t\t}\n\t\tif (s.equals(\"-\")) {\n\t\t\tSystem.out.println(a - b);\n\t\t\t}\n\n\t\tif (s.equals(\"*\")) {\n\t\t\tSystem.out.println(a * b);\n\t\t\t}\n\t\tif (s.equals(\"/\")) {\n\t\t\tSystem.out.println(a / b);\n\t\t\t}\n\n\t}\n\n}", "problem_context": "Simple Calculator\n\nWrite a program which reads two integers a, b and an operator op, and then prints the value of a op b.\n\nThe operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.\n\nInput\n\nThe input consists of multiple datasets. Each dataset is given in the following format.\n\na op b\n\nThe input ends with a dataset where op = '?'. Your program should not process for this dataset.\n\nOutput\n\nFor each dataset, print the value in a line.\n\nConstraints\n\n0 ≤ a, b ≤ 20000\n\nNo divisions by zero are given.\n\nSample Input 1\n\n1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 81\n0 ? 0\n\nSample Output 1\n\n3\n38\n26\n10\n108", "sample_input": "1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 81\n0 ? 0\n"}, "reference_outputs": ["3\n38\n26\n10\n108\n"], "source_document_id": "p02401", "source_text": "Simple Calculator\n\nWrite a program which reads two integers a, b and an operator op, and then prints the value of a op b.\n\nThe operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.\n\nInput\n\nThe input consists of multiple datasets. Each dataset is given in the following format.\n\na op b\n\nThe input ends with a dataset where op = '?'. Your program should not process for this dataset.\n\nOutput\n\nFor each dataset, print the value in a line.\n\nConstraints\n\n0 ≤ a, b ≤ 20000\n\nNo divisions by zero are given.\n\nSample Input 1\n\n1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 81\n0 ? 0\n\nSample Output 1\n\n3\n38\n26\n10\n108", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 636, "cpu_time_ms": 50, "memory_kb": 24104}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s704015652", "group_id": "codeNet:p02402", "input_text": "import java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Scanner;\n\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tlong total = 0;\n\t\tArrayList list = new ArrayList();\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tlist.add(sc.nextInt());\n\t\t}\n\t\t//????????§???????????????\n\t\tCollections.sort(list);\n\t\tfor (int i = 0; i < list.size(); i++) {\n\t\t\ttotal += list.get(i);\n\t\t}\n\t\t//????°????????????§??????????¨???????????????????\n\t\tSystem.out.println(list.get(0) +\" \"+ list.get(list.size()-1) +\" \"+ total);\n\t}\n}", "language": "Java", "metadata": {"date": 1440140606, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02402.html", "problem_id": "p02402", "resource_group": "high_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/Java/s704015652.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s704015652", "user_id": "u294917737"}, "prompt_components": {"gold_output": "1 17 37\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Scanner;\n\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tlong total = 0;\n\t\tArrayList list = new ArrayList();\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tlist.add(sc.nextInt());\n\t\t}\n\t\t//????????§???????????????\n\t\tCollections.sort(list);\n\t\tfor (int i = 0; i < list.size(); i++) {\n\t\t\ttotal += list.get(i);\n\t\t}\n\t\t//????°????????????§??????????¨???????????????????\n\t\tSystem.out.println(list.get(0) +\" \"+ list.get(list.size()-1) +\" \"+ total);\n\t}\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": 613, "cpu_time_ms": 280, "memory_kb": 39820}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s059531333", "group_id": "codeNet:p02402", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint M=1000000,m=-1000000;\n\t\tlong S = 0;\n\n\t\tfor(int i = 1;i <= n;i++){\n\t\t\tint x = sc.nextInt();\n\t\t\tM = Math.max(M, x);\n\t\t\tm = Math.min(m, x);\n\t\t\tS = S+x;\n\t\t}\n\t\tSystem.out.print(m+\" \"+M+\" \"+S);\n\t}\n}", "language": "Java", "metadata": {"date": 1452963457, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02402.html", "problem_id": "p02402", "resource_group": "high_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/Java/s059531333.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s059531333", "user_id": "u918457647"}, "prompt_components": {"gold_output": "1 17 37\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint M=1000000,m=-1000000;\n\t\tlong S = 0;\n\n\t\tfor(int i = 1;i <= n;i++){\n\t\t\tint x = sc.nextInt();\n\t\t\tM = Math.max(M, x);\n\t\t\tm = Math.min(m, x);\n\t\t\tS = S+x;\n\t\t}\n\t\tSystem.out.print(m+\" \"+M+\" \"+S);\n\t}\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": 349, "cpu_time_ms": 80, "memory_kb": 25996}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s229431522", "group_id": "codeNet:p02402", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tStringBuilder sb = new StringBuilder();\n\n\t\tint count = Integer.parseInt(br.readLine());\n String[] strArray = new String[count];\n strArray = br.readLine().split(\" \");\n\n int max=-1000000, min=1000000, sum=0;\n int a = 0;\n\n for(String str : strArray) {\n \ta = Integer.parseInt(str);\n \tmax = Math.max(max, a);\n \tmin = Math.min(min, a);\n \tsum += a;\n }\n\n System.out.print(min + \" \" + max + \" \" + sum);\n\t}\n}", "language": "Java", "metadata": {"date": 1514588720, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02402.html", "problem_id": "p02402", "resource_group": "high_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/Java/s229431522.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s229431522", "user_id": "u012343371"}, "prompt_components": {"gold_output": "1 17 37\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tStringBuilder sb = new StringBuilder();\n\n\t\tint count = Integer.parseInt(br.readLine());\n String[] strArray = new String[count];\n strArray = br.readLine().split(\" \");\n\n int max=-1000000, min=1000000, sum=0;\n int a = 0;\n\n for(String str : strArray) {\n \ta = Integer.parseInt(str);\n \tmax = Math.max(max, a);\n \tmin = Math.min(min, a);\n \tsum += a;\n }\n\n System.out.print(min + \" \" + max + \" \" + sum);\n\t}\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": 730, "cpu_time_ms": 50, "memory_kb": 24208}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s672525300", "group_id": "codeNet:p02403", "input_text": "import java.util.Scanner;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc=new Scanner(System.in);\n\t\twhile(true){\n\t\t\tint H=sc.nextInt();\n\t\t\tint W=sc.nextInt();\n\t\t\t\n\t\t\tif(H==0&&W==0) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\t\n\t\t\tfor(int i=0; i 0 && w > 0){\n\t\t\th = a.nextInt();\n\t\t\tw = a.nextInt();\n\t\t\tfor(int i = 0;i < h;i++){\n\t\t\t\tfor(int j = 0;j < w;j++){\n\t\t\t\t\tif((i % 2) == 0){\n\t\t\t\t\t\tSystem.out.print(\"#\");\n\t\t\t\t\t\tSystem.out.print(\".\");\n\t\t\t\t\t}else{\n\t\t\t\t\t\tSystem.out.print(\".\");\n\t\t\t\t\t\tSystem.out.print(\"#\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(h != 0 && w != 0)\n\t\t\t\t\tSystem.out.println();\n\t\t\t}\n\t\t\tif(h != 0 && w != 0)\n\t\t\t\tSystem.out.println();\n\t\t}\n\t}\n\n}", "language": "Java", "metadata": {"date": 1432523028, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02405.html", "problem_id": "p02405", "resource_group": "high_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/Java/s600829754.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s600829754", "user_id": "u267351132"}, "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": "\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner a = new Scanner(System.in);\n\t\tint h =1;\n\t\tint w = 1;\n\t\t\n\t\twhile(h > 0 && w > 0){\n\t\t\th = a.nextInt();\n\t\t\tw = a.nextInt();\n\t\t\tfor(int i = 0;i < h;i++){\n\t\t\t\tfor(int j = 0;j < w;j++){\n\t\t\t\t\tif((i % 2) == 0){\n\t\t\t\t\t\tSystem.out.print(\"#\");\n\t\t\t\t\t\tSystem.out.print(\".\");\n\t\t\t\t\t}else{\n\t\t\t\t\t\tSystem.out.print(\".\");\n\t\t\t\t\t\tSystem.out.print(\"#\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(h != 0 && w != 0)\n\t\t\t\t\tSystem.out.println();\n\t\t\t}\n\t\t\tif(h != 0 && w != 0)\n\t\t\t\tSystem.out.println();\n\t\t}\n\t}\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": 559, "cpu_time_ms": 50, "memory_kb": 17304}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s480586423", "group_id": "codeNet:p02405", "input_text": "\n\nimport java.util.*;\n\npublic class Main {\n\tpublic static void main(String args[]) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tStringBuilder sb = new StringBuilder();\n\t\t//sb.append(\"\");// ??????????????\\???????????????\n\t\tint h, w, c;\n\t\tc = 0;// ?????¶??§???????????°\n\n\t\twhile (true) {\n\t\t\th = scan.nextInt();// ????????????\n\t\t\tw = scan.nextInt();// ?¨??????????\n\t\t\t// h??¨w?????¨??????0????????£?????¨??????????????????????????????\n\t\t\tif ((h == 0) & (w == 0)) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// for?????§????????????h??§????????????\n\t\t\tfor (int count = 0; count < h; count++) {\n\t\t\t\t// for?????§?¨???????????????§????????????\n\t\t\t\tfor (int count2 = 0; count2 < w; count2++) {\n\t\t\t\t\t// #???StringBuilder?????\\????????????\n\t\t\t\t\tif (c % 2 == 0) {// C????????????0?????¨?????¨????????´?????§???????????????\n\t\t\t\t\t\tsb.append(\"#\");\n\t\t\t\t\t\tc++;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsb.append(\".\");\n\t\t\t\t\t\tc++;\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t\t\tsb.append(\"\\n\");\n\t\t\t\t\tc++;\n\n\t\t\t}\n\t\t\tSystem.out.printf(new String(sb));\n\t\t\t// StringBuilder????????????????????????\n\t\t\tsb.delete(0, sb.length());\n\t\t\tc = 0;// ?????¶??§???????????°????????????\n\t\t}\n\n\t}\n}", "language": "Java", "metadata": {"date": 1444010057, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02405.html", "problem_id": "p02405", "resource_group": "high_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/Java/s480586423.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s480586423", "user_id": "u623975125"}, "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": "\n\nimport java.util.*;\n\npublic class Main {\n\tpublic static void main(String args[]) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tStringBuilder sb = new StringBuilder();\n\t\t//sb.append(\"\");// ??????????????\\???????????????\n\t\tint h, w, c;\n\t\tc = 0;// ?????¶??§???????????°\n\n\t\twhile (true) {\n\t\t\th = scan.nextInt();// ????????????\n\t\t\tw = scan.nextInt();// ?¨??????????\n\t\t\t// h??¨w?????¨??????0????????£?????¨??????????????????????????????\n\t\t\tif ((h == 0) & (w == 0)) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// for?????§????????????h??§????????????\n\t\t\tfor (int count = 0; count < h; count++) {\n\t\t\t\t// for?????§?¨???????????????§????????????\n\t\t\t\tfor (int count2 = 0; count2 < w; count2++) {\n\t\t\t\t\t// #???StringBuilder?????\\????????????\n\t\t\t\t\tif (c % 2 == 0) {// C????????????0?????¨?????¨????????´?????§???????????????\n\t\t\t\t\t\tsb.append(\"#\");\n\t\t\t\t\t\tc++;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsb.append(\".\");\n\t\t\t\t\t\tc++;\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t\t\tsb.append(\"\\n\");\n\t\t\t\t\tc++;\n\n\t\t\t}\n\t\t\tSystem.out.printf(new String(sb));\n\t\t\t// StringBuilder????????????????????????\n\t\t\tsb.delete(0, sb.length());\n\t\t\tc = 0;// ?????¶??§???????????°????????????\n\t\t}\n\n\t}\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": 1109, "cpu_time_ms": 60, "memory_kb": 26308}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s279071757", "group_id": "codeNet:p02405", "input_text": "import java.io.*;\n\npublic class Main {\n\n public static void main(String args[]) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));\n String input;\n while (!(input = br.readLine()).equals(\"0 0\")) {\n String[] st = input.split(\" \");\n int a = Integer.parseInt(st[0]);\n int b = Integer.parseInt(st[1]);\n for (int i = 0; i < a; i++) {\n if (i % 2 == 0) {\n for (int j = 0; j < b; j++) {\n bw.append(j % 2 == 0 ? \"#\" : \".\");\n }\n } else {\n for (int j = 0; j < b; j++) {\n bw.append(j % 2 == 0 ? \".\" : \"#\");\n }\n }\n bw.newLine();\n }\n bw.newLine();\n }\n bw.flush();\n }\n\n\n}\n\n", "language": "Java", "metadata": {"date": 1520506866, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02405.html", "problem_id": "p02405", "resource_group": "high_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/Java/s279071757.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s279071757", "user_id": "u355560727"}, "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 java.io.*;\n\npublic class Main {\n\n public static void main(String args[]) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));\n String input;\n while (!(input = br.readLine()).equals(\"0 0\")) {\n String[] st = input.split(\" \");\n int a = Integer.parseInt(st[0]);\n int b = Integer.parseInt(st[1]);\n for (int i = 0; i < a; i++) {\n if (i % 2 == 0) {\n for (int j = 0; j < b; j++) {\n bw.append(j % 2 == 0 ? \"#\" : \".\");\n }\n } else {\n for (int j = 0; j < b; j++) {\n bw.append(j % 2 == 0 ? \".\" : \"#\");\n }\n }\n bw.newLine();\n }\n bw.newLine();\n }\n bw.flush();\n }\n\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": 975, "cpu_time_ms": 70, "memory_kb": 26204}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s721644059", "group_id": "codeNet:p02406", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\tif (i % 3 == 0 || i % 10 == 3 || i % 10 == 0) {\n\t\t\t\tint[] data = { i };\n\t\t\t\tfor (int data1 : data) {\n\t\t\t\t\tSystem.out.print(\" \" + data1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(\"\");\n\t}\n}\n", "language": "Java", "metadata": {"date": 1541053757, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02406.html", "problem_id": "p02406", "resource_group": "high_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/Java/s721644059.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s721644059", "user_id": "u189727512"}, "prompt_components": {"gold_output": " 3 6 9 12 13 15 18 21 23 24 27 30\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\tif (i % 3 == 0 || i % 10 == 3 || i % 10 == 0) {\n\t\t\t\tint[] data = { i };\n\t\t\t\tfor (int data1 : data) {\n\t\t\t\t\tSystem.out.print(\" \" + data1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(\"\");\n\t}\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": 371, "cpu_time_ms": 50, "memory_kb": 25856}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s644776382", "group_id": "codeNet:p02406", "input_text": "import java.util.Scanner;\n\npublic class Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tlong n = sc.nextInt();\n\t\t\n\t\t\n\t\tfor(long i = 1;i <= n;i++){\n\t\t\tlong x = i;\n\t\t\tif(x % 3 == 0 || x % 10 == 3){\n\t\t\t\tSystem.out.print(\" \"+i);\n\t\t\t\tcontinue;\n\t\t\t}else{\n\t\t\t\tfor(x /= 10;x != 0;x /= 10){\n\t\t\t\t\tif(x % 10 == 3)\n\t\t\t\t\t\tSystem.out.print(\" \"+i);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.print(\"\\n\");\n\t\t\n\t\tsc.close();\n\t}\n}", "language": "Java", "metadata": {"date": 1425914952, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02406.html", "problem_id": "p02406", "resource_group": "high_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/Java/s644776382.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s644776382", "user_id": "u645367856"}, "prompt_components": {"gold_output": " 3 6 9 12 13 15 18 21 23 24 27 30\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tlong n = sc.nextInt();\n\t\t\n\t\t\n\t\tfor(long i = 1;i <= n;i++){\n\t\t\tlong x = i;\n\t\t\tif(x % 3 == 0 || x % 10 == 3){\n\t\t\t\tSystem.out.print(\" \"+i);\n\t\t\t\tcontinue;\n\t\t\t}else{\n\t\t\t\tfor(x /= 10;x != 0;x /= 10){\n\t\t\t\t\tif(x % 10 == 3)\n\t\t\t\t\t\tSystem.out.print(\" \"+i);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.print(\"\\n\");\n\t\t\n\t\tsc.close();\n\t}\n}", "problem_context": "Structured Programming\n\nIn programming languages like C/C++, a goto statement provides an unconditional jump from the \"goto\" to a labeled statement. For example, a statement \"goto CHECK_NUM;\" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.\n\nNote that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.\n\nWrite a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.\n\nvoid call(int n){\nint i = 1;\nCHECK_NUM:\nint x = i;\nif ( x % 3 == 0 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nINCLUDE3:\nif ( x % 10 == 3 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nx /= 10;\nif ( x ) goto INCLUDE3;\nEND_CHECK_NUM:\nif ( ++i <= n ) goto CHECK_NUM;\n\ncout << endl;\n}\n\nInput\n\nAn integer n is given in a line.\n\nOutput\n\nPrint the output result of the above program for given integer n.\n\nConstraints\n\n3 ≤ n ≤ 10000\n\nSample Input\n\n30\n\nSample Output\n\n3 6 9 12 13 15 18 21 23 24 27 30\n\nPut a single space character before each element.", "sample_input": "30\n"}, "reference_outputs": [" 3 6 9 12 13 15 18 21 23 24 27 30\n"], "source_document_id": "p02406", "source_text": "Structured Programming\n\nIn programming languages like C/C++, a goto statement provides an unconditional jump from the \"goto\" to a labeled statement. For example, a statement \"goto CHECK_NUM;\" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.\n\nNote that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.\n\nWrite a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.\n\nvoid call(int n){\nint i = 1;\nCHECK_NUM:\nint x = i;\nif ( x % 3 == 0 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nINCLUDE3:\nif ( x % 10 == 3 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nx /= 10;\nif ( x ) goto INCLUDE3;\nEND_CHECK_NUM:\nif ( ++i <= n ) goto CHECK_NUM;\n\ncout << endl;\n}\n\nInput\n\nAn integer n is given in a line.\n\nOutput\n\nPrint the output result of the above program for given integer n.\n\nConstraints\n\n3 ≤ n ≤ 10000\n\nSample Input\n\n30\n\nSample Output\n\n3 6 9 12 13 15 18 21 23 24 27 30\n\nPut a single space character before each element.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 452, "cpu_time_ms": 50, "memory_kb": 17320}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s526026769", "group_id": "codeNet:p02406", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString line = sc.nextLine();\n\t\tint n = Integer.parseInt(line);\n\t\tint i = 1;\n\t\twhile (i <= n) {\n\t\t\tif (i % 3 == 0) {\n\t\t\t\tSystem.out.print(\" \" + i);\n\t\t\t} else if (i % 10 == 3) {\n\t\t\t\tSystem.out.print(\" \" + i);\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1492660961, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02406.html", "problem_id": "p02406", "resource_group": "high_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/Java/s526026769.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s526026769", "user_id": "u979459657"}, "prompt_components": {"gold_output": " 3 6 9 12 13 15 18 21 23 24 27 30\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString line = sc.nextLine();\n\t\tint n = Integer.parseInt(line);\n\t\tint i = 1;\n\t\twhile (i <= n) {\n\t\t\tif (i % 3 == 0) {\n\t\t\t\tSystem.out.print(\" \" + i);\n\t\t\t} else if (i % 10 == 3) {\n\t\t\t\tSystem.out.print(\" \" + i);\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t}\n}", "problem_context": "Structured Programming\n\nIn programming languages like C/C++, a goto statement provides an unconditional jump from the \"goto\" to a labeled statement. For example, a statement \"goto CHECK_NUM;\" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.\n\nNote that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.\n\nWrite a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.\n\nvoid call(int n){\nint i = 1;\nCHECK_NUM:\nint x = i;\nif ( x % 3 == 0 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nINCLUDE3:\nif ( x % 10 == 3 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nx /= 10;\nif ( x ) goto INCLUDE3;\nEND_CHECK_NUM:\nif ( ++i <= n ) goto CHECK_NUM;\n\ncout << endl;\n}\n\nInput\n\nAn integer n is given in a line.\n\nOutput\n\nPrint the output result of the above program for given integer n.\n\nConstraints\n\n3 ≤ n ≤ 10000\n\nSample Input\n\n30\n\nSample Output\n\n3 6 9 12 13 15 18 21 23 24 27 30\n\nPut a single space character before each element.", "sample_input": "30\n"}, "reference_outputs": [" 3 6 9 12 13 15 18 21 23 24 27 30\n"], "source_document_id": "p02406", "source_text": "Structured Programming\n\nIn programming languages like C/C++, a goto statement provides an unconditional jump from the \"goto\" to a labeled statement. For example, a statement \"goto CHECK_NUM;\" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.\n\nNote that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.\n\nWrite a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.\n\nvoid call(int n){\nint i = 1;\nCHECK_NUM:\nint x = i;\nif ( x % 3 == 0 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nINCLUDE3:\nif ( x % 10 == 3 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nx /= 10;\nif ( x ) goto INCLUDE3;\nEND_CHECK_NUM:\nif ( ++i <= n ) goto CHECK_NUM;\n\ncout << endl;\n}\n\nInput\n\nAn integer n is given in a line.\n\nOutput\n\nPrint the output result of the above program for given integer n.\n\nConstraints\n\n3 ≤ n ≤ 10000\n\nSample Input\n\n30\n\nSample Output\n\n3 6 9 12 13 15 18 21 23 24 27 30\n\nPut a single space character before each element.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 358, "cpu_time_ms": 50, "memory_kb": 26000}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s235338436", "group_id": "codeNet:p02406", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n\tpublic static final int BIG_NUM = 2000000000;\n\tpublic static final int MOD = 1000000007;\n\n\tpublic static void main(String[] args) {\n\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\ttry {\n\t\t\tint N = Integer.parseInt(br.readLine());\n\n\t\t\tint x;\n\n\t\t\tfor(int i = 1; i <= N; i++)\n\t\t\t{\n\t\t\t\tif(i%3 == 0){\n\t\t\t\t\tSystem.out.printf(\" %d\",i);\n\t\t\t\t}else{\n\t\t\t\t\tx = i;\n\t\t\t\t\tdo{\n\t\t\t\t\t\tif(x%10 == 3){\n\t\t\t\t\t\t\tSystem.out.printf(\" %d\",i);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tx /=10;\n\t\t\t\t\t}while(x != 0);\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.printf(\"\\n\");\n\n\t\t} catch (NumberFormatException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n}\n\n\n\n", "language": "Java", "metadata": {"date": 1581637659, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02406.html", "problem_id": "p02406", "resource_group": "high_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/Java/s235338436.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s235338436", "user_id": "u203383696"}, "prompt_components": {"gold_output": " 3 6 9 12 13 15 18 21 23 24 27 30\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n\tpublic static final int BIG_NUM = 2000000000;\n\tpublic static final int MOD = 1000000007;\n\n\tpublic static void main(String[] args) {\n\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\ttry {\n\t\t\tint N = Integer.parseInt(br.readLine());\n\n\t\t\tint x;\n\n\t\t\tfor(int i = 1; i <= N; i++)\n\t\t\t{\n\t\t\t\tif(i%3 == 0){\n\t\t\t\t\tSystem.out.printf(\" %d\",i);\n\t\t\t\t}else{\n\t\t\t\t\tx = i;\n\t\t\t\t\tdo{\n\t\t\t\t\t\tif(x%10 == 3){\n\t\t\t\t\t\t\tSystem.out.printf(\" %d\",i);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tx /=10;\n\t\t\t\t\t}while(x != 0);\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.printf(\"\\n\");\n\n\t\t} catch (NumberFormatException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n}\n\n\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": 790, "cpu_time_ms": 230, "memory_kb": 38040}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s736724305", "group_id": "codeNet:p02407", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scan = new Scanner(System.in);\n int n = scan.nextInt();\n ArrayList ls = new ArrayList<>();\n\n for (int i = 0; i < n; i++) ls.add(scan.nextInt());\n\n Collections.reverse(ls);\n for (int i = 0; i < ls.size(); i++) {\n System.out.print(i == ls.size() -1? ls.get(i) : ls.get(i) + \" \");\n }\n System.out.println();\n }\n}", "language": "Java", "metadata": {"date": 1460530783, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02407.html", "problem_id": "p02407", "resource_group": "high_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/Java/s736724305.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s736724305", "user_id": "u636711749"}, "prompt_components": {"gold_output": "5 4 3 2 1\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scan = new Scanner(System.in);\n int n = scan.nextInt();\n ArrayList ls = new ArrayList<>();\n\n for (int i = 0; i < n; i++) ls.add(scan.nextInt());\n\n Collections.reverse(ls);\n for (int i = 0; i < ls.size(); i++) {\n System.out.print(i == ls.size() -1? ls.get(i) : ls.get(i) + \" \");\n }\n System.out.println();\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": 482, "cpu_time_ms": 60, "memory_kb": 26176}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s431297066", "group_id": "codeNet:p02407", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tint n = Integer.parseInt(s.nextLine());\n\t\tboolean flag=true;\n\t\tint[] seq = new int[n];\n\t\tif(n<=100) {\n\t\t\n\t\tfor(int i=0;i=0 && seq[i]<1000) {\n\t\t\t\tcontinue;\n\t\t\t}else {\n\t\t\t\tflag=false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t}\n\t\t\n\t\tif(flag==true) {\n\t\t\tfor(int j=n;j>0;j--) {\n\t\t\t\tSystem.out.print(seq[j-1]);\n\t\t\t\tif(j!=1)\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\n}", "language": "Java", "metadata": {"date": 1509347466, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02407.html", "problem_id": "p02407", "resource_group": "high_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/Java/s431297066.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s431297066", "user_id": "u729909349"}, "prompt_components": {"gold_output": "5 4 3 2 1\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tint n = Integer.parseInt(s.nextLine());\n\t\tboolean flag=true;\n\t\tint[] seq = new int[n];\n\t\tif(n<=100) {\n\t\t\n\t\tfor(int i=0;i=0 && seq[i]<1000) {\n\t\t\t\tcontinue;\n\t\t\t}else {\n\t\t\t\tflag=false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t}\n\t\t\n\t\tif(flag==true) {\n\t\t\tfor(int j=n;j>0;j--) {\n\t\t\t\tSystem.out.print(seq[j-1]);\n\t\t\t\tif(j!=1)\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\t\n\t}\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": 519, "cpu_time_ms": 60, "memory_kb": 25664}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s937892719", "group_id": "codeNet:p02407", "input_text": "import java.util.Scanner;\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int a[] = new int[n];\n int b[] = new int[n];\n int c;\n for(int i = 0; i < n; i++){\n \tc = sc.nextInt();\n \ta[i] = c;\n \tb[i] = c;\n }\n for(int i = 0; i < n; i++){\n \ta[i] = b[n - i - 1];\n \tSystem.out.print(a[i] + \" \");\n }\n System.out.println();\n }\n}\n", "language": "Java", "metadata": {"date": 1517200324, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02407.html", "problem_id": "p02407", "resource_group": "high_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/Java/s937892719.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s937892719", "user_id": "u200189227"}, "prompt_components": {"gold_output": "5 4 3 2 1\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int a[] = new int[n];\n int b[] = new int[n];\n int c;\n for(int i = 0; i < n; i++){\n \tc = sc.nextInt();\n \ta[i] = c;\n \tb[i] = c;\n }\n for(int i = 0; i < n; i++){\n \ta[i] = b[n - i - 1];\n \tSystem.out.print(a[i] + \" \");\n }\n System.out.println();\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": 507, "cpu_time_ms": 50, "memory_kb": 26144}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s452975415", "group_id": "codeNet:p02407", "input_text": "import java.util.Scanner;\n\nclass Main{\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n sc.nextLine();\n String str[] = sc.nextLine().split(\" \");\n for(int i=n-1;i>=0;i--){\n if(i==0){\n System.out.print(str[i]);\n }else{\n System.out.print(str[i]+\" \");\n }\n }\n System.out.println();\n }\n}\n", "language": "Java", "metadata": {"date": 1582699403, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02407.html", "problem_id": "p02407", "resource_group": "high_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/Java/s452975415.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s452975415", "user_id": "u080282480"}, "prompt_components": {"gold_output": "5 4 3 2 1\n", "input_to_evaluate": "import java.util.Scanner;\n\nclass Main{\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n sc.nextLine();\n String str[] = sc.nextLine().split(\" \");\n for(int i=n-1;i>=0;i--){\n if(i==0){\n System.out.print(str[i]);\n }else{\n System.out.print(str[i]+\" \");\n }\n }\n System.out.println();\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": 454, "cpu_time_ms": 80, "memory_kb": 26404}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s552397172", "group_id": "codeNet:p02408", "input_text": "\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n=sc.nextInt();\n\t\tint[][] array=new int[4][13];\n\t\tfor(int i=1; i<=n; i++){\n\t\t\tString s=sc.next();\n\t\t\tint a=sc.nextInt();\n\t\t\tif(s.equals(\"S\")){\n\t\t\t\tarray[0][a-1]=1;\n\t\t\t}else if(s.equals(\"H\")){\n\t\t\t\tarray[1][a-1]=1;\n\t\t\t}else if(s.equals(\"C\")){\n\t\t\t\tarray[2][a-1]=1;\n\t\t\t}else if(s.equals(\"D\")){\n\t\t\t\tarray[3][a-1]=1;\n\t\t\t}\n\t\t}\n\t\tfor(int i=0; i suits;\n\n public void add(Card card) {\n suits.get(card.getSuitSymbol()).add(card.getRank());\n }\n\n private boolean isMissing(String suitSymbol, int rank) {\n return suits.get(suitSymbol).isMissing(rank);\n }\n\n private String getMissingCardListAsString() {\n List missingCardList = new ArrayList<>();\n String[] suitSymbol = {\"S\", \"H\", \"C\", \"D\"};\n\n for(int i = 0; i < 4; i++) {\n for (int j = 1; j <= 13; j++) {\n if (isMissing(suitSymbol[i], j)) {\n missingCardList.add(suitSymbol[i] + \" \" + j);\n }\n }\n }\n if(missingCardList.size() > 0) {\n return missingCardList.stream().collect(Collectors.joining(String.format(\"%n\"),\"\", String.format(\"%n\")));\n } else {\n return \"\";\n }\n }\n\n @Override\n public String toString() {\n return getMissingCardListAsString();\n }\n\n public Deck(){\n super();\n suits = new HashMap<>();\n suits.put(\"S\", new Suit());\n suits.put(\"C\", new Suit());\n suits.put(\"H\", new Suit());\n suits.put(\"D\", new Suit());\n }\n}\n\nclass Suit {\n private final boolean[] cards;\n\n public void add(int rank) {\n cards[rank - 1] = true;\n }\n\n public boolean isMissing(int rank) {\n return !cards[rank - 1];\n }\n\n public Suit() {\n super();\n cards = new boolean[13];\n }\n}\n\nclass Card {\n private final String suitSymbol;\n private final int rank;\n\n public String getSuitSymbol() {\n return suitSymbol;\n }\n\n public int getRank() {\n return rank;\n }\n\n private Card(String suitSymbol, int rank) {\n super();\n this.suitSymbol = suitSymbol;\n this.rank = rank;\n }\n\n public Card(String lineString) {\n this(lineString.split(\" \")[0], lineString.split(\" \")[1]);\n }\n\n private Card(String suitSymbol, String rank) {\n this(suitSymbol, Integer.parseInt(rank));\n }\n}\n", "language": "Java", "metadata": {"date": 1592232990, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02408.html", "problem_id": "p02408", "resource_group": "high_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/Java/s738048072.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s738048072", "user_id": "u285298145"}, "prompt_components": {"gold_output": "S 1\nH 3\nH 7\nC 12\nD 8\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.stream.Collectors;\n\npublic class Main {\n\n public static void main(String[] args) throws IOException {\n Deck deck = new Deck();\n\n try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n br.readLine();//1行目は捨てる;\n br.lines().map(Card::new).forEach(deck::add);//行ごとにカード生成してデッキに追加\n }\n\n System.out.print(deck);\n }\n}\n\nclass Deck {\n private final Map suits;\n\n public void add(Card card) {\n suits.get(card.getSuitSymbol()).add(card.getRank());\n }\n\n private boolean isMissing(String suitSymbol, int rank) {\n return suits.get(suitSymbol).isMissing(rank);\n }\n\n private String getMissingCardListAsString() {\n List missingCardList = new ArrayList<>();\n String[] suitSymbol = {\"S\", \"H\", \"C\", \"D\"};\n\n for(int i = 0; i < 4; i++) {\n for (int j = 1; j <= 13; j++) {\n if (isMissing(suitSymbol[i], j)) {\n missingCardList.add(suitSymbol[i] + \" \" + j);\n }\n }\n }\n if(missingCardList.size() > 0) {\n return missingCardList.stream().collect(Collectors.joining(String.format(\"%n\"),\"\", String.format(\"%n\")));\n } else {\n return \"\";\n }\n }\n\n @Override\n public String toString() {\n return getMissingCardListAsString();\n }\n\n public Deck(){\n super();\n suits = new HashMap<>();\n suits.put(\"S\", new Suit());\n suits.put(\"C\", new Suit());\n suits.put(\"H\", new Suit());\n suits.put(\"D\", new Suit());\n }\n}\n\nclass Suit {\n private final boolean[] cards;\n\n public void add(int rank) {\n cards[rank - 1] = true;\n }\n\n public boolean isMissing(int rank) {\n return !cards[rank - 1];\n }\n\n public Suit() {\n super();\n cards = new boolean[13];\n }\n}\n\nclass Card {\n private final String suitSymbol;\n private final int rank;\n\n public String getSuitSymbol() {\n return suitSymbol;\n }\n\n public int getRank() {\n return rank;\n }\n\n private Card(String suitSymbol, int rank) {\n super();\n this.suitSymbol = suitSymbol;\n this.rank = rank;\n }\n\n public Card(String lineString) {\n this(lineString.split(\" \")[0], lineString.split(\" \")[1]);\n }\n\n private Card(String suitSymbol, String rank) {\n this(suitSymbol, Integer.parseInt(rank));\n }\n}\n", "problem_context": "Finding Missing Cards\n\nTaro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).\n\nThe 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.\n\nInput\n\nIn the first line, the number of cards n (n ≤ 52) is given.\n\nIn the following n lines, data of the n cards are given. Each card is given by a pair of a character and an integer which represent its suit and rank respectively. A suit is represented by 'S', 'H', 'C' and 'D' for spades, hearts, clubs and diamonds respectively. A rank is represented by an integer from 1 to 13.\n\nOutput\n\nPrint the missing cards. The same as the input format, each card should be printed with a character and an integer separated by a space character in a line.\nArrange the missing cards in the following priorities:\n\nPrint cards of spades, hearts, clubs and diamonds in this order.\n\nIf the suits are equal, print cards with lower ranks first.\n\nSample Input\n\n47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n\nSample Output\n\nS 1\nH 3\nH 7\nC 12\nD 8\n\nNote\n\n      解説", "sample_input": "47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n"}, "reference_outputs": ["S 1\nH 3\nH 7\nC 12\nD 8\n"], "source_document_id": "p02408", "source_text": "Finding Missing Cards\n\nTaro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).\n\nThe 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.\n\nInput\n\nIn the first line, the number of cards n (n ≤ 52) is given.\n\nIn the following n lines, data of the n cards are given. Each card is given by a pair of a character and an integer which represent its suit and rank respectively. A suit is represented by 'S', 'H', 'C' and 'D' for spades, hearts, clubs and diamonds respectively. A rank is represented by an integer from 1 to 13.\n\nOutput\n\nPrint the missing cards. The same as the input format, each card should be printed with a character and an integer separated by a space character in a line.\nArrange the missing cards in the following priorities:\n\nPrint cards of spades, hearts, clubs and diamonds in this order.\n\nIf the suits are equal, print cards with lower ranks first.\n\nSample Input\n\n47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n\nSample Output\n\nS 1\nH 3\nH 7\nC 12\nD 8\n\nNote\n\n      解説", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2703, "cpu_time_ms": 160, "memory_kb": 31532}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s948418511", "group_id": "codeNet:p02408", "input_text": "import java.util.Scanner;\n\n\npublic class Main { \n public static void main(String[] args) {\n int n; \n String a;\n int i;\n int j;\n \n Scanner sc = new Scanner(System.in);\n n = sc.nextInt();\n String [] [] c = new String [4] [13];\n \n while(n!=0){\n n--;\n switch(a = sc.next().toUpperCase()){\n case \"S\":\n i = 0;\n j = sc.nextInt();\n c [i] [j-1] = a+\" \"+j;\n break;\n case \"H\":\n i = 1;\n j = sc.nextInt();\n c [i] [j-1] = a+ \" \" + j;\n break;\n case \"C\":\n i = 2;\n j = sc.nextInt();\n c [i] [j-1] = a+ \" \" + j;\n break; \n case \"D\":\n i = 3;\n j = sc.nextInt();\n c [i] [j-1] = a+ \" \" + j;\n break; \n }\n }\n for ( i = 0; i <4; i++){\n for (j = 0; j<13; j++){\n int k = j+1;\n if( c[i][j]== null){\n switch(i){\n case 0:\n System.out.println(\"S \"+ k);\n break;\n case 1:\n System.out.println(\"H \"+ k);\n break;\n case 2:\n System.out.println(\"C \"+ k);\n break;\n case 3:\n System.out.println(\"D \"+ k);\n break;\n }\n }\n }\n }\n }\n}\n\n\n", "language": "Java", "metadata": {"date": 1563873810, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02408.html", "problem_id": "p02408", "resource_group": "high_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/Java/s948418511.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s948418511", "user_id": "u349657032"}, "prompt_components": {"gold_output": "S 1\nH 3\nH 7\nC 12\nD 8\n", "input_to_evaluate": "import java.util.Scanner;\n\n\npublic class Main { \n public static void main(String[] args) {\n int n; \n String a;\n int i;\n int j;\n \n Scanner sc = new Scanner(System.in);\n n = sc.nextInt();\n String [] [] c = new String [4] [13];\n \n while(n!=0){\n n--;\n switch(a = sc.next().toUpperCase()){\n case \"S\":\n i = 0;\n j = sc.nextInt();\n c [i] [j-1] = a+\" \"+j;\n break;\n case \"H\":\n i = 1;\n j = sc.nextInt();\n c [i] [j-1] = a+ \" \" + j;\n break;\n case \"C\":\n i = 2;\n j = sc.nextInt();\n c [i] [j-1] = a+ \" \" + j;\n break; \n case \"D\":\n i = 3;\n j = sc.nextInt();\n c [i] [j-1] = a+ \" \" + j;\n break; \n }\n }\n for ( i = 0; i <4; i++){\n for (j = 0; j<13; j++){\n int k = j+1;\n if( c[i][j]== null){\n switch(i){\n case 0:\n System.out.println(\"S \"+ k);\n break;\n case 1:\n System.out.println(\"H \"+ k);\n break;\n case 2:\n System.out.println(\"C \"+ k);\n break;\n case 3:\n System.out.println(\"D \"+ k);\n break;\n }\n }\n }\n }\n }\n}\n\n\n", "problem_context": "Finding Missing Cards\n\nTaro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).\n\nThe 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.\n\nInput\n\nIn the first line, the number of cards n (n ≤ 52) is given.\n\nIn the following n lines, data of the n cards are given. Each card is given by a pair of a character and an integer which represent its suit and rank respectively. A suit is represented by 'S', 'H', 'C' and 'D' for spades, hearts, clubs and diamonds respectively. A rank is represented by an integer from 1 to 13.\n\nOutput\n\nPrint the missing cards. The same as the input format, each card should be printed with a character and an integer separated by a space character in a line.\nArrange the missing cards in the following priorities:\n\nPrint cards of spades, hearts, clubs and diamonds in this order.\n\nIf the suits are equal, print cards with lower ranks first.\n\nSample Input\n\n47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n\nSample Output\n\nS 1\nH 3\nH 7\nC 12\nD 8\n\nNote\n\n      解説", "sample_input": "47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n"}, "reference_outputs": ["S 1\nH 3\nH 7\nC 12\nD 8\n"], "source_document_id": "p02408", "source_text": "Finding Missing Cards\n\nTaro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).\n\nThe 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.\n\nInput\n\nIn the first line, the number of cards n (n ≤ 52) is given.\n\nIn the following n lines, data of the n cards are given. Each card is given by a pair of a character and an integer which represent its suit and rank respectively. A suit is represented by 'S', 'H', 'C' and 'D' for spades, hearts, clubs and diamonds respectively. A rank is represented by an integer from 1 to 13.\n\nOutput\n\nPrint the missing cards. The same as the input format, each card should be printed with a character and an integer separated by a space character in a line.\nArrange the missing cards in the following priorities:\n\nPrint cards of spades, hearts, clubs and diamonds in this order.\n\nIf the suits are equal, print cards with lower ranks first.\n\nSample Input\n\n47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n\nSample Output\n\nS 1\nH 3\nH 7\nC 12\nD 8\n\nNote\n\n      解説", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1719, "cpu_time_ms": 60, "memory_kb": 26204}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s950903507", "group_id": "codeNet:p02408", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tboolean[][] card = new boolean[4][13];\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tString s = scanner.next();\n\t\t\tint num = scanner.nextInt();\n\t\t\tcard[s.equals(\"S\") ? 0 : s.equals(\"H\") ? 1 : s.equals(\"C\") ? 2 : 3][num - 1] = true;\n\t\t}\n\t\tfor (int i = 0; i < 4; ++i) {\n\t\t\tfor (int j = 0; j < 13; ++j) {\n\t\t\t\tif (!card[i][j])\n\t\t\t\t\tSystem.out.printf(\"%s %d\\n\", i == 0 ? \"S\" : i == 1 ? \"H\" : i == 2 ? \"C\" : \"D\", j + 1);\n\t\t\t}\n\t\t}\n\t}\n}\n\n", "language": "Java", "metadata": {"date": 1536204151, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02408.html", "problem_id": "p02408", "resource_group": "high_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/Java/s950903507.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s950903507", "user_id": "u884291095"}, "prompt_components": {"gold_output": "S 1\nH 3\nH 7\nC 12\nD 8\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tboolean[][] card = new boolean[4][13];\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tString s = scanner.next();\n\t\t\tint num = scanner.nextInt();\n\t\t\tcard[s.equals(\"S\") ? 0 : s.equals(\"H\") ? 1 : s.equals(\"C\") ? 2 : 3][num - 1] = true;\n\t\t}\n\t\tfor (int i = 0; i < 4; ++i) {\n\t\t\tfor (int j = 0; j < 13; ++j) {\n\t\t\t\tif (!card[i][j])\n\t\t\t\t\tSystem.out.printf(\"%s %d\\n\", i == 0 ? \"S\" : i == 1 ? \"H\" : i == 2 ? \"C\" : \"D\", j + 1);\n\t\t\t}\n\t\t}\n\t}\n}\n\n", "problem_context": "Finding Missing Cards\n\nTaro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).\n\nThe 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.\n\nInput\n\nIn the first line, the number of cards n (n ≤ 52) is given.\n\nIn the following n lines, data of the n cards are given. Each card is given by a pair of a character and an integer which represent its suit and rank respectively. A suit is represented by 'S', 'H', 'C' and 'D' for spades, hearts, clubs and diamonds respectively. A rank is represented by an integer from 1 to 13.\n\nOutput\n\nPrint the missing cards. The same as the input format, each card should be printed with a character and an integer separated by a space character in a line.\nArrange the missing cards in the following priorities:\n\nPrint cards of spades, hearts, clubs and diamonds in this order.\n\nIf the suits are equal, print cards with lower ranks first.\n\nSample Input\n\n47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n\nSample Output\n\nS 1\nH 3\nH 7\nC 12\nD 8\n\nNote\n\n      解説", "sample_input": "47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n"}, "reference_outputs": ["S 1\nH 3\nH 7\nC 12\nD 8\n"], "source_document_id": "p02408", "source_text": "Finding Missing Cards\n\nTaro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).\n\nThe 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.\n\nInput\n\nIn the first line, the number of cards n (n ≤ 52) is given.\n\nIn the following n lines, data of the n cards are given. Each card is given by a pair of a character and an integer which represent its suit and rank respectively. A suit is represented by 'S', 'H', 'C' and 'D' for spades, hearts, clubs and diamonds respectively. A rank is represented by an integer from 1 to 13.\n\nOutput\n\nPrint the missing cards. The same as the input format, each card should be printed with a character and an integer separated by a space character in a line.\nArrange the missing cards in the following priorities:\n\nPrint cards of spades, hearts, clubs and diamonds in this order.\n\nIf the suits are equal, print cards with lower ranks first.\n\nSample Input\n\n47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n\nSample Output\n\nS 1\nH 3\nH 7\nC 12\nD 8\n\nNote\n\n      解説", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 583, "cpu_time_ms": 60, "memory_kb": 26264}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s251221269", "group_id": "codeNet:p02409", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint b,f,r,v;\n\t\tint d[][][] = new int[4][3][10];\n\n\t\tfor(int i=1;i<=n;i++){\n\t\t\tb = sc.nextInt();\n\t\t\tf = sc.nextInt();\n\t\t\tr = sc.nextInt();\n\t\t\tv = sc.nextInt();\n\t\t\td[b-1][f-1][r-1] = d[b-1][f-1][r-1]+v;\n\t\t}\n\t\tfor(int i=0;i<4;i++){\n\t\t\tfor(int j=0;j<3;j++){\n\t\t\t\tfor(int k=0;k<9;k++){\n\t\t\t\t\tSystem.out.print(d[i][j][k]+\" \");\n\t\t\t\t}\n\t\t\t\tSystem.out.println(d[i][j][9]);\n\t\t\t}\n\t\t\tif(i!=3){\n\t\t\t\tSystem.out.println(\"####################\");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println();\n\t}\n}", "language": "Java", "metadata": {"date": 1453035310, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02409.html", "problem_id": "p02409", "resource_group": "high_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/Java/s251221269.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s251221269", "user_id": "u918457647"}, "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 java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint b,f,r,v;\n\t\tint d[][][] = new int[4][3][10];\n\n\t\tfor(int i=1;i<=n;i++){\n\t\t\tb = sc.nextInt();\n\t\t\tf = sc.nextInt();\n\t\t\tr = sc.nextInt();\n\t\t\tv = sc.nextInt();\n\t\t\td[b-1][f-1][r-1] = d[b-1][f-1][r-1]+v;\n\t\t}\n\t\tfor(int i=0;i<4;i++){\n\t\t\tfor(int j=0;j<3;j++){\n\t\t\t\tfor(int k=0;k<9;k++){\n\t\t\t\t\tSystem.out.print(d[i][j][k]+\" \");\n\t\t\t\t}\n\t\t\t\tSystem.out.println(d[i][j][9]);\n\t\t\t}\n\t\t\tif(i!=3){\n\t\t\t\tSystem.out.println(\"####################\");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println();\n\t}\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": 617, "cpu_time_ms": 90, "memory_kb": 25848}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s942154726", "group_id": "codeNet:p02409", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int bfrv[][][] = new int[5][4][11];\n int b = 0;\n int f = 0;\n int r = 0;\n int v = 0;\n for (int i = 0; i < n; i++) {\n\n b = sc.nextInt();\n f = sc.nextInt();\n r = sc.nextInt();\n v = sc.nextInt();\n\n bfrv[b][f][r] += v;\n if (bfrv[b][f][r] < 0) {\n bfrv[b][f][r] = 0;\n }\n }\n for (int i = 1; i < 5; i++) {\n for (int j = 1; j < 4; j++) {\n for (int k = 1; k < 11; k++) {\n System.out.print(bfrv[i][j][k]);\n if (k != 10) {\n System.out.print(\" \");\n }\n }\n System.out.println(\"\");\n }\n if (i != 4) {\n System.out.println(\"####################\");\n }\n }\n }\n}", "language": "Java", "metadata": {"date": 1502267207, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02409.html", "problem_id": "p02409", "resource_group": "high_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/Java/s942154726.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s942154726", "user_id": "u233301102"}, "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 java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int bfrv[][][] = new int[5][4][11];\n int b = 0;\n int f = 0;\n int r = 0;\n int v = 0;\n for (int i = 0; i < n; i++) {\n\n b = sc.nextInt();\n f = sc.nextInt();\n r = sc.nextInt();\n v = sc.nextInt();\n\n bfrv[b][f][r] += v;\n if (bfrv[b][f][r] < 0) {\n bfrv[b][f][r] = 0;\n }\n }\n for (int i = 1; i < 5; i++) {\n for (int j = 1; j < 4; j++) {\n for (int k = 1; k < 11; k++) {\n System.out.print(bfrv[i][j][k]);\n if (k != 10) {\n System.out.print(\" \");\n }\n }\n System.out.println(\"\");\n }\n if (i != 4) {\n System.out.println(\"####################\");\n }\n }\n }\n}", "problem_context": "Official House\n\nYou manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room.\n\nFor each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left.\n\nAssume that initially no person lives in the building.\n\nInput\n\nIn the first line, the number of notices n is given. In the following n lines, a set of four integers b, f, r and v which represents ith notice is given in a line.\n\nOutput\n\nFor each building, print the information of 1st, 2nd and 3rd floor in this order. For each floor information, print the number of tenants of 1st, 2nd, .. and 10th room in this order. Print a single space character before the number of tenants. Print \"####################\" (20 '#') between buildings.\n\nConstraints\n\nNo incorrect building, floor and room numbers are given.\n\n0 ≤ the number of tenants during the management ≤ 9\n\nSample Input\n\n3\n1 1 3 8\n3 2 2 7\n4 3 8 1\n\nSample Output\n\n0 0 8 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n####################\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n####################\n0 0 0 0 0 0 0 0 0 0\n0 7 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n####################\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 1 0 0", "sample_input": "3\n1 1 3 8\n3 2 2 7\n4 3 8 1\n"}, "reference_outputs": [" 0 0 8 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n####################\n 0 0 0 0 0 0 0 0 0 0\n 0 7 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 1 0 0\n"], "source_document_id": "p02409", "source_text": "Official House\n\nYou manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room.\n\nFor each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left.\n\nAssume that initially no person lives in the building.\n\nInput\n\nIn the first line, the number of notices n is given. In the following n lines, a set of four integers b, f, r and v which represents ith notice is given in a line.\n\nOutput\n\nFor each building, print the information of 1st, 2nd and 3rd floor in this order. For each floor information, print the number of tenants of 1st, 2nd, .. and 10th room in this order. Print a single space character before the number of tenants. Print \"####################\" (20 '#') between buildings.\n\nConstraints\n\nNo incorrect building, floor and room numbers are given.\n\n0 ≤ the number of tenants during the management ≤ 9\n\nSample Input\n\n3\n1 1 3 8\n3 2 2 7\n4 3 8 1\n\nSample Output\n\n0 0 8 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n####################\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n####################\n0 0 0 0 0 0 0 0 0 0\n0 7 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n####################\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 1 0 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1049, "cpu_time_ms": 50, "memory_kb": 26316}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s662328944", "group_id": "codeNet:p02410", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws Exception {\n int i,j;\n \n Scanner sc=new Scanner(System.in);\n int n=sc.nextInt();\n int m=sc.nextInt();\n \n Matrix A=new Matrix(n,m);\n for(i=0;i list = new ArrayList();\n\n\t\twhile(isContinue){\n\n\t\t\tint m = scan.nextInt();\n\t\t\tint f = scan.nextInt();\n\t\t\tint r = scan.nextInt();\n\n\n\t\t\tint intScore = 0;\n\t\t\t//????????????????????´??????intScore????¨????\n\t\t\tif(m != -1 && f != -1){\n\t\t\t\tintScore = m + f;\n\t\t\t}\n\n\t\t\t//while????????????????????¶\n\t\t\tif(m == -1 && f == -1 && r == -1){\n\t\t\t\tisContinue = false;\n\t\t\t\tscan.close();\n\n\t\t\t//????????????????????????????????????list???????´?\n\t\t\t}else if(m == -1 || f == -1 || intScore < 30 ){\n\n\t\t\t\tlist.add(\"F\");\n\t\t\t}else if(80 <= intScore){\n\n\t\t\t\tlist.add(\"A\");\n\t\t\t}else if(65 <= intScore){\n\n\t\t\t\tlist.add(\"B\");\n\t\t\t}else if(50 <= intScore){\n\n\t\t\t\tlist.add(\"C\");\n\t\t\t}else if(30 <= intScore && 50 <= r){\n\n\t\t\t\tlist.add(\"C\");\n\n\t\t\t}else{\n\n\t\t\t\tlist.add(\"D\");\n\t\t\t}\n\t\t\t//System.out.println(\"list.size():\" + list.size());\n\t\t}\n\n\t\tfor(int i = 0; i < list.size(); i++){\n\n\t\t\tSystem.out.println(list.get(i));\n\t\t}\n\n\t}\n}", "language": "Java", "metadata": {"date": 1438926786, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02411.html", "problem_id": "p02411", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02411/input.txt", "sample_output_relpath": "derived/input_output/data/p02411/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02411/Java/s075558068.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s075558068", "user_id": "u752206831"}, "prompt_components": {"gold_output": "A\nC\nF\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO ?????????????????????????????????????????????\n\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tboolean isContinue = true;\n\n\t\t//?????°???????´?????????????\n\t\tint[] score = new int[3];\n\t\t//????????????????´????????????¬????????§????????????\n\t\tArrayList list = new ArrayList();\n\n\t\twhile(isContinue){\n\n\t\t\tint m = scan.nextInt();\n\t\t\tint f = scan.nextInt();\n\t\t\tint r = scan.nextInt();\n\n\n\t\t\tint intScore = 0;\n\t\t\t//????????????????????´??????intScore????¨????\n\t\t\tif(m != -1 && f != -1){\n\t\t\t\tintScore = m + f;\n\t\t\t}\n\n\t\t\t//while????????????????????¶\n\t\t\tif(m == -1 && f == -1 && r == -1){\n\t\t\t\tisContinue = false;\n\t\t\t\tscan.close();\n\n\t\t\t//????????????????????????????????????list???????´?\n\t\t\t}else if(m == -1 || f == -1 || intScore < 30 ){\n\n\t\t\t\tlist.add(\"F\");\n\t\t\t}else if(80 <= intScore){\n\n\t\t\t\tlist.add(\"A\");\n\t\t\t}else if(65 <= intScore){\n\n\t\t\t\tlist.add(\"B\");\n\t\t\t}else if(50 <= intScore){\n\n\t\t\t\tlist.add(\"C\");\n\t\t\t}else if(30 <= intScore && 50 <= r){\n\n\t\t\t\tlist.add(\"C\");\n\n\t\t\t}else{\n\n\t\t\t\tlist.add(\"D\");\n\t\t\t}\n\t\t\t//System.out.println(\"list.size():\" + list.size());\n\t\t}\n\n\t\tfor(int i = 0; i < list.size(); i++){\n\n\t\t\tSystem.out.println(list.get(i));\n\t\t}\n\n\t}\n}", "problem_context": "Grading\n\nWrite a program which reads a list of student test scores and evaluates the performance for each student.\n\nThe test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, the score is indicated by -1.\n\nThe final performance of a student is evaluated by the following procedure:\n\nIf the student does not take the midterm or final examination, the student's grade shall be F.\n\nIf the total score of the midterm and final examination is greater than or equal to 80, the student's grade shall be A.\n\nIf the total score of the midterm and final examination is greater than or equal to 65 and less than 80, the student's grade shall be B.\n\nIf the total score of the midterm and final examination is greater than or equal to 50 and less than 65, the student's grade shall be C.\n\nIf the total score of the midterm and final examination is greater than or equal to 30 and less than 50, the student's grade shall be D. However, if the score of the makeup examination is greater than or equal to 50, the grade shall be C.\n\nIf the total score of the midterm and final examination is less than 30, the student's grade shall be F.\n\nInput\n\nThe input consists of multiple datasets. For each dataset, three integers m, f and r are given in a line.\n\nThe input ends with three -1 for m, f and r respectively. Your program should not process for the terminal symbols.\n\nThe number of datasets (the number of students) does not exceed 50.\n\nOutput\n\nFor each dataset, print the grade (A, B, C, D or F) in a line.\n\nSample Input\n\n40 42 -1\n20 30 -1\n0 2 -1\n-1 -1 -1\n\nSample Output\n\nA\nC\nF", "sample_input": "40 42 -1\n20 30 -1\n0 2 -1\n-1 -1 -1\n"}, "reference_outputs": ["A\nC\nF\n"], "source_document_id": "p02411", "source_text": "Grading\n\nWrite a program which reads a list of student test scores and evaluates the performance for each student.\n\nThe test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, the score is indicated by -1.\n\nThe final performance of a student is evaluated by the following procedure:\n\nIf the student does not take the midterm or final examination, the student's grade shall be F.\n\nIf the total score of the midterm and final examination is greater than or equal to 80, the student's grade shall be A.\n\nIf the total score of the midterm and final examination is greater than or equal to 65 and less than 80, the student's grade shall be B.\n\nIf the total score of the midterm and final examination is greater than or equal to 50 and less than 65, the student's grade shall be C.\n\nIf the total score of the midterm and final examination is greater than or equal to 30 and less than 50, the student's grade shall be D. However, if the score of the makeup examination is greater than or equal to 50, the grade shall be C.\n\nIf the total score of the midterm and final examination is less than 30, the student's grade shall be F.\n\nInput\n\nThe input consists of multiple datasets. For each dataset, three integers m, f and r are given in a line.\n\nThe input ends with three -1 for m, f and r respectively. Your program should not process for the terminal symbols.\n\nThe number of datasets (the number of students) does not exceed 50.\n\nOutput\n\nFor each dataset, print the grade (A, B, C, D or F) in a line.\n\nSample Input\n\n40 42 -1\n20 30 -1\n0 2 -1\n-1 -1 -1\n\nSample Output\n\nA\nC\nF", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1285, "cpu_time_ms": 50, "memory_kb": 19652}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s304387027", "group_id": "codeNet:p02412", "input_text": "import java.util.Scanner;\nimport java.util.ArrayList;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tScanner scan = new Scanner(System.in);\n\t\tArrayList number = new ArrayList();\n\t\t\n\t\tint n = 0;\n\t\tint x = 0;\n\t\tint countA = 0;\n\t\t\n\t\twhile(true){\n\t\t\tn = scan.nextInt();\n\t\t\tx = scan.nextInt();\n\t\t\tint count = 0;\n\t\t\tif(n == 0 && x == 0){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\tfor (int i = 1; i <= n; i++) {\n\t\t\t\tfor (int j = 1; j <= n; j++) {\n\t\t\t\t\tfor (int k = 1; k <= n; k++) {\n\t\t\t\t\t\tif (i == j || j == k) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t} else if (i < j && j < k) {\n\t\t\t\t\t\t\tint s = i + j + k;\n\t\t\t\t\t\t\tif (s == x) {\n\t\t\t\t\t\t\t\tcount = count + 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tnumber.add(count);\n\t\t\tcountA++;\n\t\t}\n\t\tfor(int h = 0; h < countA; h++){\n\t\t\tSystem.out.println(number.get(h));\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1471182118, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02412.html", "problem_id": "p02412", "resource_group": "high_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/Java/s304387027.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s304387027", "user_id": "u954258807"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner;\nimport java.util.ArrayList;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tScanner scan = new Scanner(System.in);\n\t\tArrayList number = new ArrayList();\n\t\t\n\t\tint n = 0;\n\t\tint x = 0;\n\t\tint countA = 0;\n\t\t\n\t\twhile(true){\n\t\t\tn = scan.nextInt();\n\t\t\tx = scan.nextInt();\n\t\t\tint count = 0;\n\t\t\tif(n == 0 && x == 0){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\tfor (int i = 1; i <= n; i++) {\n\t\t\t\tfor (int j = 1; j <= n; j++) {\n\t\t\t\t\tfor (int k = 1; k <= n; k++) {\n\t\t\t\t\t\tif (i == j || j == k) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t} else if (i < j && j < k) {\n\t\t\t\t\t\t\tint s = i + j + k;\n\t\t\t\t\t\t\tif (s == x) {\n\t\t\t\t\t\t\t\tcount = count + 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tnumber.add(count);\n\t\t\tcountA++;\n\t\t}\n\t\tfor(int h = 0; h < countA; h++){\n\t\t\tSystem.out.println(number.get(h));\n\t\t}\n\t}\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": 861, "cpu_time_ms": 110, "memory_kb": 27412}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s980852493", "group_id": "codeNet:p02412", "input_text": "import java.util.Scanner;\n\nclass Main{\n public static void main(String[] args){\n Scanner scan = new Scanner(System.in);\n\n String[] inputs = scan.nextLine().split(\" \");\n int n = Integer.parseInt(inputs[0]);\n int x = Integer.parseInt(inputs[1]);\n int num = 0;\n int k;\n\n for (int i=1; i j && k <= n)\n num += 1;\n }\n }\n if (num != 0){\n System.out.println(num);\n }\n }\n}", "language": "Java", "metadata": {"date": 1496501013, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02412.html", "problem_id": "p02412", "resource_group": "high_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/Java/s980852493.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s980852493", "user_id": "u834139744"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner;\n\nclass Main{\n public static void main(String[] args){\n Scanner scan = new Scanner(System.in);\n\n String[] inputs = scan.nextLine().split(\" \");\n int n = Integer.parseInt(inputs[0]);\n int x = Integer.parseInt(inputs[1]);\n int num = 0;\n int k;\n\n for (int i=1; i j && k <= n)\n num += 1;\n }\n }\n if (num != 0){\n System.out.println(num);\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": 854, "cpu_time_ms": 50, "memory_kb": 26028}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s666293838", "group_id": "codeNet:p02412", "input_text": "import java.util.*;\npublic class Main {\n static Scanner kbd = new Scanner(System.in);\n public static void main(String[] args) {\n \n while(kbd.hasNext()){\n int n = kbd.nextInt();\n int x = kbd.nextInt();\n int z=0;\n if(!(n==0 && x==0)){\n for(int a=1; a<=n-2; a++){\n for(int b=2; b<=n-1; b++){\n for(int c=3; c<=n; c++){\n //System.out.println(a+\" \"+b+\" \"+c);\n if(m(a,b,c,x)) z++;\n }\n }\n }\n System.out.println(z);\n }\n }\n }\n static boolean m(int a, int b, int c, int x){\n boolean p = a+b+c==x;\n boolean q = a= 0 && num < 26){\n \t\t\tcount[num]++;\n \t\t}\n \t}\n \t\n \tfor(int i = 0; i < 26; i++){;\n \t\tSystem.out.println(alphabet + \":\" + count[i]);\n \t\talphabet += 1;\n \t}\n }\n}", "language": "Java", "metadata": {"date": 1491472262, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02417.html", "problem_id": "p02417", "resource_group": "high_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/Java/s727651552.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s727651552", "user_id": "u206778360"}, "prompt_components": {"gold_output": "a : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0\n", "input_to_evaluate": "import java.util.Scanner;\n\nclass Main{\n public static void main(String[] args){\n \tScanner scan = new Scanner(System.in);\n \tString number = scan.nextLine();\n \tString change = number.toLowerCase();\n \t\n \tchar[] ca = change.toCharArray();\n \tint[] count = new int[26];\n \tint num;\n \tchar alphabet = 'a';\n \t\n \tfor(int i = 0; i < ca.length; i++){\n \t\tnum = ca[i] - 'a';\n \t\tif(num >= 0 && num < 26){\n \t\t\tcount[num]++;\n \t\t}\n \t}\n \t\n \tfor(int i = 0; i < 26; i++){;\n \t\tSystem.out.println(alphabet + \":\" + count[i]);\n \t\talphabet += 1;\n \t}\n }\n}", "problem_context": "Counting Characters\n\nWrite a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.\n\nInput\n\nA sentence in English is given in several lines.\n\nOutput\n\nPrints the number of alphabetical letters in the following format:\n\na : The number of 'a'\nb : The number of 'b'\nc : The number of 'c'\n.\n.\nz : The number of 'z'\n\nConstraints\n\nThe number of characters in the sentence < 1200\n\nSample Input\n\nThis is a pen.\n\nSample Output\n\na : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0", "sample_input": "This is a pen.\n"}, "reference_outputs": ["a : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0\n"], "source_document_id": "p02417", "source_text": "Counting Characters\n\nWrite a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.\n\nInput\n\nA sentence in English is given in several lines.\n\nOutput\n\nPrints the number of alphabetical letters in the following format:\n\na : The number of 'a'\nb : The number of 'b'\nc : The number of 'c'\n.\n.\nz : The number of 'z'\n\nConstraints\n\nThe number of characters in the sentence < 1200\n\nSample Input\n\nThis is a pen.\n\nSample Output\n\na : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 598, "cpu_time_ms": 50, "memory_kb": 26012}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s765044504", "group_id": "codeNet:p02417", "input_text": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner inp = new Scanner(System.in);\n\n\n StringBuilder s = new StringBuilder();\n\n while(inp.hasNext()){\n s.append(inp.nextLine());\n }\n\n count(s.toString());\n }\n\n public static void count(String s) {\n for (int alpha = 0; alpha < 26; alpha++) {\n String letter;\n int counter = 0;\n\n switch (alpha) {\n case 0: letter = \"a\";\n break;\n case 1: letter = \"b\";\n break;\n case 2: letter = \"c\";\n break;\n case 3: letter = \"d\";\n break;\n case 4: letter = \"e\";\n break;\n case 5: letter = \"f\";\n break;\n case 6: letter = \"g\";\n break;\n case 7: letter = \"h\";\n break;\n case 8: letter = \"i\";\n break;\n case 9: letter = \"j\";\n break;\n case 10: letter = \"k\";\n break;\n case 11: letter = \"l\";\n break;\n case 12: letter = \"m\";\n break;\n case 13: letter = \"n\";\n break;\n case 14: letter = \"o\";\n break;\n case 15: letter = \"p\";\n break;\n case 16: letter = \"q\";\n break;\n case 17: letter = \"r\";\n break;\n case 18: letter = \"s\";\n break;\n case 19: letter = \"t\";\n break;\n case 20: letter = \"u\";\n break;\n case 21: letter = \"v\";\n break;\n case 22: letter = \"w\";\n break;\n case 23: letter = \"x\";\n break;\n case 24: letter = \"y\";\n break;\n default: letter = \"z\";\n break;\n }\n String letterUp = letter.toUpperCase();\n\n for (int i = 0; i < s.length(); i++) {\n if ((\"\"+s.charAt(i)).equals(letter) || (\"\"+s.charAt(i)).equals(letterUp)) {\n counter++;\n }\n }\n\n System.out.println(letter + \" : \" + counter);\n }\n }\n}\n\n", "language": "Java", "metadata": {"date": 1543610523, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02417.html", "problem_id": "p02417", "resource_group": "high_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/Java/s765044504.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s765044504", "user_id": "u647456682"}, "prompt_components": {"gold_output": "a : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner inp = new Scanner(System.in);\n\n\n StringBuilder s = new StringBuilder();\n\n while(inp.hasNext()){\n s.append(inp.nextLine());\n }\n\n count(s.toString());\n }\n\n public static void count(String s) {\n for (int alpha = 0; alpha < 26; alpha++) {\n String letter;\n int counter = 0;\n\n switch (alpha) {\n case 0: letter = \"a\";\n break;\n case 1: letter = \"b\";\n break;\n case 2: letter = \"c\";\n break;\n case 3: letter = \"d\";\n break;\n case 4: letter = \"e\";\n break;\n case 5: letter = \"f\";\n break;\n case 6: letter = \"g\";\n break;\n case 7: letter = \"h\";\n break;\n case 8: letter = \"i\";\n break;\n case 9: letter = \"j\";\n break;\n case 10: letter = \"k\";\n break;\n case 11: letter = \"l\";\n break;\n case 12: letter = \"m\";\n break;\n case 13: letter = \"n\";\n break;\n case 14: letter = \"o\";\n break;\n case 15: letter = \"p\";\n break;\n case 16: letter = \"q\";\n break;\n case 17: letter = \"r\";\n break;\n case 18: letter = \"s\";\n break;\n case 19: letter = \"t\";\n break;\n case 20: letter = \"u\";\n break;\n case 21: letter = \"v\";\n break;\n case 22: letter = \"w\";\n break;\n case 23: letter = \"x\";\n break;\n case 24: letter = \"y\";\n break;\n default: letter = \"z\";\n break;\n }\n String letterUp = letter.toUpperCase();\n\n for (int i = 0; i < s.length(); i++) {\n if ((\"\"+s.charAt(i)).equals(letter) || (\"\"+s.charAt(i)).equals(letterUp)) {\n counter++;\n }\n }\n\n System.out.println(letter + \" : \" + counter);\n }\n }\n}\n\n", "problem_context": "Counting Characters\n\nWrite a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.\n\nInput\n\nA sentence in English is given in several lines.\n\nOutput\n\nPrints the number of alphabetical letters in the following format:\n\na : The number of 'a'\nb : The number of 'b'\nc : The number of 'c'\n.\n.\nz : The number of 'z'\n\nConstraints\n\nThe number of characters in the sentence < 1200\n\nSample Input\n\nThis is a pen.\n\nSample Output\n\na : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0", "sample_input": "This is a pen.\n"}, "reference_outputs": ["a : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0\n"], "source_document_id": "p02417", "source_text": "Counting Characters\n\nWrite a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.\n\nInput\n\nA sentence in English is given in several lines.\n\nOutput\n\nPrints the number of alphabetical letters in the following format:\n\na : The number of 'a'\nb : The number of 'b'\nc : The number of 'c'\n.\n.\nz : The number of 'z'\n\nConstraints\n\nThe number of characters in the sentence < 1200\n\nSample Input\n\nThis is a pen.\n\nSample Output\n\na : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2550, "cpu_time_ms": 70, "memory_kb": 34096}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s089272538", "group_id": "codeNet:p02418", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n StringBuilder sb = new StringBuilder();\n String[] str = sc.nextLine().split(\"\");\n String p = sc.nextLine();\n for(int i = 0; i < str.length; i++) {\n sb.setLength(0);\n for(int j = i; j < i + str.length; j++) {\n int a = j;\n if(a >= str.length) {\n a -= str.length;\n }\n sb.append(str[a]);\n }\n String s = sb.toString();\n if(s.contains(p)) {\n System.out.println(\"Yes\");\n break;\n } else if(i == str.length - 1) {\n System.out.println(\"No\");\n }\n }\n }\n}\n\n", "language": "Java", "metadata": {"date": 1527903663, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02418.html", "problem_id": "p02418", "resource_group": "high_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/Java/s089272538.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s089272538", "user_id": "u676874280"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n StringBuilder sb = new StringBuilder();\n String[] str = sc.nextLine().split(\"\");\n String p = sc.nextLine();\n for(int i = 0; i < str.length; i++) {\n sb.setLength(0);\n for(int j = i; j < i + str.length; j++) {\n int a = j;\n if(a >= str.length) {\n a -= str.length;\n }\n sb.append(str[a]);\n }\n String s = sb.toString();\n if(s.contains(p)) {\n System.out.println(\"Yes\");\n break;\n } else if(i == str.length - 1) {\n System.out.println(\"No\");\n }\n }\n }\n}\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": 679, "cpu_time_ms": 70, "memory_kb": 26920}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s401219052", "group_id": "codeNet:p02419", "input_text": "import java.io.IOException;\nimport java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String[] args) throws IOException {\n\n\t\tScanner scanner = new Scanner(System.in);\n\t\tString ans = scanner.nextLine().toLowerCase();\n\t\tint count = 0;\n\t\t\n\t\tend:\n\t\twhile (scanner.hasNext()) {\n\t\t\tString str = scanner.nextLine().toLowerCase();\n\t\t\tString[] strs = str.split(\" \");\n\t\t\tfor (int i = 0; i < strs.length; i++) {\n\t\t\t\tif(strs[i].equals(\"end_of_text\")){\n\t\t\t\t\tbreak end;\n\t\t\t\t}\n\t\t\t\tif (strs[i].contains(ans)) {\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.println(count);\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1468980991, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02419.html", "problem_id": "p02419", "resource_group": "high_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/Java/s401219052.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s401219052", "user_id": "u960488816"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.IOException;\nimport java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String[] args) throws IOException {\n\n\t\tScanner scanner = new Scanner(System.in);\n\t\tString ans = scanner.nextLine().toLowerCase();\n\t\tint count = 0;\n\t\t\n\t\tend:\n\t\twhile (scanner.hasNext()) {\n\t\t\tString str = scanner.nextLine().toLowerCase();\n\t\t\tString[] strs = str.split(\" \");\n\t\t\tfor (int i = 0; i < strs.length; i++) {\n\t\t\t\tif(strs[i].equals(\"end_of_text\")){\n\t\t\t\t\tbreak end;\n\t\t\t\t}\n\t\t\t\tif (strs[i].contains(ans)) {\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.println(count);\n\t\t}\n\t}\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": 565, "cpu_time_ms": 50, "memory_kb": 25812}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s408251292", "group_id": "codeNet:p02419", "input_text": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n\n int count = 0;\n String key = sc.next().toString();\n String cmp;\n\n String input = sc.next();\n while(! input.equals(\"END_OF_TEXT\")) {\n cmp = input.toLowerCase();\n if(input.equals(cmp))\n count++;\n input = sc.next();\n }\n System.out.println(count);\n }\n}\n", "language": "Java", "metadata": {"date": 1524001357, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02419.html", "problem_id": "p02419", "resource_group": "high_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/Java/s408251292.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s408251292", "user_id": "u047818749"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n\n int count = 0;\n String key = sc.next().toString();\n String cmp;\n\n String input = sc.next();\n while(! input.equals(\"END_OF_TEXT\")) {\n cmp = input.toLowerCase();\n if(input.equals(cmp))\n count++;\n input = sc.next();\n }\n System.out.println(count);\n }\n}\n", "problem_context": "Finding a Word\n\nWrite a program which reads a word W and a text T, and prints the number of word W which appears in text T\n\nT consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case insensitive.\n\nConstraints\n\nThe length of W ≤ 10\n\nW consists of lower case letters\n\nThe length of T in a line ≤ 1000\n\nInput\n\nIn the first line, the word W is given. In the following lines, the text T is given separated by space characters and newlines.\n\n\"END_OF_TEXT\" indicates the end of the text.\n\nOutput\n\nPrint the number of W in the text.\n\nSample Input\n\ncomputer\nNurtures computer scientists and highly-skilled computer engineers\nwho will create and exploit \"knowledge\" for the new era.\nProvides an outstanding computer environment.\nEND_OF_TEXT\n\nSample Output\n\n3", "sample_input": "computer\nNurtures computer scientists and highly-skilled computer engineers\nwho will create and exploit \"knowledge\" for the new era.\nProvides an outstanding computer environment.\nEND_OF_TEXT\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02419", "source_text": "Finding a Word\n\nWrite a program which reads a word W and a text T, and prints the number of word W which appears in text T\n\nT consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case insensitive.\n\nConstraints\n\nThe length of W ≤ 10\n\nW consists of lower case letters\n\nThe length of T in a line ≤ 1000\n\nInput\n\nIn the first line, the word W is given. In the following lines, the text T is given separated by space characters and newlines.\n\n\"END_OF_TEXT\" indicates the end of the text.\n\nOutput\n\nPrint the number of W in the text.\n\nSample Input\n\ncomputer\nNurtures computer scientists and highly-skilled computer engineers\nwho will create and exploit \"knowledge\" for the new era.\nProvides an outstanding computer environment.\nEND_OF_TEXT\n\nSample Output\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 60, "memory_kb": 25744}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s435184101", "group_id": "codeNet:p02419", "input_text": "import java.io.*;\nimport java.util.ArrayList;\npublic class Main{\n\tpublic static void main(String args[]){\n int a=0,end = 0;\n String ans;\n BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\n try{\n String line = reader.readLine();\n ans = line;\n \n while (true) {\n line = reader.readLine();\n for(String splitted: line.split(\" \")){\n if (ans.equalsIgnoreCase(splitted)) a++;\n if (splitted.equals(\"END_OF_TEXT\")) end = 1;\n }\n if(end == 1) break;\n }\n \n\t\t}catch(Exception e){\n }\n System.out.println(a);\n\n }\n}\n", "language": "Java", "metadata": {"date": 1589789390, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02419.html", "problem_id": "p02419", "resource_group": "high_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/Java/s435184101.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s435184101", "user_id": "u834261208"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.*;\nimport java.util.ArrayList;\npublic class Main{\n\tpublic static void main(String args[]){\n int a=0,end = 0;\n String ans;\n BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\n try{\n String line = reader.readLine();\n ans = line;\n \n while (true) {\n line = reader.readLine();\n for(String splitted: line.split(\" \")){\n if (ans.equalsIgnoreCase(splitted)) a++;\n if (splitted.equals(\"END_OF_TEXT\")) end = 1;\n }\n if(end == 1) break;\n }\n \n\t\t}catch(Exception e){\n }\n System.out.println(a);\n\n }\n}\n", "problem_context": "Finding a Word\n\nWrite a program which reads a word W and a text T, and prints the number of word W which appears in text T\n\nT consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case insensitive.\n\nConstraints\n\nThe length of W ≤ 10\n\nW consists of lower case letters\n\nThe length of T in a line ≤ 1000\n\nInput\n\nIn the first line, the word W is given. In the following lines, the text T is given separated by space characters and newlines.\n\n\"END_OF_TEXT\" indicates the end of the text.\n\nOutput\n\nPrint the number of W in the text.\n\nSample Input\n\ncomputer\nNurtures computer scientists and highly-skilled computer engineers\nwho will create and exploit \"knowledge\" for the new era.\nProvides an outstanding computer environment.\nEND_OF_TEXT\n\nSample Output\n\n3", "sample_input": "computer\nNurtures computer scientists and highly-skilled computer engineers\nwho will create and exploit \"knowledge\" for the new era.\nProvides an outstanding computer environment.\nEND_OF_TEXT\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02419", "source_text": "Finding a Word\n\nWrite a program which reads a word W and a text T, and prints the number of word W which appears in text T\n\nT consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case insensitive.\n\nConstraints\n\nThe length of W ≤ 10\n\nW consists of lower case letters\n\nThe length of T in a line ≤ 1000\n\nInput\n\nIn the first line, the word W is given. In the following lines, the text T is given separated by space characters and newlines.\n\n\"END_OF_TEXT\" indicates the end of the text.\n\nOutput\n\nPrint the number of W in the text.\n\nSample Input\n\ncomputer\nNurtures computer scientists and highly-skilled computer engineers\nwho will create and exploit \"knowledge\" for the new era.\nProvides an outstanding computer environment.\nEND_OF_TEXT\n\nSample Output\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 50, "memory_kb": 24496}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s298516327", "group_id": "codeNet:p02420", "input_text": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String input;\n int m;\n\n while (!(input = sc.next()).equals(\"-\")) {\n m = sc.nextInt();\n int[] h = new int[m];\n char[] output = new char[input.length()];\n for (int i = 0; i < m; i++) {\n h[i] = sc.nextInt();\n }\n for (int i = 0; i < input.length(); i++) {\n output[i] = input.charAt(i);\n }\n\n for (int i = 0; i < m; i++) {\n output = change(output, input.length(), h[i]);\n }\n for (char c : output) System.out.print(c);\n System.out.println();\n }\n }\n\n public static char[] change(char[] input, int length, int n) {\n char[] output = new char[length];\n\n for (int i = 0; i < length - n; i++) {\n output[i] = input[i+n];\n }\n for (int i = length - n; i < length; i++) {\n output[i] = input[i + n - length];\n }\n\n return output;\n }\n}\n", "language": "Java", "metadata": {"date": 1555911390, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02420.html", "problem_id": "p02420", "resource_group": "high_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/Java/s298516327.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s298516327", "user_id": "u070996128"}, "prompt_components": {"gold_output": "aabc\nxyzvw\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String input;\n int m;\n\n while (!(input = sc.next()).equals(\"-\")) {\n m = sc.nextInt();\n int[] h = new int[m];\n char[] output = new char[input.length()];\n for (int i = 0; i < m; i++) {\n h[i] = sc.nextInt();\n }\n for (int i = 0; i < input.length(); i++) {\n output[i] = input.charAt(i);\n }\n\n for (int i = 0; i < m; i++) {\n output = change(output, input.length(), h[i]);\n }\n for (char c : output) System.out.print(c);\n System.out.println();\n }\n }\n\n public static char[] change(char[] input, int length, int n) {\n char[] output = new char[length];\n\n for (int i = 0; i < length - n; i++) {\n output[i] = input[i+n];\n }\n for (int i = length - n; i < length; i++) {\n output[i] = input[i + n - length];\n }\n\n return output;\n }\n}\n", "problem_context": "Shuffle\n\nYour task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter.\n\nA single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck.\n\nThe deck of cards is represented by a string as follows.\n\nabcdeefab\n\nThe first character and the last character correspond to the card located at the bottom of the deck and the card on the top of the deck respectively.\n\nFor example, a shuffle with h = 4 to the above deck, moves the first 4 characters \"abcd\" to the end of the remaining characters \"eefab\", and generates the following deck:\n\neefababcd\n\nYou can repeat such shuffle operations.\n\nWrite a program which reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput\n\nThe input consists of multiple datasets. Each dataset is given in the following format:\n\nA string which represents a deck\nThe number of shuffle m\nh1\nh2\n.\n.\nhm\n\nThe input ends with a single character '-' for the string.\n\nConstraints\n\nThe length of the string ≤ 200\n\n1 ≤ m ≤ 100\n\n1 ≤ hi < The length of the string\n\nThe number of datasets ≤ 10\n\nOutput\n\nFor each dataset, print a string which represents the final state in a line.\n\nSample Input\n\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output\n\naabc\nxyzvw", "sample_input": "aabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n"}, "reference_outputs": ["aabc\nxyzvw\n"], "source_document_id": "p02420", "source_text": "Shuffle\n\nYour task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter.\n\nA single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck.\n\nThe deck of cards is represented by a string as follows.\n\nabcdeefab\n\nThe first character and the last character correspond to the card located at the bottom of the deck and the card on the top of the deck respectively.\n\nFor example, a shuffle with h = 4 to the above deck, moves the first 4 characters \"abcd\" to the end of the remaining characters \"eefab\", and generates the following deck:\n\neefababcd\n\nYou can repeat such shuffle operations.\n\nWrite a program which reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput\n\nThe input consists of multiple datasets. Each dataset is given in the following format:\n\nA string which represents a deck\nThe number of shuffle m\nh1\nh2\n.\n.\nhm\n\nThe input ends with a single character '-' for the string.\n\nConstraints\n\nThe length of the string ≤ 200\n\n1 ≤ m ≤ 100\n\n1 ≤ hi < The length of the string\n\nThe number of datasets ≤ 10\n\nOutput\n\nFor each dataset, print a string which represents the final state in a line.\n\nSample Input\n\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output\n\naabc\nxyzvw", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1121, "cpu_time_ms": 60, "memory_kb": 26436}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s566964810", "group_id": "codeNet:p02420", "input_text": "import java.util.ArrayList;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tfinal static String END_SIGN = \"-\";\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tArrayList resultList = new ArrayList();\n\n\t\tString str;\n\t\twhile (EndDecision(str = sc.nextLine())) {\n\n\t\t\tint shuffleCount = Integer.parseInt(sc.nextLine());\n\n\t\t\tfor (int i = 0; i < shuffleCount; i++) {\n\t\t\t\tstr = Shuffle(str, Integer.parseInt(sc.nextLine()));\n\t\t\t}\n\t\t\tresultList.add(str);\n\t\t}\n\n\t\tfor (String s : resultList) {\n\t\t\tSystem.out.println(s);\n\t\t}\n\n\t}\n\n\tstatic String Shuffle(String str, int num) {\n\t\tString result = str.substring(num);\n\t\tresult += str.substring(0, num);\n\t\treturn result;\n\t}\n\n\t// 終了判定\n\tpublic static boolean EndDecision(String array) {\n\t\tif (array.equals(END_SIGN)) {\n\t\t\treturn false;\n\t\t} else {\n\t\t\treturn true;\n\t\t}\n\n\t}\n\n}\n\n", "language": "Java", "metadata": {"date": 1524118225, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02420.html", "problem_id": "p02420", "resource_group": "high_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/Java/s566964810.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s566964810", "user_id": "u366739360"}, "prompt_components": {"gold_output": "aabc\nxyzvw\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tfinal static String END_SIGN = \"-\";\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tArrayList resultList = new ArrayList();\n\n\t\tString str;\n\t\twhile (EndDecision(str = sc.nextLine())) {\n\n\t\t\tint shuffleCount = Integer.parseInt(sc.nextLine());\n\n\t\t\tfor (int i = 0; i < shuffleCount; i++) {\n\t\t\t\tstr = Shuffle(str, Integer.parseInt(sc.nextLine()));\n\t\t\t}\n\t\t\tresultList.add(str);\n\t\t}\n\n\t\tfor (String s : resultList) {\n\t\t\tSystem.out.println(s);\n\t\t}\n\n\t}\n\n\tstatic String Shuffle(String str, int num) {\n\t\tString result = str.substring(num);\n\t\tresult += str.substring(0, num);\n\t\treturn result;\n\t}\n\n\t// 終了判定\n\tpublic static boolean EndDecision(String array) {\n\t\tif (array.equals(END_SIGN)) {\n\t\t\treturn false;\n\t\t} else {\n\t\t\treturn true;\n\t\t}\n\n\t}\n\n}\n\n", "problem_context": "Shuffle\n\nYour task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter.\n\nA single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck.\n\nThe deck of cards is represented by a string as follows.\n\nabcdeefab\n\nThe first character and the last character correspond to the card located at the bottom of the deck and the card on the top of the deck respectively.\n\nFor example, a shuffle with h = 4 to the above deck, moves the first 4 characters \"abcd\" to the end of the remaining characters \"eefab\", and generates the following deck:\n\neefababcd\n\nYou can repeat such shuffle operations.\n\nWrite a program which reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput\n\nThe input consists of multiple datasets. Each dataset is given in the following format:\n\nA string which represents a deck\nThe number of shuffle m\nh1\nh2\n.\n.\nhm\n\nThe input ends with a single character '-' for the string.\n\nConstraints\n\nThe length of the string ≤ 200\n\n1 ≤ m ≤ 100\n\n1 ≤ hi < The length of the string\n\nThe number of datasets ≤ 10\n\nOutput\n\nFor each dataset, print a string which represents the final state in a line.\n\nSample Input\n\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output\n\naabc\nxyzvw", "sample_input": "aabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n"}, "reference_outputs": ["aabc\nxyzvw\n"], "source_document_id": "p02420", "source_text": "Shuffle\n\nYour task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter.\n\nA single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck.\n\nThe deck of cards is represented by a string as follows.\n\nabcdeefab\n\nThe first character and the last character correspond to the card located at the bottom of the deck and the card on the top of the deck respectively.\n\nFor example, a shuffle with h = 4 to the above deck, moves the first 4 characters \"abcd\" to the end of the remaining characters \"eefab\", and generates the following deck:\n\neefababcd\n\nYou can repeat such shuffle operations.\n\nWrite a program which reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput\n\nThe input consists of multiple datasets. Each dataset is given in the following format:\n\nA string which represents a deck\nThe number of shuffle m\nh1\nh2\n.\n.\nhm\n\nThe input ends with a single character '-' for the string.\n\nConstraints\n\nThe length of the string ≤ 200\n\n1 ≤ m ≤ 100\n\n1 ≤ hi < The length of the string\n\nThe number of datasets ≤ 10\n\nOutput\n\nFor each dataset, print a string which represents the final state in a line.\n\nSample Input\n\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output\n\naabc\nxyzvw", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 869, "cpu_time_ms": 70, "memory_kb": 26336}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s488939673", "group_id": "codeNet:p02422", "input_text": "import java.util.Scanner;\n\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n String target = sc.next();\n int num = sc.nextInt();\n for(int i = 0; i < num; i++){\n String command = sc.next();\n int a = sc.nextInt();\n int b = sc.nextInt();\n String c = \"\";\n if(command.equals(\"replace\")){\n c = sc.next();\n }\n\n if(command.equals(\"print\")){\n System.out.println(target.substring(a, b));\n }else if(command.equals(\"reverse\")){\n char[] charArray = target.substring(a, b).toCharArray();\n String str = \"\";\n for(int j = charArray.length - 1; j >= 0; j--){\n str += charArray[j];\n }\n target = target.substring(0, a) + str + target.substring(b);\n }else if(command.equals(\"replace\")){\n target = target.substring(0, a) + c + target.substring(b);\n }\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1515072582, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02422.html", "problem_id": "p02422", "resource_group": "high_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/Java/s488939673.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s488939673", "user_id": "u928579315"}, "prompt_components": {"gold_output": "xaze\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n String target = sc.next();\n int num = sc.nextInt();\n for(int i = 0; i < num; i++){\n String command = sc.next();\n int a = sc.nextInt();\n int b = sc.nextInt();\n String c = \"\";\n if(command.equals(\"replace\")){\n c = sc.next();\n }\n\n if(command.equals(\"print\")){\n System.out.println(target.substring(a, b));\n }else if(command.equals(\"reverse\")){\n char[] charArray = target.substring(a, b).toCharArray();\n String str = \"\";\n for(int j = charArray.length - 1; j >= 0; j--){\n str += charArray[j];\n }\n target = target.substring(0, a) + str + target.substring(b);\n }else if(command.equals(\"replace\")){\n target = target.substring(0, a) + c + target.substring(b);\n }\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": 1076, "cpu_time_ms": 70, "memory_kb": 26152}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s909627626", "group_id": "codeNet:p02450", "input_text": "import java.util.Scanner;\npublic class Main {\n\tpublic static void main(String[] args){\n\t\ttry (Scanner sc = new Scanner(System.in)) {\n\t\t\tStringBuilder str = new StringBuilder();\n\t\t\tint n = sc.nextInt();\n\t\t\tfor(int i = 1; i < n + 1; i++) {\n\t\t\t\tstr.append(i);\n\t\t\t}\n\t\t\tpermutation(str.toString(),\"\");\n\t\t}\n\t}\n\tpublic static void permutation(String q, String ans){\n\t\tif(q.length() <= 1) {\n\t\t\tfor(char output : ans.toCharArray()) {\n\t\t\t\tSystem.out.print(output + \" \");\n\t\t\t}\n\t\t\tSystem.out.println(q);\n\t\t}\n\t\telse {\n\t\t\tfor (int i = 0; i < q.length(); i++) {\n\t\t\t\tpermutation(q.substring(0, i) + q.substring(i + 1), ans + q.charAt(i));\n\t\t\t}\n\t\t}\n\t}\n}\n", "language": "Java", "metadata": {"date": 1556009666, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02450.html", "problem_id": "p02450", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02450/input.txt", "sample_output_relpath": "derived/input_output/data/p02450/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02450/Java/s909627626.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s909627626", "user_id": "u132756922"}, "prompt_components": {"gold_output": "1 2\n2 1\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main {\n\tpublic static void main(String[] args){\n\t\ttry (Scanner sc = new Scanner(System.in)) {\n\t\t\tStringBuilder str = new StringBuilder();\n\t\t\tint n = sc.nextInt();\n\t\t\tfor(int i = 1; i < n + 1; i++) {\n\t\t\t\tstr.append(i);\n\t\t\t}\n\t\t\tpermutation(str.toString(),\"\");\n\t\t}\n\t}\n\tpublic static void permutation(String q, String ans){\n\t\tif(q.length() <= 1) {\n\t\t\tfor(char output : ans.toCharArray()) {\n\t\t\t\tSystem.out.print(output + \" \");\n\t\t\t}\n\t\t\tSystem.out.println(q);\n\t\t}\n\t\telse {\n\t\t\tfor (int i = 0; i < q.length(); i++) {\n\t\t\t\tpermutation(q.substring(0, i) + q.substring(i + 1), ans + q.charAt(i));\n\t\t\t}\n\t\t}\n\t}\n}\n", "problem_context": "Permutation Enumeration\n\nFor given an integer $n$, print all permutations of $\\{1, 2, ..., n\\}$ in lexicographic order.\n\nInput\n\nAn integer $n$ is given in a line.\n\nOutput\n\nPrint each permutation in a line in order. Separate adjacency elements by a space character.\n\nConstraints\n\n$1 \\leq n \\leq 9$\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1 2\n2 1\n\nSample Input 2\n\n3\n\nSample Output 2\n\n1 2 3\n1 3 2\n2 1 3\n2 3 1\n3 1 2\n3 2 1", "sample_input": "2\n"}, "reference_outputs": ["1 2\n2 1\n"], "source_document_id": "p02450", "source_text": "Permutation Enumeration\n\nFor given an integer $n$, print all permutations of $\\{1, 2, ..., n\\}$ in lexicographic order.\n\nInput\n\nAn integer $n$ is given in a line.\n\nOutput\n\nPrint each permutation in a line in order. Separate adjacency elements by a space character.\n\nConstraints\n\n$1 \\leq n \\leq 9$\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1 2\n2 1\n\nSample Input 2\n\n3\n\nSample Output 2\n\n1 2 3\n1 3 2\n2 1 3\n2 3 1\n3 1 2\n3 2 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": 637, "cpu_time_ms": 4610, "memory_kb": 106048}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s287617274", "group_id": "codeNet:p02468", "input_text": "\nimport java.text.DecimalFormat;\nimport java.util.stream.LongStream;\nimport java.util.stream.IntStream;\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n FastScanner sc = new FastScanner();\n PrintWriter out = new PrintWriter(System.out);\n\n AOJ problem = new AOJ(sc);\n problem.solve(out);\n\n out.flush();\n }\n\n}\n\nclass AOJ {\n\n final int m, n, mod;\n\n AOJ(FastScanner sc) {\n m = sc.nextInt();\n n = sc.nextInt();\n mod = (int) 1e9 + 7;\n }\n\n void solve(PrintWriter out) {\n out.println(pow(m, n));\n }\n\n long pow(long x, long n) {\n if (n == 0) return 1;\n long res = pow(x * x % mod, n / 2);\n if (n % 2 == 1) res = res * x % mod;\n return res;\n }\n}\n\nclass FastScanner {\n\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) {\n return buffer[ptr++];\n } else {\n return -1;\n }\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) {\n ptr++;\n }\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {\n throw new NumberFormatException();\n }\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n\n public int[] arrayInt(int N) {\n int[] array = new int[N];\n for (int i = 0; i < N; i++) {\n array[i] = nextInt();\n }\n return array;\n }\n\n public long[] arrayLong(int N) {\n long[] array = new long[N];\n for (int i = 0; i < N; i++) {\n array[i] = nextLong();\n }\n return array;\n }\n\n public double[] arrayDouble(int N) {\n double[] array = new double[N];\n for (int i = 0; i < N; i++) {\n array[i] = nextDouble();\n }\n return array;\n }\n\n public String[] arrayString(int N) {\n String[] array = new String[N];\n for (int i = 0; i < N; i++) {\n array[i] = next();\n }\n return array;\n }\n\n}\n\n", "language": "Java", "metadata": {"date": 1593176097, "filename_ext": "java", "original_language": "JAVA", "problem_description_relpath": "problem_descriptions/p02468.html", "problem_id": "p02468", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02468/input.txt", "sample_output_relpath": "derived/input_output/data/p02468/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02468/Java/s287617274.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s287617274", "user_id": "u299683143"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "\nimport java.text.DecimalFormat;\nimport java.util.stream.LongStream;\nimport java.util.stream.IntStream;\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n FastScanner sc = new FastScanner();\n PrintWriter out = new PrintWriter(System.out);\n\n AOJ problem = new AOJ(sc);\n problem.solve(out);\n\n out.flush();\n }\n\n}\n\nclass AOJ {\n\n final int m, n, mod;\n\n AOJ(FastScanner sc) {\n m = sc.nextInt();\n n = sc.nextInt();\n mod = (int) 1e9 + 7;\n }\n\n void solve(PrintWriter out) {\n out.println(pow(m, n));\n }\n\n long pow(long x, long n) {\n if (n == 0) return 1;\n long res = pow(x * x % mod, n / 2);\n if (n % 2 == 1) res = res * x % mod;\n return res;\n }\n}\n\nclass FastScanner {\n\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) {\n return buffer[ptr++];\n } else {\n return -1;\n }\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) {\n ptr++;\n }\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {\n throw new NumberFormatException();\n }\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n\n public int[] arrayInt(int N) {\n int[] array = new int[N];\n for (int i = 0; i < N; i++) {\n array[i] = nextInt();\n }\n return array;\n }\n\n public long[] arrayLong(int N) {\n long[] array = new long[N];\n for (int i = 0; i < N; i++) {\n array[i] = nextLong();\n }\n return array;\n }\n\n public double[] arrayDouble(int N) {\n double[] array = new double[N];\n for (int i = 0; i < N; i++) {\n array[i] = nextDouble();\n }\n return array;\n }\n\n public String[] arrayString(int N) {\n String[] array = new String[N];\n for (int i = 0; i < N; i++) {\n array[i] = next();\n }\n return array;\n }\n\n}\n\n", "problem_context": "Power\n\nFor given integers m and n, compute mn (mod 1,000,000,007). Here, A (mod M) is the remainder when A is divided by M.\n\nInput\n\nm n\n\nTwo integers m and n are given in a line.\n\nOutput\n\nPrint mn (mod 1,000,000,007) in a line.\n\nConstraints\n\n1 ≤ m ≤ 100\n\n1 ≤ n ≤ 109\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n8\n\nSample Input 2\n\n5 8\n\nSample Output 2\n\n390625", "sample_input": "2 3\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02468", "source_text": "Power\n\nFor given integers m and n, compute mn (mod 1,000,000,007). Here, A (mod M) is the remainder when A is divided by M.\n\nInput\n\nm n\n\nTwo integers m and n are given in a line.\n\nOutput\n\nPrint mn (mod 1,000,000,007) in a line.\n\nConstraints\n\n1 ≤ m ≤ 100\n\n1 ≤ n ≤ 109\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n8\n\nSample Input 2\n\n5 8\n\nSample Output 2\n\n390625", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3870, "cpu_time_ms": 50, "memory_kb": 24364}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s340916772", "group_id": "codeNet:p02534", "input_text": "import java.util.Scanner;\n\n\npublic class Main {\n\n\n\tpublic static void main(String[] args) {\n\t Scanner sc = new Scanner(System.in);\n\t int k = sc.nextInt();\n\n\t StringBuffer sb = new StringBuffer();\n\t for (int i = 0; i < k; i++) {\n\t \tsb.append(\"ACL\");\n\t }\n\n\t System.out.println(sb.toString());\n\t}\n\n\n}", "language": "Java", "metadata": {"date": 1601168593, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02534.html", "problem_id": "p02534", "resource_group": "high_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/Java/s340916772.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s340916772", "user_id": "u711908537"}, "prompt_components": {"gold_output": "ACLACLACL\n", "input_to_evaluate": "import java.util.Scanner;\n\n\npublic class Main {\n\n\n\tpublic static void main(String[] args) {\n\t Scanner sc = new Scanner(System.in);\n\t int k = sc.nextInt();\n\n\t StringBuffer sb = new StringBuffer();\n\t for (int i = 0; i < k; i++) {\n\t \tsb.append(\"ACL\");\n\t }\n\n\t System.out.println(sb.toString());\n\t}\n\n\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given an integer K.\nPrint the string obtained by repeating the string ACL K times and concatenating them.\n\nFor example, if K = 3, print ACLACLACL.\n\nConstraints\n\n1 \\leq K \\leq 5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the string obtained by repeating the string ACL K times and concatenating them.\n\nSample Input 1\n\n3\n\nSample Output 1\n\nACLACLACL", "sample_input": "3\n"}, "reference_outputs": ["ACLACLACL\n"], "source_document_id": "p02534", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given an integer K.\nPrint the string obtained by repeating the string ACL K times and concatenating them.\n\nFor example, if K = 3, print ACLACLACL.\n\nConstraints\n\n1 \\leq K \\leq 5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the string obtained by repeating the string ACL K times and concatenating them.\n\nSample Input 1\n\n3\n\nSample Output 1\n\nACLACLACL", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 318, "cpu_time_ms": 151, "memory_kb": 35700}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s247065015", "group_id": "codeNet:p02538", "input_text": "import java.io.BufferedReader;\nimport java.io.Closeable;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.PrintWriter;\nimport java.math.BigDecimal;\nimport java.math.BigInteger;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.Iterator;\nimport java.util.LinkedHashMap;\nimport java.util.LinkedList;\nimport java.util.ListIterator;\nimport java.util.Map.Entry;\n\nimport java.util.PriorityQueue;\nimport java.util.Random;\nimport java.util.StringTokenizer;\nimport java.util.TreeMap;\nimport java.util.TreeSet;\n\n\npublic class Main {\n\t\n\tpublic static final long MOD = 998244353;\n\t\n\tpublic static long mod_inv(long a, long m){\n\t\treturn (a == 1 ? 1 : (1 - m*mod_inv(m%a, a)) / a + m);\n\t}\n\t\n\tpublic static long[] fact_10_memo;\n\tpublic static long[][] suc_lazy_memo;\n\t\n\tpublic static class LazySetSumSegmentTree {\n\t\tint n;\n\t\tlong[] dat, lazy;\n\t\tboolean[] push;\n\n\t\tpublic LazySetSumSegmentTree(int n_) {\n\t\t\tint n = 1;\n\t\t\twhile(n < n_){ n *= 2; }\n\t\t\tthis.n = n;\n\t\t\tdat = new long[this.n * 2 - 1];\n\t\t\tlazy = new long[this.n * 2 - 1];\n\t\t\tpush = new boolean[this.n * 2 - 1];\n\t\t}\n\n\t\tprivate void evaluate_lazy(int k, int l, int r) {\n\t\t\tif(!push[k]){\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tdat[k] = suc_lazy_memo[(int)(lazy[k])][(r - l)];\n\t\t\tif(k < n - 1){\n\t\t\t\tlazy[k * 2 + 1] = lazy[k * 2 + 2] = lazy[k];\n\t\t\t\tpush[k * 2 + 1] = push[k * 2 + 2] = true;\n\t\t\t}\n\t\t\tlazy[k] = 0;\n\t\t\tpush[k] = false;\n\t\t}\n\n\t\tprivate void update_node(int k, int l, int r) {\n\t\t\tdat[k] = (((dat[k * 2 + 1] * fact_10_memo[(r - l) / 2]) % MOD) + (dat[k * 2 + 2])) % MOD;\n\t\t}\n\n\t\tpublic void set(long v, int a, int b) {\n\t\t\tset(v, a, b, 0, 0, this.n);\n\t\t}\n\n\t\tpublic void set(long v, int a, int b, int k, int l, int r) {\n\t\t\tevaluate_lazy(k, l, r);\n\t\t\tif(r <= a || b <= l){\n\t\t\t\treturn;\n\t\t\t}else if(a <= l && r <= b){\n\t\t\t\tlazy[k] = v;\n\t\t\t\tpush[k] = true;\n\t\t\t\tevaluate_lazy(k, l, r);\n\t\t\t}else{\n\t\t\t\tset(v, a, b, k * 2 + 1, l, (l + r) / 2);\n\t\t\t\tset(v, a, b, k * 2 + 2, (l + r) / 2, r);\n\t\t\t\tupdate_node(k, l, r);\n\t\t\t}\n\t\t}\n\n\t\tpublic long sum(int a, int b) {\n\t\t\treturn sum(a, b, 0, 0, this.n);\n\t\t}\n\n\t\tpublic long sum(int a, int b, int k, int l, int r) {\n\t\t\tevaluate_lazy(k, l, r);\n\t\t\tif(r <= a || b <= l){\n\t\t\t\treturn 0;\n\t\t\t}else if(a <= l && r <= b){\n\t\t\t\treturn dat[k];\n\t\t\t}else{\n\t\t\t\tfinal long v1 = sum(a, b, k * 2 + 1, l, (l + r) / 2);\n\t\t\t\tfinal long v2 = sum(a, b, k * 2 + 2, (l + r) / 2, r);\n\t\t\t\tupdate_node(k, l, r);\n\t\t\t\treturn ((v1 * fact_10_memo[(r - l) / 2] % MOD) + v2) % MOD;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args) throws IOException {\t\n\t\ttry(final Scanner sc = new Scanner(System.in)){\n\t\t\tfinal int N = sc.nextInt();\n\t\t\tfinal int Q = sc.nextInt();\n\t\t\t\n\t\t\tLazySetSumSegmentTree seg = new LazySetSumSegmentTree(N);\n\t\t\tfinal int size_diff = seg.n - N;\n\n\t\t\tfact_10_memo = new long[seg.n + 1];\n\t\t\tfact_10_memo[0] = 1;\n\t\t\tfor(int i = 0; i < seg.n; i++) {\n\t\t\t\tfact_10_memo[i + 1] = (fact_10_memo[i] * 10) % MOD;\n\t\t\t}\n\t\t\t\n\t\t\tsuc_lazy_memo = new long[10][seg.n + 1];\n\t\t\tfor(int i = 0; i < 10; i++) {\n\t\t\t\tsuc_lazy_memo[i][0] = 0;\n\t\t\t\tfor(int j = 0; j < seg.n; j++) {\n\t\t\t\t\tsuc_lazy_memo[i][j + 1] = (suc_lazy_memo[i][j] * 10 + i) % MOD;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tseg.set(1, 0, N);\n\t\t\t//System.out.println(seg.sum(0, N) * mod_inv(mod_pow(10, size_diff, MOD), MOD) % MOD);\n\t\t\t\n\t\t\tfinal long mod_size_diff = mod_inv(fact_10_memo[size_diff], MOD);\n\t\t\t\n\t\t\tPrintWriter out = new PrintWriter(System.out);\n\t\t\tfor(int q = 0; q < Q; q++) {\n\t\t\t\tfinal int l = sc.nextInt() - 1;\n\t\t\t\tfinal int r = sc.nextInt() - 1;\n\t\t\t\tfinal int D = sc.nextInt();\n\t\t\t\tseg.set(D, l, r + 1);\n\t\t\t\t\n\t\t\t\tout.println(seg.sum(0, N) * mod_size_diff % MOD);\n\t\t\t}\n\t\t\t\n\t\t\tout.flush();\n\t\t\t\n\t\t}\n\t}\n\n\tpublic static class Scanner implements Closeable {\n\t\tprivate BufferedReader br;\n\t\tprivate StringTokenizer tok;\n\n\t\tpublic Scanner(InputStream is) throws IOException {\n\t\t\tbr = new BufferedReader(new InputStreamReader(is));\n\t\t}\n\n\t\tprivate void getLine() throws IOException {\n\t\t\twhile(!hasNext()){\n\t\t\t\ttok = new StringTokenizer(br.readLine());\n\t\t\t}\n\t\t}\n\n\t\tprivate boolean hasNext() {\n\t\t\treturn tok != null && tok.hasMoreTokens();\n\t\t}\n\n\t\tpublic String next() throws IOException {\n\t\t\tgetLine();\n\t\t\treturn tok.nextToken();\n\t\t}\n\n\t\tpublic int nextInt() throws IOException {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tpublic long nextLong() throws IOException {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\t\t\n\n\t\tpublic double nextDouble() throws IOException {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tpublic int[] nextIntArray(int n) throws IOException {\n\t\t\tfinal int[] ret = new int[n];\n\t\t\tfor(int i = 0; i < n; i++){\n\t\t\t\tret[i] = this.nextInt();\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic long[] nextLongArray(int n) throws IOException {\n\t\t\tfinal long[] ret = new long[n];\n\t\t\tfor(int i = 0; i < n; i++){\n\t\t\t\tret[i] = this.nextLong();\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic void close() throws IOException {\n\t\t\tbr.close();\n\t\t}\n\t}\n}\n", "language": "Java", "metadata": {"date": 1601174235, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02538.html", "problem_id": "p02538", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02538/input.txt", "sample_output_relpath": "derived/input_output/data/p02538/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02538/Java/s247065015.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s247065015", "user_id": "u316432228"}, "prompt_components": {"gold_output": "11222211\n77772211\n77333333\n72333333\n72311333\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.Closeable;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.PrintWriter;\nimport java.math.BigDecimal;\nimport java.math.BigInteger;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.Iterator;\nimport java.util.LinkedHashMap;\nimport java.util.LinkedList;\nimport java.util.ListIterator;\nimport java.util.Map.Entry;\n\nimport java.util.PriorityQueue;\nimport java.util.Random;\nimport java.util.StringTokenizer;\nimport java.util.TreeMap;\nimport java.util.TreeSet;\n\n\npublic class Main {\n\t\n\tpublic static final long MOD = 998244353;\n\t\n\tpublic static long mod_inv(long a, long m){\n\t\treturn (a == 1 ? 1 : (1 - m*mod_inv(m%a, a)) / a + m);\n\t}\n\t\n\tpublic static long[] fact_10_memo;\n\tpublic static long[][] suc_lazy_memo;\n\t\n\tpublic static class LazySetSumSegmentTree {\n\t\tint n;\n\t\tlong[] dat, lazy;\n\t\tboolean[] push;\n\n\t\tpublic LazySetSumSegmentTree(int n_) {\n\t\t\tint n = 1;\n\t\t\twhile(n < n_){ n *= 2; }\n\t\t\tthis.n = n;\n\t\t\tdat = new long[this.n * 2 - 1];\n\t\t\tlazy = new long[this.n * 2 - 1];\n\t\t\tpush = new boolean[this.n * 2 - 1];\n\t\t}\n\n\t\tprivate void evaluate_lazy(int k, int l, int r) {\n\t\t\tif(!push[k]){\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tdat[k] = suc_lazy_memo[(int)(lazy[k])][(r - l)];\n\t\t\tif(k < n - 1){\n\t\t\t\tlazy[k * 2 + 1] = lazy[k * 2 + 2] = lazy[k];\n\t\t\t\tpush[k * 2 + 1] = push[k * 2 + 2] = true;\n\t\t\t}\n\t\t\tlazy[k] = 0;\n\t\t\tpush[k] = false;\n\t\t}\n\n\t\tprivate void update_node(int k, int l, int r) {\n\t\t\tdat[k] = (((dat[k * 2 + 1] * fact_10_memo[(r - l) / 2]) % MOD) + (dat[k * 2 + 2])) % MOD;\n\t\t}\n\n\t\tpublic void set(long v, int a, int b) {\n\t\t\tset(v, a, b, 0, 0, this.n);\n\t\t}\n\n\t\tpublic void set(long v, int a, int b, int k, int l, int r) {\n\t\t\tevaluate_lazy(k, l, r);\n\t\t\tif(r <= a || b <= l){\n\t\t\t\treturn;\n\t\t\t}else if(a <= l && r <= b){\n\t\t\t\tlazy[k] = v;\n\t\t\t\tpush[k] = true;\n\t\t\t\tevaluate_lazy(k, l, r);\n\t\t\t}else{\n\t\t\t\tset(v, a, b, k * 2 + 1, l, (l + r) / 2);\n\t\t\t\tset(v, a, b, k * 2 + 2, (l + r) / 2, r);\n\t\t\t\tupdate_node(k, l, r);\n\t\t\t}\n\t\t}\n\n\t\tpublic long sum(int a, int b) {\n\t\t\treturn sum(a, b, 0, 0, this.n);\n\t\t}\n\n\t\tpublic long sum(int a, int b, int k, int l, int r) {\n\t\t\tevaluate_lazy(k, l, r);\n\t\t\tif(r <= a || b <= l){\n\t\t\t\treturn 0;\n\t\t\t}else if(a <= l && r <= b){\n\t\t\t\treturn dat[k];\n\t\t\t}else{\n\t\t\t\tfinal long v1 = sum(a, b, k * 2 + 1, l, (l + r) / 2);\n\t\t\t\tfinal long v2 = sum(a, b, k * 2 + 2, (l + r) / 2, r);\n\t\t\t\tupdate_node(k, l, r);\n\t\t\t\treturn ((v1 * fact_10_memo[(r - l) / 2] % MOD) + v2) % MOD;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args) throws IOException {\t\n\t\ttry(final Scanner sc = new Scanner(System.in)){\n\t\t\tfinal int N = sc.nextInt();\n\t\t\tfinal int Q = sc.nextInt();\n\t\t\t\n\t\t\tLazySetSumSegmentTree seg = new LazySetSumSegmentTree(N);\n\t\t\tfinal int size_diff = seg.n - N;\n\n\t\t\tfact_10_memo = new long[seg.n + 1];\n\t\t\tfact_10_memo[0] = 1;\n\t\t\tfor(int i = 0; i < seg.n; i++) {\n\t\t\t\tfact_10_memo[i + 1] = (fact_10_memo[i] * 10) % MOD;\n\t\t\t}\n\t\t\t\n\t\t\tsuc_lazy_memo = new long[10][seg.n + 1];\n\t\t\tfor(int i = 0; i < 10; i++) {\n\t\t\t\tsuc_lazy_memo[i][0] = 0;\n\t\t\t\tfor(int j = 0; j < seg.n; j++) {\n\t\t\t\t\tsuc_lazy_memo[i][j + 1] = (suc_lazy_memo[i][j] * 10 + i) % MOD;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tseg.set(1, 0, N);\n\t\t\t//System.out.println(seg.sum(0, N) * mod_inv(mod_pow(10, size_diff, MOD), MOD) % MOD);\n\t\t\t\n\t\t\tfinal long mod_size_diff = mod_inv(fact_10_memo[size_diff], MOD);\n\t\t\t\n\t\t\tPrintWriter out = new PrintWriter(System.out);\n\t\t\tfor(int q = 0; q < Q; q++) {\n\t\t\t\tfinal int l = sc.nextInt() - 1;\n\t\t\t\tfinal int r = sc.nextInt() - 1;\n\t\t\t\tfinal int D = sc.nextInt();\n\t\t\t\tseg.set(D, l, r + 1);\n\t\t\t\t\n\t\t\t\tout.println(seg.sum(0, N) * mod_size_diff % MOD);\n\t\t\t}\n\t\t\t\n\t\t\tout.flush();\n\t\t\t\n\t\t}\n\t}\n\n\tpublic static class Scanner implements Closeable {\n\t\tprivate BufferedReader br;\n\t\tprivate StringTokenizer tok;\n\n\t\tpublic Scanner(InputStream is) throws IOException {\n\t\t\tbr = new BufferedReader(new InputStreamReader(is));\n\t\t}\n\n\t\tprivate void getLine() throws IOException {\n\t\t\twhile(!hasNext()){\n\t\t\t\ttok = new StringTokenizer(br.readLine());\n\t\t\t}\n\t\t}\n\n\t\tprivate boolean hasNext() {\n\t\t\treturn tok != null && tok.hasMoreTokens();\n\t\t}\n\n\t\tpublic String next() throws IOException {\n\t\t\tgetLine();\n\t\t\treturn tok.nextToken();\n\t\t}\n\n\t\tpublic int nextInt() throws IOException {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tpublic long nextLong() throws IOException {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\t\t\n\n\t\tpublic double nextDouble() throws IOException {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tpublic int[] nextIntArray(int n) throws IOException {\n\t\t\tfinal int[] ret = new int[n];\n\t\t\tfor(int i = 0; i < n; i++){\n\t\t\t\tret[i] = this.nextInt();\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic long[] nextLongArray(int n) throws IOException {\n\t\t\tfinal long[] ret = new long[n];\n\t\t\tfor(int i = 0; i < n; i++){\n\t\t\t\tret[i] = this.nextLong();\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic void close() throws IOException {\n\t\t\tbr.close();\n\t\t}\n\t}\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou have a string S of length N.\nInitially, all characters in S are 1s.\n\nYou will perform queries Q times.\nIn the i-th query, you are given two integers L_i, R_i and a character D_i (which is a digit).\nThen, you must replace all characters from the L_i-th to the R_i-th (inclusive) with D_i.\n\nAfter each query, read the string S as a decimal integer, and print its value modulo 998,244,353.\n\nConstraints\n\n1 \\leq N, Q \\leq 200,000\n\n1 \\leq L_i \\leq R_i \\leq N\n\n1 \\leq D_i \\leq 9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nL_1 R_1 D_1\n:\nL_Q R_Q D_Q\n\nOutput\n\nPrint Q lines.\nIn the i-th line print the value of S after the i-th query, modulo 998,244,353.\n\nSample Input 1\n\n8 5\n3 6 2\n1 4 7\n3 8 3\n2 2 2\n4 5 1\n\nSample Output 1\n\n11222211\n77772211\n77333333\n72333333\n72311333\n\nSample Input 2\n\n200000 1\n123 456 7\n\nSample Output 2\n\n641437905\n\nDon't forget to take the modulo.", "sample_input": "8 5\n3 6 2\n1 4 7\n3 8 3\n2 2 2\n4 5 1\n"}, "reference_outputs": ["11222211\n77772211\n77333333\n72333333\n72311333\n"], "source_document_id": "p02538", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou have a string S of length N.\nInitially, all characters in S are 1s.\n\nYou will perform queries Q times.\nIn the i-th query, you are given two integers L_i, R_i and a character D_i (which is a digit).\nThen, you must replace all characters from the L_i-th to the R_i-th (inclusive) with D_i.\n\nAfter each query, read the string S as a decimal integer, and print its value modulo 998,244,353.\n\nConstraints\n\n1 \\leq N, Q \\leq 200,000\n\n1 \\leq L_i \\leq R_i \\leq N\n\n1 \\leq D_i \\leq 9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nL_1 R_1 D_1\n:\nL_Q R_Q D_Q\n\nOutput\n\nPrint Q lines.\nIn the i-th line print the value of S after the i-th query, modulo 998,244,353.\n\nSample Input 1\n\n8 5\n3 6 2\n1 4 7\n3 8 3\n2 2 2\n4 5 1\n\nSample Output 1\n\n11222211\n77772211\n77333333\n72333333\n72311333\n\nSample Input 2\n\n200000 1\n123 456 7\n\nSample Output 2\n\n641437905\n\nDon't forget to take the modulo.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4975, "cpu_time_ms": 1034, "memory_kb": 91820}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s572625704", "group_id": "codeNet:p02546", "input_text": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n String input = scanner.next();\n scanner.close();\n\n if(input.endsWith(\"s\")){\n System.out.println(input + \"es\");\n }else{\n System.out.println(input+\"s\");\n }\n\n }\n\n}\n", "language": "Java", "metadata": {"date": 1600542591, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02546.html", "problem_id": "p02546", "resource_group": "high_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/Java/s572625704.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s572625704", "user_id": "u242435425"}, "prompt_components": {"gold_output": "apples\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n String input = scanner.next();\n scanner.close();\n\n if(input.endsWith(\"s\")){\n System.out.println(input + \"es\");\n }else{\n System.out.println(input+\"s\");\n }\n\n }\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": 364, "cpu_time_ms": 187, "memory_kb": 38504}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s816766625", "group_id": "codeNet:p02547", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int count = 0;\n boolean flg = false;\n for (int i = 0; i < N; i++) {\n int a = sc.nextInt();\n int b = sc.nextInt();\n if (a == b){\n count++;\n } else {\n count = 0;\n } \n if (count >= 3) {\n flg = true;\n break;\n }\n } \n if (flg == true) {\n System.out.print(\"Yes\");\n } else {\n System.out.print(\"No\");\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1600551648, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02547.html", "problem_id": "p02547", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02547/input.txt", "sample_output_relpath": "derived/input_output/data/p02547/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02547/Java/s816766625.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s816766625", "user_id": "u751338626"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int count = 0;\n boolean flg = false;\n for (int i = 0; i < N; i++) {\n int a = sc.nextInt();\n int b = sc.nextInt();\n if (a == b){\n count++;\n } else {\n count = 0;\n } \n if (count >= 3) {\n flg = true;\n break;\n }\n } \n if (flg == true) {\n System.out.print(\"Yes\");\n } else {\n System.out.print(\"No\");\n }\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTak performed the following action N times: rolling two dice.\nThe result of the i-th roll is D_{i,1} and D_{i,2}.\n\nCheck if doublets occurred at least three times in a row.\nSpecifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1\\leq D_{i,j} \\leq 6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_{1,1} D_{1,2}\n\\vdots\nD_{N,1} D_{N,2}\n\nOutput\n\nPrint Yes if doublets occurred at least three times in a row. Print No otherwise.\n\nSample Input 1\n\n5\n1 2\n6 6\n4 4\n3 3\n3 2\n\nSample Output 1\n\nYes\n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\nSample Input 2\n\n5\n1 1\n2 2\n3 4\n5 5\n6 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n\nSample Output 3\n\nYes", "sample_input": "5\n1 2\n6 6\n4 4\n3 3\n3 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02547", "source_text": "Score : 200 points\n\nProblem Statement\n\nTak performed the following action N times: rolling two dice.\nThe result of the i-th roll is D_{i,1} and D_{i,2}.\n\nCheck if doublets occurred at least three times in a row.\nSpecifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1\\leq D_{i,j} \\leq 6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_{1,1} D_{1,2}\n\\vdots\nD_{N,1} D_{N,2}\n\nOutput\n\nPrint Yes if doublets occurred at least three times in a row. Print No otherwise.\n\nSample Input 1\n\n5\n1 2\n6 6\n4 4\n3 3\n3 2\n\nSample Output 1\n\nYes\n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\nSample Input 2\n\n5\n1 1\n2 2\n3 4\n5 5\n6 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 681, "cpu_time_ms": 128, "memory_kb": 36032}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s496572936", "group_id": "codeNet:p02547", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.math.BigInteger;\nimport java.util.*;\nimport java.util.Map.Entry;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tFastScanner fs = new FastScanner();\n\t int n =fs.nextInt();\n\t int count=0;\n\t boolean present=false;\n\t while(n-->0) {\n\t \t int si=fs.nextInt();\n\t \t int ei =fs.nextInt();\n\t \t if(si==ei) {\n\t \t\t count++;\n\t \t }\n\t \t if(count==3) {\n\t \t\t present=true;\n\t \t }\n\t \t if(si!=ei) {\n\t \t\t count=0;\n\t \t }\n\t }\n\t if(present)System.out.println(\"Yes\");\n\t else System.out.println(\"No\");\n\t}\n\tstatic void sort(int[] a) {\n\t\tArrayList l = new ArrayList<>();\n\t\tfor(int i:a) l.add(i);\n\t\tCollections.sort(l);\n\t\tfor(int i=0;i0) {\n\t \t int si=fs.nextInt();\n\t \t int ei =fs.nextInt();\n\t \t if(si==ei) {\n\t \t\t count++;\n\t \t }\n\t \t if(count==3) {\n\t \t\t present=true;\n\t \t }\n\t \t if(si!=ei) {\n\t \t\t count=0;\n\t \t }\n\t }\n\t if(present)System.out.println(\"Yes\");\n\t else System.out.println(\"No\");\n\t}\n\tstatic void sort(int[] a) {\n\t\tArrayList l = new ArrayList<>();\n\t\tfor(int i:a) l.add(i);\n\t\tCollections.sort(l);\n\t\tfor(int i=0;i0)\n {\n int n=in.nextInt();\n if(n==1)pr.println(0);\n \n else pr.println(1);\n \n }\n pr.flush();\n }\n\n\n\n \n static int gcd(int a,int b)\n {\n \n if(a==0)\n return b;\n return gcd(a%b,b);\n }\n\n static int lcm(int a,int b)\n {\n return (a*b)/gcd(a,b);\n }\n\n\n static boolean prime[];\n\n static void sieveofe()\n {\n int n=1000000;\n \n prime=new boolean[n+1];\n Arrays.fill(prime,true);\n prime[1]=false;\n for(int i=2;i*i<=n;i++)\n {\n if(prime[i]==true)\n {\n for(int j=i*i;j<=n;j+=i)\n {\n prime[j]=false;\n }\n }\n }\n \n \n }\n \n static void sort(long[] a) {\n\t\tArrayList l = new ArrayList<>();\n\t\tfor (long i : a)\n\t\t\tl.add(i);\n\t\tCollections.sort(l);\n\t\tfor (int i = 0; i < a.length; i++)\n\t\t\ta[i] = l.get(i);\n\t}\n \n \n\tstatic void sort(int[] a) {\n\t\tArrayList l = new ArrayList<>();\n\t\tfor (int i : a)\n\t\t\tl.add(i);\n\t\tCollections.sort(l);\n\t\tfor (int i = 0; i < a.length; i++)\n\t\t\ta[i] = l.get(i);\n }\n\n \n static class FastReader\n { \n BufferedReader br; \n StringTokenizer st; \n\n public FastReader() \n { \n br = new BufferedReader(new\n InputStreamReader(System.in)); \n } \n\n String next() \n { \n while (st == null || !st.hasMoreElements()) \n { \n try\n { \n st = new StringTokenizer(br.readLine()); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n } \n\n int nextInt() \n { \n return Integer.parseInt(next()); \n } \n\n long nextLong() \n { \n return Long.parseLong(next()); \n } \n\n double nextDouble() \n { \n return Double.parseDouble(next()); \n } \n\n String nextLine() \n { \n String str = \"\"; \n try\n { \n str = br.readLine(); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n return str; \n } \n } \n\n \n \n}", "language": "Java", "metadata": {"date": 1600023673, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02552.html", "problem_id": "p02552", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02552/input.txt", "sample_output_relpath": "derived/input_output/data/p02552/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02552/Java/s158303351.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s158303351", "user_id": "u154002512"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "import java.util.*;\nimport java.util.Scanner;\nimport java.io.*;\nimport javax.lang.model.util.ElementScanner6; \n\npublic class Main\n{\n\n public static void main(String args[])\n { \n\n FastReader in=new FastReader();\n PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));\n int t=1;\n \n //t=in.nextInt();\n while(t-->0)\n {\n int n=in.nextInt();\n if(n==1)pr.println(0);\n \n else pr.println(1);\n \n }\n pr.flush();\n }\n\n\n\n \n static int gcd(int a,int b)\n {\n \n if(a==0)\n return b;\n return gcd(a%b,b);\n }\n\n static int lcm(int a,int b)\n {\n return (a*b)/gcd(a,b);\n }\n\n\n static boolean prime[];\n\n static void sieveofe()\n {\n int n=1000000;\n \n prime=new boolean[n+1];\n Arrays.fill(prime,true);\n prime[1]=false;\n for(int i=2;i*i<=n;i++)\n {\n if(prime[i]==true)\n {\n for(int j=i*i;j<=n;j+=i)\n {\n prime[j]=false;\n }\n }\n }\n \n \n }\n \n static void sort(long[] a) {\n\t\tArrayList l = new ArrayList<>();\n\t\tfor (long i : a)\n\t\t\tl.add(i);\n\t\tCollections.sort(l);\n\t\tfor (int i = 0; i < a.length; i++)\n\t\t\ta[i] = l.get(i);\n\t}\n \n \n\tstatic void sort(int[] a) {\n\t\tArrayList l = new ArrayList<>();\n\t\tfor (int i : a)\n\t\t\tl.add(i);\n\t\tCollections.sort(l);\n\t\tfor (int i = 0; i < a.length; i++)\n\t\t\ta[i] = l.get(i);\n }\n\n \n static class FastReader\n { \n BufferedReader br; \n StringTokenizer st; \n\n public FastReader() \n { \n br = new BufferedReader(new\n InputStreamReader(System.in)); \n } \n\n String next() \n { \n while (st == null || !st.hasMoreElements()) \n { \n try\n { \n st = new StringTokenizer(br.readLine()); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n } \n\n int nextInt() \n { \n return Integer.parseInt(next()); \n } \n\n long nextLong() \n { \n return Long.parseLong(next()); \n } \n\n double nextDouble() \n { \n return Double.parseDouble(next()); \n } \n\n String nextLine() \n { \n String str = \"\"; \n try\n { \n str = br.readLine(); \n } \n catch (IOException e) \n { \n e.printStackTrace(); \n } \n return str; \n } \n } \n\n \n \n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer x that is greater than or equal to 0, and less than or equal to 1.\nOutput 1 if x is equal to 0, or 0 if x is equal to 1.\n\nConstraints\n\n0 \\leq x \\leq 1\n\nx is an integer\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint 1 if x is equal to 0, or 0 if x is equal to 1.\n\nSample Input 1\n\n1\n\nSample Output 1\n\n0\n\nSample Input 2\n\n0\n\nSample Output 2\n\n1", "sample_input": "1\n"}, "reference_outputs": ["0\n"], "source_document_id": "p02552", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer x that is greater than or equal to 0, and less than or equal to 1.\nOutput 1 if x is equal to 0, or 0 if x is equal to 1.\n\nConstraints\n\n0 \\leq x \\leq 1\n\nx is an integer\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint 1 if x is equal to 0, or 0 if x is equal to 1.\n\nSample Input 1\n\n1\n\nSample Output 1\n\n0\n\nSample Input 2\n\n0\n\nSample Output 2\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2830, "cpu_time_ms": 95, "memory_kb": 32820}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s886513142", "group_id": "codeNet:p02553", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tlong a = sc.nextLong();\n\t\tlong b = sc.nextLong();\n\t\tlong c = sc.nextLong();\n\t\tlong d = sc.nextLong();\n\n\t\tlong ans = 0;\n\t\tif(a < 0 && b <= 0 && c < 0 && d <= 0) {\n\t\t\tans = a * c;\n\t\t\tSystem.out.print(ans);\n\t\t}else if(a < 0 && b <= 0) {\n\t\t\tif(c < 0) {\n\t\t\t\tans = a * c;\n\t\t\t\tSystem.out.print(ans);\n\t\t\t}else{\n\t\t\t\tans = b * c;\n\t\t\t\tSystem.out.print(ans);\n\t\t\t}\n\t\t}else if(c < 0 && d <= 0) {\n\t\t\tif(a < 0) {\n\t\t\t\tans = a * c;\n\t\t\t\tSystem.out.print(ans);\n\t\t\t}else{\n\t\t\t\tans = a * d;\n\t\t\t\tSystem.out.print(ans);\n\t\t\t}\n\t\t}else {\n\t\t\tans = b * d;\n\t\t\tSystem.out.print(ans);\n\t\t}\n\n\t\tsc.close();\n\t}\n}", "language": "Java", "metadata": {"date": 1600028652, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02553.html", "problem_id": "p02553", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02553/input.txt", "sample_output_relpath": "derived/input_output/data/p02553/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02553/Java/s886513142.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s886513142", "user_id": "u667687319"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tlong a = sc.nextLong();\n\t\tlong b = sc.nextLong();\n\t\tlong c = sc.nextLong();\n\t\tlong d = sc.nextLong();\n\n\t\tlong ans = 0;\n\t\tif(a < 0 && b <= 0 && c < 0 && d <= 0) {\n\t\t\tans = a * c;\n\t\t\tSystem.out.print(ans);\n\t\t}else if(a < 0 && b <= 0) {\n\t\t\tif(c < 0) {\n\t\t\t\tans = a * c;\n\t\t\t\tSystem.out.print(ans);\n\t\t\t}else{\n\t\t\t\tans = b * c;\n\t\t\t\tSystem.out.print(ans);\n\t\t\t}\n\t\t}else if(c < 0 && d <= 0) {\n\t\t\tif(a < 0) {\n\t\t\t\tans = a * c;\n\t\t\t\tSystem.out.print(ans);\n\t\t\t}else{\n\t\t\t\tans = a * d;\n\t\t\t\tSystem.out.print(ans);\n\t\t\t}\n\t\t}else {\n\t\t\tans = b * d;\n\t\t\tSystem.out.print(ans);\n\t\t}\n\n\t\tsc.close();\n\t}\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are integers a,b,c and d.\nIf x and y are integers and a \\leq x \\leq b and c\\leq y \\leq d hold, what is the maximum possible value of x \\times y?\n\nConstraints\n\n-10^9 \\leq a \\leq b \\leq 10^9\n\n-10^9 \\leq c \\leq d \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 2 1 1\n\nSample Output 1\n\n2\n\nIf x = 1 and y = 1 then x \\times y = 1.\nIf x = 2 and y = 1 then x \\times y = 2.\nTherefore, the answer is 2.\n\nSample Input 2\n\n3 5 -4 -2\n\nSample Output 2\n\n-6\n\nThe answer can be negative.\n\nSample Input 3\n\n-1000000000 0 -1000000000 0\n\nSample Output 3\n\n1000000000000000000", "sample_input": "1 2 1 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02553", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are integers a,b,c and d.\nIf x and y are integers and a \\leq x \\leq b and c\\leq y \\leq d hold, what is the maximum possible value of x \\times y?\n\nConstraints\n\n-10^9 \\leq a \\leq b \\leq 10^9\n\n-10^9 \\leq c \\leq d \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 2 1 1\n\nSample Output 1\n\n2\n\nIf x = 1 and y = 1 then x \\times y = 1.\nIf x = 2 and y = 1 then x \\times y = 2.\nTherefore, the answer is 2.\n\nSample Input 2\n\n3 5 -4 -2\n\nSample Output 2\n\n-6\n\nThe answer can be negative.\n\nSample Input 3\n\n-1000000000 0 -1000000000 0\n\nSample Output 3\n\n1000000000000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 724, "cpu_time_ms": 121, "memory_kb": 35768}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s847008492", "group_id": "codeNet:p02556", "input_text": "\nimport java.util.Scanner;\n\n/**\n * @author kep\n * @date 2020-09-14\n */\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int n = scanner.nextInt();\n long ans = 0;\n long[] max = new long[4];\n long[] min = new long[4];\n for(int i = 0;i<4;i++){\n max[i] = Long.MIN_VALUE;\n min[i] = Long.MAX_VALUE;\n }\n for(int i = 0;i> 1) == 1?-x:x;\n long tmp_y = (j & 1) == 1?-y:y;\n long tmp = tmp_x + tmp_y ;\n min[j] = Math.min(min[j],tmp);\n max[j] = Math.max(max[j],tmp);\n ans = Math.max(ans,max[j]-min[j]);\n }\n }\n System.out.println(ans);\n }\n}\n", "language": "Java", "metadata": {"date": 1600086224, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02556.html", "problem_id": "p02556", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02556/input.txt", "sample_output_relpath": "derived/input_output/data/p02556/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02556/Java/s847008492.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s847008492", "user_id": "u074473710"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "\nimport java.util.Scanner;\n\n/**\n * @author kep\n * @date 2020-09-14\n */\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int n = scanner.nextInt();\n long ans = 0;\n long[] max = new long[4];\n long[] min = new long[4];\n for(int i = 0;i<4;i++){\n max[i] = Long.MIN_VALUE;\n min[i] = Long.MAX_VALUE;\n }\n for(int i = 0;i> 1) == 1?-x:x;\n long tmp_y = (j & 1) == 1?-y:y;\n long tmp = tmp_x + tmp_y ;\n min[j] = Math.min(min[j],tmp);\n max[j] = Math.max(max[j],tmp);\n ans = Math.max(ans,max[j]-min[j]);\n }\n }\n System.out.println(ans);\n }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N points on the 2D plane, i-th of which is located on (x_i, y_i).\nThere can be multiple points that share the same coordinate.\nWhat is the maximum possible Manhattan distance between two distinct points?\n\nHere, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defined by |x_i-x_j| + |y_i-y_j|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq x_i,y_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 1\n2 4\n3 2\n\nSample Output 1\n\n4\n\nThe Manhattan distance between the first point and the second point is |1-2|+|1-4|=4, which is maximum possible.\n\nSample Input 2\n\n2\n1 1\n1 1\n\nSample Output 2\n\n0", "sample_input": "3\n1 1\n2 4\n3 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02556", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N points on the 2D plane, i-th of which is located on (x_i, y_i).\nThere can be multiple points that share the same coordinate.\nWhat is the maximum possible Manhattan distance between two distinct points?\n\nHere, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defined by |x_i-x_j| + |y_i-y_j|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq x_i,y_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 1\n2 4\n3 2\n\nSample Output 1\n\n4\n\nThe Manhattan distance between the first point and the second point is |1-2|+|1-4|=4, which is maximum possible.\n\nSample Input 2\n\n2\n1 1\n1 1\n\nSample Output 2\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 927, "cpu_time_ms": 698, "memory_kb": 60208}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s332811660", "group_id": "codeNet:p02556", "input_text": "import java.util.*;\n\n\npublic class Main {\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n String line = sc.nextLine();\n int num = Integer.parseInt(line);\n\n int[] xList = new int[num];\n int[] yList = new int[num];\n \n int[] xList2 = new int[2];\n int[] yList2 = new int[2];\n for (int i = 0; i < num; i++) {\n line = sc.nextLine();\n String[] lines = line.split(\" \", 0);\n int x = Integer.parseInt(lines[0]);\n int y = Integer.parseInt(lines[1]);\n xList[i] = x;\n yList[i] = y;\n \n if (i < 2) {\n xList2[i] = x;\n yList2[i] = y;\n } else {\n int manO = manh(xList2[0], yList2[0], xList2[1], yList2[1]);\n int man1 = manh(xList2[0], yList2[0], x, y);\n int man2 = manh(xList2[1], yList2[1], x, y);\n if (man1 > manO && man1 > man2) {\n xList2[1] = x;\n yList2[1] = y;\n } else if (man2 > manO && man2 > man1) {\n xList2[0] = x;\n yList2[0] = y;\n }\n }\n }\n\n long min = Long.MAX_VALUE;\n int minNumber = 0;\n int minX = Integer.MAX_VALUE;\n int minXNumber = 0;\n int maxX = 0;\n int maxXNumber = 0;\n int minY = Integer.MAX_VALUE;\n int minYNumber = 0;\n int maxY = 0;\n int maxYNumber = 0;\n long max = 0;\n int maxNumber = 0;\n for (int i = 0; i < num; i++) {\n if (xList[i] + yList[i] > max) {\n max = xList[i] + yList[i];\n maxNumber = i;\n }\n if (xList[i] + yList[i] < min) {\n min = xList[i] + yList[i];\n minNumber = i;\n }\n if (xList[i] > maxX) {\n maxX = xList[i];\n maxXNumber = i;\n }\n if (xList[i] < minX) {\n minX = xList[i];\n minXNumber = i;\n }\n if (yList[i] > maxY) {\n maxY = yList[i];\n maxYNumber = i;\n }\n if (yList[i] < minY) {\n minY = yList[i];\n minYNumber = i;\n }\n }\n\n int[] ret = new int[30];\n int b = minNumber;\n ret[0] = Math.abs(xList[maxNumber] - xList[b]) + Math.abs(yList[maxNumber] - yList[b]);\n ret[1] = Math.abs(xList[maxXNumber] - xList[b]) + Math.abs(yList[maxXNumber] - yList[b]);\n ret[2] = Math.abs(xList[minXNumber] - xList[b]) + Math.abs(yList[minXNumber] - yList[b]);\n ret[3] = Math.abs(xList[maxYNumber] - xList[b]) + Math.abs(yList[maxYNumber] - yList[b]);\n ret[4] = Math.abs(xList[minYNumber] - xList[b]) + Math.abs(yList[minYNumber] - yList[b]);\n\n b = maxNumber;\n ret[5] = Math.abs(xList[minNumber] - xList[b]) + Math.abs(yList[minNumber] - yList[b]);\n ret[6] = Math.abs(xList[maxXNumber] - xList[b]) + Math.abs(yList[maxXNumber] - yList[b]);\n ret[7] = Math.abs(xList[minXNumber] - xList[b]) + Math.abs(yList[minXNumber] - yList[b]);\n ret[8] = Math.abs(xList[maxYNumber] - xList[b]) + Math.abs(yList[maxYNumber] - yList[b]);\n ret[9] = Math.abs(xList[minYNumber] - xList[b]) + Math.abs(yList[minYNumber] - yList[b]);\n\n b = maxXNumber;\n ret[10] = Math.abs(xList[minNumber] - xList[b]) + Math.abs(yList[minNumber] - yList[b]);\n ret[11] = Math.abs(xList[maxNumber] - xList[b]) + Math.abs(yList[maxNumber] - yList[b]);\n ret[12] = Math.abs(xList[minXNumber] - xList[b]) + Math.abs(yList[minXNumber] - yList[b]);\n ret[13] = Math.abs(xList[maxYNumber] - xList[b]) + Math.abs(yList[maxYNumber] - yList[b]);\n ret[14] = Math.abs(xList[minYNumber] - xList[b]) + Math.abs(yList[minYNumber] - yList[b]);\n\n b = minXNumber;\n ret[15] = Math.abs(xList[minNumber] - xList[b]) + Math.abs(yList[minNumber] - yList[b]);\n ret[16] = Math.abs(xList[maxNumber] - xList[b]) + Math.abs(yList[maxNumber] - yList[b]);\n ret[17] = Math.abs(xList[maxXNumber] - xList[b]) + Math.abs(yList[maxXNumber] - yList[b]);\n ret[18] = Math.abs(xList[maxYNumber] - xList[b]) + Math.abs(yList[maxYNumber] - yList[b]);\n ret[19] = Math.abs(xList[minYNumber] - xList[b]) + Math.abs(yList[minYNumber] - yList[b]);\n\n b = maxYNumber;\n ret[20] = Math.abs(xList[minNumber] - xList[b]) + Math.abs(yList[minNumber] - yList[b]);\n ret[21] = Math.abs(xList[maxNumber] - xList[b]) + Math.abs(yList[maxNumber] - yList[b]);\n ret[22] = Math.abs(xList[minXNumber] - xList[b]) + Math.abs(yList[minXNumber] - yList[b]);\n ret[23] = Math.abs(xList[maxXNumber] - xList[b]) + Math.abs(yList[maxXNumber] - yList[b]);\n ret[24] = Math.abs(xList[minYNumber] - xList[b]) + Math.abs(yList[minYNumber] - yList[b]);\n\n b = minYNumber;\n ret[25] = Math.abs(xList[minNumber] - xList[b]) + Math.abs(yList[minNumber] - yList[b]);\n ret[26] = Math.abs(xList[maxNumber] - xList[b]) + Math.abs(yList[maxNumber] - yList[b]);\n ret[27] = Math.abs(xList[minXNumber] - xList[b]) + Math.abs(yList[minXNumber] - yList[b]);\n ret[28] = Math.abs(xList[maxYNumber] - xList[b]) + Math.abs(yList[maxYNumber] - yList[b]);\n ret[29] = Math.abs(xList[maxXNumber] - xList[b]) + Math.abs(yList[maxXNumber] - yList[b]);\n\n int result = 0;\n for (int i = 0; i < 30; i++) {\n if (ret[i] > result) {\n result = ret[i];\n }\n }\n int result2 = manh(xList2[0], yList2[0], xList2[1], yList2[1]);\n\n System.out.println(Math.max(result, result2));\n }\n\n public static int manh (int x1, int y1, int x2, int y2) {\n return Math.abs(x1 - x2) + Math.abs(y1 - y2);\n }\n}", "language": "Java", "metadata": {"date": 1600028043, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02556.html", "problem_id": "p02556", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02556/input.txt", "sample_output_relpath": "derived/input_output/data/p02556/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02556/Java/s332811660.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s332811660", "user_id": "u396971617"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*;\n\n\npublic class Main {\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n String line = sc.nextLine();\n int num = Integer.parseInt(line);\n\n int[] xList = new int[num];\n int[] yList = new int[num];\n \n int[] xList2 = new int[2];\n int[] yList2 = new int[2];\n for (int i = 0; i < num; i++) {\n line = sc.nextLine();\n String[] lines = line.split(\" \", 0);\n int x = Integer.parseInt(lines[0]);\n int y = Integer.parseInt(lines[1]);\n xList[i] = x;\n yList[i] = y;\n \n if (i < 2) {\n xList2[i] = x;\n yList2[i] = y;\n } else {\n int manO = manh(xList2[0], yList2[0], xList2[1], yList2[1]);\n int man1 = manh(xList2[0], yList2[0], x, y);\n int man2 = manh(xList2[1], yList2[1], x, y);\n if (man1 > manO && man1 > man2) {\n xList2[1] = x;\n yList2[1] = y;\n } else if (man2 > manO && man2 > man1) {\n xList2[0] = x;\n yList2[0] = y;\n }\n }\n }\n\n long min = Long.MAX_VALUE;\n int minNumber = 0;\n int minX = Integer.MAX_VALUE;\n int minXNumber = 0;\n int maxX = 0;\n int maxXNumber = 0;\n int minY = Integer.MAX_VALUE;\n int minYNumber = 0;\n int maxY = 0;\n int maxYNumber = 0;\n long max = 0;\n int maxNumber = 0;\n for (int i = 0; i < num; i++) {\n if (xList[i] + yList[i] > max) {\n max = xList[i] + yList[i];\n maxNumber = i;\n }\n if (xList[i] + yList[i] < min) {\n min = xList[i] + yList[i];\n minNumber = i;\n }\n if (xList[i] > maxX) {\n maxX = xList[i];\n maxXNumber = i;\n }\n if (xList[i] < minX) {\n minX = xList[i];\n minXNumber = i;\n }\n if (yList[i] > maxY) {\n maxY = yList[i];\n maxYNumber = i;\n }\n if (yList[i] < minY) {\n minY = yList[i];\n minYNumber = i;\n }\n }\n\n int[] ret = new int[30];\n int b = minNumber;\n ret[0] = Math.abs(xList[maxNumber] - xList[b]) + Math.abs(yList[maxNumber] - yList[b]);\n ret[1] = Math.abs(xList[maxXNumber] - xList[b]) + Math.abs(yList[maxXNumber] - yList[b]);\n ret[2] = Math.abs(xList[minXNumber] - xList[b]) + Math.abs(yList[minXNumber] - yList[b]);\n ret[3] = Math.abs(xList[maxYNumber] - xList[b]) + Math.abs(yList[maxYNumber] - yList[b]);\n ret[4] = Math.abs(xList[minYNumber] - xList[b]) + Math.abs(yList[minYNumber] - yList[b]);\n\n b = maxNumber;\n ret[5] = Math.abs(xList[minNumber] - xList[b]) + Math.abs(yList[minNumber] - yList[b]);\n ret[6] = Math.abs(xList[maxXNumber] - xList[b]) + Math.abs(yList[maxXNumber] - yList[b]);\n ret[7] = Math.abs(xList[minXNumber] - xList[b]) + Math.abs(yList[minXNumber] - yList[b]);\n ret[8] = Math.abs(xList[maxYNumber] - xList[b]) + Math.abs(yList[maxYNumber] - yList[b]);\n ret[9] = Math.abs(xList[minYNumber] - xList[b]) + Math.abs(yList[minYNumber] - yList[b]);\n\n b = maxXNumber;\n ret[10] = Math.abs(xList[minNumber] - xList[b]) + Math.abs(yList[minNumber] - yList[b]);\n ret[11] = Math.abs(xList[maxNumber] - xList[b]) + Math.abs(yList[maxNumber] - yList[b]);\n ret[12] = Math.abs(xList[minXNumber] - xList[b]) + Math.abs(yList[minXNumber] - yList[b]);\n ret[13] = Math.abs(xList[maxYNumber] - xList[b]) + Math.abs(yList[maxYNumber] - yList[b]);\n ret[14] = Math.abs(xList[minYNumber] - xList[b]) + Math.abs(yList[minYNumber] - yList[b]);\n\n b = minXNumber;\n ret[15] = Math.abs(xList[minNumber] - xList[b]) + Math.abs(yList[minNumber] - yList[b]);\n ret[16] = Math.abs(xList[maxNumber] - xList[b]) + Math.abs(yList[maxNumber] - yList[b]);\n ret[17] = Math.abs(xList[maxXNumber] - xList[b]) + Math.abs(yList[maxXNumber] - yList[b]);\n ret[18] = Math.abs(xList[maxYNumber] - xList[b]) + Math.abs(yList[maxYNumber] - yList[b]);\n ret[19] = Math.abs(xList[minYNumber] - xList[b]) + Math.abs(yList[minYNumber] - yList[b]);\n\n b = maxYNumber;\n ret[20] = Math.abs(xList[minNumber] - xList[b]) + Math.abs(yList[minNumber] - yList[b]);\n ret[21] = Math.abs(xList[maxNumber] - xList[b]) + Math.abs(yList[maxNumber] - yList[b]);\n ret[22] = Math.abs(xList[minXNumber] - xList[b]) + Math.abs(yList[minXNumber] - yList[b]);\n ret[23] = Math.abs(xList[maxXNumber] - xList[b]) + Math.abs(yList[maxXNumber] - yList[b]);\n ret[24] = Math.abs(xList[minYNumber] - xList[b]) + Math.abs(yList[minYNumber] - yList[b]);\n\n b = minYNumber;\n ret[25] = Math.abs(xList[minNumber] - xList[b]) + Math.abs(yList[minNumber] - yList[b]);\n ret[26] = Math.abs(xList[maxNumber] - xList[b]) + Math.abs(yList[maxNumber] - yList[b]);\n ret[27] = Math.abs(xList[minXNumber] - xList[b]) + Math.abs(yList[minXNumber] - yList[b]);\n ret[28] = Math.abs(xList[maxYNumber] - xList[b]) + Math.abs(yList[maxYNumber] - yList[b]);\n ret[29] = Math.abs(xList[maxXNumber] - xList[b]) + Math.abs(yList[maxXNumber] - yList[b]);\n\n int result = 0;\n for (int i = 0; i < 30; i++) {\n if (ret[i] > result) {\n result = ret[i];\n }\n }\n int result2 = manh(xList2[0], yList2[0], xList2[1], yList2[1]);\n\n System.out.println(Math.max(result, result2));\n }\n\n public static int manh (int x1, int y1, int x2, int y2) {\n return Math.abs(x1 - x2) + Math.abs(y1 - y2);\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N points on the 2D plane, i-th of which is located on (x_i, y_i).\nThere can be multiple points that share the same coordinate.\nWhat is the maximum possible Manhattan distance between two distinct points?\n\nHere, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defined by |x_i-x_j| + |y_i-y_j|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq x_i,y_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 1\n2 4\n3 2\n\nSample Output 1\n\n4\n\nThe Manhattan distance between the first point and the second point is |1-2|+|1-4|=4, which is maximum possible.\n\nSample Input 2\n\n2\n1 1\n1 1\n\nSample Output 2\n\n0", "sample_input": "3\n1 1\n2 4\n3 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02556", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N points on the 2D plane, i-th of which is located on (x_i, y_i).\nThere can be multiple points that share the same coordinate.\nWhat is the maximum possible Manhattan distance between two distinct points?\n\nHere, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defined by |x_i-x_j| + |y_i-y_j|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq x_i,y_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 1\n2 4\n3 2\n\nSample Output 1\n\n4\n\nThe Manhattan distance between the first point and the second point is |1-2|+|1-4|=4, which is maximum possible.\n\nSample Input 2\n\n2\n1 1\n1 1\n\nSample Output 2\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5899, "cpu_time_ms": 682, "memory_kb": 64168}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s259675089", "group_id": "codeNet:p02570", "input_text": "import java.util.*;\npublic class Main {\n\n public static void main(String[] args) {\n\n \n Scanner sc = new Scanner(System.in);\n\n \n int d = sc.nextInt();\n int t = sc.nextInt();\n int s = sc.nextInt();\n\n if (t >= d / s){\n System.out.println(\"Yes\");\n }else{\n System.out.println(\"No\");\n }\n }\n}", "language": "Java", "metadata": {"date": 1599215894, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02570.html", "problem_id": "p02570", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02570/input.txt", "sample_output_relpath": "derived/input_output/data/p02570/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02570/Java/s259675089.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s259675089", "user_id": "u821719138"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*;\npublic class Main {\n\n public static void main(String[] args) {\n\n \n Scanner sc = new Scanner(System.in);\n\n \n int d = sc.nextInt();\n int t = sc.nextInt();\n int s = sc.nextInt();\n\n if (t >= d / s){\n System.out.println(\"Yes\");\n }else{\n System.out.println(\"No\");\n }\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "sample_input": "1000 15 80\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02570", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 376, "cpu_time_ms": 122, "memory_kb": 35644}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s878992528", "group_id": "codeNet:p02570", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.StringTokenizer;\n\npublic class Main {\n\n\t static class FastReader \n\t { \n\t BufferedReader br; \n\t StringTokenizer st; \n\t \n\t public FastReader() \n\t { \n\t br = new BufferedReader(new\n\t InputStreamReader(System.in)); \n\t } \n\t \n\t String next() \n\t { \n\t while (st == null || !st.hasMoreElements()) \n\t { \n\t try\n\t { \n\t st = new StringTokenizer(br.readLine()); \n\t } \n\t catch (IOException e) \n\t { \n\t e.printStackTrace(); \n\t } \n\t } \n\t return st.nextToken(); \n\t } \n\t \n\t int nextInt() \n\t { \n\t return Integer.parseInt(next()); \n\t } \n\t \n\t long nextLong() \n\t { \n\t return Long.parseLong(next()); \n\t } \n\t \n\t double nextDouble() \n\t { \n\t return Double.parseDouble(next()); \n\t } \n\t \n\t String nextLine() \n\t { \n\t String str = \"\"; \n\t try\n\t { \n\t str = br.readLine(); \n\t } \n\t catch (IOException e) \n\t { \n\t e.printStackTrace(); \n\t } \n\t return str; \n\t } \n\t } \n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\n\t\tFastReader sc = new FastReader();\n\t\tdouble d = sc.nextDouble();\n\t\tdouble t = sc.nextDouble();\n\t\tdouble s = sc.nextInt();\n\t\t\n\t\tif(s!=0)\n\t\t{\n\t\tif(d/s <= t )\n\t\t{\n\t\t\tSystem.out.println(\"Yes\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tSystem.out.println(\"No\");\n\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tSystem.out.println(\"No\");\n\t\t}\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1598728607, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02570.html", "problem_id": "p02570", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02570/input.txt", "sample_output_relpath": "derived/input_output/data/p02570/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02570/Java/s878992528.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s878992528", "user_id": "u711981118"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.StringTokenizer;\n\npublic class Main {\n\n\t static class FastReader \n\t { \n\t BufferedReader br; \n\t StringTokenizer st; \n\t \n\t public FastReader() \n\t { \n\t br = new BufferedReader(new\n\t InputStreamReader(System.in)); \n\t } \n\t \n\t String next() \n\t { \n\t while (st == null || !st.hasMoreElements()) \n\t { \n\t try\n\t { \n\t st = new StringTokenizer(br.readLine()); \n\t } \n\t catch (IOException e) \n\t { \n\t e.printStackTrace(); \n\t } \n\t } \n\t return st.nextToken(); \n\t } \n\t \n\t int nextInt() \n\t { \n\t return Integer.parseInt(next()); \n\t } \n\t \n\t long nextLong() \n\t { \n\t return Long.parseLong(next()); \n\t } \n\t \n\t double nextDouble() \n\t { \n\t return Double.parseDouble(next()); \n\t } \n\t \n\t String nextLine() \n\t { \n\t String str = \"\"; \n\t try\n\t { \n\t str = br.readLine(); \n\t } \n\t catch (IOException e) \n\t { \n\t e.printStackTrace(); \n\t } \n\t return str; \n\t } \n\t } \n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\n\t\tFastReader sc = new FastReader();\n\t\tdouble d = sc.nextDouble();\n\t\tdouble t = sc.nextDouble();\n\t\tdouble s = sc.nextInt();\n\t\t\n\t\tif(s!=0)\n\t\t{\n\t\tif(d/s <= t )\n\t\t{\n\t\t\tSystem.out.println(\"Yes\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tSystem.out.println(\"No\");\n\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tSystem.out.println(\"No\");\n\t\t}\n\t}\n\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "sample_input": "1000 15 80\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02570", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1817, "cpu_time_ms": 82, "memory_kb": 33100}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s368710243", "group_id": "codeNet:p02570", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t Scanner sc = new Scanner(System.in);\n\t int d = sc.nextInt();\n\t int t = sc.nextInt();\n\t int s = sc.nextInt();\n\n\t if (Math.ceil(d / s) <= t) {\n\t \tSystem.out.println(\"Yes\");\n\t } else {\n\t \tSystem.out.println(\"No\");\n\t }\n\t}\n}", "language": "Java", "metadata": {"date": 1598727978, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02570.html", "problem_id": "p02570", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02570/input.txt", "sample_output_relpath": "derived/input_output/data/p02570/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02570/Java/s368710243.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s368710243", "user_id": "u711908537"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t Scanner sc = new Scanner(System.in);\n\t int d = sc.nextInt();\n\t int t = sc.nextInt();\n\t int s = sc.nextInt();\n\n\t if (Math.ceil(d / s) <= t) {\n\t \tSystem.out.println(\"Yes\");\n\t } else {\n\t \tSystem.out.println(\"No\");\n\t }\n\t}\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "sample_input": "1000 15 80\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02570", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 337, "cpu_time_ms": 153, "memory_kb": 35664}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s224287402", "group_id": "codeNet:p02570", "input_text": "import java.util.*;\n\n \npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tdouble d = sc.nextDouble();\n\t\tdouble t = sc.nextDouble();\n\t\tdouble s = sc.nextDouble();\n\n\t\tif(d / s <= t)\n\t\tSystem.out.println(\"Yes\");\n\t\telse\n\t\tSystem.out.println(\"No\");\n\t}\n}", "language": "Java", "metadata": {"date": 1598727910, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02570.html", "problem_id": "p02570", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02570/input.txt", "sample_output_relpath": "derived/input_output/data/p02570/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02570/Java/s224287402.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s224287402", "user_id": "u403519522"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*;\n\n \npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tdouble d = sc.nextDouble();\n\t\tdouble t = sc.nextDouble();\n\t\tdouble s = sc.nextDouble();\n\n\t\tif(d / s <= t)\n\t\tSystem.out.println(\"Yes\");\n\t\telse\n\t\tSystem.out.println(\"No\");\n\t}\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "sample_input": "1000 15 80\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02570", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 300, "cpu_time_ms": 139, "memory_kb": 37252}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s412117330", "group_id": "codeNet:p02570", "input_text": "import java.util.*;\nimport java.io.*;\nimport java.nio.charset.StandardCharsets;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tInputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);\n\t\tBufferedReader in = new BufferedReader(reader);\n\t\tMain ins = new Main(in);\n\t\tins.calc();\n\t\tins.showResult();\n\t}\n\n\tMain(BufferedReader in) throws IOException {\n\t\tString[] tokens = in.readLine().split(\" \");\n\t\tint D = Integer.parseInt(tokens[0]);\n\t\tint T = Integer.parseInt(tokens[1]);\n\t\tint S = Integer.parseInt(tokens[2]);\n\t\tif (T * S >= D) {\n\t\t\tSystem.out.println(\"Yes\");\n\t\t} else {\n\t\t\tSystem.out.println(\"No\");\n\t\t}\n\t}\n\n\tvoid calc() {\n\t}\n\n\tvoid showResult() {\n\t}\n}\n", "language": "Java", "metadata": {"date": 1598727699, "filename_ext": "java", "original_language": "Java (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02570.html", "problem_id": "p02570", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02570/input.txt", "sample_output_relpath": "derived/input_output/data/p02570/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02570/Java/s412117330.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s412117330", "user_id": "u655125439"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\nimport java.nio.charset.StandardCharsets;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tInputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);\n\t\tBufferedReader in = new BufferedReader(reader);\n\t\tMain ins = new Main(in);\n\t\tins.calc();\n\t\tins.showResult();\n\t}\n\n\tMain(BufferedReader in) throws IOException {\n\t\tString[] tokens = in.readLine().split(\" \");\n\t\tint D = Integer.parseInt(tokens[0]);\n\t\tint T = Integer.parseInt(tokens[1]);\n\t\tint S = Integer.parseInt(tokens[2]);\n\t\tif (T * S >= D) {\n\t\t\tSystem.out.println(\"Yes\");\n\t\t} else {\n\t\t\tSystem.out.println(\"No\");\n\t\t}\n\t}\n\n\tvoid calc() {\n\t}\n\n\tvoid showResult() {\n\t}\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "sample_input": "1000 15 80\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02570", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 717, "cpu_time_ms": 82, "memory_kb": 25348}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s622467682", "group_id": "codeNet:p02575", "input_text": "import java.io.DataInputStream;\nimport java.io.FileInputStream;\nimport java.io.IOException;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\n\npublic class Main {\n static class Reader\n {\n final private int BUFFER_SIZE = 1 << 16;\n private DataInputStream din;\n private byte[] buffer;\n private int bufferPointer, bytesRead;\n\n public Reader()\n {\n din = new DataInputStream(System.in);\n buffer = new byte[BUFFER_SIZE];\n bufferPointer = bytesRead = 0;\n }\n\n public Reader(String file_name) throws IOException\n {\n din = new DataInputStream(new FileInputStream(file_name));\n buffer = new byte[BUFFER_SIZE];\n bufferPointer = bytesRead = 0;\n }\n\n public String readLine() throws IOException\n {\n byte[] buf = new byte[1_000_010]; // line length\n int cnt = 0, c;\n while ((c = read()) != -1)\n {\n if (c == '\\n')\n break;\n buf[cnt++] = (byte) c;\n }\n return new String(buf, 0, cnt);\n }\n\n public int nextInt() throws IOException\n {\n int ret = 0;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n do\n {\n ret = ret * 10 + c - '0';\n } while ((c = read()) >= '0' && c <= '9');\n\n if (neg)\n return -ret;\n return ret;\n }\n\n public long nextLong() throws IOException\n {\n long ret = 0;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n do {\n ret = ret * 10 + c - '0';\n }\n while ((c = read()) >= '0' && c <= '9');\n if (neg)\n return -ret;\n return ret;\n }\n\n public double nextDouble() throws IOException\n {\n double ret = 0, div = 1;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n\n do {\n ret = ret * 10 + c - '0';\n }\n while ((c = read()) >= '0' && c <= '9');\n\n if (c == '.')\n {\n while ((c = read()) >= '0' && c <= '9')\n {\n ret += (c - '0') / (div *= 10);\n }\n }\n\n if (neg)\n return -ret;\n return ret;\n }\n\n private void fillBuffer() throws IOException\n {\n bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);\n if (bytesRead == -1)\n buffer[0] = -1;\n }\n\n private byte read() throws IOException\n {\n if (bufferPointer == bytesRead)\n fillBuffer();\n return buffer[bufferPointer++];\n }\n\n public void close() throws IOException\n {\n if (din == null)\n return;\n din.close();\n }\n }\n void solve(Reader sc, PrintWriter pw) throws IOException {\n int H, W;\n H = sc.nextInt();\n W = sc.nextInt();\n int INF = H * W + 1;\n int[][] grid = new int[H + 1][W + 1];\n for (int i = 1; i < grid.length; i++) {\n Arrays.fill(grid[i], INF);\n }\n int[] begin = new int[W];\n int[] end = new int[W];\n for (int i = 0; i < H; i++) {\n begin[i] = sc.nextInt() - 1;\n end[i] = sc.nextInt() - 1;\n }\n int[] result = new int[H];\n for (int i = 0; i < H; i++) {\n int rowMin = INF;\n for (int j = 0; j < W; j++) {\n if (i > 0) {\n rowMin = Math.min(rowMin, grid[i][j]);\n }\n// System.out.print(grid[i][j] + \" \");\n if (grid[i][j] == INF) {\n continue;\n }\n grid[i][j + 1] = Math.min(grid[i][j + 1], grid[i][j] + 1);\n if (j < begin[i] || j > end[i]) {\n grid[i + 1][j] = Math.min(grid[i + 1][j], grid[i][j] + 1);\n }\n }\n// System.out.println();\n if (i > 0)\n pw.println( rowMin == INF ? -1 : rowMin);\n }\n pw.println(-1);\n }\n public static void main(String[] args) throws IOException {\n Reader sc = new Reader();\n PrintWriter pw = new PrintWriter(System.out);\n// PrintWriter pw = new PrintWriter(System.out, true);\n new Main().solve(sc, pw);\n pw.flush();\n pw.close();\n sc.close();\n }\n}\n\n\n", "language": "Java", "metadata": {"date": 1598733429, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02575.html", "problem_id": "p02575", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02575/input.txt", "sample_output_relpath": "derived/input_output/data/p02575/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02575/Java/s622467682.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s622467682", "user_id": "u683869754"}, "prompt_components": {"gold_output": "1\n3\n6\n-1\n", "input_to_evaluate": "import java.io.DataInputStream;\nimport java.io.FileInputStream;\nimport java.io.IOException;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\n\npublic class Main {\n static class Reader\n {\n final private int BUFFER_SIZE = 1 << 16;\n private DataInputStream din;\n private byte[] buffer;\n private int bufferPointer, bytesRead;\n\n public Reader()\n {\n din = new DataInputStream(System.in);\n buffer = new byte[BUFFER_SIZE];\n bufferPointer = bytesRead = 0;\n }\n\n public Reader(String file_name) throws IOException\n {\n din = new DataInputStream(new FileInputStream(file_name));\n buffer = new byte[BUFFER_SIZE];\n bufferPointer = bytesRead = 0;\n }\n\n public String readLine() throws IOException\n {\n byte[] buf = new byte[1_000_010]; // line length\n int cnt = 0, c;\n while ((c = read()) != -1)\n {\n if (c == '\\n')\n break;\n buf[cnt++] = (byte) c;\n }\n return new String(buf, 0, cnt);\n }\n\n public int nextInt() throws IOException\n {\n int ret = 0;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n do\n {\n ret = ret * 10 + c - '0';\n } while ((c = read()) >= '0' && c <= '9');\n\n if (neg)\n return -ret;\n return ret;\n }\n\n public long nextLong() throws IOException\n {\n long ret = 0;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n do {\n ret = ret * 10 + c - '0';\n }\n while ((c = read()) >= '0' && c <= '9');\n if (neg)\n return -ret;\n return ret;\n }\n\n public double nextDouble() throws IOException\n {\n double ret = 0, div = 1;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n\n do {\n ret = ret * 10 + c - '0';\n }\n while ((c = read()) >= '0' && c <= '9');\n\n if (c == '.')\n {\n while ((c = read()) >= '0' && c <= '9')\n {\n ret += (c - '0') / (div *= 10);\n }\n }\n\n if (neg)\n return -ret;\n return ret;\n }\n\n private void fillBuffer() throws IOException\n {\n bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);\n if (bytesRead == -1)\n buffer[0] = -1;\n }\n\n private byte read() throws IOException\n {\n if (bufferPointer == bytesRead)\n fillBuffer();\n return buffer[bufferPointer++];\n }\n\n public void close() throws IOException\n {\n if (din == null)\n return;\n din.close();\n }\n }\n void solve(Reader sc, PrintWriter pw) throws IOException {\n int H, W;\n H = sc.nextInt();\n W = sc.nextInt();\n int INF = H * W + 1;\n int[][] grid = new int[H + 1][W + 1];\n for (int i = 1; i < grid.length; i++) {\n Arrays.fill(grid[i], INF);\n }\n int[] begin = new int[W];\n int[] end = new int[W];\n for (int i = 0; i < H; i++) {\n begin[i] = sc.nextInt() - 1;\n end[i] = sc.nextInt() - 1;\n }\n int[] result = new int[H];\n for (int i = 0; i < H; i++) {\n int rowMin = INF;\n for (int j = 0; j < W; j++) {\n if (i > 0) {\n rowMin = Math.min(rowMin, grid[i][j]);\n }\n// System.out.print(grid[i][j] + \" \");\n if (grid[i][j] == INF) {\n continue;\n }\n grid[i][j + 1] = Math.min(grid[i][j + 1], grid[i][j] + 1);\n if (j < begin[i] || j > end[i]) {\n grid[i + 1][j] = Math.min(grid[i + 1][j], grid[i][j] + 1);\n }\n }\n// System.out.println();\n if (i > 0)\n pw.println( rowMin == INF ? -1 : rowMin);\n }\n pw.println(-1);\n }\n public static void main(String[] args) throws IOException {\n Reader sc = new Reader();\n PrintWriter pw = new PrintWriter(System.out);\n// PrintWriter pw = new PrintWriter(System.out, true);\n new Main().solve(sc, pw);\n pw.flush();\n pw.close();\n sc.close();\n }\n}\n\n\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a grid of squares with H+1 horizontal rows and W vertical columns.\n\nYou will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \\ldots, B_i-th squares from the left in the i-th row from the top.\n\nFor each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print -1 instead.\n\nConstraints\n\n1 \\leq H,W \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nA_1 B_1\nA_2 B_2\n:\nA_H B_H\n\nOutput\n\nPrint H lines. The i-th line should contain the answer for the case k=i.\n\nSample Input 1\n\n4 4\n2 4\n1 1\n2 3\n2 4\n\nSample Output 1\n\n1\n3\n6\n-1\n\nLet (i,j) denote the square at the i-th row from the top and j-th column from the left.\n\nFor k=1, we need one move such as (1,1) → (2,1).\n\nFor k=2, we need three moves such as (1,1) → (2,1) → (2,2) → (3,2).\n\nFor k=3, we need six moves such as (1,1) → (2,1) → (2,2) → (3,2) → (3,3) → (3,4) → (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top.", "sample_input": "4 4\n2 4\n1 1\n2 3\n2 4\n"}, "reference_outputs": ["1\n3\n6\n-1\n"], "source_document_id": "p02575", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a grid of squares with H+1 horizontal rows and W vertical columns.\n\nYou will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \\ldots, B_i-th squares from the left in the i-th row from the top.\n\nFor each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print -1 instead.\n\nConstraints\n\n1 \\leq H,W \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nA_1 B_1\nA_2 B_2\n:\nA_H B_H\n\nOutput\n\nPrint H lines. The i-th line should contain the answer for the case k=i.\n\nSample Input 1\n\n4 4\n2 4\n1 1\n2 3\n2 4\n\nSample Output 1\n\n1\n3\n6\n-1\n\nLet (i,j) denote the square at the i-th row from the top and j-th column from the left.\n\nFor k=1, we need one move such as (1,1) → (2,1).\n\nFor k=2, we need three moves such as (1,1) → (2,1) → (2,2) → (3,2).\n\nFor k=3, we need six moves such as (1,1) → (2,1) → (2,2) → (3,2) → (3,3) → (3,4) → (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4925, "cpu_time_ms": 928, "memory_kb": 951320}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s019175316", "group_id": "codeNet:p02575", "input_text": "import java.io.*;\nimport java.util.*;\n\npublic class Main{\n\tstatic int inf=(int)1e9;\n\tstatic class segmentTree {\n\t\tlong[][]sTree;\n\t\tlong[]lazy;\n\t\tint N;\n\t\tint max;\n\t\tpublic segmentTree(int n) {//in array is 1-based array\n\t\t\tmax=n-1;\n\t\t\tN=1;\n\t\t\twhile(Nright || curRight=left && curRight<=right) {\n\t\t\t\treturn sTree[node];\n\t\t\t}\n\t\t\tint mid=(curLeft+curRight)>>1;\n\t\t\tint leftChild=node<<1,rightChild=node<<1|1;\n\t\t\tpropagate(node, curLeft, mid, curRight);\n\t\t\tlong[] q1=query(leftChild, curLeft, mid, left, right);\n\t\t\tlong[] q2=query(rightChild, mid+1, curRight, left, right);\n\t\t\t\n\t\t\tif(q1[0]+q1[1]>max && q2[0]+q2[1]>max) {\n\t\t\t\treturn new long[] {inf,inf};\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif(q1[0]+q1[1]>max) {\n\t\t\t\t\treturn q2;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif(q2[0]+q2[1]>max) {\n\t\t\t\t\t\treturn q1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(q1[0]>1;\n\t\t\tint leftChild=node<<1,rightChild=node<<1|1;\n\t\t\tpropagate(node, curLeft, mid, curRight);\n\t\t\tif(idx<=mid) {\n\t\t\t\treturn query_point(leftChild, curLeft, mid,idx);\n\t\t\t}\n\t\t\treturn query_point(rightChild, mid+1, curRight,idx);\n\t\t\t\t\t\n\t\t}\n\t\t\n\t\tvoid update_range(int i, int j, int val){\n\t\t\tupdate_range(1,1,N,i,j,val);\n\t\t}\n\t\t\n\t\tvoid update_range(int node,int curLeft,int curRight,int left,int right,int val) {\n\t\t\tif(curLeft>right || curRight=left && curRight<=right) {\n\t\t\t\tsTree[node][0] += val;\t\t\t\n\t\t\t\tlazy[node] += val;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tint mid=(curLeft+curRight)>>1;\n\t\t\tint leftChild=node<<1,rightChild=node<<1|1;\n\t\t\tpropagate(node, curLeft, mid, curRight);\n\t\t\tupdate_range(leftChild, curLeft, mid, left, right,val);\n\t\t\tupdate_range(rightChild, mid+1, curRight, left, right,val);\n\t\t\t\n\t\t\tif(sTree[leftChild][0]+sTree[leftChild][1]>max && sTree[rightChild][0]+sTree[rightChild][1]>max) {\n\t\t\t\tsTree[node]=new long[] {inf,inf};\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif(sTree[leftChild][0]+sTree[leftChild][1]>max) {\n\t\t\t\t\tsTree[node]=sTree[rightChild];\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif(sTree[rightChild][0]+sTree[rightChild][1]>max) {\n\t\t\t\t\t\tsTree[node]=sTree[leftChild];\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif(sTree[leftChild][0]>1;\n\t\t\tint leftChild=node<<1,rightChild=node<<1|1;\n\t\t\tpropagate(node, curLeft, mid, curRight);\n\t\t\tif(idx<=mid)\n\t\t\t\tupdate_Point(leftChild, curLeft, mid, idx, val);\n\t\t\telse\n\t\t\t\tupdate_Point(rightChild, mid+1, curRight, idx ,val);\n\t\t\t\n\t\t\tif(sTree[leftChild][0]+sTree[leftChild][1]>max && sTree[rightChild][0]+sTree[rightChild][1]>max) {\n\t\t\t\tsTree[node]=new long[] {inf,inf};\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif(sTree[leftChild][0]+sTree[leftChild][1]>max) {\n\t\t\t\t\tsTree[node]=sTree[rightChild];\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif(sTree[rightChild][0]+sTree[rightChild][1]>max) {\n\t\t\t\t\t\tsTree[node]=sTree[leftChild];\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tvoid propagate(int node, int b, int mid, int e){\n\t\t\tlazy[node<<1] += lazy[node];\n\t\t\tlazy[node<<1|1] += lazy[node];\n\t\t\tsTree[node<<1][0] += lazy[node];\t\t\n\t\t\tsTree[node<<1|1][0] += lazy[node];\t\t\n\t\t\tlazy[node] = 0;//the value that won't affect the required operation\n\t\t}\n\t\t\n\t}\n\tstatic void main() throws Exception{\n\t\tint n=sc.nextInt(),m=sc.nextInt();\n\t\tsegmentTree st=new segmentTree(m+1);\n\t\tint[]assign=new int[m+2];\n\t\tfor(int i=1;i<=m;i++) {\n\t\t\tassign[i]=i;\n\t\t}\n\t\tfor(int i=1;i<=n;i++) {\n\t\t\tint a=sc.nextInt(),b=sc.nextInt();\n\t\t\tint left=a,right=b-1;\n\t\t\tif(left<=right) {\n\t\t\t\tst.update_range(left, right, inf);\n\t\t\t}\n\t\t\tleft=assign[a];right=a-1;\n\t\t\tif(left<=right) {\n//\t\t\t\tSystem.out.println(left+\" \"+right+\" \"+(b-a+1));\n\t\t\t\tst.update_range(left, right, b-a+1);\n\t\t\t}\n\t\t\tst.update_Point(b, 1);\n\t\t\tassign[b+1]=assign[b];\n\t\t\tlong[]best=st.query(1, m);\n//\t\t\tSystem.out.println(Arrays.toString(best)+\" \"+Arrays.toString(st.query_point(1)));\n\t\t\tif(best[0]>=inf || best[0]+best[1]>m) {\n\t\t\t\tpw.println(-1);\n\t\t\t}\n\t\t\telse\n\t\t\t\tpw.println(i+best[0]);\n\t\t}\n\t}\n\tpublic static void main(String[] args) throws Exception{\n\t\tsc=new MScanner(System.in);\n\t\tpw = new PrintWriter(System.out);\n\t\tint tc=1;\n//\t\ttc=sc.nextInt();\n\t\twhile(tc-->0)\n\t\t\tmain();\n\t\tpw.flush();\n\t}\n\tstatic PrintWriter pw;\n\tstatic MScanner sc;\n\tstatic class MScanner {\n\t\tStringTokenizer st;\n\t\tBufferedReader br;\n\t\tpublic MScanner(InputStream system) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(system));\n\t\t}\n \n\t\tpublic MScanner(String file) throws Exception {\n\t\t\tbr = new BufferedReader(new FileReader(file));\n\t\t}\n \n\t\tpublic String next() throws IOException {\n\t\t\twhile (st == null || !st.hasMoreTokens())\n\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\treturn st.nextToken();\n\t\t}\n\t\tpublic int[] intArr(int n) throws IOException {\n\t int[]in=new int[n];for(int i=0;iright || curRight=left && curRight<=right) {\n\t\t\t\treturn sTree[node];\n\t\t\t}\n\t\t\tint mid=(curLeft+curRight)>>1;\n\t\t\tint leftChild=node<<1,rightChild=node<<1|1;\n\t\t\tpropagate(node, curLeft, mid, curRight);\n\t\t\tlong[] q1=query(leftChild, curLeft, mid, left, right);\n\t\t\tlong[] q2=query(rightChild, mid+1, curRight, left, right);\n\t\t\t\n\t\t\tif(q1[0]+q1[1]>max && q2[0]+q2[1]>max) {\n\t\t\t\treturn new long[] {inf,inf};\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif(q1[0]+q1[1]>max) {\n\t\t\t\t\treturn q2;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif(q2[0]+q2[1]>max) {\n\t\t\t\t\t\treturn q1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(q1[0]>1;\n\t\t\tint leftChild=node<<1,rightChild=node<<1|1;\n\t\t\tpropagate(node, curLeft, mid, curRight);\n\t\t\tif(idx<=mid) {\n\t\t\t\treturn query_point(leftChild, curLeft, mid,idx);\n\t\t\t}\n\t\t\treturn query_point(rightChild, mid+1, curRight,idx);\n\t\t\t\t\t\n\t\t}\n\t\t\n\t\tvoid update_range(int i, int j, int val){\n\t\t\tupdate_range(1,1,N,i,j,val);\n\t\t}\n\t\t\n\t\tvoid update_range(int node,int curLeft,int curRight,int left,int right,int val) {\n\t\t\tif(curLeft>right || curRight=left && curRight<=right) {\n\t\t\t\tsTree[node][0] += val;\t\t\t\n\t\t\t\tlazy[node] += val;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tint mid=(curLeft+curRight)>>1;\n\t\t\tint leftChild=node<<1,rightChild=node<<1|1;\n\t\t\tpropagate(node, curLeft, mid, curRight);\n\t\t\tupdate_range(leftChild, curLeft, mid, left, right,val);\n\t\t\tupdate_range(rightChild, mid+1, curRight, left, right,val);\n\t\t\t\n\t\t\tif(sTree[leftChild][0]+sTree[leftChild][1]>max && sTree[rightChild][0]+sTree[rightChild][1]>max) {\n\t\t\t\tsTree[node]=new long[] {inf,inf};\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif(sTree[leftChild][0]+sTree[leftChild][1]>max) {\n\t\t\t\t\tsTree[node]=sTree[rightChild];\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif(sTree[rightChild][0]+sTree[rightChild][1]>max) {\n\t\t\t\t\t\tsTree[node]=sTree[leftChild];\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif(sTree[leftChild][0]>1;\n\t\t\tint leftChild=node<<1,rightChild=node<<1|1;\n\t\t\tpropagate(node, curLeft, mid, curRight);\n\t\t\tif(idx<=mid)\n\t\t\t\tupdate_Point(leftChild, curLeft, mid, idx, val);\n\t\t\telse\n\t\t\t\tupdate_Point(rightChild, mid+1, curRight, idx ,val);\n\t\t\t\n\t\t\tif(sTree[leftChild][0]+sTree[leftChild][1]>max && sTree[rightChild][0]+sTree[rightChild][1]>max) {\n\t\t\t\tsTree[node]=new long[] {inf,inf};\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif(sTree[leftChild][0]+sTree[leftChild][1]>max) {\n\t\t\t\t\tsTree[node]=sTree[rightChild];\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif(sTree[rightChild][0]+sTree[rightChild][1]>max) {\n\t\t\t\t\t\tsTree[node]=sTree[leftChild];\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tvoid propagate(int node, int b, int mid, int e){\n\t\t\tlazy[node<<1] += lazy[node];\n\t\t\tlazy[node<<1|1] += lazy[node];\n\t\t\tsTree[node<<1][0] += lazy[node];\t\t\n\t\t\tsTree[node<<1|1][0] += lazy[node];\t\t\n\t\t\tlazy[node] = 0;//the value that won't affect the required operation\n\t\t}\n\t\t\n\t}\n\tstatic void main() throws Exception{\n\t\tint n=sc.nextInt(),m=sc.nextInt();\n\t\tsegmentTree st=new segmentTree(m+1);\n\t\tint[]assign=new int[m+2];\n\t\tfor(int i=1;i<=m;i++) {\n\t\t\tassign[i]=i;\n\t\t}\n\t\tfor(int i=1;i<=n;i++) {\n\t\t\tint a=sc.nextInt(),b=sc.nextInt();\n\t\t\tint left=a,right=b-1;\n\t\t\tif(left<=right) {\n\t\t\t\tst.update_range(left, right, inf);\n\t\t\t}\n\t\t\tleft=assign[a];right=a-1;\n\t\t\tif(left<=right) {\n//\t\t\t\tSystem.out.println(left+\" \"+right+\" \"+(b-a+1));\n\t\t\t\tst.update_range(left, right, b-a+1);\n\t\t\t}\n\t\t\tst.update_Point(b, 1);\n\t\t\tassign[b+1]=assign[b];\n\t\t\tlong[]best=st.query(1, m);\n//\t\t\tSystem.out.println(Arrays.toString(best)+\" \"+Arrays.toString(st.query_point(1)));\n\t\t\tif(best[0]>=inf || best[0]+best[1]>m) {\n\t\t\t\tpw.println(-1);\n\t\t\t}\n\t\t\telse\n\t\t\t\tpw.println(i+best[0]);\n\t\t}\n\t}\n\tpublic static void main(String[] args) throws Exception{\n\t\tsc=new MScanner(System.in);\n\t\tpw = new PrintWriter(System.out);\n\t\tint tc=1;\n//\t\ttc=sc.nextInt();\n\t\twhile(tc-->0)\n\t\t\tmain();\n\t\tpw.flush();\n\t}\n\tstatic PrintWriter pw;\n\tstatic MScanner sc;\n\tstatic class MScanner {\n\t\tStringTokenizer st;\n\t\tBufferedReader br;\n\t\tpublic MScanner(InputStream system) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(system));\n\t\t}\n \n\t\tpublic MScanner(String file) throws Exception {\n\t\t\tbr = new BufferedReader(new FileReader(file));\n\t\t}\n \n\t\tpublic String next() throws IOException {\n\t\t\twhile (st == null || !st.hasMoreTokens())\n\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\treturn st.nextToken();\n\t\t}\n\t\tpublic int[] intArr(int n) throws IOException {\n\t int[]in=new int[n];for(int i=0;i= a)min = Math.max(min, b);\n if(min > W)pn(-1);\n else pn(min+i-2);\n }\n }\n //SOLUTION END\n void hold(boolean b)throws Exception{if(!b)throw new Exception(\"Hold right there, Sparky!\");}\n void exit(boolean b){if(!b)System.exit(0);}\n static void dbg(Object... o){System.err.println(Arrays.deepToString(o));}\n final long IINF = (long)1e17;\n final int INF = (int)1e9+2;\n DecimalFormat df = new DecimalFormat(\"0.00000000000\");\n double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-8;\n static boolean multipleTC = false, memory = false, fileIO = false;\n FastReader in;PrintWriter out;\n void run() throws Exception{\n long ct = System.currentTimeMillis();\n if (fileIO) {\n in = new FastReader(\"\");\n out = new PrintWriter(\"\");\n } else {\n in = new FastReader();\n out = new PrintWriter(System.out);\n }\n //Solution Credits: Taranpreet Singh\n int T = multipleTC? ni():1;\n pre();\n for (int t = 1; t <= T; t++) solve(t);\n out.flush();\n out.close();\n System.err.println(System.currentTimeMillis() - ct);\n }\n public static void main(String[] args) throws Exception{\n if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();System.exit(1);}}}, \"1\", 1 << 28).start();\n else new Main().run();\n }\n int[][] make(int n, int e, int[] from, int[] to, boolean f){\n int[][] g = new int[n][];int[]cnt = new int[n];\n for(int i = 0; i< e; i++){\n cnt[from[i]]++;\n if(f)cnt[to[i]]++;\n }\n for(int i = 0; i< n; i++)g[i] = new int[cnt[i]];\n for(int i = 0; i< e; i++){\n g[from[i]][--cnt[from[i]]] = to[i];\n if(f)g[to[i]][--cnt[to[i]]] = from[i];\n }\n return g;\n }\n int[][][] makeS(int n, int e, int[] from, int[] to, boolean f){\n int[][][] g = new int[n][][];int[]cnt = new int[n];\n for(int i = 0; i< e; i++){\n cnt[from[i]]++;\n if(f)cnt[to[i]]++;\n }\n for(int i = 0; i< n; i++)g[i] = new int[cnt[i]][];\n for(int i = 0; i< e; i++){\n g[from[i]][--cnt[from[i]]] = new int[]{to[i], i, 0};\n if(f)g[to[i]][--cnt[to[i]]] = new int[]{from[i], i, 1};\n }\n return g;\n }\n int find(int[] set, int u){return set[u] = (set[u] == u?u:find(set, set[u]));}\n int digit(long s){int ans = 0;while(s>0){s/=10;ans++;}return ans;}\n long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}\n int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}\n int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}\n void p(Object... o){for(Object oo:o)out.print(oo+\" \");}\n void pn(Object... o){for(Object oo:o)out.print(oo+\" \");out.println();}\n void pni(Object... o){for(Object oo:o)out.print(oo+\" \");out.println();out.flush();}\n String n()throws Exception{return in.next();}\n String nln()throws Exception{return in.nextLine();}\n int ni()throws Exception{return Integer.parseInt(in.next());}\n long nl()throws Exception{return Long.parseLong(in.next());}\n double nd()throws Exception{return Double.parseDouble(in.next());}\n\n class FastReader{\n BufferedReader br;\n StringTokenizer st;\n public FastReader(){\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n\n public FastReader(String s) throws Exception{\n br = new BufferedReader(new FileReader(s));\n }\n\n String next() throws Exception{\n while (st == null || !st.hasMoreElements()){\n try{\n st = new StringTokenizer(br.readLine());\n }catch (IOException e){\n throw new Exception(e.toString());\n }\n }\n return st.nextToken();\n }\n\n String nextLine() throws Exception{\n String str;\n try{\n str = br.readLine();\n }catch (IOException e){\n throw new Exception(e.toString());\n }\n return str;\n }\n }\n}", "language": "Java", "metadata": {"date": 1598728735, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02575.html", "problem_id": "p02575", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02575/input.txt", "sample_output_relpath": "derived/input_output/data/p02575/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02575/Java/s457053837.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s457053837", "user_id": "u136104392"}, "prompt_components": {"gold_output": "1\n3\n6\n-1\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\nimport java.text.*;\n\nclass Main{\n //SOLUTION BEGIN\n //Into the Hardware Mode\n void pre() throws Exception{}\n void solve(int TC) throws Exception{\n int H = ni(), W = ni();\n int min = 1;\n for(int i = 2; i<= H+1; i++){\n int a = ni(), b = ni()+1;\n if(min >= a)min = Math.max(min, b);\n if(min > W)pn(-1);\n else pn(min+i-2);\n }\n }\n //SOLUTION END\n void hold(boolean b)throws Exception{if(!b)throw new Exception(\"Hold right there, Sparky!\");}\n void exit(boolean b){if(!b)System.exit(0);}\n static void dbg(Object... o){System.err.println(Arrays.deepToString(o));}\n final long IINF = (long)1e17;\n final int INF = (int)1e9+2;\n DecimalFormat df = new DecimalFormat(\"0.00000000000\");\n double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-8;\n static boolean multipleTC = false, memory = false, fileIO = false;\n FastReader in;PrintWriter out;\n void run() throws Exception{\n long ct = System.currentTimeMillis();\n if (fileIO) {\n in = new FastReader(\"\");\n out = new PrintWriter(\"\");\n } else {\n in = new FastReader();\n out = new PrintWriter(System.out);\n }\n //Solution Credits: Taranpreet Singh\n int T = multipleTC? ni():1;\n pre();\n for (int t = 1; t <= T; t++) solve(t);\n out.flush();\n out.close();\n System.err.println(System.currentTimeMillis() - ct);\n }\n public static void main(String[] args) throws Exception{\n if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();System.exit(1);}}}, \"1\", 1 << 28).start();\n else new Main().run();\n }\n int[][] make(int n, int e, int[] from, int[] to, boolean f){\n int[][] g = new int[n][];int[]cnt = new int[n];\n for(int i = 0; i< e; i++){\n cnt[from[i]]++;\n if(f)cnt[to[i]]++;\n }\n for(int i = 0; i< n; i++)g[i] = new int[cnt[i]];\n for(int i = 0; i< e; i++){\n g[from[i]][--cnt[from[i]]] = to[i];\n if(f)g[to[i]][--cnt[to[i]]] = from[i];\n }\n return g;\n }\n int[][][] makeS(int n, int e, int[] from, int[] to, boolean f){\n int[][][] g = new int[n][][];int[]cnt = new int[n];\n for(int i = 0; i< e; i++){\n cnt[from[i]]++;\n if(f)cnt[to[i]]++;\n }\n for(int i = 0; i< n; i++)g[i] = new int[cnt[i]][];\n for(int i = 0; i< e; i++){\n g[from[i]][--cnt[from[i]]] = new int[]{to[i], i, 0};\n if(f)g[to[i]][--cnt[to[i]]] = new int[]{from[i], i, 1};\n }\n return g;\n }\n int find(int[] set, int u){return set[u] = (set[u] == u?u:find(set, set[u]));}\n int digit(long s){int ans = 0;while(s>0){s/=10;ans++;}return ans;}\n long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}\n int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}\n int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}\n void p(Object... o){for(Object oo:o)out.print(oo+\" \");}\n void pn(Object... o){for(Object oo:o)out.print(oo+\" \");out.println();}\n void pni(Object... o){for(Object oo:o)out.print(oo+\" \");out.println();out.flush();}\n String n()throws Exception{return in.next();}\n String nln()throws Exception{return in.nextLine();}\n int ni()throws Exception{return Integer.parseInt(in.next());}\n long nl()throws Exception{return Long.parseLong(in.next());}\n double nd()throws Exception{return Double.parseDouble(in.next());}\n\n class FastReader{\n BufferedReader br;\n StringTokenizer st;\n public FastReader(){\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n\n public FastReader(String s) throws Exception{\n br = new BufferedReader(new FileReader(s));\n }\n\n String next() throws Exception{\n while (st == null || !st.hasMoreElements()){\n try{\n st = new StringTokenizer(br.readLine());\n }catch (IOException e){\n throw new Exception(e.toString());\n }\n }\n return st.nextToken();\n }\n\n String nextLine() throws Exception{\n String str;\n try{\n str = br.readLine();\n }catch (IOException e){\n throw new Exception(e.toString());\n }\n return str;\n }\n }\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a grid of squares with H+1 horizontal rows and W vertical columns.\n\nYou will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \\ldots, B_i-th squares from the left in the i-th row from the top.\n\nFor each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print -1 instead.\n\nConstraints\n\n1 \\leq H,W \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nA_1 B_1\nA_2 B_2\n:\nA_H B_H\n\nOutput\n\nPrint H lines. The i-th line should contain the answer for the case k=i.\n\nSample Input 1\n\n4 4\n2 4\n1 1\n2 3\n2 4\n\nSample Output 1\n\n1\n3\n6\n-1\n\nLet (i,j) denote the square at the i-th row from the top and j-th column from the left.\n\nFor k=1, we need one move such as (1,1) → (2,1).\n\nFor k=2, we need three moves such as (1,1) → (2,1) → (2,2) → (3,2).\n\nFor k=3, we need six moves such as (1,1) → (2,1) → (2,2) → (3,2) → (3,3) → (3,4) → (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top.", "sample_input": "4 4\n2 4\n1 1\n2 3\n2 4\n"}, "reference_outputs": ["1\n3\n6\n-1\n"], "source_document_id": "p02575", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a grid of squares with H+1 horizontal rows and W vertical columns.\n\nYou will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \\ldots, B_i-th squares from the left in the i-th row from the top.\n\nFor each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print -1 instead.\n\nConstraints\n\n1 \\leq H,W \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nA_1 B_1\nA_2 B_2\n:\nA_H B_H\n\nOutput\n\nPrint H lines. The i-th line should contain the answer for the case k=i.\n\nSample Input 1\n\n4 4\n2 4\n1 1\n2 3\n2 4\n\nSample Output 1\n\n1\n3\n6\n-1\n\nLet (i,j) denote the square at the i-th row from the top and j-th column from the left.\n\nFor k=1, we need one move such as (1,1) → (2,1).\n\nFor k=2, we need three moves such as (1,1) → (2,1) → (2,2) → (3,2).\n\nFor k=3, we need six moves such as (1,1) → (2,1) → (2,2) → (3,2) → (3,3) → (3,4) → (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4533, "cpu_time_ms": 446, "memory_kb": 58464}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s943439575", "group_id": "codeNet:p02576", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.*;\n public class Main\n {\n \tpublic static void main(String[]args)\n \t{\n \t\tScanner sc=new Scanner (System.in);\n \t\tint n=sc.nextInt();\n \t\tint x=sc.nextInt();\n \t\tint t=sc.nextInt();\n \t\tSystem.out.println((n/x)*t);\n \t}\n }", "language": "Java", "metadata": {"date": 1598465259, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02576.html", "problem_id": "p02576", "resource_group": "high_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/Java/s943439575.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s943439575", "user_id": "u722000554"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.*;\n public class Main\n {\n \tpublic static void main(String[]args)\n \t{\n \t\tScanner sc=new Scanner (System.in);\n \t\tint n=sc.nextInt();\n \t\tint x=sc.nextInt();\n \t\tint t=sc.nextInt();\n \t\tSystem.out.println((n/x)*t);\n \t}\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": 325, "cpu_time_ms": 121, "memory_kb": 35668}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s422554351", "group_id": "codeNet:p02576", "input_text": "import java.util.*;\n//import java.util.stream.Collectors;\n\npublic class Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint x = Integer.parseInt(sc.next());\n\t\tint t = Integer.parseInt(sc.next());\n\t\tlong time = 0;\n\t\twhile(n > 0){\n\t\t\tn -= x;\n\t\t\ttime += t;\n\t\t}\n\t\tSystem.out.println(time);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1598123250, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02576.html", "problem_id": "p02576", "resource_group": "high_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/Java/s422554351.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s422554351", "user_id": "u675269406"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "import java.util.*;\n//import java.util.stream.Collectors;\n\npublic class Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint x = Integer.parseInt(sc.next());\n\t\tint t = Integer.parseInt(sc.next());\n\t\tlong time = 0;\n\t\twhile(n > 0){\n\t\t\tn -= x;\n\t\t\ttime += t;\n\t\t}\n\t\tSystem.out.println(time);\n\t}\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi loves takoyaki - a ball-shaped snack.\n\nWith a takoyaki machine, he can make at most X pieces of takoyaki at a time, taking T minutes regardless of the number of pieces to make.\n\nHow long does it take to make N takoyaki?\n\nConstraints\n\n1 \\leq N,X,T \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X T\n\nOutput\n\nPrint an integer representing the minimum number of minutes needed to make N pieces of takoyaki.\n\nSample Input 1\n\n20 12 6\n\nSample Output 1\n\n12\n\nHe can make 12 pieces of takoyaki in the first 6 minutes and 8 more in the next 6 minutes, so he can make 20 in a total of 12 minutes.\n\nNote that being able to make 12 in 6 minutes does not mean he can make 2 in 1 minute.\n\nSample Input 2\n\n1000 1 1000\n\nSample Output 2\n\n1000000\n\nIt seems to take a long time to make this kind of takoyaki.", "sample_input": "20 12 6\n"}, "reference_outputs": ["12\n"], "source_document_id": "p02576", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi loves takoyaki - a ball-shaped snack.\n\nWith a takoyaki machine, he can make at most X pieces of takoyaki at a time, taking T minutes regardless of the number of pieces to make.\n\nHow long does it take to make N takoyaki?\n\nConstraints\n\n1 \\leq N,X,T \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X T\n\nOutput\n\nPrint an integer representing the minimum number of minutes needed to make N pieces of takoyaki.\n\nSample Input 1\n\n20 12 6\n\nSample Output 1\n\n12\n\nHe can make 12 pieces of takoyaki in the first 6 minutes and 8 more in the next 6 minutes, so he can make 20 in a total of 12 minutes.\n\nNote that being able to make 12 in 6 minutes does not mean he can make 2 in 1 minute.\n\nSample Input 2\n\n1000 1 1000\n\nSample Output 2\n\n1000000\n\nIt seems to take a long time to make this kind of takoyaki.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 373, "cpu_time_ms": 154, "memory_kb": 35532}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s496798007", "group_id": "codeNet:p02577", "input_text": "//Coded By Visnunathan\n\nimport java.io.*;\nimport java.util.*;\nimport java.text.*;\nimport java.math.*;\nimport java.lang.*;\n\npublic class Main {\n public static void main(String[] args) {\n FastScanner sc=new FastScanner();\n char[] line = sc.next().toCharArray();\n int sum = 0;\n for (char c:line) sum+=c-'0';\n System.out.println(sum%9==0?\"YES\":\"NO\");\n }\n // public static void main(String[] args) {\n // FastScanner fs=new FastScanner();\n // char[] line=fs.next().toCharArray();\n // int sum=0;\n // for (char c:line) sum+=c-'0';\n // System.out.println(sum%9==0?\"Yes\":\"No\");\n // }\n\n static final Random random=new Random();\n \n static void ruffleSort(int[] a) {\n int n=a.length;//shuffle, then sort \n for (int i=0; i void prtln(T t) { System.out.println(t); }\n}\n", "language": "Java", "metadata": {"date": 1598123978, "filename_ext": "java", "original_language": "Java (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02577.html", "problem_id": "p02577", "resource_group": "high_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/Java/s167144857.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s167144857", "user_id": "u176590289"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.math.BigInteger;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(final String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tBigInteger n = sc.nextBigInteger();\n\t\tsc.close();\n\t\tprtln(n.remainder(new BigInteger(\"9\")).equals(new BigInteger(\"0\")) ? \"Yes\" : \"No\");\n\t}\n\n\tpublic static void prtln(T t) { System.out.println(t); }\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": 370, "cpu_time_ms": 824, "memory_kb": 34372}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s320020074", "group_id": "codeNet:p02578", "input_text": "import java.util.Scanner;\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n int maxA = sc.nextInt();\n long res = 0;\n for(int i=1; i= upTo) usedFrom = N;\n int ret = table[usedFrom][upTo];\n if (ret != -1) return ret;\n ret = 0;\n if (upTo > 0) {\n ret = calc(usedFrom, upTo - 1);\n for (int i = 0; i < vals[upTo].length; i++) {\n int cur = vals[upTo][i];\n if (third[cur] == upTo) {\n int[] tmp = new int[3];\n int leftNeed = 0;\n if (first[cur] < upTo) tmp[leftNeed++] = first[cur];\n if (second[cur] < upTo) tmp[leftNeed++] = second[cur];\n if (usedFrom < upTo) tmp[leftNeed++] = usedFrom;\n if (leftNeed <= 2) {\n Arrays.sort(tmp, 0, leftNeed);\n if (leftNeed == 2) {\n int next = tmp[1];\n ret = Math.max(ret, fulls[next + 1][upTo] + 1 + calc(tmp[0], next));\n } else if (leftNeed == 1) {\n ret = Math.max(ret, 1 + calc(tmp[0], upTo - 1));\n } else {\n ret = Math.max(ret, 1 + calc(N, upTo - 1));\n }\n }\n }\n }\n }\n return table[usedFrom][upTo] = ret;\n }\n\n }\n\n static class MyScanner {\n private BufferedReader br;\n private StringTokenizer tokenizer;\n\n public MyScanner(InputStream is) {\n br = new BufferedReader(new InputStreamReader(is));\n }\n\n public String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1598248965, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02581.html", "problem_id": "p02581", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02581/input.txt", "sample_output_relpath": "derived/input_output/data/p02581/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02581/Java/s475115460.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s475115460", "user_id": "u592387631"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.StringTokenizer;\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author lucasr\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n MyScanner in = new MyScanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n FBraveCHAIN solver = new FBraveCHAIN();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class FBraveCHAIN {\n static int N;\n static int[][] table;\n static int[] first;\n static int[] second;\n static int[] third;\n static int[][] vals;\n static int[][] fulls;\n\n public void solve(int testNumber, MyScanner sc, PrintWriter out) {\n N = sc.nextInt();\n table = new int[N + 1][N + 1];\n for (int i = 0; i < N + 1; i++) {\n Arrays.fill(table[i], -1);\n }\n first = new int[N];\n Arrays.fill(first, -1);\n second = new int[N];\n Arrays.fill(second, -1);\n third = new int[N];\n Arrays.fill(third, -1);\n vals = new int[N + 1][];\n for (int i = 0; i <= N; i++) {\n int tot = 3;\n if (i == 0) tot = 2;\n else if (i == N) tot = 1;\n vals[i] = new int[tot];\n for (int j = 0; j < tot; j++) {\n int vv = sc.nextInt() - 1;\n vals[i][j] = vv;\n if (first[vv] == -1) {\n first[vv] = i;\n } else if (second[vv] == -1) {\n second[vv] = i;\n } else {\n third[vv] = i;\n }\n }\n }\n\n fulls = new int[N + 1][N + 2];\n for (int i = 0; i < N + 1; i++) {\n for (int j = i + 1; j < N + 2; j++) {\n fulls[i][j] = fulls[i][j - 1] + full(j - 1);\n }\n }\n out.println(calc(N, N));\n }\n\n static int full(int index) {\n if (0 < index && index < N) {\n if (vals[index][0] == vals[index][1] && vals[index][1] == vals[index][2]) return 1;\n }\n return 0;\n }\n\n static int calc(int usedFrom, int upTo) {\n if (usedFrom >= upTo) usedFrom = N;\n int ret = table[usedFrom][upTo];\n if (ret != -1) return ret;\n ret = 0;\n if (upTo > 0) {\n ret = calc(usedFrom, upTo - 1);\n for (int i = 0; i < vals[upTo].length; i++) {\n int cur = vals[upTo][i];\n if (third[cur] == upTo) {\n int[] tmp = new int[3];\n int leftNeed = 0;\n if (first[cur] < upTo) tmp[leftNeed++] = first[cur];\n if (second[cur] < upTo) tmp[leftNeed++] = second[cur];\n if (usedFrom < upTo) tmp[leftNeed++] = usedFrom;\n if (leftNeed <= 2) {\n Arrays.sort(tmp, 0, leftNeed);\n if (leftNeed == 2) {\n int next = tmp[1];\n ret = Math.max(ret, fulls[next + 1][upTo] + 1 + calc(tmp[0], next));\n } else if (leftNeed == 1) {\n ret = Math.max(ret, 1 + calc(tmp[0], upTo - 1));\n } else {\n ret = Math.max(ret, 1 + calc(N, upTo - 1));\n }\n }\n }\n }\n }\n return table[usedFrom][upTo] = ret;\n }\n\n }\n\n static class MyScanner {\n private BufferedReader br;\n private StringTokenizer tokenizer;\n\n public MyScanner(InputStream is) {\n br = new BufferedReader(new InputStreamReader(is));\n }\n\n public String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n }\n}\n\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have 3N cards arranged in a row from left to right, where each card has an integer between 1 and N (inclusive) written on it. The integer written on the i-th card from the left is A_i.\n\nYou will do the following operation N-1 times:\n\nRearrange the five leftmost cards in any order you like, then remove the three leftmost cards. If the integers written on those three cards are all equal, you gain 1 point.\n\nAfter these N-1 operations, if the integers written on the remaining three cards are all equal, you will gain 1 additional point.\n\nFind the maximum number of points you can gain.\n\nConstraints\n\n1 \\leq N \\leq 2000\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 \\cdots A_{3N}\n\nOutput\n\nPrint the maximum number of points you can gain.\n\nSample Input 1\n\n2\n1 2 1 2 2 1\n\nSample Output 1\n\n2\n\nLet us rearrange the five leftmost cards so that the integers written on the six cards will be 2\\ 2\\ 2\\ 1\\ 1\\ 1 from left to right.\n\nThen, remove the three leftmost cards, all of which have the same integer 2, gaining 1 point.\n\nNow, the integers written on the remaining cards are 1\\ 1\\ 1.\n\nSince these three cards have the same integer 1, we gain 1 more point.\n\nIn this way, we can gain 2 points - which is the maximum possible.\n\nSample Input 2\n\n3\n1 1 2 2 3 3 3 2 1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1 1 2 2 2 3 3 3 1\n\nSample Output 3\n\n3", "sample_input": "2\n1 2 1 2 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02581", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have 3N cards arranged in a row from left to right, where each card has an integer between 1 and N (inclusive) written on it. The integer written on the i-th card from the left is A_i.\n\nYou will do the following operation N-1 times:\n\nRearrange the five leftmost cards in any order you like, then remove the three leftmost cards. If the integers written on those three cards are all equal, you gain 1 point.\n\nAfter these N-1 operations, if the integers written on the remaining three cards are all equal, you will gain 1 additional point.\n\nFind the maximum number of points you can gain.\n\nConstraints\n\n1 \\leq N \\leq 2000\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 \\cdots A_{3N}\n\nOutput\n\nPrint the maximum number of points you can gain.\n\nSample Input 1\n\n2\n1 2 1 2 2 1\n\nSample Output 1\n\n2\n\nLet us rearrange the five leftmost cards so that the integers written on the six cards will be 2\\ 2\\ 2\\ 1\\ 1\\ 1 from left to right.\n\nThen, remove the three leftmost cards, all of which have the same integer 2, gaining 1 point.\n\nNow, the integers written on the remaining cards are 1\\ 1\\ 1.\n\nSince these three cards have the same integer 1, we gain 1 more point.\n\nIn this way, we can gain 2 points - which is the maximum possible.\n\nSample Input 2\n\n3\n1 1 2 2 3 3 3 2 1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1 1 2 2 2 3 3 3 1\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": 4791, "cpu_time_ms": 216, "memory_kb": 85380}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s444703527", "group_id": "codeNet:p02582", "input_text": "import java.util.Scanner;\n \npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n \tString rain = sc.next();\n \n \tif (rain.contains(\"R\")) {\n System.out.println(1);\n } else if(rain.contains(\"RR\")) {\n\t\t System.out.println(2);\n } else if(rain.contains(\"RRR\")) {\n\t System.out.println(3);\n } else {\n System.out.println(0);\n }\n\t\tsc.close();\n\t}\n \n}", "language": "Java", "metadata": {"date": 1598873465, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02582.html", "problem_id": "p02582", "resource_group": "high_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/Java/s444703527.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s444703527", "user_id": "u367060939"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner;\n \npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n \tString rain = sc.next();\n \n \tif (rain.contains(\"R\")) {\n System.out.println(1);\n } else if(rain.contains(\"RR\")) {\n\t\t System.out.println(2);\n } else if(rain.contains(\"RRR\")) {\n\t System.out.println(3);\n } else {\n System.out.println(0);\n }\n\t\tsc.close();\n\t}\n \n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.\n\nFind the maximum number of consecutive rainy days in this period.\n\nConstraints\n\n|S| = 3\n\nEach character of S is S or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of consecutive rainy days in the period.\n\nSample Input 1\n\nRRS\n\nSample Output 1\n\n2\n\nWe had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.\n\nSample Input 2\n\nSSS\n\nSample Output 2\n\n0\n\nIt was sunny throughout the period. We had no rainy days, so we should print 0.\n\nSample Input 3\n\nRSR\n\nSample Output 3\n\n1\n\nWe had rain on the 1-st and 3-rd days - two \"streaks\" of one rainy day, so we should print 1.", "sample_input": "RRS\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02582", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.\n\nFind the maximum number of consecutive rainy days in this period.\n\nConstraints\n\n|S| = 3\n\nEach character of S is S or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of consecutive rainy days in the period.\n\nSample Input 1\n\nRRS\n\nSample Output 1\n\n2\n\nWe had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.\n\nSample Input 2\n\nSSS\n\nSample Output 2\n\n0\n\nIt was sunny throughout the period. We had no rainy days, so we should print 0.\n\nSample Input 3\n\nRSR\n\nSample Output 3\n\n1\n\nWe had rain on the 1-st and 3-rd days - two \"streaks\" of one rainy day, so we should print 1.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 454, "cpu_time_ms": 115, "memory_kb": 35604}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s095070781", "group_id": "codeNet:p02582", "input_text": "import java.util.Scanner;\n\npublic class Main{\n\tpublic static void main(String args[]){\n test_ans();\n }\n\n private static void test_mine(){\n Scanner scan = new Scanner(System.in);\n String s = scan.next();\n\n int count = 0;\n if(s.charAt(1) == 'S'){\n if(s.charAt(0) == 'R' || s.charAt(2) == 'R')\n count = 1;\n else\n count = 0;\n }else{\n if(s.charAt(0) == 'R'){\n if(s.charAt(2) == 'R'){\n count = 3;\n }else{\n count = 2;\n }\n }else if(s.charAt(2) == 'R'){\n if(s.charAt(0) == 'R'){\n count = 3;\n }else{\n count = 2;\n }\n }else\n count = 1;\n }\n System.out.println(count);\n }\n\n private static void test_ans(){\n Scanner scan = new Scanner(System.in);\n String s = scan.next();\n \n boolean p = s.charAt(0) == 'R';\n boolean q = s.charAt(1) == 'R';\n boolean r = s.charAt(2) == 'R';\n\n int count = 0;\n if(p && q && r)\n count = 3;\n else if((p && q) || (q && r))\n count = 2;\n else if(p || q || r)\n count = 1;\n else\n count = 0;\n\n System.out.println(count);\n }\n}", "language": "Java", "metadata": {"date": 1598019323, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02582.html", "problem_id": "p02582", "resource_group": "high_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/Java/s095070781.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s095070781", "user_id": "u079088332"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main{\n\tpublic static void main(String args[]){\n test_ans();\n }\n\n private static void test_mine(){\n Scanner scan = new Scanner(System.in);\n String s = scan.next();\n\n int count = 0;\n if(s.charAt(1) == 'S'){\n if(s.charAt(0) == 'R' || s.charAt(2) == 'R')\n count = 1;\n else\n count = 0;\n }else{\n if(s.charAt(0) == 'R'){\n if(s.charAt(2) == 'R'){\n count = 3;\n }else{\n count = 2;\n }\n }else if(s.charAt(2) == 'R'){\n if(s.charAt(0) == 'R'){\n count = 3;\n }else{\n count = 2;\n }\n }else\n count = 1;\n }\n System.out.println(count);\n }\n\n private static void test_ans(){\n Scanner scan = new Scanner(System.in);\n String s = scan.next();\n \n boolean p = s.charAt(0) == 'R';\n boolean q = s.charAt(1) == 'R';\n boolean r = s.charAt(2) == 'R';\n\n int count = 0;\n if(p && q && r)\n count = 3;\n else if((p && q) || (q && r))\n count = 2;\n else if(p || q || r)\n count = 1;\n else\n count = 0;\n\n System.out.println(count);\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.\n\nFind the maximum number of consecutive rainy days in this period.\n\nConstraints\n\n|S| = 3\n\nEach character of S is S or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of consecutive rainy days in the period.\n\nSample Input 1\n\nRRS\n\nSample Output 1\n\n2\n\nWe had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.\n\nSample Input 2\n\nSSS\n\nSample Output 2\n\n0\n\nIt was sunny throughout the period. We had no rainy days, so we should print 0.\n\nSample Input 3\n\nRSR\n\nSample Output 3\n\n1\n\nWe had rain on the 1-st and 3-rd days - two \"streaks\" of one rainy day, so we should print 1.", "sample_input": "RRS\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02582", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.\n\nFind the maximum number of consecutive rainy days in this period.\n\nConstraints\n\n|S| = 3\n\nEach character of S is S or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of consecutive rainy days in the period.\n\nSample Input 1\n\nRRS\n\nSample Output 1\n\n2\n\nWe had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.\n\nSample Input 2\n\nSSS\n\nSample Output 2\n\n0\n\nIt was sunny throughout the period. We had no rainy days, so we should print 0.\n\nSample Input 3\n\nRSR\n\nSample Output 3\n\n1\n\nWe had rain on the 1-st and 3-rd days - two \"streaks\" of one rainy day, so we should print 1.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1399, "cpu_time_ms": 116, "memory_kb": 35336}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s816185970", "group_id": "codeNet:p02582", "input_text": "import java.util.*;\n\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n String str = sc.nextLine();\n\n int result=0;\n boolean flag = false;\n for(int i = 0; i < 3; i++){\n if(str.charAt(i) == 'R'){\n result++;\n flag = true;\n }\n else{\n if(flag == true) break;\n }\n }\n\n System.out.println(result);\n }\n}\n", "language": "Java", "metadata": {"date": 1597581966, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02582.html", "problem_id": "p02582", "resource_group": "high_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/Java/s816185970.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s816185970", "user_id": "u608537218"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n String str = sc.nextLine();\n\n int result=0;\n boolean flag = false;\n for(int i = 0; i < 3; i++){\n if(str.charAt(i) == 'R'){\n result++;\n flag = true;\n }\n else{\n if(flag == true) break;\n }\n }\n\n System.out.println(result);\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.\n\nFind the maximum number of consecutive rainy days in this period.\n\nConstraints\n\n|S| = 3\n\nEach character of S is S or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of consecutive rainy days in the period.\n\nSample Input 1\n\nRRS\n\nSample Output 1\n\n2\n\nWe had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.\n\nSample Input 2\n\nSSS\n\nSample Output 2\n\n0\n\nIt was sunny throughout the period. We had no rainy days, so we should print 0.\n\nSample Input 3\n\nRSR\n\nSample Output 3\n\n1\n\nWe had rain on the 1-st and 3-rd days - two \"streaks\" of one rainy day, so we should print 1.", "sample_input": "RRS\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02582", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.\n\nFind the maximum number of consecutive rainy days in this period.\n\nConstraints\n\n|S| = 3\n\nEach character of S is S or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of consecutive rainy days in the period.\n\nSample Input 1\n\nRRS\n\nSample Output 1\n\n2\n\nWe had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.\n\nSample Input 2\n\nSSS\n\nSample Output 2\n\n0\n\nIt was sunny throughout the period. We had no rainy days, so we should print 0.\n\nSample Input 3\n\nRSR\n\nSample Output 3\n\n1\n\nWe had rain on the 1-st and 3-rd days - two \"streaks\" of one rainy day, so we should print 1.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 648, "cpu_time_ms": 117, "memory_kb": 35716}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s394078782", "group_id": "codeNet:p02583", "input_text": "import java.util.*;\n \npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int num = sc.nextInt();\n long array[] = new long[num];\n for(int i = 0;i < num;i++){\n array[i] = sc.nextLong();\n }\n long count = 0;\n for(int i = 0;i < num - 2;i++){\n for(int j = i + 1;j < num - 1;j++){\n for(int k = j + 1;k < num;k++){\n long a = array[i];\n long b = array[j];\n long c = array[k];\n long sum = a + b + c;\n if(a != b && b != c && c != a){\n long max = Math.max(a,Math.max(b,c));\n if(max < sum - max){\n count++;\n }\n }\n }\n }\n }\n System.out.println(count);\n }\n}", "language": "Java", "metadata": {"date": 1599659551, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02583.html", "problem_id": "p02583", "resource_group": "high_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/Java/s394078782.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s394078782", "user_id": "u583294876"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*;\n \npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int num = sc.nextInt();\n long array[] = new long[num];\n for(int i = 0;i < num;i++){\n array[i] = sc.nextLong();\n }\n long count = 0;\n for(int i = 0;i < num - 2;i++){\n for(int j = i + 1;j < num - 1;j++){\n for(int k = j + 1;k < num;k++){\n long a = array[i];\n long b = array[j];\n long c = array[k];\n long sum = a + b + c;\n if(a != b && b != c && c != a){\n long max = Math.max(a,Math.max(b,c));\n if(max < sum - max){\n count++;\n }\n }\n }\n }\n }\n System.out.println(count);\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": 747, "cpu_time_ms": 137, "memory_kb": 36588}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s563722157", "group_id": "codeNet:p02584", "input_text": "import javax.swing.*;\nimport java.lang.management.ManagementFactory;\nimport java.lang.reflect.Array;\nimport java.util.*;\nimport java.io.*;\nimport java.util.stream.Collectors;\n\npublic class Main {\n static class Pair {\n int num;\n int cut;\n\n Pair(int num, int cut) {\n this.num = num;\n this.cut = cut;\n }\n\n double getVal() {\n return -num / (double) cut;\n }\n }\n\n public static void main(String[] args) throws IOException {\n sc = new MScanner(System.in);\n pw = new PrintWriter(System.out);\n long X = sc.nextLong();\n long K = sc.nextLong();\n long D = sc.nextLong();\n long res = solve(X,D, K);\n if(X < 0) {\n if( X + D * K < 0) {\n pw.println(- (X + D * K));\n } else {\n pw.println(Math.min(res, Math.abs(res - 2 * D)));\n }\n pw.flush();\n return;\n }\n pw.println(res);\n\n //pw.println(\"end\");\n // pw.println();\n\n pw.flush();\n // System.out.println(cnt);\n }\n static long solve(long X, long D,long K) {\n if (K < X/D) {\n return (X - K * D);\n }\n long multiple = Math.floorDiv(X, D);\n long res = X - D * multiple;\n if (((K - multiple) & 1) == 0) {\n return (Math.min(res, Math.abs(res - 2 * D)));\n } else {\n return (Math.min(Math.abs(res - D), Math.abs(res + D)));\n }\n }\n\n /**\n * https://www.slideshare.net/hcpc_hokudai/binary-indexed-tree A space efficient version segment\n * tree. Usually for range sum. Or the required metric can be calulated in that:\n *\n *

right_metric = parant_metric - left_metric Only then, we can stop memoizing right_metric\n *\n *

The internal structure is a 1-base array, to simplify calculation of parent node's idx. lsb\n * = 3 & -3 = 2 (0x0011 & 0x1101 = 0x0001) lastParentOf3 = 3 - lsb = 2 curParentOf3 = 3 + lsb = 4\n */\n static class FenwickTree {\n private final long[] state;\n private final int size;\n\n FenwickTree(int size) {\n this.size = size;\n state = new long[size + 1];\n }\n\n @Override\n public String toString() {\n return Arrays.toString(state);\n }\n\n long queryRangeSumFromZeroTo(int idx) {\n long sum = 0;\n while (idx != 0) {\n sum += state[idx];\n idx -= (idx & -idx);\n }\n return sum;\n }\n\n /** @param val can be negative */\n void updateElement(int idx, long val) {\n while (idx <= size) {\n state[idx] += val;\n idx += (idx & -idx);\n }\n }\n }\n\n // sc.close();\n // pw.println(cnt);\n // pw.flush();\n\n static PrintWriter pw;\n static MScanner sc;\n\n static class MScanner {\n StringTokenizer st;\n BufferedReader br;\n\n public MScanner(InputStream system) {\n br = new BufferedReader(new InputStreamReader(system));\n }\n\n public MScanner(String file) throws Exception {\n br = new BufferedReader(new FileReader(file));\n }\n\n public String next() throws IOException {\n while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());\n return st.nextToken();\n }\n\n public int[] intArr(int n) throws IOException {\n int[] in = new int[n];\n for (int i = 0; i < n; i++) in[i] = nextInt();\n return in;\n }\n\n public long[] longArr(int n) throws IOException {\n long[] in = new long[n];\n for (int i = 0; i < n; i++) in[i] = nextLong();\n return in;\n }\n\n public int[] intSortedArr(int n) throws IOException {\n int[] in = new int[n];\n for (int i = 0; i < n; i++) in[i] = nextInt();\n shuffle(in);\n Arrays.sort(in);\n return in;\n }\n\n public long[] longSortedArr(int n) throws IOException {\n long[] in = new long[n];\n for (int i = 0; i < n; i++) in[i] = nextLong();\n shuffle(in);\n Arrays.sort(in);\n return in;\n }\n\n public Integer[] IntegerArr(int n) throws IOException {\n Integer[] in = new Integer[n];\n for (int i = 0; i < n; i++) in[i] = nextInt();\n return in;\n }\n\n public Long[] LongArr(int n) throws IOException {\n Long[] in = new Long[n];\n for (int i = 0; i < n; i++) in[i] = nextLong();\n return in;\n }\n\n public String nextLine() throws IOException {\n return br.readLine();\n }\n\n public int nextInt() throws IOException {\n return Integer.parseInt(next());\n }\n\n public double nextDouble() throws IOException {\n return Double.parseDouble(next());\n }\n\n public char nextChar() throws IOException {\n return next().charAt(0);\n }\n\n public long nextLong() throws IOException {\n return Long.parseLong(next());\n }\n\n public boolean ready() throws IOException {\n return br.ready();\n }\n\n public void waitForInput() throws InterruptedException {\n Thread.sleep(3000);\n }\n }\n\n static void shuffle(int[] in) {\n for (int i = 0; i < in.length; i++) {\n int idx = (int) (Math.random() * in.length);\n int tmp = in[i];\n in[i] = in[idx];\n in[idx] = tmp;\n }\n }\n\n static void shuffle(long[] in) {\n for (int i = 0; i < in.length; i++) {\n int idx = (int) (Math.random() * in.length);\n long tmp = in[i];\n in[i] = in[idx];\n in[idx] = tmp;\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1597571478, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02584.html", "problem_id": "p02584", "resource_group": "high_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/Java/s563722157.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s563722157", "user_id": "u708615801"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import javax.swing.*;\nimport java.lang.management.ManagementFactory;\nimport java.lang.reflect.Array;\nimport java.util.*;\nimport java.io.*;\nimport java.util.stream.Collectors;\n\npublic class Main {\n static class Pair {\n int num;\n int cut;\n\n Pair(int num, int cut) {\n this.num = num;\n this.cut = cut;\n }\n\n double getVal() {\n return -num / (double) cut;\n }\n }\n\n public static void main(String[] args) throws IOException {\n sc = new MScanner(System.in);\n pw = new PrintWriter(System.out);\n long X = sc.nextLong();\n long K = sc.nextLong();\n long D = sc.nextLong();\n long res = solve(X,D, K);\n if(X < 0) {\n if( X + D * K < 0) {\n pw.println(- (X + D * K));\n } else {\n pw.println(Math.min(res, Math.abs(res - 2 * D)));\n }\n pw.flush();\n return;\n }\n pw.println(res);\n\n //pw.println(\"end\");\n // pw.println();\n\n pw.flush();\n // System.out.println(cnt);\n }\n static long solve(long X, long D,long K) {\n if (K < X/D) {\n return (X - K * D);\n }\n long multiple = Math.floorDiv(X, D);\n long res = X - D * multiple;\n if (((K - multiple) & 1) == 0) {\n return (Math.min(res, Math.abs(res - 2 * D)));\n } else {\n return (Math.min(Math.abs(res - D), Math.abs(res + D)));\n }\n }\n\n /**\n * https://www.slideshare.net/hcpc_hokudai/binary-indexed-tree A space efficient version segment\n * tree. Usually for range sum. Or the required metric can be calulated in that:\n *\n *

right_metric = parant_metric - left_metric Only then, we can stop memoizing right_metric\n *\n *

The internal structure is a 1-base array, to simplify calculation of parent node's idx. lsb\n * = 3 & -3 = 2 (0x0011 & 0x1101 = 0x0001) lastParentOf3 = 3 - lsb = 2 curParentOf3 = 3 + lsb = 4\n */\n static class FenwickTree {\n private final long[] state;\n private final int size;\n\n FenwickTree(int size) {\n this.size = size;\n state = new long[size + 1];\n }\n\n @Override\n public String toString() {\n return Arrays.toString(state);\n }\n\n long queryRangeSumFromZeroTo(int idx) {\n long sum = 0;\n while (idx != 0) {\n sum += state[idx];\n idx -= (idx & -idx);\n }\n return sum;\n }\n\n /** @param val can be negative */\n void updateElement(int idx, long val) {\n while (idx <= size) {\n state[idx] += val;\n idx += (idx & -idx);\n }\n }\n }\n\n // sc.close();\n // pw.println(cnt);\n // pw.flush();\n\n static PrintWriter pw;\n static MScanner sc;\n\n static class MScanner {\n StringTokenizer st;\n BufferedReader br;\n\n public MScanner(InputStream system) {\n br = new BufferedReader(new InputStreamReader(system));\n }\n\n public MScanner(String file) throws Exception {\n br = new BufferedReader(new FileReader(file));\n }\n\n public String next() throws IOException {\n while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());\n return st.nextToken();\n }\n\n public int[] intArr(int n) throws IOException {\n int[] in = new int[n];\n for (int i = 0; i < n; i++) in[i] = nextInt();\n return in;\n }\n\n public long[] longArr(int n) throws IOException {\n long[] in = new long[n];\n for (int i = 0; i < n; i++) in[i] = nextLong();\n return in;\n }\n\n public int[] intSortedArr(int n) throws IOException {\n int[] in = new int[n];\n for (int i = 0; i < n; i++) in[i] = nextInt();\n shuffle(in);\n Arrays.sort(in);\n return in;\n }\n\n public long[] longSortedArr(int n) throws IOException {\n long[] in = new long[n];\n for (int i = 0; i < n; i++) in[i] = nextLong();\n shuffle(in);\n Arrays.sort(in);\n return in;\n }\n\n public Integer[] IntegerArr(int n) throws IOException {\n Integer[] in = new Integer[n];\n for (int i = 0; i < n; i++) in[i] = nextInt();\n return in;\n }\n\n public Long[] LongArr(int n) throws IOException {\n Long[] in = new Long[n];\n for (int i = 0; i < n; i++) in[i] = nextLong();\n return in;\n }\n\n public String nextLine() throws IOException {\n return br.readLine();\n }\n\n public int nextInt() throws IOException {\n return Integer.parseInt(next());\n }\n\n public double nextDouble() throws IOException {\n return Double.parseDouble(next());\n }\n\n public char nextChar() throws IOException {\n return next().charAt(0);\n }\n\n public long nextLong() throws IOException {\n return Long.parseLong(next());\n }\n\n public boolean ready() throws IOException {\n return br.ready();\n }\n\n public void waitForInput() throws InterruptedException {\n Thread.sleep(3000);\n }\n }\n\n static void shuffle(int[] in) {\n for (int i = 0; i < in.length; i++) {\n int idx = (int) (Math.random() * in.length);\n int tmp = in[i];\n in[i] = in[idx];\n in[idx] = tmp;\n }\n }\n\n static void shuffle(long[] in) {\n for (int i = 0; i < in.length; i++) {\n int idx = (int) (Math.random() * in.length);\n long tmp = in[i];\n in[i] = in[idx];\n in[idx] = tmp;\n }\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "sample_input": "6 2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02584", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5150, "cpu_time_ms": 88, "memory_kb": 32924}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s225151220", "group_id": "codeNet:p02584", "input_text": "import java.util.*;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n Scanner sc=new Scanner(System.in);\n long x=sc.nextLong();\n long k=sc.nextLong();\n long d=sc.nextLong();\n if(x==k && k==d)\n {\n \tSystem.out.println(x);\n \t\n System.exit(1);\n }\n x=Math.abs(x);\n k=k-(x/d);\n x=x%d;\n if(k<=0)\n {\n \tSystem.out.println((x-(k*d)));\n \tSystem.exit(1);\n }\n else\n {\n \tif(k%2==1)\n \t\tSystem.out.println(Math.abs(x-d));\n \telse\n \t\tSystem.out.println(x);\n }\n \n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1597523987, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02584.html", "problem_id": "p02584", "resource_group": "high_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/Java/s225151220.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s225151220", "user_id": "u053570263"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n Scanner sc=new Scanner(System.in);\n long x=sc.nextLong();\n long k=sc.nextLong();\n long d=sc.nextLong();\n if(x==k && k==d)\n {\n \tSystem.out.println(x);\n \t\n System.exit(1);\n }\n x=Math.abs(x);\n k=k-(x/d);\n x=x%d;\n if(k<=0)\n {\n \tSystem.out.println((x-(k*d)));\n \tSystem.exit(1);\n }\n else\n {\n \tif(k%2==1)\n \t\tSystem.out.println(Math.abs(x-d));\n \telse\n \t\tSystem.out.println(x);\n }\n \n\t}\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "sample_input": "6 2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02584", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 687, "cpu_time_ms": 139, "memory_kb": 35776}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s827586598", "group_id": "codeNet:p02584", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tlong x = sc.nextLong();\n\t\tlong k = sc.nextLong();\n\t\tlong d = sc.nextLong();\n\t\tlong min1 = x % d;\n\t\tif(min1 < 0)\n\t\t\tmin1 += d;\n\t\tlong min2 = min1 - d;\n\t\tlong ans = Long.MAX_VALUE / 2;\n\t\tif(Math.abs(x - min1) / d <= k && Math.abs(x - min1) / d % 2 == k % 2) {\n\t\t\tans = min1;\n\t\t}\n\t\tif(Math.abs(x - min2) / d <= k && Math.abs(x - min2) / d % 2 == k % 2) {\n\t\t\tans = Math.abs(min2);\n\t\t}\n\n\t\tans = Math.min(ans, Math.abs(x - k * d));\n\n\n\t\tsc.close();\n\t\tSystem.out.println(ans);\n\n\t}\n}\n\n", "language": "Java", "metadata": {"date": 1597519004, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02584.html", "problem_id": "p02584", "resource_group": "high_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/Java/s827586598.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s827586598", "user_id": "u465572759"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tlong x = sc.nextLong();\n\t\tlong k = sc.nextLong();\n\t\tlong d = sc.nextLong();\n\t\tlong min1 = x % d;\n\t\tif(min1 < 0)\n\t\t\tmin1 += d;\n\t\tlong min2 = min1 - d;\n\t\tlong ans = Long.MAX_VALUE / 2;\n\t\tif(Math.abs(x - min1) / d <= k && Math.abs(x - min1) / d % 2 == k % 2) {\n\t\t\tans = min1;\n\t\t}\n\t\tif(Math.abs(x - min2) / d <= k && Math.abs(x - min2) / d % 2 == k % 2) {\n\t\t\tans = Math.abs(min2);\n\t\t}\n\n\t\tans = Math.min(ans, Math.abs(x - k * d));\n\n\n\t\tsc.close();\n\t\tSystem.out.println(ans);\n\n\t}\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "sample_input": "6 2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02584", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 607, "cpu_time_ms": 136, "memory_kb": 35648}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s781148706", "group_id": "codeNet:p02585", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.PrintWriter;\nimport java.math.BigInteger;\nimport java.util.*;\n \npublic class Main {\n \n void solve() throws IOException {\n int N = ni();\n int K = ni();\n int[] P = new int[N];\n int[] C = new int[N];\n for (int i = 0; i < N; i++) {\n P[i] = ni()-1;\n }\n for (int i = 0; i < N; i++) {\n C[i] = ni();\n }\n long ans = -Long.MAX_VALUE;\n for (int i = 0; i < N; i++) {\n HashSet visited = new HashSet<>();\n int current = i;\n int count = 0;\n long cost = 0;\n while(true){\n visited.add(current);\n count++;\n current = P[current];\n cost += C[current];\n ans = Math.max(ans, cost);\n // System.out.println(current);\n // System.out.println(cost);\n if(visited.contains(current) || count>=K) break;\n }\n if(count < K){\n if(cost>0)cost += cost * ((K-count)/count);\n ans = Math.max(ans, cost);\n // System.out.println(cost);\n int rest = K%count;\n for (int j = 0; j < rest; j++) {\n current = P[current];\n cost += C[current];\n ans = Math.max(ans, cost);\n // System.out.println(cost);\n }\n }\n // System.out.println();\n\n }\n \n out.println(ans);\n }\n\n final int mod = 1000000007;\n final BigInteger MOD = BigInteger.valueOf(mod);\n int upperBound(ArrayList list, Long target){\n int i = Collections.binarySearch(list, target, new UpperBoundComparator());\n return ~i;\n }\n class UpperBoundComparator> implements Comparator{\n public int compare(T x, T y){\n return (x.compareTo(y) > 0) ? 1 : -1;\n }\n }\n int lowerBound(ArrayList list, Long target){\n int i = Collections.binarySearch(list, target, new LowerBoundComparator());\n return ~i;\n }\n class LowerBoundComparator> implements Comparator{\n public int compare(T x, T y){\n return (x.compareTo(y) >= 0) ? 1 : -1;\n }\n }\n int mul(int x, int y){\n int val = (int)((x * 1L * y) % mod);\n return val>=0 ? val : val+mod;\n }\n int add(int x, int y) {\n x += y;\n if(x < 0) x += mod;\n if(x>=mod) x -= mod;\n return x;\n }\n int sub(int x, int y){\n x = add(x,mod-y);\n if(x < 0) x += mod;\n if(x>=mod) x -= mod;\n return x;\n }\n String ns() throws IOException {\n while (!tok.hasMoreTokens()) {\n tok = new StringTokenizer(in.readLine(), \" \");\n }\n return tok.nextToken();\n }\n \n int ni() throws IOException {\n return Integer.parseInt(ns());\n }\n \n long nl() throws IOException {\n return Long.parseLong(ns());\n }\n \n double nd() throws IOException {\n return Double.parseDouble(ns());\n }\n \n String[] nsa(int n) throws IOException {\n String[] res = new String[n];\n for (int i = 0; i < n; i++) {\n res[i] = ns();\n }\n return res;\n }\n \n int[] nia(int n) throws IOException {\n int[] res = new int[n];\n for (int i = 0; i < n; i++) {\n res[i] = ni();\n }\n return res;\n }\n \n long[] nla(int n) throws IOException {\n long[] res = new long[n];\n for (int i = 0; i < n; i++) {\n res[i] = nl();\n }\n return res;\n }\n \n static BufferedReader in;\n static PrintWriter out;\n static StringTokenizer tok;\n \n public static void main(String[] args) throws IOException {\n in = new BufferedReader(new InputStreamReader(System.in));\n out = new PrintWriter(System.out);\n tok = new StringTokenizer(\"\");\n Main main = new Main();\n main.solve();\n out.close();\n }\n}", "language": "Java", "metadata": {"date": 1597714445, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02585.html", "problem_id": "p02585", "resource_group": "high_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/Java/s781148706.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s781148706", "user_id": "u082512804"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.PrintWriter;\nimport java.math.BigInteger;\nimport java.util.*;\n \npublic class Main {\n \n void solve() throws IOException {\n int N = ni();\n int K = ni();\n int[] P = new int[N];\n int[] C = new int[N];\n for (int i = 0; i < N; i++) {\n P[i] = ni()-1;\n }\n for (int i = 0; i < N; i++) {\n C[i] = ni();\n }\n long ans = -Long.MAX_VALUE;\n for (int i = 0; i < N; i++) {\n HashSet visited = new HashSet<>();\n int current = i;\n int count = 0;\n long cost = 0;\n while(true){\n visited.add(current);\n count++;\n current = P[current];\n cost += C[current];\n ans = Math.max(ans, cost);\n // System.out.println(current);\n // System.out.println(cost);\n if(visited.contains(current) || count>=K) break;\n }\n if(count < K){\n if(cost>0)cost += cost * ((K-count)/count);\n ans = Math.max(ans, cost);\n // System.out.println(cost);\n int rest = K%count;\n for (int j = 0; j < rest; j++) {\n current = P[current];\n cost += C[current];\n ans = Math.max(ans, cost);\n // System.out.println(cost);\n }\n }\n // System.out.println();\n\n }\n \n out.println(ans);\n }\n\n final int mod = 1000000007;\n final BigInteger MOD = BigInteger.valueOf(mod);\n int upperBound(ArrayList list, Long target){\n int i = Collections.binarySearch(list, target, new UpperBoundComparator());\n return ~i;\n }\n class UpperBoundComparator> implements Comparator{\n public int compare(T x, T y){\n return (x.compareTo(y) > 0) ? 1 : -1;\n }\n }\n int lowerBound(ArrayList list, Long target){\n int i = Collections.binarySearch(list, target, new LowerBoundComparator());\n return ~i;\n }\n class LowerBoundComparator> implements Comparator{\n public int compare(T x, T y){\n return (x.compareTo(y) >= 0) ? 1 : -1;\n }\n }\n int mul(int x, int y){\n int val = (int)((x * 1L * y) % mod);\n return val>=0 ? val : val+mod;\n }\n int add(int x, int y) {\n x += y;\n if(x < 0) x += mod;\n if(x>=mod) x -= mod;\n return x;\n }\n int sub(int x, int y){\n x = add(x,mod-y);\n if(x < 0) x += mod;\n if(x>=mod) x -= mod;\n return x;\n }\n String ns() throws IOException {\n while (!tok.hasMoreTokens()) {\n tok = new StringTokenizer(in.readLine(), \" \");\n }\n return tok.nextToken();\n }\n \n int ni() throws IOException {\n return Integer.parseInt(ns());\n }\n \n long nl() throws IOException {\n return Long.parseLong(ns());\n }\n \n double nd() throws IOException {\n return Double.parseDouble(ns());\n }\n \n String[] nsa(int n) throws IOException {\n String[] res = new String[n];\n for (int i = 0; i < n; i++) {\n res[i] = ns();\n }\n return res;\n }\n \n int[] nia(int n) throws IOException {\n int[] res = new int[n];\n for (int i = 0; i < n; i++) {\n res[i] = ni();\n }\n return res;\n }\n \n long[] nla(int n) throws IOException {\n long[] res = new long[n];\n for (int i = 0; i < n; i++) {\n res[i] = nl();\n }\n return res;\n }\n \n static BufferedReader in;\n static PrintWriter out;\n static StringTokenizer tok;\n \n public static void main(String[] args) throws IOException {\n in = new BufferedReader(new InputStreamReader(System.in));\n out = new PrintWriter(System.out);\n tok = new StringTokenizer(\"\");\n Main main = new Main();\n main.solve();\n out.close();\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": 4178, "cpu_time_ms": 1296, "memory_kb": 56952}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s040661293", "group_id": "codeNet:p02585", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.stream.LongStream;\nimport java.util.Set;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.HashSet;\nimport java.util.OptionalLong;\nimport java.util.StringTokenizer;\nimport java.io.BufferedReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n MyScanner in = new MyScanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n D solver = new D();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class D {\n long minValue = (long) -1e50;\n\n public void solve(int testNumber, MyScanner in, PrintWriter out) {\n int N = in.Int();\n int K = in.Int();\n int[] P = new int[N];\n for (int i = 0; i < N; i++) {\n P[i] = in.Int() - 1;\n }\n int[] C = in.Int(N);\n\n long ans = minValue;\n boolean[] f = new boolean[N];\n for (int n = 0; n < N; n++) {\n if (f[n]) continue;\n Set set = new HashSet<>();\n int cur = n;\n long sum = 0;\n while (!set.contains(cur)) {\n f[cur] = true;\n set.add(cur);\n cur = P[cur];\n sum += C[cur];\n }\n int k = K % set.size();\n long[] c = new long[N];\n long max = minValue;\n long max2 = 0;\n for (int i = 0; i < set.size(); i++) {\n if (i <= k) max2 = Math.max(max2, max);\n long[] cc = new long[N];\n for (int j : set) {\n cc[P[j]] = c[j] + C[j];\n }\n c = cc;\n max = Math.max(max, LongStream.of(c).max().getAsLong());\n }\n ans = Math.max(ans, Math.max(max, sum * (K / set.size()) + max2));\n }\n out.println(ans);\n }\n\n }\n\n static class MyScanner {\n private BufferedReader in;\n private StringTokenizer st;\n\n public MyScanner(InputStream stream) {\n in = new BufferedReader(new InputStreamReader(stream));\n }\n\n public String next() {\n while (st == null || !st.hasMoreTokens()) {\n try {\n String rl = in.readLine();\n if (rl == null) {\n return null;\n }\n st = new StringTokenizer(rl);\n } catch (IOException e) {\n return null;\n }\n }\n return st.nextToken();\n }\n\n public int Int() {\n return Integer.parseInt(next());\n }\n\n public int[] Int(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = Int();\n }\n return a;\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1597545152, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02585.html", "problem_id": "p02585", "resource_group": "high_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/Java/s040661293.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s040661293", "user_id": "u305384049"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.stream.LongStream;\nimport java.util.Set;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.HashSet;\nimport java.util.OptionalLong;\nimport java.util.StringTokenizer;\nimport java.io.BufferedReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n MyScanner in = new MyScanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n D solver = new D();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class D {\n long minValue = (long) -1e50;\n\n public void solve(int testNumber, MyScanner in, PrintWriter out) {\n int N = in.Int();\n int K = in.Int();\n int[] P = new int[N];\n for (int i = 0; i < N; i++) {\n P[i] = in.Int() - 1;\n }\n int[] C = in.Int(N);\n\n long ans = minValue;\n boolean[] f = new boolean[N];\n for (int n = 0; n < N; n++) {\n if (f[n]) continue;\n Set set = new HashSet<>();\n int cur = n;\n long sum = 0;\n while (!set.contains(cur)) {\n f[cur] = true;\n set.add(cur);\n cur = P[cur];\n sum += C[cur];\n }\n int k = K % set.size();\n long[] c = new long[N];\n long max = minValue;\n long max2 = 0;\n for (int i = 0; i < set.size(); i++) {\n if (i <= k) max2 = Math.max(max2, max);\n long[] cc = new long[N];\n for (int j : set) {\n cc[P[j]] = c[j] + C[j];\n }\n c = cc;\n max = Math.max(max, LongStream.of(c).max().getAsLong());\n }\n ans = Math.max(ans, Math.max(max, sum * (K / set.size()) + max2));\n }\n out.println(ans);\n }\n\n }\n\n static class MyScanner {\n private BufferedReader in;\n private StringTokenizer st;\n\n public MyScanner(InputStream stream) {\n in = new BufferedReader(new InputStreamReader(stream));\n }\n\n public String next() {\n while (st == null || !st.hasMoreTokens()) {\n try {\n String rl = in.readLine();\n if (rl == null) {\n return null;\n }\n st = new StringTokenizer(rl);\n } catch (IOException e) {\n return null;\n }\n }\n return st.nextToken();\n }\n\n public int Int() {\n return Integer.parseInt(next());\n }\n\n public int[] Int(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = Int();\n }\n return a;\n }\n\n }\n}\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": 3281, "cpu_time_ms": 542, "memory_kb": 58464}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s014575773", "group_id": "codeNet:p02585", "input_text": "import java.io.*;\nimport java.util.*;\nimport java.util.Arrays;\nimport java.util.Collections;\n// import java.io.BufferedReader;\n// import java.io.IOException;\n// import java.io.InputStreamReader;\n// import java.util.ArrayList;\n// import java.util.Arrays;\n// import java.util.Collections;\n// import java.util.List;\n// import java.util.HashSet;\n// import java.util.Set;\n// import java.util.Map;\n// import java.util.HashMap;\n\nimport java.math.*;\n\npublic class Main {\n private static Scanner sc;\n private static final long mod = 1000000007;\n\n public static void main(final String[] args) {\n final Main instance = new Main();\n sc = instance.new Scanner();\n instance.solve();\n }\n\n private static String getUpperAlpha(int i) {\n return String.valueOf((char) (i + 64));\n }\n\n /* i=1 return a */\n private static String getLowerAlpha(int i) {\n return String.valueOf((char) (i + 96));\n }\n\n private class Scanner {\n String[] s;\n int i;\n BufferedReader br;\n String regex = \" \";\n\n public Scanner() {\n s = new String[0];\n i = 0;\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n\n @Override\n protected void finalize() throws Throwable {\n try {\n super.finalize();\n } finally {\n destruction();\n }\n }\n\n private void destruction() throws IOException {\n if (br != null)\n br.close();\n }\n\n public String next() throws IOException {\n if (i < s.length)\n return s[i++];\n String st = br.readLine();\n while (st == \"\")\n st = br.readLine();\n s = st.split(regex, 0);\n i = 0;\n return s[i++];\n }\n\n public int nextInt() throws NumberFormatException, IOException {\n return Integer.parseInt(next());\n }\n\n public Long nextLong() throws NumberFormatException, IOException {\n return Long.parseLong(next());\n }\n\n public Double nextDouble() throws NumberFormatException, IOException {\n return Double.parseDouble(next());\n }\n\n public long[] nextLongArray(int n) throws NumberFormatException, IOException {\n long[] ret = new long[n];\n for (int i = 0; i < n; i++) {\n ret[i] = nextLong();\n }\n return ret;\n }\n\n public int[] nextIntArray(int n) throws NumberFormatException, IOException {\n int[] ret = new int[n];\n for (int i = 0; i < n; i++) {\n ret[i] = nextInt();\n }\n return ret;\n }\n }\n\n private void solve() {\n try {\n int n = sc.nextInt();\n long k = sc.nextLong();\n int[] p = sc.nextIntArray(n);\n long[] c = sc.nextLongArray(n);\n long ans = 0;\n\n long max = Long.MIN_VALUE;\n int loop = 0;\n for (int i = 0; i < n; i++) {\n long sum = 0;\n int idx = i;\n int iniIdx = i;\n loop = 0;\n for (int j = 0; j < k; j++) {\n int loopcount = 0;\n sum += c[idx];\n idx = p[idx] - 1;\n\n if (iniIdx == idx) {\n if (sum > max) {\n max = sum;\n loopcount++;\n loop = loopcount;\n }\n break;\n } else {\n max = Math.max(max, sum);\n }\n loopcount++;\n }\n }\n if (loop != 0)\n ans = max * (k / loop);\n\n max = Long.MIN_VALUE;\n for (int i = 0; i < n; i++) {\n long sum = 0;\n int idx = i;\n for (int j = 0; j < k; j++) {\n sum += c[idx];\n idx = p[idx] - 1;\n max = Math.max(max, sum);\n }\n }\n\n // if (k > n) {\n // long sum = 0;\n // for (int i = 0; i < n; i++) {\n // sum += c[i];\n // }\n // if (sum > 0) {\n // ans = sum * (k / n);\n // }\n // k %= n;\n // }\n // System.out.println(ans);\n\n System.out.println(max + ans);\n } catch (\n\n Exception e) {\n e.printStackTrace();\n }\n\n }\n}\n", "language": "Java", "metadata": {"date": 1597543587, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02585.html", "problem_id": "p02585", "resource_group": "high_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/Java/s014575773.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s014575773", "user_id": "u490452536"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\nimport java.util.Arrays;\nimport java.util.Collections;\n// import java.io.BufferedReader;\n// import java.io.IOException;\n// import java.io.InputStreamReader;\n// import java.util.ArrayList;\n// import java.util.Arrays;\n// import java.util.Collections;\n// import java.util.List;\n// import java.util.HashSet;\n// import java.util.Set;\n// import java.util.Map;\n// import java.util.HashMap;\n\nimport java.math.*;\n\npublic class Main {\n private static Scanner sc;\n private static final long mod = 1000000007;\n\n public static void main(final String[] args) {\n final Main instance = new Main();\n sc = instance.new Scanner();\n instance.solve();\n }\n\n private static String getUpperAlpha(int i) {\n return String.valueOf((char) (i + 64));\n }\n\n /* i=1 return a */\n private static String getLowerAlpha(int i) {\n return String.valueOf((char) (i + 96));\n }\n\n private class Scanner {\n String[] s;\n int i;\n BufferedReader br;\n String regex = \" \";\n\n public Scanner() {\n s = new String[0];\n i = 0;\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n\n @Override\n protected void finalize() throws Throwable {\n try {\n super.finalize();\n } finally {\n destruction();\n }\n }\n\n private void destruction() throws IOException {\n if (br != null)\n br.close();\n }\n\n public String next() throws IOException {\n if (i < s.length)\n return s[i++];\n String st = br.readLine();\n while (st == \"\")\n st = br.readLine();\n s = st.split(regex, 0);\n i = 0;\n return s[i++];\n }\n\n public int nextInt() throws NumberFormatException, IOException {\n return Integer.parseInt(next());\n }\n\n public Long nextLong() throws NumberFormatException, IOException {\n return Long.parseLong(next());\n }\n\n public Double nextDouble() throws NumberFormatException, IOException {\n return Double.parseDouble(next());\n }\n\n public long[] nextLongArray(int n) throws NumberFormatException, IOException {\n long[] ret = new long[n];\n for (int i = 0; i < n; i++) {\n ret[i] = nextLong();\n }\n return ret;\n }\n\n public int[] nextIntArray(int n) throws NumberFormatException, IOException {\n int[] ret = new int[n];\n for (int i = 0; i < n; i++) {\n ret[i] = nextInt();\n }\n return ret;\n }\n }\n\n private void solve() {\n try {\n int n = sc.nextInt();\n long k = sc.nextLong();\n int[] p = sc.nextIntArray(n);\n long[] c = sc.nextLongArray(n);\n long ans = 0;\n\n long max = Long.MIN_VALUE;\n int loop = 0;\n for (int i = 0; i < n; i++) {\n long sum = 0;\n int idx = i;\n int iniIdx = i;\n loop = 0;\n for (int j = 0; j < k; j++) {\n int loopcount = 0;\n sum += c[idx];\n idx = p[idx] - 1;\n\n if (iniIdx == idx) {\n if (sum > max) {\n max = sum;\n loopcount++;\n loop = loopcount;\n }\n break;\n } else {\n max = Math.max(max, sum);\n }\n loopcount++;\n }\n }\n if (loop != 0)\n ans = max * (k / loop);\n\n max = Long.MIN_VALUE;\n for (int i = 0; i < n; i++) {\n long sum = 0;\n int idx = i;\n for (int j = 0; j < k; j++) {\n sum += c[idx];\n idx = p[idx] - 1;\n max = Math.max(max, sum);\n }\n }\n\n // if (k > n) {\n // long sum = 0;\n // for (int i = 0; i < n; i++) {\n // sum += c[i];\n // }\n // if (sum > 0) {\n // ans = sum * (k / n);\n // }\n // k %= n;\n // }\n // System.out.println(ans);\n\n System.out.println(max + ans);\n } catch (\n\n Exception e) {\n e.printStackTrace();\n }\n\n }\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": 4638, "cpu_time_ms": 3309, "memory_kb": 37960}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s141564224", "group_id": "codeNet:p02588", "input_text": "import java.util.*;\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n double[] a = new double[n];\n for(int i = 0 ; i < n ; i++){\n a[i] = sc.nextDouble();\n }\n int yono = 0;\n sc.close();\n for(int i = 0 ; i < n ; i++){\n for(int j = 0 ; j < i ; j++){\n if(a[i] * a[j] % 1 == 0) yono++;\n }\n }\n System.out.println(yono);\n }\n}//0=48\n //a=97 a -> +26 = 123\n//鶏になれ", "language": "Java", "metadata": {"date": 1597021322, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02588.html", "problem_id": "p02588", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02588/input.txt", "sample_output_relpath": "derived/input_output/data/p02588/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02588/Java/s141564224.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s141564224", "user_id": "u073879055"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*;\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n double[] a = new double[n];\n for(int i = 0 ; i < n ; i++){\n a[i] = sc.nextDouble();\n }\n int yono = 0;\n sc.close();\n for(int i = 0 ; i < n ; i++){\n for(int j = 0 ; j < i ; j++){\n if(a[i] * a[j] % 1 == 0) yono++;\n }\n }\n System.out.println(yono);\n }\n}//0=48\n //a=97 a -> +26 = 123\n//鶏になれ", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given N real values A_1, A_2, \\ldots, A_N.\nCompute the number of pairs of indices (i, j)\nsuch that i < j and the product A_i \\cdot A_j is integer.\n\nConstraints\n\n2 \\leq N \\leq 200\\,000\n\n0 < A_i < 10^4\n\nA_i is given with at most 9 digits after the decimal.\n\nInput\n\nInput is given from Standard Input in the following format.\n\nN\nA_1\nA_2\n\\vdots\nA_N\n\nOutput\n\nPrint the number of pairs with integer product A_i \\cdot A_j (and i < j).\n\nSample Input 1\n\n5\n7.5\n2.4\n17.000000001\n17\n16.000000000\n\nSample Output 1\n\n3\n\nThere are 3 pairs with integer product:\n\n7.5 \\cdot 2.4 = 18\n\n7.5 \\cdot 16 = 120\n\n17 \\cdot 16 = 272\n\nSample Input 2\n\n11\n0.9\n1\n1\n1.25\n2.30000\n5\n70\n0.000000001\n9999.999999999\n0.999999999\n1.000000001\n\nSample Output 2\n\n8", "sample_input": "5\n7.5\n2.4\n17.000000001\n17\n16.000000000\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02588", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given N real values A_1, A_2, \\ldots, A_N.\nCompute the number of pairs of indices (i, j)\nsuch that i < j and the product A_i \\cdot A_j is integer.\n\nConstraints\n\n2 \\leq N \\leq 200\\,000\n\n0 < A_i < 10^4\n\nA_i is given with at most 9 digits after the decimal.\n\nInput\n\nInput is given from Standard Input in the following format.\n\nN\nA_1\nA_2\n\\vdots\nA_N\n\nOutput\n\nPrint the number of pairs with integer product A_i \\cdot A_j (and i < j).\n\nSample Input 1\n\n5\n7.5\n2.4\n17.000000001\n17\n16.000000000\n\nSample Output 1\n\n3\n\nThere are 3 pairs with integer product:\n\n7.5 \\cdot 2.4 = 18\n\n7.5 \\cdot 16 = 120\n\n17 \\cdot 16 = 272\n\nSample Input 2\n\n11\n0.9\n1\n1\n1.25\n2.30000\n5\n70\n0.000000001\n9999.999999999\n0.999999999\n1.000000001\n\nSample Output 2\n\n8", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2208, "memory_kb": 65484}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s706923189", "group_id": "codeNet:p02594", "input_text": "import java.util.*;\npublic class Main{\n\tpublic static void main(String args[]){\n \tScanner s=new Scanner(System.in);\n \tint n=s.nextInt();\n \tif(n>=30){\n System.out.println(\"Yes\");\n }else{\n \tSystem.out.println(\"No\");\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1596572223, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02594.html", "problem_id": "p02594", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02594/input.txt", "sample_output_relpath": "derived/input_output/data/p02594/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02594/Java/s706923189.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s706923189", "user_id": "u942455341"}, "prompt_components": {"gold_output": "No\n", "input_to_evaluate": "import java.util.*;\npublic class Main{\n\tpublic static void main(String args[]){\n \tScanner s=new Scanner(System.in);\n \tint n=s.nextInt();\n \tif(n>=30){\n System.out.println(\"Yes\");\n }else{\n \tSystem.out.println(\"No\");\n }\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above.\n\nThe current temperature of the room is X degrees Celsius. Will you turn on the air conditioner?\n\nConstraints\n\n-40 \\leq X \\leq 40\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint Yes if you will turn on the air conditioner; print No otherwise.\n\nSample Input 1\n\n25\n\nSample Output 1\n\nNo\n\nSample Input 2\n\n30\n\nSample Output 2\n\nYes", "sample_input": "25\n"}, "reference_outputs": ["No\n"], "source_document_id": "p02594", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above.\n\nThe current temperature of the room is X degrees Celsius. Will you turn on the air conditioner?\n\nConstraints\n\n-40 \\leq X \\leq 40\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint Yes if you will turn on the air conditioner; print No otherwise.\n\nSample Input 1\n\n25\n\nSample Output 1\n\nNo\n\nSample Input 2\n\n30\n\nSample Output 2\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 268, "cpu_time_ms": 120, "memory_kb": 35616}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s903568369", "group_id": "codeNet:p02594", "input_text": "/*\n Author: @__goku__\n ssrivastava990@gmail.com\n\n `\\-. `\n \\ `. `\n \\ \\ |\n __.._ | \\. S O N - G O K U\n ..---~~ ~ . | Y\n ~-. `| |\n `. `~~--.\n \\ ~.\n \\ \\__. . -- - .\n .-~~~~~ , , ~~~~~~---...._\n .-~___ ,'/ ,'/ ,'\\ __...---~~~\n ~-. /._\\_( ,(/_. 7,-. ~~---...__\n _...>- P\"\"6=`_/\"6\"~ 6) ___...--~~~\n ~~--._ \\`--') `---' 9' _..--~~~\n ~\\ ~~/_ ~~~ /`-.--~~\n `. --- .' \\_\n `. \" _.-' | ~-.,-------._\n ..._../~~ ./ .-' .-~~~-.\n ,--~~~ ,'...\\` _./.----~~.'/ /' `-\n _.-( |\\ `/~ _____..-' / / _.-~~`.\n / | /. ^---~~~~ ' / / ,' ~. \\\n ( / ( . _ ' /' / ,/ \\ )\n (`. | `\\ - - - - ~ /' ( / . |\n \\.\\| \\ /' \\ |`. /\n /.'\\\\ `\\ /' ~-\\ . /\\\n /, ( `\\ /' `.___..- \\\n | | \\ `\\_/' // \\. |\n | | | _Seal_ /' | | |\n */\n\nimport java.io.*;\nimport java.util.*;\n\npublic class Main\n{\n static PrintWriter out = new PrintWriter((System.out));\n\n public static void main(String args[]) throws IOException\n {\n Kioken sc = new Kioken();\n int n=sc.nextInt();\n if(n>=30)\n {\n out.println(\"Yes\");\n }\n else\n {\n out.println(\"No\");\n }\n out.close();\n }\n\n public static void kamehameha()\n {\n }\n\n public static int lower_bound(ArrayList ar, int k)\n {\n int s = 0, e = ar.size();\n while (s != e)\n {\n int mid = s + e >> 1;\n if (ar.get(mid) <= k)\n {\n s = mid + 1;\n }\n else\n {\n e = mid;\n }\n }\n return Math.abs(s) - 1;\n }\n\n public static int upper_bound(ArrayList ar, int k)\n {\n int s = 0;\n int e = ar.size();\n while (s != e)\n {\n int mid = s + e >> 1;\n if (ar.get(mid) < k)\n {\n s = mid + 1;\n }\n else\n {\n e = mid;\n }\n }\n if (s == ar.size())\n {\n return -1;\n }\n return s;\n }\n\n static class Kioken\n {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st = new StringTokenizer(\"\");\n\n public String next()\n {\n while (!st.hasMoreTokens())\n {\n try\n {\n st = new StringTokenizer(br.readLine());\n }\n catch (Exception e)\n {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n public int nextInt()\n {\n return Integer.parseInt(next());\n }\n\n public long nextLong()\n {\n return Long.parseLong(next());\n }\n\n public double nextDouble()\n {\n return Double.parseDouble(next());\n }\n\n public String nextLine()\n {\n try\n {\n return br.readLine();\n }\n catch (Exception e)\n {\n e.printStackTrace();\n }\n return null;\n }\n\n public boolean hasNext()\n {\n String next = null;\n try\n {\n next = br.readLine();\n }\n catch (Exception e)\n {\n }\n if (next == null || next.length() == 0)\n {\n return false;\n }\n st = new StringTokenizer(next);\n return true;\n }\n }\n}", "language": "Java", "metadata": {"date": 1596416489, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02594.html", "problem_id": "p02594", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02594/input.txt", "sample_output_relpath": "derived/input_output/data/p02594/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02594/Java/s903568369.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s903568369", "user_id": "u957244388"}, "prompt_components": {"gold_output": "No\n", "input_to_evaluate": "/*\n Author: @__goku__\n ssrivastava990@gmail.com\n\n `\\-. `\n \\ `. `\n \\ \\ |\n __.._ | \\. S O N - G O K U\n ..---~~ ~ . | Y\n ~-. `| |\n `. `~~--.\n \\ ~.\n \\ \\__. . -- - .\n .-~~~~~ , , ~~~~~~---...._\n .-~___ ,'/ ,'/ ,'\\ __...---~~~\n ~-. /._\\_( ,(/_. 7,-. ~~---...__\n _...>- P\"\"6=`_/\"6\"~ 6) ___...--~~~\n ~~--._ \\`--') `---' 9' _..--~~~\n ~\\ ~~/_ ~~~ /`-.--~~\n `. --- .' \\_\n `. \" _.-' | ~-.,-------._\n ..._../~~ ./ .-' .-~~~-.\n ,--~~~ ,'...\\` _./.----~~.'/ /' `-\n _.-( |\\ `/~ _____..-' / / _.-~~`.\n / | /. ^---~~~~ ' / / ,' ~. \\\n ( / ( . _ ' /' / ,/ \\ )\n (`. | `\\ - - - - ~ /' ( / . |\n \\.\\| \\ /' \\ |`. /\n /.'\\\\ `\\ /' ~-\\ . /\\\n /, ( `\\ /' `.___..- \\\n | | \\ `\\_/' // \\. |\n | | | _Seal_ /' | | |\n */\n\nimport java.io.*;\nimport java.util.*;\n\npublic class Main\n{\n static PrintWriter out = new PrintWriter((System.out));\n\n public static void main(String args[]) throws IOException\n {\n Kioken sc = new Kioken();\n int n=sc.nextInt();\n if(n>=30)\n {\n out.println(\"Yes\");\n }\n else\n {\n out.println(\"No\");\n }\n out.close();\n }\n\n public static void kamehameha()\n {\n }\n\n public static int lower_bound(ArrayList ar, int k)\n {\n int s = 0, e = ar.size();\n while (s != e)\n {\n int mid = s + e >> 1;\n if (ar.get(mid) <= k)\n {\n s = mid + 1;\n }\n else\n {\n e = mid;\n }\n }\n return Math.abs(s) - 1;\n }\n\n public static int upper_bound(ArrayList ar, int k)\n {\n int s = 0;\n int e = ar.size();\n while (s != e)\n {\n int mid = s + e >> 1;\n if (ar.get(mid) < k)\n {\n s = mid + 1;\n }\n else\n {\n e = mid;\n }\n }\n if (s == ar.size())\n {\n return -1;\n }\n return s;\n }\n\n static class Kioken\n {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st = new StringTokenizer(\"\");\n\n public String next()\n {\n while (!st.hasMoreTokens())\n {\n try\n {\n st = new StringTokenizer(br.readLine());\n }\n catch (Exception e)\n {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n public int nextInt()\n {\n return Integer.parseInt(next());\n }\n\n public long nextLong()\n {\n return Long.parseLong(next());\n }\n\n public double nextDouble()\n {\n return Double.parseDouble(next());\n }\n\n public String nextLine()\n {\n try\n {\n return br.readLine();\n }\n catch (Exception e)\n {\n e.printStackTrace();\n }\n return null;\n }\n\n public boolean hasNext()\n {\n String next = null;\n try\n {\n next = br.readLine();\n }\n catch (Exception e)\n {\n }\n if (next == null || next.length() == 0)\n {\n return false;\n }\n st = new StringTokenizer(next);\n return true;\n }\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above.\n\nThe current temperature of the room is X degrees Celsius. Will you turn on the air conditioner?\n\nConstraints\n\n-40 \\leq X \\leq 40\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint Yes if you will turn on the air conditioner; print No otherwise.\n\nSample Input 1\n\n25\n\nSample Output 1\n\nNo\n\nSample Input 2\n\n30\n\nSample Output 2\n\nYes", "sample_input": "25\n"}, "reference_outputs": ["No\n"], "source_document_id": "p02594", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above.\n\nThe current temperature of the room is X degrees Celsius. Will you turn on the air conditioner?\n\nConstraints\n\n-40 \\leq X \\leq 40\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint Yes if you will turn on the air conditioner; print No otherwise.\n\nSample Input 1\n\n25\n\nSample Output 1\n\nNo\n\nSample Input 2\n\n30\n\nSample Output 2\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4235, "cpu_time_ms": 87, "memory_kb": 32664}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s857319431", "group_id": "codeNet:p02594", "input_text": "import java.util.*;\n\n\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int x = scanner.nextInt();\n \n if(x >= 30){\n System.out.println(\"Yes\");\n }else{\n System.out.println(\"No\");\n }\n scanner.close();\n return;\n }\n \n}\n", "language": "Java", "metadata": {"date": 1596416483, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02594.html", "problem_id": "p02594", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02594/input.txt", "sample_output_relpath": "derived/input_output/data/p02594/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02594/Java/s857319431.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s857319431", "user_id": "u090765289"}, "prompt_components": {"gold_output": "No\n", "input_to_evaluate": "import java.util.*;\n\n\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int x = scanner.nextInt();\n \n if(x >= 30){\n System.out.println(\"Yes\");\n }else{\n System.out.println(\"No\");\n }\n scanner.close();\n return;\n }\n \n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above.\n\nThe current temperature of the room is X degrees Celsius. Will you turn on the air conditioner?\n\nConstraints\n\n-40 \\leq X \\leq 40\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint Yes if you will turn on the air conditioner; print No otherwise.\n\nSample Input 1\n\n25\n\nSample Output 1\n\nNo\n\nSample Input 2\n\n30\n\nSample Output 2\n\nYes", "sample_input": "25\n"}, "reference_outputs": ["No\n"], "source_document_id": "p02594", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above.\n\nThe current temperature of the room is X degrees Celsius. Will you turn on the air conditioner?\n\nConstraints\n\n-40 \\leq X \\leq 40\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint Yes if you will turn on the air conditioner; print No otherwise.\n\nSample Input 1\n\n25\n\nSample Output 1\n\nNo\n\nSample Input 2\n\n30\n\nSample Output 2\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 309, "cpu_time_ms": 183, "memory_kb": 35600}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s678455970", "group_id": "codeNet:p02595", "input_text": "public class Main {\n\tpublic static void main(String[] args) {\n\t\tvar sc = new java.util.Scanner(System.in);\n\t\tvar n = sc.nextInt();\n\t\tvar d = sc.nextLong();\n\t\tvar cnt = 0;\n\t\tfor(int i=0;i[] graph;\n\t// static boolean visited[];\n\t// static long size[];\n\n\tpublic static void main(String[] args) throws NumberFormatException, IOException {\n\t\tFastReader sc = new FastReader();\n\t\tPrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t// Scanner scn = new Scanner(System.in);\n\t\t//\n\t\tint n = sc.nextInt();\n\t\tint val = 7 % n;\n\t\tint ans = -1;\n\t\tfor (int i = 1; i <= 1e7; i++) {\n\t\t\tif (val == 0) {\n\t\t\t\tans = i;\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tval = (val * 10 + 7) % n;\n\t\t\t}\n\t\t}\n\t\tpr.println(ans);\n\t\t//\n\t\t// Coded to Perfection by Rohan Mukhija\n\t\tpr.flush();\n\t\tpr.close();\n\t}\n\n\t/*\n\t * Template From Here\n\t */\n\tprivate static boolean possible(long[] arr, double mid, long k) {\n\t\tlong c = 0;\n\t\tfor (int i = 0; i < arr.length; i++) {\n\t\t\tc += ((arr[i]) / mid);\n\t\t\tif (c % arr[i] == 0)\n\t\t\t\tc--;\n\t\t}\n\t\t// System.out.println(mid+\" \"+c+\" \"+k);\n\t\tif (c <= k)\n\t\t\treturn true;\n\t\treturn false;\n\t}\n\n\tpublic static class Pair implements Comparable {\n\t\tint u;\n\t\tint v;\n\n\t\tPair(int u, int v, char c) {\n\t\t\tthis.u = u;\n\t\t\tthis.v = v;\n\n\t\t}\n\n\t\tpublic int compareTo(Pair compareEdge) {\n\t\t\treturn Long.compare(this.v, compareEdge.v);\n\t\t}\n\t};\n\n\tstatic void sort(long[] a) {\n\t\tArrayList l = new ArrayList<>();\n\t\tfor (long i : a)\n\t\t\tl.add(i);\n\t\tCollections.sort(l);\n\t\tfor (int i = 0; i < a.length; i++)\n\t\t\ta[i] = l.get(i);\n\t}\n\n\tstatic void sort(int[] a) {\n\t\tArrayList l = new ArrayList<>();\n\t\tfor (int i : a)\n\t\t\tl.add(i);\n\t\tCollections.sort(l);\n\t\tfor (int i = 0; i < a.length; i++)\n\t\t\ta[i] = l.get(i);\n\t}\n\n\tpublic static int lowerBound(ArrayList array, int length, long value) {\n\t\tint low = 0;\n\t\tint high = length;\n\t\twhile (low < high) {\n\t\t\tfinal int mid = (low + high) / 2;\n\t\t\tif (value <= array.get(mid)) {\n\t\t\t\thigh = mid;\n\t\t\t} else {\n\t\t\t\tlow = mid + 1;\n\t\t\t}\n\t\t}\n\t\treturn low;\n\t}\n\n\tpublic static long mul(long a, long b) {\n\t\treturn (a * b) % MOD;\n\t}\n\n\tstatic class FastReader {\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\n\t\tpublic FastReader() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\n\t\tString next() {\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\n\t\tpublic int[] nextIntArray(int n) {\n\t\t\tint[] a = new int[n];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\ta[i] = nextInt();\n\t\t\treturn a;\n\t\t}\n\n\t\tpublic long[] nextLongArray(int n) {\n\t\t\tlong[] a = new long[n];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\ta[i] = nextLong();\n\t\t\treturn a;\n\t\t}\n\t}\n\n\tstatic long gcd(long a, long b) {\n\t\tif (a == 0)\n\t\t\treturn b;\n\t\treturn gcd(b % a, a);\n\t}\n\n\tstatic long lcm(long a, long b) {\n\t\treturn (a * b) / gcd(a, b);\n\t}\n\n\tpublic static void sortbyColumn(int[][] att, int col) {\n\t\t// Using built-in sort function Arrays.sort\n\t\tArrays.sort(att, new Comparator() {\n\n\t\t\t@Override\n\t\t\t// Compare values according to columns\n\t\t\tpublic int compare(final int[] entry1, final int[] entry2) {\n\n\t\t\t\t// To sort in descending order revert\n\t\t\t\t// the '>' Operator\n\t\t\t\t// if (entry1[col] > entry2[col])\n\t\t\t\t// return 1;\n\t\t\t\t// else //(entry1[col] >= entry2[col])\n\t\t\t\t// return -1;\n\t\t\t\treturn new Integer(entry1[col]).compareTo(entry2[col]);\n\t\t\t\t// return entry1[col].\n\t\t\t}\n\t\t}); // End of function call sort().\n\t}\n\n\tpublic static void sortbyColumn(double[][] att, int col) {\n\t\t// Using built-in sort function Arrays.sort\n\t\tArrays.sort(att, new Comparator() {\n\n\t\t\t@Override\n\t\t\t// Compare values according to columns\n\t\t\tpublic int compare(final double[] entry1, final double[] entry2) {\n\n\t\t\t\t// To sort in descending order revert\n\t\t\t\t// the '>' Operator\n\t\t\t\t// if (entry1[col] > entry2[col])\n\t\t\t\t// return 1;\n\t\t\t\t// else //(entry1[col] >= entry2[col])\n\t\t\t\t// return -1;\n\t\t\t\treturn new Double(entry1[col]).compareTo(entry2[col]);\n\t\t\t\t// return entry1[col].\n\t\t\t}\n\t\t}); // End of function call sort().\n\t}\n\n\tstatic class pair {\n\t\tint V, I;\n\n\t\tpair(int v, int i) {\n\t\t\tV = v;\n\t\t\tI = i;\n\t\t}\n\t}\n\n\tpublic static int[] swap(int data[], int left, int right) {\n\t\tint temp = data[left];\n\t\tdata[left] = data[right];\n\t\tdata[right] = temp;\n\t\treturn data;\n\t}\n\n\tpublic static int[] reverse(int data[], int left, int right) {\n\t\twhile (left < right) {\n\t\t\tint temp = data[left];\n\t\t\tdata[left++] = data[right];\n\t\t\tdata[right--] = temp;\n\t\t}\n\t\treturn data;\n\t}\n\n\tpublic static boolean findNextPermutation(int data[]) {\n\t\tif (data.length <= 1)\n\t\t\treturn false;\n\n\t\tint last = data.length - 2;\n\t\twhile (last >= 0) {\n\t\t\tif (data[last] < data[last + 1]) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tlast--;\n\t\t}\n\t\tif (last < 0)\n\t\t\treturn false;\n\n\t\tint nextGreater = data.length - 1;\n\t\tfor (int i = data.length - 1; i > last; i--) {\n\t\t\tif (data[i] > data[last]) {\n\t\t\t\tnextGreater = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tdata = swap(data, nextGreater, last);\n\t\tdata = reverse(data, last + 1, data.length - 1);\n\t\treturn true;\n\t}\n\n\tstatic long ncr(long a, long b) {\n\t\tif (b > a - b)\n\t\t\treturn ncr(a, a - b);\n\t\tlong ansMul = 1;\n\t\tlong ansDiv = 1;\n\t\tfor (int i = 0; i < b; i++) {\n\t\t\tansMul *= (a - i);\n\t\t\tansDiv *= (i + 1);\n\t\t\tansMul %= MOD;\n\t\t\tansDiv %= MOD;\n\t\t}\n\n\t\tlong ans = ansMul * power(ansDiv, MOD - 2, MOD) % MOD;\n\n\t\treturn ans;\n\t}\n\n\tstatic long __gcd(long n1, long n2) {\n\t\tlong gcd = 1;\n\n\t\tfor (int i = 1; i <= n1 && i <= n2; ++i) {\n\t\t\t// Checks if i is factor of both integers\n\t\t\tif (n1 % i == 0 && n2 % i == 0) {\n\t\t\t\tgcd = i;\n\t\t\t}\n\t\t}\n\t\treturn gcd;\n\t}\n\n\tstatic long power(long prev, long n2, long mod2) {\n\t\tlong res = 1;\n\n\t\tprev = prev % mod2;\n\n\t\tif (prev == 0)\n\t\t\treturn 0;\n\t\twhile (n2 > 0) {\n\n\t\t\tif ((n2 & 1) == 1)\n\t\t\t\tres = (res * prev) % mod2;\n\n\t\t\tn2 = n2 >> 1;\n\t\t\tprev = (prev * prev) % mod2;\n\t\t}\n\t\treturn res;\n\t}\n\n\tstatic long modInverse(long fac2, int p) {\n\t\treturn power(fac2, p - 2, p);\n\t}\n\n\tstatic boolean isPrime(int n) {\n\t\t// Corner cases\n\t\tif (n <= 1)\n\t\t\treturn false;\n\t\tif (n <= 3)\n\t\t\treturn true;\n\n\t\t// This is checked so that we can skip\n\t\t// middle five numbers in below loop\n\t\tif (n % 2 == 0 || n % 3 == 0)\n\t\t\treturn false;\n\n\t\tfor (int i = 5; i * i <= n; i = i + 6)\n\t\t\tif (n % i == 0 || n % (i + 2) == 0)\n\t\t\t\treturn false;\n\n\t\treturn true;\n\t}\n\n\tpublic static BigInteger lcmm(String a, String b) {\n\t\tBigInteger s = new BigInteger(a);\n\t\tBigInteger s1 = new BigInteger(b);\n\t\tBigInteger mul = s.multiply(s1);\n\t\tBigInteger gcd = s.gcd(s1);\n\t\tBigInteger lcm = mul.divide(gcd);\n\t\treturn lcm;\n\t}\n\t/*\n\t * static boolean prime[] = new boolean[10000007]; static int spf[] = new\n\t * int[10000007];\n\t * \n\t * public static void sieveOfEratosthenes(int n) { for (int i = 2; i < n;\n\t * i++) prime[i] = true; for (int p = 2; p * p <= n; p++) {\n\t * \n\t * if (prime[p] == true) {\n\t * \n\t * for (int i = p * p; i <= n; i += p) { prime[i] = false; spf[i] = p; } } }\n\t * }\n\t */\n}\n", "language": "Java", "metadata": {"date": 1596439889, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02596.html", "problem_id": "p02596", "resource_group": "high_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/Java/s087304441.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s087304441", "user_id": "u225470629"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.io.*;\nimport java.math.*;\nimport java.util.*;\n\npublic class Main {\n\tstatic final int INF = (int) (1e9 + 10);\n\tstatic final long MOD = (int) (1e9 + 7);\n\tstatic final int N = (int) (4e5 + 5);\n\t// static ArrayList[] graph;\n\t// static boolean visited[];\n\t// static long size[];\n\n\tpublic static void main(String[] args) throws NumberFormatException, IOException {\n\t\tFastReader sc = new FastReader();\n\t\tPrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t// Scanner scn = new Scanner(System.in);\n\t\t//\n\t\tint n = sc.nextInt();\n\t\tint val = 7 % n;\n\t\tint ans = -1;\n\t\tfor (int i = 1; i <= 1e7; i++) {\n\t\t\tif (val == 0) {\n\t\t\t\tans = i;\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tval = (val * 10 + 7) % n;\n\t\t\t}\n\t\t}\n\t\tpr.println(ans);\n\t\t//\n\t\t// Coded to Perfection by Rohan Mukhija\n\t\tpr.flush();\n\t\tpr.close();\n\t}\n\n\t/*\n\t * Template From Here\n\t */\n\tprivate static boolean possible(long[] arr, double mid, long k) {\n\t\tlong c = 0;\n\t\tfor (int i = 0; i < arr.length; i++) {\n\t\t\tc += ((arr[i]) / mid);\n\t\t\tif (c % arr[i] == 0)\n\t\t\t\tc--;\n\t\t}\n\t\t// System.out.println(mid+\" \"+c+\" \"+k);\n\t\tif (c <= k)\n\t\t\treturn true;\n\t\treturn false;\n\t}\n\n\tpublic static class Pair implements Comparable {\n\t\tint u;\n\t\tint v;\n\n\t\tPair(int u, int v, char c) {\n\t\t\tthis.u = u;\n\t\t\tthis.v = v;\n\n\t\t}\n\n\t\tpublic int compareTo(Pair compareEdge) {\n\t\t\treturn Long.compare(this.v, compareEdge.v);\n\t\t}\n\t};\n\n\tstatic void sort(long[] a) {\n\t\tArrayList l = new ArrayList<>();\n\t\tfor (long i : a)\n\t\t\tl.add(i);\n\t\tCollections.sort(l);\n\t\tfor (int i = 0; i < a.length; i++)\n\t\t\ta[i] = l.get(i);\n\t}\n\n\tstatic void sort(int[] a) {\n\t\tArrayList l = new ArrayList<>();\n\t\tfor (int i : a)\n\t\t\tl.add(i);\n\t\tCollections.sort(l);\n\t\tfor (int i = 0; i < a.length; i++)\n\t\t\ta[i] = l.get(i);\n\t}\n\n\tpublic static int lowerBound(ArrayList array, int length, long value) {\n\t\tint low = 0;\n\t\tint high = length;\n\t\twhile (low < high) {\n\t\t\tfinal int mid = (low + high) / 2;\n\t\t\tif (value <= array.get(mid)) {\n\t\t\t\thigh = mid;\n\t\t\t} else {\n\t\t\t\tlow = mid + 1;\n\t\t\t}\n\t\t}\n\t\treturn low;\n\t}\n\n\tpublic static long mul(long a, long b) {\n\t\treturn (a * b) % MOD;\n\t}\n\n\tstatic class FastReader {\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\n\t\tpublic FastReader() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\n\t\tString next() {\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\n\t\tpublic int[] nextIntArray(int n) {\n\t\t\tint[] a = new int[n];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\ta[i] = nextInt();\n\t\t\treturn a;\n\t\t}\n\n\t\tpublic long[] nextLongArray(int n) {\n\t\t\tlong[] a = new long[n];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\ta[i] = nextLong();\n\t\t\treturn a;\n\t\t}\n\t}\n\n\tstatic long gcd(long a, long b) {\n\t\tif (a == 0)\n\t\t\treturn b;\n\t\treturn gcd(b % a, a);\n\t}\n\n\tstatic long lcm(long a, long b) {\n\t\treturn (a * b) / gcd(a, b);\n\t}\n\n\tpublic static void sortbyColumn(int[][] att, int col) {\n\t\t// Using built-in sort function Arrays.sort\n\t\tArrays.sort(att, new Comparator() {\n\n\t\t\t@Override\n\t\t\t// Compare values according to columns\n\t\t\tpublic int compare(final int[] entry1, final int[] entry2) {\n\n\t\t\t\t// To sort in descending order revert\n\t\t\t\t// the '>' Operator\n\t\t\t\t// if (entry1[col] > entry2[col])\n\t\t\t\t// return 1;\n\t\t\t\t// else //(entry1[col] >= entry2[col])\n\t\t\t\t// return -1;\n\t\t\t\treturn new Integer(entry1[col]).compareTo(entry2[col]);\n\t\t\t\t// return entry1[col].\n\t\t\t}\n\t\t}); // End of function call sort().\n\t}\n\n\tpublic static void sortbyColumn(double[][] att, int col) {\n\t\t// Using built-in sort function Arrays.sort\n\t\tArrays.sort(att, new Comparator() {\n\n\t\t\t@Override\n\t\t\t// Compare values according to columns\n\t\t\tpublic int compare(final double[] entry1, final double[] entry2) {\n\n\t\t\t\t// To sort in descending order revert\n\t\t\t\t// the '>' Operator\n\t\t\t\t// if (entry1[col] > entry2[col])\n\t\t\t\t// return 1;\n\t\t\t\t// else //(entry1[col] >= entry2[col])\n\t\t\t\t// return -1;\n\t\t\t\treturn new Double(entry1[col]).compareTo(entry2[col]);\n\t\t\t\t// return entry1[col].\n\t\t\t}\n\t\t}); // End of function call sort().\n\t}\n\n\tstatic class pair {\n\t\tint V, I;\n\n\t\tpair(int v, int i) {\n\t\t\tV = v;\n\t\t\tI = i;\n\t\t}\n\t}\n\n\tpublic static int[] swap(int data[], int left, int right) {\n\t\tint temp = data[left];\n\t\tdata[left] = data[right];\n\t\tdata[right] = temp;\n\t\treturn data;\n\t}\n\n\tpublic static int[] reverse(int data[], int left, int right) {\n\t\twhile (left < right) {\n\t\t\tint temp = data[left];\n\t\t\tdata[left++] = data[right];\n\t\t\tdata[right--] = temp;\n\t\t}\n\t\treturn data;\n\t}\n\n\tpublic static boolean findNextPermutation(int data[]) {\n\t\tif (data.length <= 1)\n\t\t\treturn false;\n\n\t\tint last = data.length - 2;\n\t\twhile (last >= 0) {\n\t\t\tif (data[last] < data[last + 1]) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tlast--;\n\t\t}\n\t\tif (last < 0)\n\t\t\treturn false;\n\n\t\tint nextGreater = data.length - 1;\n\t\tfor (int i = data.length - 1; i > last; i--) {\n\t\t\tif (data[i] > data[last]) {\n\t\t\t\tnextGreater = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tdata = swap(data, nextGreater, last);\n\t\tdata = reverse(data, last + 1, data.length - 1);\n\t\treturn true;\n\t}\n\n\tstatic long ncr(long a, long b) {\n\t\tif (b > a - b)\n\t\t\treturn ncr(a, a - b);\n\t\tlong ansMul = 1;\n\t\tlong ansDiv = 1;\n\t\tfor (int i = 0; i < b; i++) {\n\t\t\tansMul *= (a - i);\n\t\t\tansDiv *= (i + 1);\n\t\t\tansMul %= MOD;\n\t\t\tansDiv %= MOD;\n\t\t}\n\n\t\tlong ans = ansMul * power(ansDiv, MOD - 2, MOD) % MOD;\n\n\t\treturn ans;\n\t}\n\n\tstatic long __gcd(long n1, long n2) {\n\t\tlong gcd = 1;\n\n\t\tfor (int i = 1; i <= n1 && i <= n2; ++i) {\n\t\t\t// Checks if i is factor of both integers\n\t\t\tif (n1 % i == 0 && n2 % i == 0) {\n\t\t\t\tgcd = i;\n\t\t\t}\n\t\t}\n\t\treturn gcd;\n\t}\n\n\tstatic long power(long prev, long n2, long mod2) {\n\t\tlong res = 1;\n\n\t\tprev = prev % mod2;\n\n\t\tif (prev == 0)\n\t\t\treturn 0;\n\t\twhile (n2 > 0) {\n\n\t\t\tif ((n2 & 1) == 1)\n\t\t\t\tres = (res * prev) % mod2;\n\n\t\t\tn2 = n2 >> 1;\n\t\t\tprev = (prev * prev) % mod2;\n\t\t}\n\t\treturn res;\n\t}\n\n\tstatic long modInverse(long fac2, int p) {\n\t\treturn power(fac2, p - 2, p);\n\t}\n\n\tstatic boolean isPrime(int n) {\n\t\t// Corner cases\n\t\tif (n <= 1)\n\t\t\treturn false;\n\t\tif (n <= 3)\n\t\t\treturn true;\n\n\t\t// This is checked so that we can skip\n\t\t// middle five numbers in below loop\n\t\tif (n % 2 == 0 || n % 3 == 0)\n\t\t\treturn false;\n\n\t\tfor (int i = 5; i * i <= n; i = i + 6)\n\t\t\tif (n % i == 0 || n % (i + 2) == 0)\n\t\t\t\treturn false;\n\n\t\treturn true;\n\t}\n\n\tpublic static BigInteger lcmm(String a, String b) {\n\t\tBigInteger s = new BigInteger(a);\n\t\tBigInteger s1 = new BigInteger(b);\n\t\tBigInteger mul = s.multiply(s1);\n\t\tBigInteger gcd = s.gcd(s1);\n\t\tBigInteger lcm = mul.divide(gcd);\n\t\treturn lcm;\n\t}\n\t/*\n\t * static boolean prime[] = new boolean[10000007]; static int spf[] = new\n\t * int[10000007];\n\t * \n\t * public static void sieveOfEratosthenes(int n) { for (int i = 2; i < n;\n\t * i++) prime[i] = true; for (int p = 2; p * p <= n; p++) {\n\t * \n\t * if (prime[p] == true) {\n\t * \n\t * for (int i = p * p; i <= n; i += p) { prime[i] = false; spf[i] = p; } } }\n\t * }\n\t */\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": 7343, "cpu_time_ms": 192, "memory_kb": 33256}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s814225839", "group_id": "codeNet:p02598", "input_text": "import java.util.*;\nimport java.io.*;\n \npublic class Main {\n public static void main(String[] args) throws Exception {\n FastScanner sc = new FastScanner(System.in);\n PrintWriter pw = new PrintWriter(System.out);\n int n = sc.nextInt();\n int k = sc.nextInt();\n long[] a = sc.nextLongArray(n);\n if(k == 0){\n long max = 0;\n for(long v : a){\n max = Math.max(max,v);\n }\n pw.println(max);\n }else{\n int left = 0;\n int right = (int)1e9+1;\n while(right - left > 1){\n int mid = (right+left)/2; //丸太の最大長さ\n int cnt = 0; //何回切るか\n for(int i = 0; i < n; i++){\n if(mid >= a[i]){\n continue;\n }\n cnt += (int)(a[i]/mid);\n if(a[i]%mid == 0){\n cnt--;\n }\n }\n if(cnt <= k){ \n right = mid;\n }else{\n left = mid;\n }\n }\n pw.println(right);\n }\n pw.flush();\n }\n\n static class GeekInteger {\n public static void save_sort(int[] array) {\n shuffle(array);\n Arrays.sort(array);\n }\n \n public static int[] shuffle(int[] array) {\n int n = array.length;\n Random random = new Random();\n for (int i = 0, j; i < n; i++) {\n j = i + random.nextInt(n - i);\n int randomElement = array[j];\n array[j] = array[i];\n array[i] = randomElement;\n }\n return array;\n }\n \n }\n}\n\nclass FastScanner {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n public FastScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n tokenizer = null;\n }\n\n public String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken(\"\\n\");\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n \n public String[] nextArray(int n) {\n String[] a = new String[n];\n for (int i = 0; i < n; i++)\n a[i] = next();\n return a;\n }\n\n public int[] nextIntArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = nextInt();\n return a;\n }\n\n public long[] nextLongArray(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = nextLong();\n return a;\n } \n}\n", "language": "Java", "metadata": {"date": 1596417833, "filename_ext": "java", "original_language": "Java (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02598.html", "problem_id": "p02598", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02598/input.txt", "sample_output_relpath": "derived/input_output/data/p02598/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02598/Java/s814225839.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s814225839", "user_id": "u578775554"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\n \npublic class Main {\n public static void main(String[] args) throws Exception {\n FastScanner sc = new FastScanner(System.in);\n PrintWriter pw = new PrintWriter(System.out);\n int n = sc.nextInt();\n int k = sc.nextInt();\n long[] a = sc.nextLongArray(n);\n if(k == 0){\n long max = 0;\n for(long v : a){\n max = Math.max(max,v);\n }\n pw.println(max);\n }else{\n int left = 0;\n int right = (int)1e9+1;\n while(right - left > 1){\n int mid = (right+left)/2; //丸太の最大長さ\n int cnt = 0; //何回切るか\n for(int i = 0; i < n; i++){\n if(mid >= a[i]){\n continue;\n }\n cnt += (int)(a[i]/mid);\n if(a[i]%mid == 0){\n cnt--;\n }\n }\n if(cnt <= k){ \n right = mid;\n }else{\n left = mid;\n }\n }\n pw.println(right);\n }\n pw.flush();\n }\n\n static class GeekInteger {\n public static void save_sort(int[] array) {\n shuffle(array);\n Arrays.sort(array);\n }\n \n public static int[] shuffle(int[] array) {\n int n = array.length;\n Random random = new Random();\n for (int i = 0, j; i < n; i++) {\n j = i + random.nextInt(n - i);\n int randomElement = array[j];\n array[j] = array[i];\n array[i] = randomElement;\n }\n return array;\n }\n \n }\n}\n\nclass FastScanner {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n public FastScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n tokenizer = null;\n }\n\n public String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken(\"\\n\");\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n \n public String[] nextArray(int n) {\n String[] a = new String[n];\n for (int i = 0; i < n; i++)\n a[i] = next();\n return a;\n }\n\n public int[] nextIntArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = nextInt();\n return a;\n }\n\n public long[] nextLongArray(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = nextLong();\n return a;\n } \n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have N logs of lengths A_1,A_2,\\cdots A_N.\n\nWe can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (00) {\n\t\tif(bg&&g>r) {\n\t\tSystem.out.println(\"Yes\");\n\t}else {\n\t\tSystem.out.println(\"No\");\n\t}\n\t\n\t\n}\n}", "language": "Java", "metadata": {"date": 1595727835, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02601.html", "problem_id": "p02601", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02601/input.txt", "sample_output_relpath": "derived/input_output/data/p02601/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02601/Java/s725918001.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s725918001", "user_id": "u701299971"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main {\npublic static void main(String args[]) {\n\tScanner sc =new Scanner(System.in);\n\tint r=sc.nextInt();\n\tint g=sc.nextInt();\n\tint b=sc.nextInt();\n\tint k=sc.nextInt();\n\twhile(k>0) {\n\t\tif(bg&&g>r) {\n\t\tSystem.out.println(\"Yes\");\n\t}else {\n\t\tSystem.out.println(\"No\");\n\t}\n\t\n\t\n}\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nM-kun has the following three cards:\n\nA red card with the integer A.\n\nA green card with the integer B.\n\nA blue card with the integer C.\n\nHe is a genius magician who can do the following operation at most K times:\n\nChoose one of the three cards and multiply the written integer by 2.\n\nHis magic is successful if both of the following conditions are satisfied after the operations:\n\nThe integer on the green card is strictly greater than the integer on the red card.\n\nThe integer on the blue card is strictly greater than the integer on the green card.\n\nDetermine whether the magic can be successful.\n\nConstraints\n\n1 \\leq A, B, C \\leq 7\n\n1 \\leq K \\leq 7\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nIf the magic can be successful, print Yes; otherwise, print No.\n\nSample Input 1\n\n7 2 5\n3\n\nSample Output 1\n\nYes\n\nThe magic will be successful if, for example, he does the following operations:\n\nFirst, choose the blue card. The integers on the red, green, and blue cards are now 7, 2, and 10, respectively.\n\nSecond, choose the green card. The integers on the red, green, and blue cards are now 7, 4, and 10, respectively.\n\nThird, choose the green card. The integers on the red, green, and blue cards are now 7, 8, and 10, respectively.\n\nSample Input 2\n\n7 4 2\n3\n\nSample Output 2\n\nNo\n\nHe has no way to succeed in the magic with at most three operations.", "sample_input": "7 2 5\n3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02601", "source_text": "Score: 200 points\n\nProblem Statement\n\nM-kun has the following three cards:\n\nA red card with the integer A.\n\nA green card with the integer B.\n\nA blue card with the integer C.\n\nHe is a genius magician who can do the following operation at most K times:\n\nChoose one of the three cards and multiply the written integer by 2.\n\nHis magic is successful if both of the following conditions are satisfied after the operations:\n\nThe integer on the green card is strictly greater than the integer on the red card.\n\nThe integer on the blue card is strictly greater than the integer on the green card.\n\nDetermine whether the magic can be successful.\n\nConstraints\n\n1 \\leq A, B, C \\leq 7\n\n1 \\leq K \\leq 7\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nIf the magic can be successful, print Yes; otherwise, print No.\n\nSample Input 1\n\n7 2 5\n3\n\nSample Output 1\n\nYes\n\nThe magic will be successful if, for example, he does the following operations:\n\nFirst, choose the blue card. The integers on the red, green, and blue cards are now 7, 2, and 10, respectively.\n\nSecond, choose the green card. The integers on the red, green, and blue cards are now 7, 4, and 10, respectively.\n\nThird, choose the green card. The integers on the red, green, and blue cards are now 7, 8, and 10, respectively.\n\nSample Input 2\n\n7 4 2\n3\n\nSample Output 2\n\nNo\n\nHe has no way to succeed in the magic with at most three operations.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 615, "cpu_time_ms": 120, "memory_kb": 35624}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s682928205", "group_id": "codeNet:p02601", "input_text": "import java.io.*;\nimport java.util.*;\n\npublic class Main{\n static class FastReader{\n BufferedReader br;\n StringTokenizer st;\n public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}\n String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException e){e.printStackTrace();}}return st.nextToken();}\n int nextInt(){return Integer.parseInt(next());}\n long nextLong(){return Long.parseLong(next());}\n double nextDouble(){return Double.parseDouble(next());}\n int[] readArray(int n){int[] a=new int[n];for (int i=0; i n2) n1 -= n2;\n else n2 -= n1;\n }\n return n1;\n }\n static boolean isSorted(int[] arr, int n){\n for(int i=1;i n2) n1 -= n2;\n else n2 -= n1;\n }\n return n1;\n }\n static boolean isSorted(int[] arr, int n){\n for(int i=1;i0) {\n System.out.println(\"Yes\");\n count++;\n }\n else{\n System.out.println(\"No\");\n count++;\n }\n\n }\n }\n}", "language": "Java", "metadata": {"date": 1595809663, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02602.html", "problem_id": "p02602", "resource_group": "high_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/Java/s344150604.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s344150604", "user_id": "u596403663"}, "prompt_components": {"gold_output": "Yes\nNo\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();int k=sc.nextInt();int[] array = new int[n];\n for(int i=0;i0) {\n System.out.println(\"Yes\");\n count++;\n }\n else{\n System.out.println(\"No\");\n count++;\n }\n\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": 803, "cpu_time_ms": 2208, "memory_kb": 60928}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s063196739", "group_id": "codeNet:p02602", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint k = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tfor (int i = k; i < n; i++) {\n\t\t\tSystem.out.println(a[i - k] < a[i] ? \"Yes\" : \"No\");\n\t\t}\n\t}\n\n}", "language": "Java", "metadata": {"date": 1595728146, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02602.html", "problem_id": "p02602", "resource_group": "high_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/Java/s063196739.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s063196739", "user_id": "u686205370"}, "prompt_components": {"gold_output": "Yes\nNo\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint k = sc.nextInt();\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\t\n\t\tfor (int i = k; i < n; i++) {\n\t\t\tSystem.out.println(a[i - k] < a[i] ? \"Yes\" : \"No\");\n\t\t}\n\t}\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": 367, "cpu_time_ms": 1290, "memory_kb": 58856}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s770523565", "group_id": "codeNet:p02605", "input_text": "import java.io.*;\nimport java.math.*;\nimport java.util.*;\n \npublic class Main {\n\tstatic final long MOD = 1000000007L;\n\tstatic final int INF = 50000000;\n\tpublic static void main(String[] args) {\n\t\tFastScanner sc = new FastScanner();\n\t\tPrintWriter pw = new PrintWriter(System.out);\n\t\t\n\t\tint N = sc.ni();\n\t\tArrayList up = new ArrayList();\n\t\tArrayList down = new ArrayList();\n\t\tArrayList left = new ArrayList();\n\t\tArrayList right = new ArrayList();\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tint x = sc.ni();\n\t\t\tint y = sc.ni();\n\t\t\tchar c = sc.next().charAt(0);\n\t\t\tint[] pair = new int[] {x,y,c};\n\t\t\tif (c=='U')\n\t\t\t\tup.add(pair);\n\t\t\telse if (c=='D')\n\t\t\t\tdown.add(pair);\n\t\t\telse if (c=='L')\n\t\t\t\tleft.add(pair);\n\t\t\telse\n\t\t\t\tright.add(pair);\n\t\t}\n\t\tint ans = INF;\n\t\tPriorityQueue pq1 = new PriorityQueue(new Comparator() {\n\t\t\t@Override\n\t\t\tpublic int compare(int[] arr1, int[] arr2) {\n\t\t\t\treturn arr1[0]-arr2[0];\n\t\t\t}\n\t\t});\n\t\tPriorityQueue pq2 = new PriorityQueue(new Comparator() {\n\t\t\t@Override\n\t\t\tpublic int compare(int[] arr1, int[] arr2) {\n\t\t\t\treturn arr2[0]-arr1[0];\n\t\t\t}\n\t\t});\n\t\t\n\t\t//UR\n\t\tfor (int[] pair: up)\n\t\t\tpq1.add(pair);\n\t\tfor (int[] pair: right)\n\t\t\tpq1.add(pair);\n\t\tHashMap hm = new HashMap();\n\t\twhile (!pq1.isEmpty()) {\n\t\t\tint[] pair = pq1.poll();\n\t\t\tint val = pair[1]+pair[0];\n\t\t\tif (pair[2]=='U') {\n\t\t\t\tif (hm.containsKey(val)) {\n\t\t\t\t\tint diff = Math.abs(pair[0]-hm.get(val));\n\t\t\t\t\tans = Math.min(ans,diff);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\thm.put(val, pair[0]);\n\t\t\t}\n\t\t}\n\t\t//UL\n\t\tfor (int[] pair: up)\n\t\t\tpq2.add(pair);\n\t\tfor (int[] pair: left)\n\t\t\tpq2.add(pair);\n\t\thm = new HashMap();\n\t\twhile (!pq2.isEmpty()) {\n\t\t\tint[] pair = pq2.poll();\n\t\t\tint val = pair[1]-pair[0];\n\t\t\tif (pair[2]=='U') {\n\t\t\t\tif (hm.containsKey(val)) {\n\t\t\t\t\tint diff = Math.abs(hm.get(val)-pair[0]);\n\t\t\t\t\tans = Math.min(ans,diff);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\thm.put(val, pair[0]);\n\t\t\t}\n\t\t}\n\t\t//DR\n\t\tfor (int[] pair: down)\n\t\t\tpq1.add(pair);\n\t\tfor (int[] pair: right)\n\t\t\tpq1.add(pair);\n\t\thm = new HashMap();\n\t\twhile (!pq1.isEmpty()) {\n\t\t\tint[] pair = pq1.poll();\n\t\t\tint val = pair[1]-pair[0];\n\t\t\tif (pair[2]=='D') {\n\t\t\t\tif (hm.containsKey(val)) {\n\t\t\t\t\tint diff = Math.abs(pair[0]-hm.get(val));\n\t\t\t\t\tans = Math.min(ans,diff);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\thm.put(val, pair[0]);\n\t\t\t}\n\t\t}\n\t\t\n\t\t//DL\n\t\tfor (int[] pair: down)\n\t\t\tpq2.add(pair);\n\t\tfor (int[] pair: left)\n\t\t\tpq2.add(pair);\n\t\thm = new HashMap();\n\t\twhile (!pq2.isEmpty()) {\n\t\t\tint[] pair = pq2.poll();\n\t\t\tint val = pair[1]+pair[0];\n\t\t\tif (pair[2]=='D') {\n\t\t\t\tif (hm.containsKey(val)) {\n\t\t\t\t\tint diff = Math.abs(hm.get(val)-pair[0]);\n\t\t\t\t\tans = Math.min(ans,diff);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\thm.put(val, pair[0]);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\tint ans2 = INF;\n\t\t//UD\n\t\tTreeSet[] ts = new TreeSet[200001];\n\t\tfor (int[] pair: down) {\n\t\t\tif (ts[pair[0]]==null) {\n\t\t\t\tts[pair[0]] = new TreeSet();\n\t\t\t}\n\t\t\tts[pair[0]].add(pair[1]);\n\t\t}\n\t\tfor (int[] pair: up) {\n\t\t\tif (ts[pair[0]]!=null) {\n\t\t\t\tInteger collision = ts[pair[0]].higher(pair[1]);\n\t\t\t\tif (collision != null) {\n\t\t\t\t\tint diff = Math.abs(collision-pair[1]);\n\t\t\t\t\tans2 = Math.min(ans2, diff);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t//LR\n\t\tfor (int i = 0; i <= 200000; i++)\n\t\t\tts[i] = null;\n\t\tfor (int[] pair: right) {\n\t\t\tif (ts[pair[1]]==null) {\n\t\t\t\tts[pair[1]] = new TreeSet();\n\t\t\t}\n\t\t\tts[pair[1]].add(pair[0]);\n\t\t}\n\t\tfor (int[] pair: left) {\n\t\t\tif (ts[pair[1]]!=null) {\n\t\t\t\tInteger collision = ts[pair[1]].lower(pair[0]);\n\t\t\t\tif (collision != null) {\n\t\t\t\t\tint diff = Math.abs(pair[0]-collision);\n\t\t\t\t\tans2 = Math.min(ans2, diff);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tint finalAns = Math.min(10*ans, 5*ans2);\n\t\tif (finalAns >= INF) {\n\t\t\tpw.println(\"SAFE\");\n\t\t} else {\n\t\t\tpw.println(finalAns);\n\t\t}\n\t\t\n\t\tpw.close();\n\t}\n\t\n static class FastScanner { \n BufferedReader br; \n StringTokenizer st; \n \n public FastScanner() { \n br = new BufferedReader(new InputStreamReader(System.in)); \n } \n \n String next() { \n while (st == null || !st.hasMoreElements()) { \n try { \n st = new StringTokenizer(br.readLine());\n } catch (IOException e) { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n }\n \n int ni() { \n return Integer.parseInt(next()); \n }\n \n long nl() { \n return Long.parseLong(next()); \n } \n \n double nd() { \n return Double.parseDouble(next()); \n } \n \n String nextLine() {\n String str = \"\"; \n try { \n str = br.readLine(); \n } catch (IOException e) {\n e.printStackTrace(); \n } \n return str;\n }\n }\n}", "language": "Java", "metadata": {"date": 1597761834, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02605.html", "problem_id": "p02605", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02605/input.txt", "sample_output_relpath": "derived/input_output/data/p02605/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02605/Java/s770523565.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s770523565", "user_id": "u495186373"}, "prompt_components": {"gold_output": "230\n", "input_to_evaluate": "import java.io.*;\nimport java.math.*;\nimport java.util.*;\n \npublic class Main {\n\tstatic final long MOD = 1000000007L;\n\tstatic final int INF = 50000000;\n\tpublic static void main(String[] args) {\n\t\tFastScanner sc = new FastScanner();\n\t\tPrintWriter pw = new PrintWriter(System.out);\n\t\t\n\t\tint N = sc.ni();\n\t\tArrayList up = new ArrayList();\n\t\tArrayList down = new ArrayList();\n\t\tArrayList left = new ArrayList();\n\t\tArrayList right = new ArrayList();\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tint x = sc.ni();\n\t\t\tint y = sc.ni();\n\t\t\tchar c = sc.next().charAt(0);\n\t\t\tint[] pair = new int[] {x,y,c};\n\t\t\tif (c=='U')\n\t\t\t\tup.add(pair);\n\t\t\telse if (c=='D')\n\t\t\t\tdown.add(pair);\n\t\t\telse if (c=='L')\n\t\t\t\tleft.add(pair);\n\t\t\telse\n\t\t\t\tright.add(pair);\n\t\t}\n\t\tint ans = INF;\n\t\tPriorityQueue pq1 = new PriorityQueue(new Comparator() {\n\t\t\t@Override\n\t\t\tpublic int compare(int[] arr1, int[] arr2) {\n\t\t\t\treturn arr1[0]-arr2[0];\n\t\t\t}\n\t\t});\n\t\tPriorityQueue pq2 = new PriorityQueue(new Comparator() {\n\t\t\t@Override\n\t\t\tpublic int compare(int[] arr1, int[] arr2) {\n\t\t\t\treturn arr2[0]-arr1[0];\n\t\t\t}\n\t\t});\n\t\t\n\t\t//UR\n\t\tfor (int[] pair: up)\n\t\t\tpq1.add(pair);\n\t\tfor (int[] pair: right)\n\t\t\tpq1.add(pair);\n\t\tHashMap hm = new HashMap();\n\t\twhile (!pq1.isEmpty()) {\n\t\t\tint[] pair = pq1.poll();\n\t\t\tint val = pair[1]+pair[0];\n\t\t\tif (pair[2]=='U') {\n\t\t\t\tif (hm.containsKey(val)) {\n\t\t\t\t\tint diff = Math.abs(pair[0]-hm.get(val));\n\t\t\t\t\tans = Math.min(ans,diff);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\thm.put(val, pair[0]);\n\t\t\t}\n\t\t}\n\t\t//UL\n\t\tfor (int[] pair: up)\n\t\t\tpq2.add(pair);\n\t\tfor (int[] pair: left)\n\t\t\tpq2.add(pair);\n\t\thm = new HashMap();\n\t\twhile (!pq2.isEmpty()) {\n\t\t\tint[] pair = pq2.poll();\n\t\t\tint val = pair[1]-pair[0];\n\t\t\tif (pair[2]=='U') {\n\t\t\t\tif (hm.containsKey(val)) {\n\t\t\t\t\tint diff = Math.abs(hm.get(val)-pair[0]);\n\t\t\t\t\tans = Math.min(ans,diff);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\thm.put(val, pair[0]);\n\t\t\t}\n\t\t}\n\t\t//DR\n\t\tfor (int[] pair: down)\n\t\t\tpq1.add(pair);\n\t\tfor (int[] pair: right)\n\t\t\tpq1.add(pair);\n\t\thm = new HashMap();\n\t\twhile (!pq1.isEmpty()) {\n\t\t\tint[] pair = pq1.poll();\n\t\t\tint val = pair[1]-pair[0];\n\t\t\tif (pair[2]=='D') {\n\t\t\t\tif (hm.containsKey(val)) {\n\t\t\t\t\tint diff = Math.abs(pair[0]-hm.get(val));\n\t\t\t\t\tans = Math.min(ans,diff);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\thm.put(val, pair[0]);\n\t\t\t}\n\t\t}\n\t\t\n\t\t//DL\n\t\tfor (int[] pair: down)\n\t\t\tpq2.add(pair);\n\t\tfor (int[] pair: left)\n\t\t\tpq2.add(pair);\n\t\thm = new HashMap();\n\t\twhile (!pq2.isEmpty()) {\n\t\t\tint[] pair = pq2.poll();\n\t\t\tint val = pair[1]+pair[0];\n\t\t\tif (pair[2]=='D') {\n\t\t\t\tif (hm.containsKey(val)) {\n\t\t\t\t\tint diff = Math.abs(hm.get(val)-pair[0]);\n\t\t\t\t\tans = Math.min(ans,diff);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\thm.put(val, pair[0]);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\tint ans2 = INF;\n\t\t//UD\n\t\tTreeSet[] ts = new TreeSet[200001];\n\t\tfor (int[] pair: down) {\n\t\t\tif (ts[pair[0]]==null) {\n\t\t\t\tts[pair[0]] = new TreeSet();\n\t\t\t}\n\t\t\tts[pair[0]].add(pair[1]);\n\t\t}\n\t\tfor (int[] pair: up) {\n\t\t\tif (ts[pair[0]]!=null) {\n\t\t\t\tInteger collision = ts[pair[0]].higher(pair[1]);\n\t\t\t\tif (collision != null) {\n\t\t\t\t\tint diff = Math.abs(collision-pair[1]);\n\t\t\t\t\tans2 = Math.min(ans2, diff);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t//LR\n\t\tfor (int i = 0; i <= 200000; i++)\n\t\t\tts[i] = null;\n\t\tfor (int[] pair: right) {\n\t\t\tif (ts[pair[1]]==null) {\n\t\t\t\tts[pair[1]] = new TreeSet();\n\t\t\t}\n\t\t\tts[pair[1]].add(pair[0]);\n\t\t}\n\t\tfor (int[] pair: left) {\n\t\t\tif (ts[pair[1]]!=null) {\n\t\t\t\tInteger collision = ts[pair[1]].lower(pair[0]);\n\t\t\t\tif (collision != null) {\n\t\t\t\t\tint diff = Math.abs(pair[0]-collision);\n\t\t\t\t\tans2 = Math.min(ans2, diff);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tint finalAns = Math.min(10*ans, 5*ans2);\n\t\tif (finalAns >= INF) {\n\t\t\tpw.println(\"SAFE\");\n\t\t} else {\n\t\t\tpw.println(finalAns);\n\t\t}\n\t\t\n\t\tpw.close();\n\t}\n\t\n static class FastScanner { \n BufferedReader br; \n StringTokenizer st; \n \n public FastScanner() { \n br = new BufferedReader(new InputStreamReader(System.in)); \n } \n \n String next() { \n while (st == null || !st.hasMoreElements()) { \n try { \n st = new StringTokenizer(br.readLine());\n } catch (IOException e) { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n }\n \n int ni() { \n return Integer.parseInt(next()); \n }\n \n long nl() { \n return Long.parseLong(next()); \n } \n \n double nd() { \n return Double.parseDouble(next()); \n } \n \n String nextLine() {\n String str = \"\"; \n try { \n str = br.readLine(); \n } catch (IOException e) {\n e.printStackTrace(); \n } \n return str;\n }\n }\n}", "problem_context": "Score: 600 points\n\nProblem Statement\n\nM-kun is a brilliant air traffic controller.\n\nOn the display of his radar, there are N airplanes numbered 1, 2, ..., N, all flying at the same altitude.\n\nEach of the airplanes flies at a constant speed of 0.1 per second in a constant direction. The current coordinates of the airplane numbered i are (X_i, Y_i), and the direction of the airplane is as follows:\n\nif U_i is U, it flies in the positive y direction;\n\nif U_i is R, it flies in the positive x direction;\n\nif U_i is D, it flies in the negative y direction;\n\nif U_i is L, it flies in the negative x direction.\n\nTo help M-kun in his work, determine whether there is a pair of airplanes that will collide with each other if they keep flying as they are now.\n\nIf there is such a pair, find the number of seconds after which the first collision will happen.\n\nWe assume that the airplanes are negligibly small so that two airplanes only collide when they reach the same coordinates simultaneously.\n\nConstraints\n\n1 \\leq N \\leq 200000\n\n0 \\leq X_i, Y_i \\leq 200000\n\nU_i is U, R, D, or L.\n\nThe current positions of the N airplanes, (X_i, Y_i), are all distinct.\n\nN, X_i, and Y_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 Y_1 U_1\nX_2 Y_2 U_2\nX_3 Y_3 U_3\n:\nX_N Y_N U_N\n\nOutput\n\nIf there is a pair of airplanes that will collide with each other if they keep flying as they are now, print an integer representing the number of seconds after which the first collision will happen.\n\nIf there is no such pair, print SAFE.\n\nSample Input 1\n\n2\n11 1 U\n11 47 D\n\nSample Output 1\n\n230\n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2 will reach the coordinates (11, 24) simultaneously and collide.\n\nSample Input 2\n\n4\n20 30 U\n30 20 R\n20 10 D\n10 20 L\n\nSample Output 2\n\nSAFE\n\nNo pair of airplanes will collide.\n\nSample Input 3\n\n8\n168 224 U\n130 175 R\n111 198 D\n121 188 L\n201 116 U\n112 121 R\n145 239 D\n185 107 L\n\nSample Output 3\n\n100", "sample_input": "2\n11 1 U\n11 47 D\n"}, "reference_outputs": ["230\n"], "source_document_id": "p02605", "source_text": "Score: 600 points\n\nProblem Statement\n\nM-kun is a brilliant air traffic controller.\n\nOn the display of his radar, there are N airplanes numbered 1, 2, ..., N, all flying at the same altitude.\n\nEach of the airplanes flies at a constant speed of 0.1 per second in a constant direction. The current coordinates of the airplane numbered i are (X_i, Y_i), and the direction of the airplane is as follows:\n\nif U_i is U, it flies in the positive y direction;\n\nif U_i is R, it flies in the positive x direction;\n\nif U_i is D, it flies in the negative y direction;\n\nif U_i is L, it flies in the negative x direction.\n\nTo help M-kun in his work, determine whether there is a pair of airplanes that will collide with each other if they keep flying as they are now.\n\nIf there is such a pair, find the number of seconds after which the first collision will happen.\n\nWe assume that the airplanes are negligibly small so that two airplanes only collide when they reach the same coordinates simultaneously.\n\nConstraints\n\n1 \\leq N \\leq 200000\n\n0 \\leq X_i, Y_i \\leq 200000\n\nU_i is U, R, D, or L.\n\nThe current positions of the N airplanes, (X_i, Y_i), are all distinct.\n\nN, X_i, and Y_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 Y_1 U_1\nX_2 Y_2 U_2\nX_3 Y_3 U_3\n:\nX_N Y_N U_N\n\nOutput\n\nIf there is a pair of airplanes that will collide with each other if they keep flying as they are now, print an integer representing the number of seconds after which the first collision will happen.\n\nIf there is no such pair, print SAFE.\n\nSample Input 1\n\n2\n11 1 U\n11 47 D\n\nSample Output 1\n\n230\n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2 will reach the coordinates (11, 24) simultaneously and collide.\n\nSample Input 2\n\n4\n20 30 U\n30 20 R\n20 10 D\n10 20 L\n\nSample Output 2\n\nSAFE\n\nNo pair of airplanes will collide.\n\nSample Input 3\n\n8\n168 224 U\n130 175 R\n111 198 D\n121 188 L\n201 116 U\n112 121 R\n145 239 D\n185 107 L\n\nSample Output 3\n\n100", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4867, "cpu_time_ms": 882, "memory_kb": 81648}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s641880369", "group_id": "codeNet:p02608", "input_text": "import java.util.*;\nimport java.io.*;\n\npublic class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = Integer.parseInt(sc.next());\n PrintWriter pw = new PrintWriter(System.out);\n for(int i=1;i<=N;i++){\n int count = 0;\n for(int x=1;x*x<=N;x++){\n for(int y=1;y*y<=N;y++){\n for(int z=1;z*z<=N;z++){\n if(x*x+y*y+z*z+x*y+y*z+z*x==i){\n count++;\n }\n }\n }\n } \n pw.println(count);\n pw.flush();\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1594519935, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02608.html", "problem_id": "p02608", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02608/input.txt", "sample_output_relpath": "derived/input_output/data/p02608/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02608/Java/s641880369.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s641880369", "user_id": "u093848957"}, "prompt_components": {"gold_output": "0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\n\npublic class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = Integer.parseInt(sc.next());\n PrintWriter pw = new PrintWriter(System.out);\n for(int i=1;i<=N;i++){\n int count = 0;\n for(int x=1;x*x<=N;x++){\n for(int y=1;y*y<=N;y++){\n for(int z=1;z*z<=N;z++){\n if(x*x+y*y+z*z+x*y+y*z+z*x==i){\n count++;\n }\n }\n }\n } \n pw.println(count);\n pw.flush();\n }\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nLet f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n1 \\leq x,y,z\n\nx^2 + y^2 + z^2 + xy + yz + zx = n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,f(N).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(i).\n\nSample Input 1\n\n20\n\nSample Output 1\n\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n\nFor n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n\nFor n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n\nFor n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n\nFor n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.", "sample_input": "20\n"}, "reference_outputs": ["0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n"], "source_document_id": "p02608", "source_text": "Score : 300 points\n\nProblem Statement\n\nLet f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n1 \\leq x,y,z\n\nx^2 + y^2 + z^2 + xy + yz + zx = n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,f(N).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(i).\n\nSample Input 1\n\n20\n\nSample Output 1\n\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n\nFor n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n\nFor n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n\nFor n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n\nFor n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2206, "memory_kb": 37172}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s120607470", "group_id": "codeNet:p02608", "input_text": "import java.util.*;\npublic class Main{\n public static void main(String[] args){\n Scanner sc =new Scanner(System.in);\n int N =sc.nextInt();\n for(int i=1;i<=N;i++){\n if(i<4){System.out.println(0);}\n else{\n double I =(double)i;\n double T=Math.sqrt(2*I-8);\n double D=Math.sqrt(2*I/3);\n int t =(int)T;\n int d =(int)D;\n long ans =0;\n for(int j=2;j<=d;j++){\n for(int k=j;k<=t;k++){\n int m =Math.max(d,k);\n for(int l=m;l<=t;l++){\n if(j+1<=k+l){\n if(k+1<=j+l){\n if(l+1<=j+k){\n if(j*j+k*k+l*l==2*i){\n ans =ans+3;\n if((j==k)&&(k==l)){ans =ans-2;}\n }}}}}}}\n System.out.println(ans);\n }\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1594519653, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02608.html", "problem_id": "p02608", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02608/input.txt", "sample_output_relpath": "derived/input_output/data/p02608/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02608/Java/s120607470.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s120607470", "user_id": "u547671064"}, "prompt_components": {"gold_output": "0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n", "input_to_evaluate": "import java.util.*;\npublic class Main{\n public static void main(String[] args){\n Scanner sc =new Scanner(System.in);\n int N =sc.nextInt();\n for(int i=1;i<=N;i++){\n if(i<4){System.out.println(0);}\n else{\n double I =(double)i;\n double T=Math.sqrt(2*I-8);\n double D=Math.sqrt(2*I/3);\n int t =(int)T;\n int d =(int)D;\n long ans =0;\n for(int j=2;j<=d;j++){\n for(int k=j;k<=t;k++){\n int m =Math.max(d,k);\n for(int l=m;l<=t;l++){\n if(j+1<=k+l){\n if(k+1<=j+l){\n if(l+1<=j+k){\n if(j*j+k*k+l*l==2*i){\n ans =ans+3;\n if((j==k)&&(k==l)){ans =ans-2;}\n }}}}}}}\n System.out.println(ans);\n }\n }\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nLet f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n1 \\leq x,y,z\n\nx^2 + y^2 + z^2 + xy + yz + zx = n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,f(N).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(i).\n\nSample Input 1\n\n20\n\nSample Output 1\n\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n\nFor n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n\nFor n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n\nFor n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n\nFor n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.", "sample_input": "20\n"}, "reference_outputs": ["0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n"], "source_document_id": "p02608", "source_text": "Score : 300 points\n\nProblem Statement\n\nLet f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n1 \\leq x,y,z\n\nx^2 + y^2 + z^2 + xy + yz + zx = n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,f(N).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(i).\n\nSample Input 1\n\n20\n\nSample Output 1\n\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n\nFor n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n\nFor n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n\nFor n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n\nFor n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 772, "cpu_time_ms": 2207, "memory_kb": 39524}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s644492689", "group_id": "codeNet:p02613", "input_text": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.NoSuchElementException;\n\npublic class Main{\n\tstatic FastScanner sc = new FastScanner();\n\tstatic PrintWriter out = new PrintWriter(System.out);\n\tstatic int n;\n\t//static HashMap map;\n\t\n\tpublic static void main(String[] args) {\n\t\tn = sc.nextInt();\n\t\t\n\t\tint ac = 0;\n\t\tint wa = 0;\n\t\tint re = 0;\n\t\tint tle = 0;\n\t\t\n\t\tfor (int i=0; i map;\n\t\n\tpublic static void main(String[] args) {\n\t\tn = sc.nextInt();\n\t\t\n\t\tint ac = 0;\n\t\tint wa = 0;\n\t\tint re = 0;\n\t\tint tle = 0;\n\t\t\n\t\tfor (int i=0; i list = IntStream.range(0, n)\n .mapToObj(i -> scanner.nextLong())\n .sorted(Comparator.reverseOrder())\n .collect(Collectors.toList());\n\n final Deque queue = new ArrayDeque<>();\n queue.add(list.get(0));\n queue.add(list.get(1));\n long sum = list.get(0);\n final Deque tmp = new ArrayDeque<>();\n for (int i = 2; i < n; i++) {\n if (queue.isEmpty()) {\n queue.addAll(tmp);\n tmp.clear();\n }\n\n final long a = queue.pollFirst();\n final long b = queue.isEmpty() ? list.get(0) : queue.peekFirst();\n sum += Math.min(a, b);\n final long value = list.get(i);\n tmp.add(a);\n tmp.add(value);\n }\n\n System.out.println(sum);\n }\n\n private static class FastScanner {\n private final BufferedReader reader;\n private StringTokenizer tokenizer;\n\n FastScanner(final InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n }\n\n String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (final IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (final IOException e) {\n throw new RuntimeException(e);\n }\n }\n\n return tokenizer.nextToken(\"\\n\");\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n }\n}\n ", "language": "Java", "metadata": {"date": 1594000495, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02615.html", "problem_id": "p02615", "resource_group": "high_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/Java/s199656480.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s199656480", "user_id": "u476482490"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.util.ArrayDeque;\nimport java.util.Comparator;\nimport java.util.Deque;\nimport java.util.List;\nimport java.util.StringTokenizer;\nimport java.util.stream.Collectors;\nimport java.util.stream.IntStream;\n\npublic class Main {\n public static void main(final String[] args) {\n final FastScanner scanner = new FastScanner(System.in);\n final int n = scanner.nextInt();\n final List list = IntStream.range(0, n)\n .mapToObj(i -> scanner.nextLong())\n .sorted(Comparator.reverseOrder())\n .collect(Collectors.toList());\n\n final Deque queue = new ArrayDeque<>();\n queue.add(list.get(0));\n queue.add(list.get(1));\n long sum = list.get(0);\n final Deque tmp = new ArrayDeque<>();\n for (int i = 2; i < n; i++) {\n if (queue.isEmpty()) {\n queue.addAll(tmp);\n tmp.clear();\n }\n\n final long a = queue.pollFirst();\n final long b = queue.isEmpty() ? list.get(0) : queue.peekFirst();\n sum += Math.min(a, b);\n final long value = list.get(i);\n tmp.add(a);\n tmp.add(value);\n }\n\n System.out.println(sum);\n }\n\n private static class FastScanner {\n private final BufferedReader reader;\n private StringTokenizer tokenizer;\n\n FastScanner(final InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n }\n\n String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (final IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (final IOException e) {\n throw new RuntimeException(e);\n }\n }\n\n return tokenizer.nextToken(\"\\n\");\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n }\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": 2592, "cpu_time_ms": 610, "memory_kb": 69424}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s616172924", "group_id": "codeNet:p02615", "input_text": "import java.util.*;\nimport java.io.*;\n \npublic class Main {\n public static void main(String[] args) throws Exception {\n FastScanner sc = new FastScanner(System.in);\n int n = sc.nextInt();\n ArrayList a = new ArrayList<>();\n for(int i = 0; i < n; i++){\n a.add(sc.nextInt());\n }\n Collections.sort(a,Comparator.reverseOrder());\n long ans = a.get(0);\n int cnt = 1;\n int index = 1;\n while(cnt < n-1){\n if(n-1-cnt == 1){\n ans += a.get(index);\n cnt++;\n }else{\n ans += a.get(index)*2;\n cnt += 2;\n }\n index++;\n }\n System.out.println(ans);\n }\n \n}\n\nclass FastScanner {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n public FastScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n tokenizer = null;\n }\n\n public String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken(\"\\n\");\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n \n public String[] nextArray(int n) {\n String[] a = new String[n];\n for (int i = 0; i < n; i++)\n a[i] = next();\n return a;\n }\n\n public int[] nextIntArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = nextInt();\n return a;\n }\n\n public long[] nextLongArray(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = nextLong();\n return a;\n } \n}\n", "language": "Java", "metadata": {"date": 1593998879, "filename_ext": "java", "original_language": "Java (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02615.html", "problem_id": "p02615", "resource_group": "high_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/Java/s616172924.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s616172924", "user_id": "u578775554"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\n \npublic class Main {\n public static void main(String[] args) throws Exception {\n FastScanner sc = new FastScanner(System.in);\n int n = sc.nextInt();\n ArrayList a = new ArrayList<>();\n for(int i = 0; i < n; i++){\n a.add(sc.nextInt());\n }\n Collections.sort(a,Comparator.reverseOrder());\n long ans = a.get(0);\n int cnt = 1;\n int index = 1;\n while(cnt < n-1){\n if(n-1-cnt == 1){\n ans += a.get(index);\n cnt++;\n }else{\n ans += a.get(index)*2;\n cnt += 2;\n }\n index++;\n }\n System.out.println(ans);\n }\n \n}\n\nclass FastScanner {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n public FastScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n tokenizer = null;\n }\n\n public String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken(\"\\n\");\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n \n public String[] nextArray(int n) {\n String[] a = new String[n];\n for (int i = 0; i < n; i++)\n a[i] = next();\n return a;\n }\n\n public int[] nextIntArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = nextInt();\n return a;\n }\n\n public long[] nextLongArray(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = nextLong();\n return a;\n } \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": 2370, "cpu_time_ms": 396, "memory_kb": 54260}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s484948290", "group_id": "codeNet:p02621", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\ttry (Scanner scn = new Scanner(System.in)) {\n\t\t\tint num = scn.nextInt();\n\t\t\tSystem.out.println(num + (num*num) + (num*num*num));\n\t\t}\n\t}\n}\n", "language": "Java", "metadata": {"date": 1593306180, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02621.html", "problem_id": "p02621", "resource_group": "high_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/Java/s484948290.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s484948290", "user_id": "u371094731"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\ttry (Scanner scn = new Scanner(System.in)) {\n\t\t\tint num = scn.nextInt();\n\t\t\tSystem.out.println(num + (num*num) + (num*num*num));\n\t\t}\n\t}\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": 229, "cpu_time_ms": 126, "memory_kb": 35600}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s093719457", "group_id": "codeNet:p02622", "input_text": "import java.util.*;\n\nclass Main{\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n String str_S = sc.next();\n char[] s = str_S.toCharArray();\n String str_T = sc.next();\n char[] t = str_T.toCharArray();\n int result = 0;\n for(int i = 0;i < s.length;i++) {\n if(s[i] != t[i]) {\n result++;\n }\n }\n System.out.println(result);\n }\n}", "language": "Java", "metadata": {"date": 1593306862, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02622.html", "problem_id": "p02622", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02622/input.txt", "sample_output_relpath": "derived/input_output/data/p02622/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02622/Java/s093719457.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s093719457", "user_id": "u588526725"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*;\n\nclass Main{\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n String str_S = sc.next();\n char[] s = str_S.toCharArray();\n String str_T = sc.next();\n char[] t = str_T.toCharArray();\n int result = 0;\n for(int i = 0;i < s.length;i++) {\n if(s[i] != t[i]) {\n result++;\n }\n }\n System.out.println(result);\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.\n\nOperation: Choose one character of S and replace it with a different character.\n\nConstraints\n\nS and T have lengths between 1 and 2\\times 10^5 (inclusive).\n\nS and T consists of lowercase English letters.\n\nS and T have equal lengths.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\ncupofcoffee\ncupofhottea\n\nSample Output 1\n\n4\n\nWe can achieve the objective in four operations, such as the following:\n\nFirst, replace the sixth character c with h.\n\nSecond, replace the eighth character f with t.\n\nThird, replace the ninth character f with t.\n\nFourth, replace the eleventh character e with a.\n\nSample Input 2\n\nabcde\nbcdea\n\nSample Output 2\n\n5\n\nSample Input 3\n\napple\napple\n\nSample Output 3\n\n0\n\nNo operations may be needed to achieve the objective.", "sample_input": "cupofcoffee\ncupofhottea\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02622", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.\n\nOperation: Choose one character of S and replace it with a different character.\n\nConstraints\n\nS and T have lengths between 1 and 2\\times 10^5 (inclusive).\n\nS and T consists of lowercase English letters.\n\nS and T have equal lengths.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\ncupofcoffee\ncupofhottea\n\nSample Output 1\n\n4\n\nWe can achieve the objective in four operations, such as the following:\n\nFirst, replace the sixth character c with h.\n\nSecond, replace the eighth character f with t.\n\nThird, replace the ninth character f with t.\n\nFourth, replace the eleventh character e with a.\n\nSample Input 2\n\nabcde\nbcdea\n\nSample Output 2\n\n5\n\nSample Input 3\n\napple\napple\n\nSample Output 3\n\n0\n\nNo operations may be needed to achieve the objective.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 401, "cpu_time_ms": 241, "memory_kb": 41636}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s526654014", "group_id": "codeNet:p02626", "input_text": "import java.util.*;\nimport java.io.*;\npublic class Main{\n public static void main(String[] main) throws Exception{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st = new StringTokenizer(br.readLine());\n PrintWriter out = new PrintWriter(System.out);\n int n = Integer.parseInt(st.nextToken());\n st = new StringTokenizer(br.readLine());\n long a1 = 0, a2 = 0;\n long xor = 0;\n for(int i = 0; i < n; i++) {\n \t long a = Long.parseLong(st.nextToken());\n \t if(i == 0)\n \t\t a1 = a;\n \t else if(i == 1)\n \t\t a2 = a;\n \t else\n \t\t xor = a ^ xor;\n }\n long sum = a1 + a2;\n long res = 0;\n PriorityQueue one = new PriorityQueue();\n boolean works = true;\n long pow = 1;\n while(sum > 0) {\n \t if(sum%2 == xor%2) {\n \t\t if(sum%2 == 1)\n \t\t\t one.add(-pow);\n \t\t else {\n \t\t\t if(sum%4 != xor%4) {\n\t \t\t\t res += pow;\n\t \t\t\t sum -= 2;\n \t\t\t }\n \t\t }\n \t }\n \t else {\n \t\t works = false;\n \t\t break;\n \t }\n \t sum /= 2;\n \t xor /= 2;\n \t pow *= 2;\n }\n if(!works || res > a1 || xor > 0)\n \t out.println(-1);\n else {\n \t while(one.size() > 0) {\n \t\t pow = -one.remove();\n \t\t if(res + pow <= a1)\n \t\t\t res += pow;\n \t }\n \t if(res == 0)\n \t\t out.println(-1);\n \t else\n \t\t out.println(a1 - res);\n }\n out.close();\n }\n}", "language": "Java", "metadata": {"date": 1593513982, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02626.html", "problem_id": "p02626", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02626/input.txt", "sample_output_relpath": "derived/input_output/data/p02626/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02626/Java/s526654014.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s526654014", "user_id": "u926632269"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\npublic class Main{\n public static void main(String[] main) throws Exception{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st = new StringTokenizer(br.readLine());\n PrintWriter out = new PrintWriter(System.out);\n int n = Integer.parseInt(st.nextToken());\n st = new StringTokenizer(br.readLine());\n long a1 = 0, a2 = 0;\n long xor = 0;\n for(int i = 0; i < n; i++) {\n \t long a = Long.parseLong(st.nextToken());\n \t if(i == 0)\n \t\t a1 = a;\n \t else if(i == 1)\n \t\t a2 = a;\n \t else\n \t\t xor = a ^ xor;\n }\n long sum = a1 + a2;\n long res = 0;\n PriorityQueue one = new PriorityQueue();\n boolean works = true;\n long pow = 1;\n while(sum > 0) {\n \t if(sum%2 == xor%2) {\n \t\t if(sum%2 == 1)\n \t\t\t one.add(-pow);\n \t\t else {\n \t\t\t if(sum%4 != xor%4) {\n\t \t\t\t res += pow;\n\t \t\t\t sum -= 2;\n \t\t\t }\n \t\t }\n \t }\n \t else {\n \t\t works = false;\n \t\t break;\n \t }\n \t sum /= 2;\n \t xor /= 2;\n \t pow *= 2;\n }\n if(!works || res > a1 || xor > 0)\n \t out.println(-1);\n else {\n \t while(one.size() > 0) {\n \t\t pow = -one.remove();\n \t\t if(res + pow <= a1)\n \t\t\t res += pow;\n \t }\n \t if(res == 0)\n \t\t out.println(-1);\n \t else\n \t\t out.println(a1 - res);\n }\n out.close();\n }\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are N piles of stones. The i-th pile has A_i stones.\n\nAoki and Takahashi are about to use them to play the following game:\n\nStarting with Aoki, the two players alternately do the following operation:\n\nOperation: Choose one pile of stones, and remove one or more stones from it.\n\nWhen a player is unable to do the operation, he loses, and the other player wins.\n\nWhen the two players play optimally, there are two possibilities in this game: the player who moves first always wins, or the player who moves second always wins, only depending on the initial number of stones in each pile.\n\nIn such a situation, Takahashi, the second player to act, is trying to guarantee his win by moving at least zero and at most (A_1 - 1) stones from the 1-st pile to the 2-nd pile before the game begins.\n\nIf this is possible, print the minimum number of stones to move to guarantee his victory; otherwise, print -1 instead.\n\nConstraints\n\n2 \\leq N \\leq 300\n\n1 \\leq A_i \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum number of stones to move to guarantee Takahashi's win; otherwise, print -1 instead.\n\nSample Input 1\n\n2\n5 3\n\nSample Output 1\n\n1\n\nWithout moving stones, if Aoki first removes 2 stones from the 1-st pile, Takahashi cannot win in any way.\n\nIf Takahashi moves 1 stone from the 1-st pile to the 2-nd before the game begins so that both piles have 4 stones, Takahashi can always win by properly choosing his actions.\n\nSample Input 2\n\n2\n3 5\n\nSample Output 2\n\n-1\n\nIt is not allowed to move stones from the 2-nd pile to the 1-st.\n\nSample Input 3\n\n3\n1 1 2\n\nSample Output 3\n\n-1\n\nIt is not allowed to move all stones from the 1-st pile.\n\nSample Input 4\n\n8\n10 9 8 7 6 5 4 3\n\nSample Output 4\n\n3\n\nSample Input 5\n\n3\n4294967297 8589934593 12884901890\n\nSample Output 5\n\n1\n\nWatch out for overflows.", "sample_input": "2\n5 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02626", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are N piles of stones. The i-th pile has A_i stones.\n\nAoki and Takahashi are about to use them to play the following game:\n\nStarting with Aoki, the two players alternately do the following operation:\n\nOperation: Choose one pile of stones, and remove one or more stones from it.\n\nWhen a player is unable to do the operation, he loses, and the other player wins.\n\nWhen the two players play optimally, there are two possibilities in this game: the player who moves first always wins, or the player who moves second always wins, only depending on the initial number of stones in each pile.\n\nIn such a situation, Takahashi, the second player to act, is trying to guarantee his win by moving at least zero and at most (A_1 - 1) stones from the 1-st pile to the 2-nd pile before the game begins.\n\nIf this is possible, print the minimum number of stones to move to guarantee his victory; otherwise, print -1 instead.\n\nConstraints\n\n2 \\leq N \\leq 300\n\n1 \\leq A_i \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum number of stones to move to guarantee Takahashi's win; otherwise, print -1 instead.\n\nSample Input 1\n\n2\n5 3\n\nSample Output 1\n\n1\n\nWithout moving stones, if Aoki first removes 2 stones from the 1-st pile, Takahashi cannot win in any way.\n\nIf Takahashi moves 1 stone from the 1-st pile to the 2-nd before the game begins so that both piles have 4 stones, Takahashi can always win by properly choosing his actions.\n\nSample Input 2\n\n2\n3 5\n\nSample Output 2\n\n-1\n\nIt is not allowed to move stones from the 2-nd pile to the 1-st.\n\nSample Input 3\n\n3\n1 1 2\n\nSample Output 3\n\n-1\n\nIt is not allowed to move all stones from the 1-st pile.\n\nSample Input 4\n\n8\n10 9 8 7 6 5 4 3\n\nSample Output 4\n\n3\n\nSample Input 5\n\n3\n4294967297 8589934593 12884901890\n\nSample Output 5\n\n1\n\nWatch out for overflows.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 90, "memory_kb": 33148}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s226268953", "group_id": "codeNet:p02627", "input_text": "import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n abc171_a();\n // abc172_a();\n // abc172_b();\n // abc172_c();\n // abc173_a();\n // abc173_b();\n // abc173_c();\n }\n\n // int 2147483648 [ 2 * 10(9)]\n // long 9223372036854775808 [ 9 * 10(18)]\n\n public static void abc171_a() {\n try (Scanner sc = new Scanner(System.in)) {\n String a = sc.next();\n if (Character.isUpperCase(a.charAt(0))) {\n System.out.println(\"A\");\n } else {\n System.out.println(\"a\");\n }\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n public static void abc172_a() {\n try (Scanner sc = new Scanner(System.in)) {\n int a = parseI(sc.next());\n\n System.out.println(a + (int) Math.pow(a, 2) + (int) Math.pow(a, 3));\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n public static void abc172_b() {\n try (Scanner sc = new Scanner(System.in)) {\n String s = sc.next();\n String t = sc.next();\n int ansCnt = 0;\n for (int i = 0; i < s.length(); i++) {\n if (!parseS(s.charAt(i)).equals(parseS(t.charAt(i)))) {\n ansCnt++;\n }\n }\n System.out.println(ansCnt);\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n public static void abc172_c() {\n try (Scanner sc = new Scanner(System.in)) {\n int n = parseI(sc.next());\n int m = parseI(sc.next());\n int k = parseI(sc.next());\n long[] nList = new long[n + 1];\n long[] mList = new long[m + 1];\n nList[0] = 0;\n mList[0] = 0;\n for (int i = 1; i <= n; i++) {\n nList[i] = nList[i - 1] + parseI(sc.next());\n }\n for (int i = 1; i <= m; i++) {\n mList[i] = mList[i - 1] + parseI(sc.next());\n }\n int ansCnt = 0;\n for (int i = 0; i <= n; i++) {\n if (k < nList[i]) {\n break;\n }\n while (k - nList[i] < mList[m])\n m--;\n ansCnt = Math.max(ansCnt, i + m);\n }\n System.out.println(ansCnt);\n }\n }\n\n public static void abc173_a() {\n try (Scanner sc = new Scanner(System.in)) {\n int payment = parseI(sc.next());\n int max = 10000;\n int thou = 1000;\n\n System.out.println((max - payment) % thou);\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n public static void abc173_b() {\n try (Scanner sc = new Scanner(System.in)) {\n int num = parseI(sc.next());\n\n // AC\n // WA\n // TLE\n // RE x 0\n int[] ansCount = new int[4];\n final String[] err = { \"AC\", \"WA\", \"TLE\", \"RE\" };\n Arrays.fill(ansCount, 0);\n\n for (int i = 0; i < num; i++) {\n String ans = sc.next();\n switch (ans) {\n case \"AC\":\n ansCount[0]++;\n break;\n case \"WA\":\n ansCount[1]++;\n break;\n case \"TLE\":\n ansCount[2]++;\n break;\n case \"RE\":\n ansCount[3]++;\n break;\n }\n }\n int count = 0;\n for (int answer : ansCount) {\n System.out.println(err[count] + \" x \" + answer);\n count++;\n }\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n public static void abc173_c() {\n try (Scanner sc = new Scanner(System.in)) {\n int row = parseI(sc.next());\n int column = parseI(sc.next());\n int checkBlackCount = parseI(sc.next());\n int existBlack = 0;\n int ansCount = 0;\n int[][] inputList = new int[row][column];\n String input = \"\";\n for (int i = 0; i < row; i++) {\n input = sc.next();\n for (int x = 0; x < column; x++) {\n inputList[i][x] =\n parseI(parseS(input.charAt(x)).replace(\".\", \"0\").replace(\"#\", \"1\"));\n }\n }\n\n for (int i = 0; i < (1 << row); i++) {\n for (int x = 0; x < (1 << column); x++) {\n\n for (int chRownum = 0; chRownum < row; chRownum++) {\n for (int chColNum = 0; chColNum < column; chColNum++) {\n if (inputList[chRownum][chColNum] == 1\n && ((i >> chRownum) & 1) == 0 && ((x >> chColNum) & 1) == 0) {\n existBlack++;\n }\n }\n }\n if (existBlack == checkBlackCount) ansCount++;\n existBlack = 0;\n\n }\n }\n System.out.println(ansCount);\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n public static int parseI(String value) {\n return Integer.parseInt(value);\n }\n\n public static long parseL(String value) {\n return Long.parseLong(value);\n }\n\n public static double parseD(String value) {\n return Double.parseDouble(value);\n }\n\n public static String parseS(T value) {\n return String.valueOf(value);\n }\n\n}\n", "language": "Java", "metadata": {"date": 1595359750, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02627.html", "problem_id": "p02627", "resource_group": "high_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/Java/s226268953.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s226268953", "user_id": "u247775641"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n abc171_a();\n // abc172_a();\n // abc172_b();\n // abc172_c();\n // abc173_a();\n // abc173_b();\n // abc173_c();\n }\n\n // int 2147483648 [ 2 * 10(9)]\n // long 9223372036854775808 [ 9 * 10(18)]\n\n public static void abc171_a() {\n try (Scanner sc = new Scanner(System.in)) {\n String a = sc.next();\n if (Character.isUpperCase(a.charAt(0))) {\n System.out.println(\"A\");\n } else {\n System.out.println(\"a\");\n }\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n public static void abc172_a() {\n try (Scanner sc = new Scanner(System.in)) {\n int a = parseI(sc.next());\n\n System.out.println(a + (int) Math.pow(a, 2) + (int) Math.pow(a, 3));\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n public static void abc172_b() {\n try (Scanner sc = new Scanner(System.in)) {\n String s = sc.next();\n String t = sc.next();\n int ansCnt = 0;\n for (int i = 0; i < s.length(); i++) {\n if (!parseS(s.charAt(i)).equals(parseS(t.charAt(i)))) {\n ansCnt++;\n }\n }\n System.out.println(ansCnt);\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n public static void abc172_c() {\n try (Scanner sc = new Scanner(System.in)) {\n int n = parseI(sc.next());\n int m = parseI(sc.next());\n int k = parseI(sc.next());\n long[] nList = new long[n + 1];\n long[] mList = new long[m + 1];\n nList[0] = 0;\n mList[0] = 0;\n for (int i = 1; i <= n; i++) {\n nList[i] = nList[i - 1] + parseI(sc.next());\n }\n for (int i = 1; i <= m; i++) {\n mList[i] = mList[i - 1] + parseI(sc.next());\n }\n int ansCnt = 0;\n for (int i = 0; i <= n; i++) {\n if (k < nList[i]) {\n break;\n }\n while (k - nList[i] < mList[m])\n m--;\n ansCnt = Math.max(ansCnt, i + m);\n }\n System.out.println(ansCnt);\n }\n }\n\n public static void abc173_a() {\n try (Scanner sc = new Scanner(System.in)) {\n int payment = parseI(sc.next());\n int max = 10000;\n int thou = 1000;\n\n System.out.println((max - payment) % thou);\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n public static void abc173_b() {\n try (Scanner sc = new Scanner(System.in)) {\n int num = parseI(sc.next());\n\n // AC\n // WA\n // TLE\n // RE x 0\n int[] ansCount = new int[4];\n final String[] err = { \"AC\", \"WA\", \"TLE\", \"RE\" };\n Arrays.fill(ansCount, 0);\n\n for (int i = 0; i < num; i++) {\n String ans = sc.next();\n switch (ans) {\n case \"AC\":\n ansCount[0]++;\n break;\n case \"WA\":\n ansCount[1]++;\n break;\n case \"TLE\":\n ansCount[2]++;\n break;\n case \"RE\":\n ansCount[3]++;\n break;\n }\n }\n int count = 0;\n for (int answer : ansCount) {\n System.out.println(err[count] + \" x \" + answer);\n count++;\n }\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n public static void abc173_c() {\n try (Scanner sc = new Scanner(System.in)) {\n int row = parseI(sc.next());\n int column = parseI(sc.next());\n int checkBlackCount = parseI(sc.next());\n int existBlack = 0;\n int ansCount = 0;\n int[][] inputList = new int[row][column];\n String input = \"\";\n for (int i = 0; i < row; i++) {\n input = sc.next();\n for (int x = 0; x < column; x++) {\n inputList[i][x] =\n parseI(parseS(input.charAt(x)).replace(\".\", \"0\").replace(\"#\", \"1\"));\n }\n }\n\n for (int i = 0; i < (1 << row); i++) {\n for (int x = 0; x < (1 << column); x++) {\n\n for (int chRownum = 0; chRownum < row; chRownum++) {\n for (int chColNum = 0; chColNum < column; chColNum++) {\n if (inputList[chRownum][chColNum] == 1\n && ((i >> chRownum) & 1) == 0 && ((x >> chColNum) & 1) == 0) {\n existBlack++;\n }\n }\n }\n if (existBlack == checkBlackCount) ansCount++;\n existBlack = 0;\n\n }\n }\n System.out.println(ansCount);\n\n } catch (Exception e) {\n System.out.println(\"エラー\" + e);\n }\n }\n\n public static int parseI(String value) {\n return Integer.parseInt(value);\n }\n\n public static long parseL(String value) {\n return Long.parseLong(value);\n }\n\n public static double parseD(String value) {\n return Double.parseDouble(value);\n }\n\n public static String parseS(T value) {\n return String.valueOf(value);\n }\n\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "sample_input": "B\n"}, "reference_outputs": ["A\n"], "source_document_id": "p02627", "source_text": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4863, "cpu_time_ms": 113, "memory_kb": 35748}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s658256066", "group_id": "codeNet:p02627", "input_text": "import java.util.*;\npublic class Main {\n public static void main(String[] args){\n\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tString alpha = sc.next();\n \n if(alpha.equals(alpha.toUpperCase())){\n System.out.println(\"A\"); \n }else{\n System.out.println(\"a\");\n }\n \n\t\t\n\t\t\n }\n}", "language": "Java", "metadata": {"date": 1593637988, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02627.html", "problem_id": "p02627", "resource_group": "high_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/Java/s658256066.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s658256066", "user_id": "u307487840"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "import java.util.*;\npublic class Main {\n public static void main(String[] args){\n\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tString alpha = sc.next();\n \n if(alpha.equals(alpha.toUpperCase())){\n System.out.println(\"A\"); \n }else{\n System.out.println(\"a\");\n }\n \n\t\t\n\t\t\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": 318, "cpu_time_ms": 111, "memory_kb": 35668}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s687554461", "group_id": "codeNet:p02627", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.StringTokenizer;\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.InputStream;\n\npublic class Main {\n\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskA solver = new TaskA();\n solver.call(in,out);\n out.close();\n }\n\n static class TaskA {\n public void call(InputReader in, PrintWriter out) {\n String s;\n s =in.next();\n int a =s.charAt(0);\n if(a<97)\n out.println(\"A\");\n else{\n out.println(\"a\");\n }\n\n\n }\n }\n\n static class InputReader {\n public BufferedReader reader;\n public StringTokenizer tokenizer;\n\n public InputReader(InputStream stream) {\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\n tokenizer = null;\n }\n\n public String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n public long nextLong(){\n return Long.parseLong(next());\n }\n\n }\n}", "language": "Java", "metadata": {"date": 1592788022, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02627.html", "problem_id": "p02627", "resource_group": "high_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/Java/s687554461.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s687554461", "user_id": "u651450633"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.StringTokenizer;\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.InputStream;\n\npublic class Main {\n\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskA solver = new TaskA();\n solver.call(in,out);\n out.close();\n }\n\n static class TaskA {\n public void call(InputReader in, PrintWriter out) {\n String s;\n s =in.next();\n int a =s.charAt(0);\n if(a<97)\n out.println(\"A\");\n else{\n out.println(\"a\");\n }\n\n\n }\n }\n\n static class InputReader {\n public BufferedReader reader;\n public StringTokenizer tokenizer;\n\n public InputReader(InputStream stream) {\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\n tokenizer = null;\n }\n\n public String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n public long nextLong(){\n return Long.parseLong(next());\n }\n\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "sample_input": "B\n"}, "reference_outputs": ["A\n"], "source_document_id": "p02627", "source_text": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1788, "cpu_time_ms": 94, "memory_kb": 32844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s661756613", "group_id": "codeNet:p02627", "input_text": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n\n String str = scanner.next();\n\n scanner.close();\n\n if (str.matches(\"[A-Z]+\")) {\n System.out.println(\"A\");\n } else {\n System.out.println(\"a\");\n }\n\n }\n}\n", "language": "Java", "metadata": {"date": 1592787847, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02627.html", "problem_id": "p02627", "resource_group": "high_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/Java/s661756613.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s661756613", "user_id": "u242435425"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n\n String str = scanner.next();\n\n scanner.close();\n\n if (str.matches(\"[A-Z]+\")) {\n System.out.println(\"A\");\n } else {\n System.out.println(\"a\");\n }\n\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "sample_input": "B\n"}, "reference_outputs": ["A\n"], "source_document_id": "p02627", "source_text": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 145, "memory_kb": 35652}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s793389059", "group_id": "codeNet:p02629", "input_text": "import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tlong n = sc.nextLong();\n\t\tString str = \"abcdefghijklmnopqrstuvwxyz\";\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint len = 1;\n\t\tfor(int i=1; i<16; i++){\n\t\t\tif(Math.pow(26,i) < n){\n\t\t\t\tlen++;\n\t\t\t\tn -= Math.pow(26,i);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tn--;\n\t\tList list = new ArrayList<>();\n\t\tdo{\n\t\t\tlong amari = n%26;\n\t\t\tn = n/26;\n\t\t\tlist.add((int)amari);\n\t\t}\n\t\twhile(n > 0);\n\t\tif(len>list.size()){\n\t\t\tint sa = len - list.size();\n\t\t\tfor(int i = 0; i=0; i--){\n\t\t\tsb.append(str.charAt(list.get(i)));\n\t\t}\n\t\tSystem.out.println(sb);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1592913617, "filename_ext": "java", "original_language": "Java (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02629.html", "problem_id": "p02629", "resource_group": "high_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/Java/s793389059.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s793389059", "user_id": "u248433238"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tlong n = sc.nextLong();\n\t\tString str = \"abcdefghijklmnopqrstuvwxyz\";\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint len = 1;\n\t\tfor(int i=1; i<16; i++){\n\t\t\tif(Math.pow(26,i) < n){\n\t\t\t\tlen++;\n\t\t\t\tn -= Math.pow(26,i);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tn--;\n\t\tList list = new ArrayList<>();\n\t\tdo{\n\t\t\tlong amari = n%26;\n\t\t\tn = n/26;\n\t\t\tlist.add((int)amari);\n\t\t}\n\t\twhile(n > 0);\n\t\tif(len>list.size()){\n\t\t\tint sa = len - list.size();\n\t\t\tfor(int i = 0; i=0; i--){\n\t\t\tsb.append(str.charAt(list.get(i)));\n\t\t}\n\t\tSystem.out.println(sb);\n\t}\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": 731, "cpu_time_ms": 107, "memory_kb": 27084}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s676086636", "group_id": "codeNet:p02629", "input_text": "import java.util.*;\n\npublic class Main {\n\n static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n long N = sc.nextInt();\n String ans = \"\";\n\n\n while(true){\n int mod = (int)N % 26;\n N = N / 26;\n ans = Character.toString('a' + Character.toChars(mod)[0] -1) + ans;\n\n if(N == 0)\n break;\n }\n\n System.out.println(ans);\n\n }\n\n}\n", "language": "Java", "metadata": {"date": 1592788516, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02629.html", "problem_id": "p02629", "resource_group": "high_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/Java/s676086636.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s676086636", "user_id": "u579455624"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\n static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n long N = sc.nextInt();\n String ans = \"\";\n\n\n while(true){\n int mod = (int)N % 26;\n N = N / 26;\n ans = Character.toString('a' + Character.toChars(mod)[0] -1) + ans;\n\n if(N == 0)\n break;\n }\n\n System.out.println(ans);\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": 513, "cpu_time_ms": 198, "memory_kb": 39448}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s419398972", "group_id": "codeNet:p02630", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws Exception {\n // Your code here!\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n TreeMap map = new TreeMap();\n long sum = 0;\n for (int i = 0; i < n; i++) {\n int num = sc.nextInt();\n int val = map.getOrDefault(num, 0);\n map.put(num, ++val);\n sum = sum + num;\n }\n \n int q = sc.nextInt();\n while (q-- > 0) {\n int prev = sc.nextInt();\n int next = sc.nextInt();\n \n long dif = next - prev;\n \n int prevcount = map.getOrDefault(prev, 0);\n sum = sum + dif * prevcount;\n \n map.remove(prev);\n int val = map.getOrDefault(next, 0);\n map.put(next, val + prevcount);\n System.out.println(sum);\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1592789984, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02630.html", "problem_id": "p02630", "resource_group": "high_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/Java/s419398972.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s419398972", "user_id": "u273816974"}, "prompt_components": {"gold_output": "11\n12\n16\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws Exception {\n // Your code here!\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n TreeMap map = new TreeMap();\n long sum = 0;\n for (int i = 0; i < n; i++) {\n int num = sc.nextInt();\n int val = map.getOrDefault(num, 0);\n map.put(num, ++val);\n sum = sum + num;\n }\n \n int q = sc.nextInt();\n while (q-- > 0) {\n int prev = sc.nextInt();\n int next = sc.nextInt();\n \n long dif = next - prev;\n \n int prevcount = map.getOrDefault(prev, 0);\n sum = sum + dif * prevcount;\n \n map.remove(prev);\n int val = map.getOrDefault(next, 0);\n map.put(next, val + prevcount);\n System.out.println(sum);\n }\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": 982, "cpu_time_ms": 1346, "memory_kb": 65720}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s221197407", "group_id": "codeNet:p02630", "input_text": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n private static List solve(int n, int[] as, int q, int[][] bcs) {\n long sum = 0;\n Map aMap = new HashMap<>();\n for (int a : as) {\n aMap.put(a, aMap.getOrDefault(a, 0) + 1);\n sum += a;\n }\n\n List answers = new ArrayList<>();\n for (int[] bc : bcs) {\n int b = bc[0];\n int c = bc[1];\n int bCount = aMap.getOrDefault(b, 0);\n aMap.remove(b);\n aMap.put(c, aMap.getOrDefault(c, 0) + bCount);\n\n sum += (long)bCount * (long)(c - b);\n answers.add(sum);\n }\n return answers;\n }\n\n private static void execute(ContestReader reader, ContestWriter out) {\n int n = reader.nextInt();\n int[] as = reader.nextInt(n);\n int q = reader.nextInt();\n int[][] bcs = reader.nextInt(q, 2);\n out.printList(solve(n, as, q, bcs));\n }\n \n public static void main(String[] args) {\n ContestReader reader = new ContestReader(System.in);\n ContestWriter out = new ContestWriter(System.out);\n execute(reader, out);\n out.flush();\n }\n}\n\nclass ContestWriter extends PrintWriter {\n ContestWriter(PrintStream printStream) {\n super(printStream);\n }\n\n public void printList(List list) {\n for (Object object : list) {\n println(object);\n }\n }\n\n public void printListOneLine(List list) {\n List stringList = new ArrayList<>();\n for (Object object : list) {\n stringList.add(object.toString());\n }\n println(String.join(\" \", stringList));\n }\n}\n\nclass ContestReader {\n private static final int BUFFER_SIZE = 1024;\n \n private final InputStream stream;\n private final byte[] buffer;\n private int pointer;\n private int bufferLength;\n \n ContestReader(InputStream stream) {\n this.stream = stream;\n this.buffer = new byte[BUFFER_SIZE];\n this.pointer = 0;\n this.bufferLength = 0;\n }\n \n private boolean hasNextByte() {\n if (pointer < bufferLength) {\n return true;\n }\n \n pointer = 0;\n try {\n bufferLength = stream.read(buffer);\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n return bufferLength > 0;\n }\n \n private int readByte() {\n if (hasNextByte()) {\n return buffer[pointer++];\n } else {\n return -1;\n }\n }\n \n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n \n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[pointer])) {\n pointer++;\n }\n return hasNextByte();\n }\n \n public String next() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n StringBuilder sb = new StringBuilder();\n while(true) {\n int b = readByte();\n if (!isPrintableChar(b)) {\n break;\n }\n sb.appendCodePoint(b);\n }\n return sb.toString();\n }\n \n public String nextLine() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n StringBuilder sb = new StringBuilder();\n while(true) {\n int b = readByte();\n if (!isPrintableChar(b) && b != 0x20) {\n break;\n }\n sb.appendCodePoint(b);\n }\n return sb.toString();\n }\n \n public char nextChar() {\n return next().charAt(0);\n }\n \n public int nextInt() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n \n int n = 0;\n boolean minus = false;\n \n {\n int b = readByte();\n if (b == '-') {\n minus = true;\n } else if ('0' <= b && b <= '9') {\n n = b - '0';\n } else {\n throw new NumberFormatException();\n }\n }\n \n while(true){\n int b = readByte();\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n }\n }\n \n public long nextLong() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n \n long n = 0;\n boolean minus = false;\n \n {\n int b = readByte();\n if (b == '-') {\n minus = true;\n } else if ('0' <= b && b <= '9') {\n n = b - '0';\n } else {\n throw new NumberFormatException();\n }\n }\n \n while(true){\n int b = readByte();\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n }\n }\n \n public double nextDouble() {\n return Double.parseDouble(next());\n }\n \n public String[] next(int n) {\n String[] array = new String[n];\n for (int i = 0; i < n; i++) {\n array[i] = next();\n }\n return array;\n }\n \n public String[] nextLine(int n) {\n String[] array = new String[n];\n for (int i = 0; i < n; i++) {\n array[i] = nextLine();\n }\n return array;\n }\n \n public char[] nextChar(int n) {\n char[] array = new char[n];\n for (int i = 0; i < n; i++) {\n array[i] = nextChar();\n }\n return array;\n }\n \n public int[] nextInt(int n) {\n int[] array = new int[n];\n for (int i = 0; i < n; i++) {\n array[i] = nextInt();\n }\n return array;\n }\n \n public long[] nextLong(int n) {\n long[] array = new long[n];\n for (int i = 0; i < n; i++) {\n array[i] = nextLong();\n }\n return array;\n }\n \n public double[] nextDouble(int n) {\n double[] array = new double[n];\n for (int i = 0; i < n; i++) {\n array[i] = nextDouble();\n }\n return array;\n }\n \n public char[] nextCharArray() {\n return next().toCharArray();\n }\n \n public String[][] next(int n, int m) {\n String[][] matrix = new String[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n matrix[i][j] = next();\n }\n }\n return matrix;\n }\n \n public int[][] nextInt(int n, int m) {\n int[][] matrix = new int[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n matrix[i][j] = nextInt();\n }\n }\n return matrix;\n }\n \n public char[][] nextChar(int n, int m) {\n char[][] matrix = new char[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n matrix[i][j] = nextChar();\n }\n }\n return matrix;\n }\n \n public long[][] nextLong(int n, int m) {\n long[][] matrix = new long[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n matrix[i][j] = nextLong();\n }\n }\n return matrix;\n }\n \n public double[][] nextDouble(int n, int m) {\n double[][] matrix = new double[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n matrix[i][j] = nextDouble();\n }\n }\n return matrix;\n }\n \n public char[][] nextCharArray(int n) {\n char[][] matrix = new char[n][];\n for (int i = 0; i < n; i++) {\n matrix[i] = next().toCharArray();\n }\n return matrix;\n }\n}\n\nclass MyAssert {\n public static void myAssert(boolean flag, String message) {\n if (!flag) {\n throw new RuntimeException(message);\n }\n }\n \n public static void myAssert(boolean flag) {\n myAssert(flag, \"\");\n }\n}\n", "language": "Java", "metadata": {"date": 1592788653, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02630.html", "problem_id": "p02630", "resource_group": "high_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/Java/s221197407.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s221197407", "user_id": "u853633924"}, "prompt_components": {"gold_output": "11\n12\n16\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n private static List solve(int n, int[] as, int q, int[][] bcs) {\n long sum = 0;\n Map aMap = new HashMap<>();\n for (int a : as) {\n aMap.put(a, aMap.getOrDefault(a, 0) + 1);\n sum += a;\n }\n\n List answers = new ArrayList<>();\n for (int[] bc : bcs) {\n int b = bc[0];\n int c = bc[1];\n int bCount = aMap.getOrDefault(b, 0);\n aMap.remove(b);\n aMap.put(c, aMap.getOrDefault(c, 0) + bCount);\n\n sum += (long)bCount * (long)(c - b);\n answers.add(sum);\n }\n return answers;\n }\n\n private static void execute(ContestReader reader, ContestWriter out) {\n int n = reader.nextInt();\n int[] as = reader.nextInt(n);\n int q = reader.nextInt();\n int[][] bcs = reader.nextInt(q, 2);\n out.printList(solve(n, as, q, bcs));\n }\n \n public static void main(String[] args) {\n ContestReader reader = new ContestReader(System.in);\n ContestWriter out = new ContestWriter(System.out);\n execute(reader, out);\n out.flush();\n }\n}\n\nclass ContestWriter extends PrintWriter {\n ContestWriter(PrintStream printStream) {\n super(printStream);\n }\n\n public void printList(List list) {\n for (Object object : list) {\n println(object);\n }\n }\n\n public void printListOneLine(List list) {\n List stringList = new ArrayList<>();\n for (Object object : list) {\n stringList.add(object.toString());\n }\n println(String.join(\" \", stringList));\n }\n}\n\nclass ContestReader {\n private static final int BUFFER_SIZE = 1024;\n \n private final InputStream stream;\n private final byte[] buffer;\n private int pointer;\n private int bufferLength;\n \n ContestReader(InputStream stream) {\n this.stream = stream;\n this.buffer = new byte[BUFFER_SIZE];\n this.pointer = 0;\n this.bufferLength = 0;\n }\n \n private boolean hasNextByte() {\n if (pointer < bufferLength) {\n return true;\n }\n \n pointer = 0;\n try {\n bufferLength = stream.read(buffer);\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n return bufferLength > 0;\n }\n \n private int readByte() {\n if (hasNextByte()) {\n return buffer[pointer++];\n } else {\n return -1;\n }\n }\n \n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n \n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[pointer])) {\n pointer++;\n }\n return hasNextByte();\n }\n \n public String next() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n StringBuilder sb = new StringBuilder();\n while(true) {\n int b = readByte();\n if (!isPrintableChar(b)) {\n break;\n }\n sb.appendCodePoint(b);\n }\n return sb.toString();\n }\n \n public String nextLine() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n StringBuilder sb = new StringBuilder();\n while(true) {\n int b = readByte();\n if (!isPrintableChar(b) && b != 0x20) {\n break;\n }\n sb.appendCodePoint(b);\n }\n return sb.toString();\n }\n \n public char nextChar() {\n return next().charAt(0);\n }\n \n public int nextInt() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n \n int n = 0;\n boolean minus = false;\n \n {\n int b = readByte();\n if (b == '-') {\n minus = true;\n } else if ('0' <= b && b <= '9') {\n n = b - '0';\n } else {\n throw new NumberFormatException();\n }\n }\n \n while(true){\n int b = readByte();\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n }\n }\n \n public long nextLong() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n \n long n = 0;\n boolean minus = false;\n \n {\n int b = readByte();\n if (b == '-') {\n minus = true;\n } else if ('0' <= b && b <= '9') {\n n = b - '0';\n } else {\n throw new NumberFormatException();\n }\n }\n \n while(true){\n int b = readByte();\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n }\n }\n \n public double nextDouble() {\n return Double.parseDouble(next());\n }\n \n public String[] next(int n) {\n String[] array = new String[n];\n for (int i = 0; i < n; i++) {\n array[i] = next();\n }\n return array;\n }\n \n public String[] nextLine(int n) {\n String[] array = new String[n];\n for (int i = 0; i < n; i++) {\n array[i] = nextLine();\n }\n return array;\n }\n \n public char[] nextChar(int n) {\n char[] array = new char[n];\n for (int i = 0; i < n; i++) {\n array[i] = nextChar();\n }\n return array;\n }\n \n public int[] nextInt(int n) {\n int[] array = new int[n];\n for (int i = 0; i < n; i++) {\n array[i] = nextInt();\n }\n return array;\n }\n \n public long[] nextLong(int n) {\n long[] array = new long[n];\n for (int i = 0; i < n; i++) {\n array[i] = nextLong();\n }\n return array;\n }\n \n public double[] nextDouble(int n) {\n double[] array = new double[n];\n for (int i = 0; i < n; i++) {\n array[i] = nextDouble();\n }\n return array;\n }\n \n public char[] nextCharArray() {\n return next().toCharArray();\n }\n \n public String[][] next(int n, int m) {\n String[][] matrix = new String[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n matrix[i][j] = next();\n }\n }\n return matrix;\n }\n \n public int[][] nextInt(int n, int m) {\n int[][] matrix = new int[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n matrix[i][j] = nextInt();\n }\n }\n return matrix;\n }\n \n public char[][] nextChar(int n, int m) {\n char[][] matrix = new char[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n matrix[i][j] = nextChar();\n }\n }\n return matrix;\n }\n \n public long[][] nextLong(int n, int m) {\n long[][] matrix = new long[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n matrix[i][j] = nextLong();\n }\n }\n return matrix;\n }\n \n public double[][] nextDouble(int n, int m) {\n double[][] matrix = new double[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n matrix[i][j] = nextDouble();\n }\n }\n return matrix;\n }\n \n public char[][] nextCharArray(int n) {\n char[][] matrix = new char[n][];\n for (int i = 0; i < n; i++) {\n matrix[i] = next().toCharArray();\n }\n return matrix;\n }\n}\n\nclass MyAssert {\n public static void myAssert(boolean flag, String message) {\n if (!flag) {\n throw new RuntimeException(message);\n }\n }\n \n public static void myAssert(boolean flag) {\n myAssert(flag, \"\");\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": 7197, "cpu_time_ms": 332, "memory_kb": 60096}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s265014434", "group_id": "codeNet:p02631", "input_text": "/*****Author: Satyajeet Singh, Delhi Technological University************************************/\n import java.io.*;\n import java.util.*;\n import java.text.*; \n import java.lang.*;\n import java.math.*;\npublic class Main{\n/*********************************************Constants******************************************/\n static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out)); \n static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n static long mod=(long)1e9+7;\n static long mod1=998244353;\n static ArrayList graph[];\n static int pptr=0,pptrmax=0;\n static String st[];\n/*****************************************Solution Begins***************************************/ \n public static void main(String args[]) throws Exception{\n int n=pi();\n long input[]=new long[n];\n long s=0;\n for(int i=0;i();\n }\n static void addEdge(int a,int b){\n graph[a].add(b);\n }\n // static void addEdge(int a,int b,int c){\n // graph[a].add(new Pair(b,c));\n // } \n/*********************************************PAIR********************************************************/\n static class Pair{\n int u;\n int v;\n public Pair(int u, int v) {\n this.u = u;\n this.v = v;\n }\n public int hashCode() {\n int hu = (int) (u ^ (u >>> 32));\n int hv = (int) (v ^ (v >>> 32));\n return 31 * hu + hv;\n }\n public boolean equals(Object o) {\n Pair other = (Pair) o;\n return u == other.u && v == other.v;\n }\n public String toString() {\n return \"[u=\" + u + \", v=\" + v + \"]\";\n }\n }\n/******************************************Long Pair*******************************************************/\n static class Pairl{\n long u;\n long v;\n public Pairl(long u, long v) {\n this.u = u;\n this.v = v;\n }\n public int hashCode() {\n int hu = (int) (u ^ (u >>> 32));\n int hv = (int) (v ^ (v >>> 32));\n return 31 * hu + hv;\n }\n public boolean equals(Object o) {\n Pairl other = (Pairl) o;\n return u == other.u && v == other.v;\n }\n public String toString() {\n return \"[u=\" + u + \", v=\" + v + \"]\";\n }\n }\n/*****************************************DEBUG***********************************************************/\n public static void debug(Object... o){\n System.out.println(Arrays.deepToString(o));\n }\n/************************************MODULAR EXPONENTIATION***********************************************/\n static long modulo(long a,long b,long c){\n long x=1,y=a%c;\n while(b > 0){\n if(b%2 == 1)\n x=(x*y)%c;\n y = (y*y)%c;\n b = b>>1;\n }\n return x%c;\n }\n/********************************************GCD**********************************************************/\n static long gcd(long x, long y){\n if(x==0)\n return y;\n if(y==0)\n return x;\n long r=0, a, b;\n a = (x > y) ? x : y; \n b = (x < y) ? x : y;\n r = b;\n while(a % b != 0){\n r = a % b;\n a = b;\n b = r;\n }\n return r;\n }\n}", "language": "Java", "metadata": {"date": 1592789257, "filename_ext": "java", "original_language": "Java (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02631.html", "problem_id": "p02631", "resource_group": "high_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/Java/s265014434.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s265014434", "user_id": "u904730393"}, "prompt_components": {"gold_output": "26 5 7 22\n", "input_to_evaluate": "/*****Author: Satyajeet Singh, Delhi Technological University************************************/\n import java.io.*;\n import java.util.*;\n import java.text.*; \n import java.lang.*;\n import java.math.*;\npublic class Main{\n/*********************************************Constants******************************************/\n static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out)); \n static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n static long mod=(long)1e9+7;\n static long mod1=998244353;\n static ArrayList graph[];\n static int pptr=0,pptrmax=0;\n static String st[];\n/*****************************************Solution Begins***************************************/ \n public static void main(String args[]) throws Exception{\n int n=pi();\n long input[]=new long[n];\n long s=0;\n for(int i=0;i();\n }\n static void addEdge(int a,int b){\n graph[a].add(b);\n }\n // static void addEdge(int a,int b,int c){\n // graph[a].add(new Pair(b,c));\n // } \n/*********************************************PAIR********************************************************/\n static class Pair{\n int u;\n int v;\n public Pair(int u, int v) {\n this.u = u;\n this.v = v;\n }\n public int hashCode() {\n int hu = (int) (u ^ (u >>> 32));\n int hv = (int) (v ^ (v >>> 32));\n return 31 * hu + hv;\n }\n public boolean equals(Object o) {\n Pair other = (Pair) o;\n return u == other.u && v == other.v;\n }\n public String toString() {\n return \"[u=\" + u + \", v=\" + v + \"]\";\n }\n }\n/******************************************Long Pair*******************************************************/\n static class Pairl{\n long u;\n long v;\n public Pairl(long u, long v) {\n this.u = u;\n this.v = v;\n }\n public int hashCode() {\n int hu = (int) (u ^ (u >>> 32));\n int hv = (int) (v ^ (v >>> 32));\n return 31 * hu + hv;\n }\n public boolean equals(Object o) {\n Pairl other = (Pairl) o;\n return u == other.u && v == other.v;\n }\n public String toString() {\n return \"[u=\" + u + \", v=\" + v + \"]\";\n }\n }\n/*****************************************DEBUG***********************************************************/\n public static void debug(Object... o){\n System.out.println(Arrays.deepToString(o));\n }\n/************************************MODULAR EXPONENTIATION***********************************************/\n static long modulo(long a,long b,long c){\n long x=1,y=a%c;\n while(b > 0){\n if(b%2 == 1)\n x=(x*y)%c;\n y = (y*y)%c;\n b = b>>1;\n }\n return x%c;\n }\n/********************************************GCD**********************************************************/\n static long gcd(long x, long y){\n if(x==0)\n return y;\n if(y==0)\n return x;\n long r=0, a, b;\n a = (x > y) ? x : y; \n b = (x < y) ? x : y;\n r = b;\n while(a % b != 0){\n r = a % b;\n a = b;\n b = r;\n }\n return r;\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": 5337, "cpu_time_ms": 389, "memory_kb": 73508}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s748946356", "group_id": "codeNet:p02633", "input_text": "import java.util.*;\n\npublic class Main{\npublic static void main(String[] args){\nScanner sc=new Scanner(System.in);\n int x=sc.nextInt();\n if(360/x==0){\nSystem.out.print(360/x);\n }else{\nSystem.out.print(360/x+1);\n }\n}\n}", "language": "Java", "metadata": {"date": 1592706872, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02633.html", "problem_id": "p02633", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02633/input.txt", "sample_output_relpath": "derived/input_output/data/p02633/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02633/Java/s748946356.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s748946356", "user_id": "u587100042"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main{\npublic static void main(String[] args){\nScanner sc=new Scanner(System.in);\n int x=sc.nextInt();\n if(360/x==0){\nSystem.out.print(360/x);\n }else{\nSystem.out.print(360/x+1);\n }\n}\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi is standing on a two-dimensional plane, facing north. Find the minimum positive integer K such that Takahashi will be at the starting position again after he does the following action K times:\n\nGo one meter in the direction he is facing. Then, turn X degrees counter-clockwise.\n\nConstraints\n\n1 \\leq X \\leq 179\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of times Takahashi will do the action before he is at the starting position again.\n\nSample Input 1\n\n90\n\nSample Output 1\n\n4\n\nTakahashi's path is a square.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n360", "sample_input": "90\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02633", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi is standing on a two-dimensional plane, facing north. Find the minimum positive integer K such that Takahashi will be at the starting position again after he does the following action K times:\n\nGo one meter in the direction he is facing. Then, turn X degrees counter-clockwise.\n\nConstraints\n\n1 \\leq X \\leq 179\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of times Takahashi will do the action before he is at the starting position again.\n\nSample Input 1\n\n90\n\nSample Output 1\n\n4\n\nTakahashi's path is a square.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n360", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 221, "cpu_time_ms": 128, "memory_kb": 35712}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s361808112", "group_id": "codeNet:p02639", "input_text": "import java.io.*;\nimport java.util.*;\n\npublic class Main{\n\tstatic void main() throws Exception{\n\t\tint n=sc.nextInt(),m=sc.nextInt(),k=sc.nextInt();\n\t\tint[]start=new int[2],end=new int[2];\n\t\tfor(int i=0;i<2;i++) {\n\t\t\tstart[i]=sc.nextInt()-1;\n\t\t}\n\t\tfor(int i=0;i<2;i++) {\n\t\t\tend[i]=sc.nextInt()-1;\n\t\t}\n\t\t\n\t\tchar[][]in=new char[n][m];\n\t\tfor(int i=0;iq=new LinkedList<>();\n\t\tq.add(new int[] {start[0],start[1],k-1,-1,0});\n\t\tdist[start[0]][start[1]][0]=0;\n\t\tdist[start[0]][start[1]][1]=0;\n\t\tdist[start[0]][start[1]][2]=0;\n\t\tdist[start[0]][start[1]][3]=0;\n\t\tint[]dx= {0,1,0,-1},dy= {1,0,-1,0};\n\t\twhile(!q.isEmpty()) {\n\t\t\tint cur[]=q.pollFirst();\n\t\t\tint x=cur[0],y=cur[1],curK=cur[2],dir=cur[3];\n\t\t\tint curDist=cur[4];\n//\t\t\tSystem.out.println(Arrays.toString(cur));\n\t\t\tfor(int i=0;i<4;i++) {\n\t\t\t\tint xx=x+dx[i],yy=y+dy[i];\n\t\t\t\tif(xx<0 || xx>=n || yy<0 || yy>=m || dist[xx][yy][(i)]!=inf || in[xx][yy]=='@')continue;\n\t\t\t\t\n\t\t\t\tint[]nxt=new int[] {xx,yy,curK-1,(i),0};\n\t\t\t\tif(nxt[2]<0) {\n\t\t\t\t\tnxt[2]=k-1;\n\t\t\t\t\tdist[xx][yy][(i)]=curDist+1;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif(dir==(i)) {\n\t\t\t\t\t\tdist[xx][yy][(i)]=curDist;\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tdist[xx][yy][(i)]=curDist+1;\n\t\t\t\t\t\tnxt[2]=k-1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnxt[4]=dist[xx][yy][(i)];\n\t\t\t\tif(nxt[4]==curDist) {\n\t\t\t\t\tq.addFirst(nxt);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tq.addLast(nxt);\n\t\t\t}\n\t\t}\n\t\tint ans=inf;\n\t\tfor(int i=0;i<4;i++) {\n\t\t\tans=Math.min(ans, dist[end[0]][end[1]][i]);\n\t\t}\n\t\tpw.println(ans==inf?-1:ans);\n\t}\n\tpublic static void main(String[] args) throws Exception{\n\t\tpw=new PrintWriter(System.out);\n\t\tsc = new MScanner(System.in);\n//\t\tint tc=sc.nextInt();\n//\t\twhile(tc-->0)\n\t\t\tmain();\n\t\tpw.flush();\n\t}\n\tstatic PrintWriter pw;\n\tstatic MScanner sc;\n\tstatic class MScanner {\n\t\tStringTokenizer st;\n\t\tBufferedReader br;\n\t\tpublic MScanner(InputStream system) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(system));\n\t\t}\n \n\t\tpublic MScanner(String file) throws Exception {\n\t\t\tbr = new BufferedReader(new FileReader(file));\n\t\t}\n \n\t\tpublic String next() throws IOException {\n\t\t\twhile (st == null || !st.hasMoreTokens())\n\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\treturn st.nextToken();\n\t\t}\n\t\tpublic int[] intArr(int n) throws IOException {\n\t int[]in=new int[n];for(int i=0;iq=new LinkedList<>();\n\t\tq.add(new int[] {start[0],start[1],k-1,-1,0});\n\t\tdist[start[0]][start[1]][0]=0;\n\t\tdist[start[0]][start[1]][1]=0;\n\t\tdist[start[0]][start[1]][2]=0;\n\t\tdist[start[0]][start[1]][3]=0;\n\t\tint[]dx= {0,1,0,-1},dy= {1,0,-1,0};\n\t\twhile(!q.isEmpty()) {\n\t\t\tint cur[]=q.pollFirst();\n\t\t\tint x=cur[0],y=cur[1],curK=cur[2],dir=cur[3];\n\t\t\tint curDist=cur[4];\n//\t\t\tSystem.out.println(Arrays.toString(cur));\n\t\t\tfor(int i=0;i<4;i++) {\n\t\t\t\tint xx=x+dx[i],yy=y+dy[i];\n\t\t\t\tif(xx<0 || xx>=n || yy<0 || yy>=m || dist[xx][yy][(i)]!=inf || in[xx][yy]=='@')continue;\n\t\t\t\t\n\t\t\t\tint[]nxt=new int[] {xx,yy,curK-1,(i),0};\n\t\t\t\tif(nxt[2]<0) {\n\t\t\t\t\tnxt[2]=k-1;\n\t\t\t\t\tdist[xx][yy][(i)]=curDist+1;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif(dir==(i)) {\n\t\t\t\t\t\tdist[xx][yy][(i)]=curDist;\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tdist[xx][yy][(i)]=curDist+1;\n\t\t\t\t\t\tnxt[2]=k-1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnxt[4]=dist[xx][yy][(i)];\n\t\t\t\tif(nxt[4]==curDist) {\n\t\t\t\t\tq.addFirst(nxt);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tq.addLast(nxt);\n\t\t\t}\n\t\t}\n\t\tint ans=inf;\n\t\tfor(int i=0;i<4;i++) {\n\t\t\tans=Math.min(ans, dist[end[0]][end[1]][i]);\n\t\t}\n\t\tpw.println(ans==inf?-1:ans);\n\t}\n\tpublic static void main(String[] args) throws Exception{\n\t\tpw=new PrintWriter(System.out);\n\t\tsc = new MScanner(System.in);\n//\t\tint tc=sc.nextInt();\n//\t\twhile(tc-->0)\n\t\t\tmain();\n\t\tpw.flush();\n\t}\n\tstatic PrintWriter pw;\n\tstatic MScanner sc;\n\tstatic class MScanner {\n\t\tStringTokenizer st;\n\t\tBufferedReader br;\n\t\tpublic MScanner(InputStream system) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(system));\n\t\t}\n \n\t\tpublic MScanner(String file) throws Exception {\n\t\t\tbr = new BufferedReader(new FileReader(file));\n\t\t}\n \n\t\tpublic String next() throws IOException {\n\t\t\twhile (st == null || !st.hasMoreTokens())\n\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\treturn st.nextToken();\n\t\t}\n\t\tpublic int[] intArr(int n) throws IOException {\n\t int[]in=new int[n];for(int i=0;i= y) {\n ans = \"Yes\";\n } else {\n ans = \"No\";\n }\n System.out.println(ans);\n }\n}", "language": "Java", "metadata": {"date": 1592183327, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02640.html", "problem_id": "p02640", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02640/input.txt", "sample_output_relpath": "derived/input_output/data/p02640/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02640/Java/s649403677.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s649403677", "user_id": "u843746948"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int x = sc.nextInt();\n int y = sc.nextInt();\n String ans = \"\";\n if (2 * x <= y && 4 * x >= y) {\n ans = \"Yes\";\n } else {\n ans = \"No\";\n }\n System.out.println(ans);\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs.\n\nTakahashi says: \"there are X animals in total in the garden, and they have Y legs in total.\" Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n1 \\leq Y \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf there is a combination of numbers of cranes and turtles in which the statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 8\n\nSample Output 1\n\nYes\n\nThe statement \"there are 3 animals in total in the garden, and they have 8 legs in total\" is correct if there are two cranes and one turtle. Thus, there is a combination of numbers of cranes and turtles in which the statement is correct.\n\nSample Input 2\n\n2 100\n\nSample Output 2\n\nNo\n\nThere is no combination of numbers of cranes and turtles in which this statement is correct.\n\nSample Input 3\n\n1 2\n\nSample Output 3\n\nYes\n\nWe also consider the case in which there are only cranes or only turtles.", "sample_input": "3 8\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02640", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs.\n\nTakahashi says: \"there are X animals in total in the garden, and they have Y legs in total.\" Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n1 \\leq Y \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf there is a combination of numbers of cranes and turtles in which the statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 8\n\nSample Output 1\n\nYes\n\nThe statement \"there are 3 animals in total in the garden, and they have 8 legs in total\" is correct if there are two cranes and one turtle. Thus, there is a combination of numbers of cranes and turtles in which the statement is correct.\n\nSample Input 2\n\n2 100\n\nSample Output 2\n\nNo\n\nThere is no combination of numbers of cranes and turtles in which this statement is correct.\n\nSample Input 3\n\n1 2\n\nSample Output 3\n\nYes\n\nWe also consider the case in which there are only cranes or only turtles.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 372, "cpu_time_ms": 123, "memory_kb": 35832}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s432807068", "group_id": "codeNet:p02641", "input_text": "\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n Long n = sc.nextLong();\n sc.nextLine();\n String[] str = sc.nextLine().split(\" \");\n\n List aList = new ArrayList();\n for(int i = 0;i < n;i++) {\n aList.add(Long.parseLong(str[i]));\n }\n\n int cnt = 0;\n boolean flg = true;\n for(int i = 0;i < n;i++) {\n for(int j = 0;j < n;j++) {\n if(i != j && aList.get(i) % aList.get(j) == 0) {\n flg = false;\n break;\n }\n }\n if(flg) {\n cnt++;\n }\n flg = true;\n }\n System.out.println(cnt);\n }\n}\n", "language": "Java", "metadata": {"date": 1593666129, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02641.html", "problem_id": "p02641", "resource_group": "high_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/Java/s432807068.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s432807068", "user_id": "u580010448"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n Long n = sc.nextLong();\n sc.nextLine();\n String[] str = sc.nextLine().split(\" \");\n\n List aList = new ArrayList();\n for(int i = 0;i < n;i++) {\n aList.add(Long.parseLong(str[i]));\n }\n\n int cnt = 0;\n boolean flg = true;\n for(int i = 0;i < n;i++) {\n for(int j = 0;j < n;j++) {\n if(i != j && aList.get(i) % aList.get(j) == 0) {\n flg = false;\n break;\n }\n }\n if(flg) {\n cnt++;\n }\n flg = true;\n }\n System.out.println(cnt);\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": 720, "cpu_time_ms": 123, "memory_kb": 35944}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s802362380", "group_id": "codeNet:p02641", "input_text": "import java.util.ArrayList;\nimport java.util.List;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n\n int x = sc.nextInt();\n int n = sc.nextInt();\n\n List p = new ArrayList();\n for(int i=0; i p = new ArrayList();\n for(int i=0; i= a || a == 0) {\n System.out.println(\"YES\");\n }else{\n System.out.println(\"NO\");\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1592151074, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02646.html", "problem_id": "p02646", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02646/input.txt", "sample_output_relpath": "derived/input_output/data/p02646/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02646/Java/s122097758.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s122097758", "user_id": "u516693153"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int A = sc.nextInt();\n int V = sc.nextInt();\n int B = sc.nextInt();\n int W = sc.nextInt();\n int T = sc.nextInt();\n int a=B-A;\n if(a<=0){a=a*-1;}\n if((long)(V-W)*T >= a || a == 0) {\n System.out.println(\"YES\");\n }else{\n System.out.println(\"NO\");\n }\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTwo children are playing tag on a number line. (In the game of tag, the child called \"it\" tries to catch the other child.) The child who is \"it\" is now at coordinate A, and he can travel the distance of V per second.\nThe other child is now at coordinate B, and she can travel the distance of W per second.\n\nHe can catch her when his coordinate is the same as hers.\nDetermine whether he can catch her within T seconds (including exactly T seconds later).\nWe assume that both children move optimally.\n\nConstraints\n\n-10^9 \\leq A,B \\leq 10^9\n\n1 \\leq V,W \\leq 10^9\n\n1 \\leq T \\leq 10^9\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA V\nB W\nT\n\nOutput\n\nIf \"it\" can catch the other child, print YES; otherwise, print NO.\n\nSample Input 1\n\n1 2\n3 1\n3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n1 2\n3 2\n3\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n1 2\n3 3\n3\n\nSample Output 3\n\nNO", "sample_input": "1 2\n3 1\n3\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02646", "source_text": "Score : 200 points\n\nProblem Statement\n\nTwo children are playing tag on a number line. (In the game of tag, the child called \"it\" tries to catch the other child.) The child who is \"it\" is now at coordinate A, and he can travel the distance of V per second.\nThe other child is now at coordinate B, and she can travel the distance of W per second.\n\nHe can catch her when his coordinate is the same as hers.\nDetermine whether he can catch her within T seconds (including exactly T seconds later).\nWe assume that both children move optimally.\n\nConstraints\n\n-10^9 \\leq A,B \\leq 10^9\n\n1 \\leq V,W \\leq 10^9\n\n1 \\leq T \\leq 10^9\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA V\nB W\nT\n\nOutput\n\nIf \"it\" can catch the other child, print YES; otherwise, print NO.\n\nSample Input 1\n\n1 2\n3 1\n3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n1 2\n3 2\n3\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n1 2\n3 3\n3\n\nSample Output 3\n\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 419, "cpu_time_ms": 107, "memory_kb": 35592}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s036327305", "group_id": "codeNet:p02647", "input_text": "import java.util.*;\n\nclass Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n \tint K = sc.nextInt();\n \tif(K>100) K=41;\n \tInteger A[] = new Integer[N];\n \tInteger ans[] = new Integer[N];\n for (int i=0; i0) sta=i-A[i];\n if(i+A[i]100) K=41;\n \tInteger A[] = new Integer[N];\n \tInteger ans[] = new Integer[N];\n for (int i=0; i0) sta=i-A[i];\n if(i+A[i] 18) con = false;\n \t\n \tif(con) System.out.println(ans);\n \telse System.out.println(-1);\n \n\t}\n}\n", "language": "Java", "metadata": {"date": 1593708540, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02657.html", "problem_id": "p02657", "resource_group": "high_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/Java/s592504094.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s592504094", "user_id": "u591547748"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.util.*;\nimport java.lang.Math;\n\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\n \t\tint num = sc.nextInt(); \n \tlong ans = 1;\n \tboolean con = true;\n \n \tfor(int i = 0;i < num; i++) {\n ans *= sc.nextLong();\n }\n \n \tif(Math.log(ans) > 18) con = false;\n \t\n \tif(con) System.out.println(ans);\n \telse System.out.println(-1);\n \n\t}\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nCompute A \\times B.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the value A \\times B as an integer.\n\nSample Input 1\n\n2 5\n\nSample Output 1\n\n10\n\nWe have 2 \\times 5 = 10.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\n10000", "sample_input": "2 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02657", "source_text": "Score : 100 points\n\nProblem Statement\n\nCompute A \\times B.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the value A \\times B as an integer.\n\nSample Input 1\n\n2 5\n\nSample Output 1\n\n10\n\nWe have 2 \\times 5 = 10.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\n10000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 456, "cpu_time_ms": 119, "memory_kb": 35624}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s442317058", "group_id": "codeNet:p02657", "input_text": "import java.util.*;\nimport java.lang.*;\nimport java.io.*;\nimport java.math.BigInteger;\n/* Name of the class has to be \"Main\" only if the class is public. */\nclass Main\n{\n\tpublic static void main (String[] args) throws java.lang.Exception\n\t{try {\n\t \n\t\n\t Scanner k=new Scanner(System.in);\n\t\tint n=k.nextInt();\n\t\tBigInteger f=new BigInteger(\"1\");\tBigInteger ff=new BigInteger(\"1000000000000000000\");\n\t\tfor(int i=0;i0) {\n long ele = in.nextLong();\n ans = ans*ele;\n if(ans > 1000000000000000000L) {\n ans = -1; \n } \n }\n System.out.println(ans<0?-1:ans);\n }\n}", "language": "Java", "metadata": {"date": 1591158058, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02657.html", "problem_id": "p02657", "resource_group": "high_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/Java/s764464857.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s764464857", "user_id": "u082516339"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.util.Scanner;\n\nclass Main { \n public static void main(String[] args) { \n Scanner in = new Scanner(System.in);\n \tint n = in.nextInt();\n long ans = 1;\n while(n-- >0) {\n long ele = in.nextLong();\n ans = ans*ele;\n if(ans > 1000000000000000000L) {\n ans = -1; \n } \n }\n System.out.println(ans<0?-1:ans);\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nCompute A \\times B.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the value A \\times B as an integer.\n\nSample Input 1\n\n2 5\n\nSample Output 1\n\n10\n\nWe have 2 \\times 5 = 10.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\n10000", "sample_input": "2 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02657", "source_text": "Score : 100 points\n\nProblem Statement\n\nCompute A \\times B.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the value A \\times B as an integer.\n\nSample Input 1\n\n2 5\n\nSample Output 1\n\n10\n\nWe have 2 \\times 5 = 10.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\n10000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 424, "cpu_time_ms": 109, "memory_kb": 35924}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s824286604", "group_id": "codeNet:p02660", "input_text": "import java.util.*;\n\npublic class Main {\n\n public static void main(String args[]) {\n\n // 入力\n Scanner sc = new Scanner(System.in);\n long n = Long.parseLong(sc.next());\n sc.close();\n\n // 主処理\n int result = 0;\n if (n != 1) {\n List list = primeFactorization(n);\n Map map = new HashMap<>();\n for (int i = 0; i < list.size(); i++) {\n long num = list.get(i);\n if (map.containsKey(num)) {\n map.put(num, map.get(num) + 1);\n } else {\n map.put(num, 1);\n }\n }\n\n int[] count = new int[40];\n for (int i = 1; i < count.length; i++) {\n count[i] = count[i - 1] + i;\n }\n\n for (Long key : map.keySet()) {\n int val = map.get(key);\n for (int i = 0; i < count.length; i++) {\n if (val < count[i]) {\n result += i - 1;\n break;\n }\n }\n }\n }\n\n // 出力\n System.out.println(result);\n\n }\n\n public static List primeFactorization(long num) {\n List list = new ArrayList<>();\n long div = 2;\n while (!isPrime(num)) {\n if (num % div == 0) {\n num /= div;\n list.add(div);\n } else {\n div++;\n }\n }\n list.add(num);\n return list;\n }\n\n public static boolean isPrime(long num) {\n if (num == 2) {\n return true;\n } else if (num < 2 || num % 2 == 0) {\n return false;\n }\n double sqrtNum = Math.sqrt(num);\n for (long i = 3; i <= sqrtNum; i += 2) {\n if (num % i == 0) {\n return false;\n }\n }\n return true;\n }\n}\n", "language": "Java", "metadata": {"date": 1591041233, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02660.html", "problem_id": "p02660", "resource_group": "high_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/Java/s824286604.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s824286604", "user_id": "u194225526"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\n public static void main(String args[]) {\n\n // 入力\n Scanner sc = new Scanner(System.in);\n long n = Long.parseLong(sc.next());\n sc.close();\n\n // 主処理\n int result = 0;\n if (n != 1) {\n List list = primeFactorization(n);\n Map map = new HashMap<>();\n for (int i = 0; i < list.size(); i++) {\n long num = list.get(i);\n if (map.containsKey(num)) {\n map.put(num, map.get(num) + 1);\n } else {\n map.put(num, 1);\n }\n }\n\n int[] count = new int[40];\n for (int i = 1; i < count.length; i++) {\n count[i] = count[i - 1] + i;\n }\n\n for (Long key : map.keySet()) {\n int val = map.get(key);\n for (int i = 0; i < count.length; i++) {\n if (val < count[i]) {\n result += i - 1;\n break;\n }\n }\n }\n }\n\n // 出力\n System.out.println(result);\n\n }\n\n public static List primeFactorization(long num) {\n List list = new ArrayList<>();\n long div = 2;\n while (!isPrime(num)) {\n if (num % div == 0) {\n num /= div;\n list.add(div);\n } else {\n div++;\n }\n }\n list.add(num);\n return list;\n }\n\n public static boolean isPrime(long num) {\n if (num == 2) {\n return true;\n } else if (num < 2 || num % 2 == 0) {\n return false;\n }\n double sqrtNum = Math.sqrt(num);\n for (long i = 3; i <= sqrtNum; i += 2) {\n if (num % i == 0) {\n return false;\n }\n }\n return true;\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": 1960, "cpu_time_ms": 2207, "memory_kb": 36320}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s400745758", "group_id": "codeNet:p02660", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.HashMap;\nimport java.util.StringTokenizer;\n\npublic class Main {\n\t\n\tpublic static void main(String[] args) throws IOException {\n\t\tMain mainObj = new Main();\n\t\tmainObj.solve();\n\t}\n\n\tpublic void solve() throws IOException {\n\t\tFastScanner fs = new FastScanner();\n\t\tlong n = fs.nextLong();\n\t\t\n\t\tif(n == 1) {\n\t\t\tSystem.out.println(0);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tint sqrt = (int)Math.sqrt(n)+1;\n\t\t\n//\t\tHashMap insuMap = new HashMap<>();\n\t\t\n\t\tint[] insuArr = new int[sqrt+1];\n\t\t\n\t\tfor(int i = 2; i <= sqrt; i++) {\n\t\t\twhile(n % i == 0) {\n\t\t\t\tinsuArr[i]++;\n\t\t\t\tn /= i;\n\t\t\t}\n\t\t}\n\t\t\n\t\tlong ans = 0;\n\t\t\n\t\tif(n != 1) {\n\t\t\tans++;\n\t\t}\n\t\t\n\t\tfor(int i = 0; i <= sqrt; i++) {\n\t\t\t\n\t\t\tif(insuArr[i] > 0) {\n\t\t\t\tint now = 1;\n\t\t\t\twhile(insuArr[i] >= now) {\n\t\t\t\t\tans++;\n\t\t\t\t\tinsuArr[i] -= now;\n\t\t\t\t\tnow++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(ans);\n\t\t\n\t}\t\n\n\tpublic class FastScanner {\n\n\t\tBufferedReader reader;\n\t\tprivate StringTokenizer st;\n\n\t\tpublic FastScanner() {\n\t\t\tst = null;\n\t\t\treader = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\n\t\tpublic String next() throws IOException {\n\t\t\tif (st == null || !st.hasMoreElements()) {\n\t\t\t\tst = new StringTokenizer(reader.readLine());\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tpublic String nextLine() throws IOException {\n\t\t\tst = null;\n\t\t\tString readLine = null;\n\t\t\treadLine = reader.readLine();\n\t\t\treturn readLine;\n\t\t}\n\n\t\tpublic int nextInt() throws NumberFormatException, IOException {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tpublic long nextLong() throws NumberFormatException, IOException {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tpublic int[] nextIntArr(int n) throws NumberFormatException, IOException {\n\t\t\tint[] retArr = new int[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tretArr[i] = nextInt();\n\t\t\t}\n\t\t\treturn retArr;\n\t\t}\n\n\t\tpublic long[] nextLongArr(int n) throws NumberFormatException, IOException {\n\t\t\tlong[] retArr = new long[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tretArr[i] = nextLong();\n\t\t\t}\n\t\t\treturn retArr;\n\t\t}\n\n\t\tpublic void close() throws IOException {\n\t\t\treader.close();\n\t\t}\n\t}\n\n\n}\n", "language": "Java", "metadata": {"date": 1590976648, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02660.html", "problem_id": "p02660", "resource_group": "high_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/Java/s400745758.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s400745758", "user_id": "u903557324"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.HashMap;\nimport java.util.StringTokenizer;\n\npublic class Main {\n\t\n\tpublic static void main(String[] args) throws IOException {\n\t\tMain mainObj = new Main();\n\t\tmainObj.solve();\n\t}\n\n\tpublic void solve() throws IOException {\n\t\tFastScanner fs = new FastScanner();\n\t\tlong n = fs.nextLong();\n\t\t\n\t\tif(n == 1) {\n\t\t\tSystem.out.println(0);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tint sqrt = (int)Math.sqrt(n)+1;\n\t\t\n//\t\tHashMap insuMap = new HashMap<>();\n\t\t\n\t\tint[] insuArr = new int[sqrt+1];\n\t\t\n\t\tfor(int i = 2; i <= sqrt; i++) {\n\t\t\twhile(n % i == 0) {\n\t\t\t\tinsuArr[i]++;\n\t\t\t\tn /= i;\n\t\t\t}\n\t\t}\n\t\t\n\t\tlong ans = 0;\n\t\t\n\t\tif(n != 1) {\n\t\t\tans++;\n\t\t}\n\t\t\n\t\tfor(int i = 0; i <= sqrt; i++) {\n\t\t\t\n\t\t\tif(insuArr[i] > 0) {\n\t\t\t\tint now = 1;\n\t\t\t\twhile(insuArr[i] >= now) {\n\t\t\t\t\tans++;\n\t\t\t\t\tinsuArr[i] -= now;\n\t\t\t\t\tnow++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(ans);\n\t\t\n\t}\t\n\n\tpublic class FastScanner {\n\n\t\tBufferedReader reader;\n\t\tprivate StringTokenizer st;\n\n\t\tpublic FastScanner() {\n\t\t\tst = null;\n\t\t\treader = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\n\t\tpublic String next() throws IOException {\n\t\t\tif (st == null || !st.hasMoreElements()) {\n\t\t\t\tst = new StringTokenizer(reader.readLine());\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tpublic String nextLine() throws IOException {\n\t\t\tst = null;\n\t\t\tString readLine = null;\n\t\t\treadLine = reader.readLine();\n\t\t\treturn readLine;\n\t\t}\n\n\t\tpublic int nextInt() throws NumberFormatException, IOException {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tpublic long nextLong() throws NumberFormatException, IOException {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tpublic int[] nextIntArr(int n) throws NumberFormatException, IOException {\n\t\t\tint[] retArr = new int[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tretArr[i] = nextInt();\n\t\t\t}\n\t\t\treturn retArr;\n\t\t}\n\n\t\tpublic long[] nextLongArr(int n) throws NumberFormatException, IOException {\n\t\t\tlong[] retArr = new long[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tretArr[i] = nextLong();\n\t\t\t}\n\t\t\treturn retArr;\n\t\t}\n\n\t\tpublic void close() throws IOException {\n\t\t\treader.close();\n\t\t}\n\t}\n\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": 2153, "cpu_time_ms": 87, "memory_kb": 36800}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s200956746", "group_id": "codeNet:p02663", "input_text": "import java.util.Scanner;\nclass Main{\n\tpublic static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int H1 = sc.nextInt();\n int M1 = sc.nextInt();\n int H2= sc.nextInt();\n int M2 = sc.nextInt();\n int t = sc.nextInt();\n int tt= Math.abs((H2-H1)*60) - Math.abs(M1-M2)-t;\n System.out.println(\"\"+tt);\n }\n}", "language": "Java", "metadata": {"date": 1590889613, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02663.html", "problem_id": "p02663", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02663/input.txt", "sample_output_relpath": "derived/input_output/data/p02663/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02663/Java/s200956746.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s200956746", "user_id": "u052878000"}, "prompt_components": {"gold_output": "270\n", "input_to_evaluate": "import java.util.Scanner;\nclass Main{\n\tpublic static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int H1 = sc.nextInt();\n int M1 = sc.nextInt();\n int H2= sc.nextInt();\n int M2 = sc.nextInt();\n int t = sc.nextInt();\n int tt= Math.abs((H2-H1)*60) - Math.abs(M1-M2)-t;\n System.out.println(\"\"+tt);\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn this problem, we use the 24-hour clock.\n\nTakahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.)\nHe has decided to study for K consecutive minutes while he is up.\nWhat is the length of the period in which he can start studying?\n\nConstraints\n\n0 \\le H_1, H_2 \\le 23\n\n0 \\le M_1, M_2 \\le 59\n\nThe time H_1 : M_1 comes before the time H_2 : M_2.\n\nK \\ge 1\n\nTakahashi is up for at least K minutes.\n\nAll values in input are integers (without leading zeros).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH_1 M_1 H_2 M_2 K\n\nOutput\n\nPrint the length of the period in which he can start studying, as an integer.\n\nSample Input 1\n\n10 0 15 0 30\n\nSample Output 1\n\n270\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly three in the afternoon.\nIt takes 30 minutes to do the study, so he can start it in the period between ten o'clock and half-past two. The length of this period is 270 minutes, so we should print 270.\n\nSample Input 2\n\n10 0 12 0 120\n\nSample Output 2\n\n0\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly noon. It takes 120 minutes to do the study, so he has to start it at exactly ten o'clock. Thus, we should print 0.", "sample_input": "10 0 15 0 30\n"}, "reference_outputs": ["270\n"], "source_document_id": "p02663", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn this problem, we use the 24-hour clock.\n\nTakahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.)\nHe has decided to study for K consecutive minutes while he is up.\nWhat is the length of the period in which he can start studying?\n\nConstraints\n\n0 \\le H_1, H_2 \\le 23\n\n0 \\le M_1, M_2 \\le 59\n\nThe time H_1 : M_1 comes before the time H_2 : M_2.\n\nK \\ge 1\n\nTakahashi is up for at least K minutes.\n\nAll values in input are integers (without leading zeros).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH_1 M_1 H_2 M_2 K\n\nOutput\n\nPrint the length of the period in which he can start studying, as an integer.\n\nSample Input 1\n\n10 0 15 0 30\n\nSample Output 1\n\n270\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly three in the afternoon.\nIt takes 30 minutes to do the study, so he can start it in the period between ten o'clock and half-past two. The length of this period is 270 minutes, so we should print 270.\n\nSample Input 2\n\n10 0 12 0 120\n\nSample Output 2\n\n0\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly noon. It takes 120 minutes to do the study, so he has to start it at exactly ten o'clock. Thus, we should print 0.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 359, "cpu_time_ms": 145, "memory_kb": 38724}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s835939596", "group_id": "codeNet:p02663", "input_text": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int h1 = sc.nextInt();\n int m1 = sc.nextInt();\n int h2 = sc.nextInt();\n int m2 = sc.nextInt();\n int k = sc.nextInt();\n \n int t1 = h1*60+m1;\n int t2 = h2*60+m2;\n int ans = t2-t1-k;\n \n System.out.println(ans);\n }\n}\n", "language": "Java", "metadata": {"date": 1590887821, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02663.html", "problem_id": "p02663", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02663/input.txt", "sample_output_relpath": "derived/input_output/data/p02663/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02663/Java/s835939596.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s835939596", "user_id": "u229092595"}, "prompt_components": {"gold_output": "270\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int h1 = sc.nextInt();\n int m1 = sc.nextInt();\n int h2 = sc.nextInt();\n int m2 = sc.nextInt();\n int k = sc.nextInt();\n \n int t1 = h1*60+m1;\n int t2 = h2*60+m2;\n int ans = t2-t1-k;\n \n System.out.println(ans);\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn this problem, we use the 24-hour clock.\n\nTakahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.)\nHe has decided to study for K consecutive minutes while he is up.\nWhat is the length of the period in which he can start studying?\n\nConstraints\n\n0 \\le H_1, H_2 \\le 23\n\n0 \\le M_1, M_2 \\le 59\n\nThe time H_1 : M_1 comes before the time H_2 : M_2.\n\nK \\ge 1\n\nTakahashi is up for at least K minutes.\n\nAll values in input are integers (without leading zeros).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH_1 M_1 H_2 M_2 K\n\nOutput\n\nPrint the length of the period in which he can start studying, as an integer.\n\nSample Input 1\n\n10 0 15 0 30\n\nSample Output 1\n\n270\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly three in the afternoon.\nIt takes 30 minutes to do the study, so he can start it in the period between ten o'clock and half-past two. The length of this period is 270 minutes, so we should print 270.\n\nSample Input 2\n\n10 0 12 0 120\n\nSample Output 2\n\n0\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly noon. It takes 120 minutes to do the study, so he has to start it at exactly ten o'clock. Thus, we should print 0.", "sample_input": "10 0 15 0 30\n"}, "reference_outputs": ["270\n"], "source_document_id": "p02663", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn this problem, we use the 24-hour clock.\n\nTakahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.)\nHe has decided to study for K consecutive minutes while he is up.\nWhat is the length of the period in which he can start studying?\n\nConstraints\n\n0 \\le H_1, H_2 \\le 23\n\n0 \\le M_1, M_2 \\le 59\n\nThe time H_1 : M_1 comes before the time H_2 : M_2.\n\nK \\ge 1\n\nTakahashi is up for at least K minutes.\n\nAll values in input are integers (without leading zeros).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH_1 M_1 H_2 M_2 K\n\nOutput\n\nPrint the length of the period in which he can start studying, as an integer.\n\nSample Input 1\n\n10 0 15 0 30\n\nSample Output 1\n\n270\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly three in the afternoon.\nIt takes 30 minutes to do the study, so he can start it in the period between ten o'clock and half-past two. The length of this period is 270 minutes, so we should print 270.\n\nSample Input 2\n\n10 0 12 0 120\n\nSample Output 2\n\n0\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly noon. It takes 120 minutes to do the study, so he has to start it at exactly ten o'clock. Thus, we should print 0.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 431, "cpu_time_ms": 106, "memory_kb": 35768}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s850064670", "group_id": "codeNet:p02665", "input_text": "\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.math.BigInteger;\nimport java.util.Arrays;\nimport java.util.InputMismatchException;\n\n/**\n * @author Mubtasim Shahriar\n */\n\npublic class Main {\n\n\n\tpublic static void main(String[] args) {\n\n\t\tInputStream inputStream = System.in;\n\t\tOutputStream outputStream = System.out;\n\t\tInputReader sc = new InputReader(inputStream);\n\t\tPrintWriter out = new PrintWriter(outputStream);\n\t\tSolver solver = new Solver();\n//\t\tint t = sc.nextInt();\n\t\tint t = 1;\n\t\twhile(t--!=0) {\n\t\t\tsolver.solve(sc, out);\n\t\t}\t\t\n\t\tout.close();\n\n\t}\n\n\tstatic class Solver {\n\t\tpublic void solve(InputReader sc, PrintWriter out) {\n\t\t\tint n = sc.nextInt()+1;\n\t\t\tlong[] arr = sc.nextLongArray(n);\n\t\t\tif(arr[0]==1 && n>1) {\n\t\t\t\tout.println(-1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif(arr[0]>1) {\n\t\t\t\tout.println(-1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlong[] fromdown = new long[n];\n\t\t\tlong[] fromup = new long[n];\n\t\t\tfromdown[n-1] = arr[n-1];\n\t\t\tfor(int i = n-2; i >= 0; i--) {\n\t\t\t\tfromdown[i] = fromdown[i+1] + arr[i];\n\t\t\t}\n\t\t\tfromup[0] = 1;\n\t\t\tlong next = 1;\n\t\t\tfor(int i = 1; i < n; i++) {\n\t\t\t\tlong canhave = Math.min(fromdown[i], next*2);\n\t\t\t\tnext = canhave - arr[i];\n\t\t\t\tfromup[i] = canhave;\n\t\t\t\tif(canhave= numChars) {\n\t\t\t\tcurChar = 0;\n\t\t\t\ttry {\n\t\t\t\t\tnumChars = stream.read(buf);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\t\t\t\tif (numChars <= 0) {\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn buf[curChar++];\n\t\t}\n\n\t\tpublic int peek() {\n\t\t\tif (numChars == -1) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tif (curChar >= numChars) {\n\t\t\t\tcurChar = 0;\n\t\t\t\ttry {\n\t\t\t\t\tnumChars = stream.read(buf);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t\tif (numChars <= 0) {\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn buf[curChar];\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c)) {\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tint sgn = 1;\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tint res = 0;\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9') {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\t\t\treturn res * sgn;\n\t\t}\n\n\t\tpublic long nextLong() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c)) {\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tint sgn = 1;\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tlong res = 0;\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9') {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\t\t\treturn res * sgn;\n\t\t}\n\n\t\tpublic String nextString() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c)) {\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tStringBuilder res = new StringBuilder();\n\t\t\tdo {\n\t\t\t\tif (Character.isValidCodePoint(c)) {\n\t\t\t\t\tres.appendCodePoint(c);\n\t\t\t\t}\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\t\t\treturn res.toString();\n\t\t}\n\n\t\tpublic boolean isSpaceChar(int c) {\n\t\t\tif (filter != null) {\n\t\t\t\treturn filter.isSpaceChar(c);\n\t\t\t}\n\t\t\treturn isWhitespace(c);\n\t\t}\n\n\t\tpublic static boolean isWhitespace(int c) {\n\t\t\treturn c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n\t\t}\n\n\t\tprivate String readLine0() {\n\t\t\tStringBuilder buf = new StringBuilder();\n\t\t\tint c = read();\n\t\t\twhile (c != '\\n' && c != -1) {\n\t\t\t\tif (c != '\\r') {\n\t\t\t\t\tbuf.appendCodePoint(c);\n\t\t\t\t}\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\treturn buf.toString();\n\t\t}\n\n\t\tpublic String readLine() {\n\t\t\tString s = readLine0();\n\t\t\twhile (s.trim().length() == 0) {\n\t\t\t\ts = readLine0();\n\t\t\t}\n\t\t\treturn s;\n\t\t}\n\n\t\tpublic String readLine(boolean ignoreEmptyLines) {\n\t\t\tif (ignoreEmptyLines) {\n\t\t\t\treturn readLine();\n\t\t\t} else {\n\t\t\t\treturn readLine0();\n\t\t\t}\n\t\t}\n\n\t\tpublic BigInteger readBigInteger() {\n\t\t\ttry {\n\t\t\t\treturn new BigInteger(nextString());\n\t\t\t} catch (NumberFormatException e) {\n\t\t\t\tthrow new InputMismatchException();\n\t\t\t}\n\t\t}\n\n\t\tpublic char nextCharacter() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c)) {\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\treturn (char) c;\n\t\t}\n\n\t\tpublic double nextDouble() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c)) {\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tint sgn = 1;\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tdouble res = 0;\n\t\t\twhile (!isSpaceChar(c) && c != '.') {\n\t\t\t\tif (c == 'e' || c == 'E') {\n\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\t}\n\t\t\t\tif (c < '0' || c > '9') {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tif (c == '.') {\n\t\t\t\tc = read();\n\t\t\t\tdouble m = 1;\n\t\t\t\twhile (!isSpaceChar(c)) {\n\t\t\t\t\tif (c == 'e' || c == 'E') {\n\t\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\t\t}\n\t\t\t\t\tif (c < '0' || c > '9') {\n\t\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t\t}\n\t\t\t\t\tm /= 10;\n\t\t\t\t\tres += (c - '0') * m;\n\t\t\t\t\tc = read();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn res * sgn;\n\t\t}\n\n\t\tpublic boolean isExhausted() {\n\t\t\tint value;\n\t\t\twhile (isSpaceChar(value = peek()) && value != -1) {\n\t\t\t\tread();\n\t\t\t}\n\t\t\treturn value == -1;\n\t\t}\n\n\t\tpublic String next() {\n\t\t\treturn nextString();\n\t\t}\n\n\t\tpublic SpaceCharFilter getFilter() {\n\t\t\treturn filter;\n\t\t}\n\n\t\tpublic void setFilter(SpaceCharFilter filter) {\n\t\t\tthis.filter = filter;\n\t\t}\n\n\t\tpublic interface SpaceCharFilter {\n\t\t\tpublic boolean isSpaceChar(int ch);\n\t\t}\n\t\tpublic int[] nextIntArray(int n){\n\t\t\tint[] array=new int[n];\n\t\t\tfor(int i=0;i1) {\n\t\t\t\tout.println(-1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif(arr[0]>1) {\n\t\t\t\tout.println(-1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlong[] fromdown = new long[n];\n\t\t\tlong[] fromup = new long[n];\n\t\t\tfromdown[n-1] = arr[n-1];\n\t\t\tfor(int i = n-2; i >= 0; i--) {\n\t\t\t\tfromdown[i] = fromdown[i+1] + arr[i];\n\t\t\t}\n\t\t\tfromup[0] = 1;\n\t\t\tlong next = 1;\n\t\t\tfor(int i = 1; i < n; i++) {\n\t\t\t\tlong canhave = Math.min(fromdown[i], next*2);\n\t\t\t\tnext = canhave - arr[i];\n\t\t\t\tfromup[i] = canhave;\n\t\t\t\tif(canhave= numChars) {\n\t\t\t\tcurChar = 0;\n\t\t\t\ttry {\n\t\t\t\t\tnumChars = stream.read(buf);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\t\t\t\tif (numChars <= 0) {\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn buf[curChar++];\n\t\t}\n\n\t\tpublic int peek() {\n\t\t\tif (numChars == -1) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tif (curChar >= numChars) {\n\t\t\t\tcurChar = 0;\n\t\t\t\ttry {\n\t\t\t\t\tnumChars = stream.read(buf);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t\tif (numChars <= 0) {\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn buf[curChar];\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c)) {\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tint sgn = 1;\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tint res = 0;\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9') {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\t\t\treturn res * sgn;\n\t\t}\n\n\t\tpublic long nextLong() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c)) {\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tint sgn = 1;\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tlong res = 0;\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9') {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\t\t\treturn res * sgn;\n\t\t}\n\n\t\tpublic String nextString() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c)) {\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tStringBuilder res = new StringBuilder();\n\t\t\tdo {\n\t\t\t\tif (Character.isValidCodePoint(c)) {\n\t\t\t\t\tres.appendCodePoint(c);\n\t\t\t\t}\n\t\t\t\tc = read();\n\t\t\t} while (!isSpaceChar(c));\n\t\t\treturn res.toString();\n\t\t}\n\n\t\tpublic boolean isSpaceChar(int c) {\n\t\t\tif (filter != null) {\n\t\t\t\treturn filter.isSpaceChar(c);\n\t\t\t}\n\t\t\treturn isWhitespace(c);\n\t\t}\n\n\t\tpublic static boolean isWhitespace(int c) {\n\t\t\treturn c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n\t\t}\n\n\t\tprivate String readLine0() {\n\t\t\tStringBuilder buf = new StringBuilder();\n\t\t\tint c = read();\n\t\t\twhile (c != '\\n' && c != -1) {\n\t\t\t\tif (c != '\\r') {\n\t\t\t\t\tbuf.appendCodePoint(c);\n\t\t\t\t}\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\treturn buf.toString();\n\t\t}\n\n\t\tpublic String readLine() {\n\t\t\tString s = readLine0();\n\t\t\twhile (s.trim().length() == 0) {\n\t\t\t\ts = readLine0();\n\t\t\t}\n\t\t\treturn s;\n\t\t}\n\n\t\tpublic String readLine(boolean ignoreEmptyLines) {\n\t\t\tif (ignoreEmptyLines) {\n\t\t\t\treturn readLine();\n\t\t\t} else {\n\t\t\t\treturn readLine0();\n\t\t\t}\n\t\t}\n\n\t\tpublic BigInteger readBigInteger() {\n\t\t\ttry {\n\t\t\t\treturn new BigInteger(nextString());\n\t\t\t} catch (NumberFormatException e) {\n\t\t\t\tthrow new InputMismatchException();\n\t\t\t}\n\t\t}\n\n\t\tpublic char nextCharacter() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c)) {\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\treturn (char) c;\n\t\t}\n\n\t\tpublic double nextDouble() {\n\t\t\tint c = read();\n\t\t\twhile (isSpaceChar(c)) {\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tint sgn = 1;\n\t\t\tif (c == '-') {\n\t\t\t\tsgn = -1;\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tdouble res = 0;\n\t\t\twhile (!isSpaceChar(c) && c != '.') {\n\t\t\t\tif (c == 'e' || c == 'E') {\n\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\t}\n\t\t\t\tif (c < '0' || c > '9') {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\t\t\t\tres *= 10;\n\t\t\t\tres += c - '0';\n\t\t\t\tc = read();\n\t\t\t}\n\t\t\tif (c == '.') {\n\t\t\t\tc = read();\n\t\t\t\tdouble m = 1;\n\t\t\t\twhile (!isSpaceChar(c)) {\n\t\t\t\t\tif (c == 'e' || c == 'E') {\n\t\t\t\t\t\treturn res * Math.pow(10, nextInt());\n\t\t\t\t\t}\n\t\t\t\t\tif (c < '0' || c > '9') {\n\t\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t\t}\n\t\t\t\t\tm /= 10;\n\t\t\t\t\tres += (c - '0') * m;\n\t\t\t\t\tc = read();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn res * sgn;\n\t\t}\n\n\t\tpublic boolean isExhausted() {\n\t\t\tint value;\n\t\t\twhile (isSpaceChar(value = peek()) && value != -1) {\n\t\t\t\tread();\n\t\t\t}\n\t\t\treturn value == -1;\n\t\t}\n\n\t\tpublic String next() {\n\t\t\treturn nextString();\n\t\t}\n\n\t\tpublic SpaceCharFilter getFilter() {\n\t\t\treturn filter;\n\t\t}\n\n\t\tpublic void setFilter(SpaceCharFilter filter) {\n\t\t\tthis.filter = filter;\n\t\t}\n\n\t\tpublic interface SpaceCharFilter {\n\t\t\tpublic boolean isSpaceChar(int ch);\n\t\t}\n\t\tpublic int[] nextIntArray(int n){\n\t\t\tint[] array=new int[n];\n\t\t\tfor(int i=0;i e - 1);\n boolean[] c = new boolean[n];\n UnionFindTree t = new UnionFindTree(n);\n int g = n;\n int k = 0;\n int q = 0;\n for (int i = 0; i < n; i++) {\n if (p[i] >= 0) {\n if (t.isSame(i, p[i])) {\n c[t.root(i)] = true;\n k++;\n } else {\n boolean cb = c[t.root(i)] | c[t.root(p[i])];\n t.unite(i, p[i]);\n c[t.root(i)] = cb;\n g--;\n }\n } else {\n q++;\n }\n }\n long ans = ma.mul(k, ma.pow(n - 1, q));\n int m = g - k;\n if (m == 0) {\n out.append(ma.sub(ma.mul(n, ma.pow(n - 1, q)), ma.mod(ans)));\n return;\n }\n int[] a = new int[n];\n for (int i = 0, idx = 0; i < n; i++) if (t.isRoot(i) && !c[i]) a[idx++] = t.size(i);\n long[][] dp = new long[m][m + 1];\n dp[0][1] = a[0];\n for (int i = 1; i < m; i++) {\n for (int j = 1; j <= m; j++) {\n dp[i][j] = dp[i - 1][j];\n if (j == 1) {\n dp[i][j] += a[i];\n } else {\n dp[i][j] += ma.prod(dp[i - 1][j - 1], j - 1, a[i]);\n }\n if (dp[i][j] >= ma.MOD) dp[i][j] -= ma.MOD;\n }\n }\n for (int j = 2; j <= m; j++) ans += ma.mul(dp[m - 1][j], ma.pow(n - 1, m - j));\n ans += ma.mul(dp[m - 1][1] - q, ma.pow(n - 1, m - 1));\n out.append(ma.sub(ma.mul(n, ma.pow(n - 1, q)), ma.mod(ans)));\n }\n}\n\n\n\nclass LongSemiRing extends LongExtendedMagma {\n public LongSemiRing(final LongMonoid addition, final LongMonoid multiplication) {\n super(addition, multiplication, TypicalPropertySets.SEMI_RING);\n addition.requireProperties(EnumSet.of(Property.COMMUTATIVE));\n }\n public static LongSemiRing of(LongExtendedMagma m) {\n if (!m.additiveProps.containsAll(TypicalPropertySets.COMMUTATIVE_MONOID.getProperties())) {\n throw new ClassCastException(\"addition does not meet the conditions of commutative monoid.\");\n }\n LongCommutativeMonoid add = new LongCommutativeMonoid(m::add, m.e0);\n LongMonoid mul = new LongMonoid(m::mul, m.e1);\n return new LongSemiRing(add, mul);\n }\n}\n\n\n\nclass LongMonoid extends LongMagma implements LongUnital {\n public final long e;\n public LongMonoid(final LongBinaryOperator operator, final long e) {\n super(operator, TypicalPropertySets.MONOID);\n this.e = e;\n }\n @Override\n public long identityElement() {return e;}\n public static LongMonoid of(M m) {\n m.requireProperties(TypicalPropertySets.MONOID);\n return new LongMonoid(m.operator, m.identityElement());\n }\n}\n\n\n\n/**\n * @author https://atcoder.jp/users/suisen\n */\nfinal class ModuloArithmetic extends LongField {\n public final long MOD;\n public final LongAbelianGroup addition;\n public final LongAbelianGroup multiplication;\n /**\n * support modulo p arithmetic\n * @param p p s.t. p is a prime number.\n */\n public ModuloArithmetic(final long p) {\n super(\n new LongAbelianGroup((u, v) -> add(u, v, p), 0l, x -> -x),\n new LongAbelianGroup((u, v) -> mul(u, v, p), 1l, x -> inv(x, p)));\n this.addition = new LongAbelianGroup((u, v) -> add(u, v, p), 0l, x -> -x);\n this.multiplication = new LongAbelianGroup((u, v) -> mul(u, v, p), 1l, x -> inv(x, p));\n this.MOD = p;\n }\n /**\n * Calculate x s.t. 0 <= x < MOD /\\ x = a + b mod p.\n */\n private static long add(final long a, final long b, final long mod) {\n final long s = a + b; return s < 0 ? s + mod : s >= mod ? s - mod : s;\n }\n /**\n * Calculate x s.t. 0 <= x < MOD /\\ x = a * b mod p.\n */\n private static long mul(final long a, final long b, final long mod) {\n final long ret = (a * b) % mod; return ret < 0 ? ret + mod : ret;\n }\n /**\n * Calculate the value b s.t. a*b mod MOD = 1.\n */\n private static long inv(long a, final long mod) {\n long b = mod;\n long u = 1, v = 0;\n while (b >= 1) {\n final long t = a / b;\n a -= t * b;\n final long tmp1 = a; a = b; b = tmp1;\n u -= t * v;\n final long tmp2 = u; u = v; v = tmp2;\n }\n u %= mod;\n return u < 0 ? u + mod : u;\n }\n /**\n * Calculate x s.t. 0 <= x < MOD /\\ x = a mod p.\n */\n public long mod(long a) {a %= MOD; return a < 0 ? a + MOD : a;}\n /**\n * Calculate x s.t. 0 <= x < MOD /\\ x = a_1 + 1_2 + ... + a_k mod p.\n */\n public long sum(final long... a) {\n long ret = 0; for (final long c : a) ret += c;\n return mod(ret);\n }\n /**\n * Calculate x s.t. 0 <= x < MOD /\\ x = a - b mod p.\n */\n public long sub(final long a, final long b) {\n final long s = a - b; return s < 0 ? s + MOD : s >= MOD ? s - MOD : s;\n }\n /**\n * Calculate x s.t. 0 <= x < MOD /\\ x = a_1 * 1_2 * ... * a_k mod p.\n */\n public long prod(final long... a) {\n long ret = 1; for (final long c : a) ret = (ret * c) % MOD;\n return ret < 0 ? ret + MOD : ret;\n }\n /**\n * Calculate x s.t. 0 <= x < MOD /\\ b * x = a mod p.\n */\n public long div(final long a, final long b) {return mul(a, inv(b));}\n /**\n * Calculate the value b s.t. a*b mod MOD = 1.\n */\n public long inv(long a) {\n long b = MOD;\n long u = 1, v = 0;\n while (b >= 1) {\n final long t = a / b;\n a -= t * b;\n final long tmp1 = a; a = b; b = tmp1;\n u -= t * v;\n final long tmp2 = u; u = v; v = tmp2;\n }\n return mod(u);\n }\n /**\n * Calculate the permutation nPr.\n */\n public long perm(final long n, final long r) {\n if (n < r) return 0;\n long ret = 1; for (long i = n; i > n - r; i--) ret = mul(ret, i);\n return ret;\n }\n public long perm(final int n, final int r, final long[] fact, final long[] ifact) {\n if (n < r) return 0;\n return mul(fact[n], ifact[n - r]);\n }\n /**\n * Calculate the combination nCr.\n */\n public long comb(long n, long r) {\n if (n < r) return 0;\n r = Math.min(r, n - r);\n n %= MOD;\n long res = 1; for (long d = 1; d <= r; d++) res = div(mul(res, n--), d);\n return res;\n }\n public long comb(final int n, final int r, final long[] fact, final long[] ifact) {\n if (n < r) return 0;\n return prod(fact[n], ifact[n - r], ifact[r]);\n }\n /**\n * Calculate a^b (mod {@code MOD}) in O(log b) time.\n */\n public long pow(final long a, final long b) {\n if (b == 0 || a == 1) return 1;\n final long half = pow(a, b >> 1);\n return (b & 1) == 0 ? mul(half, half) : prod(half, half, a);\n }\n /**\n * calculate x := log_a b mod MOD. (i.e. a^x = b mod MOD). if not exists, return\n * negative value.\n */\n public long log(final long a, final long b) {return log(a, b, getMapForLogarithm(a));}\n public long log(long a, long b, final HashMap aMap) {\n a %= MOD; b %= MOD;\n final long sq = (long) (Math.sqrt(MOD) + 2);\n final long inv = pow(inv(a), sq);\n for (long p = 0, r = b; p <= sq; p++) {\n if (aMap.containsKey(r)) {\n final long res = p * sq + aMap.get(r);\n if (res > 0) return res;\n }\n r = mul(r, inv);\n }\n return -1;\n }\n public HashMap getMapForLogarithm(long a) {\n a %= MOD;\n final long sq = (long) (Math.sqrt(MOD) + 2);\n final HashMap map = new HashMap<>();\n for (long i = 0, ar = 1; i < sq; i++) {\n map.putIfAbsent(ar, i);\n ar = mul(ar, a);\n }\n return map;\n }\n /**\n * build factorial array from 0 to n (closed)\n */\n public long[] factorialArray(final int n) {\n final long[] fact = new long[n + 1];\n fact[0] = fact[1] = 1;\n for (int i = 1; i <= n; i++) fact[i] = mul(fact[i - 1], i);\n return fact;\n }\n public long[] inversiveFactrialArray(final long[] fact) {\n int n = fact.length - 1;\n final long[] ifact = new long[n + 1];\n ifact[n] = inv(fact[n]);\n for (int i = n - 1; i >= 0; i--) ifact[i] = mul(ifact[i + 1], i + 1);\n return ifact;\n }\n /**\n * build power array based on a from 0 to n (closed)\n * @param a base of power\n * @param n\n */\n public long[] powerArray(final long a, final int n) {\n if (a == 2) return powerArray(n);\n final long[] pow = new long[n + 1];\n pow[0] = 1; for (int i = 0; i <= n; i++) pow[i] = mul(pow[i - 1], a);\n return pow;\n }\n /**\n * build power array based on 2 from 0 to n (closed)\n * @param n\n */\n public long[] powerArray(final int n) {\n final long[] pow = new long[n + 1];\n pow[0] = 1;\n for (int i = 1; i <= n; i++) {\n pow[i] = pow[i - 1] << 1;\n if (pow[i] >= MOD) pow[i] -= MOD;\n }\n return pow;\n }\n}\n\n\n\nabstract class LongMagma extends PropertyHolder {\n protected final LongBinaryOperator operator;\n public LongMagma(final LongBinaryOperator operator, final EnumSet properties) {\n super(properties);\n this.operator = operator;\n }\n public LongMagma(final LongBinaryOperator operator, final TypicalPropertySets properties) {\n super(properties);\n this.operator = operator;\n }\n public final long apply(final long left, final long right) {return operator.applyAsLong(left, right);}\n}\n\n\n\nabstract class LongExtendedMagma extends PropertyHolder {\n public final long e0, e1;\n private final LongBinaryOperator addition, multiplication;\n protected final EnumSet additiveProps, multiplicativeProps;\n public LongExtendedMagma(LongMonoid addition, LongMonoid multiplication, EnumSet properties) {\n super(properties);\n this.addition = addition.operator;\n this.multiplication = multiplication.operator;\n this.e0 = addition.identityElement();\n this.e1 = multiplication.identityElement();\n this.additiveProps = addition.getProperties();\n this.multiplicativeProps = multiplication.getProperties();\n }\n public LongExtendedMagma(LongMonoid addition, LongMonoid multiplication, TypicalPropertySets properties) {\n this(addition, multiplication, properties.getProperties());\n }\n public final long add(long t, long u) {return addition.applyAsLong(t, u);}\n public final long mul(long t, long u) {return multiplication.applyAsLong(t, u);}\n}\n\n\n\nclass LongField extends LongRing {\n public LongField(final LongAbelianGroup addition, final LongMonoid multiplication) {\n super(addition, multiplication);\n multiplication.requireProperties(EnumSet.of(Property.COMMUTATIVE));\n }\n}\n\n\n\nclass LongCommutativeMonoid extends LongMonoid {\n public LongCommutativeMonoid(final LongBinaryOperator operator, final long e) {\n super(operator, e);\n addProperties(Property.COMMUTATIVE);\n }\n public static LongCommutativeMonoid of(M m) {\n m.requireProperties(TypicalPropertySets.COMMUTATIVE_MONOID.getProperties());\n return new LongCommutativeMonoid(m.operator, m.identityElement());\n }\n}\n\n\nclass LongRing extends LongSemiRing {\n private final LongUnaryOperator additiveInverse;\n public LongRing(final LongAbelianGroup addition, final LongMonoid multiplication) {\n super(addition, multiplication);\n this.additiveInverse = addition::inverse;\n }\n public final long additiveInverse(final long t) {return additiveInverse.applyAsLong(t);}\n}\n\n\n/**\n * @author https://atcoder.jp/users/suisen\n */\nfinal class In {\n public static final FastScanner fsc = new FastScanner();\n public static int ni() {return fsc.nextInt();}\n public static int[] ni(final int n) {\n final int[] a = new int[n];\n for (int i = 0; i < n; i++) a[i] = fsc.nextInt();\n return a;\n }\n public static int[] ni(final int n, final IntUnaryOperator f) {\n final int[] a = new int[n];\n for (int i = 0; i < n; i++) a[i] = f.applyAsInt(fsc.nextInt());\n return a;\n }\n public static int[][] ni(final int n, final int m) {\n final int[][] a = new int[n][m];\n for (int i = 0; i < n; i++) a[i] = ni(m);\n return a;\n }\n public static int[][] ni(final int n, final int m, final IntUnaryOperator f) {\n final int[][] a = new int[n][m];\n for (int i = 0; i < n; i++) a[i] = ni(m, f);\n return a;\n }\n public static long nl() {return fsc.nextLong();}\n public static long[] nl(final int n) {\n final long[] a = new long[n];\n for (int i = 0; i < n; i++) a[i] = fsc.nextLong();\n return a;\n }\n public static long[] nl(final int n, final LongUnaryOperator f) {\n final long[] a = new long[n];\n for (int i = 0; i < n; i++) a[i] = f.applyAsLong(fsc.nextLong());\n return a;\n }\n public static long[][] nl(final int n, final int m) {\n final long[][] a = new long[n][m];\n for (int i = 0; i < n; i++) a[i] = nl(m);\n return a;\n }\n public static long[][] nl(final int n, final int m, final LongUnaryOperator f) {\n final long[][] a = new long[n][m];\n for (int i = 0; i < n; i++) a[i] = nl(m, f);\n return a;\n }\n public static char[] nc() {return fsc.next().toCharArray();}\n public static char[][] nc(final int n) {\n final char[][] c = new char[n][];\n for (int i = 0; i < n; i++) c[i] = nc();\n return c;\n }\n public static double nd() {return fsc.nextDouble();}\n public static double[] nd(final int n) {\n final double[] a = new double[n];\n for (int i = 0; i < n; i++) a[i] = fsc.nextDouble();\n return a;\n }\n public static double[][] nd(final int n, final int m) {\n final double[][] a = new double[n][m];\n for (int i = 0; i < n; i++) a[i] = nd(m);\n return a;\n }\n public static String ns() {return fsc.next();}\n public static String[] ns(final int n) {\n final String[] s = new String[n];\n for (int i = 0; i < n; i++) s[i] = fsc.next();\n return s;\n }\n public static boolean[][] grid(final int h, final int w, final char trueCharacter) {\n final boolean[][] grid = new boolean[h][w];\n for (int i = 0; i < h; i++) {\n final char[] s = fsc.next().toCharArray();\n for (int j = 0; j < w; j++) grid[i][j] = s[j] == trueCharacter;\n }\n return grid;\n }\n}\n\n\nfinal class FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte() {\n if (ptr < buflen) return true;\n ptr = 0;\n try {buflen = in.read(buffer);}\n catch (final IOException e) {e.printStackTrace();}\n return buflen > 0;\n }\n private int readByte() {return hasNextByte() ? buffer[ptr++] : -1;}\n public boolean hasNext() {\n while (hasNextByte() && !(33 <= buffer[ptr] && buffer[ptr] <= 126)) ptr++;\n return hasNextByte();\n }\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n final StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (33 <= b && b <= 126) {sb.appendCodePoint(b); b = readByte();}\n return sb.toString();\n }\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {minus = true; b = readByte();}\n if (b < '0' || '9' < b) throw new NumberFormatException();\n for (; ; b = readByte()) {\n if ('0' <= b && b <= '9') n = n * 10 + b - '0';\n else if (b == -1 || !(33 <= b && b <= 126)) return minus ? -n : n;\n else throw new NumberFormatException();\n }\n }\n public int nextInt() {return Math.toIntExact(nextLong());}\n public double nextDouble() {return Double.parseDouble(next());}\n}\n\n\n/**\n * @author https://atcoder.jp/users/suisen\n */\nfinal class UnionFindTree {\n private final int[] data;\n public UnionFindTree(final int n) {this.data = new int[n]; Arrays.fill(data, -1);}\n public int root(final int x) {return data[x] < 0 ? x : (data[x] = root(data[x]));}\n public boolean isSame(final int x, final int y) {return root(x) == root(y);}\n public boolean unite(int x, int y) {\n x = root(x); y = root(y);\n if (x == y) return false;\n if (data[x] > data[y]) {int tmp = x; x = y; y = tmp;}\n data[x] += data[y];\n data[y] = x;\n return true;\n }\n public int size(final int x) {return -data[root(x)];}\n public boolean isRoot(final int x) {return data[x] < 0;}\n}\n\nenum Property {ANNIHILATED_BY_ZERO, ASSOCIATIVE, CANCELLATIVE, COMMUTATIVE, DISTRIBUTIVE, IDEMPOTENT;}\n\n\nenum TypicalPropertySets {\n ABELIAN_GROUP(EnumSet.of(Property.ASSOCIATIVE, Property.CANCELLATIVE, Property.COMMUTATIVE)),\n BOUNDED_SEMI_LATTICE(EnumSet.of(Property.ASSOCIATIVE, Property.COMMUTATIVE, Property.IDEMPOTENT)),\n COMMUTATIVE_MONOID(EnumSet.of(Property.ASSOCIATIVE, Property.COMMUTATIVE)),\n GROUP(EnumSet.of(Property.ASSOCIATIVE, Property.CANCELLATIVE)),\n MONOID(EnumSet.of(Property.ASSOCIATIVE)),\n SEMI_GROUP(EnumSet.of(Property.ASSOCIATIVE)),\n SEMI_LATTICE(EnumSet.of(Property.ASSOCIATIVE, Property.IDEMPOTENT, Property.COMMUTATIVE)),\n SEMI_RING(EnumSet.of(Property.DISTRIBUTIVE, Property.ANNIHILATED_BY_ZERO)),\n RING(EnumSet.of(Property.DISTRIBUTIVE, Property.ANNIHILATED_BY_ZERO));\n private final EnumSet properties;\n private TypicalPropertySets(EnumSet properties) {this.properties = properties;}\n public final EnumSet getProperties() {return properties.clone();}\n}\n\ninterface LongInversible {long inverse(long t);}\n\n/**\n * @author https://atcoder.jp/users/suisen\n */\nclass Const {\n public static final long MOD7 = 1_000_000_007;\n public static final long MOD9 = 1_000_000_009;\n public static final long MOD99 = 998_244_353;\n\n public static final long LINF = Long.MAX_VALUE >> 2;\n public static final int IINF = Integer.MAX_VALUE >> 1;\n public static final double DINF = 1e150;\n\n public static final double SDELTA = 1e-12;\n public static final double DELTA = 1e-9;\n public static final double LDELTA = 1e-6;\n\n public static final int[] dx8 = {1, 0, -1, 0, 1, -1, -1, 1};\n public static final int[] dy8 = {0, 1, 0, -1, 1, 1, -1, -1};\n public static final int[] dx4 = {1, 0, -1, 0};\n public static final int[] dy4 = {0, 1, 0, -1};\n\n private Const(){}\n}\n\n\n\nclass LongAbelianGroup extends LongGroup {\n public LongAbelianGroup(final LongBinaryOperator operator, final long e, final LongUnaryOperator inverse) {\n super(operator, e, inverse);\n addProperties(Property.COMMUTATIVE);\n }\n}\n\ninterface LongUnital {long identityElement();}\n\n\n\nclass LongGroup extends LongMonoid implements LongInversible {\n private final LongUnaryOperator inverse;\n public LongGroup(final LongBinaryOperator operator, final long e, final LongUnaryOperator inverse) {\n super(operator, e);\n addProperties(Property.CANCELLATIVE);\n this.inverse = inverse;\n }\n @Override\n public long inverse(final long t) {return inverse.applyAsLong(t);}\n}\n\n\nabstract class PropertyHolder {\n private final EnumSet properties;\n public PropertyHolder(final EnumSet properties) {this.properties = properties;}\n public PropertyHolder(final TypicalPropertySets typicalSet) {this(typicalSet.getProperties());}\n public final EnumSet getProperties() {return properties;}\n public final void addProperties(final Property... props) {for (Property prop : props) properties.add(prop);}\n public final void addProperties(final EnumSet props) {for (Property prop : props) properties.add(prop);}\n public final void addProperties(final TypicalPropertySets props) {addProperties(props.getProperties());}\n public final boolean hasProperties(final Property... props) {\n for (final Property prop : props) if (!properties.contains(prop)) return false;\n return true;\n }\n public final boolean hasProperties(final EnumSet props) {\n for (final Property prop : props) if (!properties.contains(prop)) return false;\n return true;\n }\n public final boolean hasProperties(final TypicalPropertySets props) {return hasProperties(props.getProperties());}\n public final void requireProperties(final EnumSet props, final Property... ps) {\n final ArrayList unmet = new ArrayList<>();\n for (final Property prop : props) if (!properties.contains(prop)) unmet.add(prop);\n for (final Property prop : ps) if (!properties.contains(prop)) unmet.add(prop);\n if (unmet.size() > 0) throw new UnsatisfiedRequiredPropertiesException(unmet);\n }\n public final void requireProperties(final TypicalPropertySets props, final Property... ps) {\n requireProperties(props.getProperties(), ps);\n }\n private static final class UnsatisfiedRequiredPropertiesException extends RuntimeException {\n private static final long serialVersionUID = 1L;\n private UnsatisfiedRequiredPropertiesException(final Collection props) {\n for (final Property prop : props) System.err.println(prop.name() + \"should be satisfied.\");\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1590901632, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02666.html", "problem_id": "p02666", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02666/input.txt", "sample_output_relpath": "derived/input_output/data/p02666/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02666/Java/s558028163.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s558028163", "user_id": "u541055501"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.EnumSet;\nimport java.util.HashMap;\nimport java.util.NoSuchElementException;\nimport java.util.function.IntUnaryOperator;\nimport java.util.function.LongBinaryOperator;\nimport java.util.function.LongUnaryOperator;\n\n\npublic class Main {\n public static void main(String[] args) throws Exception {\n StringBuilder out = new StringBuilder();\n solve(out);\n PrintWriter pw = new PrintWriter(System.out);\n pw.println(out);\n pw.flush();\n pw.close();\n }\n\n public static void solve(StringBuilder out) {\n ModuloArithmetic ma = new ModuloArithmetic(Const.MOD7);\n int n = In.ni();\n int[] p = In.ni(n, e -> e - 1);\n boolean[] c = new boolean[n];\n UnionFindTree t = new UnionFindTree(n);\n int g = n;\n int k = 0;\n int q = 0;\n for (int i = 0; i < n; i++) {\n if (p[i] >= 0) {\n if (t.isSame(i, p[i])) {\n c[t.root(i)] = true;\n k++;\n } else {\n boolean cb = c[t.root(i)] | c[t.root(p[i])];\n t.unite(i, p[i]);\n c[t.root(i)] = cb;\n g--;\n }\n } else {\n q++;\n }\n }\n long ans = ma.mul(k, ma.pow(n - 1, q));\n int m = g - k;\n if (m == 0) {\n out.append(ma.sub(ma.mul(n, ma.pow(n - 1, q)), ma.mod(ans)));\n return;\n }\n int[] a = new int[n];\n for (int i = 0, idx = 0; i < n; i++) if (t.isRoot(i) && !c[i]) a[idx++] = t.size(i);\n long[][] dp = new long[m][m + 1];\n dp[0][1] = a[0];\n for (int i = 1; i < m; i++) {\n for (int j = 1; j <= m; j++) {\n dp[i][j] = dp[i - 1][j];\n if (j == 1) {\n dp[i][j] += a[i];\n } else {\n dp[i][j] += ma.prod(dp[i - 1][j - 1], j - 1, a[i]);\n }\n if (dp[i][j] >= ma.MOD) dp[i][j] -= ma.MOD;\n }\n }\n for (int j = 2; j <= m; j++) ans += ma.mul(dp[m - 1][j], ma.pow(n - 1, m - j));\n ans += ma.mul(dp[m - 1][1] - q, ma.pow(n - 1, m - 1));\n out.append(ma.sub(ma.mul(n, ma.pow(n - 1, q)), ma.mod(ans)));\n }\n}\n\n\n\nclass LongSemiRing extends LongExtendedMagma {\n public LongSemiRing(final LongMonoid addition, final LongMonoid multiplication) {\n super(addition, multiplication, TypicalPropertySets.SEMI_RING);\n addition.requireProperties(EnumSet.of(Property.COMMUTATIVE));\n }\n public static LongSemiRing of(LongExtendedMagma m) {\n if (!m.additiveProps.containsAll(TypicalPropertySets.COMMUTATIVE_MONOID.getProperties())) {\n throw new ClassCastException(\"addition does not meet the conditions of commutative monoid.\");\n }\n LongCommutativeMonoid add = new LongCommutativeMonoid(m::add, m.e0);\n LongMonoid mul = new LongMonoid(m::mul, m.e1);\n return new LongSemiRing(add, mul);\n }\n}\n\n\n\nclass LongMonoid extends LongMagma implements LongUnital {\n public final long e;\n public LongMonoid(final LongBinaryOperator operator, final long e) {\n super(operator, TypicalPropertySets.MONOID);\n this.e = e;\n }\n @Override\n public long identityElement() {return e;}\n public static LongMonoid of(M m) {\n m.requireProperties(TypicalPropertySets.MONOID);\n return new LongMonoid(m.operator, m.identityElement());\n }\n}\n\n\n\n/**\n * @author https://atcoder.jp/users/suisen\n */\nfinal class ModuloArithmetic extends LongField {\n public final long MOD;\n public final LongAbelianGroup addition;\n public final LongAbelianGroup multiplication;\n /**\n * support modulo p arithmetic\n * @param p p s.t. p is a prime number.\n */\n public ModuloArithmetic(final long p) {\n super(\n new LongAbelianGroup((u, v) -> add(u, v, p), 0l, x -> -x),\n new LongAbelianGroup((u, v) -> mul(u, v, p), 1l, x -> inv(x, p)));\n this.addition = new LongAbelianGroup((u, v) -> add(u, v, p), 0l, x -> -x);\n this.multiplication = new LongAbelianGroup((u, v) -> mul(u, v, p), 1l, x -> inv(x, p));\n this.MOD = p;\n }\n /**\n * Calculate x s.t. 0 <= x < MOD /\\ x = a + b mod p.\n */\n private static long add(final long a, final long b, final long mod) {\n final long s = a + b; return s < 0 ? s + mod : s >= mod ? s - mod : s;\n }\n /**\n * Calculate x s.t. 0 <= x < MOD /\\ x = a * b mod p.\n */\n private static long mul(final long a, final long b, final long mod) {\n final long ret = (a * b) % mod; return ret < 0 ? ret + mod : ret;\n }\n /**\n * Calculate the value b s.t. a*b mod MOD = 1.\n */\n private static long inv(long a, final long mod) {\n long b = mod;\n long u = 1, v = 0;\n while (b >= 1) {\n final long t = a / b;\n a -= t * b;\n final long tmp1 = a; a = b; b = tmp1;\n u -= t * v;\n final long tmp2 = u; u = v; v = tmp2;\n }\n u %= mod;\n return u < 0 ? u + mod : u;\n }\n /**\n * Calculate x s.t. 0 <= x < MOD /\\ x = a mod p.\n */\n public long mod(long a) {a %= MOD; return a < 0 ? a + MOD : a;}\n /**\n * Calculate x s.t. 0 <= x < MOD /\\ x = a_1 + 1_2 + ... + a_k mod p.\n */\n public long sum(final long... a) {\n long ret = 0; for (final long c : a) ret += c;\n return mod(ret);\n }\n /**\n * Calculate x s.t. 0 <= x < MOD /\\ x = a - b mod p.\n */\n public long sub(final long a, final long b) {\n final long s = a - b; return s < 0 ? s + MOD : s >= MOD ? s - MOD : s;\n }\n /**\n * Calculate x s.t. 0 <= x < MOD /\\ x = a_1 * 1_2 * ... * a_k mod p.\n */\n public long prod(final long... a) {\n long ret = 1; for (final long c : a) ret = (ret * c) % MOD;\n return ret < 0 ? ret + MOD : ret;\n }\n /**\n * Calculate x s.t. 0 <= x < MOD /\\ b * x = a mod p.\n */\n public long div(final long a, final long b) {return mul(a, inv(b));}\n /**\n * Calculate the value b s.t. a*b mod MOD = 1.\n */\n public long inv(long a) {\n long b = MOD;\n long u = 1, v = 0;\n while (b >= 1) {\n final long t = a / b;\n a -= t * b;\n final long tmp1 = a; a = b; b = tmp1;\n u -= t * v;\n final long tmp2 = u; u = v; v = tmp2;\n }\n return mod(u);\n }\n /**\n * Calculate the permutation nPr.\n */\n public long perm(final long n, final long r) {\n if (n < r) return 0;\n long ret = 1; for (long i = n; i > n - r; i--) ret = mul(ret, i);\n return ret;\n }\n public long perm(final int n, final int r, final long[] fact, final long[] ifact) {\n if (n < r) return 0;\n return mul(fact[n], ifact[n - r]);\n }\n /**\n * Calculate the combination nCr.\n */\n public long comb(long n, long r) {\n if (n < r) return 0;\n r = Math.min(r, n - r);\n n %= MOD;\n long res = 1; for (long d = 1; d <= r; d++) res = div(mul(res, n--), d);\n return res;\n }\n public long comb(final int n, final int r, final long[] fact, final long[] ifact) {\n if (n < r) return 0;\n return prod(fact[n], ifact[n - r], ifact[r]);\n }\n /**\n * Calculate a^b (mod {@code MOD}) in O(log b) time.\n */\n public long pow(final long a, final long b) {\n if (b == 0 || a == 1) return 1;\n final long half = pow(a, b >> 1);\n return (b & 1) == 0 ? mul(half, half) : prod(half, half, a);\n }\n /**\n * calculate x := log_a b mod MOD. (i.e. a^x = b mod MOD). if not exists, return\n * negative value.\n */\n public long log(final long a, final long b) {return log(a, b, getMapForLogarithm(a));}\n public long log(long a, long b, final HashMap aMap) {\n a %= MOD; b %= MOD;\n final long sq = (long) (Math.sqrt(MOD) + 2);\n final long inv = pow(inv(a), sq);\n for (long p = 0, r = b; p <= sq; p++) {\n if (aMap.containsKey(r)) {\n final long res = p * sq + aMap.get(r);\n if (res > 0) return res;\n }\n r = mul(r, inv);\n }\n return -1;\n }\n public HashMap getMapForLogarithm(long a) {\n a %= MOD;\n final long sq = (long) (Math.sqrt(MOD) + 2);\n final HashMap map = new HashMap<>();\n for (long i = 0, ar = 1; i < sq; i++) {\n map.putIfAbsent(ar, i);\n ar = mul(ar, a);\n }\n return map;\n }\n /**\n * build factorial array from 0 to n (closed)\n */\n public long[] factorialArray(final int n) {\n final long[] fact = new long[n + 1];\n fact[0] = fact[1] = 1;\n for (int i = 1; i <= n; i++) fact[i] = mul(fact[i - 1], i);\n return fact;\n }\n public long[] inversiveFactrialArray(final long[] fact) {\n int n = fact.length - 1;\n final long[] ifact = new long[n + 1];\n ifact[n] = inv(fact[n]);\n for (int i = n - 1; i >= 0; i--) ifact[i] = mul(ifact[i + 1], i + 1);\n return ifact;\n }\n /**\n * build power array based on a from 0 to n (closed)\n * @param a base of power\n * @param n\n */\n public long[] powerArray(final long a, final int n) {\n if (a == 2) return powerArray(n);\n final long[] pow = new long[n + 1];\n pow[0] = 1; for (int i = 0; i <= n; i++) pow[i] = mul(pow[i - 1], a);\n return pow;\n }\n /**\n * build power array based on 2 from 0 to n (closed)\n * @param n\n */\n public long[] powerArray(final int n) {\n final long[] pow = new long[n + 1];\n pow[0] = 1;\n for (int i = 1; i <= n; i++) {\n pow[i] = pow[i - 1] << 1;\n if (pow[i] >= MOD) pow[i] -= MOD;\n }\n return pow;\n }\n}\n\n\n\nabstract class LongMagma extends PropertyHolder {\n protected final LongBinaryOperator operator;\n public LongMagma(final LongBinaryOperator operator, final EnumSet properties) {\n super(properties);\n this.operator = operator;\n }\n public LongMagma(final LongBinaryOperator operator, final TypicalPropertySets properties) {\n super(properties);\n this.operator = operator;\n }\n public final long apply(final long left, final long right) {return operator.applyAsLong(left, right);}\n}\n\n\n\nabstract class LongExtendedMagma extends PropertyHolder {\n public final long e0, e1;\n private final LongBinaryOperator addition, multiplication;\n protected final EnumSet additiveProps, multiplicativeProps;\n public LongExtendedMagma(LongMonoid addition, LongMonoid multiplication, EnumSet properties) {\n super(properties);\n this.addition = addition.operator;\n this.multiplication = multiplication.operator;\n this.e0 = addition.identityElement();\n this.e1 = multiplication.identityElement();\n this.additiveProps = addition.getProperties();\n this.multiplicativeProps = multiplication.getProperties();\n }\n public LongExtendedMagma(LongMonoid addition, LongMonoid multiplication, TypicalPropertySets properties) {\n this(addition, multiplication, properties.getProperties());\n }\n public final long add(long t, long u) {return addition.applyAsLong(t, u);}\n public final long mul(long t, long u) {return multiplication.applyAsLong(t, u);}\n}\n\n\n\nclass LongField extends LongRing {\n public LongField(final LongAbelianGroup addition, final LongMonoid multiplication) {\n super(addition, multiplication);\n multiplication.requireProperties(EnumSet.of(Property.COMMUTATIVE));\n }\n}\n\n\n\nclass LongCommutativeMonoid extends LongMonoid {\n public LongCommutativeMonoid(final LongBinaryOperator operator, final long e) {\n super(operator, e);\n addProperties(Property.COMMUTATIVE);\n }\n public static LongCommutativeMonoid of(M m) {\n m.requireProperties(TypicalPropertySets.COMMUTATIVE_MONOID.getProperties());\n return new LongCommutativeMonoid(m.operator, m.identityElement());\n }\n}\n\n\nclass LongRing extends LongSemiRing {\n private final LongUnaryOperator additiveInverse;\n public LongRing(final LongAbelianGroup addition, final LongMonoid multiplication) {\n super(addition, multiplication);\n this.additiveInverse = addition::inverse;\n }\n public final long additiveInverse(final long t) {return additiveInverse.applyAsLong(t);}\n}\n\n\n/**\n * @author https://atcoder.jp/users/suisen\n */\nfinal class In {\n public static final FastScanner fsc = new FastScanner();\n public static int ni() {return fsc.nextInt();}\n public static int[] ni(final int n) {\n final int[] a = new int[n];\n for (int i = 0; i < n; i++) a[i] = fsc.nextInt();\n return a;\n }\n public static int[] ni(final int n, final IntUnaryOperator f) {\n final int[] a = new int[n];\n for (int i = 0; i < n; i++) a[i] = f.applyAsInt(fsc.nextInt());\n return a;\n }\n public static int[][] ni(final int n, final int m) {\n final int[][] a = new int[n][m];\n for (int i = 0; i < n; i++) a[i] = ni(m);\n return a;\n }\n public static int[][] ni(final int n, final int m, final IntUnaryOperator f) {\n final int[][] a = new int[n][m];\n for (int i = 0; i < n; i++) a[i] = ni(m, f);\n return a;\n }\n public static long nl() {return fsc.nextLong();}\n public static long[] nl(final int n) {\n final long[] a = new long[n];\n for (int i = 0; i < n; i++) a[i] = fsc.nextLong();\n return a;\n }\n public static long[] nl(final int n, final LongUnaryOperator f) {\n final long[] a = new long[n];\n for (int i = 0; i < n; i++) a[i] = f.applyAsLong(fsc.nextLong());\n return a;\n }\n public static long[][] nl(final int n, final int m) {\n final long[][] a = new long[n][m];\n for (int i = 0; i < n; i++) a[i] = nl(m);\n return a;\n }\n public static long[][] nl(final int n, final int m, final LongUnaryOperator f) {\n final long[][] a = new long[n][m];\n for (int i = 0; i < n; i++) a[i] = nl(m, f);\n return a;\n }\n public static char[] nc() {return fsc.next().toCharArray();}\n public static char[][] nc(final int n) {\n final char[][] c = new char[n][];\n for (int i = 0; i < n; i++) c[i] = nc();\n return c;\n }\n public static double nd() {return fsc.nextDouble();}\n public static double[] nd(final int n) {\n final double[] a = new double[n];\n for (int i = 0; i < n; i++) a[i] = fsc.nextDouble();\n return a;\n }\n public static double[][] nd(final int n, final int m) {\n final double[][] a = new double[n][m];\n for (int i = 0; i < n; i++) a[i] = nd(m);\n return a;\n }\n public static String ns() {return fsc.next();}\n public static String[] ns(final int n) {\n final String[] s = new String[n];\n for (int i = 0; i < n; i++) s[i] = fsc.next();\n return s;\n }\n public static boolean[][] grid(final int h, final int w, final char trueCharacter) {\n final boolean[][] grid = new boolean[h][w];\n for (int i = 0; i < h; i++) {\n final char[] s = fsc.next().toCharArray();\n for (int j = 0; j < w; j++) grid[i][j] = s[j] == trueCharacter;\n }\n return grid;\n }\n}\n\n\nfinal class FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte() {\n if (ptr < buflen) return true;\n ptr = 0;\n try {buflen = in.read(buffer);}\n catch (final IOException e) {e.printStackTrace();}\n return buflen > 0;\n }\n private int readByte() {return hasNextByte() ? buffer[ptr++] : -1;}\n public boolean hasNext() {\n while (hasNextByte() && !(33 <= buffer[ptr] && buffer[ptr] <= 126)) ptr++;\n return hasNextByte();\n }\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n final StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (33 <= b && b <= 126) {sb.appendCodePoint(b); b = readByte();}\n return sb.toString();\n }\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {minus = true; b = readByte();}\n if (b < '0' || '9' < b) throw new NumberFormatException();\n for (; ; b = readByte()) {\n if ('0' <= b && b <= '9') n = n * 10 + b - '0';\n else if (b == -1 || !(33 <= b && b <= 126)) return minus ? -n : n;\n else throw new NumberFormatException();\n }\n }\n public int nextInt() {return Math.toIntExact(nextLong());}\n public double nextDouble() {return Double.parseDouble(next());}\n}\n\n\n/**\n * @author https://atcoder.jp/users/suisen\n */\nfinal class UnionFindTree {\n private final int[] data;\n public UnionFindTree(final int n) {this.data = new int[n]; Arrays.fill(data, -1);}\n public int root(final int x) {return data[x] < 0 ? x : (data[x] = root(data[x]));}\n public boolean isSame(final int x, final int y) {return root(x) == root(y);}\n public boolean unite(int x, int y) {\n x = root(x); y = root(y);\n if (x == y) return false;\n if (data[x] > data[y]) {int tmp = x; x = y; y = tmp;}\n data[x] += data[y];\n data[y] = x;\n return true;\n }\n public int size(final int x) {return -data[root(x)];}\n public boolean isRoot(final int x) {return data[x] < 0;}\n}\n\nenum Property {ANNIHILATED_BY_ZERO, ASSOCIATIVE, CANCELLATIVE, COMMUTATIVE, DISTRIBUTIVE, IDEMPOTENT;}\n\n\nenum TypicalPropertySets {\n ABELIAN_GROUP(EnumSet.of(Property.ASSOCIATIVE, Property.CANCELLATIVE, Property.COMMUTATIVE)),\n BOUNDED_SEMI_LATTICE(EnumSet.of(Property.ASSOCIATIVE, Property.COMMUTATIVE, Property.IDEMPOTENT)),\n COMMUTATIVE_MONOID(EnumSet.of(Property.ASSOCIATIVE, Property.COMMUTATIVE)),\n GROUP(EnumSet.of(Property.ASSOCIATIVE, Property.CANCELLATIVE)),\n MONOID(EnumSet.of(Property.ASSOCIATIVE)),\n SEMI_GROUP(EnumSet.of(Property.ASSOCIATIVE)),\n SEMI_LATTICE(EnumSet.of(Property.ASSOCIATIVE, Property.IDEMPOTENT, Property.COMMUTATIVE)),\n SEMI_RING(EnumSet.of(Property.DISTRIBUTIVE, Property.ANNIHILATED_BY_ZERO)),\n RING(EnumSet.of(Property.DISTRIBUTIVE, Property.ANNIHILATED_BY_ZERO));\n private final EnumSet properties;\n private TypicalPropertySets(EnumSet properties) {this.properties = properties;}\n public final EnumSet getProperties() {return properties.clone();}\n}\n\ninterface LongInversible {long inverse(long t);}\n\n/**\n * @author https://atcoder.jp/users/suisen\n */\nclass Const {\n public static final long MOD7 = 1_000_000_007;\n public static final long MOD9 = 1_000_000_009;\n public static final long MOD99 = 998_244_353;\n\n public static final long LINF = Long.MAX_VALUE >> 2;\n public static final int IINF = Integer.MAX_VALUE >> 1;\n public static final double DINF = 1e150;\n\n public static final double SDELTA = 1e-12;\n public static final double DELTA = 1e-9;\n public static final double LDELTA = 1e-6;\n\n public static final int[] dx8 = {1, 0, -1, 0, 1, -1, -1, 1};\n public static final int[] dy8 = {0, 1, 0, -1, 1, 1, -1, -1};\n public static final int[] dx4 = {1, 0, -1, 0};\n public static final int[] dy4 = {0, 1, 0, -1};\n\n private Const(){}\n}\n\n\n\nclass LongAbelianGroup extends LongGroup {\n public LongAbelianGroup(final LongBinaryOperator operator, final long e, final LongUnaryOperator inverse) {\n super(operator, e, inverse);\n addProperties(Property.COMMUTATIVE);\n }\n}\n\ninterface LongUnital {long identityElement();}\n\n\n\nclass LongGroup extends LongMonoid implements LongInversible {\n private final LongUnaryOperator inverse;\n public LongGroup(final LongBinaryOperator operator, final long e, final LongUnaryOperator inverse) {\n super(operator, e);\n addProperties(Property.CANCELLATIVE);\n this.inverse = inverse;\n }\n @Override\n public long inverse(final long t) {return inverse.applyAsLong(t);}\n}\n\n\nabstract class PropertyHolder {\n private final EnumSet properties;\n public PropertyHolder(final EnumSet properties) {this.properties = properties;}\n public PropertyHolder(final TypicalPropertySets typicalSet) {this(typicalSet.getProperties());}\n public final EnumSet getProperties() {return properties;}\n public final void addProperties(final Property... props) {for (Property prop : props) properties.add(prop);}\n public final void addProperties(final EnumSet props) {for (Property prop : props) properties.add(prop);}\n public final void addProperties(final TypicalPropertySets props) {addProperties(props.getProperties());}\n public final boolean hasProperties(final Property... props) {\n for (final Property prop : props) if (!properties.contains(prop)) return false;\n return true;\n }\n public final boolean hasProperties(final EnumSet props) {\n for (final Property prop : props) if (!properties.contains(prop)) return false;\n return true;\n }\n public final boolean hasProperties(final TypicalPropertySets props) {return hasProperties(props.getProperties());}\n public final void requireProperties(final EnumSet props, final Property... ps) {\n final ArrayList unmet = new ArrayList<>();\n for (final Property prop : props) if (!properties.contains(prop)) unmet.add(prop);\n for (final Property prop : ps) if (!properties.contains(prop)) unmet.add(prop);\n if (unmet.size() > 0) throw new UnsatisfiedRequiredPropertiesException(unmet);\n }\n public final void requireProperties(final TypicalPropertySets props, final Property... ps) {\n requireProperties(props.getProperties(), ps);\n }\n private static final class UnsatisfiedRequiredPropertiesException extends RuntimeException {\n private static final long serialVersionUID = 1L;\n private UnsatisfiedRequiredPropertiesException(final Collection props) {\n for (final Property prop : props) System.err.println(prop.name() + \"should be satisfied.\");\n }\n }\n}\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nThere are N towns numbered 1, 2, \\cdots, N.\n\nSome roads are planned to be built so that each of them connects two distinct towns bidirectionally. Currently, there are no roads connecting towns.\n\nIn the planning of construction, each town chooses one town different from itself and requests the following: roads are built so that the chosen town is reachable from itself using one or more roads.\n\nThese requests from the towns are represented by an array P_1, P_2, \\cdots, P_N. If P_i = -1, it means that Town i has not chosen the request; if 1 \\leq P_i \\leq N, it means that Town i has chosen Town P_i.\n\nLet K be the number of towns i such that P_i = -1. There are (N-1)^K ways in which the towns can make the requests. For each way to make requests, find the minimum number of roads needed to meet all the requests, and print the sum of those (N-1)^K numbers, modulo (10^9+7).\n\nConstraints\n\n2 \\leq N \\leq 5000\n\nP_i = -1 or 1 \\leq P_i \\leq N.\n\nP_i \\neq i\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 \\cdots P_N\n\nOutput\n\nFor each way to make requests, find the minimum number of roads needed to meet all the requests, and print the sum of those (N-1)^K numbers, modulo (10^9+7).\n\nSample Input 1\n\n4\n2 1 -1 3\n\nSample Output 1\n\n8\n\nThere are three ways to make requests, as follows:\n\nChoose P_1 = 2, P_2 = 1, P_3 = 1, P_4 = 3. In this case, at least three roads - for example, (1,2),(1,3),(3,4) - are needed to meet the requests.\n\nChoose P_1 = 2, P_2 = 1, P_3 = 2, P_4 = 3. In this case, at least three roads - for example, (1,2),(1,3),(3,4) - are needed to meet the requests.\n\nChoose P_1 = 2, P_2 = 1, P_3 = 4, P_4 = 3. In this case, at least two roads - for example, (1,2),(3,4) - are needed to meet the requests.\n\nNote that it is not mandatory to connect Town i and Town P_i directly.\n\nThe sum of the above numbers is 8.\n\nSample Input 2\n\n2\n2 1\n\nSample Output 2\n\n1\n\nThere may be just one fixed way to make requests.\n\nSample Input 3\n\n10\n2 6 9 -1 6 9 -1 -1 -1 -1\n\nSample Output 3\n\n527841", "sample_input": "4\n2 1 -1 3\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02666", "source_text": "Score : 700 points\n\nProblem Statement\n\nThere are N towns numbered 1, 2, \\cdots, N.\n\nSome roads are planned to be built so that each of them connects two distinct towns bidirectionally. Currently, there are no roads connecting towns.\n\nIn the planning of construction, each town chooses one town different from itself and requests the following: roads are built so that the chosen town is reachable from itself using one or more roads.\n\nThese requests from the towns are represented by an array P_1, P_2, \\cdots, P_N. If P_i = -1, it means that Town i has not chosen the request; if 1 \\leq P_i \\leq N, it means that Town i has chosen Town P_i.\n\nLet K be the number of towns i such that P_i = -1. There are (N-1)^K ways in which the towns can make the requests. For each way to make requests, find the minimum number of roads needed to meet all the requests, and print the sum of those (N-1)^K numbers, modulo (10^9+7).\n\nConstraints\n\n2 \\leq N \\leq 5000\n\nP_i = -1 or 1 \\leq P_i \\leq N.\n\nP_i \\neq i\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 \\cdots P_N\n\nOutput\n\nFor each way to make requests, find the minimum number of roads needed to meet all the requests, and print the sum of those (N-1)^K numbers, modulo (10^9+7).\n\nSample Input 1\n\n4\n2 1 -1 3\n\nSample Output 1\n\n8\n\nThere are three ways to make requests, as follows:\n\nChoose P_1 = 2, P_2 = 1, P_3 = 1, P_4 = 3. In this case, at least three roads - for example, (1,2),(1,3),(3,4) - are needed to meet the requests.\n\nChoose P_1 = 2, P_2 = 1, P_3 = 2, P_4 = 3. In this case, at least three roads - for example, (1,2),(1,3),(3,4) - are needed to meet the requests.\n\nChoose P_1 = 2, P_2 = 1, P_3 = 4, P_4 = 3. In this case, at least two roads - for example, (1,2),(3,4) - are needed to meet the requests.\n\nNote that it is not mandatory to connect Town i and Town P_i directly.\n\nThe sum of the above numbers is 8.\n\nSample Input 2\n\n2\n2 1\n\nSample Output 2\n\n1\n\nThere may be just one fixed way to make requests.\n\nSample Input 3\n\n10\n2 6 9 -1 6 9 -1 -1 -1 -1\n\nSample Output 3\n\n527841", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 22714, "cpu_time_ms": 1465, "memory_kb": 366000}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s251364796", "group_id": "codeNet:p02675", "input_text": "import java.util.Scanner;\n \npublic class Main{\n public static void Main(String[] args){\n Scanner stdIn=new Scanner(System.in);\n int N=stdIn.nextInt();\n int m=N%10;\n switch(m){\n case 0: System.out.println(\"hon\"); break;\n case 2: System.out.println(\"hon\"); break;\n case 4: System.out.println(\"hon\"); break;\n case 5: System.out.println(\"hon\"); break;\n case 7: System.out.println(\"hon\"); break;\n case 9: System.out.println(\"hon\"); break;\n case 1: System.out.println(\"pon\"); break;\n case 6: System.out.println(\"pon\"); break;\n case 8: System.out.println(\"pon\"); break;\n case 3: System.out.println(\"bon\"); break;\n }\n }\n}", "language": "Java", "metadata": {"date": 1589777249, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02675.html", "problem_id": "p02675", "resource_group": "high_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/Java/s251364796.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s251364796", "user_id": "u419040385"}, "prompt_components": {"gold_output": "pon\n", "input_to_evaluate": "import java.util.Scanner;\n \npublic class Main{\n public static void Main(String[] args){\n Scanner stdIn=new Scanner(System.in);\n int N=stdIn.nextInt();\n int m=N%10;\n switch(m){\n case 0: System.out.println(\"hon\"); break;\n case 2: System.out.println(\"hon\"); break;\n case 4: System.out.println(\"hon\"); break;\n case 5: System.out.println(\"hon\"); break;\n case 7: System.out.println(\"hon\"); break;\n case 9: System.out.println(\"hon\"); break;\n case 1: System.out.println(\"pon\"); break;\n case 6: System.out.println(\"pon\"); break;\n case 8: System.out.println(\"pon\"); break;\n case 3: System.out.println(\"bon\"); break;\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": 680, "cpu_time_ms": 86, "memory_kb": 35192}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s454477950", "group_id": "codeNet:p02677", "input_text": "import java.util.*;\nimport java.lang.*;\npublic class Main\n{\n\tpublic static void main(String[] args) {\n\t Scanner sc = new Scanner(System.in);\n\t double a = sc.nextInt();\n\t double b = sc.nextInt();\n\t double h = sc.nextInt();\n\t double m = sc.nextInt();\n\t if(h==0){\n\t h=12;\n\t }\n\t if(m==0){\n\t m=60;\n\t }\n\t m=m/5;\n\t double c=0;\n\t c= a*a + b*b - 2*a*b*Math.cos(Math.toRadians(Math.abs(h-m)*30));\n\t System.out.println(Math.sqrt(c));\n\t}\n}\n", "language": "Java", "metadata": {"date": 1589768646, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02677.html", "problem_id": "p02677", "resource_group": "high_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/Java/s454477950.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s454477950", "user_id": "u452351607"}, "prompt_components": {"gold_output": "5.00000000000000000000\n", "input_to_evaluate": "import java.util.*;\nimport java.lang.*;\npublic class Main\n{\n\tpublic static void main(String[] args) {\n\t Scanner sc = new Scanner(System.in);\n\t double a = sc.nextInt();\n\t double b = sc.nextInt();\n\t double h = sc.nextInt();\n\t double m = sc.nextInt();\n\t if(h==0){\n\t h=12;\n\t }\n\t if(m==0){\n\t m=60;\n\t }\n\t m=m/5;\n\t double c=0;\n\t c= a*a + b*b - 2*a*b*Math.cos(Math.toRadians(Math.abs(h-m)*30));\n\t System.out.println(Math.sqrt(c));\n\t}\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": 481, "cpu_time_ms": 118, "memory_kb": 36016}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s676301720", "group_id": "codeNet:p02677", "input_text": "import java.awt.*;\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.util.StringTokenizer;\n\npublic class Main {\n private static class FastScanner {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n\n public FastScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n tokenizer = null;\n }\n\n public String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n\n return tokenizer.nextToken(\"\\n\");\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n\n public int[] nextIntArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = nextInt();\n return a;\n }\n\n public long[] nextLongArray(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = nextLong();\n return a;\n }\n }\n\n public static void main(String[] args) {\n FastScanner sc = new FastScanner(System.in);\n double a = sc.nextDouble();\n double b = sc.nextDouble();\n int h = sc.nextInt();\n int m = sc.nextInt();\n double mTheta = 360.0 * ((double) m / 60.0);\n double hTheta = 360.0 * ((double) h / 12.0) + 30.0 * ((double) m / 60.0);\n double[] hp = new double[2];\n hp[0] = a * Math.cos(Math.toRadians(hTheta));\n hp[1] = a * Math.sin(Math.toRadians(hTheta));\n double[] mp = new double[2];\n mp[0] = b * Math.cos(Math.toRadians(mTheta));\n mp[1] = b * Math.sin(Math.toRadians(mTheta));\n double ans = Math.hypot(hp[0] - mp[0], hp[1] - mp[1]);\n System.out.println(ans);\n }\n}", "language": "Java", "metadata": {"date": 1589765724, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02677.html", "problem_id": "p02677", "resource_group": "high_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/Java/s676301720.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s676301720", "user_id": "u562002567"}, "prompt_components": {"gold_output": "5.00000000000000000000\n", "input_to_evaluate": "import java.awt.*;\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.util.StringTokenizer;\n\npublic class Main {\n private static class FastScanner {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n\n public FastScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n tokenizer = null;\n }\n\n public String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n\n return tokenizer.nextToken(\"\\n\");\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n\n public int[] nextIntArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = nextInt();\n return a;\n }\n\n public long[] nextLongArray(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = nextLong();\n return a;\n }\n }\n\n public static void main(String[] args) {\n FastScanner sc = new FastScanner(System.in);\n double a = sc.nextDouble();\n double b = sc.nextDouble();\n int h = sc.nextInt();\n int m = sc.nextInt();\n double mTheta = 360.0 * ((double) m / 60.0);\n double hTheta = 360.0 * ((double) h / 12.0) + 30.0 * ((double) m / 60.0);\n double[] hp = new double[2];\n hp[0] = a * Math.cos(Math.toRadians(hTheta));\n hp[1] = a * Math.sin(Math.toRadians(hTheta));\n double[] mp = new double[2];\n mp[0] = b * Math.cos(Math.toRadians(mTheta));\n mp[1] = b * Math.sin(Math.toRadians(mTheta));\n double ans = Math.hypot(hp[0] - mp[0], hp[1] - mp[1]);\n System.out.println(ans);\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": 2268, "cpu_time_ms": 71, "memory_kb": 33136}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s578317873", "group_id": "codeNet:p02677", "input_text": "import java.io.*;\nimport java.util.*;\n\nclass Main{\n final static long INF = Long.MAX_VALUE / 2;\n final static int MOD = 1_000_000_007;\n final static int SIZE = 1_000_000;\n long[] fac = new long[SIZE];\n long[] inv = new long[SIZE];\n long[] finv = new long[SIZE];\n FastScanner sc = new FastScanner();\n\n public static void main(String[] args) {\n new Main().solve();\n }\n\n void solve(){\n\n int a = sc.nextInt();\n int b = sc.nextInt();\n int h = sc.nextInt();\n int m = sc.nextInt();\n\n double a_d = Math.min(h * 30.0 + m / 60.0 * 30.0, 180.0 - (h * 30.0 + m / 60.0 * 30.0));\n double b_d = Math.min(m * 6.0, 180.0 - m * 6.0);\n double a_x = a * Math.sin(Math.toRadians(a_d));\n double a_y = a * Math.cos(Math.toRadians(a_d));\n double b_x = b * Math.sin(Math.toRadians(b_d));\n double b_y = b * Math.cos(Math.toRadians(b_d));\n\n System.out.println(String.format(\"%.15f\", Math.sqrt((a_x - b_x) * (a_x - b_x) + (a_y - b_y) * (a_y - b_y))));\n\n }\n\n long gcd(long a, long b){ // return aとbの最大公約数\n if(b == 0){\n return a;\n }\n return gcd(b, a % b);\n }\n\n long lcm(long a, long b){ // return aとbの最小公倍数\n return a * b / gcd(a, b);\n }\n\n long inv(long a){ // return aの逆元 (mod MOD)\n return pow(a, MOD - 2);\n }\n\n long pow(long a, long r){ // return a^r (mod MOD)\n long sum = 1;\n while(r > 0){\n if((r & 1) == 1){ // 2進数表記で末尾1の時\n sum *= a;\n sum %= MOD;\n }\n a *= a;\n a %= MOD;\n r >>= 1;\n }\n return sum;\n }\n\n long modFact(long n){ // retur n! (mod MOD)\n if(n == 0){\n return 1;\n }\n return n * modFact(n - 1) % MOD;\n }\n\n long fact(long n){ // return n!\n if(n == 0){\n return 1;\n }\n return n * fact(n - 1);\n }\n\n void initCOMB(){\n fac[0] = fac[1] = 1;\n inv[1] = 1;\n finv[0] = finv[1] = 1;\n for(int i = 2; i < SIZE; i++){\n fac[i] = fac[i - 1] * i % MOD;\n inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;\n finv[i] = finv[i - 1] * inv[i] % MOD;\n }\n }\n\n long modComb(int n, int r){ // return nCr (先にinitCOMB()必要)\n if(n < r || n < 0 || r < 0) return 0;\n return fac[n] * finv[r] % MOD * finv[n - r] % MOD;\n }\n\n long comb(long n, long r){ // return nCr\n long num = 1;\n for(long i = 1; i <= r; i++){\n num = num * (n - i + 1) / i;\n }\n return num;\n }\n\n boolean isPrime(long a){ // aの素数判定\n if(a <= 1) return false;\n for(int i = 2; i * i <= a; i++){\n if(a % i == 0) return false;\n }\n return true;\n }\n\n int lowerBound(long[] a, long v){ // return 配列a内のv以上の要素の内最低の要素のイテレータ\n int r = a.length;\n int l = -1;\n while(r - l > 1){\n int mid = (r + l) / 2;\n if(a[mid] >= v){\n r = mid;\n }else{\n l = mid;\n }\n }\n return r;\n }\n\n int upperBound(long[] a, long v){ // return 配列a内のvより大きい要素の内最低の要素のイテレータ\n int r = a.length;\n int l = -1;\n while(r - l > 1){\n int mid = (r + l) / 2;\n if(a[mid] > v){\n r = mid;\n }else{\n l = mid;\n }\n }\n return r;\n }\n\n String nextPermutation(String s){ // return sの次の順列\n ArrayList list = new ArrayList<>();\n for(int i = 0; i < s.length(); i++) list.add(s.charAt(i));\n\n int pivotPos = -1;\n char pivot = 0;\n for(int i = list.size() - 2; i >= 0; i--){\n if(list.get(i) < list.get(i+1)){\n \t\t\tpivotPos = i;\n \t\t\tpivot = list.get(i);\n \t\t\tbreak;\n \t\t}\n \t}\n\n if(pivotPos == -1 && pivot == 0) return null;\n\n int L = pivotPos + 1;\n int R = list.size() - 1;\n \tint minPos = -1;\n \tchar min = Character.MAX_VALUE;\n \tfor(int i = R; i >= L; i--){\n \t\tif(pivot < list.get(i)){\n \t\t\tif(list.get(i) < min){\n \t\t\t\tmin = list.get(i);\n \t\t\t\tminPos = i;\n \t\t\t}\n \t\t}\n \t}\n\n \tCollections.swap(list, pivotPos, minPos);\n \tCollections.sort(list.subList(L, R + 1));\n\n \tStringBuilder sb = new StringBuilder();\n \tfor(int i=0; i 0; i--){\n if(a[i - 1] < a[i]){\n int swapIndex = find(a[i - 1], a, i, a.length - 1);\n long temp = a[swapIndex];\n a[swapIndex] = a[i - 1];\n a[i - 1] = temp;\n Arrays.sort(a, i, a.length);\n return true;\n }\n }\n return false;\n }\n\n int find(long dest, long[] a, int s, int e){\n if(s == e){\n return s;\n }\n int m = (s + e + 1) / 2;\n return a[m] <= dest ? find(dest, a, s, m - 1) : find(dest, a, m, e);\n }\n\n void elimination(int[][] a, int[] b) {\n int n = a.length;\n double f;\n for(int k = 0; k < n - 1; k++){\n for(int i = k + 1; i < n; i++){\n f = - a[i][k] / a[k][k];\n for(int j = k + 1; j < n; j++){\n a[i][j] += f * a[k][j];\n }\n b[i] += f * b[k];\n }\n for(int i = n - 1; i >= 0; i--){\n for(int j = i + 1; j < n; j++){\n b[i] -= a[i][j] * b[j];\n }\n b[i] = b[i] / a[i][i];\n }\n }\n }\n\n\n\n class SegmentTree{\n\n //------------------------------------------------------------\n // 2 * n - 1 : 木全体のノード数\n // i + n - 1 : 配列のi番目が対応するノードの番号\n // 2 * i + 1, 2 * i + 2 : i番目のノードの子ノードの番号\n // (i - 1) / 2 : i番目のノードの親ノードの番号\n //\n // int n = sc.nextInt();\n // long[] a = new long[n];\n // for(int i = 0; i < n; i++) a[i] = sc.nextLong();\n // SegmentTree st = new SegmentTree(a);\n // int l = sc.nextInt() - 1;\n // int r = sc.nextInt() - 1;\n // System.out.println(st.query(l, r));\n //------------------------------------------------------------\n\n final static long INF = Long.MAX_VALUE / 2;\n\n // long e = INF; // 単位元\n long e = 0;\n long func(long a, long b){ // 処理\n // return Math.min(a, b);\n return a + b;\n }\n\n int n; // 配列の要素数を超える最小の2のべき乗\n long[] node;\n\n SegmentTree(long[] a){\n init(a);\n }\n\n void init(long[] a){ // 配列aで初期化\n n = 1;\n while(n < a.length){\n n *= 2;\n }\n node = new long[2 * n - 1];\n Arrays.fill(node, e);\n for(int i = 0; i < a.length; i++){\n node[i + n - 1] = a[i];\n }\n for(int i = n - 2; i >= 0; i--){\n node[i] = func(node[2 * i + 1], node[2 * i + 2]);\n }\n }\n\n void update(int p, long v){ // 配列のp番目をvに変更し、木全体を更新\n p = p + n - 1;\n node[p] = v;\n while(p > 0){\n p = (p - 1) / 2;\n node[p] = func(node[2 * p + 1], node[2 * p + 2]);\n }\n }\n\n long query(int a, int b){ // 区間[a, b)についてクエリを処理\n return query(a, b, 0, 0, n);\n }\n\n long query(int a, int b, int k, int l, int r){\n if(r <= a || b <= l) return e;\n if(a <= l && r <= b) return node[k];\n return func(query(a, b, 2 * k + 1, l, (l + r) / 2), query(a, b, 2 * k + 2, (l + r) / 2, r));\n }\n\n }\n\n\n\n}\n\n\n\nclass Pair implements Comparable{\n long a, b;\n public Pair(long i, long j){\n a = i;\n b = j;\n }\n\n @Override\n public int compareTo(Pair p){\n if(this.b < p.b) return -1;\n else if(this.b > p.b) return 1;\n else return 0;\n }\n}\n\n\n\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte(){\n if(ptr < buflen){\n return true;\n }else{\n ptr = 0;\n try{\n buflen = in.read(buffer);\n }catch(IOException e){\n e.printStackTrace();\n }\n if(buflen <= 0){\n return false;\n }\n }\n return true;\n }\n private int readByte(){\n if(hasNextByte()) return buffer[ptr++];\n else return -1;\n }\n private static boolean isPrintableChar(int c){\n return 33 <= c && c <= 126;\n }\n public boolean hasNext(){\n while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n return hasNextByte();\n }\n public String next(){\n if(!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while(isPrintableChar(b)){\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n public long nextLong(){\n if(!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if(b == '-'){\n minus = true;\n b = readByte();\n }\n if(b < '0' || '9' < b){\n throw new NumberFormatException();\n }\n while(true){\n if('0' <= b && b <= '9'){\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n public int nextInt(){\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n public double nextDouble(){\n return Double.parseDouble(next());\n }\n}\n", "language": "Java", "metadata": {"date": 1589765347, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02677.html", "problem_id": "p02677", "resource_group": "high_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/Java/s578317873.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s578317873", "user_id": "u521293705"}, "prompt_components": {"gold_output": "5.00000000000000000000\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\n\nclass Main{\n final static long INF = Long.MAX_VALUE / 2;\n final static int MOD = 1_000_000_007;\n final static int SIZE = 1_000_000;\n long[] fac = new long[SIZE];\n long[] inv = new long[SIZE];\n long[] finv = new long[SIZE];\n FastScanner sc = new FastScanner();\n\n public static void main(String[] args) {\n new Main().solve();\n }\n\n void solve(){\n\n int a = sc.nextInt();\n int b = sc.nextInt();\n int h = sc.nextInt();\n int m = sc.nextInt();\n\n double a_d = Math.min(h * 30.0 + m / 60.0 * 30.0, 180.0 - (h * 30.0 + m / 60.0 * 30.0));\n double b_d = Math.min(m * 6.0, 180.0 - m * 6.0);\n double a_x = a * Math.sin(Math.toRadians(a_d));\n double a_y = a * Math.cos(Math.toRadians(a_d));\n double b_x = b * Math.sin(Math.toRadians(b_d));\n double b_y = b * Math.cos(Math.toRadians(b_d));\n\n System.out.println(String.format(\"%.15f\", Math.sqrt((a_x - b_x) * (a_x - b_x) + (a_y - b_y) * (a_y - b_y))));\n\n }\n\n long gcd(long a, long b){ // return aとbの最大公約数\n if(b == 0){\n return a;\n }\n return gcd(b, a % b);\n }\n\n long lcm(long a, long b){ // return aとbの最小公倍数\n return a * b / gcd(a, b);\n }\n\n long inv(long a){ // return aの逆元 (mod MOD)\n return pow(a, MOD - 2);\n }\n\n long pow(long a, long r){ // return a^r (mod MOD)\n long sum = 1;\n while(r > 0){\n if((r & 1) == 1){ // 2進数表記で末尾1の時\n sum *= a;\n sum %= MOD;\n }\n a *= a;\n a %= MOD;\n r >>= 1;\n }\n return sum;\n }\n\n long modFact(long n){ // retur n! (mod MOD)\n if(n == 0){\n return 1;\n }\n return n * modFact(n - 1) % MOD;\n }\n\n long fact(long n){ // return n!\n if(n == 0){\n return 1;\n }\n return n * fact(n - 1);\n }\n\n void initCOMB(){\n fac[0] = fac[1] = 1;\n inv[1] = 1;\n finv[0] = finv[1] = 1;\n for(int i = 2; i < SIZE; i++){\n fac[i] = fac[i - 1] * i % MOD;\n inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;\n finv[i] = finv[i - 1] * inv[i] % MOD;\n }\n }\n\n long modComb(int n, int r){ // return nCr (先にinitCOMB()必要)\n if(n < r || n < 0 || r < 0) return 0;\n return fac[n] * finv[r] % MOD * finv[n - r] % MOD;\n }\n\n long comb(long n, long r){ // return nCr\n long num = 1;\n for(long i = 1; i <= r; i++){\n num = num * (n - i + 1) / i;\n }\n return num;\n }\n\n boolean isPrime(long a){ // aの素数判定\n if(a <= 1) return false;\n for(int i = 2; i * i <= a; i++){\n if(a % i == 0) return false;\n }\n return true;\n }\n\n int lowerBound(long[] a, long v){ // return 配列a内のv以上の要素の内最低の要素のイテレータ\n int r = a.length;\n int l = -1;\n while(r - l > 1){\n int mid = (r + l) / 2;\n if(a[mid] >= v){\n r = mid;\n }else{\n l = mid;\n }\n }\n return r;\n }\n\n int upperBound(long[] a, long v){ // return 配列a内のvより大きい要素の内最低の要素のイテレータ\n int r = a.length;\n int l = -1;\n while(r - l > 1){\n int mid = (r + l) / 2;\n if(a[mid] > v){\n r = mid;\n }else{\n l = mid;\n }\n }\n return r;\n }\n\n String nextPermutation(String s){ // return sの次の順列\n ArrayList list = new ArrayList<>();\n for(int i = 0; i < s.length(); i++) list.add(s.charAt(i));\n\n int pivotPos = -1;\n char pivot = 0;\n for(int i = list.size() - 2; i >= 0; i--){\n if(list.get(i) < list.get(i+1)){\n \t\t\tpivotPos = i;\n \t\t\tpivot = list.get(i);\n \t\t\tbreak;\n \t\t}\n \t}\n\n if(pivotPos == -1 && pivot == 0) return null;\n\n int L = pivotPos + 1;\n int R = list.size() - 1;\n \tint minPos = -1;\n \tchar min = Character.MAX_VALUE;\n \tfor(int i = R; i >= L; i--){\n \t\tif(pivot < list.get(i)){\n \t\t\tif(list.get(i) < min){\n \t\t\t\tmin = list.get(i);\n \t\t\t\tminPos = i;\n \t\t\t}\n \t\t}\n \t}\n\n \tCollections.swap(list, pivotPos, minPos);\n \tCollections.sort(list.subList(L, R + 1));\n\n \tStringBuilder sb = new StringBuilder();\n \tfor(int i=0; i 0; i--){\n if(a[i - 1] < a[i]){\n int swapIndex = find(a[i - 1], a, i, a.length - 1);\n long temp = a[swapIndex];\n a[swapIndex] = a[i - 1];\n a[i - 1] = temp;\n Arrays.sort(a, i, a.length);\n return true;\n }\n }\n return false;\n }\n\n int find(long dest, long[] a, int s, int e){\n if(s == e){\n return s;\n }\n int m = (s + e + 1) / 2;\n return a[m] <= dest ? find(dest, a, s, m - 1) : find(dest, a, m, e);\n }\n\n void elimination(int[][] a, int[] b) {\n int n = a.length;\n double f;\n for(int k = 0; k < n - 1; k++){\n for(int i = k + 1; i < n; i++){\n f = - a[i][k] / a[k][k];\n for(int j = k + 1; j < n; j++){\n a[i][j] += f * a[k][j];\n }\n b[i] += f * b[k];\n }\n for(int i = n - 1; i >= 0; i--){\n for(int j = i + 1; j < n; j++){\n b[i] -= a[i][j] * b[j];\n }\n b[i] = b[i] / a[i][i];\n }\n }\n }\n\n\n\n class SegmentTree{\n\n //------------------------------------------------------------\n // 2 * n - 1 : 木全体のノード数\n // i + n - 1 : 配列のi番目が対応するノードの番号\n // 2 * i + 1, 2 * i + 2 : i番目のノードの子ノードの番号\n // (i - 1) / 2 : i番目のノードの親ノードの番号\n //\n // int n = sc.nextInt();\n // long[] a = new long[n];\n // for(int i = 0; i < n; i++) a[i] = sc.nextLong();\n // SegmentTree st = new SegmentTree(a);\n // int l = sc.nextInt() - 1;\n // int r = sc.nextInt() - 1;\n // System.out.println(st.query(l, r));\n //------------------------------------------------------------\n\n final static long INF = Long.MAX_VALUE / 2;\n\n // long e = INF; // 単位元\n long e = 0;\n long func(long a, long b){ // 処理\n // return Math.min(a, b);\n return a + b;\n }\n\n int n; // 配列の要素数を超える最小の2のべき乗\n long[] node;\n\n SegmentTree(long[] a){\n init(a);\n }\n\n void init(long[] a){ // 配列aで初期化\n n = 1;\n while(n < a.length){\n n *= 2;\n }\n node = new long[2 * n - 1];\n Arrays.fill(node, e);\n for(int i = 0; i < a.length; i++){\n node[i + n - 1] = a[i];\n }\n for(int i = n - 2; i >= 0; i--){\n node[i] = func(node[2 * i + 1], node[2 * i + 2]);\n }\n }\n\n void update(int p, long v){ // 配列のp番目をvに変更し、木全体を更新\n p = p + n - 1;\n node[p] = v;\n while(p > 0){\n p = (p - 1) / 2;\n node[p] = func(node[2 * p + 1], node[2 * p + 2]);\n }\n }\n\n long query(int a, int b){ // 区間[a, b)についてクエリを処理\n return query(a, b, 0, 0, n);\n }\n\n long query(int a, int b, int k, int l, int r){\n if(r <= a || b <= l) return e;\n if(a <= l && r <= b) return node[k];\n return func(query(a, b, 2 * k + 1, l, (l + r) / 2), query(a, b, 2 * k + 2, (l + r) / 2, r));\n }\n\n }\n\n\n\n}\n\n\n\nclass Pair implements Comparable{\n long a, b;\n public Pair(long i, long j){\n a = i;\n b = j;\n }\n\n @Override\n public int compareTo(Pair p){\n if(this.b < p.b) return -1;\n else if(this.b > p.b) return 1;\n else return 0;\n }\n}\n\n\n\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte(){\n if(ptr < buflen){\n return true;\n }else{\n ptr = 0;\n try{\n buflen = in.read(buffer);\n }catch(IOException e){\n e.printStackTrace();\n }\n if(buflen <= 0){\n return false;\n }\n }\n return true;\n }\n private int readByte(){\n if(hasNextByte()) return buffer[ptr++];\n else return -1;\n }\n private static boolean isPrintableChar(int c){\n return 33 <= c && c <= 126;\n }\n public boolean hasNext(){\n while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n return hasNextByte();\n }\n public String next(){\n if(!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while(isPrintableChar(b)){\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n public long nextLong(){\n if(!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if(b == '-'){\n minus = true;\n b = readByte();\n }\n if(b < '0' || '9' < b){\n throw new NumberFormatException();\n }\n while(true){\n if('0' <= b && b <= '9'){\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n public int nextInt(){\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n public double nextDouble(){\n return Double.parseDouble(next());\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": 10501, "cpu_time_ms": 104, "memory_kb": 58696}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s994890498", "group_id": "codeNet:p02678", "input_text": "import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Scanner;\nimport java.util.Set;\n\npublic class Main {\n\tstatic List> setList = new ArrayList<>();\n\tstatic boolean resBool;\n\tstatic Integer[] res;\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint M = sc.nextInt();\n\t\tfor (int i = 0; i <= N; i++) {\n\t\t\tSet set = new HashSet<>();\n\t\t\tsetList.add(set);\n\t\t}\n\t\tfor (int i = 0; i < M; i++) {\n\t\t\tint tmp1 = sc.nextInt();\n\t\t\tint tmp2 = sc.nextInt();\n\t\t\tsetList.get(tmp1).add(tmp2);\n\t\t\tsetList.get(tmp2).add(tmp1);\n\t\t}\n\t\tresBool = true;\n\t\tres = new Integer[N + 1];\n\t\tres[0] = 99;\n\t\tres[1] = 99;\n\t\tgetRes(new ArrayList<>(Arrays.asList(1)));\n\n\t\tif (resBool) {\n\t\t\tSystem.out.println(\"Yes\");\n\t\t\tfor (int i = 2; i <= N; i++) {\n\t\t\t\tSystem.out.println(res[i]);\n\t\t\t}\n\t\t} else {\n\t\t\tSystem.out.println(\"No\");\n\t\t}\n\t}\n\n\tprivate static void getRes(List array) {\n\t\tList dist = new ArrayList<>();\n\t\tfor (int i : array) {\n\t\t\tfor (int j : setList.get(i)) {\n\t\t\t\tif (res[j] == null) {\n\t\t\t\t\tdist.add(j);\n\t\t\t\t\tres[j] = i;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!Arrays.asList(res).contains(null)) {\n\t\t\treturn;\n\t\t}\n\t\tif (dist.isEmpty()) {\n\t\t\tresBool = false;\n\t\t\treturn;\n\t\t}\n\t\tgetRes(dist);\n\t}\n}", "language": "Java", "metadata": {"date": 1589772452, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02678.html", "problem_id": "p02678", "resource_group": "high_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/Java/s994890498.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s994890498", "user_id": "u290292036"}, "prompt_components": {"gold_output": "Yes\n1\n2\n2\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Scanner;\nimport java.util.Set;\n\npublic class Main {\n\tstatic List> setList = new ArrayList<>();\n\tstatic boolean resBool;\n\tstatic Integer[] res;\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint M = sc.nextInt();\n\t\tfor (int i = 0; i <= N; i++) {\n\t\t\tSet set = new HashSet<>();\n\t\t\tsetList.add(set);\n\t\t}\n\t\tfor (int i = 0; i < M; i++) {\n\t\t\tint tmp1 = sc.nextInt();\n\t\t\tint tmp2 = sc.nextInt();\n\t\t\tsetList.get(tmp1).add(tmp2);\n\t\t\tsetList.get(tmp2).add(tmp1);\n\t\t}\n\t\tresBool = true;\n\t\tres = new Integer[N + 1];\n\t\tres[0] = 99;\n\t\tres[1] = 99;\n\t\tgetRes(new ArrayList<>(Arrays.asList(1)));\n\n\t\tif (resBool) {\n\t\t\tSystem.out.println(\"Yes\");\n\t\t\tfor (int i = 2; i <= N; i++) {\n\t\t\t\tSystem.out.println(res[i]);\n\t\t\t}\n\t\t} else {\n\t\t\tSystem.out.println(\"No\");\n\t\t}\n\t}\n\n\tprivate static void getRes(List array) {\n\t\tList dist = new ArrayList<>();\n\t\tfor (int i : array) {\n\t\t\tfor (int j : setList.get(i)) {\n\t\t\t\tif (res[j] == null) {\n\t\t\t\t\tdist.add(j);\n\t\t\t\t\tres[j] = i;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!Arrays.asList(res).contains(null)) {\n\t\t\treturn;\n\t\t}\n\t\tif (dist.isEmpty()) {\n\t\t\tresBool = false;\n\t\t\treturn;\n\t\t}\n\t\tgetRes(dist);\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": 1328, "cpu_time_ms": 1572, "memory_kb": 114624}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s823636180", "group_id": "codeNet:p02682", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\n\t\tScanner scan = new Scanner(System.in);\n\t\tint A = scan.nextInt();\n\t\tint B = scan.nextInt();\n\t\tint C = scan.nextInt();\n\t\tint K = scan.nextInt();\n\n\t\tif (K <= A) {\n\t\t\tSystem.out.print(A);\n\t\t}\n\t\tif (K <= (A + B)) {\n\t\t\tSystem.out.print(A);\n\t\t} else {\n\t\t\tif (K <= (A + B + C)) {\n\t\t\t\tK = K - A;\n\t\t\t\tK = K - B;\n\t\t\t\tint max = A - K;\n\t\t\t\tif (max <= 0) {\n\t\t\t\t\tSystem.out.print(0);\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.print(max);\n\t\t\t\t}\n\n\t\t\t}\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1589169968, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02682.html", "problem_id": "p02682", "resource_group": "high_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/Java/s823636180.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s823636180", "user_id": "u181589117"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\n\t\tScanner scan = new Scanner(System.in);\n\t\tint A = scan.nextInt();\n\t\tint B = scan.nextInt();\n\t\tint C = scan.nextInt();\n\t\tint K = scan.nextInt();\n\n\t\tif (K <= A) {\n\t\t\tSystem.out.print(A);\n\t\t}\n\t\tif (K <= (A + B)) {\n\t\t\tSystem.out.print(A);\n\t\t} else {\n\t\t\tif (K <= (A + B + C)) {\n\t\t\t\tK = K - A;\n\t\t\t\tK = K - B;\n\t\t\t\tint max = A - K;\n\t\t\t\tif (max <= 0) {\n\t\t\t\t\tSystem.out.print(0);\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.print(max);\n\t\t\t\t}\n\n\t\t\t}\n\t\t}\n\t}\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": 579, "cpu_time_ms": 103, "memory_kb": 35812}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s196830771", "group_id": "codeNet:p02682", "input_text": "import java.util.Scanner;\n\npublic class Main{\n public static void main(String[] args) {\n Scanner kbd =new Scanner(System.in);\n int a=kbd.nextInt();\n int b=kbd.nextInt();\n int c=kbd.nextInt();\n int k=kbd.nextInt();\n long A=0;//合計\n int M=0;//枚数\n int K=0;//回数\n while(M 0) {\n if ((n & 1) == 1) {\n ans = ans * x % mod;\n }\n x = x * x % mod;\n n >>= 1;\n }\n return ans;\n */\n if (n == 0) {\n return 1;\n }\n return n % 2 == 0 ?\n pow(x * x % mod, n / 2) % mod :\n x % mod * pow(x, n - 1) % mod;\n }\n }\n\n private static class ModularNFixedCombination {\n\n private final Modular modular;\n private final long[] comb;\n private final long N;\n\n public ModularNFixedCombination(long N, int size, long mod) {\n this.modular = new Modular(mod);\n this.comb = new long[size + 1];\n this.N = N;\n\n comb[0] = 1;\n\n for (int i = 1; i <= size; i++) {\n comb[i] = ((comb[i - 1] * (N - (i - 1))) % mod * modular.inverse(i)) % mod;\n }\n }\n\n long combination(int n, int k) {\n if (n != N) {\n throw new IllegalStateException();\n }\n return comb[k];\n }\n\n long repeatedCombination(int n, int k) {\n return combination(n + k - 1, k);\n }\n }\n\n private static class ModularCombination {\n\n private final long fact[];\n private final long mod;\n private final Modular modular;\n\n public ModularCombination(int size, long mod) {\n this.fact = new long[size + 1];\n this.mod = mod;\n this.modular = new Modular(mod);\n\n this.fact[0] = 1;\n for (int i = 1; i <= size; i++) {\n fact[i] = (fact[i - 1] * i) % mod;\n }\n }\n\n private long factorial(int n) {\n return fact[n];\n }\n\n long combination(int n, int k) {\n return\n (\n (\n (\n factorial(n) * modular.inverse(factorial(n - k))\n ) % mod\n ) * modular.inverse(factorial(k))\n ) % mod;\n }\n\n long repeatedCombination(int n, int k) {\n return combination(n + k - 1, k);\n }\n }\n\n private static class Scanner {\n\n private final InputStream is;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n Scanner(InputStream is) {\n this.is = is;\n }\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = is.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) {\n return buffer[ptr++];\n } else {\n return -1;\n }\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) {\n ptr++;\n }\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {\n throw new NumberFormatException();\n }\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1589159139, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02682.html", "problem_id": "p02682", "resource_group": "high_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/Java/s495023449.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s495023449", "user_id": "u482226328"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.InputStream;\nimport java.io.IOException;\nimport java.io.PrintStream;\nimport java.math.*;\nimport java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n solve(System.in, System.out);\n }\n\n static void solve(InputStream is, PrintStream os) {\n Scanner sc = new Scanner(is);\n\n /* read */\n long a = sc.nextLong();\n long b = sc.nextLong();\n long c = sc.nextLong();\n\n long k = sc.nextLong();\n\n long ans = 0;\n\n long take1 = Math.min(a, k);\n k -= take1;\n ans += take1;\n\n long take0 = Math.min(b, k);\n k -= take0;\n\n long takem1 = Math.min(c, k);\n k -= takem1;\n ans -= takem1;\n\n os.println(ans);\n\n }\n\n private static long gcd(long m, long n) {\n if (m < n) return gcd(n, m);\n if (n == 0) return m;\n return gcd(n, m % n);\n }\n\n private static long lcm(long m, long n) {\n return m / gcd(m, n) * n;\n }\n\n private static class Modular {\n\n private final long mod;\n\n private Modular(long mod) {\n this.mod = mod;\n }\n\n private long inverse(long n) {\n return pow(n, mod - 2) % mod;\n }\n\n private long pow(long x, long n) {\n /*\n long ans = 1;\n while (n > 0) {\n if ((n & 1) == 1) {\n ans = ans * x % mod;\n }\n x = x * x % mod;\n n >>= 1;\n }\n return ans;\n */\n if (n == 0) {\n return 1;\n }\n return n % 2 == 0 ?\n pow(x * x % mod, n / 2) % mod :\n x % mod * pow(x, n - 1) % mod;\n }\n }\n\n private static class ModularNFixedCombination {\n\n private final Modular modular;\n private final long[] comb;\n private final long N;\n\n public ModularNFixedCombination(long N, int size, long mod) {\n this.modular = new Modular(mod);\n this.comb = new long[size + 1];\n this.N = N;\n\n comb[0] = 1;\n\n for (int i = 1; i <= size; i++) {\n comb[i] = ((comb[i - 1] * (N - (i - 1))) % mod * modular.inverse(i)) % mod;\n }\n }\n\n long combination(int n, int k) {\n if (n != N) {\n throw new IllegalStateException();\n }\n return comb[k];\n }\n\n long repeatedCombination(int n, int k) {\n return combination(n + k - 1, k);\n }\n }\n\n private static class ModularCombination {\n\n private final long fact[];\n private final long mod;\n private final Modular modular;\n\n public ModularCombination(int size, long mod) {\n this.fact = new long[size + 1];\n this.mod = mod;\n this.modular = new Modular(mod);\n\n this.fact[0] = 1;\n for (int i = 1; i <= size; i++) {\n fact[i] = (fact[i - 1] * i) % mod;\n }\n }\n\n private long factorial(int n) {\n return fact[n];\n }\n\n long combination(int n, int k) {\n return\n (\n (\n (\n factorial(n) * modular.inverse(factorial(n - k))\n ) % mod\n ) * modular.inverse(factorial(k))\n ) % mod;\n }\n\n long repeatedCombination(int n, int k) {\n return combination(n + k - 1, k);\n }\n }\n\n private static class Scanner {\n\n private final InputStream is;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n Scanner(InputStream is) {\n this.is = is;\n }\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = is.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) {\n return buffer[ptr++];\n } else {\n return -1;\n }\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) {\n ptr++;\n }\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {\n throw new NumberFormatException();\n }\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\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": 5210, "cpu_time_ms": 65, "memory_kb": 32528}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s837602875", "group_id": "codeNet:p02683", "input_text": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int m = sc.nextInt();\n int x = sc.nextInt();\n\n int[] price = new int[n];\n int[][] skillUpValue = new int[n][];\n\n for(int i = 0; i < n; i++){//多次元配列の生成(長さnの配列、配列の各要素はmの配列)\n price[i] = sc.nextInt();//値段の配列の生成\n for(int k = 0; k < m; k++){\n skillUpValue[i][k] = sc.nextInt();\n }\n }\n\n int min = (int)12e6;\n out:for(int i = 0; i < (1<> j & 1) == 1) {//iの、j+1桁目が1かどうか判定 → 1なら該当の本を購入している\n for (int k = 0; k < m; k++) {\n rikai[k] += skillUpValue[j][k];//1〜Mまでの各アルゴリズムの理解度に本から得られる理解度を計上\n }\n cost += price[j];//購入した本の代金をコストに計上\n }\n }\n\n for(int l = 0; l < m;l++){\n if(rikai[l] < x){\n continue out;\n }\n }\n min = cost;\n }\n System.out.println(min == (int)12e6 ? -1 : min);\n }\n}\n", "language": "Java", "metadata": {"date": 1589254075, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02683.html", "problem_id": "p02683", "resource_group": "high_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/Java/s837602875.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s837602875", "user_id": "u084693272"}, "prompt_components": {"gold_output": "120\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int m = sc.nextInt();\n int x = sc.nextInt();\n\n int[] price = new int[n];\n int[][] skillUpValue = new int[n][];\n\n for(int i = 0; i < n; i++){//多次元配列の生成(長さnの配列、配列の各要素はmの配列)\n price[i] = sc.nextInt();//値段の配列の生成\n for(int k = 0; k < m; k++){\n skillUpValue[i][k] = sc.nextInt();\n }\n }\n\n int min = (int)12e6;\n out:for(int i = 0; i < (1<> j & 1) == 1) {//iの、j+1桁目が1かどうか判定 → 1なら該当の本を購入している\n for (int k = 0; k < m; k++) {\n rikai[k] += skillUpValue[j][k];//1〜Mまでの各アルゴリズムの理解度に本から得られる理解度を計上\n }\n cost += price[j];//購入した本の代金をコストに計上\n }\n }\n\n for(int l = 0; l < m;l++){\n if(rikai[l] < x){\n continue out;\n }\n }\n min = cost;\n }\n System.out.println(min == (int)12e6 ? -1 : min);\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": 1654, "cpu_time_ms": 112, "memory_kb": 35780}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s419443497", "group_id": "codeNet:p02683", "input_text": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.InputMismatchException;\nimport java.util.NoSuchElementException;\n\npublic class Main {\n\tstatic PrintWriter out;\n\tstatic InputReader ir;\n\n\tstatic void solve() {\n\t\tint n = ir.nextInt();\n\t\tint m = ir.nextInt();\n\t\tint x = ir.nextInt();\n\t\tint[] c = new int[n];\n\t\tint[][] a = new int[n][];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tc[i] = ir.nextInt();\n\t\t\ta[i] = ir.nextIntArray(m);\n\t\t}\n\t\tint mi = 1 << 30;\n\t\touter: for (int i = 0; i < 1 << n; i++) {\n\t\t\tint[] b = new int[m];\n\t\t\tint tmp = 0;\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tif ((i & (1 << j)) != 0) {\n\t\t\t\t\ttmp += c[j];\n\t\t\t\t\tfor (int k = 0; k < m; k++)\n\t\t\t\t\t\tb[k] += a[j][k];\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (int j = 0; j < m; j++) {\n\t\t\t\tif (b[j] < x)\n\t\t\t\t\tcontinue outer;\n\t\t\t}\n\t\t\tmi = Math.min(mi, tmp);\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tir = new InputReader(System.in);\n\t\tout = new PrintWriter(System.out);\n\t\tsolve();\n\t\tout.flush();\n\t}\n\n\tstatic class InputReader {\n\n\t\tprivate InputStream in;\n\t\tprivate byte[] buffer = new byte[1024];\n\t\tprivate int curbuf;\n\t\tprivate int lenbuf;\n\n\t\tpublic InputReader(InputStream in) {\n\t\t\tthis.in = in;\n\t\t\tthis.curbuf = this.lenbuf = 0;\n\t\t}\n\n\t\tpublic boolean hasNextByte() {\n\t\t\tif (curbuf >= lenbuf) {\n\t\t\t\tcurbuf = 0;\n\t\t\t\ttry {\n\t\t\t\t\tlenbuf = in.read(buffer);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\t\t\t\tif (lenbuf <= 0)\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tprivate int readByte() {\n\t\t\tif (hasNextByte())\n\t\t\t\treturn buffer[curbuf++];\n\t\t\telse\n\t\t\t\treturn -1;\n\t\t}\n\n\t\tprivate boolean isSpaceChar(int c) {\n\t\t\treturn !(c >= 33 && c <= 126);\n\t\t}\n\n\t\tprivate void skip() {\n\t\t\twhile (hasNextByte() && isSpaceChar(buffer[curbuf]))\n\t\t\t\tcurbuf++;\n\t\t}\n\n\t\tpublic boolean hasNext() {\n\t\t\tskip();\n\t\t\treturn hasNextByte();\n\t\t}\n\n\t\tpublic String next() {\n\t\t\tif (!hasNext())\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tint b = readByte();\n\t\t\twhile (!isSpaceChar(b)) {\n\t\t\t\tsb.appendCodePoint(b);\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t\treturn sb.toString();\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\tif (!hasNext())\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\tint c = readByte();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = readByte();\n\t\t\tboolean minus = false;\n\t\t\tif (c == '-') {\n\t\t\t\tminus = true;\n\t\t\t\tc = readByte();\n\t\t\t}\n\t\t\tint res = 0;\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres = res * 10 + c - '0';\n\t\t\t\tc = readByte();\n\t\t\t} while (!isSpaceChar(c));\n\t\t\treturn (minus) ? -res : res;\n\t\t}\n\n\t\tpublic long nextLong() {\n\t\t\tif (!hasNext())\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\tint c = readByte();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = readByte();\n\t\t\tboolean minus = false;\n\t\t\tif (c == '-') {\n\t\t\t\tminus = true;\n\t\t\t\tc = readByte();\n\t\t\t}\n\t\t\tlong res = 0;\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres = res * 10 + c - '0';\n\t\t\t\tc = readByte();\n\t\t\t} while (!isSpaceChar(c));\n\t\t\treturn (minus) ? -res : res;\n\t\t}\n\n\t\tpublic double nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tpublic int[] nextIntArray(int n) {\n\t\t\tint[] a = new int[n];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\ta[i] = nextInt();\n\t\t\treturn a;\n\t\t}\n\n\t\tpublic long[] nextLongArray(int n) {\n\t\t\tlong[] a = new long[n];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\ta[i] = nextLong();\n\t\t\treturn a;\n\t\t}\n\n\t\tpublic char[][] nextCharMap(int n, int m) {\n\t\t\tchar[][] map = new char[n][m];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\tmap[i] = next().toCharArray();\n\t\t\treturn map;\n\t\t}\n\t}\n\n\tstatic void tr(Object... o) {\n\t\tSystem.err.println(Arrays.deepToString(o));\n\t}\n}\n", "language": "Java", "metadata": {"date": 1589159700, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02683.html", "problem_id": "p02683", "resource_group": "high_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/Java/s419443497.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s419443497", "user_id": "u591717585"}, "prompt_components": {"gold_output": "120\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.InputMismatchException;\nimport java.util.NoSuchElementException;\n\npublic class Main {\n\tstatic PrintWriter out;\n\tstatic InputReader ir;\n\n\tstatic void solve() {\n\t\tint n = ir.nextInt();\n\t\tint m = ir.nextInt();\n\t\tint x = ir.nextInt();\n\t\tint[] c = new int[n];\n\t\tint[][] a = new int[n][];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tc[i] = ir.nextInt();\n\t\t\ta[i] = ir.nextIntArray(m);\n\t\t}\n\t\tint mi = 1 << 30;\n\t\touter: for (int i = 0; i < 1 << n; i++) {\n\t\t\tint[] b = new int[m];\n\t\t\tint tmp = 0;\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tif ((i & (1 << j)) != 0) {\n\t\t\t\t\ttmp += c[j];\n\t\t\t\t\tfor (int k = 0; k < m; k++)\n\t\t\t\t\t\tb[k] += a[j][k];\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (int j = 0; j < m; j++) {\n\t\t\t\tif (b[j] < x)\n\t\t\t\t\tcontinue outer;\n\t\t\t}\n\t\t\tmi = Math.min(mi, tmp);\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tir = new InputReader(System.in);\n\t\tout = new PrintWriter(System.out);\n\t\tsolve();\n\t\tout.flush();\n\t}\n\n\tstatic class InputReader {\n\n\t\tprivate InputStream in;\n\t\tprivate byte[] buffer = new byte[1024];\n\t\tprivate int curbuf;\n\t\tprivate int lenbuf;\n\n\t\tpublic InputReader(InputStream in) {\n\t\t\tthis.in = in;\n\t\t\tthis.curbuf = this.lenbuf = 0;\n\t\t}\n\n\t\tpublic boolean hasNextByte() {\n\t\t\tif (curbuf >= lenbuf) {\n\t\t\t\tcurbuf = 0;\n\t\t\t\ttry {\n\t\t\t\t\tlenbuf = in.read(buffer);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\t\t\t\tif (lenbuf <= 0)\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tprivate int readByte() {\n\t\t\tif (hasNextByte())\n\t\t\t\treturn buffer[curbuf++];\n\t\t\telse\n\t\t\t\treturn -1;\n\t\t}\n\n\t\tprivate boolean isSpaceChar(int c) {\n\t\t\treturn !(c >= 33 && c <= 126);\n\t\t}\n\n\t\tprivate void skip() {\n\t\t\twhile (hasNextByte() && isSpaceChar(buffer[curbuf]))\n\t\t\t\tcurbuf++;\n\t\t}\n\n\t\tpublic boolean hasNext() {\n\t\t\tskip();\n\t\t\treturn hasNextByte();\n\t\t}\n\n\t\tpublic String next() {\n\t\t\tif (!hasNext())\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tint b = readByte();\n\t\t\twhile (!isSpaceChar(b)) {\n\t\t\t\tsb.appendCodePoint(b);\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t\treturn sb.toString();\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\tif (!hasNext())\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\tint c = readByte();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = readByte();\n\t\t\tboolean minus = false;\n\t\t\tif (c == '-') {\n\t\t\t\tminus = true;\n\t\t\t\tc = readByte();\n\t\t\t}\n\t\t\tint res = 0;\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres = res * 10 + c - '0';\n\t\t\t\tc = readByte();\n\t\t\t} while (!isSpaceChar(c));\n\t\t\treturn (minus) ? -res : res;\n\t\t}\n\n\t\tpublic long nextLong() {\n\t\t\tif (!hasNext())\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\tint c = readByte();\n\t\t\twhile (isSpaceChar(c))\n\t\t\t\tc = readByte();\n\t\t\tboolean minus = false;\n\t\t\tif (c == '-') {\n\t\t\t\tminus = true;\n\t\t\t\tc = readByte();\n\t\t\t}\n\t\t\tlong res = 0;\n\t\t\tdo {\n\t\t\t\tif (c < '0' || c > '9')\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\tres = res * 10 + c - '0';\n\t\t\t\tc = readByte();\n\t\t\t} while (!isSpaceChar(c));\n\t\t\treturn (minus) ? -res : res;\n\t\t}\n\n\t\tpublic double nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tpublic int[] nextIntArray(int n) {\n\t\t\tint[] a = new int[n];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\ta[i] = nextInt();\n\t\t\treturn a;\n\t\t}\n\n\t\tpublic long[] nextLongArray(int n) {\n\t\t\tlong[] a = new long[n];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\ta[i] = nextLong();\n\t\t\treturn a;\n\t\t}\n\n\t\tpublic char[][] nextCharMap(int n, int m) {\n\t\t\tchar[][] map = new char[n][m];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\tmap[i] = next().toCharArray();\n\t\t\treturn map;\n\t\t}\n\t}\n\n\tstatic void tr(Object... o) {\n\t\tSystem.err.println(Arrays.deepToString(o));\n\t}\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": 3621, "cpu_time_ms": 89, "memory_kb": 33860}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s827117554", "group_id": "codeNet:p02687", "input_text": "public class Main {\n public static void main(String[] args) {\n System.out.println(System.getProperty(\"sun.arch.data.model\"));\n\n long x = (1L << 32) - 1 ;\n long n = (int)1e8;\n long p = 1;\n\n for (int i = 1; i <= n; i++) {\n p += i;\n p %= x;\n }\n\n System.out.println(p);\n } \n}", "language": "Java", "metadata": {"date": 1589155650, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02687.html", "problem_id": "p02687", "resource_group": "high_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/Java/s827117554.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s827117554", "user_id": "u156040680"}, "prompt_components": {"gold_output": "ARC\n", "input_to_evaluate": "public class Main {\n public static void main(String[] args) {\n System.out.println(System.getProperty(\"sun.arch.data.model\"));\n\n long x = (1L << 32) - 1 ;\n long n = (int)1e8;\n long p = 1;\n\n for (int i = 1; i <= n; i++) {\n p += i;\n p %= x;\n }\n\n System.out.println(p);\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": 350, "cpu_time_ms": 1347, "memory_kb": 32396}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s590070874", "group_id": "codeNet:p02688", "input_text": "import java.io.*;\nimport java.util.*;\nimport java.util.stream.*;\n\nclass Main{\n\tstatic final long MOD = 1_000_000_007; // 10^9+7\n static final int MAX = 2_147_483_646; // intMax \n static final int INF = 1_000_000_000; // 10^9 \n public static void main(String[] args) throws Exception {\n\t\thayami saori = new hayami();\n\t\tint n = saori.saori_hayami();\n\t\tint k = saori.saori_hayami();\n\t\tHashSet h = new HashSet<>();\n\t\tfor(int i = 0;i < k;i++){\n\t\t\tint d = saori.saori_hayami();\n\t\t\tfor(int j = 0;j < d;j++){\n\t\t\t\th.add(saori.saori_hayami());\n\t\t\t}\n\t\t}\n\t\tint ans = 0;\n\t\tfor(int i =1 ;i <= n;i++){\n\t\t\tif(!h.contains(i))ans++;\n\t\t}\n\t\tSystem.out.println(ans);\n\t\tsaori.close();\n }\n}\n\nclass hayami implements Closeable {\n\tprivate final InputStream in = System.in;\n\tprivate final byte[] hayami = new byte[1024];\n\tprivate int Hayami = 0;\n\tprivate int saori = 0;\n\tprivate boolean HayamiSaori() {\n\t\tif (Hayami < saori) {\n\t\t\treturn true;\n\t\t}else{\n\t\t\tHayami = 0;\n\t\t\ttry {\n\t\t\t\tsaori = in.read(hayami);\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (saori <= 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\tprivate int SaoriHayami() { \n\t\tif (HayamiSaori()) {\n return hayami[Hayami++];\n }else{\n return -1;\n }\n\t}\n\tprivate static boolean hayami_saori(int hayami) { \n\t\treturn 33 <= hayami && hayami <= 126;\n\t}\n\tpublic boolean hayamisaori() { \n\t\twhile(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();\n\t}\n\tpublic String nextHayami() {\n\t\tif (!hayamisaori()) throw new NoSuchElementException();\n\t\tStringBuilder hayamin = new StringBuilder();\n\t\tint saori = SaoriHayami();\n\t\twhile(hayami_saori(saori)) {\n\t\t\thayamin.appendCodePoint(saori);\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t\treturn hayamin.toString();\n\t}\n\tpublic long saorihayami() {//nextLong\n\t\tif (!hayamisaori()) throw new NoSuchElementException();\n\t\tlong hayami = 0;\n\t\tboolean misao = false;\n\t\tint saori = SaoriHayami();\n\t\tif (saori == '-') {\n\t\t\tmisao = true;\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t\tif (saori < '0' || '9' < saori) {\n\t\t\tthrow new NumberFormatException();\n\t\t}\n\t\twhile(true){\n\t\t\tif ('0' <= saori && saori <= '9') {\n\t\t\t\thayami *= 10;\n\t\t\t\thayami += saori - '0';\n\t\t\t}else if(saori == -1 || !hayami_saori(saori)){\n\t\t\t\treturn misao ? -hayami : hayami;\n\t\t\t}else{\n\t\t\t\tthrow new NumberFormatException();\n\t\t\t}\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t}\n\tpublic int saori_hayami() {//nextInt\n\t\tlong hayami = saorihayami();\n\t\tif (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();\n\t\treturn (int) hayami;\n\t}\n\tpublic double Hayamin() { //nextDouble\n\t\treturn Double.parseDouble(nextHayami());\n\t}\n\tpublic void close() {\n\t\ttry {\n\t\t\tin.close();\n\t\t} catch (IOException e) {\n\t\t}\n }\n \n}", "language": "Java", "metadata": {"date": 1588554312, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02688.html", "problem_id": "p02688", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02688/input.txt", "sample_output_relpath": "derived/input_output/data/p02688/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02688/Java/s590070874.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s590070874", "user_id": "u676749446"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\nimport java.util.stream.*;\n\nclass Main{\n\tstatic final long MOD = 1_000_000_007; // 10^9+7\n static final int MAX = 2_147_483_646; // intMax \n static final int INF = 1_000_000_000; // 10^9 \n public static void main(String[] args) throws Exception {\n\t\thayami saori = new hayami();\n\t\tint n = saori.saori_hayami();\n\t\tint k = saori.saori_hayami();\n\t\tHashSet h = new HashSet<>();\n\t\tfor(int i = 0;i < k;i++){\n\t\t\tint d = saori.saori_hayami();\n\t\t\tfor(int j = 0;j < d;j++){\n\t\t\t\th.add(saori.saori_hayami());\n\t\t\t}\n\t\t}\n\t\tint ans = 0;\n\t\tfor(int i =1 ;i <= n;i++){\n\t\t\tif(!h.contains(i))ans++;\n\t\t}\n\t\tSystem.out.println(ans);\n\t\tsaori.close();\n }\n}\n\nclass hayami implements Closeable {\n\tprivate final InputStream in = System.in;\n\tprivate final byte[] hayami = new byte[1024];\n\tprivate int Hayami = 0;\n\tprivate int saori = 0;\n\tprivate boolean HayamiSaori() {\n\t\tif (Hayami < saori) {\n\t\t\treturn true;\n\t\t}else{\n\t\t\tHayami = 0;\n\t\t\ttry {\n\t\t\t\tsaori = in.read(hayami);\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (saori <= 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\tprivate int SaoriHayami() { \n\t\tif (HayamiSaori()) {\n return hayami[Hayami++];\n }else{\n return -1;\n }\n\t}\n\tprivate static boolean hayami_saori(int hayami) { \n\t\treturn 33 <= hayami && hayami <= 126;\n\t}\n\tpublic boolean hayamisaori() { \n\t\twhile(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();\n\t}\n\tpublic String nextHayami() {\n\t\tif (!hayamisaori()) throw new NoSuchElementException();\n\t\tStringBuilder hayamin = new StringBuilder();\n\t\tint saori = SaoriHayami();\n\t\twhile(hayami_saori(saori)) {\n\t\t\thayamin.appendCodePoint(saori);\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t\treturn hayamin.toString();\n\t}\n\tpublic long saorihayami() {//nextLong\n\t\tif (!hayamisaori()) throw new NoSuchElementException();\n\t\tlong hayami = 0;\n\t\tboolean misao = false;\n\t\tint saori = SaoriHayami();\n\t\tif (saori == '-') {\n\t\t\tmisao = true;\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t\tif (saori < '0' || '9' < saori) {\n\t\t\tthrow new NumberFormatException();\n\t\t}\n\t\twhile(true){\n\t\t\tif ('0' <= saori && saori <= '9') {\n\t\t\t\thayami *= 10;\n\t\t\t\thayami += saori - '0';\n\t\t\t}else if(saori == -1 || !hayami_saori(saori)){\n\t\t\t\treturn misao ? -hayami : hayami;\n\t\t\t}else{\n\t\t\t\tthrow new NumberFormatException();\n\t\t\t}\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t}\n\tpublic int saori_hayami() {//nextInt\n\t\tlong hayami = saorihayami();\n\t\tif (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();\n\t\treturn (int) hayami;\n\t}\n\tpublic double Hayamin() { //nextDouble\n\t\treturn Double.parseDouble(nextHayami());\n\t}\n\tpublic void close() {\n\t\ttry {\n\t\t\tin.close();\n\t\t} catch (IOException e) {\n\t\t}\n }\n \n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nN Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.\n\nThere are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \\cdots, A_{i, {d_i}}.\n\nTakahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 100\n\n1 \\leq d_i \\leq N\n\n1 \\leq A_{i, 1} < \\cdots < A_{i, d_i} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nd_1\nA_{1, 1} \\cdots A_{1, d_1}\n\\vdots\nd_K\nA_{K, 1} \\cdots A_{K, d_K}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n2\n1 3\n1\n3\n\nSample Output 1\n\n1\n\nSnuke 1 has Snack 1.\n\nSnuke 2 has no snacks.\n\nSnuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\nSample Input 2\n\n3 3\n1\n3\n1\n3\n1\n3\n\nSample Output 2\n\n2", "sample_input": "3 2\n2\n1 3\n1\n3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02688", "source_text": "Score : 200 points\n\nProblem Statement\n\nN Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.\n\nThere are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \\cdots, A_{i, {d_i}}.\n\nTakahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 100\n\n1 \\leq d_i \\leq N\n\n1 \\leq A_{i, 1} < \\cdots < A_{i, d_i} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nd_1\nA_{1, 1} \\cdots A_{1, d_1}\n\\vdots\nd_K\nA_{K, 1} \\cdots A_{K, d_K}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n2\n1 3\n1\n3\n\nSample Output 1\n\n1\n\nSnuke 1 has Snack 1.\n\nSnuke 2 has no snacks.\n\nSnuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\nSample Input 2\n\n3 3\n1\n3\n1\n3\n1\n3\n\nSample Output 2\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2741, "cpu_time_ms": 73, "memory_kb": 32924}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s888573844", "group_id": "codeNet:p02689", "input_text": "import java.util.*;\n\nclass Main\n{\n public static void main(String[] args)\n {\n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n int m = sc.nextInt();\n \n int[] hight = new int[n]; //高さ入力\n for (int i = 0; i < n; i++) {\n hight[i] = sc.nextInt();\n }\n \n int[] perfect = new int[n]; // 最高かどうか\n for (int i = 0; i < n; i++) {\n perfect[i] = 0;\n }\n \n int[] perfect2 = new int[n]; //登場回数\n for (int i = 0; i < n; i++) {\n perfect2[i] = 0;\n }\n \n \n for (int i = 0; i < m ; i++) {\n int a = sc.nextInt();\n int b = sc.nextInt();\n \n perfect2[a - 1] = 1;\n perfect2[b -1] = 1;\n \n \n if (hight[a - 1] > hight[b - 1]) {\n perfect[a -1] += 100;\n perfect[b - 1] -= 9999999;\n } else if (hight[a - 1] < hight[b - 1]) {\n perfect[b - 1] += 100;\n perfect[a - 1] -= 9999999;\n } else {\n perfect[b - 1] -= 9999999;\n perfect[a - 1] -= 9999999;\n }\n }\n \n int count = 0;\n for (int i = 0; i < n; i++) {\n if (perfect[i] > 100) {\n count++;\n }\n }\n for (int i = 0; i < n; i++) {\n if (perfect2[i] == 0) {\n count++;\n }\n }\n \n System.out.println(count + 1);\n }\n} ", "language": "Java", "metadata": {"date": 1588559885, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02689.html", "problem_id": "p02689", "resource_group": "high_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/Java/s888573844.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s888573844", "user_id": "u520480375"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*;\n\nclass Main\n{\n public static void main(String[] args)\n {\n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n int m = sc.nextInt();\n \n int[] hight = new int[n]; //高さ入力\n for (int i = 0; i < n; i++) {\n hight[i] = sc.nextInt();\n }\n \n int[] perfect = new int[n]; // 最高かどうか\n for (int i = 0; i < n; i++) {\n perfect[i] = 0;\n }\n \n int[] perfect2 = new int[n]; //登場回数\n for (int i = 0; i < n; i++) {\n perfect2[i] = 0;\n }\n \n \n for (int i = 0; i < m ; i++) {\n int a = sc.nextInt();\n int b = sc.nextInt();\n \n perfect2[a - 1] = 1;\n perfect2[b -1] = 1;\n \n \n if (hight[a - 1] > hight[b - 1]) {\n perfect[a -1] += 100;\n perfect[b - 1] -= 9999999;\n } else if (hight[a - 1] < hight[b - 1]) {\n perfect[b - 1] += 100;\n perfect[a - 1] -= 9999999;\n } else {\n perfect[b - 1] -= 9999999;\n perfect[a - 1] -= 9999999;\n }\n }\n \n int count = 0;\n for (int i = 0; i < n; i++) {\n if (perfect[i] > 100) {\n count++;\n }\n }\n for (int i = 0; i < n; i++) {\n if (perfect2[i] == 0) {\n count++;\n }\n }\n \n System.out.println(count + 1);\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": 1581, "cpu_time_ms": 662, "memory_kb": 61316}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s384310364", "group_id": "codeNet:p02689", "input_text": "import java.util.*;\npublic class Main{\n public static void main(String[] args){\n Scanner sc =new Scanner(System.in);\n int N =sc.nextInt();\n int M =sc.nextInt();\n long H[] =new long[N];\n int A[] =new int[M];\n int B[] =new int[M];\n int C[] =new int[N];\n int x =0;\n for(int i=0;i=H[B[j]-1]){\n if(C[B[j]-1]==-1){continue;}\n else{\n C[B[j]-1]=-1;x=x+1;}}\n else{\n if(C[A[j]-1]==-1){continue;}\n C[A[j]-1]=-1;x=x+1;}}}\n System.out.println(N-x);\n }\n}", "language": "Java", "metadata": {"date": 1588558323, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02689.html", "problem_id": "p02689", "resource_group": "high_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/Java/s384310364.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s384310364", "user_id": "u547671064"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*;\npublic class Main{\n public static void main(String[] args){\n Scanner sc =new Scanner(System.in);\n int N =sc.nextInt();\n int M =sc.nextInt();\n long H[] =new long[N];\n int A[] =new int[M];\n int B[] =new int[M];\n int C[] =new int[N];\n int x =0;\n for(int i=0;i=H[B[j]-1]){\n if(C[B[j]-1]==-1){continue;}\n else{\n C[B[j]-1]=-1;x=x+1;}}\n else{\n if(C[A[j]-1]==-1){continue;}\n C[A[j]-1]=-1;x=x+1;}}}\n System.out.println(N-x);\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": 711, "cpu_time_ms": 656, "memory_kb": 61604}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s065543593", "group_id": "codeNet:p02689", "input_text": "\timport java.util.*;\n\timport java.util.Map.Entry;\n\t \n\t \n\t class Main {\n\t\t static int mod = (int) (Math.pow(10,9)+7);\n\t\t static List> list = new ArrayList>();\n\t public static void main(String[] args) {\n\t \t\n\t Scanner sc = new Scanner(System.in);\n\t int N = sc.nextInt();\t\n\t int M = sc.nextInt();\n\t long[] H = new long[N];\n\t for(int i=0;i());\n\t for(int i=0;i=H[i])highest=false;\n\t \t}\n\t \tif(highest==true)ans++;\n\t }\n\t System.out.println(ans);\n\t \n\t }\n\t}", "language": "Java", "metadata": {"date": 1588555069, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02689.html", "problem_id": "p02689", "resource_group": "high_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/Java/s065543593.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s065543593", "user_id": "u795978684"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\timport java.util.*;\n\timport java.util.Map.Entry;\n\t \n\t \n\t class Main {\n\t\t static int mod = (int) (Math.pow(10,9)+7);\n\t\t static List> list = new ArrayList>();\n\t public static void main(String[] args) {\n\t \t\n\t Scanner sc = new Scanner(System.in);\n\t int N = sc.nextInt();\t\n\t int M = sc.nextInt();\n\t long[] H = new long[N];\n\t for(int i=0;i());\n\t for(int i=0;i=H[i])highest=false;\n\t \t}\n\t \tif(highest==true)ans++;\n\t }\n\t System.out.println(ans);\n\t \n\t }\n\t}", "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": 1003, "cpu_time_ms": 967, "memory_kb": 76500}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s714187281", "group_id": "codeNet:p02689", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) \n\t{\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint m = sc.nextInt();\n\t\t\n\t\tlong[] a = new long[n];\n\t\t\n\t\tfor(int i = 0; i < n; i++)\n\t\t{\n\t\t\ta[i] = sc.nextLong();\n\t\t}\n\t\t\n\t\tboolean[] bad = new boolean[n];\n\t\tfor(int i = 0; i < m; i++)\n\t\t{\n\t\t\tint ta = sc.nextInt()-1;\n\t\t\tint tb = sc.nextInt()-1;\n\t\t\t\n\t\t\tif(a[ta] >= a[tb]) //b is bad\n\t\t\t{\n\t\t\t\tbad[tb] = true;\n\t\t\t}\n\t\t\tif(a[tb] >= a[ta]) //a is bad\n\t\t\t{\n\t\t\t\tbad[ta] = true;\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\tint c = 0;\n\t\tfor(int i = 0; i < n; i++)\n\t\t{\n\t\t\tif(!bad[i])c++;\n\t\t}\n\t\tSystem.out.println(c);\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1588554518, "filename_ext": "java", "original_language": "Java (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02689.html", "problem_id": "p02689", "resource_group": "high_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/Java/s714187281.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s714187281", "user_id": "u245815044"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) \n\t{\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint m = sc.nextInt();\n\t\t\n\t\tlong[] a = new long[n];\n\t\t\n\t\tfor(int i = 0; i < n; i++)\n\t\t{\n\t\t\ta[i] = sc.nextLong();\n\t\t}\n\t\t\n\t\tboolean[] bad = new boolean[n];\n\t\tfor(int i = 0; i < m; i++)\n\t\t{\n\t\t\tint ta = sc.nextInt()-1;\n\t\t\tint tb = sc.nextInt()-1;\n\t\t\t\n\t\t\tif(a[ta] >= a[tb]) //b is bad\n\t\t\t{\n\t\t\t\tbad[tb] = true;\n\t\t\t}\n\t\t\tif(a[tb] >= a[ta]) //a is bad\n\t\t\t{\n\t\t\t\tbad[ta] = true;\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\tint c = 0;\n\t\tfor(int i = 0; i < n; i++)\n\t\t{\n\t\t\tif(!bad[i])c++;\n\t\t}\n\t\tSystem.out.println(c);\n\t}\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i.\nThere are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.\n\nObs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road.\nNote that Obs. i is also good when no observatory can be reached from Obs. i using just one road.\n\nHow many good observatories are there?\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq H_i \\leq 10^9\n\n1 \\leq A_i,B_i \\leq N\n\nA_i \\neq B_i\n\nMultiple roads may connect the same pair of observatories.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nH_1 H_2 ... H_N\nA_1 B_1\nA_2 B_2\n:\nA_M B_M\n\nOutput\n\nPrint the number of good observatories.\n\nSample Input 1\n\n4 3\n1 2 3 4\n1 3\n2 3\n2 4\n\nSample Output 1\n\n2\n\nFrom Obs. 1, you can reach Obs. 3 using just one road. The elevation of Obs. 1 is not higher than that of Obs. 3, so Obs. 1 is not good.\n\nFrom Obs. 2, you can reach Obs. 3 and 4 using just one road. The elevation of Obs. 2 is not higher than that of Obs. 3, so Obs. 2 is not good.\n\nFrom Obs. 3, you can reach Obs. 1 and 2 using just one road. The elevation of Obs. 3 is higher than those of Obs. 1 and 2, so Obs. 3 is good.\n\nFrom Obs. 4, you can reach Obs. 2 using just one road. The elevation of Obs. 4 is higher than that of Obs. 2, so Obs. 4 is good.\n\nThus, the good observatories are Obs. 3 and 4, so there are two good observatories.\n\nSample Input 2\n\n6 5\n8 6 9 1 2 1\n1 3\n4 2\n4 3\n4 6\n4 6\n\nSample Output 2\n\n3", "sample_input": "4 3\n1 2 3 4\n1 3\n2 3\n2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02689", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i.\nThere are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.\n\nObs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road.\nNote that Obs. i is also good when no observatory can be reached from Obs. i using just one road.\n\nHow many good observatories are there?\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq H_i \\leq 10^9\n\n1 \\leq A_i,B_i \\leq N\n\nA_i \\neq B_i\n\nMultiple roads may connect the same pair of observatories.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nH_1 H_2 ... H_N\nA_1 B_1\nA_2 B_2\n:\nA_M B_M\n\nOutput\n\nPrint the number of good observatories.\n\nSample Input 1\n\n4 3\n1 2 3 4\n1 3\n2 3\n2 4\n\nSample Output 1\n\n2\n\nFrom Obs. 1, you can reach Obs. 3 using just one road. The elevation of Obs. 1 is not higher than that of Obs. 3, so Obs. 1 is not good.\n\nFrom Obs. 2, you can reach Obs. 3 and 4 using just one road. The elevation of Obs. 2 is not higher than that of Obs. 3, so Obs. 2 is not good.\n\nFrom Obs. 3, you can reach Obs. 1 and 2 using just one road. The elevation of Obs. 3 is higher than those of Obs. 1 and 2, so Obs. 3 is good.\n\nFrom Obs. 4, you can reach Obs. 2 using just one road. The elevation of Obs. 4 is higher than that of Obs. 2, so Obs. 4 is good.\n\nThus, the good observatories are Obs. 3 and 4, so there are two good observatories.\n\nSample Input 2\n\n6 5\n8 6 9 1 2 1\n1 3\n4 2\n4 3\n4 6\n4 6\n\nSample Output 2\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 595, "memory_kb": 50388}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s001386667", "group_id": "codeNet:p02691", "input_text": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tPrintWriter pw = new PrintWriter(System.out);\n\t\tint n=sc.nextInt();\n\t\tint a[]=sc.intArr(n);\n\t\tHashMap hm=new HashMap<>();\n\t\tlong ans=0;\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tif(hm.containsKey(a[i]-(i-1))) {\n\t\t\t\tans+=hm.get(a[i]-(i-1));\n\t\t\t}\n\t\t\thm.put(1-a[i]-i, hm.getOrDefault(1-a[i]-i, 0)+1);\n\t\t}\n\t\tpw.println(ans);\n\t\tpw.flush();\n\n\t}\n\n\t/////////////////////////////////////////////////////////////////////////////////////////////////////////////\n\n\tstatic class pair implements Comparable {\n\t\tint x, y;\n\n\t\tpair(int s, int d) {\n\t\t\tx = s;\n\t\t\ty = d;\n\t\t}\n\n\t\t@Override\n\t\tpublic int compareTo(pair p) {\n\t\t\treturn (x == p.x && y == p.y) ? 0 : 1;\n\t\t}\n\n\t\t@Override\n\t\tpublic String toString() {\n\t\t\treturn x + \" \" + y;\n\n\t\t}\n\t}\n\t\n\tstatic long mod(long ans, int mod) {\n\t\treturn (ans % mod + mod) % mod;\n\t}\n\n\tstatic long gcd(long a, long b) {\n\t\tif (a == 0)\n\t\t\treturn b;\n\t\treturn gcd(b % a, a);\n\t}\n\n\tstatic long lcm(long a, long b) {\n\t\treturn (a * b) / gcd(a, b);\n\t}\n\n\tpublic static int log(int n, int base) {\n\t\tint ans = 0;\n\t\twhile (n + 1 > base) {\n\t\t\tans++;\n\t\t\tn /= base;\n\t\t}\n\t\treturn ans;\n\t}\n\n\tstatic long pow(long b, long e) {\n\t\tlong ans = 1;\n\t\twhile (e > 0) {\n\t\t\tif ((e & 1) == 1)\n\t\t\t\tans = ((ans * 1l * b));\n\t\t\te >>= 1;\n\t\t\t{\n\n\t\t\t}\n\t\t\tb = ((b * 1l * b));\n\t\t}\n\t\treturn ans;\n\t}\n\n\tstatic int powmod(int b, long e, int mod) {\n\t\tint ans = 1;\n\t\tb %= mod;\n\t\twhile (e > 0) {\n\t\t\tif ((e & 1) == 1)\n\t\t\t\tans = (int) ((ans * 1l * b) % mod);\n\t\t\te >>= 1;\n\t\t\tb = (int) ((b * 1l * b) % mod);\n\t\t}\n\t\treturn ans;\n\t}\n\n\n\n\tstatic int ceil(int a, int b) {\n\t\tint ans = a / b;\n\t\treturn a % b == 0 ? ans : ans + 1;\n\t}\n\n\tstatic long ceil(long a, long b) {\n\t\tlong ans = a / b;\n\t\treturn a % b == 0 ? ans : ans + 1;\n\t}\n\n\t// Returns nCr % p\n\tstatic int nCrModp(int n, int r, int p) {\n\t\tif (r > n - r)\n\t\t\tr = n - r;\n\n\t\t// The array C is going to store last\n\t\t// row of pascal triangle at the end.\n\t\t// And last entry of last row is nCr\n\t\tint C[] = new int[r + 1];\n\n\t\tC[0] = 1; // Top row of Pascal Triangle\n\n\t\t// One by constructs remaining rows of Pascal\n\t\t// Triangle from top to bottom\n\t\tfor (int i = 1; i <= n; i++) {\n\n\t\t\t// Fill entries of current row using previous\n\t\t\t// row values\n\t\t\tfor (int j = Math.min(i, r); j > 0; j--)\n\n\t\t\t\t// nCj = (n-1)Cj + (n-1)C(j-1);\n\t\t\t\tC[j] = (C[j] + C[j - 1]) % p;\n\t\t}\n\t\treturn C[r];\n\t}\n\n\t\n\tstatic class Scanner {\n\t\tStringTokenizer st;\n\t\tBufferedReader br;\n\n\t\tpublic Scanner(InputStream s) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(s));\n\t\t}\n\n\t\tpublic Scanner(String file) throws Exception {\n\t\t\tbr = new BufferedReader(new FileReader(file));\n\t\t}\n\n\t\tpublic int[] intArr(int n) throws IOException {\n\t\t\tint a[] = new int[n];\n\t\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\t\ta[i] = nextInt();\n\t\t\t}\n\t\t\treturn a;\n\t\t}\n\n\t\tpublic long[] longArr(int n) throws IOException {\n\t\t\tlong a[] = new long[n];\n\t\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\t\ta[i] = nextLong();\n\t\t\t}\n\t\t\treturn a;\n\t\t}\n\n\t\tpublic String next() throws IOException {\n\t\t\twhile (st == null || !st.hasMoreTokens())\n\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tpublic int nextInt() throws IOException {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tpublic long nextLong() throws IOException {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tpublic String nextLine() throws IOException {\n\t\t\treturn br.readLine();\n\t\t}\n\n\t\tpublic double nextDouble() throws IOException {\n\t\t\tString x = next();\n\t\t\tStringBuilder sb = new StringBuilder(\"0\");\n\t\t\tdouble res = 0, f = 1;\n\t\t\tboolean dec = false, neg = false;\n\t\t\tint start = 0;\n\t\t\tif (x.charAt(0) == '-') {\n\t\t\t\tneg = true;\n\t\t\t\tstart++;\n\t\t\t}\n\t\t\tfor (int i = start; i < x.length(); i++)\n\t\t\t\tif (x.charAt(i) == '.') {\n\t\t\t\t\tres = Long.parseLong(sb.toString());\n\t\t\t\t\tsb = new StringBuilder(\"0\");\n\t\t\t\t\tdec = true;\n\t\t\t\t} else {\n\t\t\t\t\tsb.append(x.charAt(i));\n\t\t\t\t\tif (dec)\n\t\t\t\t\t\tf *= 10;\n\t\t\t\t}\n\t\t\tres += Long.parseLong(sb.toString()) / f;\n\t\t\treturn res * (neg ? -1 : 1);\n\t\t}\n\n\t\tpublic boolean ready() throws IOException {\n\t\t\treturn br.ready();\n\t\t}\n\n\t}\n\n\tpublic static void shuffle(int[] a) {\n\t\tint n = a.length;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tint r = i + (int) (Math.random() * (n - i));\n\t\t\tint tmp = a[i];\n\t\t\ta[i] = a[r];\n\t\t\ta[r] = tmp;\n\t\t}\n\t}\n\n}", "language": "Java", "metadata": {"date": 1595486113, "filename_ext": "java", "original_language": "Java (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02691.html", "problem_id": "p02691", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02691/input.txt", "sample_output_relpath": "derived/input_output/data/p02691/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02691/Java/s001386667.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s001386667", "user_id": "u863370423"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tPrintWriter pw = new PrintWriter(System.out);\n\t\tint n=sc.nextInt();\n\t\tint a[]=sc.intArr(n);\n\t\tHashMap hm=new HashMap<>();\n\t\tlong ans=0;\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tif(hm.containsKey(a[i]-(i-1))) {\n\t\t\t\tans+=hm.get(a[i]-(i-1));\n\t\t\t}\n\t\t\thm.put(1-a[i]-i, hm.getOrDefault(1-a[i]-i, 0)+1);\n\t\t}\n\t\tpw.println(ans);\n\t\tpw.flush();\n\n\t}\n\n\t/////////////////////////////////////////////////////////////////////////////////////////////////////////////\n\n\tstatic class pair implements Comparable {\n\t\tint x, y;\n\n\t\tpair(int s, int d) {\n\t\t\tx = s;\n\t\t\ty = d;\n\t\t}\n\n\t\t@Override\n\t\tpublic int compareTo(pair p) {\n\t\t\treturn (x == p.x && y == p.y) ? 0 : 1;\n\t\t}\n\n\t\t@Override\n\t\tpublic String toString() {\n\t\t\treturn x + \" \" + y;\n\n\t\t}\n\t}\n\t\n\tstatic long mod(long ans, int mod) {\n\t\treturn (ans % mod + mod) % mod;\n\t}\n\n\tstatic long gcd(long a, long b) {\n\t\tif (a == 0)\n\t\t\treturn b;\n\t\treturn gcd(b % a, a);\n\t}\n\n\tstatic long lcm(long a, long b) {\n\t\treturn (a * b) / gcd(a, b);\n\t}\n\n\tpublic static int log(int n, int base) {\n\t\tint ans = 0;\n\t\twhile (n + 1 > base) {\n\t\t\tans++;\n\t\t\tn /= base;\n\t\t}\n\t\treturn ans;\n\t}\n\n\tstatic long pow(long b, long e) {\n\t\tlong ans = 1;\n\t\twhile (e > 0) {\n\t\t\tif ((e & 1) == 1)\n\t\t\t\tans = ((ans * 1l * b));\n\t\t\te >>= 1;\n\t\t\t{\n\n\t\t\t}\n\t\t\tb = ((b * 1l * b));\n\t\t}\n\t\treturn ans;\n\t}\n\n\tstatic int powmod(int b, long e, int mod) {\n\t\tint ans = 1;\n\t\tb %= mod;\n\t\twhile (e > 0) {\n\t\t\tif ((e & 1) == 1)\n\t\t\t\tans = (int) ((ans * 1l * b) % mod);\n\t\t\te >>= 1;\n\t\t\tb = (int) ((b * 1l * b) % mod);\n\t\t}\n\t\treturn ans;\n\t}\n\n\n\n\tstatic int ceil(int a, int b) {\n\t\tint ans = a / b;\n\t\treturn a % b == 0 ? ans : ans + 1;\n\t}\n\n\tstatic long ceil(long a, long b) {\n\t\tlong ans = a / b;\n\t\treturn a % b == 0 ? ans : ans + 1;\n\t}\n\n\t// Returns nCr % p\n\tstatic int nCrModp(int n, int r, int p) {\n\t\tif (r > n - r)\n\t\t\tr = n - r;\n\n\t\t// The array C is going to store last\n\t\t// row of pascal triangle at the end.\n\t\t// And last entry of last row is nCr\n\t\tint C[] = new int[r + 1];\n\n\t\tC[0] = 1; // Top row of Pascal Triangle\n\n\t\t// One by constructs remaining rows of Pascal\n\t\t// Triangle from top to bottom\n\t\tfor (int i = 1; i <= n; i++) {\n\n\t\t\t// Fill entries of current row using previous\n\t\t\t// row values\n\t\t\tfor (int j = Math.min(i, r); j > 0; j--)\n\n\t\t\t\t// nCj = (n-1)Cj + (n-1)C(j-1);\n\t\t\t\tC[j] = (C[j] + C[j - 1]) % p;\n\t\t}\n\t\treturn C[r];\n\t}\n\n\t\n\tstatic class Scanner {\n\t\tStringTokenizer st;\n\t\tBufferedReader br;\n\n\t\tpublic Scanner(InputStream s) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(s));\n\t\t}\n\n\t\tpublic Scanner(String file) throws Exception {\n\t\t\tbr = new BufferedReader(new FileReader(file));\n\t\t}\n\n\t\tpublic int[] intArr(int n) throws IOException {\n\t\t\tint a[] = new int[n];\n\t\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\t\ta[i] = nextInt();\n\t\t\t}\n\t\t\treturn a;\n\t\t}\n\n\t\tpublic long[] longArr(int n) throws IOException {\n\t\t\tlong a[] = new long[n];\n\t\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\t\ta[i] = nextLong();\n\t\t\t}\n\t\t\treturn a;\n\t\t}\n\n\t\tpublic String next() throws IOException {\n\t\t\twhile (st == null || !st.hasMoreTokens())\n\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tpublic int nextInt() throws IOException {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tpublic long nextLong() throws IOException {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tpublic String nextLine() throws IOException {\n\t\t\treturn br.readLine();\n\t\t}\n\n\t\tpublic double nextDouble() throws IOException {\n\t\t\tString x = next();\n\t\t\tStringBuilder sb = new StringBuilder(\"0\");\n\t\t\tdouble res = 0, f = 1;\n\t\t\tboolean dec = false, neg = false;\n\t\t\tint start = 0;\n\t\t\tif (x.charAt(0) == '-') {\n\t\t\t\tneg = true;\n\t\t\t\tstart++;\n\t\t\t}\n\t\t\tfor (int i = start; i < x.length(); i++)\n\t\t\t\tif (x.charAt(i) == '.') {\n\t\t\t\t\tres = Long.parseLong(sb.toString());\n\t\t\t\t\tsb = new StringBuilder(\"0\");\n\t\t\t\t\tdec = true;\n\t\t\t\t} else {\n\t\t\t\t\tsb.append(x.charAt(i));\n\t\t\t\t\tif (dec)\n\t\t\t\t\t\tf *= 10;\n\t\t\t\t}\n\t\t\tres += Long.parseLong(sb.toString()) / f;\n\t\t\treturn res * (neg ? -1 : 1);\n\t\t}\n\n\t\tpublic boolean ready() throws IOException {\n\t\t\treturn br.ready();\n\t\t}\n\n\t}\n\n\tpublic static void shuffle(int[] a) {\n\t\tint n = a.length;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tint r = i + (int) (Math.random() * (n - i));\n\t\t\tint tmp = a[i];\n\t\t\ta[i] = a[r];\n\t\t\ta[r] = tmp;\n\t\t}\n\t}\n\n}", "problem_context": "Score: 500 points\n\nProblem Statement\n\nYou are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.\n\nThere are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.\n\nAccording to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.\n\nThe absolute difference of their attendee numbers is equal to the sum of their heights.\n\nThere are \\frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?\n\nP.S.: We cannot let you know the secret.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the number of pairs satisfying the condition.\n\nSample Input 1\n\n6\n2 3 3 1 3 1\n\nSample Output 1\n\n3\n\nA_1 + A_4 = 3, so the pair of Attendee 1 and 4 satisfy the condition.\n\nA_2 + A_6 = 4, so the pair of Attendee 2 and 6 satisfy the condition.\n\nA_4 + A_6 = 2, so the pair of Attendee 4 and 6 satisfy the condition.\n\nNo other pair satisfies the condition, so you should print 3.\n\nSample Input 2\n\n6\n5 2 4 2 8 8\n\nSample Output 2\n\n0\n\nNo pair satisfies the condition, so you should print 0.\n\nSample Input 3\n\n32\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5\n\nSample Output 3\n\n22", "sample_input": "6\n2 3 3 1 3 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02691", "source_text": "Score: 500 points\n\nProblem Statement\n\nYou are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.\n\nThere are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.\n\nAccording to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.\n\nThe absolute difference of their attendee numbers is equal to the sum of their heights.\n\nThere are \\frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?\n\nP.S.: We cannot let you know the secret.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the number of pairs satisfying the condition.\n\nSample Input 1\n\n6\n2 3 3 1 3 1\n\nSample Output 1\n\n3\n\nA_1 + A_4 = 3, so the pair of Attendee 1 and 4 satisfy the condition.\n\nA_2 + A_6 = 4, so the pair of Attendee 2 and 6 satisfy the condition.\n\nA_4 + A_6 = 2, so the pair of Attendee 4 and 6 satisfy the condition.\n\nNo other pair satisfies the condition, so you should print 3.\n\nSample Input 2\n\n6\n5 2 4 2 8 8\n\nSample Output 2\n\n0\n\nNo pair satisfies the condition, so you should print 0.\n\nSample Input 3\n\n32\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5\n\nSample Output 3\n\n22", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4339, "cpu_time_ms": 310, "memory_kb": 55248}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s334182268", "group_id": "codeNet:p02691", "input_text": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tint N = scan.nextInt();\n\n\t\tint[] Aheight = new int[N];\n\t\tfor (int j = 0; j < N; j++) {\n\t\t\tAheight[j] = scan.nextInt();\n\t\t}\n\n\t\tint count = 0;\n\n\t\tfor (int first = 0; first < N-2; first++) {\n\t\t\tint h = Aheight[first];\n\t\t\tfor (int number_from_first = Aheight[first] + 1; number_from_first < N - first; number_from_first++) {\n\t\t\t\tif (number_from_first == Aheight[first+number_from_first] + h) {\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(count);\n\n\t}\n}", "language": "Java", "metadata": {"date": 1589122153, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02691.html", "problem_id": "p02691", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02691/input.txt", "sample_output_relpath": "derived/input_output/data/p02691/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02691/Java/s334182268.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s334182268", "user_id": "u989935918"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tint N = scan.nextInt();\n\n\t\tint[] Aheight = new int[N];\n\t\tfor (int j = 0; j < N; j++) {\n\t\t\tAheight[j] = scan.nextInt();\n\t\t}\n\n\t\tint count = 0;\n\n\t\tfor (int first = 0; first < N-2; first++) {\n\t\t\tint h = Aheight[first];\n\t\t\tfor (int number_from_first = Aheight[first] + 1; number_from_first < N - first; number_from_first++) {\n\t\t\t\tif (number_from_first == Aheight[first+number_from_first] + h) {\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(count);\n\n\t}\n}", "problem_context": "Score: 500 points\n\nProblem Statement\n\nYou are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.\n\nThere are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.\n\nAccording to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.\n\nThe absolute difference of their attendee numbers is equal to the sum of their heights.\n\nThere are \\frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?\n\nP.S.: We cannot let you know the secret.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the number of pairs satisfying the condition.\n\nSample Input 1\n\n6\n2 3 3 1 3 1\n\nSample Output 1\n\n3\n\nA_1 + A_4 = 3, so the pair of Attendee 1 and 4 satisfy the condition.\n\nA_2 + A_6 = 4, so the pair of Attendee 2 and 6 satisfy the condition.\n\nA_4 + A_6 = 2, so the pair of Attendee 4 and 6 satisfy the condition.\n\nNo other pair satisfies the condition, so you should print 3.\n\nSample Input 2\n\n6\n5 2 4 2 8 8\n\nSample Output 2\n\n0\n\nNo pair satisfies the condition, so you should print 0.\n\nSample Input 3\n\n32\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5\n\nSample Output 3\n\n22", "sample_input": "6\n2 3 3 1 3 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02691", "source_text": "Score: 500 points\n\nProblem Statement\n\nYou are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.\n\nThere are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.\n\nAccording to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.\n\nThe absolute difference of their attendee numbers is equal to the sum of their heights.\n\nThere are \\frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?\n\nP.S.: We cannot let you know the secret.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the number of pairs satisfying the condition.\n\nSample Input 1\n\n6\n2 3 3 1 3 1\n\nSample Output 1\n\n3\n\nA_1 + A_4 = 3, so the pair of Attendee 1 and 4 satisfy the condition.\n\nA_2 + A_6 = 4, so the pair of Attendee 2 and 6 satisfy the condition.\n\nA_4 + A_6 = 2, so the pair of Attendee 4 and 6 satisfy the condition.\n\nNo other pair satisfies the condition, so you should print 3.\n\nSample Input 2\n\n6\n5 2 4 2 8 8\n\nSample Output 2\n\n0\n\nNo pair satisfies the condition, so you should print 0.\n\nSample Input 3\n\n32\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5\n\nSample Output 3\n\n22", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 599, "cpu_time_ms": 2208, "memory_kb": 60376}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s512417456", "group_id": "codeNet:p02691", "input_text": "\nimport java.util.HashMap;\nimport java.util.Map;\n\npublic class Main {\n\n private static void solve() {\n int n = ni();\n int[] a = na(n);\n\n int[] b = new int[n];\n int[] c = new int[n];\n for (int i = 0; i < n; i++) {\n b[i] = a[i] - i;\n c[i] = a[i] + i;\n }\n\n Map cnt = new HashMap<>();\n long ret = 0;\n for (int i = 0; i < n; i++) {\n if (cnt.containsKey(-b[i])) {\n ret += cnt.get(-b[i]);\n }\n cnt.putIfAbsent(c[i], 0);\n cnt.put(c[i], cnt.get(c[i]) + 1);\n }\n System.out.println(ret);\n }\n\n public static void main(String[] args) {\n new Thread(null, new Runnable() {\n @Override\n public void run() {\n long start = System.currentTimeMillis();\n String debug = args.length > 0 ? args[0] : null;\n if (debug != null) {\n try {\n is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));\n } catch (Exception e) {\n throw new RuntimeException(e);\n }\n }\n reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);\n solve();\n out.flush();\n tr((System.currentTimeMillis() - start) + \"ms\");\n }\n }, \"\", 64000000).start();\n }\n\n private static java.io.InputStream is = System.in;\n private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);\n private static java.util.StringTokenizer tokenizer = null;\n private static java.io.BufferedReader reader;\n\n public static String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new java.util.StringTokenizer(reader.readLine());\n } catch (Exception e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n private static double nd() {\n return Double.parseDouble(next());\n }\n\n private static long nl() {\n return Long.parseLong(next());\n }\n\n private static int[] na(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = ni();\n return a;\n }\n\n private static char[] ns() {\n return next().toCharArray();\n }\n\n private static long[] nal(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = nl();\n return a;\n }\n\n private static int[][] ntable(int n, int m) {\n int[][] table = new int[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n table[i][j] = ni();\n }\n }\n return table;\n }\n\n private static int[][] nlist(int n, int m) {\n int[][] table = new int[m][n];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n table[j][i] = ni();\n }\n }\n return table;\n }\n\n private static int ni() {\n return Integer.parseInt(next());\n }\n\n private static void tr(Object... o) {\n if (is != System.in)\n System.out.println(java.util.Arrays.deepToString(o));\n }\n}\n\n", "language": "Java", "metadata": {"date": 1588585181, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02691.html", "problem_id": "p02691", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02691/input.txt", "sample_output_relpath": "derived/input_output/data/p02691/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02691/Java/s512417456.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s512417456", "user_id": "u769201746"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "\nimport java.util.HashMap;\nimport java.util.Map;\n\npublic class Main {\n\n private static void solve() {\n int n = ni();\n int[] a = na(n);\n\n int[] b = new int[n];\n int[] c = new int[n];\n for (int i = 0; i < n; i++) {\n b[i] = a[i] - i;\n c[i] = a[i] + i;\n }\n\n Map cnt = new HashMap<>();\n long ret = 0;\n for (int i = 0; i < n; i++) {\n if (cnt.containsKey(-b[i])) {\n ret += cnt.get(-b[i]);\n }\n cnt.putIfAbsent(c[i], 0);\n cnt.put(c[i], cnt.get(c[i]) + 1);\n }\n System.out.println(ret);\n }\n\n public static void main(String[] args) {\n new Thread(null, new Runnable() {\n @Override\n public void run() {\n long start = System.currentTimeMillis();\n String debug = args.length > 0 ? args[0] : null;\n if (debug != null) {\n try {\n is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));\n } catch (Exception e) {\n throw new RuntimeException(e);\n }\n }\n reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);\n solve();\n out.flush();\n tr((System.currentTimeMillis() - start) + \"ms\");\n }\n }, \"\", 64000000).start();\n }\n\n private static java.io.InputStream is = System.in;\n private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);\n private static java.util.StringTokenizer tokenizer = null;\n private static java.io.BufferedReader reader;\n\n public static String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new java.util.StringTokenizer(reader.readLine());\n } catch (Exception e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n private static double nd() {\n return Double.parseDouble(next());\n }\n\n private static long nl() {\n return Long.parseLong(next());\n }\n\n private static int[] na(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = ni();\n return a;\n }\n\n private static char[] ns() {\n return next().toCharArray();\n }\n\n private static long[] nal(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = nl();\n return a;\n }\n\n private static int[][] ntable(int n, int m) {\n int[][] table = new int[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n table[i][j] = ni();\n }\n }\n return table;\n }\n\n private static int[][] nlist(int n, int m) {\n int[][] table = new int[m][n];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n table[j][i] = ni();\n }\n }\n return table;\n }\n\n private static int ni() {\n return Integer.parseInt(next());\n }\n\n private static void tr(Object... o) {\n if (is != System.in)\n System.out.println(java.util.Arrays.deepToString(o));\n }\n}\n\n", "problem_context": "Score: 500 points\n\nProblem Statement\n\nYou are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.\n\nThere are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.\n\nAccording to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.\n\nThe absolute difference of their attendee numbers is equal to the sum of their heights.\n\nThere are \\frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?\n\nP.S.: We cannot let you know the secret.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the number of pairs satisfying the condition.\n\nSample Input 1\n\n6\n2 3 3 1 3 1\n\nSample Output 1\n\n3\n\nA_1 + A_4 = 3, so the pair of Attendee 1 and 4 satisfy the condition.\n\nA_2 + A_6 = 4, so the pair of Attendee 2 and 6 satisfy the condition.\n\nA_4 + A_6 = 2, so the pair of Attendee 4 and 6 satisfy the condition.\n\nNo other pair satisfies the condition, so you should print 3.\n\nSample Input 2\n\n6\n5 2 4 2 8 8\n\nSample Output 2\n\n0\n\nNo pair satisfies the condition, so you should print 0.\n\nSample Input 3\n\n32\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5\n\nSample Output 3\n\n22", "sample_input": "6\n2 3 3 1 3 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02691", "source_text": "Score: 500 points\n\nProblem Statement\n\nYou are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.\n\nThere are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.\n\nAccording to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.\n\nThe absolute difference of their attendee numbers is equal to the sum of their heights.\n\nThere are \\frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?\n\nP.S.: We cannot let you know the secret.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the number of pairs satisfying the condition.\n\nSample Input 1\n\n6\n2 3 3 1 3 1\n\nSample Output 1\n\n3\n\nA_1 + A_4 = 3, so the pair of Attendee 1 and 4 satisfy the condition.\n\nA_2 + A_6 = 4, so the pair of Attendee 2 and 6 satisfy the condition.\n\nA_4 + A_6 = 2, so the pair of Attendee 4 and 6 satisfy the condition.\n\nNo other pair satisfies the condition, so you should print 3.\n\nSample Input 2\n\n6\n5 2 4 2 8 8\n\nSample Output 2\n\n0\n\nNo pair satisfies the condition, so you should print 0.\n\nSample Input 3\n\n32\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5\n\nSample Output 3\n\n22", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2910, "cpu_time_ms": 453, "memory_kb": 67084}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s319200983", "group_id": "codeNet:p02693", "input_text": "import java.util.Scanner;\npublic class Main {\n public static void main(String[] args){\n\n Scanner scan = new Scanner(System.in);\n int K = scan.nextInt();\n int A = scan.nextInt();\n int B = scan.nextInt();\n\n if(A%K==0 || B-A+A%K > K){\n System.out.println(\"OK\");\n }\n else {\n System.out.println(\"NG\");\n }\n }\n}\n\n", "language": "Java", "metadata": {"date": 1589229056, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02693.html", "problem_id": "p02693", "resource_group": "high_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/Java/s319200983.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s319200983", "user_id": "u044982943"}, "prompt_components": {"gold_output": "OK\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main {\n public static void main(String[] args){\n\n Scanner scan = new Scanner(System.in);\n int K = scan.nextInt();\n int A = scan.nextInt();\n int B = scan.nextInt();\n\n if(A%K==0 || B-A+A%K > K){\n System.out.println(\"OK\");\n }\n else {\n System.out.println(\"NG\");\n }\n }\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": 390, "cpu_time_ms": 111, "memory_kb": 35636}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s943325060", "group_id": "codeNet:p02693", "input_text": "/******************************************************************************\n\n Online Java Compiler.\n Code, Compile, Run and Debug java program online.\nWrite your code in this editor and press \"Run\" button to execute it.\n7\n500 600\n*******************************************************************************/\nimport java.util.*;\npublic class Main\n{\n\tpublic static void main(String[] args) {\n\tScanner sc = new Scanner(System.in);\n\tint k = sc.nextInt();\n\tint a = sc.nextInt();\n\tint b = sc.nextInt();\n\tboolean flag = false;\n\tfor(int i = a;i<= b;i++){\n\t if(i%k == 0){\n\t flag = true;\n\t break;\n\t }\n\t \n\t }\n\t \n\t if(!flag){\n\t System.out.println(\"NG\");\n\t }else\n\t System.out.println(\"OK\");\n\t}\n\t\n\t}\n\n", "language": "Java", "metadata": {"date": 1588468731, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02693.html", "problem_id": "p02693", "resource_group": "high_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/Java/s943325060.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s943325060", "user_id": "u710255953"}, "prompt_components": {"gold_output": "OK\n", "input_to_evaluate": "/******************************************************************************\n\n Online Java Compiler.\n Code, Compile, Run and Debug java program online.\nWrite your code in this editor and press \"Run\" button to execute it.\n7\n500 600\n*******************************************************************************/\nimport java.util.*;\npublic class Main\n{\n\tpublic static void main(String[] args) {\n\tScanner sc = new Scanner(System.in);\n\tint k = sc.nextInt();\n\tint a = sc.nextInt();\n\tint b = sc.nextInt();\n\tboolean flag = false;\n\tfor(int i = a;i<= b;i++){\n\t if(i%k == 0){\n\t flag = true;\n\t break;\n\t }\n\t \n\t }\n\t \n\t if(!flag){\n\t System.out.println(\"NG\");\n\t }else\n\t System.out.println(\"OK\");\n\t}\n\t\n\t}\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": 784, "cpu_time_ms": 107, "memory_kb": 35808}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s674796806", "group_id": "codeNet:p02693", "input_text": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int k = sc.nextInt();\n int a = sc.nextInt();\n int b = sc.nextInt();\n String answer = \"NG\";\n\n for(int i = a;i<=b;i++){\n if(i%k==0){\n answer = \"OK\";\n break;\n }\n }\n System.out.print(answer);\n }\n}", "language": "Java", "metadata": {"date": 1588468476, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02693.html", "problem_id": "p02693", "resource_group": "high_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/Java/s674796806.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s674796806", "user_id": "u562668258"}, "prompt_components": {"gold_output": "OK\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int k = sc.nextInt();\n int a = sc.nextInt();\n int b = sc.nextInt();\n String answer = \"NG\";\n\n for(int i = a;i<=b;i++){\n if(i%k==0){\n answer = \"OK\";\n break;\n }\n }\n System.out.print(answer);\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": 434, "cpu_time_ms": 107, "memory_kb": 35772}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s491646438", "group_id": "codeNet:p02696", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.StringTokenizer;\n\npublic class Main {\n\n public static void main(String[] args) {\n FastReader fs = new FastReader();\n long a =fs.nextLong();\n long b = fs.nextLong();\n long n= fs.nextLong();\n\n\n\n System.out.println(b-1);\n\n\n }\n\n static class FastReader\n {\n BufferedReader br;\n StringTokenizer st;\n\n public FastReader()\n {\n br = new BufferedReader(new\n InputStreamReader(System.in));\n }\n\n String next()\n {\n while (st == null || !st.hasMoreElements())\n {\n try\n {\n st = new StringTokenizer(br.readLine());\n }\n catch (IOException e)\n {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt()\n {\n return Integer.parseInt(next());\n }\n\n long nextLong()\n {\n return Long.parseLong(next());\n }\n\n double nextDouble()\n {\n return Double.parseDouble(next());\n }\n\n String nextLine()\n {\n String str = \"\";\n try\n {\n str = br.readLine();\n }\n catch (IOException e)\n {\n e.printStackTrace();\n }\n return str;\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1588474160, "filename_ext": "java", "original_language": "Java (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02696.html", "problem_id": "p02696", "resource_group": "high_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/Java/s491646438.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s491646438", "user_id": "u728468951"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.StringTokenizer;\n\npublic class Main {\n\n public static void main(String[] args) {\n FastReader fs = new FastReader();\n long a =fs.nextLong();\n long b = fs.nextLong();\n long n= fs.nextLong();\n\n\n\n System.out.println(b-1);\n\n\n }\n\n static class FastReader\n {\n BufferedReader br;\n StringTokenizer st;\n\n public FastReader()\n {\n br = new BufferedReader(new\n InputStreamReader(System.in));\n }\n\n String next()\n {\n while (st == null || !st.hasMoreElements())\n {\n try\n {\n st = new StringTokenizer(br.readLine());\n }\n catch (IOException e)\n {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt()\n {\n return Integer.parseInt(next());\n }\n\n long nextLong()\n {\n return Long.parseLong(next());\n }\n\n double nextDouble()\n {\n return Double.parseDouble(next());\n }\n\n String nextLine()\n {\n String str = \"\";\n try\n {\n str = br.readLine();\n }\n catch (IOException e)\n {\n e.printStackTrace();\n }\n return str;\n }\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "sample_input": "5 7 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02696", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1558, "cpu_time_ms": 67, "memory_kb": 25348}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s061907922", "group_id": "codeNet:p02696", "input_text": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n\tstatic PrintWriter out;\n\tstatic StringBuilder sb;\n\tstatic int n, m, k;\n\tstatic long mod = 998244353;\n\tstatic Boolean[][][] memo;\n\tstatic String s;\n\tstatic HashSet nodes;\n\tstatic ArrayList[] ad;\n\tstatic boolean[] vis;\n\tstatic TreeSet al;\n\tstatic int[][] val;\n\tstatic int[] b;\n\tstatic int ans;\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tout = new PrintWriter(System.out);\n\t\tint a = sc.nextInt();\n\t\tlong b = sc.nextLong();\n\t\tlong n = sc.nextLong();\n\t\tlong ans = 0;\n\t\tfor (long i = 0; i <= Math.min(n, 100000000); i++) {\n\t\t\tans = Math.max(ans, (i * a) / b - a * (i / b));\n\t\t}\n\t\tfor (long i = n; i >= Math.max(0, n - 100000000); i--) {\n\t\t\tans = Math.max(ans, (i * a) / b - a * (i / b));\n\t\t}\n\t\tSystem.out.println(ans);\n\t\tout.flush();\n\t}\n\n\tstatic class Scanner {\n\t\tStringTokenizer st;\n\t\tBufferedReader br;\n\n\t\tpublic Scanner(InputStream system) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(system));\n\t\t}\n\n\t\tpublic Scanner(String file) throws Exception {\n\t\t\tbr = new BufferedReader(new FileReader(file));\n\t\t}\n\n\t\tpublic String next() throws IOException {\n\t\t\twhile (st == null || !st.hasMoreTokens())\n\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tpublic String nextLine() throws IOException {\n\t\t\treturn br.readLine();\n\t\t}\n\n\t\tpublic int nextInt() throws IOException {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tpublic double nextDouble() throws IOException {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tpublic char nextChar() throws IOException {\n\t\t\treturn next().charAt(0);\n\t\t}\n\n\t\tpublic Long nextLong() throws IOException {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tpublic int[] nextArrInt(int n) throws IOException {\n\t\t\tint[] a = new int[n];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\ta[i] = nextInt();\n\t\t\treturn a;\n\t\t}\n\n\t\tpublic long[] nextArrLong(int n) throws IOException {\n\t\t\tlong[] a = new long[n];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\ta[i] = nextLong();\n\t\t\treturn a;\n\t\t}\n\n\t\tpublic boolean ready() throws IOException {\n\t\t\treturn br.ready();\n\t\t}\n\n\t\tpublic void waitForInput() throws InterruptedException {\n\t\t\tThread.sleep(3000);\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1588471922, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02696.html", "problem_id": "p02696", "resource_group": "high_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/Java/s061907922.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s061907922", "user_id": "u217252547"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n\tstatic PrintWriter out;\n\tstatic StringBuilder sb;\n\tstatic int n, m, k;\n\tstatic long mod = 998244353;\n\tstatic Boolean[][][] memo;\n\tstatic String s;\n\tstatic HashSet nodes;\n\tstatic ArrayList[] ad;\n\tstatic boolean[] vis;\n\tstatic TreeSet al;\n\tstatic int[][] val;\n\tstatic int[] b;\n\tstatic int ans;\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tout = new PrintWriter(System.out);\n\t\tint a = sc.nextInt();\n\t\tlong b = sc.nextLong();\n\t\tlong n = sc.nextLong();\n\t\tlong ans = 0;\n\t\tfor (long i = 0; i <= Math.min(n, 100000000); i++) {\n\t\t\tans = Math.max(ans, (i * a) / b - a * (i / b));\n\t\t}\n\t\tfor (long i = n; i >= Math.max(0, n - 100000000); i--) {\n\t\t\tans = Math.max(ans, (i * a) / b - a * (i / b));\n\t\t}\n\t\tSystem.out.println(ans);\n\t\tout.flush();\n\t}\n\n\tstatic class Scanner {\n\t\tStringTokenizer st;\n\t\tBufferedReader br;\n\n\t\tpublic Scanner(InputStream system) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(system));\n\t\t}\n\n\t\tpublic Scanner(String file) throws Exception {\n\t\t\tbr = new BufferedReader(new FileReader(file));\n\t\t}\n\n\t\tpublic String next() throws IOException {\n\t\t\twhile (st == null || !st.hasMoreTokens())\n\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tpublic String nextLine() throws IOException {\n\t\t\treturn br.readLine();\n\t\t}\n\n\t\tpublic int nextInt() throws IOException {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tpublic double nextDouble() throws IOException {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tpublic char nextChar() throws IOException {\n\t\t\treturn next().charAt(0);\n\t\t}\n\n\t\tpublic Long nextLong() throws IOException {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tpublic int[] nextArrInt(int n) throws IOException {\n\t\t\tint[] a = new int[n];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\ta[i] = nextInt();\n\t\t\treturn a;\n\t\t}\n\n\t\tpublic long[] nextArrLong(int n) throws IOException {\n\t\t\tlong[] a = new long[n];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\ta[i] = nextLong();\n\t\t\treturn a;\n\t\t}\n\n\t\tpublic boolean ready() throws IOException {\n\t\t\treturn br.ready();\n\t\t}\n\n\t\tpublic void waitForInput() throws InterruptedException {\n\t\t\tThread.sleep(3000);\n\t\t}\n\t}\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": 2202, "cpu_time_ms": 2207, "memory_kb": 33772}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s649099124", "group_id": "codeNet:p02697", "input_text": "\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n final int N = sc.nextInt(), M = sc.nextInt();\n if(N % 2 == 1){\n for(int i=1;i<=M;i++){\n System.out.println(i + \" \" + (N-i));\n }\n }else{\n int half = N/2;\n for(int i=1;i<=M;i++){\n if(i % 2 == 1) {\n int j = i / 2 + 1;\n System.out.println(j + \" \" + (N + 1 - j));\n }else{\n int j = i / 2;\n System.out.println((half - j) + \" \" + (half + j));\n }\n }\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1590625645, "filename_ext": "java", "original_language": "Java (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02697.html", "problem_id": "p02697", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02697/input.txt", "sample_output_relpath": "derived/input_output/data/p02697/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02697/Java/s649099124.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s649099124", "user_id": "u793380652"}, "prompt_components": {"gold_output": "2 3\n", "input_to_evaluate": "\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n final int N = sc.nextInt(), M = sc.nextInt();\n if(N % 2 == 1){\n for(int i=1;i<=M;i++){\n System.out.println(i + \" \" + (N-i));\n }\n }else{\n int half = N/2;\n for(int i=1;i<=M;i++){\n if(i % 2 == 1) {\n int j = i / 2 + 1;\n System.out.println(j + \" \" + (N + 1 - j));\n }else{\n int j = i / 2;\n System.out.println((half - j) + \" \" + (half + j));\n }\n }\n }\n }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.)\nN players will participate in this competition, and they are given distinct integers from 1 through N.\nThe arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive).\nYou cannot assign the same integer to multiple playing fields.\nThe competition consists of N rounds, each of which proceeds as follows:\n\nFor each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.\n\nThen, each player adds 1 to its integer. If it becomes N+1, change it to 1.\n\nYou want to ensure that no player fights the same opponent more than once during the N rounds.\nPrint an assignment of integers to the playing fields satisfying this condition.\nIt can be proved that such an assignment always exists under the constraints given.\n\nConstraints\n\n1 \\leq M\n\nM \\times 2 +1 \\leq N \\leq 200000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint M lines in the format below.\nThe i-th line should contain the two integers a_i and b_i assigned to the i-th playing field.\n\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nSample Input 1\n\n4 1\n\nSample Output 1\n\n2 3\n\nLet us call the four players A, B, C, and D, and assume that they are initially given the integers 1, 2, 3, and 4, respectively.\n\nThe 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\nThe 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\nThe 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\nThe 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so this solution will be accepted.\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n1 6\n2 5\n3 4", "sample_input": "4 1\n"}, "reference_outputs": ["2 3\n"], "source_document_id": "p02697", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.)\nN players will participate in this competition, and they are given distinct integers from 1 through N.\nThe arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive).\nYou cannot assign the same integer to multiple playing fields.\nThe competition consists of N rounds, each of which proceeds as follows:\n\nFor each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.\n\nThen, each player adds 1 to its integer. If it becomes N+1, change it to 1.\n\nYou want to ensure that no player fights the same opponent more than once during the N rounds.\nPrint an assignment of integers to the playing fields satisfying this condition.\nIt can be proved that such an assignment always exists under the constraints given.\n\nConstraints\n\n1 \\leq M\n\nM \\times 2 +1 \\leq N \\leq 200000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint M lines in the format below.\nThe i-th line should contain the two integers a_i and b_i assigned to the i-th playing field.\n\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nSample Input 1\n\n4 1\n\nSample Output 1\n\n2 3\n\nLet us call the four players A, B, C, and D, and assume that they are initially given the integers 1, 2, 3, and 4, respectively.\n\nThe 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\nThe 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\nThe 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\nThe 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so this solution will be accepted.\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n1 6\n2 5\n3 4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 711, "cpu_time_ms": 528, "memory_kb": 46312}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s674768746", "group_id": "codeNet:p02699", "input_text": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.ArrayDeque;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.NoSuchElementException;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tnew Main().solve();\n\t\tpw.close();\n\t}\n\n\t/**\n\t * ASCII\n\t * 0 48\n\t * A 65\n\t * a 97\n\t */\n\n\tstatic PrintWriter pw = new PrintWriter(System.out);\n\n\tlong MOD = 1_000_000_007;\n\n\tvoid solve() {\n\t\tFastScanner sc = new FastScanner();\n\t\tint S = sc.nextInt();\n\t\tint W = sc.nextInt();\n\t\tif (W >= S) out(\"unsafe\");\n\t\telse out(\"safe\");\n\t}\n\t\n\tint[][] q;\n\tint ans;\n\n\tvoid func(int now, int pre, int N, int M, int[] A) {\n\t\tfor (int i = pre; i <= M; i++) {\n\t\t\tA[now] = i;\n\t\t\tif (now == N) {\n\t\t\t\tint p = 0;\n\t\t\t\tfor (int[] t : q) {\n\t\t\t\t\tif (A[t[1]] - A[t[0]] == t[2]) p += t[3];\n\t\t\t\t}\n\t\t\t\tans = Math.max(p, ans);\n\t\t\t} else {\n\t\t\t\tfunc(now+1, i, N, M , A);\n\t\t\t}\n\t\t}\n\t}\n\n\tdouble getD(double x1, double x2, double y1, double y2) {\n\t\treturn Math.sqrt(Math.pow(x1-x2,2) + Math.pow(y1-y2, 2));\n\t}\n\n\tint[][] d4 = new int[][] {{1,0},{0,1},{-1,0},{0,-1}};\n\tint[][] d8 = new int[][] {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};\n\n\tclass Data {\n\t\tint a;\n\t\tint b;\n\t\tint c;\n\t\tData(){}\n\t\tData(int a) {\n\t\t\tthis.a = a;\n\t\t}\n\t\tData(int a, int b, int c) {\n\t\t\tthis.a = a;\n\t\t\tthis.b = b;\n\t\t\tthis.c = c;\n\t\t}\n\t\tData(int a, int b) {\n\t\t\tthis.a = a;\n\t\t\tthis.b = b;\n\t\t}\n\t}\n\n\tclass Permutation {\n\t\tint[] array;\n\n\t\tPermutation(int N) {\n\t\t\tarray = new int[N];\n\t\t\tfor (int i = 0; i < N; i++) {\n\t\t\t\tarray[i] = i+1;\n\t\t\t}\n\t\t}\n\n\t\tboolean nextPermutation() {\n\t\t int i = array.length - 1;\n\t\t while (i > 0 && array[i - 1] >= array[i])\n\t\t i--;\n\t\t if (i <= 0)\n\t\t return false;\n\n\t\t int j = array.length - 1;\n\t\t while (array[j] <= array[i - 1])\n\t\t j--;\n\t\t int temp = array[i - 1];\n\t\t array[i - 1] = array[j];\n\t\t array[j] = temp;\n\n\t\t j = array.length - 1;\n\t\t while (i < j) {\n\t\t temp = array[i];\n\t\t array[i] = array[j];\n\t\t array[j] = temp;\n\t\t i++;\n\t\t j--;\n\t\t }\n\t\t return true;\n\t\t}\n\t}\n\n\tclass UnionFind {\n\t\tint[] parents;\n\t\tint[] counts;\n\n\t\tpublic UnionFind(int size) {\n\t\t\tparents = new int[size];\n\t\t\tcounts = new int[size];\n\t\t\tfor (int i = 0; i < size; i++) {\n\t\t\t\tparents[i] = i;\n\t\t\t\tcounts[i] = 1;\n\t\t\t}\n\t\t}\n\n\t\tpublic int find(int a) {\n\t\t\tif (parents[a] == a) return a;\n\t\t\tparents[a] = find(parents[a]);\n\t\t\treturn parents[a];\n\t\t}\n\n\t\tpublic void unite(int a, int b) {\n\t\t\ta = find(a);\n\t\t\tb = find(b);\n\t\t\tif (a == b) return;\n\t\t\tif (counts[a] < counts[b]) {\n\t\t\t\tparents[a] = b;\n\t\t\t\tcounts[b] += counts[a];\n\t\t\t} else {\n\t\t\t\tparents[b] = a;\n\t\t\t\tcounts[a] += counts[b];\n\t\t\t}\n\t\t}\n\n\t\tpublic boolean differ(int a, int b) {\n\t\t\ta = find(a);\n\t\t\tb = find(b);\n\t\t\treturn a != b;\n\t\t}\n\n\t\tpublic int count(int a) {\n\t\t\treturn counts[find(a)];\n\t\t}\n\t}\n\n\tclass Combination {\n\t\tfinal int mod;\n\t\tfinal int max;\n\n\t\tfinal long[] fact;\n\t\tfinal long[] inv;\n\t\tfinal long[] invfact;\n\n\t\tpublic Combination(int n) {\n\t\t\tthis(n, 1_000_000_007);\n\t\t}\n\n\t\tpublic Combination(int n, int mod) {\n\t\t\tthis.mod = mod;\n\t\t\tmax = n + 1;\n\t\t\tfact = new long[max];\n\t\t\tinvfact = new long[max];\n\t\t\tinv = new long[max];\n\n\t\t\tinv[1] = 1;\n\t\t\tfor (int i = 2; i < inv.length; i++) {\n\t\t\t\tinv[i] = inv[mod % i] * (mod - mod / i) % mod;\n\t\t\t}\n\n\t\t\tfact[0] = 1;\n\t\t\tinvfact[0] = 1;\n\t\t\tfor (int i = 1; i < inv.length; i++) {\n\t\t\t\tfact[i] = i * fact[i - 1] % mod;\n\t\t\t\tinvfact[i] = inv[i] * invfact[i - 1] % mod;\n\t\t\t}\n\t\t}\n\n\t\tpublic long get(int n, int r) {\n\t\t\treturn fact[n] * invfact[n - r] % mod * invfact[r] % mod;\n\t\t}\n\n\t\tpublic long gcd(long a, long b) {\n\t\t\tif (b == 0) return a;\n\t\t\telse {\n\t\t\t\tb %= MOD;\n\t\t\t\tif (b < 0) b+=MOD;\n\t\t\t\treturn gcd(b, (b-a*inv[(int)b]%MOD*b%MOD)%MOD);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic long gcd(long a, long b) {\n\t\tif (b == 0) return a;\n\t\telse return gcd(b, a%b);\n\t}\n\n\tpublic long getInv(long a) {\n\t\tlong b = MOD, u = 1, v = 0;\n\t\twhile (b > 0) {\n\t\t\tlong t = a / b;\n\t\t\ta -= t * b;\n\t\t\tlong tmp = a;\n\t\t\ta = b;\n\t\t\tb = tmp;\n\t\t\tu -= t * v;\n\t\t\ttmp = u;\n\t\t\tu = v;\n\t\t\tv = tmp;\n\t\t}\n\t\tu %= MOD;\n\t\tif (u < 0) u += MOD;\n\t\treturn u;\n\t}\n\n\tpublic long modPow(long n) {\n\t\tif (n == 0) return 1;\n\t\tlong x = modPow(n / 2);\n\t\tx *= x;\n\t\tx %= MOD;\n\t\tif (n % 2 == 1) x *= 2;\n\t\tx %= MOD;\n\t\treturn x;\n\t}\n\n\tpublic long choose(long n, long m) {\n\t\tlong deno = 1;\n\t\tlong nume = 1;\n\t\tm = (n - m < m ? n - m : m);\n\t\tfor (long i = 1; i <= m; i++) {\n\t\t\tdeno = deno * (n - i + 1) % MOD;\n\t\t\tnume = nume * i % MOD;\n\t\t}\n\t\treturn deno * getInv(nume) % MOD;\n\t}\n\n\tpublic void reverse(int[] a) {\n\t\tint last = a.length-1;\n\t\tint n = a.length / 2;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tint t = a[i];\n\t\t\ta[i] = a[last-i];\n\t\t\ta[last-i] = t;\n\t\t}\n\t}\n\n\tpublic void reverse(long[] a) {\n\t\tint last = a.length-1;\n\t\tint n = a.length / 2;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tlong t = a[i];\n\t\t\ta[i] = a[last-i];\n\t\t\ta[last-i] = t;\n\t\t}\n\t}\n\n\tvoid fout(Object... args) {\n\t\tStringBuilder sb = new StringBuilder();\n\t\tfor (Object arg : args) {\n\t\t\tsb.append(arg.toString());\n\t\t\tsb.append(\" \");\n\t\t}\n\t\tout(sb.toString());\n\t}\n\n\tvoid out() {\n\t\tpw.println();\n\t}\n\n\tvoid out(String a) {\n\t\tpw.println(a);\n\t}\n\tvoid out(boolean a) {\n\t\tpw.println(a);\n\t}\n\n\tvoid out(int a) {\n\t\tpw.println(a);\n\t}\n\n\tvoid out(long a) {\n\t\tpw.println(a);\n\t}\n\n\tvoid out(double a) {\n\t\tpw.println(a);\n\t}\n\n\tvoid out(char a) {\n\t\tpw.println(a);\n\t}\n\n\tvoid rout(String a) {\n\t\tout(a);\n\t\tpw.close();\n\t\tSystem.exit(0);\n\t}\n\tvoid rout(int a) {\n\t\tout(a);\n\t\tpw.close();\n\t\tSystem.exit(0);\n\t}\n\tvoid rout(long a) {\n\t\tout(a);\n\t\tpw.close();\n\t\tSystem.exit(0);\n\t}\n\tvoid rout(double a) {\n\t\tout(a);\n\t\tpw.close();\n\t\tSystem.exit(0);\n\t}\n\tvoid rout(char a) {\n\t\tout(a);\n\t\tpw.close();\n\t\tSystem.exit(0);\n\t}\n}\n\n\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte())\n return buffer[ptr++];\n else\n return -1;\n }\n\n private boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr]))\n ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext())\n throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext())\n throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)\n throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n}\n", "language": "Java", "metadata": {"date": 1594777756, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02699.html", "problem_id": "p02699", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02699/input.txt", "sample_output_relpath": "derived/input_output/data/p02699/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02699/Java/s674768746.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s674768746", "user_id": "u893188242"}, "prompt_components": {"gold_output": "unsafe\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.ArrayDeque;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.NoSuchElementException;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tnew Main().solve();\n\t\tpw.close();\n\t}\n\n\t/**\n\t * ASCII\n\t * 0 48\n\t * A 65\n\t * a 97\n\t */\n\n\tstatic PrintWriter pw = new PrintWriter(System.out);\n\n\tlong MOD = 1_000_000_007;\n\n\tvoid solve() {\n\t\tFastScanner sc = new FastScanner();\n\t\tint S = sc.nextInt();\n\t\tint W = sc.nextInt();\n\t\tif (W >= S) out(\"unsafe\");\n\t\telse out(\"safe\");\n\t}\n\t\n\tint[][] q;\n\tint ans;\n\n\tvoid func(int now, int pre, int N, int M, int[] A) {\n\t\tfor (int i = pre; i <= M; i++) {\n\t\t\tA[now] = i;\n\t\t\tif (now == N) {\n\t\t\t\tint p = 0;\n\t\t\t\tfor (int[] t : q) {\n\t\t\t\t\tif (A[t[1]] - A[t[0]] == t[2]) p += t[3];\n\t\t\t\t}\n\t\t\t\tans = Math.max(p, ans);\n\t\t\t} else {\n\t\t\t\tfunc(now+1, i, N, M , A);\n\t\t\t}\n\t\t}\n\t}\n\n\tdouble getD(double x1, double x2, double y1, double y2) {\n\t\treturn Math.sqrt(Math.pow(x1-x2,2) + Math.pow(y1-y2, 2));\n\t}\n\n\tint[][] d4 = new int[][] {{1,0},{0,1},{-1,0},{0,-1}};\n\tint[][] d8 = new int[][] {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};\n\n\tclass Data {\n\t\tint a;\n\t\tint b;\n\t\tint c;\n\t\tData(){}\n\t\tData(int a) {\n\t\t\tthis.a = a;\n\t\t}\n\t\tData(int a, int b, int c) {\n\t\t\tthis.a = a;\n\t\t\tthis.b = b;\n\t\t\tthis.c = c;\n\t\t}\n\t\tData(int a, int b) {\n\t\t\tthis.a = a;\n\t\t\tthis.b = b;\n\t\t}\n\t}\n\n\tclass Permutation {\n\t\tint[] array;\n\n\t\tPermutation(int N) {\n\t\t\tarray = new int[N];\n\t\t\tfor (int i = 0; i < N; i++) {\n\t\t\t\tarray[i] = i+1;\n\t\t\t}\n\t\t}\n\n\t\tboolean nextPermutation() {\n\t\t int i = array.length - 1;\n\t\t while (i > 0 && array[i - 1] >= array[i])\n\t\t i--;\n\t\t if (i <= 0)\n\t\t return false;\n\n\t\t int j = array.length - 1;\n\t\t while (array[j] <= array[i - 1])\n\t\t j--;\n\t\t int temp = array[i - 1];\n\t\t array[i - 1] = array[j];\n\t\t array[j] = temp;\n\n\t\t j = array.length - 1;\n\t\t while (i < j) {\n\t\t temp = array[i];\n\t\t array[i] = array[j];\n\t\t array[j] = temp;\n\t\t i++;\n\t\t j--;\n\t\t }\n\t\t return true;\n\t\t}\n\t}\n\n\tclass UnionFind {\n\t\tint[] parents;\n\t\tint[] counts;\n\n\t\tpublic UnionFind(int size) {\n\t\t\tparents = new int[size];\n\t\t\tcounts = new int[size];\n\t\t\tfor (int i = 0; i < size; i++) {\n\t\t\t\tparents[i] = i;\n\t\t\t\tcounts[i] = 1;\n\t\t\t}\n\t\t}\n\n\t\tpublic int find(int a) {\n\t\t\tif (parents[a] == a) return a;\n\t\t\tparents[a] = find(parents[a]);\n\t\t\treturn parents[a];\n\t\t}\n\n\t\tpublic void unite(int a, int b) {\n\t\t\ta = find(a);\n\t\t\tb = find(b);\n\t\t\tif (a == b) return;\n\t\t\tif (counts[a] < counts[b]) {\n\t\t\t\tparents[a] = b;\n\t\t\t\tcounts[b] += counts[a];\n\t\t\t} else {\n\t\t\t\tparents[b] = a;\n\t\t\t\tcounts[a] += counts[b];\n\t\t\t}\n\t\t}\n\n\t\tpublic boolean differ(int a, int b) {\n\t\t\ta = find(a);\n\t\t\tb = find(b);\n\t\t\treturn a != b;\n\t\t}\n\n\t\tpublic int count(int a) {\n\t\t\treturn counts[find(a)];\n\t\t}\n\t}\n\n\tclass Combination {\n\t\tfinal int mod;\n\t\tfinal int max;\n\n\t\tfinal long[] fact;\n\t\tfinal long[] inv;\n\t\tfinal long[] invfact;\n\n\t\tpublic Combination(int n) {\n\t\t\tthis(n, 1_000_000_007);\n\t\t}\n\n\t\tpublic Combination(int n, int mod) {\n\t\t\tthis.mod = mod;\n\t\t\tmax = n + 1;\n\t\t\tfact = new long[max];\n\t\t\tinvfact = new long[max];\n\t\t\tinv = new long[max];\n\n\t\t\tinv[1] = 1;\n\t\t\tfor (int i = 2; i < inv.length; i++) {\n\t\t\t\tinv[i] = inv[mod % i] * (mod - mod / i) % mod;\n\t\t\t}\n\n\t\t\tfact[0] = 1;\n\t\t\tinvfact[0] = 1;\n\t\t\tfor (int i = 1; i < inv.length; i++) {\n\t\t\t\tfact[i] = i * fact[i - 1] % mod;\n\t\t\t\tinvfact[i] = inv[i] * invfact[i - 1] % mod;\n\t\t\t}\n\t\t}\n\n\t\tpublic long get(int n, int r) {\n\t\t\treturn fact[n] * invfact[n - r] % mod * invfact[r] % mod;\n\t\t}\n\n\t\tpublic long gcd(long a, long b) {\n\t\t\tif (b == 0) return a;\n\t\t\telse {\n\t\t\t\tb %= MOD;\n\t\t\t\tif (b < 0) b+=MOD;\n\t\t\t\treturn gcd(b, (b-a*inv[(int)b]%MOD*b%MOD)%MOD);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic long gcd(long a, long b) {\n\t\tif (b == 0) return a;\n\t\telse return gcd(b, a%b);\n\t}\n\n\tpublic long getInv(long a) {\n\t\tlong b = MOD, u = 1, v = 0;\n\t\twhile (b > 0) {\n\t\t\tlong t = a / b;\n\t\t\ta -= t * b;\n\t\t\tlong tmp = a;\n\t\t\ta = b;\n\t\t\tb = tmp;\n\t\t\tu -= t * v;\n\t\t\ttmp = u;\n\t\t\tu = v;\n\t\t\tv = tmp;\n\t\t}\n\t\tu %= MOD;\n\t\tif (u < 0) u += MOD;\n\t\treturn u;\n\t}\n\n\tpublic long modPow(long n) {\n\t\tif (n == 0) return 1;\n\t\tlong x = modPow(n / 2);\n\t\tx *= x;\n\t\tx %= MOD;\n\t\tif (n % 2 == 1) x *= 2;\n\t\tx %= MOD;\n\t\treturn x;\n\t}\n\n\tpublic long choose(long n, long m) {\n\t\tlong deno = 1;\n\t\tlong nume = 1;\n\t\tm = (n - m < m ? n - m : m);\n\t\tfor (long i = 1; i <= m; i++) {\n\t\t\tdeno = deno * (n - i + 1) % MOD;\n\t\t\tnume = nume * i % MOD;\n\t\t}\n\t\treturn deno * getInv(nume) % MOD;\n\t}\n\n\tpublic void reverse(int[] a) {\n\t\tint last = a.length-1;\n\t\tint n = a.length / 2;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tint t = a[i];\n\t\t\ta[i] = a[last-i];\n\t\t\ta[last-i] = t;\n\t\t}\n\t}\n\n\tpublic void reverse(long[] a) {\n\t\tint last = a.length-1;\n\t\tint n = a.length / 2;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tlong t = a[i];\n\t\t\ta[i] = a[last-i];\n\t\t\ta[last-i] = t;\n\t\t}\n\t}\n\n\tvoid fout(Object... args) {\n\t\tStringBuilder sb = new StringBuilder();\n\t\tfor (Object arg : args) {\n\t\t\tsb.append(arg.toString());\n\t\t\tsb.append(\" \");\n\t\t}\n\t\tout(sb.toString());\n\t}\n\n\tvoid out() {\n\t\tpw.println();\n\t}\n\n\tvoid out(String a) {\n\t\tpw.println(a);\n\t}\n\tvoid out(boolean a) {\n\t\tpw.println(a);\n\t}\n\n\tvoid out(int a) {\n\t\tpw.println(a);\n\t}\n\n\tvoid out(long a) {\n\t\tpw.println(a);\n\t}\n\n\tvoid out(double a) {\n\t\tpw.println(a);\n\t}\n\n\tvoid out(char a) {\n\t\tpw.println(a);\n\t}\n\n\tvoid rout(String a) {\n\t\tout(a);\n\t\tpw.close();\n\t\tSystem.exit(0);\n\t}\n\tvoid rout(int a) {\n\t\tout(a);\n\t\tpw.close();\n\t\tSystem.exit(0);\n\t}\n\tvoid rout(long a) {\n\t\tout(a);\n\t\tpw.close();\n\t\tSystem.exit(0);\n\t}\n\tvoid rout(double a) {\n\t\tout(a);\n\t\tpw.close();\n\t\tSystem.exit(0);\n\t}\n\tvoid rout(char a) {\n\t\tout(a);\n\t\tpw.close();\n\t\tSystem.exit(0);\n\t}\n}\n\n\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte())\n return buffer[ptr++];\n else\n return -1;\n }\n\n private boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr]))\n ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext())\n throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext())\n throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)\n throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are S sheep and W wolves.\n\nIf the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.\n\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\nConstraints\n\n1 \\leq S \\leq 100\n\n1 \\leq W \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS W\n\nOutput\n\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nunsafe\n\nThere are four sheep and five wolves. The number of wolves is not less than that of sheep, so they will attack them.\n\nSample Input 2\n\n100 2\n\nSample Output 2\n\nsafe\n\nMany a sheep drive away two wolves.\n\nSample Input 3\n\n10 10\n\nSample Output 3\n\nunsafe", "sample_input": "4 5\n"}, "reference_outputs": ["unsafe\n"], "source_document_id": "p02699", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are S sheep and W wolves.\n\nIf the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.\n\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\nConstraints\n\n1 \\leq S \\leq 100\n\n1 \\leq W \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS W\n\nOutput\n\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nunsafe\n\nThere are four sheep and five wolves. The number of wolves is not less than that of sheep, so they will attack them.\n\nSample Input 2\n\n100 2\n\nSample Output 2\n\nsafe\n\nMany a sheep drive away two wolves.\n\nSample Input 3\n\n10 10\n\nSample Output 3\n\nunsafe", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7865, "cpu_time_ms": 87, "memory_kb": 32660}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s803116735", "group_id": "codeNet:p02701", "input_text": "\nimport java.util.HashSet;\nimport java.util.Scanner;\nimport java.util.Set;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tSet set = new HashSet<>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tset.add(sc.nextLine());\n\t\t}\n\t\tsc.close();\n\t\tSystem.out.println(set.size());\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1588346293, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02701.html", "problem_id": "p02701", "resource_group": "high_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/Java/s803116735.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s803116735", "user_id": "u187491596"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\nimport java.util.HashSet;\nimport java.util.Scanner;\nimport java.util.Set;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tSet set = new HashSet<>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tset.add(sc.nextLine());\n\t\t}\n\t\tsc.close();\n\t\tSystem.out.println(set.size());\n\t}\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": 355, "cpu_time_ms": 652, "memory_kb": 79576}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s383323613", "group_id": "codeNet:p02701", "input_text": "import java.util.*;\n\npublic class Main {\n\tstatic final int r = 1000000000 + 7;\n\n\tpublic static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tString s[] = new String[n];\n\t\tfor (int i = 0; i < n; ++i)\n\t\t\ts[i] = sc.next();\n\t\tsc.close();\n\t\tint ans = 0;\n\t\tArrays.sort(s);\n\t\tans = 1;\n\t\tString st = s[0];\n\t\tfor(int i = 1; i < n; ++i){\n\t\t\tString tmp = s[i];\n\t\t\tif(!st.equals(tmp)){\n\t\t\t\tst = tmp.substring(0);\n\t\t\t\tans++;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1587949994, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02701.html", "problem_id": "p02701", "resource_group": "high_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/Java/s383323613.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s383323613", "user_id": "u949927271"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\tstatic final int r = 1000000000 + 7;\n\n\tpublic static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tString s[] = new String[n];\n\t\tfor (int i = 0; i < n; ++i)\n\t\t\ts[i] = sc.next();\n\t\tsc.close();\n\t\tint ans = 0;\n\t\tArrays.sort(s);\n\t\tans = 1;\n\t\tString st = s[0];\n\t\tfor(int i = 1; i < n; ++i){\n\t\t\tString tmp = s[i];\n\t\t\tif(!st.equals(tmp)){\n\t\t\t\tst = tmp.substring(0);\n\t\t\t\tans++;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\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": 499, "cpu_time_ms": 841, "memory_kb": 69816}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s815261191", "group_id": "codeNet:p02707", "input_text": "import java.util.*;\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n \n int a[] = new int[n];\n \n for (int i = 0; i < n; i++) {\n a[i] = 0;\n }\n\n for (int j = 0; j < n - 1; j++) {\n int b = sc.nextInt();\n a[b-1] += 1;\n }\n \n for (int k = 0; k < n; k++) {\n System.out.println(a[k]);\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1587346114, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02707.html", "problem_id": "p02707", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02707/input.txt", "sample_output_relpath": "derived/input_output/data/p02707/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02707/Java/s815261191.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s815261191", "user_id": "u462253630"}, "prompt_components": {"gold_output": "2\n2\n0\n0\n0\n", "input_to_evaluate": "import java.util.*;\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n \n int a[] = new int[n];\n \n for (int i = 0; i < n; i++) {\n a[i] = 0;\n }\n\n for (int j = 0; j < n - 1; j++) {\n int b = sc.nextInt();\n a[b-1] += 1;\n }\n \n for (int k = 0; k < n; k++) {\n System.out.println(a[k]);\n }\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA company has N members, who are assigned ID numbers 1, ..., N.\n\nEvery member, except the member numbered 1, has exactly one immediate boss with a smaller ID number.\n\nWhen a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X.\n\nYou are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i < i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_2 ... A_N\n\nOutput\n\nFor each of the members numbered 1, 2, ..., N, print the number of immediate subordinates it has, in its own line.\n\nSample Input 1\n\n5\n1 1 2 2\n\nSample Output 1\n\n2\n2\n0\n0\n0\n\nThe member numbered 1 has two immediate subordinates: the members numbered 2 and 3.\n\nThe member numbered 2 has two immediate subordinates: the members numbered 4 and 5.\n\nThe members numbered 3, 4, and 5 do not have immediate subordinates.\n\nSample Input 2\n\n10\n1 1 1 1 1 1 1 1 1\n\nSample Output 2\n\n9\n0\n0\n0\n0\n0\n0\n0\n0\n0\n\nSample Input 3\n\n7\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n1\n1\n1\n1\n1\n0", "sample_input": "5\n1 1 2 2\n"}, "reference_outputs": ["2\n2\n0\n0\n0\n"], "source_document_id": "p02707", "source_text": "Score : 300 points\n\nProblem Statement\n\nA company has N members, who are assigned ID numbers 1, ..., N.\n\nEvery member, except the member numbered 1, has exactly one immediate boss with a smaller ID number.\n\nWhen a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X.\n\nYou are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i < i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_2 ... A_N\n\nOutput\n\nFor each of the members numbered 1, 2, ..., N, print the number of immediate subordinates it has, in its own line.\n\nSample Input 1\n\n5\n1 1 2 2\n\nSample Output 1\n\n2\n2\n0\n0\n0\n\nThe member numbered 1 has two immediate subordinates: the members numbered 2 and 3.\n\nThe member numbered 2 has two immediate subordinates: the members numbered 4 and 5.\n\nThe members numbered 3, 4, and 5 do not have immediate subordinates.\n\nSample Input 2\n\n10\n1 1 1 1 1 1 1 1 1\n\nSample Output 2\n\n9\n0\n0\n0\n0\n0\n0\n0\n0\n0\n\nSample Input 3\n\n7\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n1\n1\n1\n1\n1\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1283, "memory_kb": 60776}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s865790648", "group_id": "codeNet:p02707", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n int N;\n int[] Ai;\n\n try (Scanner sc = new Scanner(System.in)) {\n N = sc.nextInt();\n Ai = new int[N];\n for (int i = 1; i < N; i++) {\n Ai[i] = sc.nextInt();\n }\n }\n Map map = new TreeMap<>();\n for (int i = 1; i < N; i++) {\n int js = Ai[i];\n int cnt = map.getOrDefault(js,0);\n map.put(js,++cnt);\n }\n for (int i = 1; i <= N; i++) {\n int cnt = map.getOrDefault(i,0);\n System.out.println(cnt);\n }\n\n }\n}\n", "language": "Java", "metadata": {"date": 1587345476, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02707.html", "problem_id": "p02707", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02707/input.txt", "sample_output_relpath": "derived/input_output/data/p02707/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02707/Java/s865790648.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s865790648", "user_id": "u499889187"}, "prompt_components": {"gold_output": "2\n2\n0\n0\n0\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n int N;\n int[] Ai;\n\n try (Scanner sc = new Scanner(System.in)) {\n N = sc.nextInt();\n Ai = new int[N];\n for (int i = 1; i < N; i++) {\n Ai[i] = sc.nextInt();\n }\n }\n Map map = new TreeMap<>();\n for (int i = 1; i < N; i++) {\n int js = Ai[i];\n int cnt = map.getOrDefault(js,0);\n map.put(js,++cnt);\n }\n for (int i = 1; i <= N; i++) {\n int cnt = map.getOrDefault(i,0);\n System.out.println(cnt);\n }\n\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA company has N members, who are assigned ID numbers 1, ..., N.\n\nEvery member, except the member numbered 1, has exactly one immediate boss with a smaller ID number.\n\nWhen a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X.\n\nYou are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i < i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_2 ... A_N\n\nOutput\n\nFor each of the members numbered 1, 2, ..., N, print the number of immediate subordinates it has, in its own line.\n\nSample Input 1\n\n5\n1 1 2 2\n\nSample Output 1\n\n2\n2\n0\n0\n0\n\nThe member numbered 1 has two immediate subordinates: the members numbered 2 and 3.\n\nThe member numbered 2 has two immediate subordinates: the members numbered 4 and 5.\n\nThe members numbered 3, 4, and 5 do not have immediate subordinates.\n\nSample Input 2\n\n10\n1 1 1 1 1 1 1 1 1\n\nSample Output 2\n\n9\n0\n0\n0\n0\n0\n0\n0\n0\n0\n\nSample Input 3\n\n7\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n1\n1\n1\n1\n1\n0", "sample_input": "5\n1 1 2 2\n"}, "reference_outputs": ["2\n2\n0\n0\n0\n"], "source_document_id": "p02707", "source_text": "Score : 300 points\n\nProblem Statement\n\nA company has N members, who are assigned ID numbers 1, ..., N.\n\nEvery member, except the member numbered 1, has exactly one immediate boss with a smaller ID number.\n\nWhen a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X.\n\nYou are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i < i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_2 ... A_N\n\nOutput\n\nFor each of the members numbered 1, 2, ..., N, print the number of immediate subordinates it has, in its own line.\n\nSample Input 1\n\n5\n1 1 2 2\n\nSample Output 1\n\n2\n2\n0\n0\n0\n\nThe member numbered 1 has two immediate subordinates: the members numbered 2 and 3.\n\nThe member numbered 2 has two immediate subordinates: the members numbered 4 and 5.\n\nThe members numbered 3, 4, and 5 do not have immediate subordinates.\n\nSample Input 2\n\n10\n1 1 1 1 1 1 1 1 1\n\nSample Output 2\n\n9\n0\n0\n0\n0\n0\n0\n0\n0\n0\n\nSample Input 3\n\n7\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n1\n1\n1\n1\n1\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 681, "cpu_time_ms": 1472, "memory_kb": 73460}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s761309087", "group_id": "codeNet:p02712", "input_text": "import java.util.*;\nimport java.io.*;\n\npublic class Main {\t\n\tpublic static void main(String[] args) {\n\t\tFastScanner fs = new FastScanner();\n\t\tint N = fs.nextInt();\n\t\tString a[]= new String[N];\n\t\tint ans=0;\n\t\t\n\t\tfor(int i=1; i<=N; i++){\n\t\t\tif((i%3==0&&i%5==0)||(i%3==0)||(i%5==0)){\n\t\t\t}else{\n\t\t\t\tans +=Integer.valueOf(\"a[i-1]\");\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.println(ans);\n\n\t}\n\n\tstatic class FastScanner {\n\t\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n\t\tStringTokenizer st=new StringTokenizer(\"\");\n\n\t\tpublic String next() {\n\t\t\twhile (!st.hasMoreElements())\n\t\t\t\ttry {\n\t\t\t\t\tst=new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tpublic long nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tpublic int[] readArray(int n) {\n\t\t\tint[] a=new int[n];\n\t\t\tfor (int i=0; i 0)\n {\n if(pow % 2 != 0) {\n res *= a;\n res %= mod;\n }\n a = a * a;\n a %= mod;\n pow /= 2;\n }\n\n return res;\n }\n\n public static void main(String[] args) throws Exception\n {\n int _k = Integer.valueOf(\"1\");\n if(test > 0) in = new BufferedReader(new InputStreamReader(System.in));\n else in = new BufferedReader(new FileReader(file));\n if(test < 0) {String[] str = in.readLine().split(\" \");\n char[] gg = in.readLine().toCharArray();}\n/***********************************************************************/\n/***********************************************************************/\n/***********************************************************************/\n/***********************************************************************/\n // System.out.println((-100 + 0) / 2);\n\n \n new Main().d();\n out.flush();\n }\n\n void e() throws Exception\n {\n int[] ary = toIntArray();\n int x = ary[0], y = ary[1], a = ary[2], b = ary[3], c = ary[4];\n\n int[] red = toIntArray(), green = toIntArray(), white = toIntArray();\n\n Arrays.sort(red);\n Arrays.sort(green);\n Arrays.sort(white);\n\n long redHP = 0, greenHP = 0;\n Queue rstack = new PriorityQueue<>(), gstack = new PriorityQueue<>();\n \n for(int i = 0; i < x; i++)\n {\n redHP += red[a - 1 - i];\n rstack.offer(red[a - 1 - i]);\n }\n for(int i = 0; i < y; i++)\n {\n greenHP += green[b - 1 - i];\n gstack.offer(green[b - 1 - i]);\n }\n\n // now try to pop the smallest one and add in the biggest one\n // System.out.printf(\"%d %d\\n\", redHP, greenHP);\n\n int widx = c - 1;\n int inf = 1 << 30;\n while(widx >= 0)\n {\n\n int minRed = rstack.isEmpty() ? inf : rstack.peek(), \n minGreen = gstack.isEmpty() ? inf : gstack.peek();\n \n int curWhite = white[widx];\n if(minRed >= curWhite && minGreen >= curWhite) break;\n if(minRed < minGreen)\n {\n redHP -= minRed;\n rstack.poll();\n redHP += curWhite;\n }\n else\n {\n greenHP -= minGreen;\n gstack.poll();\n greenHP += curWhite;\n }\n widx--;\n }\n out.println(redHP + greenHP);\n }\n\n void d() throws Exception\n {\n int k = readInt();\n // lun(k);\n Queue q = new LinkedList<>();\n\n for(long i = 1; i <= 9; i++) q.offer(i);\n while(k-- > 1)\n {\n long cur = q.poll();\n long last = cur % 10;\n if(last != 0 && last != 9)\n {\n q.offer(cur * 10 + last - 1);\n q.offer(cur * 10 + last);\n q.offer(cur * 10 + last + 1);\n }\n else\n {\n if(last == 0)\n {\n q.offer(cur * 10 + last);\n q.offer(cur * 10 + last + 1);\n }\n else\n {\n q.offer(cur * 10 + last - 1);\n q.offer(cur * 10 + last);\n }\n }\n }\n out.println(q.poll());\n }\n\n void lun(int k)\n {\n int a = 1, idx = 1;\n while(k > 0)\n {\n if(isLun(a))\n {\n System.out.printf(\"%d %d\\n\", idx++, a);\n k--;\n }\n a++;\n }\n }\n\n boolean isLun(int n)\n {\n String str = String.valueOf(n);\n int len = str.length();\n for(int i = 0; i < len - 1; i++)\n {\n char c1 = str.charAt(i), c2 = str.charAt(i + 1);\n if(Math.abs(c1 - c2) > 1) return false;\n }\n return true;\n }\n\n void c() throws Exception\n {\n long[] ary = toLongArray();\n long n = ary[0], k = ary[1];\n n %= k;\n long n1 = n, n2 = Math.abs(n - k);\n // System.out.println(n1);\n // System.out.println(n2);\n out.println(Math.min(n1, n2));\n }\n\n void b() throws Exception\n {\n int[] ary = toIntArray();\n int n = ary[0], m = ary[1];\n ary = toIntArray();\n int total = 0;\n for(int vote : ary) total += vote;\n Arrays.sort(ary);\n\n boolean flag = true;\n \n for(int i = n - 1; i >= n - m; i--)\n {\n int v = ary[i];\n if(v * 4 * m < total) flag = false;\n }\n if(flag) out.println(\"Yes\");\n else out.println(\"No\");\n }\n\n void a() throws Exception\n {\n int[] ary = toIntArray();\n System.out.printf(\"%d %d %d\", ary[2], ary[0], ary[1]);\n }\n}", "language": "Java", "metadata": {"date": 1586060788, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02720.html", "problem_id": "p02720", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02720/input.txt", "sample_output_relpath": "derived/input_output/data/p02720/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02720/Java/s861426880.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s861426880", "user_id": "u065842329"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "//\nimport java.math.*;\nimport java.util.*;\nimport java.io.*;\n \npublic class Main { \n \n static BufferedReader in;\n static PrintWriter out = new PrintWriter(System.out);\n static String file = \"../in\";\n static int test = 10; // 0 for local testing, 1 for std input\n static int inf = 1_000_000, mod = 1_000_000_007;\n\n\n\n void swap(int[]ary, int i, int j)\n {\n int t = ary[i];\n ary[i] = ary[j];\n ary[j] = t;\n }\n \n String[] split() throws Exception\n {\n return in.readLine().split(\" \");\n }\n\n int readInt() throws Exception\n {\n return Integer.valueOf(in.readLine());\n }\n\n long[] toLongArray() throws Exception\n {\n String[] sp = split();\n int n = sp.length;\n long[] ary = new long[n];\n for(int i = 0; i < n; i++) ary[i] = Long.valueOf(sp[i]);\n return ary;\n }\n\n int[] toIntArray() throws Exception\n {\n String[] sp = split();\n int n = sp.length;\n int[] ary = new int[n];\n for(int i = 0; i < n; i++) ary[i] = Integer.valueOf(sp[i]);\n return ary;\n }\n\n String reverse(String str)\n {\n return new StringBuilder(str).reverse().toString();\n }\n\n\n long pow(long a, int pow)\n {\n long res = 1;\n while(pow > 0)\n {\n if(pow % 2 != 0) {\n res *= a;\n res %= mod;\n }\n a = a * a;\n a %= mod;\n pow /= 2;\n }\n\n return res;\n }\n\n public static void main(String[] args) throws Exception\n {\n int _k = Integer.valueOf(\"1\");\n if(test > 0) in = new BufferedReader(new InputStreamReader(System.in));\n else in = new BufferedReader(new FileReader(file));\n if(test < 0) {String[] str = in.readLine().split(\" \");\n char[] gg = in.readLine().toCharArray();}\n/***********************************************************************/\n/***********************************************************************/\n/***********************************************************************/\n/***********************************************************************/\n // System.out.println((-100 + 0) / 2);\n\n \n new Main().d();\n out.flush();\n }\n\n void e() throws Exception\n {\n int[] ary = toIntArray();\n int x = ary[0], y = ary[1], a = ary[2], b = ary[3], c = ary[4];\n\n int[] red = toIntArray(), green = toIntArray(), white = toIntArray();\n\n Arrays.sort(red);\n Arrays.sort(green);\n Arrays.sort(white);\n\n long redHP = 0, greenHP = 0;\n Queue rstack = new PriorityQueue<>(), gstack = new PriorityQueue<>();\n \n for(int i = 0; i < x; i++)\n {\n redHP += red[a - 1 - i];\n rstack.offer(red[a - 1 - i]);\n }\n for(int i = 0; i < y; i++)\n {\n greenHP += green[b - 1 - i];\n gstack.offer(green[b - 1 - i]);\n }\n\n // now try to pop the smallest one and add in the biggest one\n // System.out.printf(\"%d %d\\n\", redHP, greenHP);\n\n int widx = c - 1;\n int inf = 1 << 30;\n while(widx >= 0)\n {\n\n int minRed = rstack.isEmpty() ? inf : rstack.peek(), \n minGreen = gstack.isEmpty() ? inf : gstack.peek();\n \n int curWhite = white[widx];\n if(minRed >= curWhite && minGreen >= curWhite) break;\n if(minRed < minGreen)\n {\n redHP -= minRed;\n rstack.poll();\n redHP += curWhite;\n }\n else\n {\n greenHP -= minGreen;\n gstack.poll();\n greenHP += curWhite;\n }\n widx--;\n }\n out.println(redHP + greenHP);\n }\n\n void d() throws Exception\n {\n int k = readInt();\n // lun(k);\n Queue q = new LinkedList<>();\n\n for(long i = 1; i <= 9; i++) q.offer(i);\n while(k-- > 1)\n {\n long cur = q.poll();\n long last = cur % 10;\n if(last != 0 && last != 9)\n {\n q.offer(cur * 10 + last - 1);\n q.offer(cur * 10 + last);\n q.offer(cur * 10 + last + 1);\n }\n else\n {\n if(last == 0)\n {\n q.offer(cur * 10 + last);\n q.offer(cur * 10 + last + 1);\n }\n else\n {\n q.offer(cur * 10 + last - 1);\n q.offer(cur * 10 + last);\n }\n }\n }\n out.println(q.poll());\n }\n\n void lun(int k)\n {\n int a = 1, idx = 1;\n while(k > 0)\n {\n if(isLun(a))\n {\n System.out.printf(\"%d %d\\n\", idx++, a);\n k--;\n }\n a++;\n }\n }\n\n boolean isLun(int n)\n {\n String str = String.valueOf(n);\n int len = str.length();\n for(int i = 0; i < len - 1; i++)\n {\n char c1 = str.charAt(i), c2 = str.charAt(i + 1);\n if(Math.abs(c1 - c2) > 1) return false;\n }\n return true;\n }\n\n void c() throws Exception\n {\n long[] ary = toLongArray();\n long n = ary[0], k = ary[1];\n n %= k;\n long n1 = n, n2 = Math.abs(n - k);\n // System.out.println(n1);\n // System.out.println(n2);\n out.println(Math.min(n1, n2));\n }\n\n void b() throws Exception\n {\n int[] ary = toIntArray();\n int n = ary[0], m = ary[1];\n ary = toIntArray();\n int total = 0;\n for(int vote : ary) total += vote;\n Arrays.sort(ary);\n\n boolean flag = true;\n \n for(int i = n - 1; i >= n - m; i--)\n {\n int v = ary[i];\n if(v * 4 * m < total) flag = false;\n }\n if(flag) out.println(\"Yes\");\n else out.println(\"No\");\n }\n\n void a() throws Exception\n {\n int[] ary = toIntArray();\n System.out.printf(\"%d %d %d\", ary[2], ary[0], ary[1]);\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA positive integer X is said to be a lunlun number if and only if the following condition is satisfied:\n\nIn the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1.\n\nFor example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or 13579 is.\n\nYou are given a positive integer K. Find the K-th smallest lunlun number.\n\nConstraints\n\n1 \\leq K \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n23\n\nWe will list the 15 smallest lunlun numbers in ascending order:\n\n1,\n2,\n3,\n4,\n5,\n6,\n7,\n8,\n9,\n10,\n11,\n12,\n21,\n22,\n23.\n\nThus, the answer is 23.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n13\n\nSample Output 3\n\n21\n\nSample Input 4\n\n100000\n\nSample Output 4\n\n3234566667\n\nNote that the answer may not fit into the 32-bit signed integer type.", "sample_input": "15\n"}, "reference_outputs": ["23\n"], "source_document_id": "p02720", "source_text": "Score : 400 points\n\nProblem Statement\n\nA positive integer X is said to be a lunlun number if and only if the following condition is satisfied:\n\nIn the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1.\n\nFor example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or 13579 is.\n\nYou are given a positive integer K. Find the K-th smallest lunlun number.\n\nConstraints\n\n1 \\leq K \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n23\n\nWe will list the 15 smallest lunlun numbers in ascending order:\n\n1,\n2,\n3,\n4,\n5,\n6,\n7,\n8,\n9,\n10,\n11,\n12,\n21,\n22,\n23.\n\nThus, the answer is 23.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n13\n\nSample Output 3\n\n21\n\nSample Input 4\n\n100000\n\nSample Output 4\n\n3234566667\n\nNote that the answer may not fit into the 32-bit signed integer type.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6181, "cpu_time_ms": 109, "memory_kb": 35924}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s909888617", "group_id": "codeNet:p02721", "input_text": "import java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int K = sc.nextInt();\n int C = sc.nextInt();\n String S = sc.next();\n boolean[] sche = new boolean[N];\n for (int i = 0; i < N; i++) {\n if(S.toCharArray()[i] == 'o'){\n sche[i] = true;\n }\n }\n\n int[] left = new int[N];\n int[] right= new int[N];\n\n int count = 0;\n\n int lcount =0;\n for (int i = 0; i < N; i++) {\n if(sche[i]){\n left[i] = ++lcount;\n i+=C;\n }\n if(lcount==K) break;\n }\n int rcount =0;\n for (int i = N-1; i >= 0; i--) {\n if(sche[i]){\n right[i] = K-rcount;\n ++rcount;\n i-=C;\n }\n if(rcount==K) break;\n }\n\n\n for (int i = 0; i < N ; i++) {\n if(left[i]==right[i] && right[i]!=0){\n System.out.println(i+1);\n }\n \n }\n\n }\n\n}\n", "language": "Java", "metadata": {"date": 1586701644, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02721.html", "problem_id": "p02721", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02721/input.txt", "sample_output_relpath": "derived/input_output/data/p02721/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02721/Java/s909888617.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s909888617", "user_id": "u584924463"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int K = sc.nextInt();\n int C = sc.nextInt();\n String S = sc.next();\n boolean[] sche = new boolean[N];\n for (int i = 0; i < N; i++) {\n if(S.toCharArray()[i] == 'o'){\n sche[i] = true;\n }\n }\n\n int[] left = new int[N];\n int[] right= new int[N];\n\n int count = 0;\n\n int lcount =0;\n for (int i = 0; i < N; i++) {\n if(sche[i]){\n left[i] = ++lcount;\n i+=C;\n }\n if(lcount==K) break;\n }\n int rcount =0;\n for (int i = N-1; i >= 0; i--) {\n if(sche[i]){\n right[i] = K-rcount;\n ++rcount;\n i-=C;\n }\n if(rcount==K) break;\n }\n\n\n for (int i = 0; i < N ; i++) {\n if(left[i]==right[i] && right[i]!=0){\n System.out.println(i+1);\n }\n \n }\n\n }\n\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi has decided to work on K days of his choice from the N days starting with tomorrow.\n\nYou are given an integer C and a string S. Takahashi will choose his workdays as follows:\n\nAfter working for a day, he will refrain from working on the subsequent C days.\n\nIf the i-th character of S is x, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.\n\nFind all days on which Takahashi is bound to work.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq N\n\n0 \\leq C \\leq N\n\nThe length of S is N.\n\nEach character of S is o or x.\n\nTakahashi can choose his workdays so that the conditions in Problem Statement are satisfied.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K C\nS\n\nOutput\n\nPrint all days on which Takahashi is bound to work in ascending order, one per line.\n\nSample Input 1\n\n11 3 2\nooxxxoxxxoo\n\nSample Output 1\n\n6\n\nTakahashi is going to work on 3 days out of the 11 days. After working for a day, he will refrain from working on the subsequent 2 days.\n\nThere are four possible choices for his workdays: Day 1,6,10, Day 1,6,11, Day 2,6,10, and Day 2,6,11.\n\nThus, he is bound to work on Day 6.\n\nSample Input 2\n\n5 2 3\nooxoo\n\nSample Output 2\n\n1\n5\n\nThere is only one possible choice for his workdays: Day 1,5.\n\nSample Input 3\n\n5 1 0\nooooo\n\nSample Output 3\n\nThere may be no days on which he is bound to work.\n\nSample Input 4\n\n16 4 3\nooxxoxoxxxoxoxxo\n\nSample Output 4\n\n11\n16", "sample_input": "11 3 2\nooxxxoxxxoo\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02721", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi has decided to work on K days of his choice from the N days starting with tomorrow.\n\nYou are given an integer C and a string S. Takahashi will choose his workdays as follows:\n\nAfter working for a day, he will refrain from working on the subsequent C days.\n\nIf the i-th character of S is x, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.\n\nFind all days on which Takahashi is bound to work.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq N\n\n0 \\leq C \\leq N\n\nThe length of S is N.\n\nEach character of S is o or x.\n\nTakahashi can choose his workdays so that the conditions in Problem Statement are satisfied.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K C\nS\n\nOutput\n\nPrint all days on which Takahashi is bound to work in ascending order, one per line.\n\nSample Input 1\n\n11 3 2\nooxxxoxxxoo\n\nSample Output 1\n\n6\n\nTakahashi is going to work on 3 days out of the 11 days. After working for a day, he will refrain from working on the subsequent 2 days.\n\nThere are four possible choices for his workdays: Day 1,6,10, Day 1,6,11, Day 2,6,10, and Day 2,6,11.\n\nThus, he is bound to work on Day 6.\n\nSample Input 2\n\n5 2 3\nooxoo\n\nSample Output 2\n\n1\n5\n\nThere is only one possible choice for his workdays: Day 1,5.\n\nSample Input 3\n\n5 1 0\nooooo\n\nSample Output 3\n\nThere may be no days on which he is bound to work.\n\nSample Input 4\n\n16 4 3\nooxxoxoxxxoxoxxo\n\nSample Output 4\n\n11\n16", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1134, "cpu_time_ms": 2110, "memory_kb": 342576}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s234861721", "group_id": "codeNet:p02721", "input_text": "import java.util.ArrayList;\nimport java.util.List;\nimport java.util.Scanner;\n\npublic class Main{\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int K = sc.nextInt();\n int C = sc.nextInt();\n String S = sc.next();\n StringBuffer sb = new StringBuffer(S);\n String S_ = sb.reverse().toString();\n List workDaysL = new ArrayList();\n List workDaysR = new ArrayList();\n for (int d: calcWorkDays(S, C).subList(0, K)) {\n workDaysL.add(d+1);\n }\n for (int d: calcWorkDays(S_, C).subList(0, K)) {\n workDaysR.add(N-d);\n }\n for (int d: workDaysL) {\n if (workDaysR.contains(d)) {\n System.out.println(d);\n }\n }\n }\n\n public static List calcWorkDays(String s, int c) {\n List workDays = new ArrayList();\n int count = 0;\n while (count < s.length()) {\n if (s.charAt(count) == 'o') {\n workDays.add(count);\n count += c+1;\n } else {\n count++;\n }\n }\n return workDays;\n }\n}", "language": "Java", "metadata": {"date": 1586463845, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02721.html", "problem_id": "p02721", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02721/input.txt", "sample_output_relpath": "derived/input_output/data/p02721/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02721/Java/s234861721.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s234861721", "user_id": "u369660560"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.List;\nimport java.util.Scanner;\n\npublic class Main{\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int K = sc.nextInt();\n int C = sc.nextInt();\n String S = sc.next();\n StringBuffer sb = new StringBuffer(S);\n String S_ = sb.reverse().toString();\n List workDaysL = new ArrayList();\n List workDaysR = new ArrayList();\n for (int d: calcWorkDays(S, C).subList(0, K)) {\n workDaysL.add(d+1);\n }\n for (int d: calcWorkDays(S_, C).subList(0, K)) {\n workDaysR.add(N-d);\n }\n for (int d: workDaysL) {\n if (workDaysR.contains(d)) {\n System.out.println(d);\n }\n }\n }\n\n public static List calcWorkDays(String s, int c) {\n List workDays = new ArrayList();\n int count = 0;\n while (count < s.length()) {\n if (s.charAt(count) == 'o') {\n workDays.add(count);\n count += c+1;\n } else {\n count++;\n }\n }\n return workDays;\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi has decided to work on K days of his choice from the N days starting with tomorrow.\n\nYou are given an integer C and a string S. Takahashi will choose his workdays as follows:\n\nAfter working for a day, he will refrain from working on the subsequent C days.\n\nIf the i-th character of S is x, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.\n\nFind all days on which Takahashi is bound to work.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq N\n\n0 \\leq C \\leq N\n\nThe length of S is N.\n\nEach character of S is o or x.\n\nTakahashi can choose his workdays so that the conditions in Problem Statement are satisfied.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K C\nS\n\nOutput\n\nPrint all days on which Takahashi is bound to work in ascending order, one per line.\n\nSample Input 1\n\n11 3 2\nooxxxoxxxoo\n\nSample Output 1\n\n6\n\nTakahashi is going to work on 3 days out of the 11 days. After working for a day, he will refrain from working on the subsequent 2 days.\n\nThere are four possible choices for his workdays: Day 1,6,10, Day 1,6,11, Day 2,6,10, and Day 2,6,11.\n\nThus, he is bound to work on Day 6.\n\nSample Input 2\n\n5 2 3\nooxoo\n\nSample Output 2\n\n1\n5\n\nThere is only one possible choice for his workdays: Day 1,5.\n\nSample Input 3\n\n5 1 0\nooooo\n\nSample Output 3\n\nThere may be no days on which he is bound to work.\n\nSample Input 4\n\n16 4 3\nooxxoxoxxxoxoxxo\n\nSample Output 4\n\n11\n16", "sample_input": "11 3 2\nooxxxoxxxoo\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02721", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi has decided to work on K days of his choice from the N days starting with tomorrow.\n\nYou are given an integer C and a string S. Takahashi will choose his workdays as follows:\n\nAfter working for a day, he will refrain from working on the subsequent C days.\n\nIf the i-th character of S is x, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.\n\nFind all days on which Takahashi is bound to work.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq N\n\n0 \\leq C \\leq N\n\nThe length of S is N.\n\nEach character of S is o or x.\n\nTakahashi can choose his workdays so that the conditions in Problem Statement are satisfied.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K C\nS\n\nOutput\n\nPrint all days on which Takahashi is bound to work in ascending order, one per line.\n\nSample Input 1\n\n11 3 2\nooxxxoxxxoo\n\nSample Output 1\n\n6\n\nTakahashi is going to work on 3 days out of the 11 days. After working for a day, he will refrain from working on the subsequent 2 days.\n\nThere are four possible choices for his workdays: Day 1,6,10, Day 1,6,11, Day 2,6,10, and Day 2,6,11.\n\nThus, he is bound to work on Day 6.\n\nSample Input 2\n\n5 2 3\nooxoo\n\nSample Output 2\n\n1\n5\n\nThere is only one possible choice for his workdays: Day 1,5.\n\nSample Input 3\n\n5 1 0\nooooo\n\nSample Output 3\n\nThere may be no days on which he is bound to work.\n\nSample Input 4\n\n16 4 3\nooxxoxoxxxoxoxxo\n\nSample Output 4\n\n11\n16", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1254, "cpu_time_ms": 2109, "memory_kb": 52112}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s915722509", "group_id": "codeNet:p02724", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint X = Integer.parseInt(sc.next());\n\t\tsc.close();\n\n\t\t//嬉しさ1000の合計\n\t\tint happy1000 = (X / 500) * 1000;\n\t\tint happy5 = (X % 100) / 5 * 5;\n\n\t\tint sum = happy1000 + happy5;\n\t\tSystem.out.println(sum);\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1590097646, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02724.html", "problem_id": "p02724", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02724/input.txt", "sample_output_relpath": "derived/input_output/data/p02724/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02724/Java/s915722509.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s915722509", "user_id": "u581098393"}, "prompt_components": {"gold_output": "2020\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint X = Integer.parseInt(sc.next());\n\t\tsc.close();\n\n\t\t//嬉しさ1000の合計\n\t\tint happy1000 = (X / 500) * 1000;\n\t\tint happy5 = (X % 100) / 5 * 5;\n\n\t\tint sum = happy1000 + happy5;\n\t\tSystem.out.println(sum);\n\t}\n\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)\n\nTakahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?\n\n(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)\n\nConstraints\n\n0 \\leq X \\leq 10^9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the maximum number of happiness points that can be earned.\n\nSample Input 1\n\n1024\n\nSample Output 1\n\n2020\n\nBy exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.\n\nSample Input 2\n\n0\n\nSample Output 2\n\n0\n\nHe is penniless - or yenless.\n\nSample Input 3\n\n1000000000\n\nSample Output 3\n\n2000000000\n\nHe is a billionaire - in yen.", "sample_input": "1024\n"}, "reference_outputs": ["2020\n"], "source_document_id": "p02724", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)\n\nTakahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?\n\n(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)\n\nConstraints\n\n0 \\leq X \\leq 10^9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the maximum number of happiness points that can be earned.\n\nSample Input 1\n\n1024\n\nSample Output 1\n\n2020\n\nBy exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.\n\nSample Input 2\n\n0\n\nSample Output 2\n\n0\n\nHe is penniless - or yenless.\n\nSample Input 3\n\n1000000000\n\nSample Output 3\n\n2000000000\n\nHe is a billionaire - in yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 346, "cpu_time_ms": 94, "memory_kb": 23124}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s120783654", "group_id": "codeNet:p02724", "input_text": "import java.util.*;\n \npublic class Main {\n public static void main(String args[]) {\n\t\t Scanner sc = new Scanner(System.in);\n\t\t int a = sc.nextInt();\n\t\t System.out.println(myFunction(a));\n\t}\n\t\n\tpublic static int myFunction(int s) {\n\t\tint total = 0;\n\t\ttotal += s/500 * 1000;\n\t\ts %= 1000;\n\t\ttotal += s/5 *5;\n\t\t\n\t\treturn total;\n }\n}", "language": "Java", "metadata": {"date": 1585860048, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02724.html", "problem_id": "p02724", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02724/input.txt", "sample_output_relpath": "derived/input_output/data/p02724/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02724/Java/s120783654.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s120783654", "user_id": "u090418999"}, "prompt_components": {"gold_output": "2020\n", "input_to_evaluate": "import java.util.*;\n \npublic class Main {\n public static void main(String args[]) {\n\t\t Scanner sc = new Scanner(System.in);\n\t\t int a = sc.nextInt();\n\t\t System.out.println(myFunction(a));\n\t}\n\t\n\tpublic static int myFunction(int s) {\n\t\tint total = 0;\n\t\ttotal += s/500 * 1000;\n\t\ts %= 1000;\n\t\ttotal += s/5 *5;\n\t\t\n\t\treturn total;\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)\n\nTakahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?\n\n(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)\n\nConstraints\n\n0 \\leq X \\leq 10^9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the maximum number of happiness points that can be earned.\n\nSample Input 1\n\n1024\n\nSample Output 1\n\n2020\n\nBy exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.\n\nSample Input 2\n\n0\n\nSample Output 2\n\n0\n\nHe is penniless - or yenless.\n\nSample Input 3\n\n1000000000\n\nSample Output 3\n\n2000000000\n\nHe is a billionaire - in yen.", "sample_input": "1024\n"}, "reference_outputs": ["2020\n"], "source_document_id": "p02724", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)\n\nTakahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?\n\n(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)\n\nConstraints\n\n0 \\leq X \\leq 10^9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the maximum number of happiness points that can be earned.\n\nSample Input 1\n\n1024\n\nSample Output 1\n\n2020\n\nBy exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.\n\nSample Input 2\n\n0\n\nSample Output 2\n\n0\n\nHe is penniless - or yenless.\n\nSample Input 3\n\n1000000000\n\nSample Output 3\n\n2000000000\n\nHe is a billionaire - in yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 334, "cpu_time_ms": 98, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s380526769", "group_id": "codeNet:p02724", "input_text": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n int x = in.nextInt();\n int coin500 = (int)Math.floor(x/500.0);\n int coin5 = (int)Math.floor((x%500)/5.0);\n System.out.println(coin500*1000 + coin5*5);\n }\n}\n", "language": "Java", "metadata": {"date": 1585443845, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02724.html", "problem_id": "p02724", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02724/input.txt", "sample_output_relpath": "derived/input_output/data/p02724/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02724/Java/s380526769.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s380526769", "user_id": "u569736690"}, "prompt_components": {"gold_output": "2020\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n int x = in.nextInt();\n int coin500 = (int)Math.floor(x/500.0);\n int coin5 = (int)Math.floor((x%500)/5.0);\n System.out.println(coin500*1000 + coin5*5);\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)\n\nTakahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?\n\n(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)\n\nConstraints\n\n0 \\leq X \\leq 10^9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the maximum number of happiness points that can be earned.\n\nSample Input 1\n\n1024\n\nSample Output 1\n\n2020\n\nBy exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.\n\nSample Input 2\n\n0\n\nSample Output 2\n\n0\n\nHe is penniless - or yenless.\n\nSample Input 3\n\n1000000000\n\nSample Output 3\n\n2000000000\n\nHe is a billionaire - in yen.", "sample_input": "1024\n"}, "reference_outputs": ["2020\n"], "source_document_id": "p02724", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)\n\nTakahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?\n\n(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)\n\nConstraints\n\n0 \\leq X \\leq 10^9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the maximum number of happiness points that can be earned.\n\nSample Input 1\n\n1024\n\nSample Output 1\n\n2020\n\nBy exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.\n\nSample Input 2\n\n0\n\nSample Output 2\n\n0\n\nHe is penniless - or yenless.\n\nSample Input 3\n\n1000000000\n\nSample Output 3\n\n2000000000\n\nHe is a billionaire - in yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 325, "cpu_time_ms": 118, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s523870684", "group_id": "codeNet:p02725", "input_text": "import java.util.*;\npublic class Main {\n \n\tpublic static void main(String[] args) {\n \n \tScanner sc = new Scanner(System.in);\n \tint k = sc.nextInt();\n \tint n = sc.nextInt();\n \tint maxDistance = 0;\n \tint newPoint;\n \tint lastPoint = sc.nextInt();\n \tint firstPoint = lastPoint;\n \tint distance;\n \tfor (int i = 0; i < n; i++) {\n if (i == n - 1) {\n newPoint = firstPoint + k;\n } else {\n \tnewPoint = sc.nextInt();\n }\n distance = Math.abs(newPoint - lastPoint);\n lastPoint = newPoint;\n maxDistance = maxDistance < distance ? distance : maxDistance;\n }\n System.out.println(k - maxDistance);\n }\n }", "language": "Java", "metadata": {"date": 1585538883, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02725.html", "problem_id": "p02725", "resource_group": "high_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/Java/s523870684.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s523870684", "user_id": "u391721234"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.util.*;\npublic class Main {\n \n\tpublic static void main(String[] args) {\n \n \tScanner sc = new Scanner(System.in);\n \tint k = sc.nextInt();\n \tint n = sc.nextInt();\n \tint maxDistance = 0;\n \tint newPoint;\n \tint lastPoint = sc.nextInt();\n \tint firstPoint = lastPoint;\n \tint distance;\n \tfor (int i = 0; i < n; i++) {\n if (i == n - 1) {\n newPoint = firstPoint + k;\n } else {\n \tnewPoint = sc.nextInt();\n }\n distance = Math.abs(newPoint - lastPoint);\n lastPoint = newPoint;\n maxDistance = maxDistance < distance ? distance : maxDistance;\n }\n System.out.println(k - maxDistance);\n }\n }", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a circular pond with a perimeter of K meters, and N houses around them.\n\nThe i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.\n\nWhen traveling between these houses, you can only go around the pond.\n\nFind the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nConstraints\n\n2 \\leq K \\leq 10^6\n\n2 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_1 < ... < A_N < K\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nSample Input 1\n\n20 3\n5 10 15\n\nSample Output 1\n\n10\n\nIf you start at the 1-st house and go to the 2-nd and 3-rd houses in this order, the total distance traveled will be 10.\n\nSample Input 2\n\n20 3\n0 5 15\n\nSample Output 2\n\n10\n\nIf you start at the 2-nd house and go to the 1-st and 3-rd houses in this order, the total distance traveled will be 10.", "sample_input": "20 3\n5 10 15\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02725", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a circular pond with a perimeter of K meters, and N houses around them.\n\nThe i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.\n\nWhen traveling between these houses, you can only go around the pond.\n\nFind the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nConstraints\n\n2 \\leq K \\leq 10^6\n\n2 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_1 < ... < A_N < K\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nSample Input 1\n\n20 3\n5 10 15\n\nSample Output 1\n\n10\n\nIf you start at the 1-st house and go to the 2-nd and 3-rd houses in this order, the total distance traveled will be 10.\n\nSample Input 2\n\n20 3\n0 5 15\n\nSample Output 2\n\n10\n\nIf you start at the 2-nd house and go to the 1-st and 3-rd houses in this order, the total distance traveled will be 10.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 725, "cpu_time_ms": 538, "memory_kb": 64936}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s103303472", "group_id": "codeNet:p02725", "input_text": "import java.util.*;\nimport java.math.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n long k = sc.nextLong();\n int n = sc.nextInt();\n\n long[] a = new long[n];\n\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextLong();\n }\n\n long sum = 0;\n\n for (int i = n-1; i > 0; i--) {\n if (a[i-1] == 0) {\n continue;\n }\n sum += a[i]-a[i-1];\n }\n\n System.out.println(sum);\n\n }\n\n}\n", "language": "Java", "metadata": {"date": 1585445084, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02725.html", "problem_id": "p02725", "resource_group": "high_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/Java/s103303472.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s103303472", "user_id": "u387775763"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.util.*;\nimport java.math.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n long k = sc.nextLong();\n int n = sc.nextInt();\n\n long[] a = new long[n];\n\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextLong();\n }\n\n long sum = 0;\n\n for (int i = n-1; i > 0; i--) {\n if (a[i-1] == 0) {\n continue;\n }\n sum += a[i]-a[i-1];\n }\n\n System.out.println(sum);\n\n }\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a circular pond with a perimeter of K meters, and N houses around them.\n\nThe i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.\n\nWhen traveling between these houses, you can only go around the pond.\n\nFind the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nConstraints\n\n2 \\leq K \\leq 10^6\n\n2 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_1 < ... < A_N < K\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nSample Input 1\n\n20 3\n5 10 15\n\nSample Output 1\n\n10\n\nIf you start at the 1-st house and go to the 2-nd and 3-rd houses in this order, the total distance traveled will be 10.\n\nSample Input 2\n\n20 3\n0 5 15\n\nSample Output 2\n\n10\n\nIf you start at the 2-nd house and go to the 1-st and 3-rd houses in this order, the total distance traveled will be 10.", "sample_input": "20 3\n5 10 15\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02725", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a circular pond with a perimeter of K meters, and N houses around them.\n\nThe i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.\n\nWhen traveling between these houses, you can only go around the pond.\n\nFind the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nConstraints\n\n2 \\leq K \\leq 10^6\n\n2 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_1 < ... < A_N < K\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nSample Input 1\n\n20 3\n5 10 15\n\nSample Output 1\n\n10\n\nIf you start at the 1-st house and go to the 2-nd and 3-rd houses in this order, the total distance traveled will be 10.\n\nSample Input 2\n\n20 3\n0 5 15\n\nSample Output 2\n\n10\n\nIf you start at the 2-nd house and go to the 1-st and 3-rd houses in this order, the total distance traveled will be 10.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 475, "cpu_time_ms": 574, "memory_kb": 67176}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s192334070", "group_id": "codeNet:p02726", "input_text": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.net.ConnectException;\nimport java.rmi.dgc.Lease;\nimport java.util.ArrayDeque;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.Deque;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.NoSuchElementException;\nimport java.util.Objects;\nimport java.util.PriorityQueue;\nimport java.util.Queue;\nimport java.util.Set;\nimport java.util.Stack;\nimport java.util.TreeMap;\nimport java.util.TreeSet;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\nimport static java.util.Comparator.*;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tMain main = new Main();\n\t\tmain.solve();\n\t\tmain.out.close();\n\t}\n\n\t// ======================================================================\n\tpublic void solve() {\n\t\tint N = ni();\n\t\tint X = ni() - 1;\n\t\tint Y = ni() - 1;\n\t\tint[] ans = new int[N+1];\n\t\tint index;\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tfor (int j = i+1; j < N; j++) {\n\t\t\t\tindex = Math.min(j-i, Math.abs(X-i) + 1 + Math.abs(Y-j));\n\t\t\t\tans[index]++;\n//\t\t\t\tif(index == 2)\tout.println(\"(\" + i + \", \" + j + \")\");\n\t\t\t}\n\t\t}\n\t\tfor (int i = 1; i < N; i++) {\n\t\t\tout.println(ans[i]);\n\t\t}\n\t}\n\t\n\t// ------------------------------------------\n\t// ライブラリ\n\t// ------------------------------------------\n\t// Print\n\tprivate PrintWriter out = new PrintWriter(System.out);\n\n\t// Scanner\n\tprivate FastScanner scan = new FastScanner();\n\n\tint ni() {\n\t\treturn scan.nextInt();\n\t}\n\n\tint[] ni(int n) {\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = ni();\n\t\t}\n\t\treturn a;\n\t}\n\n\tint[][] ni(int y, int x) {\n\t\tint[][] a = new int[y][x];\n\t\tfor (int i = 0; i < y; i++) {\n\t\t\tfor (int j = 0; j < x; j++) {\n\t\t\t\ta[i][j] = ni();\n\t\t\t}\n\t\t}\n\t\treturn a;\n\t}\n\n\tlong nl() {\n\t\treturn scan.nextLong();\n\t}\n\n\tlong[] nl(int n) {\n\t\tlong[] a = new long[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = nl();\n\t\t}\n\t\treturn a;\n\t}\n\n\tlong[][] nl(int y, int x) {\n\t\tlong[][] a = new long[y][x];\n\t\tfor (int i = 0; i < y; i++) {\n\t\t\tfor (int j = 0; j < x; j++) {\n\t\t\t\ta[i][j] = nl();\n\t\t\t}\n\t\t}\n\t\treturn a;\n\t}\n\n\tString ns() {\n\t\treturn scan.next();\n\t}\n\n\tString[] ns(int n) {\n\t\tString[] a = new String[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = ns();\n\t\t}\n\t\treturn a;\n\t}\n\n\tString[][] ns(int y, int x) {\n\t\tString[][] a = new String[y][x];\n\t\tfor (int i = 0; i < y; i++) {\n\t\t\tfor (int j = 0; j < x; j++) {\n\t\t\t\ta[i][j] = ns();\n\t\t\t}\n\t\t}\n\t\treturn a;\n\t}\n}\n\nclass FastScanner {\n\tprivate final InputStream in = System.in;\n\tprivate final byte[] buffer = new byte[1024];\n\tprivate int ptr = 0;\n\tprivate int buflen = 0;\n\n\tprivate boolean hasNextByte() {\n\t\tif (ptr < buflen) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\tptr = 0;\n\t\t\ttry {\n\t\t\t\tbuflen = in.read(buffer);\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (buflen <= 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tprivate int readByte() {\n\t\tif (hasNextByte())\n\t\t\treturn buffer[ptr++];\n\t\telse\n\t\t\treturn -1;\n\t}\n\n\tprivate static boolean isPrintableChar(int c) {\n\t\treturn 33 <= c && c <= 126;\n\t}\n\n\tpublic boolean hasNext() {\n\t\twhile (hasNextByte() && !isPrintableChar(buffer[ptr]))\n\t\t\tptr++;\n\t\treturn hasNextByte();\n\t}\n\n\tpublic String next() {\n\t\tif (!hasNext())\n\t\t\tthrow new NoSuchElementException();\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint b = readByte();\n\t\twhile (isPrintableChar(b)) {\n\t\t\tsb.appendCodePoint(b);\n\t\t\tb = readByte();\n\t\t}\n\t\treturn sb.toString();\n\t}\n\n\tpublic long nextLong() {\n\t\tif (!hasNext())\n\t\t\tthrow new NoSuchElementException();\n\t\tlong n = 0;\n\t\tboolean minus = false;\n\t\tint b = readByte();\n\t\tif (b == '-') {\n\t\t\tminus = true;\n\t\t\tb = readByte();\n\t\t}\n\t\tif (b < '0' || '9' < b) {\n\t\t\tthrow new NumberFormatException();\n\t\t}\n\t\twhile (true) {\n\t\t\tif ('0' <= b && b <= '9') {\n\t\t\t\tn *= 10;\n\t\t\t\tn += b - '0';\n\t\t\t} else if (b == -1 || !isPrintableChar(b)) {\n\t\t\t\treturn minus ? -n : n;\n\t\t\t} else {\n\t\t\t\tthrow new NumberFormatException();\n\t\t\t}\n\t\t\tb = readByte();\n\t\t}\n\t}\n\n\tpublic int nextInt() {\n\t\tlong nl = nextLong();\n\t\tif (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)\n\t\t\tthrow new NumberFormatException();\n\t\treturn (int) nl;\n\t}\n\n\tpublic double nextDouble() {\n\t\treturn Double.parseDouble(next());\n\t}\n}\n", "language": "Java", "metadata": {"date": 1590461740, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02726.html", "problem_id": "p02726", "resource_group": "high_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/Java/s192334070.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s192334070", "user_id": "u181039779"}, "prompt_components": {"gold_output": "5\n4\n1\n0\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.net.ConnectException;\nimport java.rmi.dgc.Lease;\nimport java.util.ArrayDeque;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.Deque;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.NoSuchElementException;\nimport java.util.Objects;\nimport java.util.PriorityQueue;\nimport java.util.Queue;\nimport java.util.Set;\nimport java.util.Stack;\nimport java.util.TreeMap;\nimport java.util.TreeSet;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\nimport static java.util.Comparator.*;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tMain main = new Main();\n\t\tmain.solve();\n\t\tmain.out.close();\n\t}\n\n\t// ======================================================================\n\tpublic void solve() {\n\t\tint N = ni();\n\t\tint X = ni() - 1;\n\t\tint Y = ni() - 1;\n\t\tint[] ans = new int[N+1];\n\t\tint index;\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tfor (int j = i+1; j < N; j++) {\n\t\t\t\tindex = Math.min(j-i, Math.abs(X-i) + 1 + Math.abs(Y-j));\n\t\t\t\tans[index]++;\n//\t\t\t\tif(index == 2)\tout.println(\"(\" + i + \", \" + j + \")\");\n\t\t\t}\n\t\t}\n\t\tfor (int i = 1; i < N; i++) {\n\t\t\tout.println(ans[i]);\n\t\t}\n\t}\n\t\n\t// ------------------------------------------\n\t// ライブラリ\n\t// ------------------------------------------\n\t// Print\n\tprivate PrintWriter out = new PrintWriter(System.out);\n\n\t// Scanner\n\tprivate FastScanner scan = new FastScanner();\n\n\tint ni() {\n\t\treturn scan.nextInt();\n\t}\n\n\tint[] ni(int n) {\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = ni();\n\t\t}\n\t\treturn a;\n\t}\n\n\tint[][] ni(int y, int x) {\n\t\tint[][] a = new int[y][x];\n\t\tfor (int i = 0; i < y; i++) {\n\t\t\tfor (int j = 0; j < x; j++) {\n\t\t\t\ta[i][j] = ni();\n\t\t\t}\n\t\t}\n\t\treturn a;\n\t}\n\n\tlong nl() {\n\t\treturn scan.nextLong();\n\t}\n\n\tlong[] nl(int n) {\n\t\tlong[] a = new long[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = nl();\n\t\t}\n\t\treturn a;\n\t}\n\n\tlong[][] nl(int y, int x) {\n\t\tlong[][] a = new long[y][x];\n\t\tfor (int i = 0; i < y; i++) {\n\t\t\tfor (int j = 0; j < x; j++) {\n\t\t\t\ta[i][j] = nl();\n\t\t\t}\n\t\t}\n\t\treturn a;\n\t}\n\n\tString ns() {\n\t\treturn scan.next();\n\t}\n\n\tString[] ns(int n) {\n\t\tString[] a = new String[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = ns();\n\t\t}\n\t\treturn a;\n\t}\n\n\tString[][] ns(int y, int x) {\n\t\tString[][] a = new String[y][x];\n\t\tfor (int i = 0; i < y; i++) {\n\t\t\tfor (int j = 0; j < x; j++) {\n\t\t\t\ta[i][j] = ns();\n\t\t\t}\n\t\t}\n\t\treturn a;\n\t}\n}\n\nclass FastScanner {\n\tprivate final InputStream in = System.in;\n\tprivate final byte[] buffer = new byte[1024];\n\tprivate int ptr = 0;\n\tprivate int buflen = 0;\n\n\tprivate boolean hasNextByte() {\n\t\tif (ptr < buflen) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\tptr = 0;\n\t\t\ttry {\n\t\t\t\tbuflen = in.read(buffer);\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (buflen <= 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tprivate int readByte() {\n\t\tif (hasNextByte())\n\t\t\treturn buffer[ptr++];\n\t\telse\n\t\t\treturn -1;\n\t}\n\n\tprivate static boolean isPrintableChar(int c) {\n\t\treturn 33 <= c && c <= 126;\n\t}\n\n\tpublic boolean hasNext() {\n\t\twhile (hasNextByte() && !isPrintableChar(buffer[ptr]))\n\t\t\tptr++;\n\t\treturn hasNextByte();\n\t}\n\n\tpublic String next() {\n\t\tif (!hasNext())\n\t\t\tthrow new NoSuchElementException();\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint b = readByte();\n\t\twhile (isPrintableChar(b)) {\n\t\t\tsb.appendCodePoint(b);\n\t\t\tb = readByte();\n\t\t}\n\t\treturn sb.toString();\n\t}\n\n\tpublic long nextLong() {\n\t\tif (!hasNext())\n\t\t\tthrow new NoSuchElementException();\n\t\tlong n = 0;\n\t\tboolean minus = false;\n\t\tint b = readByte();\n\t\tif (b == '-') {\n\t\t\tminus = true;\n\t\t\tb = readByte();\n\t\t}\n\t\tif (b < '0' || '9' < b) {\n\t\t\tthrow new NumberFormatException();\n\t\t}\n\t\twhile (true) {\n\t\t\tif ('0' <= b && b <= '9') {\n\t\t\t\tn *= 10;\n\t\t\t\tn += b - '0';\n\t\t\t} else if (b == -1 || !isPrintableChar(b)) {\n\t\t\t\treturn minus ? -n : n;\n\t\t\t} else {\n\t\t\t\tthrow new NumberFormatException();\n\t\t\t}\n\t\t\tb = readByte();\n\t\t}\n\t}\n\n\tpublic int nextInt() {\n\t\tlong nl = nextLong();\n\t\tif (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)\n\t\t\tthrow new NumberFormatException();\n\t\treturn (int) nl;\n\t}\n\n\tpublic double nextDouble() {\n\t\treturn Double.parseDouble(next());\n\t}\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have an undirected graph G with N vertices numbered 1 to N and N edges as follows:\n\nFor each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.\n\nThere is an edge between Vertex X and Vertex Y.\n\nFor each k=1,2,...,N-1, solve the problem below:\n\nFind the number of pairs of integers (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j in G is k.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq X,Y \\leq N\n\nX+1 < Y\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X Y\n\nOutput\n\nFor each k=1, 2, ..., N-1 in this order, print a line containing the answer to the problem.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n5\n4\n1\n0\n\nThe graph in this input is as follows:\n\nThere are five pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 1: (1,2)\\,,(2,3)\\,,(2,4)\\,,(3,4)\\,,(4,5).\n\nThere are four pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 2: (1,3)\\,,(1,4)\\,,(2,5)\\,,(3,5).\n\nThere is one pair (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 3: (1,5).\n\nThere are no pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 4.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n3\n0\n\nThe graph in this input is as follows:\n\nSample Input 3\n\n7 3 7\n\nSample Output 3\n\n7\n8\n4\n2\n0\n0\n\nSample Input 4\n\n10 4 8\n\nSample Output 4\n\n10\n12\n10\n8\n4\n1\n0\n0\n0", "sample_input": "5 2 4\n"}, "reference_outputs": ["5\n4\n1\n0\n"], "source_document_id": "p02726", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have an undirected graph G with N vertices numbered 1 to N and N edges as follows:\n\nFor each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.\n\nThere is an edge between Vertex X and Vertex Y.\n\nFor each k=1,2,...,N-1, solve the problem below:\n\nFind the number of pairs of integers (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j in G is k.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq X,Y \\leq N\n\nX+1 < Y\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X Y\n\nOutput\n\nFor each k=1, 2, ..., N-1 in this order, print a line containing the answer to the problem.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n5\n4\n1\n0\n\nThe graph in this input is as follows:\n\nThere are five pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 1: (1,2)\\,,(2,3)\\,,(2,4)\\,,(3,4)\\,,(4,5).\n\nThere are four pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 2: (1,3)\\,,(1,4)\\,,(2,5)\\,,(3,5).\n\nThere is one pair (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 3: (1,5).\n\nThere are no pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 4.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n3\n0\n\nThe graph in this input is as follows:\n\nSample Input 3\n\n7 3 7\n\nSample Output 3\n\n7\n8\n4\n2\n0\n0\n\nSample Input 4\n\n10 4 8\n\nSample Output 4\n\n10\n12\n10\n8\n4\n1\n0\n0\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4253, "cpu_time_ms": 93, "memory_kb": 23380}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s779448609", "group_id": "codeNet:p02726", "input_text": "import java.util.Scanner;\n \nclass Main{\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int x = sc.nextInt();\n int y = sc.nextInt();\n int ans[] = new int[n];\n int c = y-x;\n int d;\n for(int i = 1; i < n; i++){\n for(int j = n; j > i; j--){\n d = j-i;\n if(i<=x&&y<=j){\n ans[x-i+j-y+1]++;\n } else if(i<=x&&j i; j--){\n d = j-i;\n if(i<=x&&y<=j){\n ans[x-i+j-y+1]++;\n } else if(i<=x&&j= '0' && c <= '9');\n\n if (neg)\n return -ret;\n return ret;\n }\n\n public long nextLong() throws IOException\n {\n long ret = 0;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n do {\n ret = ret * 10 + c - '0';\n }\n while ((c = read()) >= '0' && c <= '9');\n if (neg)\n return -ret;\n return ret;\n }\n\n public double nextDouble() throws IOException\n {\n double ret = 0, div = 1;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n\n do {\n ret = ret * 10 + c - '0';\n }\n while ((c = read()) >= '0' && c <= '9');\n\n if (c == '.')\n {\n while ((c = read()) >= '0' && c <= '9')\n {\n ret += (c - '0') / (div *= 10);\n }\n }\n\n if (neg)\n return -ret;\n return ret;\n }\n\n private void fillBuffer() throws IOException\n {\n bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);\n if (bytesRead == -1)\n buffer[0] = -1;\n }\n\n private byte read() throws IOException\n {\n if (bufferPointer == bytesRead)\n fillBuffer();\n return buffer[bufferPointer++];\n }\n\n public void close() throws IOException\n {\n if (din == null)\n return;\n din.close();\n }\n }\n\n static class Edge {\n int source;\n int destination;\n int weight;\n\n public Edge(int source, int destination, int weight) {\n this.source = source;\n this.destination = destination;\n this.weight = weight;\n }\n }\n\n static class Graph {\n int vertices;\n ArrayList> al;\n\n public Graph(int vertices) {\n this.vertices = vertices;\n al = new ArrayList<>(vertices);\n for (int i = 0; i < vertices; i++) {\n al.add(new ArrayList());\n }\n }\n\n public static void addEdgeUndirected(ArrayList> al, int source, int destination, int weight) {\n al.get(source).add(new Edge(source, destination, weight));\n al.get(destination).add(new Edge(destination, source, weight));\n }\n public static void shortestpath(ArrayList> al, int v, int root,int k,int[] count) {\n boolean[] visited = new boolean[v];\n int[] dist = new int[v];\n dist[root] = 0;\n Queue q = new LinkedList<>();\n visited[root] = true;\n q.add(root);\n while (!q.isEmpty()) {\n int u = q.poll();\n for (int i = 0; i < al.get(u).size(); i++) {\n if (!visited[al.get(u).get(i).destination]) {\n visited[al.get(u).get(i).destination] = true;\n q.add(al.get(u).get(i).destination);\n dist[al.get(u).get(i).destination] = dist[u] + 1;\n if(dist[al.get(u).get(i).destination]==k) count[k-1]++;\n }\n }\n }\n }\n }\n\n public static void main(String[] args) throws IOException {\n Reader r = new Reader();\n int n = r.nextInt();\n int[] count = new int[n];\n Graph g = new Graph(n);\n for (int i = 0; i < n - 1; i++) {\n g.addEdgeUndirected(g.al, i, i + 1, 0);\n }\n int x = r.nextInt() - 1;\n int y = r.nextInt() - 1;\n g.addEdgeUndirected(g.al, x, y, 0);\n for (int k = 1; k < n; k++)\n for (int j = 0; j < n; j++)\n g.shortestpath(g.al, g.vertices, j, k, count);\n\n for (int i = 0; i = '0' && c <= '9');\n\n if (neg)\n return -ret;\n return ret;\n }\n\n public long nextLong() throws IOException\n {\n long ret = 0;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n do {\n ret = ret * 10 + c - '0';\n }\n while ((c = read()) >= '0' && c <= '9');\n if (neg)\n return -ret;\n return ret;\n }\n\n public double nextDouble() throws IOException\n {\n double ret = 0, div = 1;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n\n do {\n ret = ret * 10 + c - '0';\n }\n while ((c = read()) >= '0' && c <= '9');\n\n if (c == '.')\n {\n while ((c = read()) >= '0' && c <= '9')\n {\n ret += (c - '0') / (div *= 10);\n }\n }\n\n if (neg)\n return -ret;\n return ret;\n }\n\n private void fillBuffer() throws IOException\n {\n bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);\n if (bytesRead == -1)\n buffer[0] = -1;\n }\n\n private byte read() throws IOException\n {\n if (bufferPointer == bytesRead)\n fillBuffer();\n return buffer[bufferPointer++];\n }\n\n public void close() throws IOException\n {\n if (din == null)\n return;\n din.close();\n }\n }\n\n static class Edge {\n int source;\n int destination;\n int weight;\n\n public Edge(int source, int destination, int weight) {\n this.source = source;\n this.destination = destination;\n this.weight = weight;\n }\n }\n\n static class Graph {\n int vertices;\n ArrayList> al;\n\n public Graph(int vertices) {\n this.vertices = vertices;\n al = new ArrayList<>(vertices);\n for (int i = 0; i < vertices; i++) {\n al.add(new ArrayList());\n }\n }\n\n public static void addEdgeUndirected(ArrayList> al, int source, int destination, int weight) {\n al.get(source).add(new Edge(source, destination, weight));\n al.get(destination).add(new Edge(destination, source, weight));\n }\n public static void shortestpath(ArrayList> al, int v, int root,int k,int[] count) {\n boolean[] visited = new boolean[v];\n int[] dist = new int[v];\n dist[root] = 0;\n Queue q = new LinkedList<>();\n visited[root] = true;\n q.add(root);\n while (!q.isEmpty()) {\n int u = q.poll();\n for (int i = 0; i < al.get(u).size(); i++) {\n if (!visited[al.get(u).get(i).destination]) {\n visited[al.get(u).get(i).destination] = true;\n q.add(al.get(u).get(i).destination);\n dist[al.get(u).get(i).destination] = dist[u] + 1;\n if(dist[al.get(u).get(i).destination]==k) count[k-1]++;\n }\n }\n }\n }\n }\n\n public static void main(String[] args) throws IOException {\n Reader r = new Reader();\n int n = r.nextInt();\n int[] count = new int[n];\n Graph g = new Graph(n);\n for (int i = 0; i < n - 1; i++) {\n g.addEdgeUndirected(g.al, i, i + 1, 0);\n }\n int x = r.nextInt() - 1;\n int y = r.nextInt() - 1;\n g.addEdgeUndirected(g.al, x, y, 0);\n for (int k = 1; k < n; k++)\n for (int j = 0; j < n; j++)\n g.shortestpath(g.al, g.vertices, j, k, count);\n\n for (int i = 0; i 0?gcd(b,a%b):a;}\n\tstatic long lcm (long a, long b) {return a*b/gcd(a,b);}\n\tstatic int max(int a,int b) {return a>b?a:b;}\n\tstatic int min(int a,int b) {return adeque=new ArrayDeque();\n\t\t\t\tDequecost=new ArrayDeque();\n\t\t\t\tvisited[i]=true;\n\t\t\t\tdeque.add(i);\n\t\t\t\tcost.add(0);\n\t\t\t\twhile(true) {\n\t\t\t\t\tint pla=deque.pop();\n\t\t\t\t\tint c=cost.pop();\n\t\t\t\t\tif(pla==j) {ans[c]++;break;}\n\t\t\t\t\tif(pla!=a-1&&!visited[pla+1]) {deque.add(pla+1);cost.add(c+1);visited[pla+1]=true;}\n\t\t\t\t\tif(pla!=0&&!visited[pla-1]) {deque.add(pla-1);cost.add(c+1);visited[pla-1]=true;}\n\t\t\t\t\tif(pla==x&&!visited[y]) {deque.add(y);cost.add(c+1);visited[y]=true;}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i=1;i1) {\n\t\t\tint mid=(right+left)/2;\n\t\t\tif(a[mid]1) {\n\t\t\tint mid=(right+left)/2;\n\t\t\tif(a[mid]<=key) {\n\t\t\t\tleft=mid;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tright=mid;\n\t\t\t}\n\t\t}\n\t\treturn left;\n\t}\n\tstatic boolean isPrime (long n) {\n\t\tif (n==2) return true;\n\t\tif (n<2 || n%2==0) return false;\n\t\tdouble d = Math.sqrt(n);\n\t\tfor (int i=3; i<=d; i+=2)if(n%i==0){return false;}\n\t\treturn true;\n\t}\n\tstatic int upper_division(int a,int b) {\n\t\tif(a%b==0) {\n\t\t\treturn a/b;\n\t\t}\n\t\telse {\n\t\t\treturn a/b+1;\n\t\t}\n\t}\n\tstatic long lupper_division(long a,long b) {\n\t\tif(a%b==0) {\n\t\t\treturn a/b;\n\t\t}\n\t\telse {\n\t\t\treturn a/b+1;\n\t\t}\n\t}\n\tstatic int[] setArray(int a) {\n\t\tint b[]=new int[a];\n\t\tfor(int i=0;iInteger.compare(x[0],y[0]));\n\t\treturn a;\n\t}\n\tpublic static long[][] ldoublesort(long[][]a) {\n\t\tArrays.sort(a,(x,y)->Long.compare(x[0],y[0]));\n\t\treturn a;\n\t}\n\tstatic long modpow(long x,long n,long mo) {\n\t\tlong sum=1;\n\t\twhile(n>0) {\n\t\t\tif((n&1)==1) {\n\t\t\t\tsum=sum*x%mo;\n\t\t\t}\n\t\t\tx=x*x%mo;\n\t\t\tn>>=1;\n\t\t}\n\t\treturn sum;\n\t}\n\tpublic static char[] revch(char ch[]) {\n\t\tchar ret[]=new char[ch.length];\n\t\tfor(int i=ch.length-1,j=0;i>=0;i--,j++) {\n\t\t\tret[j]=ch[i];\n\t\t}\n\t\treturn ret;\n\t}\n\tpublic static int[] revint(int ch[]) {\n\t\tint ret[]=new int[ch.length];\n\t\tfor(int i=ch.length-1,j=0;i>=0;i--,j++) {\n\t\t\tret[j]=ch[i];\n\t\t}\n\t\treturn ret;\n\t}\n\tpublic static void warshall_floyd(int v[][],int n) {\n\t\tfor(int k=0;k Integer.MAX_VALUE) throw new NumberFormatException();\n\t\treturn (int) nl;\n\t}\n\tpublic double nextDouble() { return Double.parseDouble(next());}\n\tpublic char nextchar() {\n\t\ttry { return (char)System.in.read(); } catch(Exception e) {\n\t\t\tthrow new RuntimeException(e);\n\t\t}\n\t}\n}\n", "language": "Java", "metadata": {"date": 1585446732, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02726.html", "problem_id": "p02726", "resource_group": "high_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/Java/s679819171.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s679819171", "user_id": "u274962354"}, "prompt_components": {"gold_output": "5\n4\n1\n0\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.ArrayDeque;\nimport java.util.Arrays;\nimport java.util.Deque;\nimport java.util.NoSuchElementException;\nimport java.util.Random;\nimport java.util.Scanner;\n\nclass UnionFind{\n\tint Parent[];\n\tUnionFind(int n){//Initialize by -1\n\t\tParent=new int[n];\n\t\tArrays.fill(Parent, -1);\n\t}\n\tint root(int A) {//In which tree is A?\n\t\tif(Parent[A]<0)return A;\n\t\treturn Parent[A]=root(Parent[A]);\n\t}\n\tint size(int A) {//size of tree which is include A\n\t\treturn -Parent[root(A)];\n\t}\n\tboolean connect(int A,int B) {//Connect A and B\n\t\tA=root(A);\n\t\tB=root(B);\n\t\tif(A==B) return false;\n\t\tif(size(A)0?gcd(b,a%b):a;}\n\tstatic long lcm (long a, long b) {return a*b/gcd(a,b);}\n\tstatic int max(int a,int b) {return a>b?a:b;}\n\tstatic int min(int a,int b) {return adeque=new ArrayDeque();\n\t\t\t\tDequecost=new ArrayDeque();\n\t\t\t\tvisited[i]=true;\n\t\t\t\tdeque.add(i);\n\t\t\t\tcost.add(0);\n\t\t\t\twhile(true) {\n\t\t\t\t\tint pla=deque.pop();\n\t\t\t\t\tint c=cost.pop();\n\t\t\t\t\tif(pla==j) {ans[c]++;break;}\n\t\t\t\t\tif(pla!=a-1&&!visited[pla+1]) {deque.add(pla+1);cost.add(c+1);visited[pla+1]=true;}\n\t\t\t\t\tif(pla!=0&&!visited[pla-1]) {deque.add(pla-1);cost.add(c+1);visited[pla-1]=true;}\n\t\t\t\t\tif(pla==x&&!visited[y]) {deque.add(y);cost.add(c+1);visited[y]=true;}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i=1;i1) {\n\t\t\tint mid=(right+left)/2;\n\t\t\tif(a[mid]1) {\n\t\t\tint mid=(right+left)/2;\n\t\t\tif(a[mid]<=key) {\n\t\t\t\tleft=mid;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tright=mid;\n\t\t\t}\n\t\t}\n\t\treturn left;\n\t}\n\tstatic boolean isPrime (long n) {\n\t\tif (n==2) return true;\n\t\tif (n<2 || n%2==0) return false;\n\t\tdouble d = Math.sqrt(n);\n\t\tfor (int i=3; i<=d; i+=2)if(n%i==0){return false;}\n\t\treturn true;\n\t}\n\tstatic int upper_division(int a,int b) {\n\t\tif(a%b==0) {\n\t\t\treturn a/b;\n\t\t}\n\t\telse {\n\t\t\treturn a/b+1;\n\t\t}\n\t}\n\tstatic long lupper_division(long a,long b) {\n\t\tif(a%b==0) {\n\t\t\treturn a/b;\n\t\t}\n\t\telse {\n\t\t\treturn a/b+1;\n\t\t}\n\t}\n\tstatic int[] setArray(int a) {\n\t\tint b[]=new int[a];\n\t\tfor(int i=0;iInteger.compare(x[0],y[0]));\n\t\treturn a;\n\t}\n\tpublic static long[][] ldoublesort(long[][]a) {\n\t\tArrays.sort(a,(x,y)->Long.compare(x[0],y[0]));\n\t\treturn a;\n\t}\n\tstatic long modpow(long x,long n,long mo) {\n\t\tlong sum=1;\n\t\twhile(n>0) {\n\t\t\tif((n&1)==1) {\n\t\t\t\tsum=sum*x%mo;\n\t\t\t}\n\t\t\tx=x*x%mo;\n\t\t\tn>>=1;\n\t\t}\n\t\treturn sum;\n\t}\n\tpublic static char[] revch(char ch[]) {\n\t\tchar ret[]=new char[ch.length];\n\t\tfor(int i=ch.length-1,j=0;i>=0;i--,j++) {\n\t\t\tret[j]=ch[i];\n\t\t}\n\t\treturn ret;\n\t}\n\tpublic static int[] revint(int ch[]) {\n\t\tint ret[]=new int[ch.length];\n\t\tfor(int i=ch.length-1,j=0;i>=0;i--,j++) {\n\t\t\tret[j]=ch[i];\n\t\t}\n\t\treturn ret;\n\t}\n\tpublic static void warshall_floyd(int v[][],int n) {\n\t\tfor(int k=0;k Integer.MAX_VALUE) throw new NumberFormatException();\n\t\treturn (int) nl;\n\t}\n\tpublic double nextDouble() { return Double.parseDouble(next());}\n\tpublic char nextchar() {\n\t\ttry { return (char)System.in.read(); } catch(Exception e) {\n\t\t\tthrow new RuntimeException(e);\n\t\t}\n\t}\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have an undirected graph G with N vertices numbered 1 to N and N edges as follows:\n\nFor each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.\n\nThere is an edge between Vertex X and Vertex Y.\n\nFor each k=1,2,...,N-1, solve the problem below:\n\nFind the number of pairs of integers (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j in G is k.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq X,Y \\leq N\n\nX+1 < Y\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X Y\n\nOutput\n\nFor each k=1, 2, ..., N-1 in this order, print a line containing the answer to the problem.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n5\n4\n1\n0\n\nThe graph in this input is as follows:\n\nThere are five pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 1: (1,2)\\,,(2,3)\\,,(2,4)\\,,(3,4)\\,,(4,5).\n\nThere are four pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 2: (1,3)\\,,(1,4)\\,,(2,5)\\,,(3,5).\n\nThere is one pair (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 3: (1,5).\n\nThere are no pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 4.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n3\n0\n\nThe graph in this input is as follows:\n\nSample Input 3\n\n7 3 7\n\nSample Output 3\n\n7\n8\n4\n2\n0\n0\n\nSample Input 4\n\n10 4 8\n\nSample Output 4\n\n10\n12\n10\n8\n4\n1\n0\n0\n0", "sample_input": "5 2 4\n"}, "reference_outputs": ["5\n4\n1\n0\n"], "source_document_id": "p02726", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have an undirected graph G with N vertices numbered 1 to N and N edges as follows:\n\nFor each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.\n\nThere is an edge between Vertex X and Vertex Y.\n\nFor each k=1,2,...,N-1, solve the problem below:\n\nFind the number of pairs of integers (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j in G is k.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq X,Y \\leq N\n\nX+1 < Y\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X Y\n\nOutput\n\nFor each k=1, 2, ..., N-1 in this order, print a line containing the answer to the problem.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n5\n4\n1\n0\n\nThe graph in this input is as follows:\n\nThere are five pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 1: (1,2)\\,,(2,3)\\,,(2,4)\\,,(3,4)\\,,(4,5).\n\nThere are four pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 2: (1,3)\\,,(1,4)\\,,(2,5)\\,,(3,5).\n\nThere is one pair (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 3: (1,5).\n\nThere are no pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 4.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n3\n0\n\nThe graph in this input is as follows:\n\nSample Input 3\n\n7 3 7\n\nSample Output 3\n\n7\n8\n4\n2\n0\n0\n\nSample Input 4\n\n10 4 8\n\nSample Output 4\n\n10\n12\n10\n8\n4\n1\n0\n0\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6767, "cpu_time_ms": 2110, "memory_kb": 343096}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s958888335", "group_id": "codeNet:p02729", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint m = sc.nextInt();\n\t\tsc.close();\n\n\t\tSystem.out.println(n * (n - 1) / 2 + m * (m - 1) / 2);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1584925366, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02729.html", "problem_id": "p02729", "resource_group": "high_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/Java/s958888335.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s958888335", "user_id": "u522636435"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint m = sc.nextInt();\n\t\tsc.close();\n\n\t\tSystem.out.println(n * (n - 1) / 2 + m * (m - 1) / 2);\n\t}\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": 270, "cpu_time_ms": 122, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s745405483", "group_id": "codeNet:p02730", "input_text": "import java.util.*;\npublic class Main{\n static boolean palin(String s)\n {char c[]=s.toCharArray();\n int n=c.length;\n for(int i=0;i> 32);}\n\tstatic public final int getPair2(long v) {return (int)(v & 0xFFFFFFFF);}\n\n\tstatic public final long quad(long a, long b, long c, long d) {\n\t\treturn ((a&0xFFFF)<< 48) + ((b&0xFFFF)<< 32) + ((c&0xFFFF)<< 16) +(d&0xFFFF);}\n\tstatic public final int getQuad1(long v) {return (int)( v >> 48 );}\n\tstatic public final int getQuad2(long v) {return (int)((v >> 32) & 0xFFFF);}\n\tstatic public final int getQuad3(long v) {return (int)((v >> 16) & 0xFFFF);}\n\tstatic public final int getQuad4(long v) {return (int)( v & 0xFFFF);}\n\n\tstatic public final long record(int e, int m, int i) {\n\t\treturn quad(-1, e, m, i);\n\t}\n\tstatic public final int re(long record) {\n\t\treturn getQuad2(record);\n\t}\n\tstatic public final int rm(long record) {\n\t\treturn getQuad3(record);\n\t}\n\tstatic public final int ri(long record) {\n\t\treturn getQuad4(record);\n\t}\n\n\t//------------------------------------------\n\n\tprivate int p;\n\tprivate int[] inv;\n\tprivate int[] fact;\n\tprivate int[] finv;\n\tpublic final int mod(long v) {\n\t\treturn mod(v, p);\n\t}\n\tstatic public final int mod(long v, int M) {\n\t\tv %= M;\n\t\treturn (int)(v < 0 ? v+M : v);\n\t}\n\t/**\n\t * a * b (mod p)\n\t * 事前にinitFactを行うこと。\n\t */\n\tpublic final int mul(long a, long b) {\n\t\treturn mod(a*b);\n\t}\n\tpublic final void initFact(double limit, double p) {\n\t\tinitFact((int)limit, (int)p);\n\t}\n\t/**\n\t * 集合数nの組み合わせ計算を高速化するため、事前に計算を行う。\n\t * 組み合わせ数はpで割った余りを算出する。\n\t */\n\tpublic final void initFact(int n, int p) {\n\t\tthis.p = p;\n\t\tthis.inv = new int[n+1];\n\t\tthis.fact = new int[n+1];\n\t\tthis.finv = new int[n+1];\n\t\tfact[1] = finv[1] = inv[0] = inv[1] = 1;\n\t\tfor(int i=2;i<=n;i++) {\n\t\t\tint a = p / i;\n\t\t\tint b = p % i;\n\t\t\tinv[i] = mul(-a, inv[b]);\n\t\t\tfact[i] = mul(fact[i-1], i);\n\t\t\tfinv[i] = mul(finv[i-1], inv[i]);\n\t\t}\n\t}\n\t/**\n\t * mCnを計算する。事前にinitFactを実行すること。\n\t */\n\tpublic final int comb(int m, int n) {\n\t\treturn mul(mul(fact[m], finv[n]), finv[m-n]);\n\t}\n\t/**\n\t * a^b (mod M)を計算する。\n\t */\n\tpublic static long pow(long a, long b, int M) {\n\t\tlong ret = 1;\n\t\tlong tmp = a;\n\t\twhile (b > 0) {\n\t\t\tif ((b & 1) == 1) {\n\t\t\t\tret = (ret * tmp) % M;\n\t\t\t}\n\t\t\ttmp = (tmp * tmp) % M;\n\t\t\tb = b >> 1;\n\t\t}\n\t\treturn ret;\n\t}\n\t/**\n\t * nCk (mod M)を計算する。\n\t */\n\tpublic static int nCk(int n, int k, int M) {\n\t\tlong ret = 1;\n\t\tint min = Math.min(k, n - k);\n\t\t// 分母\n\t\tfor (int i = 1; i <= min; i++) {\n\t\t\t// a^-1 ≡ a^M-2 ※フェルマーの小定理\n\t\t\tret = (ret * pow(i, M - 2, M)) % M;\n\t\t}\n\t\t// 分子\n\t\tfor (int i = n - min + 1; i <= n; i++) {\n\t\t\tret = (ret * i) % M;\n\t\t}\n\t\treturn (int) ret;\n\t}\n\t//------------------------------------------\n\tstatic long lcm (long a, long b) {\n\t\tlong temp;\n\t\tlong c = a;\n\t\tc *= b;\n\t\twhile((temp = a%b)!=0) {\n\t\t\ta = b;\n\t\t\tb = temp;\n\t\t}\n\t\treturn (long)(c/b);\n\t}\n\n\t//------------------------------------------\n\n\tstatic class DisjointSetUnion {\n\t\tpublic int[] parent;\n\t\tpublic int[] weight;\n\t\tpublic int count;\n\n\t\tpublic DisjointSetUnion(int nodes) {\n\t\t\tcount = nodes;\n\t\t\tparent = new int[nodes];\n\t\t\tweight = new int[nodes];\n\t\t\tfor (int i = 0; i < nodes; i++) {\n\t\t\t\tparent[i] = i;\n\t\t\t\tweight[i] = 1;\n\t\t\t}\n\t\t}\n\t\t//\"find\"\n\t\tpublic int root(int p) {\n\t\t\twhile (p != parent[p]) {\n\t\t\t\tp = parent[p];\n\t\t\t}\n\t\t\treturn p;\n\t\t}\n\n\t\t//\"union\"\n\t\tpublic void connect(int p, int q) {\n\t\t\tint rootP = root(p);\n\t\t\tint rootQ = root(q);\n\t\t\tif (rootP == rootQ) return;\n\t\t\tif (weight[rootP] < weight[rootQ]) {\n\t\t\t\tparent[rootP] = rootQ;\n\t\t\t\tweight[rootQ] += weight[rootP];\n\t\t\t} else {\n\t\t\t\tparent[rootQ] = rootP;\n\t\t\t\tweight[rootP] += weight[rootQ];\n\t\t\t}\n\t\t\tcount--;\n\t\t}\n\n\t\tpublic boolean connected(int p, int q) {\n\t\t\treturn root(p) == root(q);\n\t\t}\n\t}\n\tstatic class IntList{\n\t\tint tail = 0;\n\t\tfinal int[] element;\n\t\tpublic IntList(int cap) {\n\t\t\telement = new int[cap];\n\t\t}\n\t\tpublic int size() {\n\t\t\treturn tail;\n\t\t}\n\t\tpublic int get(int index) {\n\t\t\treturn element[index];\n\t\t}\n\t\tpublic void reset() {\n\t\t\ttail = 0;\n\t\t}\n\t\tpublic void add(int v) {\n\t\t\telement[tail++] = v;\n\t\t}\n\t}\n\tstatic class LongList{\n\t\tint tail = 0;\n\t\tint head = 0;\n\t\tfinal long[] element;\n\t\tpublic LongList(int cap) {\n\t\t\telement = new long[cap];\n\t\t}\n\t\tpublic int size() {\n\t\t\treturn (element.length+tail-head)%element.length;\n\t\t}\n\t\tpublic long remove() {\n\t\t\tlong v = element[head];\n\t\t\thead = (head+1)%element.length;\n\t\t\treturn v;\n\t\t}\n\t\tpublic long get(int index) {\n\t\t\treturn element[index];\n\t\t}\n\t\tpublic void reset() {\n\t\t\thead = 0;\n\t\t\ttail = 0;\n\t\t}\n\t\tpublic void add(long v) {\n\t\t\telement[tail] = v;\n\t\t\ttail = (tail+1)%element.length;\n\t\t}\n\t\tpublic boolean hasElement() {\n\t\t\treturn this.size()!=0;\n\t\t}\n\t}\n\n\tpublic void exec() throws Exception{\n\t\tfinal int L = sc.nextInt();\n\t\tfinal double a = ((double)L)/3;\n\t\tout.println(String.format(\"%.12f\", a*a*a));\n\t}\n}\n", "language": "Java", "metadata": {"date": 1584927095, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02731.html", "problem_id": "p02731", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02731/input.txt", "sample_output_relpath": "derived/input_output/data/p02731/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02731/Java/s576478202.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s576478202", "user_id": "u365078800"}, "prompt_components": {"gold_output": "1.000000000000\n", "input_to_evaluate": "import java.io.PrintStream;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) throws Exception{\n\t\tnew Main(new Scanner(System.in), System.out, System.err).exec();\n\t}\n\tpublic final Scanner sc;\n\tpublic final PrintStream out, err;\n\tpublic Main(final Scanner sc, final PrintStream out, final PrintStream err) {\n\t\tthis.sc = sc;this.out = out;this.err = err;\n\t}\n\tstatic public final long pair(int a, int b) {return (((long)a) << 32) + b;}\n\tstatic public final int getPair1(long v) {return (int)(v >> 32);}\n\tstatic public final int getPair2(long v) {return (int)(v & 0xFFFFFFFF);}\n\n\tstatic public final long quad(long a, long b, long c, long d) {\n\t\treturn ((a&0xFFFF)<< 48) + ((b&0xFFFF)<< 32) + ((c&0xFFFF)<< 16) +(d&0xFFFF);}\n\tstatic public final int getQuad1(long v) {return (int)( v >> 48 );}\n\tstatic public final int getQuad2(long v) {return (int)((v >> 32) & 0xFFFF);}\n\tstatic public final int getQuad3(long v) {return (int)((v >> 16) & 0xFFFF);}\n\tstatic public final int getQuad4(long v) {return (int)( v & 0xFFFF);}\n\n\tstatic public final long record(int e, int m, int i) {\n\t\treturn quad(-1, e, m, i);\n\t}\n\tstatic public final int re(long record) {\n\t\treturn getQuad2(record);\n\t}\n\tstatic public final int rm(long record) {\n\t\treturn getQuad3(record);\n\t}\n\tstatic public final int ri(long record) {\n\t\treturn getQuad4(record);\n\t}\n\n\t//------------------------------------------\n\n\tprivate int p;\n\tprivate int[] inv;\n\tprivate int[] fact;\n\tprivate int[] finv;\n\tpublic final int mod(long v) {\n\t\treturn mod(v, p);\n\t}\n\tstatic public final int mod(long v, int M) {\n\t\tv %= M;\n\t\treturn (int)(v < 0 ? v+M : v);\n\t}\n\t/**\n\t * a * b (mod p)\n\t * 事前にinitFactを行うこと。\n\t */\n\tpublic final int mul(long a, long b) {\n\t\treturn mod(a*b);\n\t}\n\tpublic final void initFact(double limit, double p) {\n\t\tinitFact((int)limit, (int)p);\n\t}\n\t/**\n\t * 集合数nの組み合わせ計算を高速化するため、事前に計算を行う。\n\t * 組み合わせ数はpで割った余りを算出する。\n\t */\n\tpublic final void initFact(int n, int p) {\n\t\tthis.p = p;\n\t\tthis.inv = new int[n+1];\n\t\tthis.fact = new int[n+1];\n\t\tthis.finv = new int[n+1];\n\t\tfact[1] = finv[1] = inv[0] = inv[1] = 1;\n\t\tfor(int i=2;i<=n;i++) {\n\t\t\tint a = p / i;\n\t\t\tint b = p % i;\n\t\t\tinv[i] = mul(-a, inv[b]);\n\t\t\tfact[i] = mul(fact[i-1], i);\n\t\t\tfinv[i] = mul(finv[i-1], inv[i]);\n\t\t}\n\t}\n\t/**\n\t * mCnを計算する。事前にinitFactを実行すること。\n\t */\n\tpublic final int comb(int m, int n) {\n\t\treturn mul(mul(fact[m], finv[n]), finv[m-n]);\n\t}\n\t/**\n\t * a^b (mod M)を計算する。\n\t */\n\tpublic static long pow(long a, long b, int M) {\n\t\tlong ret = 1;\n\t\tlong tmp = a;\n\t\twhile (b > 0) {\n\t\t\tif ((b & 1) == 1) {\n\t\t\t\tret = (ret * tmp) % M;\n\t\t\t}\n\t\t\ttmp = (tmp * tmp) % M;\n\t\t\tb = b >> 1;\n\t\t}\n\t\treturn ret;\n\t}\n\t/**\n\t * nCk (mod M)を計算する。\n\t */\n\tpublic static int nCk(int n, int k, int M) {\n\t\tlong ret = 1;\n\t\tint min = Math.min(k, n - k);\n\t\t// 分母\n\t\tfor (int i = 1; i <= min; i++) {\n\t\t\t// a^-1 ≡ a^M-2 ※フェルマーの小定理\n\t\t\tret = (ret * pow(i, M - 2, M)) % M;\n\t\t}\n\t\t// 分子\n\t\tfor (int i = n - min + 1; i <= n; i++) {\n\t\t\tret = (ret * i) % M;\n\t\t}\n\t\treturn (int) ret;\n\t}\n\t//------------------------------------------\n\tstatic long lcm (long a, long b) {\n\t\tlong temp;\n\t\tlong c = a;\n\t\tc *= b;\n\t\twhile((temp = a%b)!=0) {\n\t\t\ta = b;\n\t\t\tb = temp;\n\t\t}\n\t\treturn (long)(c/b);\n\t}\n\n\t//------------------------------------------\n\n\tstatic class DisjointSetUnion {\n\t\tpublic int[] parent;\n\t\tpublic int[] weight;\n\t\tpublic int count;\n\n\t\tpublic DisjointSetUnion(int nodes) {\n\t\t\tcount = nodes;\n\t\t\tparent = new int[nodes];\n\t\t\tweight = new int[nodes];\n\t\t\tfor (int i = 0; i < nodes; i++) {\n\t\t\t\tparent[i] = i;\n\t\t\t\tweight[i] = 1;\n\t\t\t}\n\t\t}\n\t\t//\"find\"\n\t\tpublic int root(int p) {\n\t\t\twhile (p != parent[p]) {\n\t\t\t\tp = parent[p];\n\t\t\t}\n\t\t\treturn p;\n\t\t}\n\n\t\t//\"union\"\n\t\tpublic void connect(int p, int q) {\n\t\t\tint rootP = root(p);\n\t\t\tint rootQ = root(q);\n\t\t\tif (rootP == rootQ) return;\n\t\t\tif (weight[rootP] < weight[rootQ]) {\n\t\t\t\tparent[rootP] = rootQ;\n\t\t\t\tweight[rootQ] += weight[rootP];\n\t\t\t} else {\n\t\t\t\tparent[rootQ] = rootP;\n\t\t\t\tweight[rootP] += weight[rootQ];\n\t\t\t}\n\t\t\tcount--;\n\t\t}\n\n\t\tpublic boolean connected(int p, int q) {\n\t\t\treturn root(p) == root(q);\n\t\t}\n\t}\n\tstatic class IntList{\n\t\tint tail = 0;\n\t\tfinal int[] element;\n\t\tpublic IntList(int cap) {\n\t\t\telement = new int[cap];\n\t\t}\n\t\tpublic int size() {\n\t\t\treturn tail;\n\t\t}\n\t\tpublic int get(int index) {\n\t\t\treturn element[index];\n\t\t}\n\t\tpublic void reset() {\n\t\t\ttail = 0;\n\t\t}\n\t\tpublic void add(int v) {\n\t\t\telement[tail++] = v;\n\t\t}\n\t}\n\tstatic class LongList{\n\t\tint tail = 0;\n\t\tint head = 0;\n\t\tfinal long[] element;\n\t\tpublic LongList(int cap) {\n\t\t\telement = new long[cap];\n\t\t}\n\t\tpublic int size() {\n\t\t\treturn (element.length+tail-head)%element.length;\n\t\t}\n\t\tpublic long remove() {\n\t\t\tlong v = element[head];\n\t\t\thead = (head+1)%element.length;\n\t\t\treturn v;\n\t\t}\n\t\tpublic long get(int index) {\n\t\t\treturn element[index];\n\t\t}\n\t\tpublic void reset() {\n\t\t\thead = 0;\n\t\t\ttail = 0;\n\t\t}\n\t\tpublic void add(long v) {\n\t\t\telement[tail] = v;\n\t\t\ttail = (tail+1)%element.length;\n\t\t}\n\t\tpublic boolean hasElement() {\n\t\t\treturn this.size()!=0;\n\t\t}\n\t}\n\n\tpublic void exec() throws Exception{\n\t\tfinal int L = sc.nextInt();\n\t\tfinal double a = ((double)L)/3;\n\t\tout.println(String.format(\"%.12f\", a*a*a));\n\t}\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer L.\nFind the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\n\nConstraints\n\n1 ≤ L ≤ 1000\n\nL is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL\n\nOutput\n\nPrint the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\nYour output is considered correct if its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1.000000000000\n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a volume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the rectangular cuboid is 1, which is greater.\n\nSample Input 2\n\n999\n\nSample Output 2\n\n36926037.000000000000", "sample_input": "3\n"}, "reference_outputs": ["1.000000000000\n"], "source_document_id": "p02731", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer L.\nFind the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\n\nConstraints\n\n1 ≤ L ≤ 1000\n\nL is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL\n\nOutput\n\nPrint the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\nYour output is considered correct if its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1.000000000000\n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a volume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the rectangular cuboid is 1, which is greater.\n\nSample Input 2\n\n999\n\nSample Output 2\n\n36926037.000000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5330, "cpu_time_ms": 98, "memory_kb": 21204}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s828572249", "group_id": "codeNet:p02732", "input_text": "import java.util.*;\npublic class Main{\n public static void main(String[] args){\n Scanner sc =new Scanner(System.in);\n int N=sc.nextInt();\n int A[] =new int[N];\n int B[] =new int[N];\n int C[] =new int[N+1];\n int D[] =new int[N];\n long W[] =new long[N];\n C[0]=0;\n for(int i=0;i F[u][i]) {\n visited[i] = true;\n path[pathLen] = i;\n pathLen++;\n dfs(i);\n visited[i] = false;\n pathLen--;\n }\n }\n }\n }\n }\n\n public static class Utilities{\n public static List getPrimes(int limit) {\n boolean[] primes = new boolean[limit+1];\n Arrays.fill(primes, true);\n\n primes[1] = false;\n for(int i=2; i<=limit; i++){\n if (primes[i]){\n for(int j=i+i; j<=limit; j+=i){\n primes[j] = false;\n }\n }\n }\n List listPrimes = new ArrayList<>();\n for(int i=2; i<=limit; i++){\n if (primes[i]){\n listPrimes.add(i);\n }\n }\n return listPrimes;\n }\n }\n\n public static class Modulo{\n long mod = (long)1e9+7;\n\n public Modulo(long mod) {\n super();\n this.mod = mod;\n }\n\n public long inv(long a) {\n long res = pow(a, mod-2);\n return res;\n }\n\n public long pow(long a, long x) {\n if (x==0)\n return 1;\n long part = 1;\n if ((x&1)!=0)\n part = a;\n return (part * pow((a*a)%mod, x>>1)) % mod;\n }\n\n public long c(long n, long m){\n long res = 1;\n for(int i=1; i<=m; i++){\n res = (res * (n-m+i)) % mod;\n res = (res * inv(i)) % mod;\n }\n return res;\n }\n }\n\n /**\n * Added 26.04.2013.\n * See KROK 2013, Round 1, Problem D.\n */\n static class DisjointUnionSet implements Cloneable{\n int[] rank;\n int[] parent;\n\n protected DisjointUnionSet clone(){\n DisjointUnionSet cloned = new DisjointUnionSet(parent.length);\n for(int i=0; i rank[p2]){\n parent[p2] = p1;\n }else if (rank[p2] > rank[p1]){\n parent[p1] = p2;\n }else{\n parent[p2] = p1;\n rank[p1]++;\n }\n }\n\n // O(alpha(n))\n private int find(int index) {\n if (parent[index] != index)\n parent[index] = find(parent[index]);\n return parent[index];\n }\n\n // O(N alpha(N)) ==> see find()\n public int getCountDisjointSets(){\n int[] used = new int[parent.length];\n for(int i=0; i=1; j--){\n int i = rnd.nextInt(j+1);\n swap(a, i, j);\n }\n }\n\n public static void swap(int[] a, int i, int j){\n int tmp = a[i];\n a[i] = a[j];\n a[j] = tmp;\n }\n }\n\n static class GraphSupport{\n /*\n //Added 20.02.2017.\n //See Codeforces Round 398, Div.2, C.\n // Recoursive call to dfs function may result in either MTL or StackOverflow.\n // Codeforces provide stacksize 64M\n \n private void dfs_no_recursion(int root, IntConsumer dfs_post){\n int[] stack = new int[N];\n int[] stackInt = new int[N];\n int iStack = 0;\n stack[iStack] = root;\n stackInt[iStack++] = 0;\n while(true){\n Node node = nodes[stack[iStack-1]];\n int childIdx = stackInt[iStack-1];\n if (childIdx < node.children.size()){\n stack[iStack] = node.children.get(childIdx).idx;\n stackInt[iStack++] = 0;\n }else{\n dfs_post.accept(node.idx);\n \n iStack--;\n if (iStack==0){\n break;\n }\n stackInt[iStack-1]++;\n }\n }\n }\n */\n }\n\n\n ////////////////////////////////////////////////////////\n /// Typically, you don't want to edit anything below\n ///////////////////////////////////////////////////////\n final int BUF_SIZE = 1024 * 1024 * 8;//important to read long-string tokens properly\n final int INPUT_BUFFER_SIZE = 1024 * 1024 * 8;\n final int BUF_SIZE_INPUT = 1024;\n\n boolean useClassResourceTopDir = true;\n String outSuffix = \".out\";\n\n static PrintStream outGlobal;\n static ByteScanner scanner;\n\n public void run() {\n try{\n InputStream bis;\n OutputStream bos;\n if (inputFilename !=null){\n File inputFile;\n File outputFile;\n if (useClassResourceTopDir) {\n File baseFile = new File(getClass().getResource(\"/\").getFile());\n inputFile = new File(baseFile, inputFilename);\n outputFile = new File(baseFile, inputFilename +outSuffix);\n }else{\n inputFile = new File(inputFilename);\n outputFile = new File(inputFilename +outSuffix);\n }\n System.out.println(\"Input file canonical path: \"+inputFile.getCanonicalPath());\n bis = new BufferedInputStream(\n new FileInputStream(inputFile),\n INPUT_BUFFER_SIZE);\n bos = new BufferedOutputStream(new FileOutputStream(outputFile));\n outGlobal = new PrintStream(bos);\n }else{\n bis = new BufferedInputStream(System.in, INPUT_BUFFER_SIZE);\n bos = new BufferedOutputStream(System.out);\n outGlobal = new PrintStream(bos);\n }\n scanner = new ByteScanner(bis, BUF_SIZE_INPUT, BUF_SIZE);\n\n solveAll();\n outGlobal.flush();\n }catch (Exception e) {\n e.printStackTrace();\n System.exit(1);\n }\n }\n\n public static class EofException extends IOException{\n }\n\n public static class ByteScanner{\n InputStream is;\n\n public ByteScanner(InputStream is, int bufSizeInput, int bufSize){\n this.is = is;\n this.bufSizeInput = bufSizeInput;\n this.bufSize = bufSize;\n\n byteBufInput = new byte[this.bufSizeInput];\n byteBuf = new byte[this.bufSize];\n }\n\n public ByteScanner(byte[] data){\n byteBufInput = data;\n bufSizeInput = data.length;\n bufSize = data.length;\n byteBuf = new byte[bufSize];\n byteRead = data.length;\n bytePos = 0;\n }\n\n private int bufSizeInput;\n private int bufSize;\n\n byte[] byteBufInput;\n byte by=-1;\n int byteRead=-1;\n int bytePos=-1;\n\n byte[] byteBuf;\n int totalBytes;\n\n boolean eofMet = false;\n\n private byte nextByte() throws IOException{\n if (bytePos<0 || bytePos>=byteRead){\n byteRead = is==null? -1: is.read(byteBufInput);\n bytePos=0;\n if (byteRead<0){\n byteBufInput[bytePos]=-1;//!!!\n if (eofMet)\n throw new EofException();\n eofMet = true;\n }\n }\n return byteBufInput[bytePos++];\n }\n\n public byte nextVisibleChar() throws IOException{\n while ((by=nextByte())<=0x20);\n return by;\n }\n\n public String nextLine() throws IOException {\n readToken((byte)0x20);\n return new String(byteBuf,0,totalBytes);\n }\n\n // Reads token. Spacebar is separator char.\n public String nextToken() throws IOException {\n readToken((byte)0x21);\n return new String(byteBuf,0,totalBytes);\n }\n\n // Spacebar is included as separator char\n private void readToken() throws IOException {\n readToken((byte)0x21);\n }\n\n private void readToken(byte acceptFrom) throws IOException {\n totalBytes = 0;\n while ((by=nextByte())=acceptFrom){\n byteBuf[totalBytes++] = by;\n }\n }\n\n public int nextInt() throws IOException{\n readToken();\n int num=0, i=0;\n boolean sign=false;\n if (byteBuf[i]=='-'){\n sign = true;\n i++;\n }\n for (; i F[u][i]) {\n visited[i] = true;\n path[pathLen] = i;\n pathLen++;\n dfs(i);\n visited[i] = false;\n pathLen--;\n }\n }\n }\n }\n }\n\n public static class Utilities{\n public static List getPrimes(int limit) {\n boolean[] primes = new boolean[limit+1];\n Arrays.fill(primes, true);\n\n primes[1] = false;\n for(int i=2; i<=limit; i++){\n if (primes[i]){\n for(int j=i+i; j<=limit; j+=i){\n primes[j] = false;\n }\n }\n }\n List listPrimes = new ArrayList<>();\n for(int i=2; i<=limit; i++){\n if (primes[i]){\n listPrimes.add(i);\n }\n }\n return listPrimes;\n }\n }\n\n public static class Modulo{\n long mod = (long)1e9+7;\n\n public Modulo(long mod) {\n super();\n this.mod = mod;\n }\n\n public long inv(long a) {\n long res = pow(a, mod-2);\n return res;\n }\n\n public long pow(long a, long x) {\n if (x==0)\n return 1;\n long part = 1;\n if ((x&1)!=0)\n part = a;\n return (part * pow((a*a)%mod, x>>1)) % mod;\n }\n\n public long c(long n, long m){\n long res = 1;\n for(int i=1; i<=m; i++){\n res = (res * (n-m+i)) % mod;\n res = (res * inv(i)) % mod;\n }\n return res;\n }\n }\n\n /**\n * Added 26.04.2013.\n * See KROK 2013, Round 1, Problem D.\n */\n static class DisjointUnionSet implements Cloneable{\n int[] rank;\n int[] parent;\n\n protected DisjointUnionSet clone(){\n DisjointUnionSet cloned = new DisjointUnionSet(parent.length);\n for(int i=0; i rank[p2]){\n parent[p2] = p1;\n }else if (rank[p2] > rank[p1]){\n parent[p1] = p2;\n }else{\n parent[p2] = p1;\n rank[p1]++;\n }\n }\n\n // O(alpha(n))\n private int find(int index) {\n if (parent[index] != index)\n parent[index] = find(parent[index]);\n return parent[index];\n }\n\n // O(N alpha(N)) ==> see find()\n public int getCountDisjointSets(){\n int[] used = new int[parent.length];\n for(int i=0; i=1; j--){\n int i = rnd.nextInt(j+1);\n swap(a, i, j);\n }\n }\n\n public static void swap(int[] a, int i, int j){\n int tmp = a[i];\n a[i] = a[j];\n a[j] = tmp;\n }\n }\n\n static class GraphSupport{\n /*\n //Added 20.02.2017.\n //See Codeforces Round 398, Div.2, C.\n // Recoursive call to dfs function may result in either MTL or StackOverflow.\n // Codeforces provide stacksize 64M\n \n private void dfs_no_recursion(int root, IntConsumer dfs_post){\n int[] stack = new int[N];\n int[] stackInt = new int[N];\n int iStack = 0;\n stack[iStack] = root;\n stackInt[iStack++] = 0;\n while(true){\n Node node = nodes[stack[iStack-1]];\n int childIdx = stackInt[iStack-1];\n if (childIdx < node.children.size()){\n stack[iStack] = node.children.get(childIdx).idx;\n stackInt[iStack++] = 0;\n }else{\n dfs_post.accept(node.idx);\n \n iStack--;\n if (iStack==0){\n break;\n }\n stackInt[iStack-1]++;\n }\n }\n }\n */\n }\n\n\n ////////////////////////////////////////////////////////\n /// Typically, you don't want to edit anything below\n ///////////////////////////////////////////////////////\n final int BUF_SIZE = 1024 * 1024 * 8;//important to read long-string tokens properly\n final int INPUT_BUFFER_SIZE = 1024 * 1024 * 8;\n final int BUF_SIZE_INPUT = 1024;\n\n boolean useClassResourceTopDir = true;\n String outSuffix = \".out\";\n\n static PrintStream outGlobal;\n static ByteScanner scanner;\n\n public void run() {\n try{\n InputStream bis;\n OutputStream bos;\n if (inputFilename !=null){\n File inputFile;\n File outputFile;\n if (useClassResourceTopDir) {\n File baseFile = new File(getClass().getResource(\"/\").getFile());\n inputFile = new File(baseFile, inputFilename);\n outputFile = new File(baseFile, inputFilename +outSuffix);\n }else{\n inputFile = new File(inputFilename);\n outputFile = new File(inputFilename +outSuffix);\n }\n System.out.println(\"Input file canonical path: \"+inputFile.getCanonicalPath());\n bis = new BufferedInputStream(\n new FileInputStream(inputFile),\n INPUT_BUFFER_SIZE);\n bos = new BufferedOutputStream(new FileOutputStream(outputFile));\n outGlobal = new PrintStream(bos);\n }else{\n bis = new BufferedInputStream(System.in, INPUT_BUFFER_SIZE);\n bos = new BufferedOutputStream(System.out);\n outGlobal = new PrintStream(bos);\n }\n scanner = new ByteScanner(bis, BUF_SIZE_INPUT, BUF_SIZE);\n\n solveAll();\n outGlobal.flush();\n }catch (Exception e) {\n e.printStackTrace();\n System.exit(1);\n }\n }\n\n public static class EofException extends IOException{\n }\n\n public static class ByteScanner{\n InputStream is;\n\n public ByteScanner(InputStream is, int bufSizeInput, int bufSize){\n this.is = is;\n this.bufSizeInput = bufSizeInput;\n this.bufSize = bufSize;\n\n byteBufInput = new byte[this.bufSizeInput];\n byteBuf = new byte[this.bufSize];\n }\n\n public ByteScanner(byte[] data){\n byteBufInput = data;\n bufSizeInput = data.length;\n bufSize = data.length;\n byteBuf = new byte[bufSize];\n byteRead = data.length;\n bytePos = 0;\n }\n\n private int bufSizeInput;\n private int bufSize;\n\n byte[] byteBufInput;\n byte by=-1;\n int byteRead=-1;\n int bytePos=-1;\n\n byte[] byteBuf;\n int totalBytes;\n\n boolean eofMet = false;\n\n private byte nextByte() throws IOException{\n if (bytePos<0 || bytePos>=byteRead){\n byteRead = is==null? -1: is.read(byteBufInput);\n bytePos=0;\n if (byteRead<0){\n byteBufInput[bytePos]=-1;//!!!\n if (eofMet)\n throw new EofException();\n eofMet = true;\n }\n }\n return byteBufInput[bytePos++];\n }\n\n public byte nextVisibleChar() throws IOException{\n while ((by=nextByte())<=0x20);\n return by;\n }\n\n public String nextLine() throws IOException {\n readToken((byte)0x20);\n return new String(byteBuf,0,totalBytes);\n }\n\n // Reads token. Spacebar is separator char.\n public String nextToken() throws IOException {\n readToken((byte)0x21);\n return new String(byteBuf,0,totalBytes);\n }\n\n // Spacebar is included as separator char\n private void readToken() throws IOException {\n readToken((byte)0x21);\n }\n\n private void readToken(byte acceptFrom) throws IOException {\n totalBytes = 0;\n while ((by=nextByte())=acceptFrom){\n byteBuf[totalBytes++] = by;\n }\n }\n\n public int nextInt() throws IOException{\n readToken();\n int num=0, i=0;\n boolean sign=false;\n if (byteBuf[i]=='-'){\n sign = true;\n i++;\n }\n for (; i map = new HashMap<>();\n for(int i = 0; i < n; i++){\n a[i] = Integer.parseInt(sc.next());\n map.put(a[i], map.getOrDefault(a[i], 0) +1);\n }\n \n long c = 0;\n for (Integer i : map.keySet()) {\n long j = map.get(i);\n if(j >= 2){\n c += (j * (j-1)) /2;\n }\n }\n \n StringBuilder sb = new StringBuilder();\n for(int i = 0; i < n; i++){\n sb.append(c - (map.get(a[i]) -1)).append(System.lineSeparator());\n }\n System.out.print(sb);\n }\n}", "language": "Java", "metadata": {"date": 1584928037, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02732.html", "problem_id": "p02732", "resource_group": "high_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/Java/s498359895.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s498359895", "user_id": "u175752990"}, "prompt_components": {"gold_output": "2\n2\n3\n2\n3\n", "input_to_evaluate": "import java.util.HashMap;\nimport java.util.Map;\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n \n Scanner sc = new Scanner(System.in);\n \n int n = Integer.parseInt(sc.next());\n int[] a = new int[n];\n Map map = new HashMap<>();\n for(int i = 0; i < n; i++){\n a[i] = Integer.parseInt(sc.next());\n map.put(a[i], map.getOrDefault(a[i], 0) +1);\n }\n \n long c = 0;\n for (Integer i : map.keySet()) {\n long j = map.get(i);\n if(j >= 2){\n c += (j * (j-1)) /2;\n }\n }\n \n StringBuilder sb = new StringBuilder();\n for(int i = 0; i < n; i++){\n sb.append(c - (map.get(a[i]) -1)).append(System.lineSeparator());\n }\n System.out.print(sb);\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": 889, "cpu_time_ms": 712, "memory_kb": 77304}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s671710578", "group_id": "codeNet:p02734", "input_text": "import java.util.*;\nimport java.io.*;\n\n//多項式を利用した考察による解法\npublic class Main {\n\tstatic final int mod = 998244353;\n\tstatic final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };\n\tstatic final int[] DX8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, DY8 = { -1, 0, 1, -1, 1, -1, 0, 1 };\n\tstatic final int INF = Integer.MAX_VALUE / 3;\n\tstatic final long LINF = Long.MAX_VALUE / 3;\n\tstatic final String nextLine = \"\\n\";\n\n\tpublic static void main(String[] args) {\n\t\tFastScanner fs = new FastScanner(System.in);\n\t\tint n = fs.nextInt(), s = fs.nextInt();\n\t\tint a[] = fs.nextIntArray(n);\n\t\t\n\t\tint F[] = new int[s+1];\n\t\tlong ans = 0;\n\t\tfor(int i=0;i q = new LinkedList<>();\n\t\t// q.offer(new State(0, 0, grid[0][0] == '#' ? 1 : 0));\n\t\t//\n\t\t// int[][] mem = new int[row][col];\n\t\t// for (int i=0; i= row || tc >= col) continue;\n\t\t// \t\tint tbrk = cur.brk + (grid[tr][tc] == '#' ? 1 : 0);\n\t\t// \t\tif (tbrk >= mem[tr][tc]) continue;\n\t\t// \t\tmem[tr][tc] = tbrk;\n\t\t// \t\tq.offer(new State(tr, tc, tbrk));\n\t\t// \t}\n\t\t// }\n\n\t\tSystem.out.println(res);\n\t\treturn;\n\t}\n\n\tprivate void dfs(int r, int c, int brk) {\n\t\tif (r == row-1 && c == col-1) {\n\t\t\tres = Math.min(res, brk);\n\t\t}\n\t\tfor (int i=0; i= row || tc >= col) continue;\n\t\t\tchar hold = grid[tr][tc];\n\t\t\tint cost = grid[tr][tc] == '#' ? 1 : 0;\n\t\t\tgrid[tr][tc] = '.';\n\t\t\tdfs(tr, tc, brk + cost);\n\t\t\tgrid[tr][tc] = hold;\n\t\t}\n\t\treturn;\n\t}\n}\n\nclass State {\n\tint r, c, brk;\n\tpublic State(int r, int c, int brk) {\n\t\tthis.r = r;\n\t\tthis.c = c;\n\t\tthis.brk = brk;\n\t}\n}\n\nclass Reader {\n\tBufferedReader br;\n\tStringTokenizer st;\n\tpublic Reader(){\n\t\ttry {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t\tst = new StringTokenizer(br.readLine());\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n\tpublic String next() {\n\t\tif (st.hasMoreTokens()) return st.nextToken();\n\t\ttry {\n\t\t\tst = new StringTokenizer(br.readLine());\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn st.nextToken();\n\t}\n\tpublic boolean hasNext() {\n\t\ttry {\n\t\t\tif (!st.hasMoreTokens() && !br.ready()) return false;\n\t\t\telse return true;\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn false;\n\t}\n\tpublic int ni() {return Integer.parseInt(this.next());}\n\tpublic String ns() {return this.next();}\n}\n", "language": "Java", "metadata": {"date": 1584840428, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02735.html", "problem_id": "p02735", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02735/input.txt", "sample_output_relpath": "derived/input_output/data/p02735/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02735/Java/s285629783.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s285629783", "user_id": "u608257553"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "//--- pA ---//\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\npublic class Main {\n\tpublic static void main (String[] args) throws java.lang.Exception {\n\t\tnew Solution();\n\t}\n}\nclass Solution {\n\tReader reader;\n\tpublic Solution () {\n\t\treader = new Reader();\n\t\twhile (reader.hasNext()) {\n\t\t\trun_case();\n\t\t}\n\t}\n\n\tint[] dir_row = new int[]{1, 0};\n\tint[] dir_col = new int[]{0, 1};\n\tint inf = (int)1e9;\n\tint row, col;\n\tint res;\n\tchar[][] grid;\n\tprivate void run_case() {\n\t\trow = reader.ni();\n\t\tcol = reader.ni();\n\t\tgrid = new char[row][col];\n\t\tfor (int i=0; i q = new LinkedList<>();\n\t\t// q.offer(new State(0, 0, grid[0][0] == '#' ? 1 : 0));\n\t\t//\n\t\t// int[][] mem = new int[row][col];\n\t\t// for (int i=0; i= row || tc >= col) continue;\n\t\t// \t\tint tbrk = cur.brk + (grid[tr][tc] == '#' ? 1 : 0);\n\t\t// \t\tif (tbrk >= mem[tr][tc]) continue;\n\t\t// \t\tmem[tr][tc] = tbrk;\n\t\t// \t\tq.offer(new State(tr, tc, tbrk));\n\t\t// \t}\n\t\t// }\n\n\t\tSystem.out.println(res);\n\t\treturn;\n\t}\n\n\tprivate void dfs(int r, int c, int brk) {\n\t\tif (r == row-1 && c == col-1) {\n\t\t\tres = Math.min(res, brk);\n\t\t}\n\t\tfor (int i=0; i= row || tc >= col) continue;\n\t\t\tchar hold = grid[tr][tc];\n\t\t\tint cost = grid[tr][tc] == '#' ? 1 : 0;\n\t\t\tgrid[tr][tc] = '.';\n\t\t\tdfs(tr, tc, brk + cost);\n\t\t\tgrid[tr][tc] = hold;\n\t\t}\n\t\treturn;\n\t}\n}\n\nclass State {\n\tint r, c, brk;\n\tpublic State(int r, int c, int brk) {\n\t\tthis.r = r;\n\t\tthis.c = c;\n\t\tthis.brk = brk;\n\t}\n}\n\nclass Reader {\n\tBufferedReader br;\n\tStringTokenizer st;\n\tpublic Reader(){\n\t\ttry {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t\tst = new StringTokenizer(br.readLine());\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n\tpublic String next() {\n\t\tif (st.hasMoreTokens()) return st.nextToken();\n\t\ttry {\n\t\t\tst = new StringTokenizer(br.readLine());\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn st.nextToken();\n\t}\n\tpublic boolean hasNext() {\n\t\ttry {\n\t\t\tif (!st.hasMoreTokens() && !br.ready()) return false;\n\t\t\telse return true;\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn false;\n\t}\n\tpublic int ni() {return Integer.parseInt(this.next());}\n\tpublic String ns() {return this.next();}\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nConsider a grid with H rows and W columns of squares. Let (r, c) denote the square at the r-th row from the top and the c-th column from the left.\nEach square is painted black or white.\n\nThe grid is said to be good if and only if the following condition is satisfied:\n\nFrom (1, 1), we can reach (H, W) by moving one square right or down repeatedly, while always being on a white square.\n\nNote that (1, 1) and (H, W) must be white if the grid is good.\n\nYour task is to make the grid good by repeating the operation below. Find the minimum number of operations needed to complete the task. It can be proved that you can always complete the task in a finite number of operations.\n\nChoose four integers r_0, c_0, r_1, c_1(1 \\leq r_0 \\leq r_1 \\leq H, 1 \\leq c_0 \\leq c_1 \\leq W). For each pair r, c (r_0 \\leq r \\leq r_1, c_0 \\leq c \\leq c_1), invert the color of (r, c) - that is, from white to black and vice versa.\n\nConstraints\n\n2 \\leq H, W \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{11} s_{12} \\cdots s_{1W}\ns_{21} s_{22} \\cdots s_{2W}\n\\vdots\ns_{H1} s_{H2} \\cdots s_{HW}\n\nHere s_{rc} represents the color of (r, c) - # stands for black, and . stands for white.\n\nOutput\n\nPrint the minimum number of operations needed.\n\nSample Input 1\n\n3 3\n.##\n.#.\n##.\n\nSample Output 1\n\n1\n\nDo the operation with (r_0, c_0, r_1, c_1) = (2, 2, 2, 2) to change just the color of (2, 2), and we are done.\n\nSample Input 2\n\n2 2\n#.\n.#\n\nSample Output 2\n\n2\n\nSample Input 3\n\n4 4\n..##\n#...\n###.\n###.\n\nSample Output 3\n\n0\n\nNo operation may be needed.\n\nSample Input 4\n\n5 5\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n\nSample Output 4\n\n4", "sample_input": "3 3\n.##\n.#.\n##.\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02735", "source_text": "Score : 400 points\n\nProblem Statement\n\nConsider a grid with H rows and W columns of squares. Let (r, c) denote the square at the r-th row from the top and the c-th column from the left.\nEach square is painted black or white.\n\nThe grid is said to be good if and only if the following condition is satisfied:\n\nFrom (1, 1), we can reach (H, W) by moving one square right or down repeatedly, while always being on a white square.\n\nNote that (1, 1) and (H, W) must be white if the grid is good.\n\nYour task is to make the grid good by repeating the operation below. Find the minimum number of operations needed to complete the task. It can be proved that you can always complete the task in a finite number of operations.\n\nChoose four integers r_0, c_0, r_1, c_1(1 \\leq r_0 \\leq r_1 \\leq H, 1 \\leq c_0 \\leq c_1 \\leq W). For each pair r, c (r_0 \\leq r \\leq r_1, c_0 \\leq c \\leq c_1), invert the color of (r, c) - that is, from white to black and vice versa.\n\nConstraints\n\n2 \\leq H, W \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{11} s_{12} \\cdots s_{1W}\ns_{21} s_{22} \\cdots s_{2W}\n\\vdots\ns_{H1} s_{H2} \\cdots s_{HW}\n\nHere s_{rc} represents the color of (r, c) - # stands for black, and . stands for white.\n\nOutput\n\nPrint the minimum number of operations needed.\n\nSample Input 1\n\n3 3\n.##\n.#.\n##.\n\nSample Output 1\n\n1\n\nDo the operation with (r_0, c_0, r_1, c_1) = (2, 2, 2, 2) to change just the color of (2, 2), and we are done.\n\nSample Input 2\n\n2 2\n#.\n.#\n\nSample Output 2\n\n2\n\nSample Input 3\n\n4 4\n..##\n#...\n###.\n###.\n\nSample Output 3\n\n0\n\nNo operation may be needed.\n\nSample Input 4\n\n5 5\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n\nSample Output 4\n\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2784, "cpu_time_ms": 2108, "memory_kb": 22988}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s061575711", "group_id": "codeNet:p02742", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws Exception {\n \n Scanner sc = new Scanner(System.in);\n int H = sc.nextInt();\n int W = sc.nextInt();\n int S= H*W;\n if(S%2==0){\n System.out.println(S/2);\n }else{\n System.out.println((S+1)/2);\n }\n \n }\n}\n", "language": "Java", "metadata": {"date": 1597704286, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02742.html", "problem_id": "p02742", "resource_group": "high_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/Java/s061575711.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s061575711", "user_id": "u161835833"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws Exception {\n \n Scanner sc = new Scanner(System.in);\n int H = sc.nextInt();\n int W = sc.nextInt();\n int S= H*W;\n if(S%2==0){\n System.out.println(S/2);\n }else{\n System.out.println((S+1)/2);\n }\n \n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "sample_input": "4 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02742", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 121, "memory_kb": 35752}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s330772556", "group_id": "codeNet:p02742", "input_text": "import java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n Long H = sc.nextLong();\n Long W = sc.nextLong();\n if(H*W%2==0)\n System.out.println(H*W/2);\n else\n System.out.println(H*W/2+1);\n }\n\n}", "language": "Java", "metadata": {"date": 1584234960, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02742.html", "problem_id": "p02742", "resource_group": "high_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/Java/s330772556.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s330772556", "user_id": "u579583524"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n Long H = sc.nextLong();\n Long W = sc.nextLong();\n if(H*W%2==0)\n System.out.println(H*W/2);\n else\n System.out.println(H*W/2+1);\n }\n\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "sample_input": "4 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02742", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 314, "cpu_time_ms": 92, "memory_kb": 23764}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s067743406", "group_id": "codeNet:p02742", "input_text": "import java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n long h=sc.nextLong();\n long w=sc.nextLong();\n if(h%2==0||w%2==0){\n System.out.println(h*w/2);\n }else{\n System.out.println((h*w+1)/2);\n }\n \n \n \n \n }\n\n\n\n}\n\n", "language": "Java", "metadata": {"date": 1584234778, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02742.html", "problem_id": "p02742", "resource_group": "high_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/Java/s067743406.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s067743406", "user_id": "u136427605"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n long h=sc.nextLong();\n long w=sc.nextLong();\n if(h%2==0||w%2==0){\n System.out.println(h*w/2);\n }else{\n System.out.println((h*w+1)/2);\n }\n \n \n \n \n }\n\n\n\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "sample_input": "4 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02742", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 368, "cpu_time_ms": 96, "memory_kb": 23380}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s516493514", "group_id": "codeNet:p02744", "input_text": "import java.io.*;\nimport java.util.*;\nclass Main{\n\tstatic final long MOD = 1_000_000_007; // 10^9+7\n static final int MAX = 2_147_483_646; // intMax \n\tstatic final int INF = 1_000_000_000; // 10^9 \n\tstatic int n;\n public static void main(String[] args) throws Exception {\n\t\thayami saori = new hayami();\n\t\tn = saori.saori_hayami();\n\t\tdfs(0,\"\");\n\n\t\tsaori.close();\n\t}\n\tpublic static void dfs(int num, String str){\n\t\tif(str.length() == n){\n\t\t\tSystem.out.println(str);\n\t\t\treturn;\n\t\t}\n\t\tString str2;\n\t\tfor(char i = 0;i <= num;i++){\n\t\t\tstr2 = str + String.valueOf((char)('a' + i));\n\t\t\tdfs(Math.max(num, i+1), str2);\n\t\t}\n\t}\n}\n\nclass hayami implements Closeable {\n\tprivate final InputStream in = System.in;\n\tprivate final byte[] hayami = new byte[1024];\n\tprivate int Hayami = 0;\n\tprivate int saori = 0;\n\tprivate boolean HayamiSaori() {\n\t\tif (Hayami < saori) {\n\t\t\treturn true;\n\t\t}else{\n\t\t\tHayami = 0;\n\t\t\ttry {\n\t\t\t\tsaori = in.read(hayami);\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (saori <= 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\tprivate int SaoriHayami() { \n\t\tif (HayamiSaori()) {\n return hayami[Hayami++];\n }else{\n return -1;\n }\n\t}\n\tprivate static boolean hayami_saori(int hayami) { \n\t\treturn 33 <= hayami && hayami <= 126;\n\t}\n\tpublic boolean hayamisaori() { \n\t\twhile(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();\n\t}\n\tpublic String nextHayami() {\n\t\tif (!hayamisaori()) throw new NoSuchElementException();\n\t\tStringBuilder hayamin = new StringBuilder();\n\t\tint saori = SaoriHayami();\n\t\twhile(hayami_saori(saori)) {\n\t\t\thayamin.appendCodePoint(saori);\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t\treturn hayamin.toString();\n\t}\n\tpublic long saorihayami() {//nextLong\n\t\tif (!hayamisaori()) throw new NoSuchElementException();\n\t\tlong hayami = 0;\n\t\tboolean misao = false;\n\t\tint saori = SaoriHayami();\n\t\tif (saori == '-') {\n\t\t\tmisao = true;\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t\tif (saori < '0' || '9' < saori) {\n\t\t\tthrow new NumberFormatException();\n\t\t}\n\t\twhile(true){\n\t\t\tif ('0' <= saori && saori <= '9') {\n\t\t\t\thayami *= 10;\n\t\t\t\thayami += saori - '0';\n\t\t\t}else if(saori == -1 || !hayami_saori(saori)){\n\t\t\t\treturn misao ? -hayami : hayami;\n\t\t\t}else{\n\t\t\t\tthrow new NumberFormatException();\n\t\t\t}\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t}\n\tpublic int saori_hayami() {//nextInt\n\t\tlong hayami = saorihayami();\n\t\tif (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();\n\t\treturn (int) hayami;\n\t}\n\tpublic double Hayamin() { //nextDouble\n\t\treturn Double.parseDouble(nextHayami());\n\t}\n\tpublic void close() {\n\t\ttry {\n\t\t\tin.close();\n\t\t} catch (IOException e) {\n\t\t}\n }\n \n}", "language": "Java", "metadata": {"date": 1584242675, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02744.html", "problem_id": "p02744", "resource_group": "high_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/Java/s516493514.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s516493514", "user_id": "u676749446"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\nclass Main{\n\tstatic final long MOD = 1_000_000_007; // 10^9+7\n static final int MAX = 2_147_483_646; // intMax \n\tstatic final int INF = 1_000_000_000; // 10^9 \n\tstatic int n;\n public static void main(String[] args) throws Exception {\n\t\thayami saori = new hayami();\n\t\tn = saori.saori_hayami();\n\t\tdfs(0,\"\");\n\n\t\tsaori.close();\n\t}\n\tpublic static void dfs(int num, String str){\n\t\tif(str.length() == n){\n\t\t\tSystem.out.println(str);\n\t\t\treturn;\n\t\t}\n\t\tString str2;\n\t\tfor(char i = 0;i <= num;i++){\n\t\t\tstr2 = str + String.valueOf((char)('a' + i));\n\t\t\tdfs(Math.max(num, i+1), str2);\n\t\t}\n\t}\n}\n\nclass hayami implements Closeable {\n\tprivate final InputStream in = System.in;\n\tprivate final byte[] hayami = new byte[1024];\n\tprivate int Hayami = 0;\n\tprivate int saori = 0;\n\tprivate boolean HayamiSaori() {\n\t\tif (Hayami < saori) {\n\t\t\treturn true;\n\t\t}else{\n\t\t\tHayami = 0;\n\t\t\ttry {\n\t\t\t\tsaori = in.read(hayami);\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (saori <= 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\tprivate int SaoriHayami() { \n\t\tif (HayamiSaori()) {\n return hayami[Hayami++];\n }else{\n return -1;\n }\n\t}\n\tprivate static boolean hayami_saori(int hayami) { \n\t\treturn 33 <= hayami && hayami <= 126;\n\t}\n\tpublic boolean hayamisaori() { \n\t\twhile(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();\n\t}\n\tpublic String nextHayami() {\n\t\tif (!hayamisaori()) throw new NoSuchElementException();\n\t\tStringBuilder hayamin = new StringBuilder();\n\t\tint saori = SaoriHayami();\n\t\twhile(hayami_saori(saori)) {\n\t\t\thayamin.appendCodePoint(saori);\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t\treturn hayamin.toString();\n\t}\n\tpublic long saorihayami() {//nextLong\n\t\tif (!hayamisaori()) throw new NoSuchElementException();\n\t\tlong hayami = 0;\n\t\tboolean misao = false;\n\t\tint saori = SaoriHayami();\n\t\tif (saori == '-') {\n\t\t\tmisao = true;\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t\tif (saori < '0' || '9' < saori) {\n\t\t\tthrow new NumberFormatException();\n\t\t}\n\t\twhile(true){\n\t\t\tif ('0' <= saori && saori <= '9') {\n\t\t\t\thayami *= 10;\n\t\t\t\thayami += saori - '0';\n\t\t\t}else if(saori == -1 || !hayami_saori(saori)){\n\t\t\t\treturn misao ? -hayami : hayami;\n\t\t\t}else{\n\t\t\t\tthrow new NumberFormatException();\n\t\t\t}\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t}\n\tpublic int saori_hayami() {//nextInt\n\t\tlong hayami = saorihayami();\n\t\tif (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();\n\t\treturn (int) hayami;\n\t}\n\tpublic double Hayamin() { //nextDouble\n\t\treturn Double.parseDouble(nextHayami());\n\t}\n\tpublic void close() {\n\t\ttry {\n\t\t\tin.close();\n\t\t} catch (IOException e) {\n\t\t}\n }\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": 2677, "cpu_time_ms": 698, "memory_kb": 51136}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s788338532", "group_id": "codeNet:p02744", "input_text": "import java.util.*;\nimport java.io.*;\n\npublic class Main {\n\tstatic int mod = (int) 1e9 + 7;\n\tstatic int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };\n\tstatic final int INF = Integer.MAX_VALUE / 3;\n\tstatic final long LINF = Long.MAX_VALUE / 3;\n\t\n\tstatic char as[] = {'b','c','d','e','f','g','h','i','j','k','l','m','n'};\n\tstatic List ls;\n\tstatic int n;\n\tpublic static void main(String[] args) {\n\t\tFastScanner fs = new FastScanner(System.in);\n\t\tn = fs.nextInt();\n\t\tls = new ArrayList<>();\n\t\tdfs(\"\", 0, 0);\n\t\tCollections.sort(ls);\n\t\tfor(String tmp:ls) System.out.println(tmp);\n\n\t}\n\tstatic void dfs(String s, int cnt, int p) {\n\t\tString ns = \"\";\n\t\tif(p == 0)ns = s + \"a\";\n\t\telse ns = s + as[cnt++];\n\t\tif(ns.length()==n) {\n\t\t\tls.add(ns);\n\t\t\treturn;\n\t\t}\n\t\tdfs(ns, cnt, 0);\n\t\tdfs(ns, cnt, 1);\n\t}\n\t\n\n\t//MOD culculations\n\tstatic long plus(long x, long y) {\n\t\tlong res = (x + y) % mod;\n\t\treturn res < 0 ? res + mod : res;\n\t}\n\n\tstatic long sub(long x, long y) {\n\t\tlong res = (x - y) % mod;\n\t\treturn res < 0 ? res + mod : res;\n\t}\n\n\tstatic long mul(long x, long y) {\n\t\tlong res = (x * y) % mod;\n\t\treturn res < 0 ? res + mod : res;\n\t}\n\n\tstatic long div(long x, long y) {\n\t\tlong res = x * pow(y, mod - 2) % mod;\n\t\treturn res < 0 ? res + mod : res;\n\t}\n\n\tstatic long pow(long x, long y) {\n\t\tif (y < 0)\n\t\t\treturn 0;\n\t\tif (y == 0)\n\t\t\treturn 1;\n\t\tif (y % 2 == 1)\n\t\t\treturn (x * pow(x, y - 1)) % mod;\n\t\tlong root = pow(x, y / 2);\n\t\treturn root * root % mod;\n\t}\n}\n\n//高速なScanner\nclass FastScanner {\n\tprivate BufferedReader reader = null;\n\tprivate StringTokenizer tokenizer = null;\n\n\tpublic FastScanner(InputStream in) {\n\t\treader = new BufferedReader(new InputStreamReader(in));\n\t\ttokenizer = null;\n\t}\n\n\tpublic String next() {\n\t\tif (tokenizer == null || !tokenizer.hasMoreTokens()) {\n\t\t\ttry {\n\t\t\t\ttokenizer = new StringTokenizer(reader.readLine());\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new RuntimeException(e);\n\t\t\t}\n\t\t}\n\t\treturn tokenizer.nextToken();\n\t}\n\n\tpublic String nextLine() {\n\t\tif (tokenizer == null || !tokenizer.hasMoreTokens()) {\n\t\t\ttry {\n\t\t\t\treturn reader.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new RuntimeException(e);\n\t\t\t}\n\t\t}\n\t\treturn tokenizer.nextToken(\"\\n\");\n\t}\n\n\tpublic long nextLong() {\n\t\treturn Long.parseLong(next());\n\t}\n\n\tpublic int nextInt() {\n\t\treturn Integer.parseInt(next());\n\t}\n\n\tpublic double nextDouble() {\n\t\treturn Double.parseDouble(next());\n\t}\n\n\tpublic int[] nextIntArray(int n) {\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\ta[i] = nextInt();\n\t\treturn a;\n\t}\n\n\tpublic long[] nextLongArray(int n) {\n\t\tlong[] a = new long[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\ta[i] = nextLong();\n\t\treturn a;\n\t}\n}", "language": "Java", "metadata": {"date": 1584236878, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02744.html", "problem_id": "p02744", "resource_group": "high_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/Java/s788338532.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s788338532", "user_id": "u881359256"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\n\npublic class Main {\n\tstatic int mod = (int) 1e9 + 7;\n\tstatic int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };\n\tstatic final int INF = Integer.MAX_VALUE / 3;\n\tstatic final long LINF = Long.MAX_VALUE / 3;\n\t\n\tstatic char as[] = {'b','c','d','e','f','g','h','i','j','k','l','m','n'};\n\tstatic List ls;\n\tstatic int n;\n\tpublic static void main(String[] args) {\n\t\tFastScanner fs = new FastScanner(System.in);\n\t\tn = fs.nextInt();\n\t\tls = new ArrayList<>();\n\t\tdfs(\"\", 0, 0);\n\t\tCollections.sort(ls);\n\t\tfor(String tmp:ls) System.out.println(tmp);\n\n\t}\n\tstatic void dfs(String s, int cnt, int p) {\n\t\tString ns = \"\";\n\t\tif(p == 0)ns = s + \"a\";\n\t\telse ns = s + as[cnt++];\n\t\tif(ns.length()==n) {\n\t\t\tls.add(ns);\n\t\t\treturn;\n\t\t}\n\t\tdfs(ns, cnt, 0);\n\t\tdfs(ns, cnt, 1);\n\t}\n\t\n\n\t//MOD culculations\n\tstatic long plus(long x, long y) {\n\t\tlong res = (x + y) % mod;\n\t\treturn res < 0 ? res + mod : res;\n\t}\n\n\tstatic long sub(long x, long y) {\n\t\tlong res = (x - y) % mod;\n\t\treturn res < 0 ? res + mod : res;\n\t}\n\n\tstatic long mul(long x, long y) {\n\t\tlong res = (x * y) % mod;\n\t\treturn res < 0 ? res + mod : res;\n\t}\n\n\tstatic long div(long x, long y) {\n\t\tlong res = x * pow(y, mod - 2) % mod;\n\t\treturn res < 0 ? res + mod : res;\n\t}\n\n\tstatic long pow(long x, long y) {\n\t\tif (y < 0)\n\t\t\treturn 0;\n\t\tif (y == 0)\n\t\t\treturn 1;\n\t\tif (y % 2 == 1)\n\t\t\treturn (x * pow(x, y - 1)) % mod;\n\t\tlong root = pow(x, y / 2);\n\t\treturn root * root % mod;\n\t}\n}\n\n//高速なScanner\nclass FastScanner {\n\tprivate BufferedReader reader = null;\n\tprivate StringTokenizer tokenizer = null;\n\n\tpublic FastScanner(InputStream in) {\n\t\treader = new BufferedReader(new InputStreamReader(in));\n\t\ttokenizer = null;\n\t}\n\n\tpublic String next() {\n\t\tif (tokenizer == null || !tokenizer.hasMoreTokens()) {\n\t\t\ttry {\n\t\t\t\ttokenizer = new StringTokenizer(reader.readLine());\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new RuntimeException(e);\n\t\t\t}\n\t\t}\n\t\treturn tokenizer.nextToken();\n\t}\n\n\tpublic String nextLine() {\n\t\tif (tokenizer == null || !tokenizer.hasMoreTokens()) {\n\t\t\ttry {\n\t\t\t\treturn reader.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new RuntimeException(e);\n\t\t\t}\n\t\t}\n\t\treturn tokenizer.nextToken(\"\\n\");\n\t}\n\n\tpublic long nextLong() {\n\t\treturn Long.parseLong(next());\n\t}\n\n\tpublic int nextInt() {\n\t\treturn Integer.parseInt(next());\n\t}\n\n\tpublic double nextDouble() {\n\t\treturn Double.parseDouble(next());\n\t}\n\n\tpublic int[] nextIntArray(int n) {\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\ta[i] = nextInt();\n\t\treturn a;\n\t}\n\n\tpublic long[] nextLongArray(int n) {\n\t\tlong[] a = new long[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\ta[i] = nextLong();\n\t\treturn a;\n\t}\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": 2642, "cpu_time_ms": 93, "memory_kb": 23252}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s676369625", "group_id": "codeNet:p02747", "input_text": "import java.util.Scanner;\npublic class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n String S = sc.next();\n //System.out.print(S);\n if(S.equals(\"hi\")||S.equals(\"hihi\")||S.equals(\"hihihi\")||S.equals(\"hihihihi\")||S.equals(\"hihihihihi\")){\n System.out.print(\"Yes\");\n }else{\n System.out.print(\"No\");\n }\n } \n}", "language": "Java", "metadata": {"date": 1583716437, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02747.html", "problem_id": "p02747", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02747/input.txt", "sample_output_relpath": "derived/input_output/data/p02747/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02747/Java/s676369625.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s676369625", "user_id": "u571543357"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n String S = sc.next();\n //System.out.print(S);\n if(S.equals(\"hi\")||S.equals(\"hihi\")||S.equals(\"hihihi\")||S.equals(\"hihihihi\")||S.equals(\"hihihihihi\")){\n System.out.print(\"Yes\");\n }else{\n System.out.print(\"No\");\n }\n } \n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA Hitachi string is a concatenation of one or more copies of the string hi.\n\nFor example, hi and hihi are Hitachi strings, while ha and hii are not.\n\nGiven a string S, determine whether S is a Hitachi string.\n\nConstraints\n\nThe length of S is between 1 and 10 (inclusive).\n\nS is a string consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a Hitachi string, print Yes; otherwise, print No.\n\nSample Input 1\n\nhihi\n\nSample Output 1\n\nYes\n\nhihi is the concatenation of two copies of hi, so it is a Hitachi string.\n\nSample Input 2\n\nhi\n\nSample Output 2\n\nYes\n\nSample Input 3\n\nha\n\nSample Output 3\n\nNo", "sample_input": "hihi\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02747", "source_text": "Score : 100 points\n\nProblem Statement\n\nA Hitachi string is a concatenation of one or more copies of the string hi.\n\nFor example, hi and hihi are Hitachi strings, while ha and hii are not.\n\nGiven a string S, determine whether S is a Hitachi string.\n\nConstraints\n\nThe length of S is between 1 and 10 (inclusive).\n\nS is a string consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a Hitachi string, print Yes; otherwise, print No.\n\nSample Input 1\n\nhihi\n\nSample Output 1\n\nYes\n\nhihi is the concatenation of two copies of hi, so it is a Hitachi string.\n\nSample Input 2\n\nhi\n\nSample Output 2\n\nYes\n\nSample Input 3\n\nha\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 94, "memory_kb": 23892}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s928384704", "group_id": "codeNet:p02754", "input_text": "import javax.sound.midi.Soundbank;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Long N, A, B;\n Scanner sc = new Scanner(System.in);\n N = sc.nextLong();\n A = sc.nextLong();\n B = sc.nextLong();\n Long N2 = N%(A+B);\n Long N1 = N/(A+B);\n System.out.println(A*N1 + (N2 >= A ? A : N2) );\n }\n}\n", "language": "Java", "metadata": {"date": 1593031951, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02754.html", "problem_id": "p02754", "resource_group": "high_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/Java/s928384704.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s928384704", "user_id": "u104386856"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import javax.sound.midi.Soundbank;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Long N, A, B;\n Scanner sc = new Scanner(System.in);\n N = sc.nextLong();\n A = sc.nextLong();\n B = sc.nextLong();\n Long N2 = N%(A+B);\n Long N1 = N/(A+B);\n System.out.println(A*N1 + (N2 >= A ? A : N2) );\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "sample_input": "8 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02754", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 393, "cpu_time_ms": 121, "memory_kb": 35772}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s929544782", "group_id": "codeNet:p02754", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int a = sc.nextInt(); // 青のボール\n int b = sc.nextInt();\n String balls = \"\";\n String flg = \"a\";\n \n while(balls.length() <= n){\n if(flg.equals(\"a\")){\n for(int i=0; i arrayA = new ArrayList<>(10);\n\t\tArrayList arrayB = new ArrayList<>(10);\n\t\tfor(BigDecimal i = BigDecimal.ZERO; i.compareTo(BigDecimal.ONE) < 0; i = i.add(BigDecimal.valueOf(0.1))) {\n\t\t\tarrayA.add(BigDecimal.valueOf(A).add(i).divide(BigDecimal.valueOf(0.08)));\n\t\t\tarrayB.add(BigDecimal.valueOf(B).add(i).divide(BigDecimal.valueOf(0.10)));\n\t\t}\n\n\t\tboolean isNotExists = true;\n\t\tstart : for(BigDecimal a : arrayA) {\n\t\t\tif(a.compareTo(a.setScale(0)) != 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfor(BigDecimal b : arrayB) {\n\t\t\t\tif(b.compareTo(b.setScale(0)) != 0) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif(a.compareTo(b) == 0) {\n\t\t\t\t\tisNotExists = false;\n\t\t\t\t\tSystem.out.println(a.intValue());\n\t\t\t\t\tbreak start;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(isNotExists) {\n\t\t\tSystem.out.println(-1);\n\t\t}\n\n\t}\n}\t", "language": "Java", "metadata": {"date": 1583635768, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02755.html", "problem_id": "p02755", "resource_group": "high_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/Java/s999528289.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s999528289", "user_id": "u217731641"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "import java.math.BigDecimal;\nimport java.util.ArrayList;\nimport java.util.Scanner;\n\npublic class Main{\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint A = sc.nextInt();\n\t\tint B = sc.nextInt();\n\n\t\tArrayList arrayA = new ArrayList<>(10);\n\t\tArrayList arrayB = new ArrayList<>(10);\n\t\tfor(BigDecimal i = BigDecimal.ZERO; i.compareTo(BigDecimal.ONE) < 0; i = i.add(BigDecimal.valueOf(0.1))) {\n\t\t\tarrayA.add(BigDecimal.valueOf(A).add(i).divide(BigDecimal.valueOf(0.08)));\n\t\t\tarrayB.add(BigDecimal.valueOf(B).add(i).divide(BigDecimal.valueOf(0.10)));\n\t\t}\n\n\t\tboolean isNotExists = true;\n\t\tstart : for(BigDecimal a : arrayA) {\n\t\t\tif(a.compareTo(a.setScale(0)) != 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfor(BigDecimal b : arrayB) {\n\t\t\t\tif(b.compareTo(b.setScale(0)) != 0) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif(a.compareTo(b) == 0) {\n\t\t\t\t\tisNotExists = false;\n\t\t\t\t\tSystem.out.println(a.intValue());\n\t\t\t\t\tbreak start;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(isNotExists) {\n\t\t\tSystem.out.println(-1);\n\t\t}\n\n\t}\n}\t", "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": 1020, "cpu_time_ms": 104, "memory_kb": 21972}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s841565566", "group_id": "codeNet:p02756", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.util.ArrayList;\nimport java.util.StringTokenizer;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tFastScanner sc = new FastScanner(System.in);\n\t\tString s = sc.next();\n\t\tchar[] a = s.toCharArray();\n\t\tint q = sc.nextInt();\n\t\tint check = 0;\n\t\tArrayList front = new ArrayList<>(),\n\t\t\t\t\t\t\tback = new ArrayList<>();\n\t\tif(s.length() == 1) {\n\t\t\tfront.add(s);\n\t\t}else {\n\t\t\tfront.add(String.valueOf(a[0]));\n\t\t\tfor(int i = 1; i < a.length; i++) {\n\t\t\t\tback.add(String.valueOf(a[i]));\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0; i < q; i++) {\n\t\t\tint t = sc.nextInt();\n\t\t\tif(t == 1) {\n\t\t\t\tcheck++;\n\t\t\t}else{\n\t\t\t\tint f = sc.nextInt();\n\t\t\t\tString x = sc.next();\n\t\t\t\tif((f== 1 && check % 2 == 0) || (f == 2 && check % 2 != 0)) {\n\t\t\t\t\tfront.add(x);\n\t\t\t\t}else {\n\t\t\t\t\tback.add(x);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(check % 2 == 0) {\n\t\t\tfor(int i = front.size()-1; i >= 0; i--) {\n\t\t\t\tSystem.out.print(front.get(i));\n\t\t\t}\n\t\t\tfor(String st : back) {\n\t\t\t\tSystem.out.print(st);\n\t\t\t}\n\t\t}else {\n\t\t\tfor(int i = back.size()-1; i >= 0; i--) {\n\t\t\t\tSystem.out.print(back.get(i));\n\t\t\t}\n\t\t\tfor(String st : front) {\n\t\t\t\tSystem.out.print(st);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tstatic class FastScanner {\n\t\tprivate BufferedReader reader = null;\n\t private StringTokenizer tokenizer = null;\n\t public FastScanner(InputStream in) {\n\t reader = new BufferedReader(new InputStreamReader(in));\n\t tokenizer = null;\n\t }\n\n\t public String next() {\n\t if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n\t try {\n\t tokenizer = new StringTokenizer(reader.readLine());\n\t } catch (IOException e) {\n\t throw new RuntimeException(e);\n\t }\n\t }\n\t return tokenizer.nextToken();\n\t }\n\n\t public String nextLine() {\n\t if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n\t try {\n\t return reader.readLine();\n\t } catch (IOException e) {\n\t throw new RuntimeException(e);\n\t }\n\t }\n\n\t return tokenizer.nextToken(\"\\n\");\n\t }\n\n\t public long nextLong() {\n\t return Long.parseLong(next());\n\t }\n\n\t public int nextInt() {\n\t return Integer.parseInt(next());\n\t }\n\n\t public double nextDouble() {\n\t return Double.parseDouble(next());\n\t }\n\n\t public int[] nextIntArray(int n) {\n\t int[] a = new int[n];\n\t for (int i = 0; i < n; i++)\n\t a[i] = nextInt();\n\t return a;\n\t }\n\n\t public long[] nextLongArray(int n) {\n\t long[] a = new long[n];\n\t for (int i = 0; i < n; i++)\n\t a[i] = nextLong();\n\t return a;\n\t }\n\t}\n}\n", "language": "Java", "metadata": {"date": 1593860771, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02756.html", "problem_id": "p02756", "resource_group": "high_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/Java/s841565566.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s841565566", "user_id": "u368078055"}, "prompt_components": {"gold_output": "cpa\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.util.ArrayList;\nimport java.util.StringTokenizer;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tFastScanner sc = new FastScanner(System.in);\n\t\tString s = sc.next();\n\t\tchar[] a = s.toCharArray();\n\t\tint q = sc.nextInt();\n\t\tint check = 0;\n\t\tArrayList front = new ArrayList<>(),\n\t\t\t\t\t\t\tback = new ArrayList<>();\n\t\tif(s.length() == 1) {\n\t\t\tfront.add(s);\n\t\t}else {\n\t\t\tfront.add(String.valueOf(a[0]));\n\t\t\tfor(int i = 1; i < a.length; i++) {\n\t\t\t\tback.add(String.valueOf(a[i]));\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0; i < q; i++) {\n\t\t\tint t = sc.nextInt();\n\t\t\tif(t == 1) {\n\t\t\t\tcheck++;\n\t\t\t}else{\n\t\t\t\tint f = sc.nextInt();\n\t\t\t\tString x = sc.next();\n\t\t\t\tif((f== 1 && check % 2 == 0) || (f == 2 && check % 2 != 0)) {\n\t\t\t\t\tfront.add(x);\n\t\t\t\t}else {\n\t\t\t\t\tback.add(x);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(check % 2 == 0) {\n\t\t\tfor(int i = front.size()-1; i >= 0; i--) {\n\t\t\t\tSystem.out.print(front.get(i));\n\t\t\t}\n\t\t\tfor(String st : back) {\n\t\t\t\tSystem.out.print(st);\n\t\t\t}\n\t\t}else {\n\t\t\tfor(int i = back.size()-1; i >= 0; i--) {\n\t\t\t\tSystem.out.print(back.get(i));\n\t\t\t}\n\t\t\tfor(String st : front) {\n\t\t\t\tSystem.out.print(st);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tstatic class FastScanner {\n\t\tprivate BufferedReader reader = null;\n\t private StringTokenizer tokenizer = null;\n\t public FastScanner(InputStream in) {\n\t reader = new BufferedReader(new InputStreamReader(in));\n\t tokenizer = null;\n\t }\n\n\t public String next() {\n\t if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n\t try {\n\t tokenizer = new StringTokenizer(reader.readLine());\n\t } catch (IOException e) {\n\t throw new RuntimeException(e);\n\t }\n\t }\n\t return tokenizer.nextToken();\n\t }\n\n\t public String nextLine() {\n\t if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n\t try {\n\t return reader.readLine();\n\t } catch (IOException e) {\n\t throw new RuntimeException(e);\n\t }\n\t }\n\n\t return tokenizer.nextToken(\"\\n\");\n\t }\n\n\t public long nextLong() {\n\t return Long.parseLong(next());\n\t }\n\n\t public int nextInt() {\n\t return Integer.parseInt(next());\n\t }\n\n\t public double nextDouble() {\n\t return Double.parseDouble(next());\n\t }\n\n\t public int[] nextIntArray(int n) {\n\t int[] a = new int[n];\n\t for (int i = 0; i < n; i++)\n\t a[i] = nextInt();\n\t return a;\n\t }\n\n\t public long[] nextLongArray(int n) {\n\t long[] a = new long[n];\n\t for (int i = 0; i < n; i++)\n\t a[i] = nextLong();\n\t return a;\n\t }\n\t}\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a string S consisting of lowercase English letters.\n\nStarting with this string, he will produce a new one in the procedure given as follows.\n\nThe procedure consists of Q operations. In Operation i (1 \\leq i \\leq Q), an integer T_i is provided, which means the following:\n\nIf T_i = 1: reverse the string S.\n\nIf T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided.\n\nIf F_i = 1 : Add C_i to the beginning of the string S.\n\nIf F_i = 2 : Add C_i to the end of the string S.\n\nHelp Takahashi by finding the final string that results from the procedure.\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS consists of lowercase English letters.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\nT_i = 1 or 2.\n\nF_i = 1 or 2, if provided.\n\nC_i is a lowercase English letter, if provided.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nQ\nQuery_1\n:\nQuery_Q\n\nIn the 3-rd through the (Q+2)-th lines, Query_i is one of the following:\n\n1\n\nwhich means T_i = 1, and:\n\n2 F_i C_i\n\nwhich means T_i = 2.\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\na\n4\n2 1 p\n1\n2 2 c\n1\n\nSample Output 1\n\ncpa\n\nThere will be Q = 4 operations. Initially, S is a.\n\nOperation 1: Add p at the beginning of S. S becomes pa.\n\nOperation 2: Reverse S. S becomes ap.\n\nOperation 3: Add c at the end of S. S becomes apc.\n\nOperation 4: Reverse S. S becomes cpa.\n\nThus, the resulting string is cpa.\n\nSample Input 2\n\na\n6\n2 2 a\n2 1 b\n1\n2 2 c\n1\n1\n\nSample Output 2\n\naabc\n\nThere will be Q = 6 operations. Initially, S is a.\n\nOperation 1: S becomes aa.\n\nOperation 2: S becomes baa.\n\nOperation 3: S becomes aab.\n\nOperation 4: S becomes aabc.\n\nOperation 5: S becomes cbaa.\n\nOperation 6: S becomes aabc.\n\nThus, the resulting string is aabc.\n\nSample Input 3\n\ny\n1\n2 1 x\n\nSample Output 3\n\nxy", "sample_input": "a\n4\n2 1 p\n1\n2 2 c\n1\n"}, "reference_outputs": ["cpa\n"], "source_document_id": "p02756", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a string S consisting of lowercase English letters.\n\nStarting with this string, he will produce a new one in the procedure given as follows.\n\nThe procedure consists of Q operations. In Operation i (1 \\leq i \\leq Q), an integer T_i is provided, which means the following:\n\nIf T_i = 1: reverse the string S.\n\nIf T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided.\n\nIf F_i = 1 : Add C_i to the beginning of the string S.\n\nIf F_i = 2 : Add C_i to the end of the string S.\n\nHelp Takahashi by finding the final string that results from the procedure.\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS consists of lowercase English letters.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\nT_i = 1 or 2.\n\nF_i = 1 or 2, if provided.\n\nC_i is a lowercase English letter, if provided.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nQ\nQuery_1\n:\nQuery_Q\n\nIn the 3-rd through the (Q+2)-th lines, Query_i is one of the following:\n\n1\n\nwhich means T_i = 1, and:\n\n2 F_i C_i\n\nwhich means T_i = 2.\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\na\n4\n2 1 p\n1\n2 2 c\n1\n\nSample Output 1\n\ncpa\n\nThere will be Q = 4 operations. Initially, S is a.\n\nOperation 1: Add p at the beginning of S. S becomes pa.\n\nOperation 2: Reverse S. S becomes ap.\n\nOperation 3: Add c at the end of S. S becomes apc.\n\nOperation 4: Reverse S. S becomes cpa.\n\nThus, the resulting string is cpa.\n\nSample Input 2\n\na\n6\n2 2 a\n2 1 b\n1\n2 2 c\n1\n1\n\nSample Output 2\n\naabc\n\nThere will be Q = 6 operations. Initially, S is a.\n\nOperation 1: S becomes aa.\n\nOperation 2: S becomes baa.\n\nOperation 3: S becomes aab.\n\nOperation 4: S becomes aabc.\n\nOperation 5: S becomes cbaa.\n\nOperation 6: S becomes aabc.\n\nThus, the resulting string is aabc.\n\nSample Input 3\n\ny\n1\n2 1 x\n\nSample Output 3\n\nxy", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2752, "cpu_time_ms": 984, "memory_kb": 77204}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s217732286", "group_id": "codeNet:p02756", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.PrintWriter;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n//\t\texecuteCountBalls();\n//\t\texecuteTaxIncrease();\n\t\texecuteStringFormation();\n\t}\n\n\tprivate static void execute() {\n\n\t\tScanner in = new Scanner(System.in);\n\n\t\ttry {\n\t\t\tString s1 = in.nextLine();\n\t\t\tString s2 = in.nextLine();\n\t\t\tString s3 = in.nextLine();\n\n\t\t\tint a = Integer.parseInt(s1);\n\t\t\tString[] s2Array = s2.split(\" \");\n\t\t\tint b = Integer.parseInt(s2Array[0]);\n\t\t\tint c = Integer.parseInt(s2Array[1]);\n\n\t\t\tint sum = a + b + c;\n\n//\t\t\tSystem.out.println(a + \",\" + b + \",\" + c );\n\n\t\t\tSystem.out.println(sum + \" \" + s3);\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO 自動生成された catch ブロック\n\t\t\tSystem.out.println(\"\");\n//\t\t\te.printStackTrace();\n\t\t}\n\n\t}\n\n\tpublic static void execute_product() {\n\n\t\tScanner in = new Scanner(System.in);\n\n\t\ttry {\n\t\t\tint a = in.nextInt();\n\t\t\tint b = in.nextInt();\n\n\t\t\tif( (a*b)%2 == 0 ) {\n\t\t\t\tSystem.out.println(\"Even\");\n\t\t\t} else {\n\t\t\t\tSystem.out.println(\"Odd\");\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\t// TODO 自動生成された catch ブロック\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n\n\tpublic static void executeCountBalls() {\n\t\tScanner in = new Scanner(System.in);\n\n\t\ttry {\n\t\t\tlong N = in.nextLong();\n\t\t\tlong A = in.nextLong();\n\t\t\tlong B = in.nextLong();\n\n\t\t\tlong surplus = N%(A+B);\n\t\t\tlong surplusA = surplus >= A ? A : surplus;\n\n\t\t\t long countA = N/(A+B) * A + surplusA;\n\n\t\t\tSystem.out.println(countA);\n\t\t} catch (Exception e) {\n\t\t\t// TODO 自動生成された catch ブロック\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n\n\n\tpublic static final int TAX_RATE_8 = 8;\n\tpublic static final int TAX_TATE_10 = 10;\n\n\tpublic static void executeTaxIncrease(){\n\n\t\tScanner in = new Scanner(System.in);\n\n\t\tdouble tax8 = (double)in.nextInt();\n\t\tdouble tax10 = (double)in.nextInt();\n\n\t\tint taxExclude_min = (int)Math.ceil((tax8 * 100)/TAX_RATE_8);\n\n\t\tint taxExclude_max = 0;\n\t\tif( ((tax8 + 1)*100)%8 == 0 ) {\n\t\t\ttaxExclude_max = (int)(((tax8 + 1) * 100)/TAX_RATE_8 - 1);\n\t\t}\telse {\n\t\t\ttaxExclude_max = (int)Math.floor(((tax8 + 1) * 100)/TAX_RATE_8);\n\t\t}\n\n//\t\tSystem.out.println(taxExclude_min + \" \" + taxExclude_max);\n\n\t\tint taxExclude_fix = -1;\n\t\tfor( int val = taxExclude_min; val <= taxExclude_max; val++) {\n\t\t\tif ( (int)Math.ceil(val/TAX_TATE_10) == tax10 ) {\n\t\t\t\ttaxExclude_fix = val;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(taxExclude_fix);\n\t}\n\n\n\n\tprivate static final int ENTRY_HEAD = 0x0;\n\tprivate static final int ENTRY_TAIL = 0xFFFFFFFF;\n\tprivate static int headFlag = ENTRY_HEAD;\n\n\tpublic static void executeStringFormation() {\n\n\n//long start = System.currentTimeMillis();\n\n\t\tString s1 = null;\n\t\tString s2 = null;\n\t\tint num = 0;\n\t\tList queryList = new ArrayList();\n\n\t\tif( false ) {\n\t\t\tScanner in = new Scanner(System.in);\n\n\t\t\ts1 = in.nextLine();\n\t\t\ts2 = in.nextLine();\n\t\t\tnum =Integer.parseInt(s2);\n\n\t\t\tfor( int i=0; i= A ? A : surplus;\n\n\t\t\t long countA = N/(A+B) * A + surplusA;\n\n\t\t\tSystem.out.println(countA);\n\t\t} catch (Exception e) {\n\t\t\t// TODO 自動生成された catch ブロック\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n\n\n\tpublic static final int TAX_RATE_8 = 8;\n\tpublic static final int TAX_TATE_10 = 10;\n\n\tpublic static void executeTaxIncrease(){\n\n\t\tScanner in = new Scanner(System.in);\n\n\t\tdouble tax8 = (double)in.nextInt();\n\t\tdouble tax10 = (double)in.nextInt();\n\n\t\tint taxExclude_min = (int)Math.ceil((tax8 * 100)/TAX_RATE_8);\n\n\t\tint taxExclude_max = 0;\n\t\tif( ((tax8 + 1)*100)%8 == 0 ) {\n\t\t\ttaxExclude_max = (int)(((tax8 + 1) * 100)/TAX_RATE_8 - 1);\n\t\t}\telse {\n\t\t\ttaxExclude_max = (int)Math.floor(((tax8 + 1) * 100)/TAX_RATE_8);\n\t\t}\n\n//\t\tSystem.out.println(taxExclude_min + \" \" + taxExclude_max);\n\n\t\tint taxExclude_fix = -1;\n\t\tfor( int val = taxExclude_min; val <= taxExclude_max; val++) {\n\t\t\tif ( (int)Math.ceil(val/TAX_TATE_10) == tax10 ) {\n\t\t\t\ttaxExclude_fix = val;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(taxExclude_fix);\n\t}\n\n\n\n\tprivate static final int ENTRY_HEAD = 0x0;\n\tprivate static final int ENTRY_TAIL = 0xFFFFFFFF;\n\tprivate static int headFlag = ENTRY_HEAD;\n\n\tpublic static void executeStringFormation() {\n\n\n//long start = System.currentTimeMillis();\n\n\t\tString s1 = null;\n\t\tString s2 = null;\n\t\tint num = 0;\n\t\tList queryList = new ArrayList();\n\n\t\tif( false ) {\n\t\t\tScanner in = new Scanner(System.in);\n\n\t\t\ts1 = in.nextLine();\n\t\t\ts2 = in.nextLine();\n\t\t\tnum =Integer.parseInt(s2);\n\n\t\t\tfor( int i=0; i list = new LinkedList<>();\n for(int i = 0; i < s.length; i++){\n list.add(s[i]);\n }\n int q = sc.nextInt();\n int dir = 0;\n for(int i = 0; i < q; i++){\n int op = sc.nextInt();\n if(op == 1){\n dir++;\n }else{\n int end = sc.nextInt();\n char let = sc.next().charAt(0);\n if((dir + end) % 2 == 0){\n list.add(let);\n }else{\n list.add(0, let);\n }\n }\n }\n if(dir % 2 == 0){\n for(int i = 0; i < list.size(); i++){\n System.out.print(list.toArray()[i]);\n }\n }else{\n for(int i = 0; i < list.size(); i++){\n System.out.print(list.toArray()[list.size() - 1 - i]);\n }\n }\n }\n}", "language": "Java", "metadata": {"date": 1586556022, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02756.html", "problem_id": "p02756", "resource_group": "high_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/Java/s652541854.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s652541854", "user_id": "u369712616"}, "prompt_components": {"gold_output": "cpa\n", "input_to_evaluate": "import java.util.*;\n\nclass Main{\n public static void main(String[] args){\n final Scanner sc = new Scanner(System.in);\n char[] s = sc.next().toCharArray();\n LinkedList list = new LinkedList<>();\n for(int i = 0; i < s.length; i++){\n list.add(s[i]);\n }\n int q = sc.nextInt();\n int dir = 0;\n for(int i = 0; i < q; i++){\n int op = sc.nextInt();\n if(op == 1){\n dir++;\n }else{\n int end = sc.nextInt();\n char let = sc.next().charAt(0);\n if((dir + end) % 2 == 0){\n list.add(let);\n }else{\n list.add(0, let);\n }\n }\n }\n if(dir % 2 == 0){\n for(int i = 0; i < list.size(); i++){\n System.out.print(list.toArray()[i]);\n }\n }else{\n for(int i = 0; i < list.size(); i++){\n System.out.print(list.toArray()[list.size() - 1 - i]);\n }\n }\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a string S consisting of lowercase English letters.\n\nStarting with this string, he will produce a new one in the procedure given as follows.\n\nThe procedure consists of Q operations. In Operation i (1 \\leq i \\leq Q), an integer T_i is provided, which means the following:\n\nIf T_i = 1: reverse the string S.\n\nIf T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided.\n\nIf F_i = 1 : Add C_i to the beginning of the string S.\n\nIf F_i = 2 : Add C_i to the end of the string S.\n\nHelp Takahashi by finding the final string that results from the procedure.\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS consists of lowercase English letters.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\nT_i = 1 or 2.\n\nF_i = 1 or 2, if provided.\n\nC_i is a lowercase English letter, if provided.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nQ\nQuery_1\n:\nQuery_Q\n\nIn the 3-rd through the (Q+2)-th lines, Query_i is one of the following:\n\n1\n\nwhich means T_i = 1, and:\n\n2 F_i C_i\n\nwhich means T_i = 2.\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\na\n4\n2 1 p\n1\n2 2 c\n1\n\nSample Output 1\n\ncpa\n\nThere will be Q = 4 operations. Initially, S is a.\n\nOperation 1: Add p at the beginning of S. S becomes pa.\n\nOperation 2: Reverse S. S becomes ap.\n\nOperation 3: Add c at the end of S. S becomes apc.\n\nOperation 4: Reverse S. S becomes cpa.\n\nThus, the resulting string is cpa.\n\nSample Input 2\n\na\n6\n2 2 a\n2 1 b\n1\n2 2 c\n1\n1\n\nSample Output 2\n\naabc\n\nThere will be Q = 6 operations. Initially, S is a.\n\nOperation 1: S becomes aa.\n\nOperation 2: S becomes baa.\n\nOperation 3: S becomes aab.\n\nOperation 4: S becomes aabc.\n\nOperation 5: S becomes cbaa.\n\nOperation 6: S becomes aabc.\n\nThus, the resulting string is aabc.\n\nSample Input 3\n\ny\n1\n2 1 x\n\nSample Output 3\n\nxy", "sample_input": "a\n4\n2 1 p\n1\n2 2 c\n1\n"}, "reference_outputs": ["cpa\n"], "source_document_id": "p02756", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a string S consisting of lowercase English letters.\n\nStarting with this string, he will produce a new one in the procedure given as follows.\n\nThe procedure consists of Q operations. In Operation i (1 \\leq i \\leq Q), an integer T_i is provided, which means the following:\n\nIf T_i = 1: reverse the string S.\n\nIf T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided.\n\nIf F_i = 1 : Add C_i to the beginning of the string S.\n\nIf F_i = 2 : Add C_i to the end of the string S.\n\nHelp Takahashi by finding the final string that results from the procedure.\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS consists of lowercase English letters.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\nT_i = 1 or 2.\n\nF_i = 1 or 2, if provided.\n\nC_i is a lowercase English letter, if provided.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nQ\nQuery_1\n:\nQuery_Q\n\nIn the 3-rd through the (Q+2)-th lines, Query_i is one of the following:\n\n1\n\nwhich means T_i = 1, and:\n\n2 F_i C_i\n\nwhich means T_i = 2.\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\na\n4\n2 1 p\n1\n2 2 c\n1\n\nSample Output 1\n\ncpa\n\nThere will be Q = 4 operations. Initially, S is a.\n\nOperation 1: Add p at the beginning of S. S becomes pa.\n\nOperation 2: Reverse S. S becomes ap.\n\nOperation 3: Add c at the end of S. S becomes apc.\n\nOperation 4: Reverse S. S becomes cpa.\n\nThus, the resulting string is cpa.\n\nSample Input 2\n\na\n6\n2 2 a\n2 1 b\n1\n2 2 c\n1\n1\n\nSample Output 2\n\naabc\n\nThere will be Q = 6 operations. Initially, S is a.\n\nOperation 1: S becomes aa.\n\nOperation 2: S becomes baa.\n\nOperation 3: S becomes aab.\n\nOperation 4: S becomes aabc.\n\nOperation 5: S becomes cbaa.\n\nOperation 6: S becomes aabc.\n\nThus, the resulting string is aabc.\n\nSample Input 3\n\ny\n1\n2 1 x\n\nSample Output 3\n\nxy", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1077, "cpu_time_ms": 2110, "memory_kb": 348484}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s751849632", "group_id": "codeNet:p02756", "input_text": "import java.io.*;\nimport java.util.*;\nclass Main{\n\tstatic final long MOD = 1_000_000_007; // 10^9+7\n static final int MAX = 2_147_483_646; // intMax \n static final int INF = 1_000_000_000; // 10^9 \n public static void main(String[] args) throws Exception {\n\t\thayami saori = new hayami();\n\t\tString s = saori.nextHayami();\n\t\tString[] s2 = s.split(\"\");\n\t\tint q = saori.saori_hayami();\n\t\tString[][] sousa = new String[q][3];\n\t\tint t = 0;\n\t\tint f = 0;\n\t\tString str =\"\";\n\t\tString ans = s;\n\t\tString ans2 = s;\n\t\tint rev = 0;\n\t\tint[] flg = new int[q];\n\t\tfor(int i = 0;i < q;i++){\n\t\t\tt = saori.saori_hayami();\n\t\t\tif(t == 1){\n\t\t\t\tsousa[i][0] = \"hayami\";\n\t\t\t} else {\n\t\t\t\tf = saori.saori_hayami();\n\t\t\t\tstr = saori.nextHayami();\n\t\t\t\tsousa[i][f] = str;\n\t\t\t\tsousa[i][0] = \"\";\n\t\t\t\tflg[i] = f;\n\t\t\t}\n\t\t\tif(sousa[i][0].equals(\"hayami\")){\n\t\t\t\trev++;\n\t\t\t} else {\n\t\t\t\tif(flg[i] == 2){\n\n\t\t\t\t\tans2 = sousa[i][2] + ans2;\n\t\t\t\t\tif(rev%2 == 0){\n\t\t\t\t\t\tans = ans + sousa[i][2];\n\t\t\t\t\t\tans2 = sousa[i][2] + ans2;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tans = sousa[i][2] + ans;\n\t\t\t\t\t\tans2 = ans2 + sousa[i][2];\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tans2 = sousa[i][1] + ans;\n\t\t\t\t\tif(rev%2 == 0){\n\t\t\t\t\t\tans = sousa[i][1] + ans;\n\t\t\t\t\t\tans2 =ans2 + sousa[i][1];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tans =ans + sousa[i][1];\n\t\t\t\t\t\tans2 = sousa[i][1] + ans2;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(rev%2 == 0){\n\t\t\tSystem.out.println(ans);\n\t\t} else {\n\t\t\tSystem.out.println(ans2);\n\t\t}\n\t\tsaori.close();\n }\n}\n\nclass hayami implements Closeable {\n\tprivate final InputStream in = System.in;\n\tprivate final byte[] hayami = new byte[1024];\n\tprivate int Hayami = 0;\n\tprivate int saori = 0;\n\tprivate boolean HayamiSaori() {\n\t\tif (Hayami < saori) {\n\t\t\treturn true;\n\t\t}else{\n\t\t\tHayami = 0;\n\t\t\ttry {\n\t\t\t\tsaori = in.read(hayami);\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (saori <= 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\tprivate int SaoriHayami() { \n\t\tif (HayamiSaori()) {\n return hayami[Hayami++];\n }else{\n return -1;\n }\n\t}\n\tprivate static boolean hayami_saori(int hayami) { \n\t\treturn 33 <= hayami && hayami <= 126;\n\t}\n\tpublic boolean hayamisaori() { \n\t\twhile(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();\n\t}\n\tpublic String nextHayami() {\n\t\tif (!hayamisaori()) throw new NoSuchElementException();\n\t\tStringBuilder hayamin = new StringBuilder();\n\t\tint saori = SaoriHayami();\n\t\twhile(hayami_saori(saori)) {\n\t\t\thayamin.appendCodePoint(saori);\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t\treturn hayamin.toString();\n\t}\n\tpublic long saorihayami() {//nextLong\n\t\tif (!hayamisaori()) throw new NoSuchElementException();\n\t\tlong hayami = 0;\n\t\tboolean misao = false;\n\t\tint saori = SaoriHayami();\n\t\tif (saori == '-') {\n\t\t\tmisao = true;\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t\tif (saori < '0' || '9' < saori) {\n\t\t\tthrow new NumberFormatException();\n\t\t}\n\t\twhile(true){\n\t\t\tif ('0' <= saori && saori <= '9') {\n\t\t\t\thayami *= 10;\n\t\t\t\thayami += saori - '0';\n\t\t\t}else if(saori == -1 || !hayami_saori(saori)){\n\t\t\t\treturn misao ? -hayami : hayami;\n\t\t\t}else{\n\t\t\t\tthrow new NumberFormatException();\n\t\t\t}\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t}\n\tpublic int saori_hayami() {//nextInt\n\t\tlong hayami = saorihayami();\n\t\tif (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();\n\t\treturn (int) hayami;\n\t}\n\tpublic double Hayamin() { //nextDouble\n\t\treturn Double.parseDouble(nextHayami());\n\t}\n\tpublic void close() {\n\t\ttry {\n\t\t\tin.close();\n\t\t} catch (IOException e) {\n\t\t}\n }\n \n}\n", "language": "Java", "metadata": {"date": 1583638793, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02756.html", "problem_id": "p02756", "resource_group": "high_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/Java/s751849632.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s751849632", "user_id": "u676749446"}, "prompt_components": {"gold_output": "cpa\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\nclass Main{\n\tstatic final long MOD = 1_000_000_007; // 10^9+7\n static final int MAX = 2_147_483_646; // intMax \n static final int INF = 1_000_000_000; // 10^9 \n public static void main(String[] args) throws Exception {\n\t\thayami saori = new hayami();\n\t\tString s = saori.nextHayami();\n\t\tString[] s2 = s.split(\"\");\n\t\tint q = saori.saori_hayami();\n\t\tString[][] sousa = new String[q][3];\n\t\tint t = 0;\n\t\tint f = 0;\n\t\tString str =\"\";\n\t\tString ans = s;\n\t\tString ans2 = s;\n\t\tint rev = 0;\n\t\tint[] flg = new int[q];\n\t\tfor(int i = 0;i < q;i++){\n\t\t\tt = saori.saori_hayami();\n\t\t\tif(t == 1){\n\t\t\t\tsousa[i][0] = \"hayami\";\n\t\t\t} else {\n\t\t\t\tf = saori.saori_hayami();\n\t\t\t\tstr = saori.nextHayami();\n\t\t\t\tsousa[i][f] = str;\n\t\t\t\tsousa[i][0] = \"\";\n\t\t\t\tflg[i] = f;\n\t\t\t}\n\t\t\tif(sousa[i][0].equals(\"hayami\")){\n\t\t\t\trev++;\n\t\t\t} else {\n\t\t\t\tif(flg[i] == 2){\n\n\t\t\t\t\tans2 = sousa[i][2] + ans2;\n\t\t\t\t\tif(rev%2 == 0){\n\t\t\t\t\t\tans = ans + sousa[i][2];\n\t\t\t\t\t\tans2 = sousa[i][2] + ans2;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tans = sousa[i][2] + ans;\n\t\t\t\t\t\tans2 = ans2 + sousa[i][2];\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tans2 = sousa[i][1] + ans;\n\t\t\t\t\tif(rev%2 == 0){\n\t\t\t\t\t\tans = sousa[i][1] + ans;\n\t\t\t\t\t\tans2 =ans2 + sousa[i][1];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tans =ans + sousa[i][1];\n\t\t\t\t\t\tans2 = sousa[i][1] + ans2;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(rev%2 == 0){\n\t\t\tSystem.out.println(ans);\n\t\t} else {\n\t\t\tSystem.out.println(ans2);\n\t\t}\n\t\tsaori.close();\n }\n}\n\nclass hayami implements Closeable {\n\tprivate final InputStream in = System.in;\n\tprivate final byte[] hayami = new byte[1024];\n\tprivate int Hayami = 0;\n\tprivate int saori = 0;\n\tprivate boolean HayamiSaori() {\n\t\tif (Hayami < saori) {\n\t\t\treturn true;\n\t\t}else{\n\t\t\tHayami = 0;\n\t\t\ttry {\n\t\t\t\tsaori = in.read(hayami);\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (saori <= 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\tprivate int SaoriHayami() { \n\t\tif (HayamiSaori()) {\n return hayami[Hayami++];\n }else{\n return -1;\n }\n\t}\n\tprivate static boolean hayami_saori(int hayami) { \n\t\treturn 33 <= hayami && hayami <= 126;\n\t}\n\tpublic boolean hayamisaori() { \n\t\twhile(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();\n\t}\n\tpublic String nextHayami() {\n\t\tif (!hayamisaori()) throw new NoSuchElementException();\n\t\tStringBuilder hayamin = new StringBuilder();\n\t\tint saori = SaoriHayami();\n\t\twhile(hayami_saori(saori)) {\n\t\t\thayamin.appendCodePoint(saori);\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t\treturn hayamin.toString();\n\t}\n\tpublic long saorihayami() {//nextLong\n\t\tif (!hayamisaori()) throw new NoSuchElementException();\n\t\tlong hayami = 0;\n\t\tboolean misao = false;\n\t\tint saori = SaoriHayami();\n\t\tif (saori == '-') {\n\t\t\tmisao = true;\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t\tif (saori < '0' || '9' < saori) {\n\t\t\tthrow new NumberFormatException();\n\t\t}\n\t\twhile(true){\n\t\t\tif ('0' <= saori && saori <= '9') {\n\t\t\t\thayami *= 10;\n\t\t\t\thayami += saori - '0';\n\t\t\t}else if(saori == -1 || !hayami_saori(saori)){\n\t\t\t\treturn misao ? -hayami : hayami;\n\t\t\t}else{\n\t\t\t\tthrow new NumberFormatException();\n\t\t\t}\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t}\n\tpublic int saori_hayami() {//nextInt\n\t\tlong hayami = saorihayami();\n\t\tif (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();\n\t\treturn (int) hayami;\n\t}\n\tpublic double Hayamin() { //nextDouble\n\t\treturn Double.parseDouble(nextHayami());\n\t}\n\tpublic void close() {\n\t\ttry {\n\t\t\tin.close();\n\t\t} catch (IOException e) {\n\t\t}\n }\n \n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a string S consisting of lowercase English letters.\n\nStarting with this string, he will produce a new one in the procedure given as follows.\n\nThe procedure consists of Q operations. In Operation i (1 \\leq i \\leq Q), an integer T_i is provided, which means the following:\n\nIf T_i = 1: reverse the string S.\n\nIf T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided.\n\nIf F_i = 1 : Add C_i to the beginning of the string S.\n\nIf F_i = 2 : Add C_i to the end of the string S.\n\nHelp Takahashi by finding the final string that results from the procedure.\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS consists of lowercase English letters.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\nT_i = 1 or 2.\n\nF_i = 1 or 2, if provided.\n\nC_i is a lowercase English letter, if provided.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nQ\nQuery_1\n:\nQuery_Q\n\nIn the 3-rd through the (Q+2)-th lines, Query_i is one of the following:\n\n1\n\nwhich means T_i = 1, and:\n\n2 F_i C_i\n\nwhich means T_i = 2.\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\na\n4\n2 1 p\n1\n2 2 c\n1\n\nSample Output 1\n\ncpa\n\nThere will be Q = 4 operations. Initially, S is a.\n\nOperation 1: Add p at the beginning of S. S becomes pa.\n\nOperation 2: Reverse S. S becomes ap.\n\nOperation 3: Add c at the end of S. S becomes apc.\n\nOperation 4: Reverse S. S becomes cpa.\n\nThus, the resulting string is cpa.\n\nSample Input 2\n\na\n6\n2 2 a\n2 1 b\n1\n2 2 c\n1\n1\n\nSample Output 2\n\naabc\n\nThere will be Q = 6 operations. Initially, S is a.\n\nOperation 1: S becomes aa.\n\nOperation 2: S becomes baa.\n\nOperation 3: S becomes aab.\n\nOperation 4: S becomes aabc.\n\nOperation 5: S becomes cbaa.\n\nOperation 6: S becomes aabc.\n\nThus, the resulting string is aabc.\n\nSample Input 3\n\ny\n1\n2 1 x\n\nSample Output 3\n\nxy", "sample_input": "a\n4\n2 1 p\n1\n2 2 c\n1\n"}, "reference_outputs": ["cpa\n"], "source_document_id": "p02756", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a string S consisting of lowercase English letters.\n\nStarting with this string, he will produce a new one in the procedure given as follows.\n\nThe procedure consists of Q operations. In Operation i (1 \\leq i \\leq Q), an integer T_i is provided, which means the following:\n\nIf T_i = 1: reverse the string S.\n\nIf T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided.\n\nIf F_i = 1 : Add C_i to the beginning of the string S.\n\nIf F_i = 2 : Add C_i to the end of the string S.\n\nHelp Takahashi by finding the final string that results from the procedure.\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS consists of lowercase English letters.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\nT_i = 1 or 2.\n\nF_i = 1 or 2, if provided.\n\nC_i is a lowercase English letter, if provided.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nQ\nQuery_1\n:\nQuery_Q\n\nIn the 3-rd through the (Q+2)-th lines, Query_i is one of the following:\n\n1\n\nwhich means T_i = 1, and:\n\n2 F_i C_i\n\nwhich means T_i = 2.\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\na\n4\n2 1 p\n1\n2 2 c\n1\n\nSample Output 1\n\ncpa\n\nThere will be Q = 4 operations. Initially, S is a.\n\nOperation 1: Add p at the beginning of S. S becomes pa.\n\nOperation 2: Reverse S. S becomes ap.\n\nOperation 3: Add c at the end of S. S becomes apc.\n\nOperation 4: Reverse S. S becomes cpa.\n\nThus, the resulting string is cpa.\n\nSample Input 2\n\na\n6\n2 2 a\n2 1 b\n1\n2 2 c\n1\n1\n\nSample Output 2\n\naabc\n\nThere will be Q = 6 operations. Initially, S is a.\n\nOperation 1: S becomes aa.\n\nOperation 2: S becomes baa.\n\nOperation 3: S becomes aab.\n\nOperation 4: S becomes aabc.\n\nOperation 5: S becomes cbaa.\n\nOperation 6: S becomes aabc.\n\nThus, the resulting string is aabc.\n\nSample Input 3\n\ny\n1\n2 1 x\n\nSample Output 3\n\nxy", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3469, "cpu_time_ms": 2110, "memory_kb": 355700}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s654482727", "group_id": "codeNet:p02756", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString s = sc.next();\n\t\tint n = sc.nextInt();\n\t\tboolean reverse = false;\n\t\tStringBuilder sb = new StringBuilder(s);\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tint q = sc.nextInt();\n\t\t\tif(q == 1) {\n\t\t\t\treverse = !reverse;\n\t\t\t} else {\n\t\t\t\tint q2 = sc.nextInt();\n\t\t\t\tif((!reverse && q2 == 1) || (reverse && q2 == 2)) {\n\t\t\t\t\tsb.insert(0, sc.next());\n\t\t\t\t} else {\n\t\t\t\t\tsb.append(sc.next());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(reverse) sb.reverse();\n\t\tSystem.out.println(sb.toString());\n\t}\n}", "language": "Java", "metadata": {"date": 1583636340, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02756.html", "problem_id": "p02756", "resource_group": "high_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/Java/s654482727.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s654482727", "user_id": "u616247903"}, "prompt_components": {"gold_output": "cpa\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString s = sc.next();\n\t\tint n = sc.nextInt();\n\t\tboolean reverse = false;\n\t\tStringBuilder sb = new StringBuilder(s);\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tint q = sc.nextInt();\n\t\t\tif(q == 1) {\n\t\t\t\treverse = !reverse;\n\t\t\t} else {\n\t\t\t\tint q2 = sc.nextInt();\n\t\t\t\tif((!reverse && q2 == 1) || (reverse && q2 == 2)) {\n\t\t\t\t\tsb.insert(0, sc.next());\n\t\t\t\t} else {\n\t\t\t\t\tsb.append(sc.next());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(reverse) sb.reverse();\n\t\tSystem.out.println(sb.toString());\n\t}\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": 592, "cpu_time_ms": 2109, "memory_kb": 94080}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s613116396", "group_id": "codeNet:p02757", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.Reader;\nimport java.io.InputStreamReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n MyInput in = new MyInput(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n EDivisibleSubstring solver = new EDivisibleSubstring();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class EDivisibleSubstring {\n public void solve(int testNumber, MyInput in, PrintWriter out) {\n int n = in.nextInt();\n int p = in.nextInt();\n\n int[] mod1 = new int[p];\n char[] s = in.nextChars();\n int v = 0;\n int iv = (int) inverseModPrime(10, p);\n long ans = 0;\n int[] mod2 = new int[p];\n for (int i = 0; i < n; i++) {\n v = (v * 10 + s[i] - '0') % p;\n if (p <= 50) {\n Arrays.fill(mod2, 0);\n for (int j = 0; j < p; j++) {\n mod2[j * 10 % p] += mod1[j];\n }\n int[] tmp = mod1;\n mod1 = mod2;\n mod2 = tmp;\n ans += mod1[v];\n if (v == 0) ans++;\n mod1[v]++;\n } else {\n ans += mod1[iv * v % p];\n if (v == 0) ans++;\n mod1[iv * v % p]++;\n }\n }\n out.println(ans);\n }\n\n static long powmod(long n, long r, int m) {\n long res = 1;\n for (; r != 0; r >>>= 1, n = n * n % m) {\n if ((r & 1) == 1) {\n res = res * n;\n if (res >= m) {\n res %= m;\n }\n }\n }\n return res;\n }\n\n static long inverseModPrime(long n, int p) {\n return powmod(n, p - 2, p);\n }\n\n }\n\n static class MyInput {\n private final BufferedReader in;\n private static int pos;\n private static int readLen;\n private static final char[] buffer = new char[1024 * 8];\n private static char[] str = new char[500 * 8 * 2];\n private static boolean[] isDigit = new boolean[256];\n private static boolean[] isSpace = new boolean[256];\n private static boolean[] isLineSep = new boolean[256];\n\n static {\n for (int i = 0; i < 10; i++) {\n isDigit['0' + i] = true;\n }\n isDigit['-'] = true;\n isSpace[' '] = isSpace['\\r'] = isSpace['\\n'] = isSpace['\\t'] = true;\n isLineSep['\\r'] = isLineSep['\\n'] = true;\n }\n\n public MyInput(InputStream is) {\n in = new BufferedReader(new InputStreamReader(is));\n }\n\n public int read() {\n if (pos >= readLen) {\n pos = 0;\n try {\n readLen = in.read(buffer);\n } catch (IOException e) {\n throw new RuntimeException();\n }\n if (readLen <= 0) {\n throw new MyInput.EndOfFileRuntimeException();\n }\n }\n return buffer[pos++];\n }\n\n public int nextInt() {\n int len = 0;\n str[len++] = nextChar();\n len = reads(len, isSpace);\n int i = 0;\n int ret = 0;\n if (str[0] == '-') {\n i = 1;\n }\n for (; i < len; i++) ret = ret * 10 + str[i] - '0';\n if (str[0] == '-') {\n ret = -ret;\n }\n return ret;\n }\n\n public char nextChar() {\n while (true) {\n final int c = read();\n if (!isSpace[c]) {\n return (char) c;\n }\n }\n }\n\n int reads(int len, boolean[] accept) {\n try {\n while (true) {\n final int c = read();\n if (accept[c]) {\n break;\n }\n if (str.length == len) {\n char[] rep = new char[str.length * 3 / 2];\n System.arraycopy(str, 0, rep, 0, str.length);\n str = rep;\n }\n str[len++] = (char) c;\n }\n } catch (MyInput.EndOfFileRuntimeException e) {\n }\n return len;\n }\n\n public char[] nextChars() {\n int len = 0;\n str[len++] = nextChar();\n len = reads(len, isSpace);\n return Arrays.copyOf(str, len);\n }\n\n static class EndOfFileRuntimeException extends RuntimeException {\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1583638496, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02757.html", "problem_id": "p02757", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02757/input.txt", "sample_output_relpath": "derived/input_output/data/p02757/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02757/Java/s613116396.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s613116396", "user_id": "u429053592"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.Reader;\nimport java.io.InputStreamReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n MyInput in = new MyInput(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n EDivisibleSubstring solver = new EDivisibleSubstring();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class EDivisibleSubstring {\n public void solve(int testNumber, MyInput in, PrintWriter out) {\n int n = in.nextInt();\n int p = in.nextInt();\n\n int[] mod1 = new int[p];\n char[] s = in.nextChars();\n int v = 0;\n int iv = (int) inverseModPrime(10, p);\n long ans = 0;\n int[] mod2 = new int[p];\n for (int i = 0; i < n; i++) {\n v = (v * 10 + s[i] - '0') % p;\n if (p <= 50) {\n Arrays.fill(mod2, 0);\n for (int j = 0; j < p; j++) {\n mod2[j * 10 % p] += mod1[j];\n }\n int[] tmp = mod1;\n mod1 = mod2;\n mod2 = tmp;\n ans += mod1[v];\n if (v == 0) ans++;\n mod1[v]++;\n } else {\n ans += mod1[iv * v % p];\n if (v == 0) ans++;\n mod1[iv * v % p]++;\n }\n }\n out.println(ans);\n }\n\n static long powmod(long n, long r, int m) {\n long res = 1;\n for (; r != 0; r >>>= 1, n = n * n % m) {\n if ((r & 1) == 1) {\n res = res * n;\n if (res >= m) {\n res %= m;\n }\n }\n }\n return res;\n }\n\n static long inverseModPrime(long n, int p) {\n return powmod(n, p - 2, p);\n }\n\n }\n\n static class MyInput {\n private final BufferedReader in;\n private static int pos;\n private static int readLen;\n private static final char[] buffer = new char[1024 * 8];\n private static char[] str = new char[500 * 8 * 2];\n private static boolean[] isDigit = new boolean[256];\n private static boolean[] isSpace = new boolean[256];\n private static boolean[] isLineSep = new boolean[256];\n\n static {\n for (int i = 0; i < 10; i++) {\n isDigit['0' + i] = true;\n }\n isDigit['-'] = true;\n isSpace[' '] = isSpace['\\r'] = isSpace['\\n'] = isSpace['\\t'] = true;\n isLineSep['\\r'] = isLineSep['\\n'] = true;\n }\n\n public MyInput(InputStream is) {\n in = new BufferedReader(new InputStreamReader(is));\n }\n\n public int read() {\n if (pos >= readLen) {\n pos = 0;\n try {\n readLen = in.read(buffer);\n } catch (IOException e) {\n throw new RuntimeException();\n }\n if (readLen <= 0) {\n throw new MyInput.EndOfFileRuntimeException();\n }\n }\n return buffer[pos++];\n }\n\n public int nextInt() {\n int len = 0;\n str[len++] = nextChar();\n len = reads(len, isSpace);\n int i = 0;\n int ret = 0;\n if (str[0] == '-') {\n i = 1;\n }\n for (; i < len; i++) ret = ret * 10 + str[i] - '0';\n if (str[0] == '-') {\n ret = -ret;\n }\n return ret;\n }\n\n public char nextChar() {\n while (true) {\n final int c = read();\n if (!isSpace[c]) {\n return (char) c;\n }\n }\n }\n\n int reads(int len, boolean[] accept) {\n try {\n while (true) {\n final int c = read();\n if (accept[c]) {\n break;\n }\n if (str.length == len) {\n char[] rep = new char[str.length * 3 / 2];\n System.arraycopy(str, 0, rep, 0, str.length);\n str = rep;\n }\n str[len++] = (char) c;\n }\n } catch (MyInput.EndOfFileRuntimeException e) {\n }\n return len;\n }\n\n public char[] nextChars() {\n int len = 0;\n str[len++] = nextChar();\n len = reads(len, isSpace);\n return Arrays.copyOf(str, len);\n }\n\n static class EndOfFileRuntimeException extends RuntimeException {\n }\n\n }\n}\n\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi has a string S of length N consisting of digits from 0 through 9.\n\nHe loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S - there are N \\times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten.\n\nHere substrings starting with a 0 also count, and substrings originated from different positions in S are distinguished, even if they are equal as strings or integers.\n\nCompute this count to help Takahashi.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS consists of digits.\n\n|S| = N\n\n2 \\leq P \\leq 10000\n\nP is a prime number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\nS\n\nOutput\n\nPrint the number of non-empty (contiguous) substrings of S that are divisible by P when regarded as an integer written in base ten.\n\nSample Input 1\n\n4 3\n3543\n\nSample Output 1\n\n6\n\nHere S = 3543. There are ten non-empty (contiguous) substrings of S:\n\n3: divisible by 3.\n\n35: not divisible by 3.\n\n354: divisible by 3.\n\n3543: divisible by 3.\n\n5: not divisible by 3.\n\n54: divisible by 3.\n\n543: divisible by 3.\n\n4: not divisible by 3.\n\n43: not divisible by 3.\n\n3: divisible by 3.\n\nSix of these are divisible by 3, so print 6.\n\nSample Input 2\n\n4 2\n2020\n\nSample Output 2\n\n10\n\nHere S = 2020. There are ten non-empty (contiguous) substrings of S, all of which are divisible by 2, so print 10.\n\nNote that substrings beginning with a 0 also count.\n\nSample Input 3\n\n20 11\n33883322005544116655\n\nSample Output 3\n\n68", "sample_input": "4 3\n3543\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02757", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi has a string S of length N consisting of digits from 0 through 9.\n\nHe loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S - there are N \\times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten.\n\nHere substrings starting with a 0 also count, and substrings originated from different positions in S are distinguished, even if they are equal as strings or integers.\n\nCompute this count to help Takahashi.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS consists of digits.\n\n|S| = N\n\n2 \\leq P \\leq 10000\n\nP is a prime number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\nS\n\nOutput\n\nPrint the number of non-empty (contiguous) substrings of S that are divisible by P when regarded as an integer written in base ten.\n\nSample Input 1\n\n4 3\n3543\n\nSample Output 1\n\n6\n\nHere S = 3543. There are ten non-empty (contiguous) substrings of S:\n\n3: divisible by 3.\n\n35: not divisible by 3.\n\n354: divisible by 3.\n\n3543: divisible by 3.\n\n5: not divisible by 3.\n\n54: divisible by 3.\n\n543: divisible by 3.\n\n4: not divisible by 3.\n\n43: not divisible by 3.\n\n3: divisible by 3.\n\nSix of these are divisible by 3, so print 6.\n\nSample Input 2\n\n4 2\n2020\n\nSample Output 2\n\n10\n\nHere S = 2020. There are ten non-empty (contiguous) substrings of S, all of which are divisible by 2, so print 10.\n\nNote that substrings beginning with a 0 also count.\n\nSample Input 3\n\n20 11\n33883322005544116655\n\nSample Output 3\n\n68", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5190, "cpu_time_ms": 139, "memory_kb": 26976}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s906578282", "group_id": "codeNet:p02759", "input_text": "import java.util.Scanner;\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint a = sc.nextInt();\n\t\tSystem.out.println(a % 2 == 0 ? a / 2 : a / 2 + 1 );\n\t}\n}\n", "language": "Java", "metadata": {"date": 1595176232, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02759.html", "problem_id": "p02759", "resource_group": "high_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/Java/s906578282.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s906578282", "user_id": "u389287142"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint a = sc.nextInt();\n\t\tSystem.out.println(a % 2 == 0 ? a / 2 : a / 2 + 1 );\n\t}\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": 211, "cpu_time_ms": 113, "memory_kb": 35800}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s800644782", "group_id": "codeNet:p02759", "input_text": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Map.Entry;\nimport java.util.NoSuchElementException;\nimport java.util.Set;\n\npublic class Main {\n\tpublic static void main(String args[]) throws IOException {\n\t\tFastScanner fs = new FastScanner();\n\t\tdouble page = fs.nextInt();\n\t\tSystem.out.println((int)Math.ceil(page / 2) );\n\t}\n}\n\n\n\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n }else{\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}\n private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}\n public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while(isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while(true){\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n public double nextDouble() { return Double.parseDouble(next());}\n}\n\n", "language": "Java", "metadata": {"date": 1583125282, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02759.html", "problem_id": "p02759", "resource_group": "high_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/Java/s800644782.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s800644782", "user_id": "u068577033"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Map.Entry;\nimport java.util.NoSuchElementException;\nimport java.util.Set;\n\npublic class Main {\n\tpublic static void main(String args[]) throws IOException {\n\t\tFastScanner fs = new FastScanner();\n\t\tdouble page = fs.nextInt();\n\t\tSystem.out.println((int)Math.ceil(page / 2) );\n\t}\n}\n\n\n\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n }else{\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}\n private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}\n public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while(isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while(true){\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n public double nextDouble() { return Double.parseDouble(next());}\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": 2597, "cpu_time_ms": 70, "memory_kb": 21204}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s236663813", "group_id": "codeNet:p02759", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int p = n / 2;\n if(n % 2 == 1){\n p ++;\n }\n System.out.println(p);\n }\n}", "language": "Java", "metadata": {"date": 1583114750, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02759.html", "problem_id": "p02759", "resource_group": "high_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/Java/s236663813.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s236663813", "user_id": "u817042904"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int p = n / 2;\n if(n % 2 == 1){\n p ++;\n }\n System.out.println(p);\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": 281, "cpu_time_ms": 120, "memory_kb": 23636}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s272746253", "group_id": "codeNet:p02762", "input_text": "import java.io.ByteArrayInputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.*;\n\npublic class Main {\n static InputStream is;\n static PrintWriter out;\n static String INPUT = \"\";\n static List[] g;\n static int[] group;\n static int[] size;\n static int id;\n static int count;\n\n static void solve() {\n int n = ni();\n int m = ni();\n int k = ni();\n\n g = new List[n];\n group = new int[n];\n size = new int[n];\n int[][] block = new int[k][2];\n\n for (int i = 0; i < n; i++) {\n g[i] = new ArrayList<>();\n }\n\n for (int i = 0; i < m; i++) {\n int a = ni() - 1;\n int b = ni() - 1;\n g[a].add(b);\n g[b].add(a);\n }\n\n for (int i = 0; i < k; i++) {\n block[i][0] = ni() - 1;\n block[i][1] = ni() - 1;\n }\n\n Arrays.fill(group, -1);\n id = 0;\n for (int i = 0; i < n; i++) {\n if (group[i] == -1) {\n count = 0;\n dfs(i);\n size[id] = count;\n id++;\n }\n }\n\n int[] ans = new int[n];\n for (int i = 0; i < n; i++) {\n ans[i] = size[group[i]] - 1 - g[i].size();\n }\n\n for (int i = 0; i < k; i++) {\n int c = block[i][0];\n int d = block[i][1];\n if (group[c] == group[d]) {\n ans[c]--;\n ans[d]--;\n }\n }\n\n for (int i = 0; i < n; i++) {\n out.print(ans[i]);\n out.print((i == n - 1)? \"\" : \" \");\n }\n\n out.println();\n }\n\n public static void dfs(int v) {\n group[v] = id;\n count++;\n for (int u : g[v]) {\n if (group[u] == -1) {\n dfs(u);\n }\n }\n }\n\n public static void main(String[] args) throws Exception {\n long S = System.currentTimeMillis();\n is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n out = new PrintWriter(System.out);\n\n solve();\n out.flush();\n long G = System.currentTimeMillis();\n tr(G-S+\"ms\");\n }\n\n private static boolean eof() {\n if(lenbuf == -1)return true;\n int lptr = ptrbuf;\n while(lptr < lenbuf)if(!isSpaceChar(inbuf[lptr++]))return false;\n\n try {\n is.mark(1000);\n while(true){\n int b = is.read();\n if(b == -1){\n is.reset();\n return true;\n }else if(!isSpaceChar(b)){\n is.reset();\n return false;\n }\n }\n } catch (IOException e) {\n return true;\n }\n }\n\n private static byte[] inbuf = new byte[1024];\n static int lenbuf = 0, ptrbuf = 0;\n\n private static int readByte() {\n if(lenbuf == -1)throw new InputMismatchException();\n if(ptrbuf >= lenbuf){\n ptrbuf = 0;\n try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }\n if(lenbuf <= 0)return -1;\n }\n return inbuf[ptrbuf++];\n }\n\n private static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }\n\n private static int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }\n\n private static double nd() { return Double.parseDouble(ns()); }\n private static char nc() { return (char)skip(); }\n\n private static String ns() {\n int b = skip();\n StringBuilder sb = new StringBuilder();\n while(!(isSpaceChar(b))){\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n private static char[] ns(int n) {\n char[] buf = new char[n];\n int b = skip(), p = 0;\n while(p < n && !(isSpaceChar(b))){\n buf[p++] = (char)b;\n b = readByte();\n }\n return n == p ? buf : Arrays.copyOf(buf, p);\n }\n\n private static char[][] nm(int n, int m) {\n char[][] map = new char[n][];\n for(int i = 0;i < n;i++)map[i] = ns(m);\n return map;\n }\n\n private static int[] na(int n) {\n int[] a = new int[n];\n for(int i = 0;i < n;i++)a[i] = ni();\n return a;\n }\n\n private static int ni() {\n int num = 0, b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-'){\n minus = true;\n b = readByte();\n }\n\n while(true){\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n }else{\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n\n private static long nl() {\n long num = 0;\n int b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-'){\n minus = true;\n b = readByte();\n }\n\n while(true){\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n }else{\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n\n private static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }\n\n // Union-Find\n // https://algs4.cs.princeton.edu/15uf/UF.java.html\n public static class UnionFind {\n private int count = 0;\n private int[] parent, rank;\n\n public UnionFind(int n) {\n count = n;\n parent = new int[n];\n rank = new int[n];\n for (int i = 0; i < n; i++) {\n parent[i] = i;\n }\n }\n\n public int find(int p) {\n while (p != parent[p]) {\n parent[p] = parent[parent[p]];\n p = parent[p];\n }\n return p;\n }\n\n public void union(int p, int q) {\n int rootP = find(p);\n int rootQ = find(q);\n if (rootP ==rootQ) return;\n if (rank[rootQ] > rank[rootP]) {\n parent[rootP] = rootQ;\n } else {\n parent[rootQ] = rootP;\n if (rank[rootP] == rank[rootQ]) {\n rank[rootP]++;\n }\n }\n count--;\n }\n\n public int count() {\n return count;\n }\n\n public void print() {\n out.println(\"Parent:\");\n for (int i : parent) {\n out.print(i);\n out.print(\" \");\n }\n out.println();\n out.println(\"Rank:\");\n for (int i : rank) {\n out.print(i);\n out.print(\" \");\n }\n out.println();\n }\n }\n\n // Dijkstra\n // Return min distance from start to end O(ElogV) (negative cost is prohibited)\n // edge is int[3] array {from,to,cost}\n // edges is edge list from specific node\n // all_edges is Map\n static int dijkstra(Map> all_edges,int start,int end,int max_node_number) {\n int[] distance = new int[max_node_number + 1];\n Arrays.fill(distance, -1);\n PriorityQueue p_que = new PriorityQueue<>((a,b) -> ((distance[a[0]] + a[2]) - (distance[b[0]] + b[2])));\n distance[start] = 0;\n List edges = all_edges.get(start);\n p_que.addAll(edges);\n while (distance[end] < 0) {\n int[] nearest_edge = p_que.poll();\n assert nearest_edge != null;\n if (distance[nearest_edge[1]] < 0) {\n distance[nearest_edge[1]] = distance[nearest_edge[0]] + nearest_edge[2];\n if (all_edges.containsKey(nearest_edge[1])) {\n edges = all_edges.get(nearest_edge[1]);\n for (int[] edge : edges) {\n if (distance[edge[1]] < 0) p_que.add(edge);\n }\n }\n }\n }\n return distance[end];\n }\n\n // Enumerate primes in [2, n] with O(n log log n)\n public static List sieveOfEratosthenes(int n) {\n boolean[] isPrime = new boolean[n+1];\n Arrays.fill(isPrime, true);\n for (int i = 2; i * i <= n; i++) {\n if (isPrime[i]) {\n for (int j = i + i; j <= n; j += i) {\n isPrime[j] = false;\n }\n }\n }\n List primes = new ArrayList<>();\n for (int i = 2; i <= n; i++) {\n if (isPrime[i]) {\n primes.add(i);\n }\n }\n return primes;\n }\n\n // Count divisor\n public static int countDivisor(int n) {\n int[] list = new int[n + 1];\n Arrays.fill(list, 0);\n int num = n;\n for (int i = 2; i <= n; i++) {\n while (num % i == 0) {\n list[i] = list[i] + 1;\n num /= i;\n }\n }\n int ans = 1;\n for (int i : list) {\n ans *= (i + 1);\n }\n return ans;\n }\n}\n", "language": "Java", "metadata": {"date": 1592130923, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02762.html", "problem_id": "p02762", "resource_group": "high_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/Java/s272746253.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s272746253", "user_id": "u381460455"}, "prompt_components": {"gold_output": "0 1 0 1\n", "input_to_evaluate": "import java.io.ByteArrayInputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.*;\n\npublic class Main {\n static InputStream is;\n static PrintWriter out;\n static String INPUT = \"\";\n static List[] g;\n static int[] group;\n static int[] size;\n static int id;\n static int count;\n\n static void solve() {\n int n = ni();\n int m = ni();\n int k = ni();\n\n g = new List[n];\n group = new int[n];\n size = new int[n];\n int[][] block = new int[k][2];\n\n for (int i = 0; i < n; i++) {\n g[i] = new ArrayList<>();\n }\n\n for (int i = 0; i < m; i++) {\n int a = ni() - 1;\n int b = ni() - 1;\n g[a].add(b);\n g[b].add(a);\n }\n\n for (int i = 0; i < k; i++) {\n block[i][0] = ni() - 1;\n block[i][1] = ni() - 1;\n }\n\n Arrays.fill(group, -1);\n id = 0;\n for (int i = 0; i < n; i++) {\n if (group[i] == -1) {\n count = 0;\n dfs(i);\n size[id] = count;\n id++;\n }\n }\n\n int[] ans = new int[n];\n for (int i = 0; i < n; i++) {\n ans[i] = size[group[i]] - 1 - g[i].size();\n }\n\n for (int i = 0; i < k; i++) {\n int c = block[i][0];\n int d = block[i][1];\n if (group[c] == group[d]) {\n ans[c]--;\n ans[d]--;\n }\n }\n\n for (int i = 0; i < n; i++) {\n out.print(ans[i]);\n out.print((i == n - 1)? \"\" : \" \");\n }\n\n out.println();\n }\n\n public static void dfs(int v) {\n group[v] = id;\n count++;\n for (int u : g[v]) {\n if (group[u] == -1) {\n dfs(u);\n }\n }\n }\n\n public static void main(String[] args) throws Exception {\n long S = System.currentTimeMillis();\n is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n out = new PrintWriter(System.out);\n\n solve();\n out.flush();\n long G = System.currentTimeMillis();\n tr(G-S+\"ms\");\n }\n\n private static boolean eof() {\n if(lenbuf == -1)return true;\n int lptr = ptrbuf;\n while(lptr < lenbuf)if(!isSpaceChar(inbuf[lptr++]))return false;\n\n try {\n is.mark(1000);\n while(true){\n int b = is.read();\n if(b == -1){\n is.reset();\n return true;\n }else if(!isSpaceChar(b)){\n is.reset();\n return false;\n }\n }\n } catch (IOException e) {\n return true;\n }\n }\n\n private static byte[] inbuf = new byte[1024];\n static int lenbuf = 0, ptrbuf = 0;\n\n private static int readByte() {\n if(lenbuf == -1)throw new InputMismatchException();\n if(ptrbuf >= lenbuf){\n ptrbuf = 0;\n try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }\n if(lenbuf <= 0)return -1;\n }\n return inbuf[ptrbuf++];\n }\n\n private static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }\n\n private static int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }\n\n private static double nd() { return Double.parseDouble(ns()); }\n private static char nc() { return (char)skip(); }\n\n private static String ns() {\n int b = skip();\n StringBuilder sb = new StringBuilder();\n while(!(isSpaceChar(b))){\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n private static char[] ns(int n) {\n char[] buf = new char[n];\n int b = skip(), p = 0;\n while(p < n && !(isSpaceChar(b))){\n buf[p++] = (char)b;\n b = readByte();\n }\n return n == p ? buf : Arrays.copyOf(buf, p);\n }\n\n private static char[][] nm(int n, int m) {\n char[][] map = new char[n][];\n for(int i = 0;i < n;i++)map[i] = ns(m);\n return map;\n }\n\n private static int[] na(int n) {\n int[] a = new int[n];\n for(int i = 0;i < n;i++)a[i] = ni();\n return a;\n }\n\n private static int ni() {\n int num = 0, b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-'){\n minus = true;\n b = readByte();\n }\n\n while(true){\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n }else{\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n\n private static long nl() {\n long num = 0;\n int b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-'){\n minus = true;\n b = readByte();\n }\n\n while(true){\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n }else{\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n\n private static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }\n\n // Union-Find\n // https://algs4.cs.princeton.edu/15uf/UF.java.html\n public static class UnionFind {\n private int count = 0;\n private int[] parent, rank;\n\n public UnionFind(int n) {\n count = n;\n parent = new int[n];\n rank = new int[n];\n for (int i = 0; i < n; i++) {\n parent[i] = i;\n }\n }\n\n public int find(int p) {\n while (p != parent[p]) {\n parent[p] = parent[parent[p]];\n p = parent[p];\n }\n return p;\n }\n\n public void union(int p, int q) {\n int rootP = find(p);\n int rootQ = find(q);\n if (rootP ==rootQ) return;\n if (rank[rootQ] > rank[rootP]) {\n parent[rootP] = rootQ;\n } else {\n parent[rootQ] = rootP;\n if (rank[rootP] == rank[rootQ]) {\n rank[rootP]++;\n }\n }\n count--;\n }\n\n public int count() {\n return count;\n }\n\n public void print() {\n out.println(\"Parent:\");\n for (int i : parent) {\n out.print(i);\n out.print(\" \");\n }\n out.println();\n out.println(\"Rank:\");\n for (int i : rank) {\n out.print(i);\n out.print(\" \");\n }\n out.println();\n }\n }\n\n // Dijkstra\n // Return min distance from start to end O(ElogV) (negative cost is prohibited)\n // edge is int[3] array {from,to,cost}\n // edges is edge list from specific node\n // all_edges is Map\n static int dijkstra(Map> all_edges,int start,int end,int max_node_number) {\n int[] distance = new int[max_node_number + 1];\n Arrays.fill(distance, -1);\n PriorityQueue p_que = new PriorityQueue<>((a,b) -> ((distance[a[0]] + a[2]) - (distance[b[0]] + b[2])));\n distance[start] = 0;\n List edges = all_edges.get(start);\n p_que.addAll(edges);\n while (distance[end] < 0) {\n int[] nearest_edge = p_que.poll();\n assert nearest_edge != null;\n if (distance[nearest_edge[1]] < 0) {\n distance[nearest_edge[1]] = distance[nearest_edge[0]] + nearest_edge[2];\n if (all_edges.containsKey(nearest_edge[1])) {\n edges = all_edges.get(nearest_edge[1]);\n for (int[] edge : edges) {\n if (distance[edge[1]] < 0) p_que.add(edge);\n }\n }\n }\n }\n return distance[end];\n }\n\n // Enumerate primes in [2, n] with O(n log log n)\n public static List sieveOfEratosthenes(int n) {\n boolean[] isPrime = new boolean[n+1];\n Arrays.fill(isPrime, true);\n for (int i = 2; i * i <= n; i++) {\n if (isPrime[i]) {\n for (int j = i + i; j <= n; j += i) {\n isPrime[j] = false;\n }\n }\n }\n List primes = new ArrayList<>();\n for (int i = 2; i <= n; i++) {\n if (isPrime[i]) {\n primes.add(i);\n }\n }\n return primes;\n }\n\n // Count divisor\n public static int countDivisor(int n) {\n int[] list = new int[n + 1];\n Arrays.fill(list, 0);\n int num = n;\n for (int i = 2; i <= n; i++) {\n while (num % i == 0) {\n list[i] = list[i] + 1;\n num /= i;\n }\n }\n int ans = 1;\n for (int i : list) {\n ans *= (i + 1);\n }\n return ans;\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": 9266, "cpu_time_ms": 302, "memory_kb": 58164}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s426600594", "group_id": "codeNet:p02762", "input_text": "import java.util.*;\nimport java.math.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int M = sc.nextInt();\n int K = sc.nextInt();\n int[] A = new int[M];\n int[] B = new int[M];\n for (int i = 0; i < M; i++) {\n A[i] = sc.nextInt();\n B[i] = sc.nextInt();\n }\n int[] C = new int[K];\n int[] D = new int[K];\n for (int i = 0; i < K; i++) {\n C[i] = sc.nextInt();\n D[i] = sc.nextInt();\n }\n sc.close();\n\n int[] fc = new int[N + 1];\n @SuppressWarnings(\"unchecked\")\n List[] g = new List[N + 1];\n int[] gn = new int[N + 1];\n for (int i = 0; i < M; i++) {\n int a = A[i];\n int b = B[i];\n fc[a]++;\n fc[b]++;\n\n if (gn[a] == 0 && gn[b] == 0) {\n List set = new ArrayList<>();\n set.add(a);\n set.add(b);\n gn[a] = a;\n gn[b] = a;\n g[a] = set;\n } else if (gn[a] == 0) {\n List set = g[gn[b]];\n set.add(a);\n gn[a] = gn[b];\n } else if (gn[b] == 0) {\n List set = g[gn[a]];\n set.add(b);\n gn[b] = gn[a];\n } else if (g[gn[a]] != g[gn[b]]) {\n List setL = g[gn[a]];\n List setS = g[gn[b]];\n int s = b;\n if (setL.size() < setS.size()) {\n List temp = setL;\n setL = setS;\n setS = temp;\n s = a;\n }\n setL.addAll(setS);\n g[gn[s]] = setL;\n }\n }\n\n int[] bc = new int[N + 1];\n for (int i = 0; i < K; i++) {\n int c = C[i];\n int d = D[i];\n if (g[gn[c]] == g[gn[d]]) {\n bc[c]++;\n bc[d]++;\n }\n }\n\n int[] ans = new int[N + 1];\n for (int i = 1; i < N + 1; i++)\n if (g[gn[i]] != null)\n ans[i] = g[gn[i]].size() - 1 - fc[i] - bc[i];\n\n StringBuilder buf = new StringBuilder();\n for (int i = 1; i < N + 1; i++)\n buf.append(ans[i]).append(' ');\n System.out.println(buf);\n }\n}", "language": "Java", "metadata": {"date": 1586150135, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02762.html", "problem_id": "p02762", "resource_group": "high_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/Java/s426600594.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s426600594", "user_id": "u086780113"}, "prompt_components": {"gold_output": "0 1 0 1\n", "input_to_evaluate": "import java.util.*;\nimport java.math.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int M = sc.nextInt();\n int K = sc.nextInt();\n int[] A = new int[M];\n int[] B = new int[M];\n for (int i = 0; i < M; i++) {\n A[i] = sc.nextInt();\n B[i] = sc.nextInt();\n }\n int[] C = new int[K];\n int[] D = new int[K];\n for (int i = 0; i < K; i++) {\n C[i] = sc.nextInt();\n D[i] = sc.nextInt();\n }\n sc.close();\n\n int[] fc = new int[N + 1];\n @SuppressWarnings(\"unchecked\")\n List[] g = new List[N + 1];\n int[] gn = new int[N + 1];\n for (int i = 0; i < M; i++) {\n int a = A[i];\n int b = B[i];\n fc[a]++;\n fc[b]++;\n\n if (gn[a] == 0 && gn[b] == 0) {\n List set = new ArrayList<>();\n set.add(a);\n set.add(b);\n gn[a] = a;\n gn[b] = a;\n g[a] = set;\n } else if (gn[a] == 0) {\n List set = g[gn[b]];\n set.add(a);\n gn[a] = gn[b];\n } else if (gn[b] == 0) {\n List set = g[gn[a]];\n set.add(b);\n gn[b] = gn[a];\n } else if (g[gn[a]] != g[gn[b]]) {\n List setL = g[gn[a]];\n List setS = g[gn[b]];\n int s = b;\n if (setL.size() < setS.size()) {\n List temp = setL;\n setL = setS;\n setS = temp;\n s = a;\n }\n setL.addAll(setS);\n g[gn[s]] = setL;\n }\n }\n\n int[] bc = new int[N + 1];\n for (int i = 0; i < K; i++) {\n int c = C[i];\n int d = D[i];\n if (g[gn[c]] == g[gn[d]]) {\n bc[c]++;\n bc[d]++;\n }\n }\n\n int[] ans = new int[N + 1];\n for (int i = 1; i < N + 1; i++)\n if (g[gn[i]] != null)\n ans[i] = g[gn[i]].size() - 1 - fc[i] - bc[i];\n\n StringBuilder buf = new StringBuilder();\n for (int i = 1; i < N + 1; i++)\n buf.append(ans[i]).append(' ');\n System.out.println(buf);\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": 2030, "cpu_time_ms": 2110, "memory_kb": 305304}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s443059327", "group_id": "codeNet:p02762", "input_text": "import java.util.*;\nimport java.math.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int M = sc.nextInt();\n int K = sc.nextInt();\n /*\n int[] A = new int[M];\n int[] B = new int[M];\n for (int i = 0; i < M; i++) {\n A[i] = sc.nextInt();\n B[i] = sc.nextInt();\n }\n int[] C = new int[K];\n int[] D = new int[K];\n for (int i = 0; i < K; i++) {\n C[i] = sc.nextInt();\n D[i] = sc.nextInt();\n }\n sc.close();\n */\n\n @SuppressWarnings(\"unchecked\")\n Set[] g = new Set[N + 1];\n int[] fc = new int[N + 1];\n for (int i = 0; i < M; i++) {\n int a = sc.nextInt();\n int b = sc.nextInt();\n if (g[a] == null && g[b] == null) {\n Set set = new HashSet<>();\n set.add(a);\n set.add(b);\n g[a] = set;\n g[b] = set;\n } else if (g[a] == null) {\n Set set = g[b];\n set.add(a);\n g[a] = set;\n } else if (g[b] == null) {\n Set set = g[a];\n set.add(b);\n g[b] = set;\n } else if (g[a] != g[b]) {\n Set setL = g[a];\n Set setS = g[b];\n if (setL.size() < setS.size()) {\n Set temp = setL;\n setL = setS;\n setS = temp;\n }\n setL.addAll(setS);\n for (int c : setS) g[c] = setL;\n }\n fc[a]++;\n fc[b]++;\n }\n\n int[] bc = new int[N + 1];\n for (int i = 0; i < K; i++) {\n int c = sc.nextInt();\n int d = sc.nextInt();\n if (g[c] == g[d]) {\n bc[c]++;\n bc[d]++;\n }\n }\n sc.close();\n\n int[] ans = new int[N + 1];\n for (int i = 1; i < N + 1; i++)\n if (g[i] != null)\n ans[i] = g[i].size() - 1 - fc[i] - bc[i];\n\n for (int i = 1; i < N + 1; i++)\n System.out.print(ans[i] + \" \");\n System.out.println();\n }\n}", "language": "Java", "metadata": {"date": 1586146450, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02762.html", "problem_id": "p02762", "resource_group": "high_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/Java/s443059327.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s443059327", "user_id": "u086780113"}, "prompt_components": {"gold_output": "0 1 0 1\n", "input_to_evaluate": "import java.util.*;\nimport java.math.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int M = sc.nextInt();\n int K = sc.nextInt();\n /*\n int[] A = new int[M];\n int[] B = new int[M];\n for (int i = 0; i < M; i++) {\n A[i] = sc.nextInt();\n B[i] = sc.nextInt();\n }\n int[] C = new int[K];\n int[] D = new int[K];\n for (int i = 0; i < K; i++) {\n C[i] = sc.nextInt();\n D[i] = sc.nextInt();\n }\n sc.close();\n */\n\n @SuppressWarnings(\"unchecked\")\n Set[] g = new Set[N + 1];\n int[] fc = new int[N + 1];\n for (int i = 0; i < M; i++) {\n int a = sc.nextInt();\n int b = sc.nextInt();\n if (g[a] == null && g[b] == null) {\n Set set = new HashSet<>();\n set.add(a);\n set.add(b);\n g[a] = set;\n g[b] = set;\n } else if (g[a] == null) {\n Set set = g[b];\n set.add(a);\n g[a] = set;\n } else if (g[b] == null) {\n Set set = g[a];\n set.add(b);\n g[b] = set;\n } else if (g[a] != g[b]) {\n Set setL = g[a];\n Set setS = g[b];\n if (setL.size() < setS.size()) {\n Set temp = setL;\n setL = setS;\n setS = temp;\n }\n setL.addAll(setS);\n for (int c : setS) g[c] = setL;\n }\n fc[a]++;\n fc[b]++;\n }\n\n int[] bc = new int[N + 1];\n for (int i = 0; i < K; i++) {\n int c = sc.nextInt();\n int d = sc.nextInt();\n if (g[c] == g[d]) {\n bc[c]++;\n bc[d]++;\n }\n }\n sc.close();\n\n int[] ans = new int[N + 1];\n for (int i = 1; i < N + 1; i++)\n if (g[i] != null)\n ans[i] = g[i].size() - 1 - fc[i] - bc[i];\n\n for (int i = 1; i < N + 1; i++)\n System.out.print(ans[i] + \" \");\n System.out.println();\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAn SNS has N users - User 1, User 2, \\cdots, User N.\n\nBetween these N users, there are some relationships - M friendships and K blockships.\n\nFor each i = 1, 2, \\cdots, M, there is a bidirectional friendship between User A_i and User B_i.\n\nFor each i = 1, 2, \\cdots, K, there is a bidirectional blockship between User C_i and User D_i.\n\nWe define User a to be a friend candidate for User b when all of the following four conditions are satisfied:\n\na \\neq b.\n\nThere is not a friendship between User a and User b.\n\nThere is not a blockship between User a and User b.\n\nThere exists a sequence c_0, c_1, c_2, \\cdots, c_L consisting of integers between 1 and N (inclusive) such that c_0 = a, c_L = b, and there is a friendship between User c_i and c_{i+1} for each i = 0, 1, \\cdots, L - 1.\n\nFor each user i = 1, 2, ... N, how many friend candidates does it have?\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10^5\n\n0 \\leq M \\leq 10^5\n\n0 \\leq K \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n1 \\leq C_i, D_i \\leq N\n\nC_i \\neq D_i\n\n(A_i, B_i) \\neq (A_j, B_j) (i \\neq j)\n\n(A_i, B_i) \\neq (B_j, A_j)\n\n(C_i, D_i) \\neq (C_j, D_j) (i \\neq j)\n\n(C_i, D_i) \\neq (D_j, C_j)\n\n(A_i, B_i) \\neq (C_j, D_j)\n\n(A_i, B_i) \\neq (D_j, C_j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\nA_1 B_1\n\\vdots\nA_M B_M\nC_1 D_1\n\\vdots\nC_K D_K\n\nOutput\n\nPrint the answers in order, with space in between.\n\nSample Input 1\n\n4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n\nSample Output 1\n\n0 1 0 1\n\nThere is a friendship between User 2 and 3, and between 3 and 4. Also, there is no friendship or blockship between User 2 and 4. Thus, User 4 is a friend candidate for User 2.\n\nHowever, neither User 1 or 3 is a friend candidate for User 2, so User 2 has one friend candidate.\n\nSample Input 2\n\n5 10 0\n1 2\n1 3\n1 4\n1 5\n3 2\n2 4\n2 5\n4 3\n5 3\n4 5\n\nSample Output 2\n\n0 0 0 0 0\n\nEveryone is a friend of everyone else and has no friend candidate.\n\nSample Input 3\n\n10 9 3\n10 1\n6 7\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 6\n7 5\n3 1\n\nSample Output 3\n\n1 3 5 4 3 3 3 3 1 0", "sample_input": "4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n"}, "reference_outputs": ["0 1 0 1\n"], "source_document_id": "p02762", "source_text": "Score : 400 points\n\nProblem Statement\n\nAn SNS has N users - User 1, User 2, \\cdots, User N.\n\nBetween these N users, there are some relationships - M friendships and K blockships.\n\nFor each i = 1, 2, \\cdots, M, there is a bidirectional friendship between User A_i and User B_i.\n\nFor each i = 1, 2, \\cdots, K, there is a bidirectional blockship between User C_i and User D_i.\n\nWe define User a to be a friend candidate for User b when all of the following four conditions are satisfied:\n\na \\neq b.\n\nThere is not a friendship between User a and User b.\n\nThere is not a blockship between User a and User b.\n\nThere exists a sequence c_0, c_1, c_2, \\cdots, c_L consisting of integers between 1 and N (inclusive) such that c_0 = a, c_L = b, and there is a friendship between User c_i and c_{i+1} for each i = 0, 1, \\cdots, L - 1.\n\nFor each user i = 1, 2, ... N, how many friend candidates does it have?\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10^5\n\n0 \\leq M \\leq 10^5\n\n0 \\leq K \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n1 \\leq C_i, D_i \\leq N\n\nC_i \\neq D_i\n\n(A_i, B_i) \\neq (A_j, B_j) (i \\neq j)\n\n(A_i, B_i) \\neq (B_j, A_j)\n\n(C_i, D_i) \\neq (C_j, D_j) (i \\neq j)\n\n(C_i, D_i) \\neq (D_j, C_j)\n\n(A_i, B_i) \\neq (C_j, D_j)\n\n(A_i, B_i) \\neq (D_j, C_j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\nA_1 B_1\n\\vdots\nA_M B_M\nC_1 D_1\n\\vdots\nC_K D_K\n\nOutput\n\nPrint the answers in order, with space in between.\n\nSample Input 1\n\n4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n\nSample Output 1\n\n0 1 0 1\n\nThere is a friendship between User 2 and 3, and between 3 and 4. Also, there is no friendship or blockship between User 2 and 4. Thus, User 4 is a friend candidate for User 2.\n\nHowever, neither User 1 or 3 is a friend candidate for User 2, so User 2 has one friend candidate.\n\nSample Input 2\n\n5 10 0\n1 2\n1 3\n1 4\n1 5\n3 2\n2 4\n2 5\n4 3\n5 3\n4 5\n\nSample Output 2\n\n0 0 0 0 0\n\nEveryone is a friend of everyone else and has no friend candidate.\n\nSample Input 3\n\n10 9 3\n10 1\n6 7\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 6\n7 5\n3 1\n\nSample Output 3\n\n1 3 5 4 3 3 3 3 1 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1925, "cpu_time_ms": 1193, "memory_kb": 141648}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s417482477", "group_id": "codeNet:p02762", "input_text": "import java.util.ArrayList;\nimport java.util.HashSet;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint m = sc.nextInt();\n\t\tint k = sc.nextInt();\n\n\t\tArrayList setList = new ArrayList();\n\t\tint[] counts = new int[n];\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tint a = sc.nextInt();\n\t\t\tint b = sc.nextInt();\n\t\t\tint index1 = getSetIndex(setList, a);\n\t\t\tint index2 = getSetIndex(setList, b);\n\t\t\tif (index1 == -1 && index2 == -1) {\n\t\t\t\tHashSet set = new HashSet();\n\t\t\t\tset.add(a);\n\t\t\t\tset.add(b);\n\t\t\t\tsetList.add(set);\n\t\t\t} else if (index1 == -1) {\n\t\t\t\tsetList.get(index2).add(a);\n\t\t\t} else if (index2 == -1) {\n\t\t\t\tsetList.get(index1).add(b);\n\t\t\t} else if (index1 != index2) {\n\t\t\t\tfor (Object x : setList.get(index2)) {\n\t\t\t\t\tsetList.get(index1).add(x);\n\t\t\t\t}\n\t\t\t\tsetList.remove(index2);\n\t\t\t}\n\t\t\tcounts[a - 1]++;\n\t\t\tcounts[b - 1]++;\n\t\t}\n\n\t\tfor (int i = 0; i < k; i++) {\n\t\t\tint c = sc.nextInt();\n\t\t\tint d = sc.nextInt();\n\t\t\tint index1 = getSetIndex(setList, c);\n\t\t\tint index2 = getSetIndex(setList, d);\n\t\t\tif (setList.get(index1).contains(d)) {\n\t\t\t\tcounts[c - 1]++;\n\t\t\t}\n\t\t\tif (setList.get(index2).contains(c)) {\n\t\t\t\tcounts[d - 1]++;\n\t\t\t}\n\t\t}\n\t\tsc.close();\n\n\t\tStringBuilder sb = new StringBuilder();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tint index = getSetIndex(setList, i + 1);\n\t\t\tint result = index == -1 ? 0 : setList.get(index).size() - 1 - counts[i];\n\t\t\tsb.append(i == 0 ? \"\" : \" \");\n\t\t\tsb.append(result);\n\t\t}\n\t\tSystem.out.print(sb.toString());\n\t}\n\n\tprivate static int getSetIndex(ArrayList setList, int n) {\n\t\tfor (int i = 0; i < setList.size(); i++) {\n\t\t\tif (setList.get(i).contains(n)) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\n\t\treturn -1;\n\t}\n}\n", "language": "Java", "metadata": {"date": 1584852557, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02762.html", "problem_id": "p02762", "resource_group": "high_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/Java/s417482477.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s417482477", "user_id": "u361173382"}, "prompt_components": {"gold_output": "0 1 0 1\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.HashSet;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint m = sc.nextInt();\n\t\tint k = sc.nextInt();\n\n\t\tArrayList setList = new ArrayList();\n\t\tint[] counts = new int[n];\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tint a = sc.nextInt();\n\t\t\tint b = sc.nextInt();\n\t\t\tint index1 = getSetIndex(setList, a);\n\t\t\tint index2 = getSetIndex(setList, b);\n\t\t\tif (index1 == -1 && index2 == -1) {\n\t\t\t\tHashSet set = new HashSet();\n\t\t\t\tset.add(a);\n\t\t\t\tset.add(b);\n\t\t\t\tsetList.add(set);\n\t\t\t} else if (index1 == -1) {\n\t\t\t\tsetList.get(index2).add(a);\n\t\t\t} else if (index2 == -1) {\n\t\t\t\tsetList.get(index1).add(b);\n\t\t\t} else if (index1 != index2) {\n\t\t\t\tfor (Object x : setList.get(index2)) {\n\t\t\t\t\tsetList.get(index1).add(x);\n\t\t\t\t}\n\t\t\t\tsetList.remove(index2);\n\t\t\t}\n\t\t\tcounts[a - 1]++;\n\t\t\tcounts[b - 1]++;\n\t\t}\n\n\t\tfor (int i = 0; i < k; i++) {\n\t\t\tint c = sc.nextInt();\n\t\t\tint d = sc.nextInt();\n\t\t\tint index1 = getSetIndex(setList, c);\n\t\t\tint index2 = getSetIndex(setList, d);\n\t\t\tif (setList.get(index1).contains(d)) {\n\t\t\t\tcounts[c - 1]++;\n\t\t\t}\n\t\t\tif (setList.get(index2).contains(c)) {\n\t\t\t\tcounts[d - 1]++;\n\t\t\t}\n\t\t}\n\t\tsc.close();\n\n\t\tStringBuilder sb = new StringBuilder();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tint index = getSetIndex(setList, i + 1);\n\t\t\tint result = index == -1 ? 0 : setList.get(index).size() - 1 - counts[i];\n\t\t\tsb.append(i == 0 ? \"\" : \" \");\n\t\t\tsb.append(result);\n\t\t}\n\t\tSystem.out.print(sb.toString());\n\t}\n\n\tprivate static int getSetIndex(ArrayList setList, int n) {\n\t\tfor (int i = 0; i < setList.size(); i++) {\n\t\t\tif (setList.get(i).contains(n)) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\n\t\treturn -1;\n\t}\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": 1754, "cpu_time_ms": 2110, "memory_kb": 354064}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s506378830", "group_id": "codeNet:p02765", "input_text": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] c) {\n Scanner scan = new Scanner(System.in);\n String[] t = scan.nextLine().split(\"\\\\s\");\n int n = Integer.valueOf(t[0]);\n int r = Integer.valueOf(t[1]);\n\n if (n >= 10) {\n System.out.println(r);\n } else {\n int num = 100 * (10 - n);\n System.out.println(r + num);\n }\n }\n}", "language": "Java", "metadata": {"date": 1582853331, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02765.html", "problem_id": "p02765", "resource_group": "high_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/Java/s506378830.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s506378830", "user_id": "u294547658"}, "prompt_components": {"gold_output": "3719\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] c) {\n Scanner scan = new Scanner(System.in);\n String[] t = scan.nextLine().split(\"\\\\s\");\n int n = Integer.valueOf(t[0]);\n int r = Integer.valueOf(t[1]);\n\n if (n >= 10) {\n System.out.println(r);\n } else {\n int num = 100 * (10 - n);\n System.out.println(r + num);\n }\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "sample_input": "2 2919\n"}, "reference_outputs": ["3719\n"], "source_document_id": "p02765", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 91, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s412024406", "group_id": "codeNet:p02765", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.StringTokenizer;\n\npublic class Main {\n\tstatic class FastReader{\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\t\tpublic FastReader() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\t\tpublic String next() {\n\t\t\twhile(st==null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\tcatch(IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\t}\n\tpublic static void main(String[] args) {\n\t\tFastReader ob = new FastReader();\n\t\tint n = ob.nextInt();\n\t\tSystem.out.println((1000-n)/100);\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1582824645, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02765.html", "problem_id": "p02765", "resource_group": "high_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/Java/s412024406.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s412024406", "user_id": "u546418037"}, "prompt_components": {"gold_output": "3719\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.StringTokenizer;\n\npublic class Main {\n\tstatic class FastReader{\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\t\tpublic FastReader() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\t\tpublic String next() {\n\t\t\twhile(st==null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\tcatch(IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\t}\n\tpublic static void main(String[] args) {\n\t\tFastReader ob = new FastReader();\n\t\tint n = ob.nextInt();\n\t\tSystem.out.println((1000-n)/100);\n\t}\n\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "sample_input": "2 2919\n"}, "reference_outputs": ["3719\n"], "source_document_id": "p02765", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 869, "cpu_time_ms": 69, "memory_kb": 21076}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s079707983", "group_id": "codeNet:p02765", "input_text": "import java.util.Scanner;\npublic class Main{\n public static void main(String args[]){\n int n,r,ans;\n Scanner reader = new Scanner(System.in);\n n=reader.nextInt();\n r=reader.nextInt();\n if(n>=10){\n ans=r;\n }\n else{\n ans=100*(10-n)+r;\n }\n System.out.println(ans);\n }\n}", "language": "Java", "metadata": {"date": 1582587569, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02765.html", "problem_id": "p02765", "resource_group": "high_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/Java/s079707983.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s079707983", "user_id": "u250046233"}, "prompt_components": {"gold_output": "3719\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main{\n public static void main(String args[]){\n int n,r,ans;\n Scanner reader = new Scanner(System.in);\n n=reader.nextInt();\n r=reader.nextInt();\n if(n>=10){\n ans=r;\n }\n else{\n ans=100*(10-n)+r;\n }\n System.out.println(ans);\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": 357, "cpu_time_ms": 94, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s237668601", "group_id": "codeNet:p02765", "input_text": "import java.util.*;\nimport java.io.*;\n\n@SuppressWarnings(\"unused\")\npublic class Main {\n FastScanner in;\n PrintWriter out;\n int MOD = (int)1e9+7;\n long ceil(long a, long b){return (a + b - 1) / b;}\n long gcd(long a, long b){return b == 0 ? a : gcd(b, a % b);}\n long lcm(long a, long b){return a / gcd(a, b) * b;}\n \n void solve(){\n int N = in.nextInt(), R = in.nextInt();\n if(N < 10) R += 100 * (10 - N);\n out.println(R);\n }\n \n public static void main(String[] args) {\n new Main().m();\n }\n \n private void m() {\n in = new FastScanner(System.in);\n out = new PrintWriter(System.out);\n /*\n try {\n String path = \"input.txt\";\n out = new PrintWriter(new BufferedWriter(new FileWriter(new File(path))));\n }catch (IOException e){\n e.printStackTrace();\n }\n */\n solve();\n out.flush();\n in.close();\n out.close();\n }\n \n static class FastScanner {\n private Reader input;\n \n public FastScanner() {this(System.in);}\n public FastScanner(InputStream stream) {this.input = new BufferedReader(new InputStreamReader(stream));}\n public void close() {\n try {\n this.input.close();\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n \n public int nextInt() {return (int) nextLong();}\n \n public long nextLong() {\n try {\n int sign = 1;\n int b = input.read();\n while ((b < '0' || '9' < b) && b != '-' && b != '+') {\n b = input.read();\n }\n if (b == '-') {\n sign = -1;\n b = input.read();\n } else if (b == '+') {\n b = input.read();\n }\n long ret = b - '0';\n while (true) {\n b = input.read();\n if (b < '0' || '9' < b) return ret * sign;\n ret *= 10;\n ret += b - '0';\n }\n } catch (IOException e) {\n e.printStackTrace();\n return -1;\n }\n }\n \n public double nextDouble() {\n try {\n double sign = 1;\n int b = input.read();\n while ((b < '0' || '9' < b) && b != '-' && b != '+') {\n b = input.read();\n }\n if (b == '-') {\n sign = -1;\n b = input.read();\n } else if (b == '+') {\n b = input.read();\n }\n double ret = b - '0';\n while (true) {\n b = input.read();\n if (b < '0' || '9' < b) break;\n ret *= 10;\n ret += b - '0';\n }\n if (b != '.') return sign * ret;\n double div = 1;\n b = input.read();\n while ('0' <= b && b <= '9') {\n ret *= 10;\n ret += b - '0';\n div *= 10;\n b = input.read();\n }\n return sign * ret / div;\n } catch (IOException e) {\n e.printStackTrace();\n return Double.NaN;\n }\n }\n \n public char nextChar() {\n try {\n int b = input.read();\n while (Character.isWhitespace(b)) {\n b = input.read();\n }\n return (char) b;\n } catch (IOException e) {\n e.printStackTrace();\n return 0;\n }\n }\n \n public String nextStr() {\n try {\n StringBuilder sb = new StringBuilder();\n int b = input.read();\n while (Character.isWhitespace(b)) {\n b = input.read();\n }\n while (b != -1 && !Character.isWhitespace(b)) {\n sb.append((char) b);\n b = input.read();\n }\n return sb.toString();\n } catch (IOException e) {\n e.printStackTrace();\n return \"\";\n }\n }\n \n public String nextLine() {\n try {\n StringBuilder sb = new StringBuilder();\n int b = input.read();\n while (b != -1 && b != '\\n') {\n sb.append((char) b);\n b = input.read();\n }\n return sb.toString();\n } catch (IOException e) {\n e.printStackTrace();\n return \"\";\n }\n }\n \n public int[] nextIntArray(int n) {\n int[] res = new int[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextInt();\n }\n return res;\n }\n \n public int[] nextIntArrayDec(int n) {\n int[] res = new int[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextInt() - 1;\n }\n return res;\n }\n \n public int[] nextIntArray1Index(int n) {\n int[] res = new int[n + 1];\n for (int i = 0; i < n; i++) {\n res[i + 1] = nextInt();\n }\n return res;\n }\n \n public long[] nextLongArray(int n) {\n long[] res = new long[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextLong();\n }\n return res;\n }\n \n public long[] nextLongArrayDec(int n) {\n long[] res = new long[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextLong() - 1;\n }\n return res;\n }\n \n public long[] nextLongArray1Index(int n) {\n long[] res = new long[n + 1];\n for (int i = 0; i < n; i++) {\n res[i + 1] = nextLong();\n }\n return res;\n }\n \n public double[] nextDoubleArray(int n) {\n double[] res = new double[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextDouble();\n }\n return res;\n }\n }\n}", "language": "Java", "metadata": {"date": 1582457439, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02765.html", "problem_id": "p02765", "resource_group": "high_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/Java/s237668601.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s237668601", "user_id": "u234826697"}, "prompt_components": {"gold_output": "3719\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\n\n@SuppressWarnings(\"unused\")\npublic class Main {\n FastScanner in;\n PrintWriter out;\n int MOD = (int)1e9+7;\n long ceil(long a, long b){return (a + b - 1) / b;}\n long gcd(long a, long b){return b == 0 ? a : gcd(b, a % b);}\n long lcm(long a, long b){return a / gcd(a, b) * b;}\n \n void solve(){\n int N = in.nextInt(), R = in.nextInt();\n if(N < 10) R += 100 * (10 - N);\n out.println(R);\n }\n \n public static void main(String[] args) {\n new Main().m();\n }\n \n private void m() {\n in = new FastScanner(System.in);\n out = new PrintWriter(System.out);\n /*\n try {\n String path = \"input.txt\";\n out = new PrintWriter(new BufferedWriter(new FileWriter(new File(path))));\n }catch (IOException e){\n e.printStackTrace();\n }\n */\n solve();\n out.flush();\n in.close();\n out.close();\n }\n \n static class FastScanner {\n private Reader input;\n \n public FastScanner() {this(System.in);}\n public FastScanner(InputStream stream) {this.input = new BufferedReader(new InputStreamReader(stream));}\n public void close() {\n try {\n this.input.close();\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n \n public int nextInt() {return (int) nextLong();}\n \n public long nextLong() {\n try {\n int sign = 1;\n int b = input.read();\n while ((b < '0' || '9' < b) && b != '-' && b != '+') {\n b = input.read();\n }\n if (b == '-') {\n sign = -1;\n b = input.read();\n } else if (b == '+') {\n b = input.read();\n }\n long ret = b - '0';\n while (true) {\n b = input.read();\n if (b < '0' || '9' < b) return ret * sign;\n ret *= 10;\n ret += b - '0';\n }\n } catch (IOException e) {\n e.printStackTrace();\n return -1;\n }\n }\n \n public double nextDouble() {\n try {\n double sign = 1;\n int b = input.read();\n while ((b < '0' || '9' < b) && b != '-' && b != '+') {\n b = input.read();\n }\n if (b == '-') {\n sign = -1;\n b = input.read();\n } else if (b == '+') {\n b = input.read();\n }\n double ret = b - '0';\n while (true) {\n b = input.read();\n if (b < '0' || '9' < b) break;\n ret *= 10;\n ret += b - '0';\n }\n if (b != '.') return sign * ret;\n double div = 1;\n b = input.read();\n while ('0' <= b && b <= '9') {\n ret *= 10;\n ret += b - '0';\n div *= 10;\n b = input.read();\n }\n return sign * ret / div;\n } catch (IOException e) {\n e.printStackTrace();\n return Double.NaN;\n }\n }\n \n public char nextChar() {\n try {\n int b = input.read();\n while (Character.isWhitespace(b)) {\n b = input.read();\n }\n return (char) b;\n } catch (IOException e) {\n e.printStackTrace();\n return 0;\n }\n }\n \n public String nextStr() {\n try {\n StringBuilder sb = new StringBuilder();\n int b = input.read();\n while (Character.isWhitespace(b)) {\n b = input.read();\n }\n while (b != -1 && !Character.isWhitespace(b)) {\n sb.append((char) b);\n b = input.read();\n }\n return sb.toString();\n } catch (IOException e) {\n e.printStackTrace();\n return \"\";\n }\n }\n \n public String nextLine() {\n try {\n StringBuilder sb = new StringBuilder();\n int b = input.read();\n while (b != -1 && b != '\\n') {\n sb.append((char) b);\n b = input.read();\n }\n return sb.toString();\n } catch (IOException e) {\n e.printStackTrace();\n return \"\";\n }\n }\n \n public int[] nextIntArray(int n) {\n int[] res = new int[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextInt();\n }\n return res;\n }\n \n public int[] nextIntArrayDec(int n) {\n int[] res = new int[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextInt() - 1;\n }\n return res;\n }\n \n public int[] nextIntArray1Index(int n) {\n int[] res = new int[n + 1];\n for (int i = 0; i < n; i++) {\n res[i + 1] = nextInt();\n }\n return res;\n }\n \n public long[] nextLongArray(int n) {\n long[] res = new long[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextLong();\n }\n return res;\n }\n \n public long[] nextLongArrayDec(int n) {\n long[] res = new long[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextLong() - 1;\n }\n return res;\n }\n \n public long[] nextLongArray1Index(int n) {\n long[] res = new long[n + 1];\n for (int i = 0; i < n; i++) {\n res[i + 1] = nextLong();\n }\n return res;\n }\n \n public double[] nextDoubleArray(int n) {\n double[] res = new double[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextDouble();\n }\n return res;\n }\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "sample_input": "2 2919\n"}, "reference_outputs": ["3719\n"], "source_document_id": "p02765", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6484, "cpu_time_ms": 71, "memory_kb": 21076}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s285884484", "group_id": "codeNet:p02766", "input_text": "import java.util.Scanner;\nimport java.util.Arrays;\nclass Main{\n public static void main(String[] args){\n Scanner scan = new Scanner(System.in);\n int N = scan.nextInt();\n int K = scan.nextInt();\n int count = 0;\n while(N >= K){\n N = N / K;\n count += 1;\n }\n System.out.println(count + 1);\n }\n}", "language": "Java", "metadata": {"date": 1589252493, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02766.html", "problem_id": "p02766", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02766/input.txt", "sample_output_relpath": "derived/input_output/data/p02766/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02766/Java/s285884484.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s285884484", "user_id": "u902482201"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.Scanner;\nimport java.util.Arrays;\nclass Main{\n public static void main(String[] args){\n Scanner scan = new Scanner(System.in);\n int N = scan.nextInt();\n int K = scan.nextInt();\n int count = 0;\n while(N >= K){\n N = N / K;\n count += 1;\n }\n System.out.println(count + 1);\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of digits that N has in base K.\n\nNotes\n\nFor information on base-K representation, see Positional notation - Wikipedia.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^9\n\n2 \\leq K \\leq 10\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of digits that N has in base K.\n\nSample Input 1\n\n11 2\n\nSample Output 1\n\n4\n\nIn binary, 11 is represented as 1011.\n\nSample Input 2\n\n1010101 10\n\nSample Output 2\n\n7\n\nSample Input 3\n\n314159265 3\n\nSample Output 3\n\n18", "sample_input": "11 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02766", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of digits that N has in base K.\n\nNotes\n\nFor information on base-K representation, see Positional notation - Wikipedia.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^9\n\n2 \\leq K \\leq 10\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of digits that N has in base K.\n\nSample Input 1\n\n11 2\n\nSample Output 1\n\n4\n\nIn binary, 11 is represented as 1011.\n\nSample Input 2\n\n1010101 10\n\nSample Output 2\n\n7\n\nSample Input 3\n\n314159265 3\n\nSample Output 3\n\n18", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 323, "cpu_time_ms": 114, "memory_kb": 23892}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s214164003", "group_id": "codeNet:p02766", "input_text": "import java.util.*;\npublic class Main{\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n long n = sc.nextInt();\n int k = sc.nextInt();\n long a = 0;\n int count = 0;\n for(int i=0 ; i0){\n count++;\n }else{\n count++;\n break;\n }\n }\n if(count==1){\n System.out.println(count);\n }else{\n System.out.println(count-1);\n }\n\n }\n}\n", "language": "Java", "metadata": {"date": 1582426611, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02766.html", "problem_id": "p02766", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02766/input.txt", "sample_output_relpath": "derived/input_output/data/p02766/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02766/Java/s214164003.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s214164003", "user_id": "u351303380"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*;\npublic class Main{\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n long n = sc.nextInt();\n int k = sc.nextInt();\n long a = 0;\n int count = 0;\n for(int i=0 ; i0){\n count++;\n }else{\n count++;\n break;\n }\n }\n if(count==1){\n System.out.println(count);\n }else{\n System.out.println(count-1);\n }\n\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of digits that N has in base K.\n\nNotes\n\nFor information on base-K representation, see Positional notation - Wikipedia.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^9\n\n2 \\leq K \\leq 10\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of digits that N has in base K.\n\nSample Input 1\n\n11 2\n\nSample Output 1\n\n4\n\nIn binary, 11 is represented as 1011.\n\nSample Input 2\n\n1010101 10\n\nSample Output 2\n\n7\n\nSample Input 3\n\n314159265 3\n\nSample Output 3\n\n18", "sample_input": "11 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02766", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of digits that N has in base K.\n\nNotes\n\nFor information on base-K representation, see Positional notation - Wikipedia.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^9\n\n2 \\leq K \\leq 10\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of digits that N has in base K.\n\nSample Input 1\n\n11 2\n\nSample Output 1\n\n4\n\nIn binary, 11 is represented as 1011.\n\nSample Input 2\n\n1010101 10\n\nSample Output 2\n\n7\n\nSample Input 3\n\n314159265 3\n\nSample Output 3\n\n18", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 475, "cpu_time_ms": 93, "memory_kb": 21460}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s480026599", "group_id": "codeNet:p02766", "input_text": "import java.util.ArrayList;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tint n = 0;\n\t\tint k = 0;\n\t\tArrayList anser = new ArrayList<>();\n\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tn = scan.nextInt();\n\t\tk = scan.nextInt();\n\n\t\twhile(n>=k) {\n\t\t\tanser.add(n%k);\n\t\t\tn=n/k;\n\t\t}\n\n\t\tif(n anser = new ArrayList<>();\n\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tn = scan.nextInt();\n\t\tk = scan.nextInt();\n\n\t\twhile(n>=k) {\n\t\t\tanser.add(n%k);\n\t\t\tn=n/k;\n\t\t}\n\n\t\tif(n aList = Arrays.stream(scan.nextLine().split(\" \"))\n .map(Integer::parseInt).collect(Collectors.toList());\n\n AtomicBoolean bool = new AtomicBoolean(false);\n aList.forEach(a -> {\n if(a % 2 == 0) {\n if(a % 3 != 0 && a % 5 != 0) {\n System.out.println(\"DENIED\");\n System.exit(0);\n }\n }\n });\n System.out.println(\"APPROVED\");\n }\n}\n", "language": "Java", "metadata": {"date": 1581884188, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02772.html", "problem_id": "p02772", "resource_group": "high_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/Java/s056982227.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s056982227", "user_id": "u712913216"}, "prompt_components": {"gold_output": "APPROVED\n", "input_to_evaluate": "import java.util.Arrays;\nimport java.util.List;\nimport java.util.Scanner;\nimport java.util.concurrent.atomic.AtomicBoolean;\nimport java.util.stream.Collectors;\n\npublic class Main {\n public static void main(String[] arg) {\n Scanner scan = new Scanner(System.in);\n int n = Integer.parseInt(scan.next());\n scan.nextLine();\n List aList = Arrays.stream(scan.nextLine().split(\" \"))\n .map(Integer::parseInt).collect(Collectors.toList());\n\n AtomicBoolean bool = new AtomicBoolean(false);\n aList.forEach(a -> {\n if(a % 2 == 0) {\n if(a % 3 != 0 && a % 5 != 0) {\n System.out.println(\"DENIED\");\n System.exit(0);\n }\n }\n });\n System.out.println(\"APPROVED\");\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": 825, "cpu_time_ms": 258, "memory_kb": 28884}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s687052590", "group_id": "codeNet:p02772", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tboolean approved = true;\n\t\tfor(int i = 0; i < n ; i++) {\n\t\t\tint val = sc.nextInt();\n\t\t\tif(val % 2 == 0) {\n\t\t\t\tif(val % 3 == 0 || val % 5 == 0) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}else {\n\t\t\t\t\tapproved = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tsc.close();\n\t\tif(approved) {\n\t\t\tSystem.out.println(\"APPROVED\");\n\t\t}else {\n\t\t\tSystem.out.println(\"DENIED\");\n\t\t}\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1581883781, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02772.html", "problem_id": "p02772", "resource_group": "high_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/Java/s687052590.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s687052590", "user_id": "u903557324"}, "prompt_components": {"gold_output": "APPROVED\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tboolean approved = true;\n\t\tfor(int i = 0; i < n ; i++) {\n\t\t\tint val = sc.nextInt();\n\t\t\tif(val % 2 == 0) {\n\t\t\t\tif(val % 3 == 0 || val % 5 == 0) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}else {\n\t\t\t\t\tapproved = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tsc.close();\n\t\tif(approved) {\n\t\t\tSystem.out.println(\"APPROVED\");\n\t\t}else {\n\t\t\tSystem.out.println(\"DENIED\");\n\t\t}\n\t}\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": 497, "cpu_time_ms": 113, "memory_kb": 22868}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s034781402", "group_id": "codeNet:p02772", "input_text": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n new Main().run();\n }\n\n private void run() {\n Scanner scanner = new Scanner(System.in);\n int N = scanner.nextInt();\n int[] A = new int[N];\n boolean isOk = true;\n for(int i = 0; i < N; i++) {\n A[i] = scanner.nextInt();\n if(A[i] % 2 == 0) {\n if(!(A[i] % 6 == 0 || A[i] % 10 == 0)) {\n isOk = false;\n }\n }\n }\n if(isOk){\n System.out.println(\"APPROVED\");\n }else{\n System.out.println(\"DENIED\");\n }\n return;\n }\n}\n", "language": "Java", "metadata": {"date": 1581883780, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02772.html", "problem_id": "p02772", "resource_group": "high_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/Java/s034781402.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s034781402", "user_id": "u867534917"}, "prompt_components": {"gold_output": "APPROVED\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n new Main().run();\n }\n\n private void run() {\n Scanner scanner = new Scanner(System.in);\n int N = scanner.nextInt();\n int[] A = new int[N];\n boolean isOk = true;\n for(int i = 0; i < N; i++) {\n A[i] = scanner.nextInt();\n if(A[i] % 2 == 0) {\n if(!(A[i] % 6 == 0 || A[i] % 10 == 0)) {\n isOk = false;\n }\n }\n }\n if(isOk){\n System.out.println(\"APPROVED\");\n }else{\n System.out.println(\"DENIED\");\n }\n return;\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": 688, "cpu_time_ms": 112, "memory_kb": 24148}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s643091507", "group_id": "codeNet:p02775", "input_text": "import java.util.*;\nimport java.io.PrintWriter;\npublic class Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc=new Scanner(System.in);\n\t\tString s=sc.next();\n\t\tlong[][] dp=new long[s.length()+1][2];\n\t\tdp[s.length()][1]=11;\n\t\tfor(int i=s.length()-1; i>=0; i--){\n\t\t\t\n\t\t\t\tdp[i][0]=Math.min(dp[i+1][0]+(s.charAt(i)-'0'),dp[i+1][1]+(s.charAt(i)-'0'));\n\t\t\t\tdp[i][1]=Math.min(dp[i+1][0]+11-(s.charAt(i)-'0'),dp[i+1][1]+9-(s.charAt(i)-'0'));\n\t\t\t\n\t\t}\n\t\tSystem.out.println(Math.min(dp[0][0],dp[0][1]));\n\t}\n}\n", "language": "Java", "metadata": {"date": 1581945618, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02775.html", "problem_id": "p02775", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02775/input.txt", "sample_output_relpath": "derived/input_output/data/p02775/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02775/Java/s643091507.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s643091507", "user_id": "u504228740"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.*;\nimport java.io.PrintWriter;\npublic class Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc=new Scanner(System.in);\n\t\tString s=sc.next();\n\t\tlong[][] dp=new long[s.length()+1][2];\n\t\tdp[s.length()][1]=11;\n\t\tfor(int i=s.length()-1; i>=0; i--){\n\t\t\t\n\t\t\t\tdp[i][0]=Math.min(dp[i+1][0]+(s.charAt(i)-'0'),dp[i+1][1]+(s.charAt(i)-'0'));\n\t\t\t\tdp[i][1]=Math.min(dp[i+1][0]+11-(s.charAt(i)-'0'),dp[i+1][1]+9-(s.charAt(i)-'0'));\n\t\t\t\n\t\t}\n\t\tSystem.out.println(Math.min(dp[0][0],dp[0][1]));\n\t}\n}\n", "problem_context": "Score: 500 points\n\nProblem Statement\n\nIn the Kingdom of AtCoder, only banknotes are used as currency. There are 10^{100}+1 kinds of banknotes, with the values of 1, 10, 10^2, 10^3, \\dots, 10^{(10^{100})}. You have come shopping at a mall and are now buying a takoyaki machine with a value of N. (Takoyaki is the name of a Japanese snack.)\n\nTo make the payment, you will choose some amount of money which is at least N and give it to the clerk. Then, the clerk gives you back the change, which is the amount of money you give minus N.\n\nWhat will be the minimum possible number of total banknotes used by you and the clerk, when both choose the combination of banknotes to minimize this count?\n\nAssume that you have sufficient numbers of banknotes, and so does the clerk.\n\nConstraints\n\nN is an integer between 1 and 10^{1,000,000} (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum possible number of total banknotes used by you and the clerk.\n\nSample Input 1\n\n36\n\nSample Output 1\n\n8\n\nIf you give four banknotes of value 10 each, and the clerk gives you back four banknotes of value 1 each, a total of eight banknotes are used.\n\nThe payment cannot be made with less than eight banknotes in total, so the answer is 8.\n\nSample Input 2\n\n91\n\nSample Output 2\n\n3\n\nIf you give two banknotes of value 100, 1, and the clerk gives you back one banknote of value 10, a total of three banknotes are used.\n\nSample Input 3\n\n314159265358979323846264338327950288419716939937551058209749445923078164062862089986280348253421170\n\nSample Output 3\n\n243", "sample_input": "36\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02775", "source_text": "Score: 500 points\n\nProblem Statement\n\nIn the Kingdom of AtCoder, only banknotes are used as currency. There are 10^{100}+1 kinds of banknotes, with the values of 1, 10, 10^2, 10^3, \\dots, 10^{(10^{100})}. You have come shopping at a mall and are now buying a takoyaki machine with a value of N. (Takoyaki is the name of a Japanese snack.)\n\nTo make the payment, you will choose some amount of money which is at least N and give it to the clerk. Then, the clerk gives you back the change, which is the amount of money you give minus N.\n\nWhat will be the minimum possible number of total banknotes used by you and the clerk, when both choose the combination of banknotes to minimize this count?\n\nAssume that you have sufficient numbers of banknotes, and so does the clerk.\n\nConstraints\n\nN is an integer between 1 and 10^{1,000,000} (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum possible number of total banknotes used by you and the clerk.\n\nSample Input 1\n\n36\n\nSample Output 1\n\n8\n\nIf you give four banknotes of value 10 each, and the clerk gives you back four banknotes of value 1 each, a total of eight banknotes are used.\n\nThe payment cannot be made with less than eight banknotes in total, so the answer is 8.\n\nSample Input 2\n\n91\n\nSample Output 2\n\n3\n\nIf you give two banknotes of value 100, 1, and the clerk gives you back one banknote of value 10, a total of three banknotes are used.\n\nSample Input 3\n\n314159265358979323846264338327950288419716939937551058209749445923078164062862089986280348253421170\n\nSample Output 3\n\n243", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 507, "cpu_time_ms": 281, "memory_kb": 72180}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s975532250", "group_id": "codeNet:p02777", "input_text": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n try (Scanner sc = new Scanner(System.in)) {\n String S = sc.next();\n String T = sc.next();\n int A = sc.nextInt();\n int B = sc.nextInt();\n String U = sc.next();\n\n if (U.equals(S)) {\n A--;\n } else {\n B--;\n }\n\n System.out.println(A + \" \" + B);\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1594065545, "filename_ext": "java", "original_language": "Java (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02777.html", "problem_id": "p02777", "resource_group": "high_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/Java/s975532250.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s975532250", "user_id": "u552502395"}, "prompt_components": {"gold_output": "2 4\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n try (Scanner sc = new Scanner(System.in)) {\n String S = sc.next();\n String T = sc.next();\n int A = sc.nextInt();\n int B = sc.nextInt();\n String U = sc.next();\n\n if (U.equals(S)) {\n A--;\n } else {\n B--;\n }\n\n System.out.println(A + \" \" + B);\n }\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now.\n\nConstraints\n\nS, T, and U are strings consisting of lowercase English letters.\n\nThe lengths of S and T are each between 1 and 10 (inclusive).\n\nS \\not= T\n\nS=U or T=U.\n\n1 \\leq A,B \\leq 10\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\nA B\nU\n\nOutput\n\nPrint the answer, with space in between.\n\nSample Input 1\n\nred blue\n3 4\nred\n\nSample Output 1\n\n2 4\n\nTakahashi chose a ball with red written on it and threw it away.\nNow we have two balls with the string S and four balls with the string T.\n\nSample Input 2\n\nred blue\n5 5\nblue\n\nSample Output 2\n\n5 4\n\nTakahashi chose a ball with blue written on it and threw it away.\nNow we have five balls with the string S and four balls with the string T.", "sample_input": "red blue\n3 4\nred\n"}, "reference_outputs": ["2 4\n"], "source_document_id": "p02777", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now.\n\nConstraints\n\nS, T, and U are strings consisting of lowercase English letters.\n\nThe lengths of S and T are each between 1 and 10 (inclusive).\n\nS \\not= T\n\nS=U or T=U.\n\n1 \\leq A,B \\leq 10\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\nA B\nU\n\nOutput\n\nPrint the answer, with space in between.\n\nSample Input 1\n\nred blue\n3 4\nred\n\nSample Output 1\n\n2 4\n\nTakahashi chose a ball with red written on it and threw it away.\nNow we have two balls with the string S and four balls with the string T.\n\nSample Input 2\n\nred blue\n5 5\nblue\n\nSample Output 2\n\n5 4\n\nTakahashi chose a ball with blue written on it and threw it away.\nNow we have five balls with the string S and four balls with the string T.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 487, "cpu_time_ms": 101, "memory_kb": 26932}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s246228269", "group_id": "codeNet:p02777", "input_text": "import java.util.*;\nimport java.util.ArrayList;\nimport java.util.Iterator;\nimport java.util.List;\nimport java.util.Collections;\n\npublic class Main {\n\tpublic static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n Random rand = new Random();\n //ArrayList list;\n List list = new ArrayList<>(200000);\n \n int number = sc.nextInt();\n for(int i = 0; i < number ; i++){\n list.add(sc.nextInt());\n }\n\n Collections.sort(list);\n int count = 0;\n for(int i = 0; i < number - 1 ; i++){\n if(list.get(i).equals(list.get(i+1))){\n count++;\n }else{}\n }\n System.out.println(list);\n\n if(count == 0){\n System.out.println(\"YES\");\n }else{\n System.out.println(\"NO\");\n }\n \n\n\n \n\t}\n}", "language": "Java", "metadata": {"date": 1581951525, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02777.html", "problem_id": "p02777", "resource_group": "high_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/Java/s246228269.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s246228269", "user_id": "u073396193"}, "prompt_components": {"gold_output": "2 4\n", "input_to_evaluate": "import java.util.*;\nimport java.util.ArrayList;\nimport java.util.Iterator;\nimport java.util.List;\nimport java.util.Collections;\n\npublic class Main {\n\tpublic static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n Random rand = new Random();\n //ArrayList list;\n List list = new ArrayList<>(200000);\n \n int number = sc.nextInt();\n for(int i = 0; i < number ; i++){\n list.add(sc.nextInt());\n }\n\n Collections.sort(list);\n int count = 0;\n for(int i = 0; i < number - 1 ; i++){\n if(list.get(i).equals(list.get(i+1))){\n count++;\n }else{}\n }\n System.out.println(list);\n\n if(count == 0){\n System.out.println(\"YES\");\n }else{\n System.out.println(\"NO\");\n }\n \n\n\n \n\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": 881, "cpu_time_ms": 97, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s507260230", "group_id": "codeNet:p02778", "input_text": "import java.util.Scanner;\n\nclass Main{\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n String s = sc.next();\n\n for(int i=0;iSystem.exit(1));\n new Thread(null, new Main(), \"\", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行\n }\n\n public void run() {\n \tFastScanner sc = new FastScanner(System.in);\n String s = sc.next();\n String rep = s.replaceAll(\".\", \"x\");\n System.out.println(rep);\n }\n}\n\n//高速なScanner\nclass FastScanner {\n\tprivate BufferedReader reader = null;\n\tprivate StringTokenizer tokenizer = null;\n\n\tpublic FastScanner(InputStream in) {\n\t\treader = new BufferedReader(new InputStreamReader(in));\n\t\ttokenizer = null;\n\t}\n\n\tpublic String next() {\n\t\tif (tokenizer == null || !tokenizer.hasMoreTokens()) {\n\t\t\ttry {\n\t\t\t\ttokenizer = new StringTokenizer(reader.readLine());\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new RuntimeException(e);\n\t\t\t}\n\t\t}\n\t\treturn tokenizer.nextToken();\n\t}\n\n\tpublic String nextLine() {\n\t\tif (tokenizer == null || !tokenizer.hasMoreTokens()) {\n\t\t\ttry {\n\t\t\t\treturn reader.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new RuntimeException(e);\n\t\t\t}\n\t\t}\n\t\treturn tokenizer.nextToken(\"\\n\");\n\t}\n\n\tpublic long nextLong() {\n\t\treturn Long.parseLong(next());\n\t}\n\n\tpublic int nextInt() {\n\t\treturn Integer.parseInt(next());\n\t}\n\n\tpublic double nextDouble() {\n\t\treturn Double.parseDouble(next());\n\t}\n\n\tpublic int[] nextIntArray(int n) {\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\ta[i] = nextInt();\n\t\treturn a;\n\t}\n\n\tpublic long[] nextLongArray(int n) {\n\t\tlong[] a = new long[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\ta[i] = nextLong();\n\t\treturn a;\n\t}\n}\n", "language": "Java", "metadata": {"date": 1581961342, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02778.html", "problem_id": "p02778", "resource_group": "high_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/Java/s726605595.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s726605595", "user_id": "u173574510"}, "prompt_components": {"gold_output": "xxxxxxx\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.util.StringTokenizer;\n\n\n//System.out.println();\npublic class Main implements Runnable { //クラス名はMain\n\n public static void main(String[] args) {\n \tThread.setDefaultUncaughtExceptionHandler((t,e)->System.exit(1));\n new Thread(null, new Main(), \"\", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行\n }\n\n public void run() {\n \tFastScanner sc = new FastScanner(System.in);\n String s = sc.next();\n String rep = s.replaceAll(\".\", \"x\");\n System.out.println(rep);\n }\n}\n\n//高速なScanner\nclass FastScanner {\n\tprivate BufferedReader reader = null;\n\tprivate StringTokenizer tokenizer = null;\n\n\tpublic FastScanner(InputStream in) {\n\t\treader = new BufferedReader(new InputStreamReader(in));\n\t\ttokenizer = null;\n\t}\n\n\tpublic String next() {\n\t\tif (tokenizer == null || !tokenizer.hasMoreTokens()) {\n\t\t\ttry {\n\t\t\t\ttokenizer = new StringTokenizer(reader.readLine());\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new RuntimeException(e);\n\t\t\t}\n\t\t}\n\t\treturn tokenizer.nextToken();\n\t}\n\n\tpublic String nextLine() {\n\t\tif (tokenizer == null || !tokenizer.hasMoreTokens()) {\n\t\t\ttry {\n\t\t\t\treturn reader.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new RuntimeException(e);\n\t\t\t}\n\t\t}\n\t\treturn tokenizer.nextToken(\"\\n\");\n\t}\n\n\tpublic long nextLong() {\n\t\treturn Long.parseLong(next());\n\t}\n\n\tpublic int nextInt() {\n\t\treturn Integer.parseInt(next());\n\t}\n\n\tpublic double nextDouble() {\n\t\treturn Double.parseDouble(next());\n\t}\n\n\tpublic int[] nextIntArray(int n) {\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\ta[i] = nextInt();\n\t\treturn a;\n\t}\n\n\tpublic long[] nextLongArray(int n) {\n\t\tlong[] a = new long[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\ta[i] = nextLong();\n\t\treturn a;\n\t}\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": 1857, "cpu_time_ms": 172, "memory_kb": 28624}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s178556974", "group_id": "codeNet:p02778", "input_text": "\n\n\nimport java.io.*;\nimport java.util.*;\n\n\npublic class Main {\n static class pair implements Comparable{\n int x;\n int idx;\n pair(int x,int idx){\n this.x=x;\n this.idx=idx;\n }\n\n @Override\n public int compareTo(pair p) {\n if(p.x==x){\n return idx-p.idx;\n }\n return x-p.x;\n }\n }\n\n\n public static long ciel(long x,long y){\n long res=x/y;\n if(x%y!=0)res++;\n return res;\n }\n\n public static long gcd(long u,long v){\n if(v==0)return u;\n return gcd(v, u%v);\n }\n static int mod= (int) (1e9+7);\n static long memo[][];\n static long inf= (long) 2e9;\n static int[]cost,weight;\n static ArrayList primes;\n static ArrayList primeFactors(int N)\t\t// O(sqrt(N) / ln sqrt(N))\n {\n ArrayList factors = new ArrayList();\t\t//take abs(N) in case of -ve integers\n int idx = 0, p = primes.get(idx);\n\n while(p * p <= N)\n {\n while(N % p == 0) { factors.add(p); N /= p; }\n p = primes.get(++idx);\n }\n\n if(N != 1)\t\t\t\t\t\t// last prime factor may be > sqrt(N)\n factors.add(N);\t\t\t\t// for integers whose largest prime factor has a power of 1\n return factors;\n }\n static int[] isComposite;\n static void sieve(int N)\t// O(N log log N)\n {\n isComposite = new int[N+1];\n isComposite[0] = isComposite[1] = 1;\t\t\t// 0 indicates a prime number\n primes = new ArrayList();\n\n for (int i = 2; i <= N; ++i) \t\t\t\t\t//can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))\n if (isComposite[i] == 0) \t\t\t\t\t//can loop in 2 and odd integers for slightly better performance\n {\n primes.add(i);\n if(1l * i * i <= N)\n for (int j = i * i; j <= N; j += i)\t// j = i * 2 will not affect performance too much, may alter in modified sieve\n isComposite[j] = 1;\n }\n }\n\n /*\n * 2. Primality Test\n *\n * Preprocessing: call sieve with sqrt(N), O(sqrt(N) log log sqrt(N))\n * Query: best case O(1), worst case O(sqrt(N) / log sqrt(N))\n */\n static boolean isPrime(int N)\n {\n if(N < isComposite.length)\n return isComposite[N] == 0;\n for(int p: primes)\t\t\t\t\t//may stop if p * p > N\n if(N%p==0)\n return false;\n return true;\n }\n static long modPow(long a, long e, long mod)\t// O(log e)\n {\n a %= mod;\n long res = 1;\n while(e > 0)\n {\n if((e & 1) == 1)\n res = (res * a) % mod;\n a = (a * a) % mod;\n e >>= 1;\n }\n return res;\n }\n public static void main(String[] args) throws Exception {\n Scanner sc=new Scanner(System.in);\n PrintWriter pw=new PrintWriter(System.out);\n String s=sc.next();\n int n=s.length();\n while (n-->0)pw.print(\"x\");\n pw.close();\n }\n\n public static class Scanner {\n StringTokenizer st;\n BufferedReader br;\n\n public Scanner(InputStream s) {\n br = new BufferedReader(new InputStreamReader(s));\n }\n\n public String next() throws IOException {\n while (st == null || !st.hasMoreTokens())\n st = new StringTokenizer(br.readLine());\n return st.nextToken();\n }\n\n public int nextInt() throws IOException {\n return Integer.parseInt(next());\n }\n\n public long nextLong() throws IOException {\n return Long.parseLong(next());\n }\n\n public String nextLine() throws IOException {\n return br.readLine();\n }\n\n public double nextDouble() throws IOException {\n String x = next();\n StringBuilder sb = new StringBuilder(\"0\");\n double res = 0, f = 1;\n boolean dec = false, neg = false;\n int start = 0;\n if (x.charAt(0) == '-') {\n neg = true;\n start++;\n }\n for (int i = start; i < x.length(); i++)\n if (x.charAt(i) == '.') {\n res = Long.parseLong(sb.toString());\n sb = new StringBuilder(\"0\");\n dec = true;\n } else {\n sb.append(x.charAt(i));\n if (dec)\n f *= 10;\n }\n res += Long.parseLong(sb.toString()) / f;\n return res * (neg ? -1 : 1);\n }\n\n public boolean ready() throws IOException, IOException {\n return br.ready();\n }\n\n }\n}", "language": "Java", "metadata": {"date": 1581278774, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02778.html", "problem_id": "p02778", "resource_group": "high_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/Java/s178556974.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s178556974", "user_id": "u482519004"}, "prompt_components": {"gold_output": "xxxxxxx\n", "input_to_evaluate": "\n\n\nimport java.io.*;\nimport java.util.*;\n\n\npublic class Main {\n static class pair implements Comparable{\n int x;\n int idx;\n pair(int x,int idx){\n this.x=x;\n this.idx=idx;\n }\n\n @Override\n public int compareTo(pair p) {\n if(p.x==x){\n return idx-p.idx;\n }\n return x-p.x;\n }\n }\n\n\n public static long ciel(long x,long y){\n long res=x/y;\n if(x%y!=0)res++;\n return res;\n }\n\n public static long gcd(long u,long v){\n if(v==0)return u;\n return gcd(v, u%v);\n }\n static int mod= (int) (1e9+7);\n static long memo[][];\n static long inf= (long) 2e9;\n static int[]cost,weight;\n static ArrayList primes;\n static ArrayList primeFactors(int N)\t\t// O(sqrt(N) / ln sqrt(N))\n {\n ArrayList factors = new ArrayList();\t\t//take abs(N) in case of -ve integers\n int idx = 0, p = primes.get(idx);\n\n while(p * p <= N)\n {\n while(N % p == 0) { factors.add(p); N /= p; }\n p = primes.get(++idx);\n }\n\n if(N != 1)\t\t\t\t\t\t// last prime factor may be > sqrt(N)\n factors.add(N);\t\t\t\t// for integers whose largest prime factor has a power of 1\n return factors;\n }\n static int[] isComposite;\n static void sieve(int N)\t// O(N log log N)\n {\n isComposite = new int[N+1];\n isComposite[0] = isComposite[1] = 1;\t\t\t// 0 indicates a prime number\n primes = new ArrayList();\n\n for (int i = 2; i <= N; ++i) \t\t\t\t\t//can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))\n if (isComposite[i] == 0) \t\t\t\t\t//can loop in 2 and odd integers for slightly better performance\n {\n primes.add(i);\n if(1l * i * i <= N)\n for (int j = i * i; j <= N; j += i)\t// j = i * 2 will not affect performance too much, may alter in modified sieve\n isComposite[j] = 1;\n }\n }\n\n /*\n * 2. Primality Test\n *\n * Preprocessing: call sieve with sqrt(N), O(sqrt(N) log log sqrt(N))\n * Query: best case O(1), worst case O(sqrt(N) / log sqrt(N))\n */\n static boolean isPrime(int N)\n {\n if(N < isComposite.length)\n return isComposite[N] == 0;\n for(int p: primes)\t\t\t\t\t//may stop if p * p > N\n if(N%p==0)\n return false;\n return true;\n }\n static long modPow(long a, long e, long mod)\t// O(log e)\n {\n a %= mod;\n long res = 1;\n while(e > 0)\n {\n if((e & 1) == 1)\n res = (res * a) % mod;\n a = (a * a) % mod;\n e >>= 1;\n }\n return res;\n }\n public static void main(String[] args) throws Exception {\n Scanner sc=new Scanner(System.in);\n PrintWriter pw=new PrintWriter(System.out);\n String s=sc.next();\n int n=s.length();\n while (n-->0)pw.print(\"x\");\n pw.close();\n }\n\n public static class Scanner {\n StringTokenizer st;\n BufferedReader br;\n\n public Scanner(InputStream s) {\n br = new BufferedReader(new InputStreamReader(s));\n }\n\n public String next() throws IOException {\n while (st == null || !st.hasMoreTokens())\n st = new StringTokenizer(br.readLine());\n return st.nextToken();\n }\n\n public int nextInt() throws IOException {\n return Integer.parseInt(next());\n }\n\n public long nextLong() throws IOException {\n return Long.parseLong(next());\n }\n\n public String nextLine() throws IOException {\n return br.readLine();\n }\n\n public double nextDouble() throws IOException {\n String x = next();\n StringBuilder sb = new StringBuilder(\"0\");\n double res = 0, f = 1;\n boolean dec = false, neg = false;\n int start = 0;\n if (x.charAt(0) == '-') {\n neg = true;\n start++;\n }\n for (int i = start; i < x.length(); i++)\n if (x.charAt(i) == '.') {\n res = Long.parseLong(sb.toString());\n sb = new StringBuilder(\"0\");\n dec = true;\n } else {\n sb.append(x.charAt(i));\n if (dec)\n f *= 10;\n }\n res += Long.parseLong(sb.toString()) / f;\n return res * (neg ? -1 : 1);\n }\n\n public boolean ready() throws IOException, IOException {\n return br.ready();\n }\n\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": 4776, "cpu_time_ms": 79, "memory_kb": 21204}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s937708929", "group_id": "codeNet:p02779", "input_text": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws IOException {\n Scanner scan = new Scanner(System.in);\n int n = scan.nextInt();\n Set set = new HashSet<>();\n for (int i = 0; i < n; i ++){\n int t = scan.nextInt();\n if (set.contains(t)){\n System.out.println(\"NO\");\n return;\n }else\n set.add(t);\n }\n System.out.println(\"YES\");\n }\n}\n", "language": "Java", "metadata": {"date": 1586423482, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02779.html", "problem_id": "p02779", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02779/input.txt", "sample_output_relpath": "derived/input_output/data/p02779/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02779/Java/s937708929.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s937708929", "user_id": "u225771945"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws IOException {\n Scanner scan = new Scanner(System.in);\n int n = scan.nextInt();\n Set set = new HashSet<>();\n for (int i = 0; i < n; i ++){\n int t = scan.nextInt();\n if (set.contains(t)){\n System.out.println(\"NO\");\n return;\n }else\n set.add(t);\n }\n System.out.println(\"YES\");\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a sequence of integers A_1, A_2, ..., A_N.\nIf its elements are pairwise distinct, print YES; otherwise, print NO.\n\nConstraints\n\n2 ≤ N ≤ 200000\n\n1 ≤ A_i ≤ 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nIf the elements of the sequence are pairwise distinct, print YES; otherwise, print NO.\n\nSample Input 1\n\n5\n2 6 1 4 5\n\nSample Output 1\n\nYES\n\nThe elements are pairwise distinct.\n\nSample Input 2\n\n6\n4 1 3 1 6 2\n\nSample Output 2\n\nNO\n\nThe second and fourth elements are identical.\n\nSample Input 3\n\n2\n10000000 10000000\n\nSample Output 3\n\nNO", "sample_input": "5\n2 6 1 4 5\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02779", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a sequence of integers A_1, A_2, ..., A_N.\nIf its elements are pairwise distinct, print YES; otherwise, print NO.\n\nConstraints\n\n2 ≤ N ≤ 200000\n\n1 ≤ A_i ≤ 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nIf the elements of the sequence are pairwise distinct, print YES; otherwise, print NO.\n\nSample Input 1\n\n5\n2 6 1 4 5\n\nSample Output 1\n\nYES\n\nThe elements are pairwise distinct.\n\nSample Input 2\n\n6\n4 1 3 1 6 2\n\nSample Output 2\n\nNO\n\nThe second and fourth elements are identical.\n\nSample Input 3\n\n2\n10000000 10000000\n\nSample Output 3\n\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 519, "cpu_time_ms": 680, "memory_kb": 100816}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s572386152", "group_id": "codeNet:p02779", "input_text": "import java.util.HashMap;\nimport java.util.Scanner;\n \npublic class Main {\n\tpublic static void main(String[] args) {\n \n\t\tScanner scan = new Scanner(System.in);\n\t\tint N = scan.nextInt();\n\t\tString anser = \"YES\";\n \n\t\tHashMap map = new HashMap();\n \n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tmap.put(scan.nextInt(), i);\n\t\t}\n \n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tint size = map.size();\n\t\t\tmap.remove(map.get(i));\n \n\t\t\tif (size - 1 > map.size()) {\n\t\t\t\tanser = \"NO\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(anser);\n\t}\n \n}", "language": "Java", "metadata": {"date": 1584213219, "filename_ext": "java", "original_language": "Java7 (OpenJDK 1.7.0)", "problem_description_relpath": "problem_descriptions/p02779.html", "problem_id": "p02779", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02779/input.txt", "sample_output_relpath": "derived/input_output/data/p02779/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02779/Java/s572386152.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s572386152", "user_id": "u162241493"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.util.HashMap;\nimport java.util.Scanner;\n \npublic class Main {\n\tpublic static void main(String[] args) {\n \n\t\tScanner scan = new Scanner(System.in);\n\t\tint N = scan.nextInt();\n\t\tString anser = \"YES\";\n \n\t\tHashMap map = new HashMap();\n \n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tmap.put(scan.nextInt(), i);\n\t\t}\n \n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tint size = map.size();\n\t\t\tmap.remove(map.get(i));\n \n\t\t\tif (size - 1 > map.size()) {\n\t\t\t\tanser = \"NO\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(anser);\n\t}\n \n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a sequence of integers A_1, A_2, ..., A_N.\nIf its elements are pairwise distinct, print YES; otherwise, print NO.\n\nConstraints\n\n2 ≤ N ≤ 200000\n\n1 ≤ A_i ≤ 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nIf the elements of the sequence are pairwise distinct, print YES; otherwise, print NO.\n\nSample Input 1\n\n5\n2 6 1 4 5\n\nSample Output 1\n\nYES\n\nThe elements are pairwise distinct.\n\nSample Input 2\n\n6\n4 1 3 1 6 2\n\nSample Output 2\n\nNO\n\nThe second and fourth elements are identical.\n\nSample Input 3\n\n2\n10000000 10000000\n\nSample Output 3\n\nNO", "sample_input": "5\n2 6 1 4 5\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02779", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a sequence of integers A_1, A_2, ..., A_N.\nIf its elements are pairwise distinct, print YES; otherwise, print NO.\n\nConstraints\n\n2 ≤ N ≤ 200000\n\n1 ≤ A_i ≤ 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nIf the elements of the sequence are pairwise distinct, print YES; otherwise, print NO.\n\nSample Input 1\n\n5\n2 6 1 4 5\n\nSample Output 1\n\nYES\n\nThe elements are pairwise distinct.\n\nSample Input 2\n\n6\n4 1 3 1 6 2\n\nSample Output 2\n\nNO\n\nThe second and fourth elements are identical.\n\nSample Input 3\n\n2\n10000000 10000000\n\nSample Output 3\n\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 541, "cpu_time_ms": 684, "memory_kb": 104336}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s206775555", "group_id": "codeNet:p02779", "input_text": "import java.util.Scanner;\n\npublic class Main {\n \n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tbyte n = sc.nextByte(),c=0,i=0,j=0;\n\t\tint a[] = new int [n];\n \n\t\twhile(c list = new LinkedList<>();\n int currentSum = 0;\n for (int i = 0; i < k; i++) {\n int tmp = p[i];\n currentSum += tmp;\n list.add(p[i]);\n }\n int max = currentSum;\n int pointer = 0;\n for (int i = k; i < n; i++) {\n int tmp = p[i];\n int first = list.poll();\n list.add(tmp);\n currentSum = currentSum + tmp - first;\n max = Math.max(max, currentSum);\n if (max == currentSum) {\n pointer = i - (k - 1);\n }\n }\n double predicts = 0;\n for (int i = pointer; i < pointer + k; i++) {\n int tmp = p[i];\n int tmpSum = 0;\n for (int j = 1; j <= tmp; j++) {\n tmpSum += j;\n }\n predicts += (double) tmpSum / tmp;\n }\n writer.println(predicts);\n }\n }\n\n public static void main(final String[] args) {\n final FastScanner sc = new FastScanner();\n try (final PrintWriter w = new PrintWriter(System.out)) {\n new Solver(sc, w).run();\n w.flush();\n }\n }\n\n // CRT stuff\n static class MOD {\n private static final int MOD = (int) 1e9 + 7;\n\n static long plus(long x, long y) {\n x %= MOD;\n y %= MOD;\n return (x + y) % MOD;\n }\n\n static long sub(long x, long y) {\n x %= MOD;\n y %= MOD;\n return (x - y + MOD) % MOD;\n }\n\n static long multi(long x, long y) {\n x %= MOD;\n y %= MOD;\n return x * y % MOD;\n }\n\n static long div(long x, long y) {\n x %= MOD;\n y %= MOD;\n return x * pow(y, MOD - 2) % MOD;\n }\n\n static long pow(final long a, final long p) {\n if (p == 0)\n return 1;\n if (p % 2 == 0) {\n final long halfP = p / 2;\n final long root = pow(a, halfP);\n return root * root % MOD;\n } else\n return a * pow(a, p - 1) % MOD;\n }\n }\n\n // FastScanner\n static class FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n public FastScanner() {\n }\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (final IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte())\n return buffer[ptr++];\n else\n return -1;\n }\n\n private boolean isPrintableChar(final int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr]))\n ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext())\n throw new NoSuchElementException();\n final StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext())\n throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n final long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)\n throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n\n public int[] nextIntArray(final int n) {\n final int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = nextInt();\n return a;\n }\n\n public long[] nextLongArray(final int n) {\n final long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = nextLong();\n return a;\n }\n }\n}", "language": "Java", "metadata": {"date": 1581322994, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02780.html", "problem_id": "p02780", "resource_group": "high_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/Java/s439502440.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s439502440", "user_id": "u100405125"}, "prompt_components": {"gold_output": "7.000000000000\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.LinkedList;\nimport java.util.NoSuchElementException;\nimport java.util.Queue;\n\nclass Main {\n\n static class Solver {\n final FastScanner sc;\n final PrintWriter writer;\n\n Solver(final FastScanner sc, final PrintWriter writer) {\n this.sc = sc;\n this.writer = writer;\n }\n\n void run() {\n int n = sc.nextInt();\n int k = sc.nextInt();\n int[] p = sc.nextIntArray(n);\n Queue list = new LinkedList<>();\n int currentSum = 0;\n for (int i = 0; i < k; i++) {\n int tmp = p[i];\n currentSum += tmp;\n list.add(p[i]);\n }\n int max = currentSum;\n int pointer = 0;\n for (int i = k; i < n; i++) {\n int tmp = p[i];\n int first = list.poll();\n list.add(tmp);\n currentSum = currentSum + tmp - first;\n max = Math.max(max, currentSum);\n if (max == currentSum) {\n pointer = i - (k - 1);\n }\n }\n double predicts = 0;\n for (int i = pointer; i < pointer + k; i++) {\n int tmp = p[i];\n int tmpSum = 0;\n for (int j = 1; j <= tmp; j++) {\n tmpSum += j;\n }\n predicts += (double) tmpSum / tmp;\n }\n writer.println(predicts);\n }\n }\n\n public static void main(final String[] args) {\n final FastScanner sc = new FastScanner();\n try (final PrintWriter w = new PrintWriter(System.out)) {\n new Solver(sc, w).run();\n w.flush();\n }\n }\n\n // CRT stuff\n static class MOD {\n private static final int MOD = (int) 1e9 + 7;\n\n static long plus(long x, long y) {\n x %= MOD;\n y %= MOD;\n return (x + y) % MOD;\n }\n\n static long sub(long x, long y) {\n x %= MOD;\n y %= MOD;\n return (x - y + MOD) % MOD;\n }\n\n static long multi(long x, long y) {\n x %= MOD;\n y %= MOD;\n return x * y % MOD;\n }\n\n static long div(long x, long y) {\n x %= MOD;\n y %= MOD;\n return x * pow(y, MOD - 2) % MOD;\n }\n\n static long pow(final long a, final long p) {\n if (p == 0)\n return 1;\n if (p % 2 == 0) {\n final long halfP = p / 2;\n final long root = pow(a, halfP);\n return root * root % MOD;\n } else\n return a * pow(a, p - 1) % MOD;\n }\n }\n\n // FastScanner\n static class FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n public FastScanner() {\n }\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (final IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte())\n return buffer[ptr++];\n else\n return -1;\n }\n\n private boolean isPrintableChar(final int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr]))\n ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext())\n throw new NoSuchElementException();\n final StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext())\n throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n final long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)\n throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n\n public int[] nextIntArray(final int n) {\n final int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = nextInt();\n return a;\n }\n\n public long[] nextLongArray(final int n) {\n final long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = nextLong();\n return a;\n }\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.\n\nWe will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.\n\nConstraints\n\n1 ≤ K ≤ N ≤ 200000\n\n1 ≤ p_i ≤ 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 ... p_N\n\nOutput\n\nPrint the maximum possible value of the expected value of the sum of the numbers shown.\n\nYour output will be considered correct when its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n5 3\n1 2 2 4 5\n\nSample Output 1\n\n7.000000000000\n\nWhen we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7. This is the maximum value we can achieve.\n\nSample Input 2\n\n4 1\n6 6 6 6\n\nSample Output 2\n\n3.500000000000\n\nRegardless of which die we choose, the expected value of the number shown is 3.5.\n\nSample Input 3\n\n10 4\n17 13 13 12 15 20 10 13 17 11\n\nSample Output 3\n\n32.000000000000", "sample_input": "5 3\n1 2 2 4 5\n"}, "reference_outputs": ["7.000000000000\n"], "source_document_id": "p02780", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.\n\nWe will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.\n\nConstraints\n\n1 ≤ K ≤ N ≤ 200000\n\n1 ≤ p_i ≤ 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 ... p_N\n\nOutput\n\nPrint the maximum possible value of the expected value of the sum of the numbers shown.\n\nYour output will be considered correct when its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n5 3\n1 2 2 4 5\n\nSample Output 1\n\n7.000000000000\n\nWhen we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7. This is the maximum value we can achieve.\n\nSample Input 2\n\n4 1\n6 6 6 6\n\nSample Output 2\n\n3.500000000000\n\nRegardless of which die we choose, the expected value of the number shown is 3.5.\n\nSample Input 3\n\n10 4\n17 13 13 12 15 20 10 13 17 11\n\nSample Output 3\n\n32.000000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4813, "cpu_time_ms": 249, "memory_kb": 32784}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s195628405", "group_id": "codeNet:p02781", "input_text": "import java.io.BufferedReader;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.PrintWriter;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.HashMap;\nimport java.util.StringTokenizer;\nimport java.util.TreeSet;\n\nimport java.lang.Integer; \n\npublic class Main {\n\tstatic ArrayListadj[];\n\tstatic PrintWriter out=new PrintWriter(System.out);\n\t public static int mod = 1000000007;\n\n\tstatic int notmemo[][][][];\n\tstatic int k;\n\tstatic int a[];\n\tstatic int b[];\n\tstatic int m;\n\tstatic char c[];\n\t\n\tstatic int trace[];\n\tstatic int h;\n\tstatic int x;\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\ts=sc.nextLine();\n\tc=s.toCharArray();\n\tk=sc.nextInt();\n\tn=c.length;\n\tmemo=new long[c.length+1][k+1][2];\n\tfor (int i = 0; i < c.length+1; i++) {\n\t\tfor (int j = 0; j k) {\n\t\t\treturn 0;\n\t\t}\n\tif(i==n) {\n\t\tif(count==k) {\n\t\t\treturn 1;\n\t\t}\n\t\telse\n\t\treturn 0;\n\t}\n\t\n\tif(memo[i][count][state]!=-1) {\n\t\treturn memo[i][count][state];\n\t}\n\t\n\tlong total=0;\n\tfor (int j = 0; j <10; j++) {\n\t\tif(state==0&&j>Integer.parseInt(\"\"+c[i])) {\n\t\t\tcontinue;\n\t\t}\n\t\t\n\n\t\t\n\t\telse if(state==0&&j==Integer.parseInt(\"\"+c[i])) {\n\t\tif(j==0)\n\t\t\ttotal+=dp(i+1,count,0);\t\n\t\telse\n\t\t\ttotal+=dp(i+1,count+1,0);\t\n\t\t\t\n\t\t}\n\t\telse if(j==0) {\n\t\t\ttotal+=dp(i+1,count,1);\n\t\t}\n\t\telse {\n\t\t\ttotal+=dp(i+1,count+1,1);\t\n\t\t}\n\t}\n\t\n\treturn memo[i][count][state]=total;\n\t\n\t}\n\tstatic boolean f=true;\n\tstatic class SegmentTree {\t\t// 1-based DS, OOP\n\t\tint N; \t\t\t//the number of elements in the array as a power of 2 (i.e. after padding)\n\t\tint[] array, sTree, lazy;\n\t\t\n\t\tSegmentTree(int[] in)\t\t\n\t\t{\n\t\t\tarray = in; N = in.length - 1;\n\t\t\tsTree = new int[N*4];\t\t//no. of nodes = 2*N - 1, we add one to cross out index zero\n\t\t\tlazy = new int[N*4];\n\t\t\t\n\t\t//\tbuild(1,1,N);\n\t\t}\n\t\t\n\t\tvoid build(int node, int b, int e)\t// O(n)\n\t\t{\n\t\t\tif(b == e)\t\t\t\t\t\n\t\t\t\tsTree[node] = array[b];\n\t\t\telse\t\t\t\t\t\t\n\t\t\t{\n\t\t\t\tint mid = b + e >> 1;\n\t\t\t\tbuild(node<<1,b,mid);\n\t\t\t\tbuild(node<<1|1,mid+1,e);\n\t\t\t\tsTree[node] = sTree[node<<1]&sTree[node<<1|1];\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\tvoid update_point(int index, int val)\t\t\t// O(log n)\n\t\t{\n\t\t\tindex += N - 1;\t\t\t\t\n\t\t\tsTree[index] += val;\t\t\t\n\t\t\twhile(index>1)\t\t\t\t\n\t\t\t{\n\t\t\t\tindex >>= 1;\n\t\t\t\tsTree[index] = sTree[index<<1] + sTree[index<<1|1];\t\t\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\tvoid update_range(int i, int j,int val)\t\t// O(log n) \n\t\t{\n\t\t\tupdate_range(1,1,N,i,j,val);\n\t\t}\n\t\t\n\t\tvoid update_range(int node, int b, int e, int i, int j,int val)\n\t\t{\n\t\t\tif(i > e || j < b)\t\t\n\t\t\t\treturn;\n\t\t\tif(b >= i && e <= j)\t\t\n\t\t\t{\n\t\t\t\tsTree[node]|= val;\t\t\t\n\t\t\t\tlazy[node]|=val;\n\t\t\n\t\t\t//LAZY LAZY\n\t\t\t}\t\t\t\t\t\t\t\n\t\t\telse\t\t\n\t\t\t{\n\t\t\t\tint mid = b + e >> 1;\n\t\t\t\tpropagate(node, b, mid, e);\n\t\t\t\tupdate_range(node<<1,b,mid,i,j,val);\n\t\t\t\tupdate_range(node<<1|1,mid+1,e,i,j,val);\n\t\t\t\tsTree[node] = sTree[node<<1]&sTree[node<<1|1];\t\t\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tvoid propagate(int node, int b, int mid, int e)\t\t\n\t\t{\n\n\t\t\tlazy[node<<1] |= lazy[node];\n\t\t\tlazy[(node<<1)|1] |= lazy[node];\n\t\t\tsTree[node<<1] |= lazy[node];\t\t\n\t\t\tsTree[(node<<1)|1] |= lazy[node];\t\t\n\t\t\tlazy[node] = 0;\n\t\t\t\n\t\t}\n\t\t\n\t\tint query(int i, int j)\n\t\t{\n\t\t\treturn query(1,1,N,i,j);\n\t\t}\n\t\t\n\t\tint query(int node, int b, int e, int i, int j)\t// O(log n)\n\t\t{\n\t\t\tif(i>e || j = i && e <= j)\n\t\t\t\treturn sTree[node];\n\t\t\tint mid = b + e >> 1;\n\t\t\tpropagate(node, b, mid, e);\n\t\t\tint q1 = query(node<<1,b,mid,i,j);\n\t\t\tint q2 = query(node<<1|1,mid+1,e,i,j);\n\t\t\treturn q1 &q2;\t\n\t\t\t\t\t\n\t\t}\n\t}\nstatic long memo[][][];\n\n\t\tstatic long nCr1(int n , int k)\n\t{\n\t\tif(n < k)\n\t\t\treturn 0;\n\t\tif(k == 0 || k == n)\n\t\t\treturn 1;\n\t\tif(comb[n][k] != -1)\n\t\t\treturn comb[n][k];\n\t\tif(n - k < k)\n\t\t\treturn comb[n][k] = nCr1(n, n - k);\n\t\treturn comb[n][k] = ((nCr1(n - 1, k - 1)%mod) +( nCr1(n - 1, k)%mod))%mod;\n\t}\n\t\n\t\nstatic class UnionFind { \n\tint[] p, rank, setSize;\n\tint numSets;\n\tint max[];\n\tpublic UnionFind(int N) \n\t{\n\t\tmax=new int[N];\n\t\tp = new int[numSets = N];\n\t\trank = new int[N];\n\t\tsetSize = new int[N];\n\t\tfor (int i = 0; i < N; i++) { p[i] = i; setSize[i] = 1;\n\t\tmax[i]=i;\n\t\t}\n\t}\n\n\tpublic int findSet(int i) { return p[i] == i ? i : (p[i] = findSet(p[i])); }\n\n\tpublic boolean isSameSet(int i, int j) { return findSet(i) == findSet(j); }\n\n\tpublic void unionSet(int i, int j) \n\t{ \n\t\tif (isSameSet(i, j)) \n\t\t\treturn;\n\t\tnumSets--; \n\t\tint x = findSet(i), y = findSet(j);\n\t\tif(rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y];\n\t\tmax[x]=Math.max(max[x], max[y]);\n\t\t\n\t\t}\n\t\telse\n\t\t{\tp[x] = y; setSize[y] += setSize[x];\n\t\t\tif(rank[x] == rank[y]) rank[y]++; \n\t\t\tmax[y]=Math.max(max[x],max[y]);\n\t\t\t\n\t\t} \n\t}\n\n\tprivate int getmax(int j) {\n\treturn max[findSet(j)];\n\t}\n\n\tpublic int numDisjointSets() { return numSets; }\n\n\tpublic int sizeOfSet(int i) { return setSize[findSet(i)]; }\n}\n\n\n\n\n\n\n\n\n\n/**private static void trace(int i, int time) {\nif(i==n) \n\treturn;\n\n\nlong ans=dp(i,time);\nif(time+a[i].t\n{\n\tint a; long b;\n\tint idx;\n\tincpair(int a, long dirg,int i) {this.a = a;\tb = dirg; idx=i; }\n\t\n\tpublic int compareTo(incpair e){ return (int) (b - e.b);\t}\n}\n\tstatic class decpair implements Comparable\n{\n\tint a; long b;int idx;\n\t\n\tdecpair(int a, long dirg,int i) {this.a = a;\tb = dirg; idx=i;}\n\t\n\tpublic int compareTo(decpair e){ return (int) (e.b- b);\t}\n}\n\n\t\n\t\n\t\n\t\n\t\n\t\n\n\n\tstatic long allpowers[];\n\tstatic class Quad implements Comparable{\n\t\tint u;\n\t\tint v;\n\t\tchar state;\n\t\tint turns;\n\t\tpublic Quad(int i, int j, char c, int k) {\n\t\tu=i;\n\t\tv=j;\n\t\tstate=c;\n\t\tturns=k;\n\t\t}\n\t\tpublic int compareTo(Quad e){ return (int) (turns - e.turns);\t}\n\t\t\n\t}\n\tstatic long dirg[][];\n\tstatic Edge[] driver;\n\t\n\tstatic int n;\n\t\tstatic class Edge implements Comparable\n\t{\n\t\tint node; long cost;\n\t\t\n\t\tEdge(int a, long dirg) { node = a;\tcost = dirg; }\n\t\t\n\t\tpublic int compareTo(Edge e){ return (int) (cost - e.cost);\t}\n\t}\n\n\t\n\n\n\n\t static long manhatandistance(long x,long x2,long y,long y2) {\n\t\t return Math.abs(x-x2)+Math.abs(y-y2);\n\t }\n\t static long fib[];\n\t static long fib(int n) {\n\t\t if(n==1||n==0) {\n\t\t\t return 1;\n\t\t }\n\t\t if(fib[n]!=-1) {\n\t\t\t return fib[n];\n\t\t }\n\t\t else \n\t\t\t return fib[n]= ((fib(n-2)%mod+fib(n-1)%mod)%mod);\n\t }\n\t static class Pair {\n\t\t\tint a, b;\n\t \n\t\t\tPair(int x, int y) {\n\t\t\t\ta = x;\n\t\t\t\tb = y;\n\t\t\t}\n\t \n\t\t\t\n\t\t}\n\t\t \n\t\n\t\t\n\t\t\n\tstatic long[][] comb;\t\t\n\t\n\t\n\t\nstatic class Triple implements Comparable{\n\nint l;\nint r;\nlong cost;\nint idx;\n\t\tpublic Triple(int a,int b,long l1,int l2) {\n\t\t\tl=a;\n\t\t\tr=b;\n\t\t\tcost=l1;\n\t\t\tidx=l2;\n\t\t}\n\t\tpublic int compareTo(Triple x)\n\t\t{\n\t\t\tif(l!=x.l || idx==x.idx)\n\t\t\t\treturn l-x.l;\n\t\t\treturn -idx;\n\t\t}\n\t\t\n\t\t\n\t}\n\t\n\tstatic TreeSet primeFactors(long N)\t\t// O(sqrt(N) / ln sqrt(N))\n\t{\n\t\tTreeSet factors = new TreeSet();\t\t//take abs(N) in case of -ve integers\n\t\tint idx = 0, p = primes.get(idx);\n\n\t\twhile(p * p <= N)\n\t\t{\n\t\t\twhile(N % p == 0) { factors.add((long) p); N /= p; }\n\t\t\tif(primes.size()>idx+1)\n\t\t\tp = primes.get(++idx);\n\t\t\telse\n\t\t\t\tbreak;\n\t\t}\n\n\t\tif(N != 1)\t\t\t\t\t\t// last prime factor may be > sqrt(N)\n\t\t\tfactors.add(N);\t\t\t\t// for integers whose largest prime factor has a power of 1\n\t\treturn factors;\n\t}\n\t\n\tstatic boolean visited[];\n\t/**static int bfs(int s)\n\t{\n\t\tQueue q = new LinkedList();\n\t\tq.add(s);\n\t\tint count=0;\n\t\tint maxcost=0;\n\t\tint dist[]=new int[n];\n\t\tdist[s]=0;\n\t\twhile(!q.isEmpty())\n\t\t{\n\t\t\t\n\t\t\tint u = q.remove();\n\t\t\tif(dist[u]==k) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tfor(Pair v: adj[u])\n\t\t\t{\t\n\t\t\t\tmaxcost=Math.max(maxcost, v.cost);\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\tif(!visited[v.v])\t{\n\t\t\t\t\n\t\t\t\tvisited[v.v]=true;\n\t\t\t\tq.add(v.v);\n\t\t\t\tdist[v.v]=dist[u]+1;\n\t\t\t\tmaxcost=Math.max(maxcost, v.cost);\n\t\t\t}\n\t\t\t}\t\n\t\t\t\n\t\t}\n\t\treturn maxcost;\n\t}**/\n\tpublic static boolean FindAllElements(int n, int k) {\n\t int sum = k; \n int[] A = new int[k]; \n Arrays.fill(A, 0, k, 1); \n \n for (int i = k - 1; i >= 0; --i) { \n \n while (sum + A[i] <= n) { \n \n sum += A[i]; \n A[i] *= 2; \n } \n } \n if(sum==n) {\n \treturn true;\n }\n else\n \treturn false; \n\t}\n\t\n\n\t\n\tstatic boolean vis2[][];\n\t\n\t\n\tstatic boolean f2=false;\n\tstatic long[][] matMul(long[][] a2, long[][] b, int p, int q, int r)\t//C(p x r) = A(p x q) x (q x r) -- O(p x q x r)\n\t{\n\t\tlong[][] C = new long[p][r];\n\t\tfor(int i = 0; i < p; ++i) {\n\t\t\tfor(int j = 0; j < r; ++j) {\n\t\t\t\tfor(int k = 0; k < q; ++k) {\n\t\t\t\t\tC[i][j] = (C[i][j]+(a2[i][k]%mod * b[k][j]%mod))%mod;\n\t\t C[i][j]%=mod;\n\t\t\t\t}\n\t\t\n\t\t\t}\n\t\t}\n\t\treturn C;\n\t}\n\t\t\n\t\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\n\t\t\n\t\n\tstatic ArrayList a1[];\n\tstatic int memo1[];\n\t\n\tstatic boolean vis[];\n\tstatic TreeSet set=new TreeSet();\n\t\n\tstatic long modPow(long ways, long count, long mod)\t// O(log e)\n\t{\n\t\tways %= mod;\n\t\tlong res = 1;\n\t\twhile(count > 0)\n\t\t{\n\t\t\tif((count & 1) == 1)\n\t\t\t\tres = (res * ways) % mod;\n\t\t\tways = (ways * ways) % mod;\n\t\t\tcount >>= 1;\n\t\t}\n\t\treturn res%mod;\n\t}\n\t\n\t\n\t\n\n\tstatic long gcd(long ans,long b) {\n\t\tif(b==0) {\n\t\t\treturn ans;\n\t\t}\n\t\treturn gcd(b,ans%b);\n\t}\n\tstatic int[] isComposite;\n\tstatic int[] valid;\n\t\n\tstatic ArrayList primes;\n\tstatic ArrayList l;\n\tstatic void sieve(int N)\t// O(N log log N) \n\t{\n\t\tisComposite = new int[N+1];\t\t\t\t\t\n\t\tisComposite[0] = isComposite[1] = 1;\t\t\t// 0 indicates a prime number\n\t\tprimes = new ArrayList();\n\t\tl=new ArrayList<>();\n\t\tvalid=new int[N+1];\n\t\tfor (int i = 2; i <= N; ++i) \t\t\t\t\t//can loop till i*i <= N if primes array is not needed O(N log log sqrt(N)) \n\t\t\tif (isComposite[i] == 0) \t\t\t\t\t//can loop in 2 and odd integers for slightly better performance\n\t\t\t{\n\t\t\t\tprimes.add(i);\n\t\t\t\tl.add(i);\n\t\t\t\tvalid[i]=1;\n\t\t\t\t\n\t\t\t\tfor (int j = i*2; j <=N; j +=i) {\t// j = i * 2 will not affect performance too much, may alter in modified sieve\n\t\t\t\t\t\tisComposite[j] = 1;\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t \n\t\t\t\t\t}\n\t\t\t}\n\t\t\n\t\tfor(int i=0 ; iN) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tvalid[primes.get(i)*j]=1;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static int[] schuffle(int[] a2) {\n\t\tfor (int i = 0; i < a2.length; i++) {\n\t\t\tint x=(int)(Math.random()*a2.length);\n\t\tint temp=a2[x];\n\t\ta2[x]=a2[i];\n\t\ta2[i]=temp;\n\t\t}\n\t\treturn a2;\n\t}\n\t\tstatic int V;\n\tstatic long INF=(long) 1E16;\n\t\t\n\t\tstatic class Edge2 \n\t\t{\n\t\t\tint node;\n\t\tlong cost;\n\t\t\tlong next;\n\t\t\tEdge2(int a, int c,Long long1) { node = a;\tcost = long1; next=c;}\n\t\t\t\n\t\t}\nstatic class Scanner {\n\t\tStringTokenizer st;\n\t\tBufferedReader br;\n \n\t\tpublic Scanner(InputStream system) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(system));\n\t\t}\n \n\t\tpublic Scanner(String file) throws Exception {\n\t\t\tbr = new BufferedReader(new FileReader(file));\n\t\t}\n \n\t\tpublic String next() throws IOException {\n\t\t\twhile (st == null || !st.hasMoreTokens())\n\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\treturn st.nextToken();\n\t\t}\n \n\t\tpublic String nextLine() throws IOException {\n\t\t\treturn br.readLine();\n\t\t}\n \n\t\tpublic int nextInt() throws IOException {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n \n\t\tpublic double nextDouble() throws IOException {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n \n\t\tpublic char nextChar() throws IOException {\n\t\t\treturn next().charAt(0);\n\t\t}\n \n\t\tpublic Long nextLong() throws IOException {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n \n\t\tpublic boolean ready() throws IOException {\n\t\t\treturn br.ready();\n\t\t}\n \n\t\tpublic void waitForInput() throws InterruptedException {\n\t\t\tThread.sleep(3000);\n\t\t}\n\t}\t\n}", "language": "Java", "metadata": {"date": 1581487181, "filename_ext": "java", "original_language": "Java7 (OpenJDK 1.7.0)", "problem_description_relpath": "problem_descriptions/p02781.html", "problem_id": "p02781", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02781/input.txt", "sample_output_relpath": "derived/input_output/data/p02781/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02781/Java/s195628405.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s195628405", "user_id": "u962340318"}, "prompt_components": {"gold_output": "19\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.PrintWriter;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.HashMap;\nimport java.util.StringTokenizer;\nimport java.util.TreeSet;\n\nimport java.lang.Integer; \n\npublic class Main {\n\tstatic ArrayListadj[];\n\tstatic PrintWriter out=new PrintWriter(System.out);\n\t public static int mod = 1000000007;\n\n\tstatic int notmemo[][][][];\n\tstatic int k;\n\tstatic int a[];\n\tstatic int b[];\n\tstatic int m;\n\tstatic char c[];\n\t\n\tstatic int trace[];\n\tstatic int h;\n\tstatic int x;\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\ts=sc.nextLine();\n\tc=s.toCharArray();\n\tk=sc.nextInt();\n\tn=c.length;\n\tmemo=new long[c.length+1][k+1][2];\n\tfor (int i = 0; i < c.length+1; i++) {\n\t\tfor (int j = 0; j k) {\n\t\t\treturn 0;\n\t\t}\n\tif(i==n) {\n\t\tif(count==k) {\n\t\t\treturn 1;\n\t\t}\n\t\telse\n\t\treturn 0;\n\t}\n\t\n\tif(memo[i][count][state]!=-1) {\n\t\treturn memo[i][count][state];\n\t}\n\t\n\tlong total=0;\n\tfor (int j = 0; j <10; j++) {\n\t\tif(state==0&&j>Integer.parseInt(\"\"+c[i])) {\n\t\t\tcontinue;\n\t\t}\n\t\t\n\n\t\t\n\t\telse if(state==0&&j==Integer.parseInt(\"\"+c[i])) {\n\t\tif(j==0)\n\t\t\ttotal+=dp(i+1,count,0);\t\n\t\telse\n\t\t\ttotal+=dp(i+1,count+1,0);\t\n\t\t\t\n\t\t}\n\t\telse if(j==0) {\n\t\t\ttotal+=dp(i+1,count,1);\n\t\t}\n\t\telse {\n\t\t\ttotal+=dp(i+1,count+1,1);\t\n\t\t}\n\t}\n\t\n\treturn memo[i][count][state]=total;\n\t\n\t}\n\tstatic boolean f=true;\n\tstatic class SegmentTree {\t\t// 1-based DS, OOP\n\t\tint N; \t\t\t//the number of elements in the array as a power of 2 (i.e. after padding)\n\t\tint[] array, sTree, lazy;\n\t\t\n\t\tSegmentTree(int[] in)\t\t\n\t\t{\n\t\t\tarray = in; N = in.length - 1;\n\t\t\tsTree = new int[N*4];\t\t//no. of nodes = 2*N - 1, we add one to cross out index zero\n\t\t\tlazy = new int[N*4];\n\t\t\t\n\t\t//\tbuild(1,1,N);\n\t\t}\n\t\t\n\t\tvoid build(int node, int b, int e)\t// O(n)\n\t\t{\n\t\t\tif(b == e)\t\t\t\t\t\n\t\t\t\tsTree[node] = array[b];\n\t\t\telse\t\t\t\t\t\t\n\t\t\t{\n\t\t\t\tint mid = b + e >> 1;\n\t\t\t\tbuild(node<<1,b,mid);\n\t\t\t\tbuild(node<<1|1,mid+1,e);\n\t\t\t\tsTree[node] = sTree[node<<1]&sTree[node<<1|1];\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\tvoid update_point(int index, int val)\t\t\t// O(log n)\n\t\t{\n\t\t\tindex += N - 1;\t\t\t\t\n\t\t\tsTree[index] += val;\t\t\t\n\t\t\twhile(index>1)\t\t\t\t\n\t\t\t{\n\t\t\t\tindex >>= 1;\n\t\t\t\tsTree[index] = sTree[index<<1] + sTree[index<<1|1];\t\t\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\tvoid update_range(int i, int j,int val)\t\t// O(log n) \n\t\t{\n\t\t\tupdate_range(1,1,N,i,j,val);\n\t\t}\n\t\t\n\t\tvoid update_range(int node, int b, int e, int i, int j,int val)\n\t\t{\n\t\t\tif(i > e || j < b)\t\t\n\t\t\t\treturn;\n\t\t\tif(b >= i && e <= j)\t\t\n\t\t\t{\n\t\t\t\tsTree[node]|= val;\t\t\t\n\t\t\t\tlazy[node]|=val;\n\t\t\n\t\t\t//LAZY LAZY\n\t\t\t}\t\t\t\t\t\t\t\n\t\t\telse\t\t\n\t\t\t{\n\t\t\t\tint mid = b + e >> 1;\n\t\t\t\tpropagate(node, b, mid, e);\n\t\t\t\tupdate_range(node<<1,b,mid,i,j,val);\n\t\t\t\tupdate_range(node<<1|1,mid+1,e,i,j,val);\n\t\t\t\tsTree[node] = sTree[node<<1]&sTree[node<<1|1];\t\t\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tvoid propagate(int node, int b, int mid, int e)\t\t\n\t\t{\n\n\t\t\tlazy[node<<1] |= lazy[node];\n\t\t\tlazy[(node<<1)|1] |= lazy[node];\n\t\t\tsTree[node<<1] |= lazy[node];\t\t\n\t\t\tsTree[(node<<1)|1] |= lazy[node];\t\t\n\t\t\tlazy[node] = 0;\n\t\t\t\n\t\t}\n\t\t\n\t\tint query(int i, int j)\n\t\t{\n\t\t\treturn query(1,1,N,i,j);\n\t\t}\n\t\t\n\t\tint query(int node, int b, int e, int i, int j)\t// O(log n)\n\t\t{\n\t\t\tif(i>e || j = i && e <= j)\n\t\t\t\treturn sTree[node];\n\t\t\tint mid = b + e >> 1;\n\t\t\tpropagate(node, b, mid, e);\n\t\t\tint q1 = query(node<<1,b,mid,i,j);\n\t\t\tint q2 = query(node<<1|1,mid+1,e,i,j);\n\t\t\treturn q1 &q2;\t\n\t\t\t\t\t\n\t\t}\n\t}\nstatic long memo[][][];\n\n\t\tstatic long nCr1(int n , int k)\n\t{\n\t\tif(n < k)\n\t\t\treturn 0;\n\t\tif(k == 0 || k == n)\n\t\t\treturn 1;\n\t\tif(comb[n][k] != -1)\n\t\t\treturn comb[n][k];\n\t\tif(n - k < k)\n\t\t\treturn comb[n][k] = nCr1(n, n - k);\n\t\treturn comb[n][k] = ((nCr1(n - 1, k - 1)%mod) +( nCr1(n - 1, k)%mod))%mod;\n\t}\n\t\n\t\nstatic class UnionFind { \n\tint[] p, rank, setSize;\n\tint numSets;\n\tint max[];\n\tpublic UnionFind(int N) \n\t{\n\t\tmax=new int[N];\n\t\tp = new int[numSets = N];\n\t\trank = new int[N];\n\t\tsetSize = new int[N];\n\t\tfor (int i = 0; i < N; i++) { p[i] = i; setSize[i] = 1;\n\t\tmax[i]=i;\n\t\t}\n\t}\n\n\tpublic int findSet(int i) { return p[i] == i ? i : (p[i] = findSet(p[i])); }\n\n\tpublic boolean isSameSet(int i, int j) { return findSet(i) == findSet(j); }\n\n\tpublic void unionSet(int i, int j) \n\t{ \n\t\tif (isSameSet(i, j)) \n\t\t\treturn;\n\t\tnumSets--; \n\t\tint x = findSet(i), y = findSet(j);\n\t\tif(rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y];\n\t\tmax[x]=Math.max(max[x], max[y]);\n\t\t\n\t\t}\n\t\telse\n\t\t{\tp[x] = y; setSize[y] += setSize[x];\n\t\t\tif(rank[x] == rank[y]) rank[y]++; \n\t\t\tmax[y]=Math.max(max[x],max[y]);\n\t\t\t\n\t\t} \n\t}\n\n\tprivate int getmax(int j) {\n\treturn max[findSet(j)];\n\t}\n\n\tpublic int numDisjointSets() { return numSets; }\n\n\tpublic int sizeOfSet(int i) { return setSize[findSet(i)]; }\n}\n\n\n\n\n\n\n\n\n\n/**private static void trace(int i, int time) {\nif(i==n) \n\treturn;\n\n\nlong ans=dp(i,time);\nif(time+a[i].t\n{\n\tint a; long b;\n\tint idx;\n\tincpair(int a, long dirg,int i) {this.a = a;\tb = dirg; idx=i; }\n\t\n\tpublic int compareTo(incpair e){ return (int) (b - e.b);\t}\n}\n\tstatic class decpair implements Comparable\n{\n\tint a; long b;int idx;\n\t\n\tdecpair(int a, long dirg,int i) {this.a = a;\tb = dirg; idx=i;}\n\t\n\tpublic int compareTo(decpair e){ return (int) (e.b- b);\t}\n}\n\n\t\n\t\n\t\n\t\n\t\n\t\n\n\n\tstatic long allpowers[];\n\tstatic class Quad implements Comparable{\n\t\tint u;\n\t\tint v;\n\t\tchar state;\n\t\tint turns;\n\t\tpublic Quad(int i, int j, char c, int k) {\n\t\tu=i;\n\t\tv=j;\n\t\tstate=c;\n\t\tturns=k;\n\t\t}\n\t\tpublic int compareTo(Quad e){ return (int) (turns - e.turns);\t}\n\t\t\n\t}\n\tstatic long dirg[][];\n\tstatic Edge[] driver;\n\t\n\tstatic int n;\n\t\tstatic class Edge implements Comparable\n\t{\n\t\tint node; long cost;\n\t\t\n\t\tEdge(int a, long dirg) { node = a;\tcost = dirg; }\n\t\t\n\t\tpublic int compareTo(Edge e){ return (int) (cost - e.cost);\t}\n\t}\n\n\t\n\n\n\n\t static long manhatandistance(long x,long x2,long y,long y2) {\n\t\t return Math.abs(x-x2)+Math.abs(y-y2);\n\t }\n\t static long fib[];\n\t static long fib(int n) {\n\t\t if(n==1||n==0) {\n\t\t\t return 1;\n\t\t }\n\t\t if(fib[n]!=-1) {\n\t\t\t return fib[n];\n\t\t }\n\t\t else \n\t\t\t return fib[n]= ((fib(n-2)%mod+fib(n-1)%mod)%mod);\n\t }\n\t static class Pair {\n\t\t\tint a, b;\n\t \n\t\t\tPair(int x, int y) {\n\t\t\t\ta = x;\n\t\t\t\tb = y;\n\t\t\t}\n\t \n\t\t\t\n\t\t}\n\t\t \n\t\n\t\t\n\t\t\n\tstatic long[][] comb;\t\t\n\t\n\t\n\t\nstatic class Triple implements Comparable{\n\nint l;\nint r;\nlong cost;\nint idx;\n\t\tpublic Triple(int a,int b,long l1,int l2) {\n\t\t\tl=a;\n\t\t\tr=b;\n\t\t\tcost=l1;\n\t\t\tidx=l2;\n\t\t}\n\t\tpublic int compareTo(Triple x)\n\t\t{\n\t\t\tif(l!=x.l || idx==x.idx)\n\t\t\t\treturn l-x.l;\n\t\t\treturn -idx;\n\t\t}\n\t\t\n\t\t\n\t}\n\t\n\tstatic TreeSet primeFactors(long N)\t\t// O(sqrt(N) / ln sqrt(N))\n\t{\n\t\tTreeSet factors = new TreeSet();\t\t//take abs(N) in case of -ve integers\n\t\tint idx = 0, p = primes.get(idx);\n\n\t\twhile(p * p <= N)\n\t\t{\n\t\t\twhile(N % p == 0) { factors.add((long) p); N /= p; }\n\t\t\tif(primes.size()>idx+1)\n\t\t\tp = primes.get(++idx);\n\t\t\telse\n\t\t\t\tbreak;\n\t\t}\n\n\t\tif(N != 1)\t\t\t\t\t\t// last prime factor may be > sqrt(N)\n\t\t\tfactors.add(N);\t\t\t\t// for integers whose largest prime factor has a power of 1\n\t\treturn factors;\n\t}\n\t\n\tstatic boolean visited[];\n\t/**static int bfs(int s)\n\t{\n\t\tQueue q = new LinkedList();\n\t\tq.add(s);\n\t\tint count=0;\n\t\tint maxcost=0;\n\t\tint dist[]=new int[n];\n\t\tdist[s]=0;\n\t\twhile(!q.isEmpty())\n\t\t{\n\t\t\t\n\t\t\tint u = q.remove();\n\t\t\tif(dist[u]==k) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tfor(Pair v: adj[u])\n\t\t\t{\t\n\t\t\t\tmaxcost=Math.max(maxcost, v.cost);\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\tif(!visited[v.v])\t{\n\t\t\t\t\n\t\t\t\tvisited[v.v]=true;\n\t\t\t\tq.add(v.v);\n\t\t\t\tdist[v.v]=dist[u]+1;\n\t\t\t\tmaxcost=Math.max(maxcost, v.cost);\n\t\t\t}\n\t\t\t}\t\n\t\t\t\n\t\t}\n\t\treturn maxcost;\n\t}**/\n\tpublic static boolean FindAllElements(int n, int k) {\n\t int sum = k; \n int[] A = new int[k]; \n Arrays.fill(A, 0, k, 1); \n \n for (int i = k - 1; i >= 0; --i) { \n \n while (sum + A[i] <= n) { \n \n sum += A[i]; \n A[i] *= 2; \n } \n } \n if(sum==n) {\n \treturn true;\n }\n else\n \treturn false; \n\t}\n\t\n\n\t\n\tstatic boolean vis2[][];\n\t\n\t\n\tstatic boolean f2=false;\n\tstatic long[][] matMul(long[][] a2, long[][] b, int p, int q, int r)\t//C(p x r) = A(p x q) x (q x r) -- O(p x q x r)\n\t{\n\t\tlong[][] C = new long[p][r];\n\t\tfor(int i = 0; i < p; ++i) {\n\t\t\tfor(int j = 0; j < r; ++j) {\n\t\t\t\tfor(int k = 0; k < q; ++k) {\n\t\t\t\t\tC[i][j] = (C[i][j]+(a2[i][k]%mod * b[k][j]%mod))%mod;\n\t\t C[i][j]%=mod;\n\t\t\t\t}\n\t\t\n\t\t\t}\n\t\t}\n\t\treturn C;\n\t}\n\t\t\n\t\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\n\t\t\n\t\n\tstatic ArrayList a1[];\n\tstatic int memo1[];\n\t\n\tstatic boolean vis[];\n\tstatic TreeSet set=new TreeSet();\n\t\n\tstatic long modPow(long ways, long count, long mod)\t// O(log e)\n\t{\n\t\tways %= mod;\n\t\tlong res = 1;\n\t\twhile(count > 0)\n\t\t{\n\t\t\tif((count & 1) == 1)\n\t\t\t\tres = (res * ways) % mod;\n\t\t\tways = (ways * ways) % mod;\n\t\t\tcount >>= 1;\n\t\t}\n\t\treturn res%mod;\n\t}\n\t\n\t\n\t\n\n\tstatic long gcd(long ans,long b) {\n\t\tif(b==0) {\n\t\t\treturn ans;\n\t\t}\n\t\treturn gcd(b,ans%b);\n\t}\n\tstatic int[] isComposite;\n\tstatic int[] valid;\n\t\n\tstatic ArrayList primes;\n\tstatic ArrayList l;\n\tstatic void sieve(int N)\t// O(N log log N) \n\t{\n\t\tisComposite = new int[N+1];\t\t\t\t\t\n\t\tisComposite[0] = isComposite[1] = 1;\t\t\t// 0 indicates a prime number\n\t\tprimes = new ArrayList();\n\t\tl=new ArrayList<>();\n\t\tvalid=new int[N+1];\n\t\tfor (int i = 2; i <= N; ++i) \t\t\t\t\t//can loop till i*i <= N if primes array is not needed O(N log log sqrt(N)) \n\t\t\tif (isComposite[i] == 0) \t\t\t\t\t//can loop in 2 and odd integers for slightly better performance\n\t\t\t{\n\t\t\t\tprimes.add(i);\n\t\t\t\tl.add(i);\n\t\t\t\tvalid[i]=1;\n\t\t\t\t\n\t\t\t\tfor (int j = i*2; j <=N; j +=i) {\t// j = i * 2 will not affect performance too much, may alter in modified sieve\n\t\t\t\t\t\tisComposite[j] = 1;\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t \n\t\t\t\t\t}\n\t\t\t}\n\t\t\n\t\tfor(int i=0 ; iN) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tvalid[primes.get(i)*j]=1;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static int[] schuffle(int[] a2) {\n\t\tfor (int i = 0; i < a2.length; i++) {\n\t\t\tint x=(int)(Math.random()*a2.length);\n\t\tint temp=a2[x];\n\t\ta2[x]=a2[i];\n\t\ta2[i]=temp;\n\t\t}\n\t\treturn a2;\n\t}\n\t\tstatic int V;\n\tstatic long INF=(long) 1E16;\n\t\t\n\t\tstatic class Edge2 \n\t\t{\n\t\t\tint node;\n\t\tlong cost;\n\t\t\tlong next;\n\t\t\tEdge2(int a, int c,Long long1) { node = a;\tcost = long1; next=c;}\n\t\t\t\n\t\t}\nstatic class Scanner {\n\t\tStringTokenizer st;\n\t\tBufferedReader br;\n \n\t\tpublic Scanner(InputStream system) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(system));\n\t\t}\n \n\t\tpublic Scanner(String file) throws Exception {\n\t\t\tbr = new BufferedReader(new FileReader(file));\n\t\t}\n \n\t\tpublic String next() throws IOException {\n\t\t\twhile (st == null || !st.hasMoreTokens())\n\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\treturn st.nextToken();\n\t\t}\n \n\t\tpublic String nextLine() throws IOException {\n\t\t\treturn br.readLine();\n\t\t}\n \n\t\tpublic int nextInt() throws IOException {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n \n\t\tpublic double nextDouble() throws IOException {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n \n\t\tpublic char nextChar() throws IOException {\n\t\t\treturn next().charAt(0);\n\t\t}\n \n\t\tpublic Long nextLong() throws IOException {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n \n\t\tpublic boolean ready() throws IOException {\n\t\t\treturn br.ready();\n\t\t}\n \n\t\tpublic void waitForInput() throws InterruptedException {\n\t\t\tThread.sleep(3000);\n\t\t}\n\t}\t\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nFind the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.\n\nConstraints\n\n1 \\leq N < 10^{100}\n\n1 \\leq K \\leq 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nK\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n100\n1\n\nSample Output 1\n\n19\n\nThe following 19 integers satisfy the condition:\n\n1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100\n\nSample Input 2\n\n25\n2\n\nSample Output 2\n\n14\n\nThe following 14 integers satisfy the condition:\n\n11,12,13,14,15,16,17,18,19,21,22,23,24,25\n\nSample Input 3\n\n314159\n2\n\nSample Output 3\n\n937\n\nSample Input 4\n\n9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n3\n\nSample Output 4\n\n117879300", "sample_input": "100\n1\n"}, "reference_outputs": ["19\n"], "source_document_id": "p02781", "source_text": "Score : 500 points\n\nProblem Statement\n\nFind the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.\n\nConstraints\n\n1 \\leq N < 10^{100}\n\n1 \\leq K \\leq 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nK\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n100\n1\n\nSample Output 1\n\n19\n\nThe following 19 integers satisfy the condition:\n\n1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100\n\nSample Input 2\n\n25\n2\n\nSample Output 2\n\n14\n\nThe following 14 integers satisfy the condition:\n\n11,12,13,14,15,16,17,18,19,21,22,23,24,25\n\nSample Input 3\n\n314159\n2\n\nSample Output 3\n\n937\n\nSample Input 4\n\n9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n3\n\nSample Output 4\n\n117879300", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 12005, "cpu_time_ms": 79, "memory_kb": 22740}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s641060377", "group_id": "codeNet:p02783", "input_text": "import java.util.*;\n\nclass Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n \n int h = sc.nextInt();\n int a = sc.nextInt();\n \n int result = h / a;\n if (h%a>0) {\n result ++;\n }\n \n System.out.println(result);\n \n }\n}", "language": "Java", "metadata": {"date": 1580069153, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02783.html", "problem_id": "p02783", "resource_group": "high_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/Java/s641060377.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s641060377", "user_id": "u844731782"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*;\n\nclass Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n \n int h = sc.nextInt();\n int a = sc.nextInt();\n \n int result = h / a;\n if (h%a>0) {\n result ++;\n }\n \n System.out.println(result);\n \n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nServal is fighting with a monster.\n\nThe health of the monster is H.\n\nIn one attack, Serval can decrease the monster's health by A.\nThere is no other way to decrease the monster's health.\n\nServal wins when the monster's health becomes 0 or below.\n\nFind the number of attacks Serval needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^4\n\n1 \\leq A \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH A\n\nOutput\n\nPrint the number of attacks Serval needs to make before winning.\n\nSample Input 1\n\n10 4\n\nSample Output 1\n\n3\n\nAfter one attack, the monster's health will be 6.\n\nAfter two attacks, the monster's health will be 2.\n\nAfter three attacks, the monster's health will be -2.\n\nThus, Serval needs to make three attacks to win.\n\nSample Input 2\n\n1 10000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n10000 1\n\nSample Output 3\n\n10000", "sample_input": "10 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02783", "source_text": "Score : 100 points\n\nProblem Statement\n\nServal is fighting with a monster.\n\nThe health of the monster is H.\n\nIn one attack, Serval can decrease the monster's health by A.\nThere is no other way to decrease the monster's health.\n\nServal wins when the monster's health becomes 0 or below.\n\nFind the number of attacks Serval needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^4\n\n1 \\leq A \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH A\n\nOutput\n\nPrint the number of attacks Serval needs to make before winning.\n\nSample Input 1\n\n10 4\n\nSample Output 1\n\n3\n\nAfter one attack, the monster's health will be 6.\n\nAfter two attacks, the monster's health will be 2.\n\nAfter three attacks, the monster's health will be -2.\n\nThus, Serval needs to make three attacks to win.\n\nSample Input 2\n\n1 10000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n10000 1\n\nSample Output 3\n\n10000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 291, "cpu_time_ms": 116, "memory_kb": 22868}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s302902080", "group_id": "codeNet:p02784", "input_text": "import java.util.Scanner;\n\npublic class Main{\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint num1 = scan.nextInt();\n\t\tint num2 = scan.nextInt();\n\t\tint i;\n\t\tint sum = 0;\n\t\t\n\t\tfor(i = 0 ; i < num2 ; i++) {\n\t\t\tint attack_point = scan.nextInt();\n\t\t\tnum1 -= attack_point;\n\t\t}\n\t\tscan.close();\n\t\tif(num1 > 0) {\n\t\t\tSystem.out.println(\"NO\");\n\t\t}\n\t\telse System.out.println(\"YES\");\n\t}\n}", "language": "Java", "metadata": {"date": 1581789909, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02784.html", "problem_id": "p02784", "resource_group": "high_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/Java/s302902080.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s302902080", "user_id": "u444828107"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main{\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint num1 = scan.nextInt();\n\t\tint num2 = scan.nextInt();\n\t\tint i;\n\t\tint sum = 0;\n\t\t\n\t\tfor(i = 0 ; i < num2 ; i++) {\n\t\t\tint attack_point = scan.nextInt();\n\t\t\tnum1 -= attack_point;\n\t\t}\n\t\tscan.close();\n\t\tif(num1 > 0) {\n\t\t\tSystem.out.println(\"NO\");\n\t\t}\n\t\telse System.out.println(\"YES\");\n\t}\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": 417, "cpu_time_ms": 438, "memory_kb": 49980}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s301107535", "group_id": "codeNet:p02784", "input_text": "import java.io.PrintWriter;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Scanner;\nimport java.util.function.Supplier;\n\npublic class Main {\n\n static void solve() {\n int h = nextInt();\n int n = nextInt();\n\n int sum = 0;\n for (int i = 0; i < n; i++) {\n int a = nextInt();\n sum += a;\n }\n if (sum >= h)\n out.println(\"Yes\");\n else\n out.println(\"No\");\n\n }\n\n static final int MOD = 1_000_000_007;\n static long[] fac, finv, inv;\n\n // 階乗(n!)\n static long factorial(long n) {\n long ans = 1;\n for (long i = n; i > 0; i--) {\n ans = ans * i % MOD;\n }\n return ans;\n }\n\n // nCkの初期化\n static void comInit(int max) {\n fac = new long[max];\n finv = new long[max];\n inv = new long[max];\n fac[0] = fac[1] = 1;\n finv[0] = finv[1] = 1;\n inv[1] = 1;\n\n for (int i = 2; i < max; i++) {\n fac[i] = fac[i - 1] * i % MOD;\n inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;\n finv[i] = finv[i - 1] * inv[i] % MOD;\n }\n }\n\n // nCkの計算\n static long com(int n, int k) {\n if (n < k)\n return 0;\n if (n < 0 || k < 0)\n return 0;\n return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;\n }\n\n static Map> primeFactors = new HashMap<>();\n\n // 素因数分解\n static List primeFactorize(int n) {\n if (primeFactors.containsKey(n))\n return primeFactors.get(n);\n\n List list = new ArrayList<>();\n if (n % 2 == 0) {\n list.addAll(primeFactorize(n / 2));\n list.add(2);\n } else {\n boolean ok = true;\n for (int j = 3; j * j <= n; j += 2) {\n if (n % j == 0) {\n list.addAll(primeFactorize(n / j));\n list.addAll(primeFactorize(j));\n ok = false;\n break;\n }\n }\n if (ok) {\n if (n != 1)\n list.add(n);\n }\n }\n\n primeFactors.put(n, Collections.unmodifiableList(list));\n return list;\n }\n\n // 2〜nまでの数値を素因数分解したmapを返す.\n // map: 数値 -> (素因数)\n // ex)\n // 2 -> (2)\n // 4 -> (2,2)\n // 12 -> (2,2,3)\n @Deprecated // primeFactorizeを使うべき\n static Map> primeFactorizeTo(int n) {\n Map> map = new HashMap<>();\n for (int i = 2; i <= n; i++) {\n List list = new ArrayList<>();\n int tmp = i;\n for (int j = i - 1; j > 1; j--) {\n if (tmp % j == 0) {\n if (map.containsKey(j)) {\n list.addAll(map.get(j));\n } else {\n list.add(j);\n }\n tmp /= j;\n }\n }\n if (tmp != 1)\n list.add(tmp);\n map.put(i, list);\n }\n return map;\n }\n\n static PrintWriter out;\n static Scanner sc;\n static boolean debugEnabled;\n static long start;\n static long end;\n\n static int[][] newIntArray(int h, int w, int value) {\n int[][] ret = new int[h][w];\n for (int i = 0; i < h; i++) {\n for (int j = 0; j < w; j++) {\n ret[i][j] = value;\n }\n }\n return ret;\n }\n\n static int nextInt() {\n return Integer.parseInt(sc.next());\n }\n\n static long nextLong() {\n return Long.parseLong(sc.next());\n }\n\n static String nextString() {\n return sc.next();\n }\n\n static int[] nextIntArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = nextInt();\n }\n return a;\n }\n\n static long[] nextLongArray(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++) {\n a[i] = nextLong();\n }\n return a;\n }\n\n static List nextIntList(int n) {\n List list = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n list.add(nextInt());\n }\n return list;\n }\n\n static List nextDoubleList(int n) {\n List list = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n list.add((double) nextInt());\n }\n return list;\n }\n\n static List nextLongList(int n) {\n List list = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n list.add(nextLong());\n }\n return list;\n }\n\n static char[][] nextCharArray(int h, int w) {\n char[][] c = new char[h][w];\n for (int i = 0; i < h; i++) {\n String str = nextString();\n for (int j = 0; j < w; j++) {\n c[i][j] = str.charAt(j);\n }\n }\n return c;\n }\n\n // 昇順\n static > List sort(List list) {\n return sortAsc(list);\n }\n\n // 昇順\n static > List sortAsc(List list) {\n Collections.sort(list);\n return list;\n }\n\n // 降順\n static > List sortDesc(List list) {\n Collections.sort(list, (e1, e2) -> e2.compareTo(e1));\n return list;\n }\n\n // greatest common divisor\n // 最大公約数\n static long gcd(long a, long b) {\n if (b == 0) {\n return a;\n }\n return gcd(b, a % b);\n }\n\n // least common multiple\n // 最小公倍数\n static long lcm(long a, long b) {\n if (a > b) {\n return (a / gcd(a, b)) * b;\n } else {\n return (b / gcd(a, b)) * a;\n }\n }\n\n // least common multiple\n // 最小公倍数\n // 素因数分解されたListを引数とした場合\n static List lcm(List a, List b) {\n List ret = new ArrayList<>(a);\n List tmp = new ArrayList<>(b);\n for (Integer i : a) {\n if (tmp.contains(i))\n tmp.remove(i);\n }\n ret.addAll(tmp);\n return ret;\n }\n\n // baseのn乗を計算を返す\n static int pow(int base, int n) {\n int ret = 1;\n for (int i = 0; i < n; i++) {\n ret *= base;\n }\n return ret;\n }\n\n // return n^k mod m\n static long powMod(long n, long k, long m) {\n if (k == 0) {\n return 1;\n } else if (k % 2 == 1) {\n return powMod(n, k - 1, m) * n % m;\n } else {\n long tmp = powMod(n, k / 2, m);\n return tmp * tmp % m;\n }\n }\n\n // intをlength桁のbit文字列に変換\n static String toBitString(int length, int n) {\n StringBuilder sb = new StringBuilder();\n for (int i = length - 1; i >= 0; i--) {\n if ((n >> i) % 2 == 1) {\n sb.append(\"1\");\n } else {\n sb.append(\"0\");\n }\n }\n return sb.toString();\n }\n\n static void setDebugEnabled() {\n String className = new Object() {\n }.getClass().getEnclosingClass().getSimpleName();\n\n if (!className.equals(\"Main\"))\n debugEnabled = true;\n }\n\n static void debug(String msg) {\n if (debugEnabled)\n System.err.println(msg);\n }\n\n static void debug(Supplier msg) {\n if (debugEnabled)\n System.err.println(msg.get());\n }\n\n static class UnionFind {\n int[] parent;\n\n UnionFind(int n) {\n parent = new int[n];\n init();\n }\n\n void init() {\n for (int i = 0; i < parent.length; i++) {\n parent[i] = i;\n }\n }\n\n int getRoot(int i) {\n if (parent[i] == i) {\n return i;\n } else {\n return parent[i] = getRoot(parent[i]);\n }\n }\n\n boolean isSame(int x, int y) {\n return getRoot(x) == getRoot(y);\n }\n\n void unit(int x, int y) {\n x = getRoot(x);\n y = getRoot(y);\n if (x != y) {\n parent[x] = y;\n }\n\n }\n }\n\n public static void main(String[] args) {\n preProcess();\n // System.exit(0)で終了した場合も、解答を出力するためにはshutdown hookの設定が必要\n // しかし、これを有効化すると100[msec]程度処理時間が長くなる\n // Runtime.getRuntime().addShutdownHook(new Thread(() -> postProcess()));\n solve();\n postProcess();\n }\n\n static void preProcess() {\n start = System.nanoTime();\n setDebugEnabled();\n out = new PrintWriter(System.out);\n sc = new Scanner(System.in);\n }\n\n static void postProcess() {\n out.flush();\n sc.close();\n end = System.nanoTime();\n debug(() -> \"elapsed time: \" + (end - start) / 1_000_000 + \"[msec]\");\n }\n\n}\n", "language": "Java", "metadata": {"date": 1580069038, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02784.html", "problem_id": "p02784", "resource_group": "high_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/Java/s301107535.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s301107535", "user_id": "u752146446"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.PrintWriter;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Scanner;\nimport java.util.function.Supplier;\n\npublic class Main {\n\n static void solve() {\n int h = nextInt();\n int n = nextInt();\n\n int sum = 0;\n for (int i = 0; i < n; i++) {\n int a = nextInt();\n sum += a;\n }\n if (sum >= h)\n out.println(\"Yes\");\n else\n out.println(\"No\");\n\n }\n\n static final int MOD = 1_000_000_007;\n static long[] fac, finv, inv;\n\n // 階乗(n!)\n static long factorial(long n) {\n long ans = 1;\n for (long i = n; i > 0; i--) {\n ans = ans * i % MOD;\n }\n return ans;\n }\n\n // nCkの初期化\n static void comInit(int max) {\n fac = new long[max];\n finv = new long[max];\n inv = new long[max];\n fac[0] = fac[1] = 1;\n finv[0] = finv[1] = 1;\n inv[1] = 1;\n\n for (int i = 2; i < max; i++) {\n fac[i] = fac[i - 1] * i % MOD;\n inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;\n finv[i] = finv[i - 1] * inv[i] % MOD;\n }\n }\n\n // nCkの計算\n static long com(int n, int k) {\n if (n < k)\n return 0;\n if (n < 0 || k < 0)\n return 0;\n return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;\n }\n\n static Map> primeFactors = new HashMap<>();\n\n // 素因数分解\n static List primeFactorize(int n) {\n if (primeFactors.containsKey(n))\n return primeFactors.get(n);\n\n List list = new ArrayList<>();\n if (n % 2 == 0) {\n list.addAll(primeFactorize(n / 2));\n list.add(2);\n } else {\n boolean ok = true;\n for (int j = 3; j * j <= n; j += 2) {\n if (n % j == 0) {\n list.addAll(primeFactorize(n / j));\n list.addAll(primeFactorize(j));\n ok = false;\n break;\n }\n }\n if (ok) {\n if (n != 1)\n list.add(n);\n }\n }\n\n primeFactors.put(n, Collections.unmodifiableList(list));\n return list;\n }\n\n // 2〜nまでの数値を素因数分解したmapを返す.\n // map: 数値 -> (素因数)\n // ex)\n // 2 -> (2)\n // 4 -> (2,2)\n // 12 -> (2,2,3)\n @Deprecated // primeFactorizeを使うべき\n static Map> primeFactorizeTo(int n) {\n Map> map = new HashMap<>();\n for (int i = 2; i <= n; i++) {\n List list = new ArrayList<>();\n int tmp = i;\n for (int j = i - 1; j > 1; j--) {\n if (tmp % j == 0) {\n if (map.containsKey(j)) {\n list.addAll(map.get(j));\n } else {\n list.add(j);\n }\n tmp /= j;\n }\n }\n if (tmp != 1)\n list.add(tmp);\n map.put(i, list);\n }\n return map;\n }\n\n static PrintWriter out;\n static Scanner sc;\n static boolean debugEnabled;\n static long start;\n static long end;\n\n static int[][] newIntArray(int h, int w, int value) {\n int[][] ret = new int[h][w];\n for (int i = 0; i < h; i++) {\n for (int j = 0; j < w; j++) {\n ret[i][j] = value;\n }\n }\n return ret;\n }\n\n static int nextInt() {\n return Integer.parseInt(sc.next());\n }\n\n static long nextLong() {\n return Long.parseLong(sc.next());\n }\n\n static String nextString() {\n return sc.next();\n }\n\n static int[] nextIntArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = nextInt();\n }\n return a;\n }\n\n static long[] nextLongArray(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++) {\n a[i] = nextLong();\n }\n return a;\n }\n\n static List nextIntList(int n) {\n List list = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n list.add(nextInt());\n }\n return list;\n }\n\n static List nextDoubleList(int n) {\n List list = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n list.add((double) nextInt());\n }\n return list;\n }\n\n static List nextLongList(int n) {\n List list = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n list.add(nextLong());\n }\n return list;\n }\n\n static char[][] nextCharArray(int h, int w) {\n char[][] c = new char[h][w];\n for (int i = 0; i < h; i++) {\n String str = nextString();\n for (int j = 0; j < w; j++) {\n c[i][j] = str.charAt(j);\n }\n }\n return c;\n }\n\n // 昇順\n static > List sort(List list) {\n return sortAsc(list);\n }\n\n // 昇順\n static > List sortAsc(List list) {\n Collections.sort(list);\n return list;\n }\n\n // 降順\n static > List sortDesc(List list) {\n Collections.sort(list, (e1, e2) -> e2.compareTo(e1));\n return list;\n }\n\n // greatest common divisor\n // 最大公約数\n static long gcd(long a, long b) {\n if (b == 0) {\n return a;\n }\n return gcd(b, a % b);\n }\n\n // least common multiple\n // 最小公倍数\n static long lcm(long a, long b) {\n if (a > b) {\n return (a / gcd(a, b)) * b;\n } else {\n return (b / gcd(a, b)) * a;\n }\n }\n\n // least common multiple\n // 最小公倍数\n // 素因数分解されたListを引数とした場合\n static List lcm(List a, List b) {\n List ret = new ArrayList<>(a);\n List tmp = new ArrayList<>(b);\n for (Integer i : a) {\n if (tmp.contains(i))\n tmp.remove(i);\n }\n ret.addAll(tmp);\n return ret;\n }\n\n // baseのn乗を計算を返す\n static int pow(int base, int n) {\n int ret = 1;\n for (int i = 0; i < n; i++) {\n ret *= base;\n }\n return ret;\n }\n\n // return n^k mod m\n static long powMod(long n, long k, long m) {\n if (k == 0) {\n return 1;\n } else if (k % 2 == 1) {\n return powMod(n, k - 1, m) * n % m;\n } else {\n long tmp = powMod(n, k / 2, m);\n return tmp * tmp % m;\n }\n }\n\n // intをlength桁のbit文字列に変換\n static String toBitString(int length, int n) {\n StringBuilder sb = new StringBuilder();\n for (int i = length - 1; i >= 0; i--) {\n if ((n >> i) % 2 == 1) {\n sb.append(\"1\");\n } else {\n sb.append(\"0\");\n }\n }\n return sb.toString();\n }\n\n static void setDebugEnabled() {\n String className = new Object() {\n }.getClass().getEnclosingClass().getSimpleName();\n\n if (!className.equals(\"Main\"))\n debugEnabled = true;\n }\n\n static void debug(String msg) {\n if (debugEnabled)\n System.err.println(msg);\n }\n\n static void debug(Supplier msg) {\n if (debugEnabled)\n System.err.println(msg.get());\n }\n\n static class UnionFind {\n int[] parent;\n\n UnionFind(int n) {\n parent = new int[n];\n init();\n }\n\n void init() {\n for (int i = 0; i < parent.length; i++) {\n parent[i] = i;\n }\n }\n\n int getRoot(int i) {\n if (parent[i] == i) {\n return i;\n } else {\n return parent[i] = getRoot(parent[i]);\n }\n }\n\n boolean isSame(int x, int y) {\n return getRoot(x) == getRoot(y);\n }\n\n void unit(int x, int y) {\n x = getRoot(x);\n y = getRoot(y);\n if (x != y) {\n parent[x] = y;\n }\n\n }\n }\n\n public static void main(String[] args) {\n preProcess();\n // System.exit(0)で終了した場合も、解答を出力するためにはshutdown hookの設定が必要\n // しかし、これを有効化すると100[msec]程度処理時間が長くなる\n // Runtime.getRuntime().addShutdownHook(new Thread(() -> postProcess()));\n solve();\n postProcess();\n }\n\n static void preProcess() {\n start = System.nanoTime();\n setDebugEnabled();\n out = new PrintWriter(System.out);\n sc = new Scanner(System.in);\n }\n\n static void postProcess() {\n out.flush();\n sc.close();\n end = System.nanoTime();\n debug(() -> \"elapsed time: \" + (end - start) / 1_000_000 + \"[msec]\");\n }\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": 9285, "cpu_time_ms": 488, "memory_kb": 46476}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s851941258", "group_id": "codeNet:p02784", "input_text": "import java.util.*;\nimport java.io.*;\nimport java.math.*;\n \npublic class Main {\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int h = sc.nextInt();\n int n = sc.nextInt();\n int atk = 0;\n for(int i = 0; i < n; i++){\n atk += sc.nextInt();\n }\n if(atk >= h){\n System.out.println(\"Yes\");\n }else{\n System.out.println(\"No\");\n }\n }\n}\n ", "language": "Java", "metadata": {"date": 1580069014, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02784.html", "problem_id": "p02784", "resource_group": "high_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/Java/s851941258.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s851941258", "user_id": "u072631296"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\nimport java.math.*;\n \npublic class Main {\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int h = sc.nextInt();\n int n = sc.nextInt();\n int atk = 0;\n for(int i = 0; i < n; i++){\n atk += sc.nextInt();\n }\n if(atk >= h){\n System.out.println(\"Yes\");\n }else{\n System.out.println(\"No\");\n }\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": 480, "cpu_time_ms": 414, "memory_kb": 48584}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s257895796", "group_id": "codeNet:p02786", "input_text": "import java.util.*;\n\nclass Main {\n static long[] memo;\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n long H = sc.nextLong();\n int N = (int)H;\n int count = 0;\n memo = new long[N*2];\n memo[0] = 0;\n memo[1] = 1;\n while(H != 0) {\n H = H/2;\n count++;\n }\n long ans = calc(count);\n int sum = 0;\n for(int i=0; i<=count; i++) {\n sum += memo[i];\n }\n System.out.println(sum);\n }\n public static long calc(int n){\n //memo[n]が0じゃなければreturn\n if (memo[n] != 0) return memo[n];\n //memo[n]が0だった場合は以下の処理\n if (n == 0) return 0;\n if (n == 1) return 1;\n long ans = 0;\n ans += calc(n-1) + calc(n-1);\n //呼び直しを起こさないようmemo[n]に値を格納\n memo[n] = ans;\n return ans;\n }\n}", "language": "Java", "metadata": {"date": 1580074409, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02786.html", "problem_id": "p02786", "resource_group": "high_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/Java/s257895796.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s257895796", "user_id": "u899530879"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*;\n\nclass Main {\n static long[] memo;\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n long H = sc.nextLong();\n int N = (int)H;\n int count = 0;\n memo = new long[N*2];\n memo[0] = 0;\n memo[1] = 1;\n while(H != 0) {\n H = H/2;\n count++;\n }\n long ans = calc(count);\n int sum = 0;\n for(int i=0; i<=count; i++) {\n sum += memo[i];\n }\n System.out.println(sum);\n }\n public static long calc(int n){\n //memo[n]が0じゃなければreturn\n if (memo[n] != 0) return memo[n];\n //memo[n]が0だった場合は以下の処理\n if (n == 0) return 0;\n if (n == 1) return 1;\n long ans = 0;\n ans += calc(n-1) + calc(n-1);\n //呼び直しを起こさないようmemo[n]に値を格納\n memo[n] = ans;\n return ans;\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": 961, "cpu_time_ms": 110, "memory_kb": 42708}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s653145443", "group_id": "codeNet:p02789", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint m = sc.nextInt();\n\t\t\n\t\tif (n == m) {\n\t\t\tSystem.out.println(\"Yes\");\n\t\t} else {\n\t\t\tSystem.out.println(\"No\");\n\t\t}\n\t\t\n\t}\n}\n", "language": "Java", "metadata": {"date": 1579547262, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02789.html", "problem_id": "p02789", "resource_group": "high_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/Java/s653145443.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s653145443", "user_id": "u395242880"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint m = sc.nextInt();\n\t\t\n\t\tif (n == m) {\n\t\t\tSystem.out.println(\"Yes\");\n\t\t} else {\n\t\t\tSystem.out.println(\"No\");\n\t\t}\n\t\t\n\t}\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": 285, "cpu_time_ms": 97, "memory_kb": 21716}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s267627621", "group_id": "codeNet:p02790", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.io.BufferedWriter;\nimport java.io.Writer;\nimport java.io.OutputStreamWriter;\nimport java.util.InputMismatchException;\nimport java.io.IOException;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author Mufaddal Naya\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n OutputWriter out = new OutputWriter(outputStream);\n BComparingStrings solver = new BComparingStrings();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class BComparingStrings {\n public void solve(int testNumber, InputReader c, OutputWriter w) {\n int a = c.readInt(), b = c.readInt();\n String s1 = \"\", s2 = \"\";\n for (int i = 0; i < b; i++) {\n s1 += a;\n }\n for (int j = 0; j < a; j++) {\n s2 += b;\n }\n// w.printLine(s1,s2);\n// w.printLine(s1.compareTo(s2));\n if (s1.compareTo(s2) > 0) {\n w.printLine(s2);\n } else {\n w.printLine(s1);\n }\n }\n\n }\n\n static class OutputWriter {\n private final PrintWriter writer;\n\n public OutputWriter(OutputStream outputStream) {\n writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));\n }\n\n public OutputWriter(Writer writer) {\n this.writer = new PrintWriter(writer);\n }\n\n public void print(Object... objects) {\n for (int i = 0; i < objects.length; i++) {\n if (i != 0) {\n writer.print(' ');\n }\n writer.print(objects[i]);\n }\n }\n\n public void printLine(Object... objects) {\n print(objects);\n writer.println();\n }\n\n public void close() {\n writer.close();\n }\n\n }\n\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private InputReader.SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n\n public int read() {\n if (numChars == -1) {\n throw new InputMismatchException();\n }\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0) {\n return -1;\n }\n }\n return buf[curChar++];\n }\n\n public int readInt() {\n int c = read();\n while (isSpaceChar(c)) {\n c = read();\n }\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n res *= 10;\n res += c - '0';\n c = read();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n\n public boolean isSpaceChar(int c) {\n if (filter != null) {\n return filter.isSpaceChar(c);\n }\n return isWhitespace(c);\n }\n\n public static boolean isWhitespace(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1579463801, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02790.html", "problem_id": "p02790", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02790/input.txt", "sample_output_relpath": "derived/input_output/data/p02790/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02790/Java/s267627621.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s267627621", "user_id": "u768031280"}, "prompt_components": {"gold_output": "3333\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.io.BufferedWriter;\nimport java.io.Writer;\nimport java.io.OutputStreamWriter;\nimport java.util.InputMismatchException;\nimport java.io.IOException;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author Mufaddal Naya\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n OutputWriter out = new OutputWriter(outputStream);\n BComparingStrings solver = new BComparingStrings();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class BComparingStrings {\n public void solve(int testNumber, InputReader c, OutputWriter w) {\n int a = c.readInt(), b = c.readInt();\n String s1 = \"\", s2 = \"\";\n for (int i = 0; i < b; i++) {\n s1 += a;\n }\n for (int j = 0; j < a; j++) {\n s2 += b;\n }\n// w.printLine(s1,s2);\n// w.printLine(s1.compareTo(s2));\n if (s1.compareTo(s2) > 0) {\n w.printLine(s2);\n } else {\n w.printLine(s1);\n }\n }\n\n }\n\n static class OutputWriter {\n private final PrintWriter writer;\n\n public OutputWriter(OutputStream outputStream) {\n writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));\n }\n\n public OutputWriter(Writer writer) {\n this.writer = new PrintWriter(writer);\n }\n\n public void print(Object... objects) {\n for (int i = 0; i < objects.length; i++) {\n if (i != 0) {\n writer.print(' ');\n }\n writer.print(objects[i]);\n }\n }\n\n public void printLine(Object... objects) {\n print(objects);\n writer.println();\n }\n\n public void close() {\n writer.close();\n }\n\n }\n\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private InputReader.SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n\n public int read() {\n if (numChars == -1) {\n throw new InputMismatchException();\n }\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0) {\n return -1;\n }\n }\n return buf[curChar++];\n }\n\n public int readInt() {\n int c = read();\n while (isSpaceChar(c)) {\n c = read();\n }\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n res *= 10;\n res += c - '0';\n c = read();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n\n public boolean isSpaceChar(int c) {\n if (filter != null) {\n return filter.isSpaceChar(c);\n }\n return isWhitespace(c);\n }\n\n public static boolean isWhitespace(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\n\n }\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?\n\nConstraints\n\n1 \\leq a \\leq 9\n\n1 \\leq b \\leq 9\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint the lexicographically smaller of the two strings. (If the two strings are equal, print one of them.)\n\nSample Input 1\n\n4 3\n\nSample Output 1\n\n3333\n\nWe have two strings 444 and 3333. Between them, 3333 is the lexicographically smaller.\n\nSample Input 2\n\n7 7\n\nSample Output 2\n\n7777777", "sample_input": "4 3\n"}, "reference_outputs": ["3333\n"], "source_document_id": "p02790", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?\n\nConstraints\n\n1 \\leq a \\leq 9\n\n1 \\leq b \\leq 9\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint the lexicographically smaller of the two strings. (If the two strings are equal, print one of them.)\n\nSample Input 1\n\n4 3\n\nSample Output 1\n\n3333\n\nWe have two strings 444 and 3333. Between them, 3333 is the lexicographically smaller.\n\nSample Input 2\n\n7 7\n\nSample Output 2\n\n7777777", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4082, "cpu_time_ms": 71, "memory_kb": 20692}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s900276690", "group_id": "codeNet:p02793", "input_text": "import java.io.*;\nimport java.math.*;\nimport java.util.*;\nimport java.lang.*;\n\npublic class Main implements Runnable {\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private SpaceCharFilter filter;\n private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n\n public int read() {\n if (numChars == -1)\n throw new InputMismatchException();\n\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }\n\n public String nextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }\n\n public int nextInt() {\n int c = read();\n\n while (isSpaceChar(c))\n c = read();\n\n int sgn = 1;\n\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n\n int res = 0;\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = read();\n }\n while (!isSpaceChar(c));\n\n return res * sgn;\n }\n\n public long nextLong() {\n int c = read();\n while (isSpaceChar(c))\n c = read();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n long res = 0;\n\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = read();\n }\n while (!isSpaceChar(c));\n return res * sgn;\n }\n\n public double nextDouble() {\n int c = read();\n while (isSpaceChar(c))\n c = read();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n double res = 0;\n while (!isSpaceChar(c) && c != '.') {\n if (c == 'e' || c == 'E')\n return res * Math.pow(10, nextInt());\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = read();\n }\n if (c == '.') {\n c = read();\n double m = 1;\n while (!isSpaceChar(c)) {\n if (c == 'e' || c == 'E')\n return res * Math.pow(10, nextInt());\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n m /= 10;\n res += (c - '0') * m;\n c = read();\n }\n }\n return res * sgn;\n }\n\n public String readString() {\n int c = read();\n while (isSpaceChar(c))\n c = read();\n StringBuilder res = new StringBuilder();\n do {\n res.appendCodePoint(c);\n c = read();\n }\n while (!isSpaceChar(c));\n\n return res.toString();\n }\n\n public boolean isSpaceChar(int c) {\n if (filter != null)\n return filter.isSpaceChar(c);\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public String next() {\n return readString();\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n }\n }\n\n public static void main(String args[]) throws Exception {\n new Thread(null, new Main(), \"Main\", 1 << 26).start();\n }\n\n static long gcd(long a, long b) {\n if (b == 0) return a;\n return gcd(b, a % b);\n }\n\n static int gcd(int a, int b) {\n if (b == 0) return a;\n return gcd(b, a % b);\n }\n\n static long modPow(long a, long p, long m) {\n if (a == 1) return 1;\n long ans = 1;\n while (p > 0) {\n if (p % 2 == 1) ans = (ans * a) % m;\n a = (a * a) % m;\n p >>= 1;\n }\n return ans;\n }\n\n static long modInv(long a, long m) {\n return modPow(a, m - 2, m);\n }\n\n\n static class Radix {\n\n\n static int getMax(int arr[], int n) {\n int mx = arr[0];\n for (int i = 1; i < n; i++)\n if (arr[i] > mx)\n mx = arr[i];\n return mx;\n }\n\n static void countSort(int arr[], int n, int exp) {\n int output[] = new int[n];\n int i;\n int count[] = new int[10];\n Arrays.fill(count, 0);\n\n for (i = 0; i < n; i++)\n count[(arr[i] / exp) % 10]++;\n\n for (i = 1; i < 10; i++)\n count[i] += count[i - 1];\n\n for (i = n - 1; i >= 0; i--) {\n output[count[(arr[i] / exp) % 10] - 1] = arr[i];\n count[(arr[i] / exp) % 10]--;\n }\n\n for (i = 0; i < n; i++)\n arr[i] = output[i];\n }\n\n static void radixsort(int arr[], int n) {\n int m = getMax(arr, n);\n\n for (int exp = 1; m / exp > 0; exp *= 10)\n countSort(arr, n, exp);\n }\n\n }\n\n class DSU {\n int par[], size[], connectedComponent;\n\n DSU(int n) {\n par = new int[n];\n size = new int[n];\n for (int i = 0; i < n; i++) {\n size[i] = 1;\n par[i] = i;\n }\n connectedComponent = n;\n }\n\n int root(int n) {\n if (n == par[n]) return n;\n return par[n] = root(par[n]);\n }\n\n boolean union(int u, int v) {\n return f_union(root(u), root(v));\n }\n\n boolean f_union(int u, int v) {\n if (u == v) return false;\n if (size[u] > size[v]) {\n size[u] += size[v];\n par[v] = u;\n } else {\n size[v] += size[u];\n par[u] = v;\n }\n connectedComponent--;\n return true;\n }\n\n DSU clone_DSU() {\n DSU t = new DSU(par.length);\n t.connectedComponent = connectedComponent;\n for (int i = 0; i < par.length; i++) {\n t.par[i] = par[i];\n t.size[i] = size[i];\n }\n return t;\n }\n }\n\n\n class segmentTree {\n long query(int cur, int l, int r, int start, int end, long tree[], long a[], long[] lazy) {\n if (l > end || r < start) return 0;\n if (lazy[cur] != 0) {\n tree[cur] += lazy[cur];\n if (l != r) {\n lazy[2 * cur + 1] += lazy[cur];\n lazy[2 * cur + 2] += lazy[cur];\n }\n lazy[cur] = 0;\n }\n if (l >= start && r <= end) return tree[cur];\n int mid = (l + r) >> 1;\n long p1 = query(2 * cur + 1, l, mid, start, end, tree, a, lazy);\n long p2 = query(2 * cur + 2, mid + 1, r, start, end, tree, a, lazy);\n return p1 + p2;\n }\n\n void build(int cur, int l, int r, long tree[], long a[]) {\n if (l == r) {\n tree[cur] = a[l];\n return;\n }\n int mid = (l + r) >> 1;\n build(2 * cur + 1, l, mid, tree, a);\n build(2 * cur + 2, mid + 1, r, tree, a);\n tree[cur] = tree[2 * cur + 1] + tree[2 * cur + 2];\n }\n\n void update(int cur, int start, int end, long val, int l, int r, long tree[], long a[], long[] lazy) {\n if (l > end || r < start) return;\n if (lazy[cur] != 0) {\n tree[cur] += (r - l + 1) * lazy[cur];\n if (l != r) {\n lazy[2 * cur + 1] += lazy[cur];\n lazy[2 * cur + 2] += lazy[cur];\n }\n lazy[cur] = 0;\n }\n if (l >= start && r <= end) {\n tree[cur] += (r - l + 1) * val;\n if (l != r) {\n lazy[cur * 2 + 1] += val;\n lazy[cur * 2 + 2] += val;\n }\n return;\n }\n int mid = (l + r) >> 1;\n update(2 * cur + 1, start, end, val, l, mid, tree, a, lazy);\n update(2 * cur + 2, start, end, val, mid + 1, r, tree, a, lazy);\n tree[cur] = tree[2 * cur + 1] + tree[2 * cur + 2];\n }\n }\n\n\n public void run() {\n InputReader sc = new InputReader(System.in);\n // Scanner sc=new Scanner(System.in);\n // Random sc=new Random();\n PrintWriter out = new PrintWriter(System.out);\n\n int n=sc.nextInt();\n int a[]=new int[n];\n for (int i = 0; i < n; i++) {\n a[i]=sc.nextInt();\n }\n ArrayList l[]=new ArrayList[n];\n for (int i = 0; i ();\n }\n HashMap h=new HashMap<>();\n long ans=0;\n for (int i = n-1; i >=0; i--) {\n int m=a[i];\n int d=2;\n while (d*d<=m){\n int c=0;\n while (m%d==0){\n m/=d;\n c++;\n }\n if(c>0){\n l[i].add(d);\n l[i].add(c);\n h.put(d,Math.max(c,h.getOrDefault(d,0)));\n }\n if(d==2)d=3;\n else d+=2;\n }\n if(m!=1){\n l[i].add(m);\n l[i].add(1);\n h.put(m,Math.max(1,h.getOrDefault(m,0)));\n }\n\n }\n\n long lcm=1,mod=1000000007;\n for(int key:h.keySet()){\n lcm=(lcm*modPow(key,h.get(key),mod))%mod;\n }\n\n\n for (int i = 0; i = numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }\n\n public String nextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }\n\n public int nextInt() {\n int c = read();\n\n while (isSpaceChar(c))\n c = read();\n\n int sgn = 1;\n\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n\n int res = 0;\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = read();\n }\n while (!isSpaceChar(c));\n\n return res * sgn;\n }\n\n public long nextLong() {\n int c = read();\n while (isSpaceChar(c))\n c = read();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n long res = 0;\n\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = read();\n }\n while (!isSpaceChar(c));\n return res * sgn;\n }\n\n public double nextDouble() {\n int c = read();\n while (isSpaceChar(c))\n c = read();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n double res = 0;\n while (!isSpaceChar(c) && c != '.') {\n if (c == 'e' || c == 'E')\n return res * Math.pow(10, nextInt());\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = read();\n }\n if (c == '.') {\n c = read();\n double m = 1;\n while (!isSpaceChar(c)) {\n if (c == 'e' || c == 'E')\n return res * Math.pow(10, nextInt());\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n m /= 10;\n res += (c - '0') * m;\n c = read();\n }\n }\n return res * sgn;\n }\n\n public String readString() {\n int c = read();\n while (isSpaceChar(c))\n c = read();\n StringBuilder res = new StringBuilder();\n do {\n res.appendCodePoint(c);\n c = read();\n }\n while (!isSpaceChar(c));\n\n return res.toString();\n }\n\n public boolean isSpaceChar(int c) {\n if (filter != null)\n return filter.isSpaceChar(c);\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public String next() {\n return readString();\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n }\n }\n\n public static void main(String args[]) throws Exception {\n new Thread(null, new Main(), \"Main\", 1 << 26).start();\n }\n\n static long gcd(long a, long b) {\n if (b == 0) return a;\n return gcd(b, a % b);\n }\n\n static int gcd(int a, int b) {\n if (b == 0) return a;\n return gcd(b, a % b);\n }\n\n static long modPow(long a, long p, long m) {\n if (a == 1) return 1;\n long ans = 1;\n while (p > 0) {\n if (p % 2 == 1) ans = (ans * a) % m;\n a = (a * a) % m;\n p >>= 1;\n }\n return ans;\n }\n\n static long modInv(long a, long m) {\n return modPow(a, m - 2, m);\n }\n\n\n static class Radix {\n\n\n static int getMax(int arr[], int n) {\n int mx = arr[0];\n for (int i = 1; i < n; i++)\n if (arr[i] > mx)\n mx = arr[i];\n return mx;\n }\n\n static void countSort(int arr[], int n, int exp) {\n int output[] = new int[n];\n int i;\n int count[] = new int[10];\n Arrays.fill(count, 0);\n\n for (i = 0; i < n; i++)\n count[(arr[i] / exp) % 10]++;\n\n for (i = 1; i < 10; i++)\n count[i] += count[i - 1];\n\n for (i = n - 1; i >= 0; i--) {\n output[count[(arr[i] / exp) % 10] - 1] = arr[i];\n count[(arr[i] / exp) % 10]--;\n }\n\n for (i = 0; i < n; i++)\n arr[i] = output[i];\n }\n\n static void radixsort(int arr[], int n) {\n int m = getMax(arr, n);\n\n for (int exp = 1; m / exp > 0; exp *= 10)\n countSort(arr, n, exp);\n }\n\n }\n\n class DSU {\n int par[], size[], connectedComponent;\n\n DSU(int n) {\n par = new int[n];\n size = new int[n];\n for (int i = 0; i < n; i++) {\n size[i] = 1;\n par[i] = i;\n }\n connectedComponent = n;\n }\n\n int root(int n) {\n if (n == par[n]) return n;\n return par[n] = root(par[n]);\n }\n\n boolean union(int u, int v) {\n return f_union(root(u), root(v));\n }\n\n boolean f_union(int u, int v) {\n if (u == v) return false;\n if (size[u] > size[v]) {\n size[u] += size[v];\n par[v] = u;\n } else {\n size[v] += size[u];\n par[u] = v;\n }\n connectedComponent--;\n return true;\n }\n\n DSU clone_DSU() {\n DSU t = new DSU(par.length);\n t.connectedComponent = connectedComponent;\n for (int i = 0; i < par.length; i++) {\n t.par[i] = par[i];\n t.size[i] = size[i];\n }\n return t;\n }\n }\n\n\n class segmentTree {\n long query(int cur, int l, int r, int start, int end, long tree[], long a[], long[] lazy) {\n if (l > end || r < start) return 0;\n if (lazy[cur] != 0) {\n tree[cur] += lazy[cur];\n if (l != r) {\n lazy[2 * cur + 1] += lazy[cur];\n lazy[2 * cur + 2] += lazy[cur];\n }\n lazy[cur] = 0;\n }\n if (l >= start && r <= end) return tree[cur];\n int mid = (l + r) >> 1;\n long p1 = query(2 * cur + 1, l, mid, start, end, tree, a, lazy);\n long p2 = query(2 * cur + 2, mid + 1, r, start, end, tree, a, lazy);\n return p1 + p2;\n }\n\n void build(int cur, int l, int r, long tree[], long a[]) {\n if (l == r) {\n tree[cur] = a[l];\n return;\n }\n int mid = (l + r) >> 1;\n build(2 * cur + 1, l, mid, tree, a);\n build(2 * cur + 2, mid + 1, r, tree, a);\n tree[cur] = tree[2 * cur + 1] + tree[2 * cur + 2];\n }\n\n void update(int cur, int start, int end, long val, int l, int r, long tree[], long a[], long[] lazy) {\n if (l > end || r < start) return;\n if (lazy[cur] != 0) {\n tree[cur] += (r - l + 1) * lazy[cur];\n if (l != r) {\n lazy[2 * cur + 1] += lazy[cur];\n lazy[2 * cur + 2] += lazy[cur];\n }\n lazy[cur] = 0;\n }\n if (l >= start && r <= end) {\n tree[cur] += (r - l + 1) * val;\n if (l != r) {\n lazy[cur * 2 + 1] += val;\n lazy[cur * 2 + 2] += val;\n }\n return;\n }\n int mid = (l + r) >> 1;\n update(2 * cur + 1, start, end, val, l, mid, tree, a, lazy);\n update(2 * cur + 2, start, end, val, mid + 1, r, tree, a, lazy);\n tree[cur] = tree[2 * cur + 1] + tree[2 * cur + 2];\n }\n }\n\n\n public void run() {\n InputReader sc = new InputReader(System.in);\n // Scanner sc=new Scanner(System.in);\n // Random sc=new Random();\n PrintWriter out = new PrintWriter(System.out);\n\n int n=sc.nextInt();\n int a[]=new int[n];\n for (int i = 0; i < n; i++) {\n a[i]=sc.nextInt();\n }\n ArrayList l[]=new ArrayList[n];\n for (int i = 0; i ();\n }\n HashMap h=new HashMap<>();\n long ans=0;\n for (int i = n-1; i >=0; i--) {\n int m=a[i];\n int d=2;\n while (d*d<=m){\n int c=0;\n while (m%d==0){\n m/=d;\n c++;\n }\n if(c>0){\n l[i].add(d);\n l[i].add(c);\n h.put(d,Math.max(c,h.getOrDefault(d,0)));\n }\n if(d==2)d=3;\n else d+=2;\n }\n if(m!=1){\n l[i].add(m);\n l[i].add(1);\n h.put(m,Math.max(1,h.getOrDefault(m,0)));\n }\n\n }\n\n long lcm=1,mod=1000000007;\n for(int key:h.keySet()){\n lcm=(lcm*modPow(key,h.get(key),mod))%mod;\n }\n\n\n for (int i = 0; i = numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0) {\n return -1;\n }\n }\n return buf[curChar++];\n }\n\n public int nextInt() {\n int c = read();\n while (isSpaceChar(c)) {\n c = read();\n }\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n res *= 10;\n res += c - '0';\n c = read();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n\n public boolean isSpaceChar(int c) {\n if (filter != null) {\n return filter.isSpaceChar(c);\n }\n return isWhitespace(c);\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1579377725, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02795.html", "problem_id": "p02795", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02795/input.txt", "sample_output_relpath": "derived/input_output/data/p02795/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02795/Java/s976484130.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s976484130", "user_id": "u485601469"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.io.BufferedWriter;\nimport java.io.Writer;\nimport java.io.OutputStreamWriter;\nimport java.util.InputMismatchException;\nimport java.io.IOException;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author prakharjain\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n OutputWriter out = new OutputWriter(outputStream);\n APainting solver = new APainting();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class APainting {\n public void solve(int testNumber, InputReader in, OutputWriter out) {\n int r = in.nextInt();\n int c = in.nextInt();\n int n = in.nextInt();\n\n out.println(Math.min((n + r - 1) / r, (n + c - 1) / c));\n }\n\n }\n\n static class OutputWriter {\n private final PrintWriter writer;\n\n public OutputWriter(OutputStream outputStream) {\n writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));\n }\n\n public OutputWriter(Writer writer) {\n this.writer = new PrintWriter(writer);\n }\n\n public void close() {\n writer.close();\n }\n\n public void println(int i) {\n writer.println(i);\n }\n\n }\n\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private InputReader.SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n\n public static boolean isWhitespace(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public int read() {\n if (numChars == -1) {\n throw new InputMismatchException();\n }\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0) {\n return -1;\n }\n }\n return buf[curChar++];\n }\n\n public int nextInt() {\n int c = read();\n while (isSpaceChar(c)) {\n c = read();\n }\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n res *= 10;\n res += c - '0';\n c = read();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n\n public boolean isSpaceChar(int c) {\n if (filter != null) {\n return filter.isSpaceChar(c);\n }\n return isWhitespace(c);\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\n\n }\n}\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns, where all the squares are initially white.\n\nYou will perform some number of painting operations on the grid.\nIn one operation, you can do one of the following two actions:\n\nChoose one row, then paint all the squares in that row black.\n\nChoose one column, then paint all the squares in that column black.\n\nAt least how many operations do you need in order to have N or more black squares in the grid?\nIt is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.\n\nConstraints\n\n1 \\leq H \\leq 100\n\n1 \\leq W \\leq 100\n\n1 \\leq N \\leq H \\times W\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH\nW\nN\n\nOutput\n\nPrint the minimum number of operations needed.\n\nSample Input 1\n\n3\n7\n10\n\nSample Output 1\n\n2\n\nYou can have 14 black squares in the grid by performing the \"row\" operation twice, on different rows.\n\nSample Input 2\n\n14\n12\n112\n\nSample Output 2\n\n8\n\nSample Input 3\n\n2\n100\n200\n\nSample Output 3\n\n2", "sample_input": "3\n7\n10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02795", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns, where all the squares are initially white.\n\nYou will perform some number of painting operations on the grid.\nIn one operation, you can do one of the following two actions:\n\nChoose one row, then paint all the squares in that row black.\n\nChoose one column, then paint all the squares in that column black.\n\nAt least how many operations do you need in order to have N or more black squares in the grid?\nIt is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.\n\nConstraints\n\n1 \\leq H \\leq 100\n\n1 \\leq W \\leq 100\n\n1 \\leq N \\leq H \\times W\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH\nW\nN\n\nOutput\n\nPrint the minimum number of operations needed.\n\nSample Input 1\n\n3\n7\n10\n\nSample Output 1\n\n2\n\nYou can have 14 black squares in the grid by performing the \"row\" operation twice, on different rows.\n\nSample Input 2\n\n14\n12\n112\n\nSample Output 2\n\n8\n\nSample Input 3\n\n2\n100\n200\n\nSample Output 3\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3473, "cpu_time_ms": 78, "memory_kb": 23508}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s916025176", "group_id": "codeNet:p02796", "input_text": "\n\n\n\nimport java.awt.Point;\nimport java.io.File;\nimport java.io.FileInputStream;\nimport java.io.FileNotFoundException;\nimport java.io.FileOutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintStream;\nimport java.io.PrintWriter;\nimport java.io.Serializable;\nimport java.util.AbstractList;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.Comparator;\nimport java.util.HashMap;\nimport java.util.Iterator;\nimport java.util.List;\nimport java.util.Locale;\nimport java.util.Map;\nimport java.util.Map.Entry;\nimport java.util.NoSuchElementException;\nimport java.util.RandomAccess;\nimport java.util.Set;\nimport java.util.function.BinaryOperator;\nimport java.util.function.UnaryOperator;\n\npublic class Main implements Runnable{\n\n\tprivate void solve(FastIO io, String[] args) {\n\t\t/*\n\t\t * author: 31536000\n\t\t * キーエンスプログラミングコンテスト2020 B問題\n\t\t * 考察メモ\n\t\t * 区間で考えていく\n\t\t * 各ロボットは[X-L, X+L)の区間を持ち、仮に[L, R)とする\n\t\t * この時、この問題は重ならない区間の最大化になる\n\t\t * dp[i]:座標P_i以下におけるロボットの答え\n\t\t * とすると、各ロボットについて、dp[P_i](i>=r)にdp[P_l]+1以上でmaxを行う操作へ\n\t\t * 座圧で\n\t\t *\n\t\t */\n\t\tint N = io.nextInt();\n\t\tIntRange[] range = new IntRange[N];\n\t\tfor (int i = 0;i < N;++ i) {\n\t\t\tint X = io.nextInt(), L = io.nextInt();\n\t\t\trange[i] = IntRange.closed(X - L, X + L);\n\t\t}\n\t\tInteger[] comp = new Integer[2 * N];\n\t\tfor (int i = 0;i < N;++ i) {\n\t\t\tcomp[i << 1] = range[i].getClosedLower();\n\t\t\tcomp[i << 1 | 1] = range[i].getClosedUpper();\n\t\t}\n\t\tCompress compress = new Compress<>(comp); // 座圧\n\t\tArrays.sort(range, (l, r) -> Integer.compare(l.getClosedUpper(), r.getClosedUpper())); // 終点ソート\n\t\t//io.debugln(range);\n\t\tint rangeIndex = 0;\n\t\tint[] dp = new int[compress.size()]; // 答え\n\t\tfor (int i = 1;i < dp.length;++ i) {\n\t\t\tdp[i] = dp[i - 1]; // まず、ロボットを使わない時\n\t\t\tif (compress.zip(range[rangeIndex].getClosedUpper()) == i) { // 現在座標\n\t\t\t\tint get = compress.zip(range[rangeIndex++].getClosedLower());\n\t\t\t\tdp[i] = Math.max(dp[i], dp[get] + 1); // このロボットを採用するとき\n\t\t\t}\n\t\t}\n\t\t//io.debugln(dp);\n\t\tio.println(dp[dp.length - 1]);\n\t}\n\n\t/** デバッグ用コードのお供に */\n\tprivate static boolean DEBUG = false;\n\t/** 確保するメモリの大きさ(単位: MB)*/\n\tprivate static final long MEMORY = 64;\n\tprivate final FastIO io;\n\tprivate final String[] args;\n\n\tpublic static void main(String[] args) {\n\t Thread.setDefaultUncaughtExceptionHandler((t, e) -> e.printStackTrace());\n\t new Thread(null, new Main(args), \"\", MEMORY * 1048576).start();\n\t}\n\n\tpublic Main(String[] args) {\n\t\tthis(new FastIO(), args);\n\t}\n\n\tpublic Main(FastIO io, String... args) {\n\t\tthis.io = io;\n\t\tthis.args = args;\n\t\tif (DEBUG) io.setAutoFlush(true);\n\t}\n\n\t@Override\n\tpublic void run() {\n\t\ttry {\n\t\t\tsolve(io, args);\n\t\t} catch (Throwable e) {\n\t\t\tthrow e;\n\t\t} finally {\n\t\t\tio.flush();\n\t\t}\n\t}\n\n\t// 以下、ライブラリ\n\n\tpublic class Compress> {\n\n\t\tprivate Map zip;\n\t\tprivate Object[] unzip;\n\n\t\tpublic Compress(T[] dat) {\n\t\t\tArrays.sort(dat);\n\t\t\tzip = new HashMap();\n\t\t\tList unzip = new ArrayList();\n\t\t\tfor (int i = 0, j = 0; i < dat.length; ++i) {\n\t\t\t\tif (zip.put(dat[i], j++ ) != null) {\n\t\t\t\t\tzip.put(dat[i], --j - 1);\n\t\t\t\t} else unzip.add(dat[i]);\n\t\t\t}\n\t\t\tthis.unzip = unzip.toArray();\n\t\t}\n\n\t\tpublic Compress(List dat) {\n\t\t\tdat.sort(null);\n\t\t\tObject[] dats = dat.toArray();\n\t\t\tzip = new HashMap();\n\t\t\tList unzip = new ArrayList();\n\t\t\tfor (int i = 0, j = 0; i < dats.length; ++i) {\n\t\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\t\tT push = (T)dats[i];\n\t\t\t\tif (zip.put(push, j++ ) != null) {\n\t\t\t\t\tzip.put(push, --j - 1);\n\t\t\t\t} else unzip.add(push);\n\t\t\t}\n\t\t\tthis.unzip = unzip.toArray();\n\t\t}\n\n\t\tpublic int zip(T dat) {\n\t\t\treturn zip.get(dat);\n\t\t}\n\n\t\tpublic T unzip(int index) {\n\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\tT ret = (T)unzip[index];\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic int size() {\n\t\t\treturn unzip.length;\n\t\t}\n\t}\n\n\t/**\n\t * 高速な入出力を提供します。\n\t * @author 31536000\n\t *\n\t */\n\tpublic static class FastIO {\n\t\tprivate InputStream in;\n\t\tprivate final byte[] buffer = new byte[1024];\n\t\tprivate int read = 0;\n\t\tprivate int length = 0;\n\t\tprivate PrintWriter out;\n\t\tprivate PrintWriter err;\n\t\tprivate boolean autoFlush = false;\n\n\t\tpublic FastIO() {\n\t\t\tthis(System.in, System.out, System.err);\n\t\t}\n\n\t\tpublic FastIO(InputStream in, PrintStream out, PrintStream err) {\n\t\t\tthis.in = in;\n\t\t\tthis.out = new PrintWriter(out, false);\n\t\t\tthis.err = new PrintWriter(err, false);\n\t\t}\n\n\t\tpublic final void setInputStream(InputStream in) {\n\t\t\tthis.in = in;\n\t\t}\n\n\t\tpublic final void setInputStream(File in) {\n\t\t\ttry {\n\t\t\t\tthis.in = new FileInputStream(in);\n\t\t\t} catch (FileNotFoundException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t}\n\n\t\tpublic final void setOutputStream(PrintStream out) {\n\t\t\tthis.out = new PrintWriter(out, false);\n\t\t}\n\n\t\tpublic final void setOutputStream(File out) {\n\t\t\ttry {\n\t\t\t\tthis.out = new PrintWriter(new FileOutputStream(out), false);\n\t\t\t} catch (FileNotFoundException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t}\n\n\t\tpublic final void setErrorStream(PrintStream err) {\n\t\t\tthis.err = new PrintWriter(err, false);\n\t\t}\n\n\t\tpublic final void setErrorStream(File err) {\n\t\t\ttry {\n\t\t\t\tthis.err = new PrintWriter(new FileOutputStream(err), false);\n\t\t\t} catch (FileNotFoundException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t}\n\n\t\tpublic final void setAutoFlush(boolean flush) {\n\t\t\tautoFlush = flush;\n\t\t}\n\n\t\tprivate boolean hasNextByte() {\n\t\t\tif (read < length) return true;\n\t\t\tread = 0;\n\t\t\ttry {\n\t\t\t\tlength = in.read(buffer);\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn length > 0;\n\t\t}\n\n\t\tprivate int readByte() {\n\t\t\treturn hasNextByte() ? buffer[read++] : -1;\n\t\t}\n\n\t\tprivate static boolean isPrintableChar(int c) {\n\t\t\treturn 33 <= c && c <= 126;\n\t\t}\n\n\t\tprivate static boolean isNumber(int c) {\n\t\t\treturn '0' <= c && c <= '9';\n\t\t}\n\n\t\tpublic final boolean hasNext() {\n\t\t\twhile (hasNextByte() && !isPrintableChar(buffer[read])) read++;\n\t\t\treturn hasNextByte();\n\t\t}\n\n\t\tpublic final char nextChar() {\n\t\t\tif (!hasNextByte()) throw new NoSuchElementException();\n\t\t\treturn (char)readByte();\n\t\t}\n\n\t\tpublic final char[][] nextChar(int height) {\n\t\t\tchar[][] ret = new char[height][];\n\t\t\tfor (int i = 0;i < ret.length;++ i) ret[i] = next().toCharArray();\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic final String next() {\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tint b;\n\t\t\twhile (isPrintableChar(b = readByte())) sb.appendCodePoint(b);\n\t\t\treturn sb.toString();\n\t\t}\n\n\t\tpublic final String nextLine() {\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tint b;\n\t\t\twhile(!isPrintableChar(b = readByte()));\n\t\t\tdo sb.appendCodePoint(b); while(isPrintableChar(b = readByte()) || b == ' ');\n\t\t\treturn sb.toString();\n\t\t}\n\n\t\tpublic final long nextLong() {\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tlong n = 0;\n\t\t\tboolean minus = false;\n\t\t\tint b = readByte();\n\t\t\tif (b == '-') {\n\t\t\t\tminus = true;\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t\tif (!isNumber(b)) throw new NumberFormatException();\n\t\t\twhile (true) {\n\t\t\t\tif (isNumber(b)) {\n\t\t\t\t\tn *= 10;\n\t\t\t\t\tn += b - '0';\n\t\t\t\t} else if (b == -1 || !isPrintableChar(b)) return minus ? -n : n;\n\t\t\t\telse throw new NumberFormatException();\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t}\n\n\t\tpublic final int nextInt() {\n\t\t\tlong nl = nextLong();\n\t\t\tif (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n\t\t\treturn (int) nl;\n\t\t}\n\n\t\tpublic final double nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tpublic final int[] nextInt(int width) {\n\t\t\tint[] ret = new int[width];\n\t\t\tfor (int i = 0;i < width;++ i) ret[i] = nextInt();\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic final int[] nextInts() {\n\t\t\treturn nextInts(\" \");\n\t\t}\n\n\t\tpublic final int[] nextInts(String parse) {\n\t\t\tString[] get = nextLine().split(parse);\n\t\t\tint[] ret = new int[get.length];\n\t\t\tfor (int i = 0;i < ret.length;++ i) ret[i] = Integer.valueOf(get[i]);\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic final long[] nextLong(int width) {\n\t\t\tlong[] ret = new long[width];\n\t\t\tfor (int i = 0;i < width;++ i) ret[i] = nextLong();\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic final long[] nextLongs() {\n\t\t\treturn nextLongs(\" \");\n\t\t}\n\n\t\tpublic final long[] nextLongs(String parse) {\n\t\t\tString[] get = nextLine().split(parse);\n\t\t\tlong[] ret = new long[get.length];\n\t\t\tfor (int i = 0;i < ret.length;++ i) ret[i] = Long.valueOf(get[i]);\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic final int[][] nextInt(int width, int height) {\n\t\t\tint[][] ret = new int[height][width];\n\t\t\tfor (int i = 0, j;i < height;++ i) for (j = 0;j < width;++ j) ret[i][j] = nextInt();\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic final long[][] nextLong(int width, int height) {\n\t\t\tlong[][] ret = new long[height][width];\n\t\t\tfor (int i = 0, j;i < height;++ i) for (j = 0;j < width;++ j) ret[j][i] = nextLong();\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic final boolean[] nextBoolean(char T) {\n\t\t\tchar[] s = next().toCharArray();\n\t\t\tboolean[] ret = new boolean[s.length];\n\t\t\tfor (int i = 0;i < ret.length;++ i) ret[i] = s[i] == T;\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic final boolean[][] nextBoolean(char T, int height) {\n\t\t\tboolean[][] ret = new boolean[height][];\n\t\t\tfor (int i = 0;i < ret.length;++ i) {\n\t\t\t\tchar[] s = next().toCharArray();\n\t\t\t\tret[i] = new boolean[s.length];\n\t\t\t\tfor (int j = 0;j < ret[i].length;++ j) ret[i][j] = s[j] == T;\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic final Point nextPoint() {\n\t\t\treturn new Point(nextInt(), nextInt());\n\t\t}\n\n\t\tpublic final Point[] nextPoint(int width) {\n\t\t\tPoint[] ret = new Point[width];\n\t\t\tfor (int i = 0;i < width;++ i) ret[i] = nextPoint();\n\t\t\treturn ret;\n\t\t}\n\n\t\t@Override\n\t\tprotected void finalize() throws Throwable {\n\t\t\ttry {\n\t\t\t\tsuper.finalize();\n\t\t\t} finally {\n\t\t\t\tin.close();\n\t\t\t\tout.close();\n\t\t\t\terr.close();\n\t\t\t}\n\t\t}\n\n\t\tpublic final boolean print(boolean b) {\n\t\t\tout.print(b);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn b;\n\t\t}\n\n\t\tpublic final Object print(boolean b, Object t, Object f) {\n\t\t\treturn b ? print(t) : print(f);\n\t\t}\n\n\t\tpublic final char print(char c) {\n\t\t\tout.print(c);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn c;\n\t\t}\n\n\t\tpublic final char[] print(char[] s) {\n\t\t\tout.print(s);\n\t\t\treturn s;\n\t\t}\n\n\t\tpublic final double print(double d) {\n\t\t\tout.print(d);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn d;\n\t\t}\n\n\t\tpublic final double print(double d, int length) {\n\t\t\tif (d < 0) {\n\t\t\t\tout.print('-');\n\t\t\t\td = -d;\n\t\t\t}\n\t\t\td += Math.pow(10, -length) / 2;\n\t\t\tout.print((long)d);\n\t\t\tout.print('.');\n\t\t\td -= (long)d;\n\t\t\tfor (int i = 0;i < length;++ i) {\n\t\t\t\td *= 10;\n\t\t\t\tout.print((int)d);\n\t\t\t\td -= (int)d;\n\t\t\t}\n\t\t\tif (autoFlush) flush();\n\t\t\treturn d;\n\t\t}\n\n\t\tpublic final float print(float f) {\n\t\t\tout.print(f);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn f;\n\t\t}\n\n\t\tpublic final int print(int i) {\n\t\t\tout.print(i);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn i;\n\t\t}\n\n\t\tpublic final long print(long l) {\n\t\t\tout.print(l);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn l;\n\t\t}\n\n\t\tpublic final Object print(Object obj) {\n\t\t\tif (obj != null && obj.getClass().isArray()) {\n\t\t\t\tif (obj instanceof boolean[][]) print(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof byte[][]) print(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof short[][]) print(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof int[][]) print(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof long[][]) print(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof float[][]) print(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof double[][]) print(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof char[][]) print(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof Object[][]) print(obj, \"\\n\", \" \");\n\t\t\t\telse print(obj, \" \");\n\t\t\t} else {\n\t\t\t\tout.print(obj);\n\t\t\t\tif (autoFlush) flush();\n\t\t\t}\n\t\t\treturn obj;\n\t\t}\n\n\t\tpublic final String print(String s) {\n\t\t\tout.print(s);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn s;\n\t\t}\n\n\t\tpublic final Object print(Object array, String... parse) {\n\t\t\tprint(array, 0, parse);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn array;\n\t\t}\n\n\t\tprivate final Object print(Object array, int check, String... parse) {\n\t\t\tif (check >= parse.length) {\n\t\t\t\tif (array != null && array.getClass().isArray()) throw new IllegalArgumentException(\"not equal dimension\");\n\t\t\t\tprint(array);\n\t\t\t\treturn array;\n\t\t\t}\n\t\t\tString str = parse[check];\n\t\t\tif (array instanceof Object[]) {\n\t\t\t\tObject[] obj = (Object[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tprint(obj[0], check + 1, parse);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tprint(str);\n\t\t\t\t\tprint(obj[i], check + 1, parse);\n\t\t\t\t}\n\t\t\t\treturn array;\n\t\t\t}\n\t\t\tif (array instanceof Collection) {\n\t\t\t\tIterator iter = ((Collection)array).iterator();\n\t\t\t\tif (!iter.hasNext()) return array;\n\t\t\t\tprint(iter.next(), check + 1, parse);\n\t\t\t\twhile(iter.hasNext()) {\n\t\t\t\t\tprint(str);\n\t\t\t\t\tprint(iter.next(), check + 1, parse);\n\t\t\t\t}\n\t\t\t\treturn array;\n\t\t\t}\n\t\t\tif (!array.getClass().isArray()) throw new IllegalArgumentException(\"not equal dimension\");\n\t\t\tif (check != parse.length - 1) throw new IllegalArgumentException(\"not equal dimension\");\n\t\t\tif (array instanceof boolean[]) {\n\t\t\t\tboolean[] obj = (boolean[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tprint(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tprint(str);\n\t\t\t\t\tprint(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof byte[]) {\n\t\t\t\tbyte[] obj = (byte[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tprint(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tprint(str);\n\t\t\t\t\tprint(obj[i]);\n\t\t\t\t}\n\t\t\t\treturn array;\n\t\t\t} else if (array instanceof short[]) {\n\t\t\t\tshort[] obj = (short[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tprint(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tprint(str);\n\t\t\t\t\tprint(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof int[]) {\n\t\t\t\tint[] obj = (int[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tprint(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tprint(str);\n\t\t\t\t\tprint(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof long[]) {\n\t\t\t\tlong[] obj = (long[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tprint(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tprint(str);\n\t\t\t\t\tprint(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof float[]) {\n\t\t\t\tfloat[] obj = (float[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tprint(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tprint(str);\n\t\t\t\t\tprint(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof double[]) {\n\t\t\t\tdouble[] obj = (double[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tprint(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tprint(str);\n\t\t\t\t\tprint(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof char[]) {\n\t\t\t\tchar[] obj = (char[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tprint(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tprint(str);\n\t\t\t\t\tprint(obj[i]);\n\t\t\t\t}\n\t\t\t} else throw new AssertionError();\n\t\t\treturn array;\n\t\t}\n\n\t\tpublic final Object[] print(String parse, Object... args) {\n\t\t\tprint(args[0]);\n\t\t\tfor (int i = 1;i < args.length;++ i) {\n\t\t\t\tprint(parse);\n\t\t\t\tprint(args[i]);\n\t\t\t}\n\t\t\treturn args;\n\t\t}\n\n\t\tpublic final Object[] printf(String format, Object... args) {\n\t\t\tout.printf(format, args);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn args;\n\t\t}\n\n\t\tpublic final Object printf(Locale l, String format, Object... args) {\n\t\t\tout.printf(l, format, args);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn args;\n\t\t}\n\n\t\tpublic final void println() {\n\t\t\tout.println();\n\t\t\tif (autoFlush) flush();\n\t\t}\n\n\t\tpublic final boolean println(boolean b) {\n\t\t\tout.println(b);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn b;\n\t\t}\n\n\t\tpublic final Object println(boolean b, Object t, Object f) {\n\t\t\treturn b ? println(t) : println(f);\n\t\t}\n\n\t\tpublic final char println(char c) {\n\t\t\tout.println(c);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn c;\n\t\t}\n\n\t\tpublic final char[] println(char[] s) {\n\t\t\tout.println(s);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn s;\n\t\t}\n\n\t\tpublic final double println(double d) {\n\t\t\tout.println(d);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn d;\n\t\t}\n\n\t\tpublic final double println(double d, int length) {\n\t\t\tprint(d, length);\n\t\t\tprintln();\n\t\t\treturn d;\n\t\t}\n\n\t\tpublic final float println(float f) {\n\t\t\tout.println(f);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn f;\n\t\t}\n\n\t\tpublic final int println(int i) {\n\t\t\tout.println(i);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn i;\n\t\t}\n\n\t\tpublic final long println(long l) {\n\t\t\tout.println(l);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn l;\n\t\t}\n\n\t\tpublic final Object println(Object obj) {\n\t\t\tprint(obj);\n\t\t\tprintln();\n\t\t\treturn obj;\n\t\t}\n\n\t\tpublic final String println(String s) {\n\t\t\tout.println(s);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn s;\n\t\t}\n\n\t\tpublic final Object println(Object array, String... parse) {\n\t\t\tprint(array, parse);\n\t\t\tprintln();\n\t\t\treturn array;\n\t\t}\n\n\t\tpublic final boolean debug(boolean b) {\n\t\t\terr.print(b);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn b;\n\t\t}\n\n\t\tpublic final Object debug(boolean b, Object t, Object f) {\n\t\t\treturn b ? debug(t) : debug(f);\n\t\t}\n\n\t\tpublic final char debug(char c) {\n\t\t\terr.print(c);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn c;\n\t\t}\n\n\t\tpublic final char[] debug(char[] s) {\n\t\t\terr.print(s);\n\t\t\treturn s;\n\t\t}\n\n\t\tpublic final double debug(double d) {\n\t\t\terr.print(d);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn d;\n\t\t}\n\n\t\tpublic final double debug(double d, int length) {\n\t\t\tif (d < 0) {\n\t\t\t\terr.print('-');\n\t\t\t\td = -d;\n\t\t\t}\n\t\t\td += Math.pow(10, -length) / 2;\n\t\t\terr.print((long)d);\n\t\t\terr.print('.');\n\t\t\td -= (long)d;\n\t\t\tfor (int i = 0;i < length;++ i) {\n\t\t\t\td *= 10;\n\t\t\t\terr.print((int)d);\n\t\t\t\td -= (int)d;\n\t\t\t}\n\t\t\tif (autoFlush) flush();\n\t\t\treturn d;\n\t\t}\n\n\t\tpublic final float debug(float f) {\n\t\t\terr.print(f);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn f;\n\t\t}\n\n\t\tpublic final int debug(int i) {\n\t\t\terr.print(i);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn i;\n\t\t}\n\n\t\tpublic final long debug(long l) {\n\t\t\terr.print(l);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn l;\n\t\t}\n\n\t\tpublic final Object debug(Object obj) {\n\t\t\tif (obj != null && obj.getClass().isArray()) {\n\t\t\t\tif (obj instanceof boolean[][]) debug(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof byte[][]) debug(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof short[][]) debug(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof int[][]) debug(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof long[][]) debug(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof float[][]) debug(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof double[][]) debug(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof char[][]) debug(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof Object[][]) debug(obj, \"\\n\", \" \");\n\t\t\t\telse debug(obj, \" \");\n\t\t\t} else {\n\t\t\t\terr.print(obj);\n\t\t\t\tif (autoFlush) flush();\n\t\t\t}\n\t\t\treturn obj;\n\t\t}\n\n\t\tpublic final String debug(String s) {\n\t\t\terr.print(s);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn s;\n\t\t}\n\n\t\tpublic final Object debug(Object array, String... parse) {\n\t\t\tdebug(array, 0, parse);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn array;\n\t\t}\n\n\t\tprivate final Object debug(Object array, int check, String... parse) {\n\t\t\tif (check >= parse.length) {\n\t\t\t\tif (array != null && array.getClass().isArray()) throw new IllegalArgumentException(\"not equal dimension\");\n\t\t\t\tdebug(array);\n\t\t\t\treturn array;\n\t\t\t}\n\t\t\tString str = parse[check];\n\t\t\tif (array instanceof Object[]) {\n\t\t\t\tObject[] obj = (Object[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tdebug(obj[0], check + 1, parse);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tdebug(str);\n\t\t\t\t\tdebug(obj[i], check + 1, parse);\n\t\t\t\t}\n\t\t\t\treturn array;\n\t\t\t}\n\t\t\tif (array instanceof Collection) {\n\t\t\t\tIterator iter = ((Collection)array).iterator();\n\t\t\t\tif (!iter.hasNext()) return array;\n\t\t\t\tdebug(iter.next(), check + 1, parse);\n\t\t\t\twhile(iter.hasNext()) {\n\t\t\t\t\tdebug(str);\n\t\t\t\t\tdebug(iter.next(), check + 1, parse);\n\t\t\t\t}\n\t\t\t\treturn array;\n\t\t\t}\n\t\t\tif (!array.getClass().isArray()) throw new IllegalArgumentException(\"not equal dimension\");\n\t\t\tif (check != parse.length - 1) throw new IllegalArgumentException(\"not equal dimension\");\n\t\t\tif (array instanceof boolean[]) {\n\t\t\t\tboolean[] obj = (boolean[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tdebug(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tdebug(str);\n\t\t\t\t\tdebug(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof byte[]) {\n\t\t\t\tbyte[] obj = (byte[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tdebug(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tdebug(str);\n\t\t\t\t\tdebug(obj[i]);\n\t\t\t\t}\n\t\t\t\treturn array;\n\t\t\t} else if (array instanceof short[]) {\n\t\t\t\tshort[] obj = (short[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tdebug(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tdebug(str);\n\t\t\t\t\tdebug(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof int[]) {\n\t\t\t\tint[] obj = (int[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tdebug(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tdebug(str);\n\t\t\t\t\tdebug(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof long[]) {\n\t\t\t\tlong[] obj = (long[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tdebug(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tdebug(str);\n\t\t\t\t\tdebug(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof float[]) {\n\t\t\t\tfloat[] obj = (float[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tdebug(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tdebug(str);\n\t\t\t\t\tdebug(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof double[]) {\n\t\t\t\tdouble[] obj = (double[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tdebug(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tdebug(str);\n\t\t\t\t\tdebug(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof char[]) {\n\t\t\t\tchar[] obj = (char[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tdebug(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tdebug(str);\n\t\t\t\t\tdebug(obj[i]);\n\t\t\t\t}\n\t\t\t} else throw new AssertionError();\n\t\t\treturn array;\n\t\t}\n\n\t\tpublic final Object[] debug(String parse, Object... args) {\n\t\t\tdebug(args[0]);\n\t\t\tfor (int i = 1;i < args.length;++ i) {\n\t\t\t\tdebug(parse);\n\t\t\t\tdebug(args[i]);\n\t\t\t}\n\t\t\treturn args;\n\t\t}\n\n\t\tpublic final Object[] debugf(String format, Object... args) {\n\t\t\terr.printf(format, args);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn args;\n\t\t}\n\n\t\tpublic final Object debugf(Locale l, String format, Object... args) {\n\t\t\terr.printf(l, format, args);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn args;\n\t\t}\n\n\t\tpublic final void debugln() {\n\t\t\terr.println();\n\t\t\tif (autoFlush) flush();\n\t\t}\n\n\t\tpublic final boolean debugln(boolean b) {\n\t\t\terr.println(b);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn b;\n\t\t}\n\n\t\tpublic final Object debugln(boolean b, Object t, Object f) {\n\t\t\treturn b ? debugln(t) : debugln(f);\n\t\t}\n\n\t\tpublic final char debugln(char c) {\n\t\t\terr.println(c);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn c;\n\t\t}\n\n\t\tpublic final char[] debugln(char[] s) {\n\t\t\terr.println(s);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn s;\n\t\t}\n\n\t\tpublic final double debugln(double d) {\n\t\t\terr.println(d);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn d;\n\t\t}\n\n\t\tpublic final double debugln(double d, int length) {\n\t\t\tdebug(d, length);\n\t\t\tdebugln();\n\t\t\treturn d;\n\t\t}\n\n\t\tpublic final float debugln(float f) {\n\t\t\terr.println(f);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn f;\n\t\t}\n\n\t\tpublic final int debugln(int i) {\n\t\t\terr.println(i);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn i;\n\t\t}\n\n\t\tpublic final long debugln(long l) {\n\t\t\terr.println(l);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn l;\n\t\t}\n\n\t\tpublic final Object debugln(Object obj) {\n\t\t\tdebug(obj);\n\t\t\tdebugln();\n\t\t\treturn obj;\n\t\t}\n\n\t\tpublic final String debugln(String s) {\n\t\t\terr.println(s);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn s;\n\t\t}\n\n\t\tpublic final Object debugln(Object array, String... parse) {\n\t\t\tdebug(array, parse);\n\t\t\tdebugln();\n\t\t\treturn array;\n\t\t}\n\n\t\tpublic final void flush() {\n\t\t\tout.flush();\n\t\t\terr.flush();\n\t\t}\n\t}\n\n\tpublic enum BoundType {\n\t\tCLOSED, OPEN;\n\t}\n\n\tpublic static class Range implements Serializable{\n\n\t\tprivate static final long serialVersionUID = -4702828934863023392L;\n\t\tprotected C lower;\n\t\tprotected C upper;\n\t\tprotected BoundType lowerType;\n\t\tprotected BoundType upperType;\n\t\tprivate Comparator comparator;\n\n\t\tprotected Range(C lower, BoundType lowerType, C upper, BoundType upperType) {\n\t\t\tthis(lower, lowerType, upper, upperType, null);\n\t\t}\n\n\t\tprotected Range(C lower, BoundType lowerType, C upper, BoundType upperType, Comparator comparator) {\n\t\t\tthis.lower = lower;\n\t\t\tthis.upper = upper;\n\t\t\tthis.lowerType = lowerType;\n\t\t\tthis.upperType = upperType;\n\t\t\tthis.comparator = comparator;\n\t\t}\n\n\t\tpublic static > Range range(C lower, BoundType lowerType, C upper, BoundType upperType) {\n\t\t\tif (lower != null && upper != null) {\n\t\t\t\tint comp = lower.compareTo(upper);\n\t\t\t\tif (comp > 0) return new Range(null, BoundType.CLOSED, null, BoundType.CLOSED);\n\t\t\t\telse if (comp == 0 && (lowerType == BoundType.OPEN || upperType == BoundType.OPEN))return new Range(null, BoundType.CLOSED, null, BoundType.CLOSED);\n\t\t\t}\n\t\t\treturn new Range(lower, lowerType, upper, upperType);\n\t\t}\n\n\t\tpublic static Range range(C lower, BoundType lowerType, C upper, BoundType upperType, Comparator comparator) {\n\t\t\tif (lower != null && upper != null) {\n\t\t\t\tint comp = comparator.compare(lower, upper);\n\t\t\t\tif (comp > 0) return new Range(null, BoundType.CLOSED, null, BoundType.CLOSED, comparator);\n\t\t\t\telse if (comp == 0 && (lowerType == BoundType.OPEN || upperType == BoundType.OPEN)) return new Range(null, BoundType.CLOSED, null, BoundType.CLOSED, comparator);\n\t\t\t}\n\t\t\treturn new Range(lower, lowerType, upper, upperType, comparator);\n\t\t}\n\n\t\tpublic static > Range all() {\n\t\t\treturn range((C)null, BoundType.OPEN, null, BoundType.OPEN);\n\t\t}\n\n\t\tpublic static Range all(Comparator comparator) {\n\t\t\treturn range((C)null, BoundType.OPEN, null, BoundType.OPEN, comparator);\n\t\t}\n\n\t\tpublic static > Range atMost(C upper) {\n\t\t\treturn range(null, BoundType.OPEN, upper, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static Range atMost(C upper, Comparator comparator) {\n\t\t\treturn range(null, BoundType.OPEN, upper, BoundType.CLOSED, comparator);\n\t\t}\n\n\t\tpublic static > Range lessThan(C upper) {\n\t\t\treturn range(null, BoundType.OPEN, upper, BoundType.OPEN);\n\t\t}\n\n\t\tpublic static Range lessThan(C upper, Comparator comparator) {\n\t\t\treturn range(null, BoundType.OPEN, upper, BoundType.OPEN, comparator);\n\t\t}\n\n\t\tpublic static > Range downTo(C upper, BoundType boundType) {\n\t\t\treturn range(null, BoundType.OPEN, upper, boundType);\n\t\t}\n\n\t\tpublic static Range downTo(C upper, BoundType boundType, Comparator comparator) {\n\t\t\treturn range(null, BoundType.OPEN, upper, boundType, comparator);\n\t\t}\n\n\t\tpublic static > Range atLeast(C lower) {\n\t\t\treturn range(lower, BoundType.CLOSED, null, BoundType.OPEN);\n\t\t}\n\n\t\tpublic static Range atLeast(C lower, Comparator comparator) {\n\t\t\treturn range(lower, BoundType.CLOSED, null, BoundType.OPEN, comparator);\n\t\t}\n\n\t\tpublic static > Range greaterThan(C lower) {\n\t\t\treturn range(lower, BoundType.OPEN, null, BoundType.OPEN);\n\t\t}\n\n\t\tpublic static Range greaterThan(C lower, Comparator comparator) {\n\t\t\treturn range(lower, BoundType.OPEN, null, BoundType.OPEN, comparator);\n\t\t}\n\n\t\tpublic static > Range upTo(C lower, BoundType boundType) {\n\t\t\treturn range(lower, boundType, null, BoundType.OPEN);\n\t\t}\n\n\t\tpublic static Range upTo(C lower, BoundType boundType, Comparator comparator) {\n\t\t\treturn range(lower, boundType, null, BoundType.OPEN, comparator );\n\t\t}\n\n\t\tpublic static > Range open(C lower, C upper) {\n\t\t\treturn range(lower, BoundType.OPEN, upper, BoundType.OPEN);\n\t\t}\n\n\t\tpublic static Range open(C lower, C upper, Comparator comparator) {\n\t\t\treturn range(lower, BoundType.OPEN, upper, BoundType.OPEN, comparator);\n\t\t}\n\n\t\tpublic static > Range openClosed(C lower, C upper) {\n\t\t\treturn range(lower, BoundType.OPEN, upper, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static Range openClosed(C lower, C upper, Comparator comparator) {\n\t\t\treturn range(lower, BoundType.OPEN, upper, BoundType.CLOSED, comparator);\n\t\t}\n\n\t\tpublic static > Range closedOpen(C lower, C upper) {\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.OPEN);\n\t\t}\n\n\t\tpublic static Range closedOpen(C lower, C upper, Comparator comparator) {\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.OPEN, comparator);\n\t\t}\n\n\t\tpublic static > Range closed(C lower, C upper) {\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static Range closed(C lower, C upper, Comparator comparator) {\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.CLOSED, comparator);\n\t\t}\n\n\t\tpublic static > Range singleton(C value) {\n\t\t\treturn range(value, BoundType.CLOSED, value, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static Range singleton(C value, Comparator comparator) {\n\t\t\treturn range(value, BoundType.CLOSED, value, BoundType.CLOSED, comparator);\n\t\t}\n\n\t\tpublic static > Range empty() {\n\t\t\treturn range((C)null, BoundType.CLOSED, null, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static Range empty(Comparator comparator) {\n\t\t\treturn range((C)null, BoundType.CLOSED, null, BoundType.CLOSED, comparator);\n\t\t}\n\n\t\tpublic static > Range encloseAll(Iterable values) {\n\t\t\tC lower = values.iterator().next();\n\t\t\tC upper = lower;\n\t\t\tfor (C i : values) {\n\t\t\t\tif (lower.compareTo(i) > 0) lower = i;\n\t\t\t\tif (upper.compareTo(i) < 0) upper = i;\n\t\t\t}\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static Range encloseAll(Iterable values, Comparator comparator) {\n\t\t\tC lower = values.iterator().next();\n\t\t\tC upper = lower;\n\t\t\tfor (C i : values) {\n\t\t\t\tif (comparator.compare(lower, i) > 0) lower = i;\n\t\t\t\tif (comparator.compare(upper, i) < 0) upper = i;\n\t\t\t}\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.CLOSED, comparator);\n\t\t}\n\n\t\tprotected int compareLower(C value) {\n\t\t\treturn compareLower(value, BoundType.CLOSED);\n\t\t}\n\n\t\tprotected int compareLower(C value, BoundType boundType) {\n\t\t\treturn compareLower(lower, lowerType, value, boundType);\n\t\t}\n\n\t\tprotected int compareLower(C lower, BoundType lowerType, C value) {\n\t\t\treturn compareLower(lower, lowerType, value, BoundType.CLOSED);\n\t\t}\n\n\t\tprotected int compareLower(C lower, BoundType lowerType, C value, BoundType boundType) {\n\t\t\tif (lower == null) return value == null ? 0 : -1;\n\t\t\telse if (value == null) return 1;\n\t\t\tint compare;\n\t\t\tif (comparator == null) {\n\t\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\t\tComparable comp = (Comparable)lower;\n\t\t\t\tcompare = comp.compareTo(value);\n\t\t\t} else compare = comparator.compare(lower, value);\n\t\t\tif (compare == 0) {\n\t\t\t\tif (lowerType == BoundType.CLOSED) -- compare;\n\t\t\t\tif (boundType == BoundType.CLOSED) ++ compare;\n\t\t\t}\n\t\t\treturn compare;\n\t\t}\n\n\t\tprotected int compareUpper(C value) {\n\t\t\treturn compareUpper(value, BoundType.CLOSED);\n\t\t}\n\n\t\tprotected int compareUpper(C value, BoundType boundType) {\n\t\t\treturn compareUpper(upper, upperType, value, boundType);\n\t\t}\n\n\t\tprotected int compareUpper(C upper, BoundType upperType, C value) {\n\t\t\treturn compareUpper(upper, upperType, value, BoundType.CLOSED);\n\t\t}\n\n\t\tprotected int compareUpper(C upper, BoundType upperType, C value, BoundType boundType) {\n\t\t\tif (upper == null) return value == null ? 0 : 1;\n\t\t\tif (value == null) return -1;\n\t\t\tint compare;\n\t\t\tif (comparator == null) {\n\t\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\t\tComparable comp = (Comparable)upper;\n\t\t\t\tcompare = comp.compareTo(value);\n\t\t\t} else compare = comparator.compare(upper, value);\n\t\t\tif (compare == 0) {\n\t\t\t\tif (upperType == BoundType.CLOSED) ++ compare;\n\t\t\t\tif (boundType == BoundType.CLOSED) -- compare;\n\t\t\t}\n\t\t\treturn compare;\n\t\t}\n\n\t\tpublic boolean hasLowerBound() {\n\t\t\treturn lower != null;\n\t\t}\n\n\t\tpublic C lowerEndpoint() {\n\t\t\tif (hasLowerBound()) return lower;\n\t\t\tthrow new IllegalStateException();\n\t\t}\n\n\t\tpublic BoundType lowerBoundType() {\n\t\t\tif (hasLowerBound()) return lowerType;\n\t\t\tthrow new IllegalStateException();\n\t\t}\n\n\t\tpublic boolean hasUpperBound() {\n\t\t\treturn upper != null;\n\t\t}\n\n\t\tpublic C upperEndpoint() {\n\t\t\tif (hasUpperBound()) return upper;\n\t\t\tthrow new IllegalStateException();\n\t\t}\n\n\t\tpublic BoundType upperBoundType() {\n\t\t\tif (hasUpperBound()) return upperType;\n\t\t\tthrow new IllegalStateException();\n\t\t}\n\n\t\t/**\n\t\t * この区間が空集合か判定します。\n\t\t * @return 空集合ならばtrue\n\t\t */\n\t\tpublic boolean isEmpty() {\n\t\t\treturn lower == null && upper == null && lowerType == BoundType.CLOSED;\n\t\t}\n\n\t\t/**\n\t\t * 与えられた引数が区間の左側に位置するか判定します。
\n\t\t * 接する場合は区間の左側ではないと判定します。\n\t\t * @param value 調べる引数\n\t\t * @return 区間の左側に位置するならtrue\n\t\t */\n\t\tpublic boolean isLess(C value) {\n\t\t\treturn isLess(value, BoundType.CLOSED);\n\t\t}\n\n\t\tprotected boolean isLess(C value, BoundType boundType) {\n\t\t\treturn compareLower(value, boundType) > 0;\n\t\t}\n\n\t\t/**\n\t\t * 与えられた引数が区間の右側に位置するか判定します。
\n\t\t * 接する場合は区間の右側ではないと判定します。\n\t\t * @param value 調べる引数\n\t\t * @return 区間の右側に位置するならtrue\n\t\t */\n\t\tpublic boolean isGreater(C value) {\n\t\t\treturn isGreater(value, BoundType.CLOSED);\n\t\t}\n\n\t\tprivate boolean isGreater(C value, BoundType boundType) {\n\t\t\treturn compareUpper(value, boundType) < 0;\n\t\t}\n\n\t\t/**\n\t\t * 与えられた引数が区間内に位置するか判定します。
\n\t\t * 接する場合も区間内に位置すると判定します。\n\t\t * @param value 調べる引数\n\t\t * @return 区間内に位置するならtrue\n\t\t */\n\t\tpublic boolean contains(C value) {\n\t\t\treturn !isLess(value) && !isGreater(value) && !isEmpty();\n\t\t}\n\n\t\t/**\n\t\t * 与えられた引数すべてが区間内に位置するか判定します。
\n\t\t * 接する場合も区間内に位置すると判定します。\n\t\t * @param value 調べる要素\n\t\t * @return 全ての要素が区間内に位置するならtrue\n\t\t */\n\t\tpublic boolean containsAll(Iterable values) {\n\t\t\tfor (C i : values) if (!contains(i)) return false;\n\t\t\treturn true;\n\t\t}\n\n\t\t/**\n\t\t * 与えられた区間がこの区間に内包されるか判定します。
\n\t\t *\n\t\t * @param other\n\t\t * @return 与えられた区間がこの区間に内包されるならtrue\n\t\t */\n\t\tpublic boolean encloses(Range other) {\n\t\t\treturn !isLess(other.lower, other.lowerType) && !isGreater(other.upper, other.upperType);\n\t\t}\n\n\t\t/**\n\t\t * 与えられた区間がこの区間と公差するか判定します。
\n\t\t * 接する場合は公差するものとします。\n\t\t * @param value 調べる引数\n\t\t * @return 区間が交差するならtrue\n\t\t */\n\t\tpublic boolean isConnected(Range other) {\n\t\t\tif (this.isEmpty() || other.isEmpty()) return false;\n\t\t\tC lower, upper;\n\t\t\tBoundType lowerType, upperType;\n\t\t\tif (isLess(other.lower, other.lowerType)) {\n\t\t\t\tlower = other.lower;\n\t\t\t\tlowerType = other.lowerType;\n\t\t\t} else {\n\t\t\t\tlower = this.lower;\n\t\t\t\tlowerType = this.lowerType;\n\t\t\t}\n\t\t\tif (isGreater(other.upper, other.upperType)) {\n\t\t\t\tupper = other.upper;\n\t\t\t\tupperType = other.upperType;\n\t\t\t} else {\n\t\t\t\tupper = this.upper;\n\t\t\t\tupperType = this.upperType;\n\t\t\t}\n\t\t\tif (lower == null || upper == null) return true;\n\t\t\tint comp = compareLower(lower, lowerType, upper, upperType);\n\t\t\treturn comp <= 0;\n\t\t}\n\t\t/**\n\t\t * この区間との積集合を返します。\n\t\t * @param connectedRange 積集合を求める区間\n\t\t * @return 積集合\n\t\t */\n\t\tpublic Range intersection(Range connectedRange) {\n\t\t\tif (this.isEmpty() || connectedRange.isEmpty()) {\n\t\t\t\tif (comparator == null) return new Range(null, BoundType.CLOSED, null, BoundType.CLOSED);\n\t\t\t\treturn empty(comparator);\n\t\t\t}\n\t\t\tC lower, upper;\n\t\t\tBoundType lowerType, upperType;\n\t\t\tif (isLess(connectedRange.lower, connectedRange.lowerType)) {\n\t\t\t\tlower = connectedRange.lower;\n\t\t\t\tlowerType = connectedRange.lowerType;\n\t\t\t} else {\n\t\t\t\tlower = this.lower;\n\t\t\t\tlowerType = this.lowerType;\n\t\t\t}\n\t\t\tif (isGreater(connectedRange.upper, connectedRange.upperType)) {\n\t\t\t\tupper = connectedRange.upper;\n\t\t\t\tupperType = connectedRange.upperType;\n\t\t\t} else {\n\t\t\t\tupper = this.upper;\n\t\t\t\tupperType = this.upperType;\n\t\t\t}\n\t\t\tif (comparator == null) {\n\t\t\t\treturn new Range(lower, lowerType, upper, upperType);\n\t\t\t}\n\t\t\treturn range(lower, lowerType, upper, upperType, comparator);\n\t\t}\n\n\t\t/**\n\t\t * この区間との和集合を返します。\n\t\t * @param other 和集合を求める区間\n\t\t * @return 和集合\n\t\t */\n\t\tpublic Range span(Range other) {\n\t\t\tif (other.isEmpty()) return new Range(lower, lowerType, upper, upperType);\n\t\t\tC lower, upper;\n\t\t\tBoundType lowerType, upperType;\n\t\t\tif (isLess(other.lower, other.lowerType)) {\n\t\t\t\tlower = this.lower;\n\t\t\t\tlowerType = this.lowerType;\n\t\t\t} else {\n\t\t\t\tlower = other.lower;\n\t\t\t\tlowerType = other.lowerType;\n\t\t\t}\n\t\t\tif (isGreater(other.upper, other.upperType)) {\n\t\t\t\tupper = this.upper;\n\t\t\t\tupperType = this.upperType;\n\t\t\t} else {\n\t\t\t\tupper = other.upper;\n\t\t\t\tupperType = other.upperType;\n\t\t\t}\n\t\t\treturn new Range(lower, lowerType, upper, upperType, comparator);\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean equals(Object object) {\n\t\t\tif (this == object) return true;\n\t\t\tif (object instanceof Range) {\n\t\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\t\tRange comp = (Range) object;\n\t\t\t\treturn compareLower(comp.lower, comp.lowerType) == 0 && compareUpper(comp.upper, comp.upperType) == 0 && lowerType == comp.lowerType && upperType == comp.upperType;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\t@Override\n\t\tpublic int hashCode() {\n\t\t\tif (lower == null && upper == null) return 0;\n\t\t\telse if (lower == null) return upper.hashCode();\n\t\t\telse if (upper == null) return lower.hashCode();\n\t\t\treturn lower.hashCode() ^ upper.hashCode();\n\t\t}\n\n\t\t@Override\n\t\tpublic String toString() {\n\t\t\tif (isEmpty()) return \"()\";\n\t\t\treturn (lowerType == BoundType.OPEN ? \"(\" : \"[\") + (lower == null ? \"\" : lower.toString()) + \"..\" + (upper == null ? \"\" : upper.toString()) + (upperType == BoundType.OPEN ? \")\" : \"]\");\n\t\t}\n\t}\n\n\tpublic static class IterableRange extends Range implements Iterable{\n\n\t\tprivate static final long serialVersionUID = 9065915259748260688L;\n\t\tprotected UnaryOperator func;\n\n\t\tprotected IterableRange(C lower, BoundType lowerType, C upper, BoundType upperType, UnaryOperator func) {\n\t\t\tsuper(lower, lowerType, upper, upperType);\n\t\t\tthis.func = func;\n\t\t}\n\n\t\tpublic static > IterableRange range(C lower, BoundType lowerType, C upper, BoundType upperType, UnaryOperator func) {\n\t\t\tif (lower == null || upper == null) return new IterableRange(null, BoundType.CLOSED, null, BoundType.CLOSED, func);\n\t\t\tint comp = lower.compareTo(upper);\n\t\t\tif (comp > 0) return new IterableRange(null, BoundType.CLOSED, null, BoundType.CLOSED, func);\n\t\t\telse if (comp == 0 && (lowerType == BoundType.OPEN || upperType == BoundType.OPEN)) return new IterableRange(null, BoundType.CLOSED, null, BoundType.CLOSED, func);\n\t\t\treturn new IterableRange(lower, lowerType, upper, upperType, func);\n\t\t}\n\n\t\tpublic static > IterableRange open(C lower, C upper, UnaryOperator func) {\n\t\t\tif (lower == null) return new IterableRange(null, BoundType.CLOSED, null, BoundType.CLOSED, func);\n\t\t\treturn range(func.apply(lower), BoundType.CLOSED, upper, BoundType.OPEN, func);\n\t\t}\n\n\t\tpublic static > IterableRange openClosed(C lower, C upper, UnaryOperator func) {\n\t\t\tif (lower == null) return new IterableRange(null, BoundType.CLOSED, null, BoundType.CLOSED, func);\n\t\t\treturn range(func.apply(lower), BoundType.CLOSED, upper, BoundType.CLOSED, func);\n\t\t}\n\n\t\tpublic static > IterableRange closedOpen(C lower, C upper, UnaryOperator func) {\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.OPEN, func);\n\t\t}\n\n\t\tpublic static > IterableRange closed(C lower, C upper, UnaryOperator func) {\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.CLOSED, func);\n\t\t}\n\n\t\tpublic static > IterableRange singleton(C value, UnaryOperator func) {\n\t\t\treturn range(value, BoundType.CLOSED, value, BoundType.CLOSED, func);\n\t\t}\n\n\t\tprotected class Iter implements Iterator {\n\t\t\tC now;\n\t\t\tIter() {\n\t\t\t\tnow = lower;\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic final boolean hasNext() {\n\t\t\t\treturn !isGreater(now);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic final C next() {\n\t\t\t\tC ret = now;\n\t\t\t\tnow = func.apply(now);\n\t\t\t\treturn ret;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic final void remove() {\n\t\t\t\tthrow new UnsupportedOperationException();\n\t\t\t}\n\t\t}\n\n\t\tprotected class EmptyIter implements Iterator {\n\n\t\t\t@Override\n\t\t\tpublic boolean hasNext() {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic C next() {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic final void remove() {\n\t\t\t\tthrow new UnsupportedOperationException();\n\t\t\t}\n\n\t\t}\n\n\t\t@Override\n\t\tpublic Iterator iterator() {\n\t\t\treturn lower == null || upper == null ? new EmptyIter() : new Iter();\n\t\t}\n\n\t\tpublic int getDistance() {\n\t\t\tC check = upper;\n\t\t\tint ret = 0;\n\t\t\twhile (lower != check) {\n\t\t\t\tcheck = func.apply(check);\n\t\t\t\t++ ret;\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\t}\n\n\tpublic static class IntRange extends IterableRange{\n\n\t\tprivate static final long serialVersionUID = 5623995336491967216L;\n\t\tprivate final boolean useFastIter;\n\n\t\tprivate static class Next implements UnaryOperator {\n\n\t\t\t@Override\n\t\t\tpublic Integer apply(Integer value) {\n\t\t\t\treturn value + 1;\n\t\t\t}\n\t\t}\n\n\t\tprotected IntRange() {\n\t\t\tsuper(null, BoundType.CLOSED, null, BoundType.CLOSED, new Next());\n\t\t\tuseFastIter = true;\n\t\t}\n\n\t\tprotected IntRange(UnaryOperator func) {\n\t\t\tsuper(null, BoundType.CLOSED, null, BoundType.CLOSED, func);\n\t\t\tuseFastIter = false;\n\t\t}\n\n\t\tprotected IntRange(int lower, BoundType lowerType, int upper, BoundType upperType) {\n\t\t\tsuper(lower, lowerType, upper, upperType, new Next());\n\t\t\tuseFastIter = true;\n\t\t}\n\n\t\tprotected IntRange(int lower, BoundType lowerType, int upper, BoundType upperType, UnaryOperator func) {\n\t\t\tsuper(lower, lowerType, upper, upperType, func);\n\t\t\tuseFastIter = false;\n\t\t}\n\n\t\tpublic static IntRange range(int lower, BoundType lowerType, int upper, BoundType upperType) {\n\t\t\tif (lower > upper) return new IntRange();\n\t\t\tif (lowerType == BoundType.OPEN) ++ lower;\n\t\t\tif (upperType == BoundType.OPEN) -- upper;\n\t\t\treturn new IntRange(lower, BoundType.CLOSED, upper, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static IntRange range(int lower, BoundType lowerType, int upper, BoundType upperType, UnaryOperator func) {\n\t\t\tif (lower > upper) return new IntRange(func);\n\t\t\tif (lowerType == BoundType.OPEN) ++ lower;\n\t\t\tif (upperType == BoundType.OPEN) -- upper;\n\t\t\treturn new IntRange(lower, BoundType.CLOSED, upper, BoundType.CLOSED, func);\n\t\t}\n\n\t\tpublic static IntRange open(int lower, int upper) {\n\t\t\treturn range(lower, BoundType.OPEN, upper, BoundType.OPEN);\n\t\t}\n\n\t\tpublic static IntRange open(int lower, int upper, UnaryOperator func) {\n\t\t\treturn range(lower, BoundType.OPEN, upper, BoundType.OPEN, func);\n\t\t}\n\n\t\tpublic static IntRange open(int upper) {\n\t\t\treturn range(0, BoundType.CLOSED, upper, BoundType.OPEN);\n\t\t}\n\n\t\tpublic static IntRange open(int upper, UnaryOperator func) {\n\t\t\treturn range(0, BoundType.CLOSED, upper, BoundType.OPEN, func);\n\t\t}\n\n\t\tpublic static IntRange openClosed(int lower, int upper) {\n\t\t\treturn range(lower, BoundType.OPEN, upper, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static IntRange openClosed(int lower, int upper, UnaryOperator func) {\n\t\t\treturn range(lower, BoundType.OPEN, upper, BoundType.CLOSED, func);\n\t\t}\n\n\t\tpublic static IntRange closedOpen(int lower, int upper) {\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.OPEN);\n\t\t}\n\n\t\tpublic static IntRange closedOpen(int lower, int upper, UnaryOperator func) {\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.OPEN, func);\n\t\t}\n\n\t\tpublic static IntRange closed(int lower, int upper) {\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static IntRange closed(int lower, int upper, UnaryOperator func) {\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.CLOSED, func);\n\t\t}\n\n\t\tpublic static IntRange closed(int upper) {\n\t\t\treturn range(0, BoundType.CLOSED, upper, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static IntRange closed(int upper, UnaryOperator func) {\n\t\t\treturn range(0, BoundType.CLOSED, upper, BoundType.CLOSED, func);\n\t\t}\n\n\t\tpublic static IntRange singleton(int value) {\n\t\t\treturn range(value, BoundType.CLOSED, value, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static IntRange singleton(int value, UnaryOperator func) {\n\t\t\treturn range(value, BoundType.CLOSED, value, BoundType.CLOSED, func);\n\t\t}\n\n\t\tprivate class FastIter implements Iterator {\n\t\t\tint now;\n\t\t\tpublic FastIter() {\n\t\t\t\tnow = lower;\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic final boolean hasNext() {\n\t\t\t\treturn now <= upper;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic final Integer next() {\n\t\t\t\treturn now++;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic final void remove() {\n\t\t\t\tthrow new UnsupportedOperationException();\n\t\t\t}\n\t\t}\n\n\t\tprivate class Iter implements Iterator {\n\t\t\tint now;\n\t\t\tpublic Iter() {\n\t\t\t\tnow = lower;\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic final boolean hasNext() {\n\t\t\t\treturn now <= upper;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic final Integer next() {\n\t\t\t\tint ret = now;\n\t\t\t\tnow = func.apply(now);\n\t\t\t\treturn ret;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic final void remove() {\n\t\t\t\tthrow new UnsupportedOperationException();\n\t\t\t}\n\t\t}\n\n\t\t@Override\n\t\tpublic Iterator iterator() {\n\t\t\treturn lower == null || upper == null ? new EmptyIter() : useFastIter ? new FastIter() : new Iter();\n\t\t}\n\n\t\t@Override\n\t\tpublic int getDistance() {\n\t\t\tint ret = upper - lower;\n\t\t\tif (upperType == BoundType.CLOSED) ++ ret;\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic int getClosedLower() {\n\t\t\treturn lower;\n\t\t}\n\n\t\tpublic int getOpenLower() {\n\t\t\treturn lower - 1;\n\t\t}\n\n\t\tpublic int getClosedUpper() {\n\t\t\treturn upperType == BoundType.CLOSED ? upper : upper - 1;\n\t\t}\n\n\t\tpublic int getOpenUpper() {\n\t\t\treturn upperType == BoundType.CLOSED ? upper + 1 : upper;\n\t\t}\n\t}\n\n\t/**\n\t * 演算が結合法則を満たすことを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t */\n\tpublic interface Associative extends BinaryOperator{\n\t\t/**\n\t\t * repeat個のelementを順次演算した値を返します。\n\t\t * @param element 演算する値\n\t\t * @param repeat 繰り返す回数、1以上であること\n\t\t * @return 演算を+として、element + element + ... + elementと演算をrepeat-1回行った値\n\t\t */\n\t\tpublic default T hyper(T element, int repeat) {\n\t\t\tif (repeat < 1) throw new IllegalArgumentException(\"undefined operation\");\n\t\t\tT ret = element;\n\t\t\t-- repeat;\n\t\t\tfor (T mul = element;repeat > 0;repeat >>= 1, mul = apply(mul, mul)) if ((repeat & 1) != 0) ret = apply(ret, mul);\n\t\t\treturn ret;\n\t\t}\n\t}\n\n\t/**\n\t* この演算が逆元を持つことを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t */\n\tpublic interface Inverse extends BinaryOperator{\n\t\tpublic T inverse(T element);\n\t}\n\n\t/**\n\t * 演算が交換法則を満たすことを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t */\n\tpublic interface Commutative extends BinaryOperator{\n\n\t}\n\n\t/**\n\t * 演算が単位元を持つことを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t */\n\tpublic interface Identity extends BinaryOperator{\n\t\t/**\n\t\t * 単位元を返します。\n\t\t * @return 単位元\n\t\t */\n\t\tpublic T identity();\n\t}\n\n\t/**\n\t * 演算が群であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t */\n\tpublic interface Group extends Monoid, Inverse{\n\t\t/**\n\t\t * repeat個のelementを順次演算した値を返します。\n\t\t * @param element 演算する値\n\t\t * @param repeat 繰り返す回数\n\t\t * @return 演算を+として、element + element + ... + elementと演算をrepeat-1回行った値\n\t\t */\n\t\t@Override\n\t\tpublic default T hyper(T element, int repeat) {\n\t\t\tT ret = identity();\n\t\t\tif (repeat < 0) {\n\t\t\t\trepeat = -repeat;\n\t\t\t\tfor (T mul = element;repeat > 0;repeat >>= 1, mul = apply(mul, mul)) if ((repeat & 1) != 0) ret = apply(ret, mul);\n\t\t\t\treturn inverse(ret);\n\t\t\t}\n\t\t\tfor (T mul = element;repeat > 0;repeat >>= 1, mul = apply(mul, mul)) if ((repeat & 1) != 0) ret = apply(ret, mul);\n\t\t\treturn ret;\n\t\t}\n\t}\n\n\t/**\n\t * 演算がモノイドであることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t */\n\tpublic interface Monoid extends Associative, Identity {\n\t\t/**\n\t\t * repeat個のelementを順次演算した値を返します。\n\t\t * @param element 演算する値\n\t\t * @param repeat 繰り返す回数、0以上であること\n\t\t * @return 演算を+として、element + element + ... + elementと演算をrepeat-1回行った値\n\t\t */\n\t\t@Override\n\t\tpublic default T hyper(T element, int repeat) {\n\t\t\tif (repeat < 0) throw new IllegalArgumentException(\"undefined operation\");\n\t\t\tT ret = identity();\n\t\t\tfor (T mul = element;repeat > 0;repeat >>= 1, mul = apply(mul, mul)) if ((repeat & 1) != 0) ret = apply(ret, mul);\n\t\t\treturn ret;\n\t\t}\n\t}\n\n\t/**\n\t * 演算が可換モノイドであることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t */\n\tpublic interface CommutativeMonoid extends Monoid, Commutative {\n\n\t}\n\n\t/**\n\t * 演算がアーベル群(可換群)であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t */\n\tpublic interface Abelian extends Group, CommutativeMonoid {\n\n\t}\n\n\t/**\n\t * 演算が半環であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t * @param 和に関する演算\n\t * @param 積に関する演算\n\t */\n\tpublic interface Semiring, M extends Monoid> {\n\t\tpublic A getAddition();\n\t\tpublic M getMultiplication();\n\t\tpublic default T add(T left, T right) {\n\t\t\treturn getAddition().apply(left, right);\n\t\t}\n\n\t\tpublic default T multiply(T left, T right) {\n\t\t\treturn getMultiplication().apply(left, right);\n\t\t}\n\n\t\tpublic default T additiveIdentity() {\n\t\t\treturn getAddition().identity();\n\t\t}\n\n\t\tpublic default T multipleIdentity() {\n\t\t\treturn getMultiplication().identity();\n\t\t}\n\n\t\tpublic default int characteristic() {\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\t/**\n\t * 演算が環であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t * @param 和に関する演算\n\t * @param 積に関する演算\n\t */\n\tpublic interface Ring, M extends Monoid> extends Semiring{\n\n\t}\n\n\t/**\n\t * 演算が可換環に属することを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t * @param 和に関する演算\n\t * @param 積に関する演算\n\t */\n\tpublic interface CommutativeRing, M extends CommutativeMonoid> extends Ring{\n\n\t}\n\n\t/**\n\t * 演算が整域であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t * @param 和に関する演算\n\t * @param 積に関する演算\n\t */\n\tpublic interface IntegralDomain, M extends CommutativeMonoid> extends CommutativeRing{\n\t\tpublic boolean isDivisible(T left, T right);\n\t\tpublic T divide(T left, T right);\n\t}\n\n\t/**\n\t * 演算が整閉整域であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t * @param 和に関する演算\n\t * @param 積に関する演算\n\t */\n\tpublic interface IntegrallyClosedDomain, M extends CommutativeMonoid> extends IntegralDomain{\n\n\t}\n\n\t/**\n\t * 演算がGCD整域であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t * @param 和に関する演算\n\t * @param 積に関する演算\n\t */\n\tpublic interface GCDDomain, M extends CommutativeMonoid> extends IntegrallyClosedDomain{\n\t\tpublic T gcd(T left, T right);\n\t\tpublic T lcm(T left, T right);\n\t}\n\n\t/**\n\t * 素元を提供します。\n\t * @author 31536000\n\t *\n\t * @param 演算の型\n\t */\n\tpublic static class PrimeElement {\n\t\tpublic final T element;\n\t\tpublic PrimeElement(T element) {\n\t\t\tthis.element = element;\n\t\t}\n\t}\n\n\tpublic interface MultiSet extends Collection{\n\t\tpublic int add(E element, int occurrences);\n\t\tpublic int count(Object element);\n\t\tpublic Set elementSet();\n\t\tpublic boolean remove(Object element, int occurrences);\n\t\tpublic int setCount(E element, int count);\n\t\tpublic boolean setCount(E element, int oldCount, int newCount);\n\t}\n\n\t/**\n\t * 演算が一意分解整域であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t * @param 和に関する演算\n\t * @param 積に関する演算\n\t */\n\tpublic interface UniqueFactorizationDomain, M extends CommutativeMonoid> extends GCDDomain{\n\t\tpublic MultiSet> PrimeFactorization(T x);\n\t}\n\n\t/**\n\t * 演算が主イデアル整域であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t * @param 和に関する演算\n\t * @param 積に関する演算\n\t */\n\tpublic interface PrincipalIdealDomain, M extends CommutativeMonoid> extends UniqueFactorizationDomain {\n\n\t}\n\n\t/**\n\t * 演算がユークリッド整域であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t * @param 和に関する演算\n\t * @param 積に関する演算\n\t */\n\tpublic interface EuclideanDomain, M extends CommutativeMonoid> extends PrincipalIdealDomain{\n\t\tpublic T reminder(T left, T right);\n\t}\n\n\t/**\n\t * 演算が体であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t * @param 和に関する演算\n\t * @param 積に関する演算\n\t */\n\tpublic interface Field, M extends Abelian> extends EuclideanDomain{\n\t\t@Override\n\t\tpublic default boolean isDivisible(T left, T right) {\n\t\t\treturn !right.equals(additiveIdentity());\n\t\t}\n\n\t\t@Override\n\t\tpublic default T divide(T left, T right) {\n\t\t\tif (isDivisible(left, right)) throw new ArithmeticException(\"divide by Additive Identify\");\n\t\t\treturn multiply(left, getMultiplication().inverse(right));\n\t\t}\n\n\t\t@Override\n\t\tpublic default T reminder(T left, T right) {\n\t\t\tif (isDivisible(left, right)) throw new ArithmeticException(\"divide by Additive Identify\");\n\t\t\treturn additiveIdentity();\n\t\t}\n\n\t\t@Override\n\t\tpublic default T gcd(T left, T right) {\n\t\t\treturn multipleIdentity();\n\t\t}\n\n\t\t@Override\n\t\tpublic default T lcm(T left, T right) {\n\t\t\treturn multipleIdentity();\n\t\t}\n\n\t\t@Override\n\t\tpublic default MultiSet> PrimeFactorization(T x) {\n\t\t\tHashMultiSet> ret = HashMultiSet.create(1);\n\t\t\tret.add(new PrimeElement(x));\n\t\t\treturn ret;\n\t\t}\n\t}\n\n\tpublic static class HashMultiSet implements MultiSet, Serializable{\n\n\t\tprivate static final long serialVersionUID = -8378919645386251159L;\n\t\tprivate final transient HashMap map;\n\t\tprivate transient int size;\n\n\t\tprivate HashMultiSet() {\n\t\t\tmap = new HashMap<>();\n\t\t\tsize = 0;\n\t\t}\n\n\t\tprivate HashMultiSet(int distinctElements) {\n\t\t\tmap = new HashMap<>(distinctElements);\n\t\t\tsize = 0;\n\t\t}\n\n\t\tpublic static HashMultiSet create() {\n\t\t\treturn new HashMultiSet<>();\n\t\t}\n\n\t\tpublic static HashMultiSet create(int distinctElements) {\n\t\t\treturn new HashMultiSet<>(distinctElements);\n\t\t}\n\n\t\tpublic static HashMultiSet create(Iterable elements) {\n\t\t\tHashMultiSet ret = new HashMultiSet<>();\n\t\t\tfor (E i : elements) ret.map.compute(i, (v, e) -> e == null ? 1 : ++e);\n\t\t\treturn ret;\n\t\t}\n\n\t\t@Override\n\t\tpublic int size() {\n\t\t\treturn size;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean isEmpty() {\n\t\t\treturn size == 0;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean contains(Object o) {\n\t\t\treturn map.containsKey(o);\n\t\t}\n\n\t\tprivate class Iter implements Iterator {\n\n\t\t\tprivate final Iterator> iter = map.entrySet().iterator();\n\t\t\tprivate E value;\n\t\t\tprivate int count = 0;\n\n\t\t\t@Override\n\t\t\tpublic boolean hasNext() {\n\t\t\t\tif (count > 0) return true;\n\t\t\t\tif (iter.hasNext()) {\n\t\t\t\t\tEntry entry = iter.next();\n\t\t\t\t\tvalue = entry.getKey();\n\t\t\t\t\tcount = entry.getValue();\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic E next() {\n\t\t\t\t-- count;\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t}\n\n\t\t@Override\n\t\tpublic Iterator iterator() {\n\t\t\treturn new Iter();\n\t\t}\n\n\t\t@Override\n\t\tpublic Object[] toArray() {\n\t\t\tObject[] ret = new Object[size];\n\t\t\tint read = 0;\n\t\t\tfor (Entry i : map.entrySet()) Arrays.fill(ret, read, read += i.getValue(), i.getKey());\n\t\t\treturn ret;\n\t\t}\n\n\t\t@Override\n\t\tpublic T[] toArray(T[] a) {\n\t\t\tObject[] src = toArray();\n\t\t\tif (a.length < src.length) {\n\t\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\t\tT[] ret = (T[])Arrays.copyOfRange(src, 0, src.length, a.getClass());\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t\tSystem.arraycopy(src, 0, a, 0, src.length);\n\t\t\treturn a;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean add(E e) {\n\t\t\tadd(e, 1);\n\t\t\treturn true;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean remove(Object o) {\n\t\t\treturn remove(o, 1);\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean containsAll(Collection c) {\n\t\t\tboolean ret = true;\n\t\t\tfor (Object i : c) ret |= contains(i);\n\t\t\treturn ret;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean addAll(Collection c) {\n\t\t\tboolean ret = false;\n\t\t\tfor (E i : c) ret |= add(i);\n\t\t\treturn ret;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean removeAll(Collection c) {\n\t\t\tboolean ret = false;\n\t\t\tfor (Object i : c) ret |= remove(i);\n\t\t\treturn ret;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean retainAll(Collection c) {\n\t\t\treturn removeAll(c);\n\t\t}\n\n\t\t@Override\n\t\tpublic void clear() {\n\t\t\tmap.clear();\n\t\t\tsize = 0;\n\t\t}\n\n\t\t@Override\n\t\tpublic int add(E element, int occurrences) {\n\t\t\tsize += occurrences;\n\t\t\treturn map.compute(element, (k, v) -> v == null ? occurrences : v + occurrences) - occurrences;\n\t\t}\n\n\t\t@Override\n\t\tpublic int count(Object element) {\n\t\t\treturn map.getOrDefault(element, 0);\n\t\t}\n\n\t\t@Override\n\t\tpublic Set elementSet() {\n\t\t\treturn map.keySet();\n\t\t}\n\n\t\tpublic Set> entrySet() {\n\t\t\treturn map.entrySet();\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean remove(Object element, int occurrences) {\n\t\t\ttry {\n\t\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\t\tE put = (E) element;\n\t\t\t\treturn map.compute(put, (k, v) -> {\n\t\t\t\t\tif (v == null) return null;\n\t\t\t\t\tif (v < occurrences) {\n\t\t\t\t\t\tsize -= v;\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tsize -= occurrences;\n\t\t\t\t\treturn v - occurrences;\n\t\t\t\t}) != null;\n\t\t\t} catch (ClassCastException E) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t@Override\n\t\tpublic int setCount(E element, int count) {\n\t\t\tInteger ret = map.put(element, count);\n\t\t\tint ret2 = ret == null ? 0 : ret;\n\t\t\tsize += count - ret2;\n\t\t\treturn ret2;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean setCount(E element, int oldCount, int newCount) {\n\t\t\tboolean ret = map.replace(element, oldCount, newCount);\n\t\t\tif (ret) size += newCount - oldCount;\n\t\t\treturn ret;\n\t\t}\n\n\t}\n\n\tpublic static class ModInteger extends Number implements Field, Abelian>{\n\n\t\tprivate static final long serialVersionUID = -8595710127161317579L;\n\t\tprivate final int mod;\n\t\tprivate int num;\n\n\t\tprivate final Addition add;\n\t\tprivate final Multiplication mul;\n\n\t\tprivate class Addition implements Abelian {\n\n\t\t\t@Override\n\t\t\tpublic ModInteger identity() {\n\t\t\t\treturn new ModInteger(mod, 0);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic ModInteger inverse(ModInteger element) {\n\t\t\t\treturn new ModInteger(element, element.mod - element.num);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic ModInteger apply(ModInteger left, ModInteger right) {\n\t\t\t\treturn new ModInteger(left).addEqual(right);\n\t\t\t}\n\t\t}\n\n\t\tprivate class Multiplication implements Abelian {\n\n\t\t\t@Override\n\t\t\tpublic ModInteger identity() {\n\t\t\t\treturn new ModInteger(mod, 1);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic ModInteger apply(ModInteger left, ModInteger right) {\n\t\t\t\treturn new ModInteger(left).multiplyEqual(right);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic ModInteger inverse(ModInteger element) {\n\t\t\t\treturn new ModInteger(element, element.inverse(element.num));\n\t\t\t}\n\n\t\t}\n\n\t\t@Override\n\t\tpublic int characteristic() {\n\t\t\treturn mod;\n\t\t}\n\n\t\tpublic ModInteger(int mod) {\n\t\t\tthis.mod = mod;\n\t\t\tnum = 0;\n\t\t\tadd = new Addition();\n\t\t\tmul = new Multiplication();\n\t\t}\n\n\t\tpublic ModInteger(int mod, int num) {\n\t\t\tthis.mod = mod;\n\t\t\tthis.num = validNum(num);\n\t\t\tadd = new Addition();\n\t\t\tmul = new Multiplication();\n\t\t}\n\n\t\tpublic ModInteger(ModInteger n) {\n\t\t\tmod = n.mod;\n\t\t\tnum = n.num;\n\t\t\tadd = n.add;\n\t\t\tmul = n.mul;\n\t\t}\n\n\t\tprivate ModInteger(ModInteger n, int num) {\n\t\t\tmod = n.mod;\n\t\t\tthis.num = num;\n\t\t\tadd = n.add;\n\t\t\tmul = n.mul;\n\t\t}\n\n\t\tprivate int validNum(int n) {\n\t\t\tn %= mod;\n\t\t\tif (n < 0) n += mod;\n\t\t\treturn n;\n\t\t}\n\n\t\tprivate int validNum(long n) {\n\t\t\tn %= mod;\n\t\t\tif (n < 0) n += mod;\n\t\t\treturn (int)n;\n\t\t}\n\n\t\tprotected int inverse(int n) {\n\t\t\tint m = mod, u = 0, v = 1, t;\n\t\t\twhile(n != 0) {\n\t\t\t\tt = m / n;\n\t\t\t\tm -= t * n;\n\t\t\t\tu -= t * v;\n\t\t\t\tif (m != 0) {\n\t\t\t\t\tt = n / m;\n\t\t\t\t\tn -= t * m;\n\t\t\t\t\tv -= t * u;\n\t\t\t\t} else {\n\t\t\t\t\tv %= mod;\n\t\t\t\t\tif (v < 0) v += mod;\n\t\t\t\t\treturn v;\n\t\t\t\t}\n\t\t\t}\n\t\t\tu %= mod;\n\t\t\tif (u < 0) u += mod;\n\t\t\treturn u;\n\t\t}\n\n\t\tpublic boolean isPrime(int n) {\n\t\t\tif ((n & 1) == 0) return false; // 偶数\n\t\t\tfor (int i = 3, j = 8, k = 9;k <= n;i += 2, k += j += 8) if (n % i == 0) return false;\n\t\t\treturn true;\n\t\t}\n\n\t\t@Override\n\t\tpublic int intValue() {\n\t\t\treturn num;\n\t\t}\n\n\t\t@Override\n\t\tpublic long longValue() {\n\t\t\treturn num;\n\t\t}\n\n\t\t@Override\n\t\tpublic float floatValue() {\n\t\t\treturn num;\n\t\t}\n\n\t\t@Override\n\t\tpublic double doubleValue() {\n\t\t\treturn num;\n\t\t}\n\n\t\tprotected ModInteger getNewInstance(ModInteger mod) {\n\t\t\treturn new ModInteger(mod);\n\t\t}\n\n\t\tpublic ModInteger add(int n) {\n\t\t\treturn getNewInstance(this).addEqual(n);\n\t\t}\n\n\t\tpublic ModInteger add(long n) {\n\t\t\treturn getNewInstance(this).addEqual(n);\n\t\t}\n\n\t\tpublic ModInteger add(ModInteger n) {\n\t\t\treturn getNewInstance(this).addEqual(n);\n\t\t}\n\n\t\tpublic ModInteger addEqual(int n) {\n\t\t\tnum = validNum(num + n);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger addEqual(long n) {\n\t\t\tnum = validNum(num + n);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger addEqual(ModInteger n) {\n\t\t\tif ((num += n.num) >= mod) num -= mod;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger subtract(int n) {\n\t\t\treturn getNewInstance(this).subtractEqual(n);\n\t\t}\n\n\t\tpublic ModInteger subtract(long n) {\n\t\t\treturn getNewInstance(this).subtractEqual(n);\n\t\t}\n\n\t\tpublic ModInteger subtract(ModInteger n) {\n\t\t\treturn getNewInstance(this).subtractEqual(n);\n\t\t}\n\n\t\tpublic ModInteger subtractEqual(int n) {\n\t\t\tnum = validNum(num - n);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger subtractEqual(long n) {\n\t\t\tnum = validNum(num - n);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger subtractEqual(ModInteger n) {\n\t\t\tif ((num -= n.num) < 0) num += mod;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger multiply(int n) {\n\t\t\treturn getNewInstance(this).multiplyEqual(n);\n\t\t}\n\n\t\tpublic ModInteger multiply(long n) {\n\t\t\treturn getNewInstance(this).multiplyEqual(n);\n\t\t}\n\n\t\tpublic ModInteger multiply(ModInteger n) {\n\t\t\treturn getNewInstance(this).multiplyEqual(n);\n\t\t}\n\n\t\tpublic ModInteger multiplyEqual(int n) {\n\t\t\tnum = (int)((long)num * n % mod);\n\t\t\tif (num < 0) num += mod;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger multiplyEqual(long n) {\n\t\t\treturn multiplyEqual((int) (n % mod));\n\t\t}\n\n\t\tpublic ModInteger multiplyEqual(ModInteger n) {\n\t\t\tnum = (int)((long)num * n.num % mod);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger divide(int n) {\n\t\t\treturn getNewInstance(this).divideEqual(n);\n\t\t}\n\n\t\tpublic ModInteger divide(long n) {\n\t\t\treturn getNewInstance(this).divideEqual(n);\n\t\t}\n\n\t\tpublic ModInteger divide(ModInteger n) {\n\t\t\treturn getNewInstance(this).divideEqual(n);\n\t\t}\n\n\t\tpublic ModInteger divideEqual(int n) {\n\t\t\tnum = (int)((long)num * inverse(validNum(n)) % mod);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger divideEqual(long n) {\n\t\t\treturn divideEqual((int)(n % mod));\n\t\t}\n\n\t\tpublic ModInteger divideEqual(ModInteger n) {\n\t\t\tnum = (int)((long)num * n.inverse(n.num) % mod);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger pow(int n) {\n\t\t\treturn getNewInstance(this).powEqual(n);\n\t\t}\n\n\t\tpublic ModInteger pow(long n) {\n\t\t\treturn getNewInstance(this).powEqual(n);\n\t\t}\n\n\t\tpublic ModInteger pow(ModInteger n) {\n\t\t\treturn getNewInstance(this).powEqual(n);\n\t\t}\n\n\t\tpublic ModInteger powEqual(int n) {\n\t\t\tlong ans = 1, num = this.num;\n\t\t\tif (n < 0) {\n\t\t\t\tn = -n;\n\t\t\t\twhile (n != 0) {\n\t\t\t\t\tif ((n & 1) != 0) ans = ans * num % mod;\n\t\t\t\t\tn >>>= 1;\n\t\t\tnum = num * num % mod;\n\t\t\t\t}\n\t\t\t\tthis.num = inverse((int)ans);\n\t\t\t\treturn this;\n\t\t\t}\n\t\t\twhile (n != 0) {\n\t\t\t\tif ((n & 1) != 0) ans = ans * num % mod;\n\t\t\t\tn >>>= 1;\n\t\t\t\t\tnum = num * num % mod;\n\t\t\t}\n\t\t\tthis.num = (int)ans;\n\t\t\treturn this;\n\t\t}\n\t\tpublic ModInteger powEqual(long n) {\n\t\t\treturn powEqual((int)(n % (mod - 1)));\n\t\t}\n\n\t\tpublic ModInteger powEqual(ModInteger n) {\n\t\t\tlong num = this.num;\n\t\t\tthis.num = 1;\n\t\t\tint mul = n.num;\n\t\t\twhile (mul != 0) {\n\t\t\t\tif ((mul & 1) != 0) this.num *= num;\n\t\t\t\tmul >>>= 1;\n\t\t\t\tnum *= num;\n\t\t\t\tnum %= mod;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger equal(int n) {\n\t\t\tnum = validNum(n);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger equal(long n) {\n\t\t\tnum = validNum(n);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger equal(ModInteger n) {\n\t\t\tnum = n.num;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic int toInt() {\n\t\t\treturn num;\n\t\t}\n\n\t\tpublic int getMod() {\n\t\t\treturn mod;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean equals(Object x) {\n\t\t\tif (x instanceof ModInteger) return ((ModInteger)x).num == num && ((ModInteger)x).mod == mod;\n\t\t\treturn false;\n\t\t}\n\n\t\t@Override\n\t\tpublic int hashCode() {\n\t\t\treturn num ^ mod;\n\t\t}\n\n\t\t@Override\n\t\tpublic String toString() {\n\t\t\treturn String.valueOf(num);\n\t\t}\n\n\t\t@Deprecated\n\t\tpublic String debug() {\n\t\t\tint min = num, ans = 1;\n\t\t\tfor (int i = 2;i < min;++ i) {\n\t\t\t\tint tmp = multiply(i).num;\n\t\t\t\tif (min > tmp) {\n\t\t\t\t\tmin = tmp;\n\t\t\t\t\tans = i;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn min + \"/\" + ans;\n\t\t}\n\n\t\t@Override\n\t\tpublic Addition getAddition() {\n\t\t\treturn add;\n\t\t}\n\n\t\t@Override\n\t\tpublic Multiplication getMultiplication() {\n\t\t\treturn mul;\n\t\t}\n\t}\n\n\t/**\n\t * 素数を法とする演算上で、組み合わせの計算を高速に行います。\n\t * @author 31536000\n\t *\n\t */\n\tpublic static class ModUtility {\n\t\tprivate final int mod;\n\t\tprivate int[] fact, inv, invfact;\n\n\t\t/**\n\t\t * modを法として、演算を行います。\n\t\t * @param mod 法とする素数\n\t\t */\n\t\tpublic ModUtility(Prime mod) {\n\t\t\tthis(mod, 2);\n\t\t}\n\n\t\t/**\n\t\t * modを法として、演算を行います。\n\t\t * @param mod 法とする素数\n\t\t * @param calc 予め前計算しておく大きさ\n\t\t */\n\t\tpublic ModUtility(Prime mod, int calc) {\n\t\t\tthis.mod = mod.prime;\n\t\t\tprecalc(calc);\n\t\t}\n\n\t\t/**\n\t\t * calcの大きさだけ、前計算を行います。\n\t\t * @param calc 前計算をする大きさ\n\t\t */\n\t\tpublic void precalc(int calc) {\n\t\t\t++ calc;\n\t\t\tif (calc < 2) calc = 2;\n\t\t\tfact = new int[calc];\n\t\t\tinv = new int[calc];\n\t\t\tinvfact = new int[calc];\n\t\t\tfact[0] = invfact[0] = fact[1] = invfact[1] = inv[1] = 1;\n\t\t\tfor (int i = 2;i < calc;++ i) {\n\t\t\t\tfact[i] = (int)((long)fact[i - 1] * i % mod);\n\t\t\t\tinv[i] = (int)(mod - (long)inv[mod % i] * (mod / i) % mod);\n\t\t\t\tinvfact[i] = (int)((long)invfact[i - 1] * inv[i] % mod);\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * modを法とする剰余環上で振舞う整数を返します。\n\t\t * @return modを法とする整数、初期値は0\n\t\t */\n\t\tpublic ModInteger create() {\n\t\t\treturn new ModInt();\n\t\t}\n\n\t\t/**\n\t\t * modを法とする剰余環上で振舞う整数を返します。\n\t\t * @param n 初期値\n\t\t * @return modを法とする整数\n\t\t */\n\t\tpublic ModInteger create(int n) {\n\t\t\treturn new ModInt(n);\n\t\t}\n\n\t\tprivate class ModInt extends ModInteger {\n\n\t\t\tprivate static final long serialVersionUID = -2435281861935422575L;\n\n\t\t\tpublic ModInt() {\n\t\t\t\tsuper(mod);\n\t\t\t}\n\n\t\t\tpublic ModInt(int n) {\n\t\t\t\tsuper(mod, n);\n\t\t\t}\n\n\t\t\tpublic ModInt(ModInteger mod) {\n\t\t\t\tsuper(mod);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tprotected ModInteger getNewInstance(ModInteger mod) {\n\t\t\t\treturn new ModInt(mod);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tprotected int inverse(int n) {\n\t\t\t\treturn ModUtility.this.inverse(n);\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * modを法として、nの逆元を返します。
\n\t\t * 計算量はO(log n)です。\n\t\t * @param n 逆元を求めたい値\n\t\t * @return 逆元\n\t\t */\n\t\tpublic int inverse(int n) {\n\t\t\ttry {\n\t\t\t\tif (inv.length > n) return inv[n];\n\t\t\t\t int m = mod, u = 0, v = 1, t;\n\t\t\t\t while(n != 0) {\n\t\t\t\t\t t = m / n;\n\t\t\t\t\t m -= t * n;\n\t\t\t\t\t u -= t * v;\n\t\t\t\t\t if (m != 0) {\n\t\t\t\t\t\t t = n / m;\n\t\t\t\t\t\t n -= t * m;\n\t\t\t\t\t\t v -= t * u;\n\t\t\t\t\t } else {\n\t\t\t\t\t\t v %= mod;\n\t\t\t\t\t\t if (v < 0) v += mod;\n\t\t\t\t\t\t return v;\n\t\t\t\t\t }\n\t\t\t\t }\n\t\t\t\t u %= mod;\n\t\t\t\t if (u < 0) u += mod;\n\t\t\t\t return u;\n\t\t\t} catch (ArrayIndexOutOfBoundsException e) {\n\t\t\t\tthrow new IllegalArgumentException();\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * n!を、modを法として求めた値を返します。
\n\t\t * 計算量はO(n)です。\n\t\t * @param n 階乗を求めたい値\n\t\t * @return nの階乗をmodで割った余り\n\t\t */\n\t\tpublic int factorial(int n) {\n\t\t\ttry {\n\t\t\t\tif (fact.length > n) return fact[n];\n\t\t\t\tlong ret = fact[fact.length - 1];\n\t\t\t\tfor (int i = fact.length;i <= n;++ i) ret = ret * i % mod;\n\t\t\t\treturn (int)ret;\n\t\t\t} catch (ArrayIndexOutOfBoundsException e) {\n\t\t\t\tthrow new IllegalArgumentException();\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * nPkをmodで割った余りを求めます。
\n\t\t * 計算量はO(n-k)です。\n\t\t * @param n 左辺\n\t\t * @param k 右辺\n\t\t * @return nPkをmodで割った余り\n\t\t */\n\t\tpublic int permutation(int n, int k) {\n\t\t\tif (n < 0) throw new IllegalArgumentException();\n\t\t\tif (n < k) return 0;\n\t\t\tif (fact.length > n) return (int)((long)fact[n] * invfact[n - k] % mod);\n\t\t\tlong ret = 1;\n\t\t\tfor (int i = n - k + 1;i <= n;++ i) ret = ret * i % mod;\n\t\t\treturn (int)ret;\n\t\t}\n\n\t\t/**\n\t\t * nCkをmodで割った余りを求めます。
\n\t\t * 計算量はO(n-k)です。\n\t\t * @param n 左辺\n\t\t * @param k 右辺\n\t\t * @return nCkをmodで割った余り\n\t\t */\n\t\tpublic int combination(int n, int k) {\n\t\t\tif (n < 0) throw new IllegalArgumentException();\n\t\t\tif (n < k) return 0;\n\t\t\tif (fact.length > n) return (int)((long)fact[n] * invfact[k] % mod * invfact[n - k] % mod);\n\t\t\tlong ret = 1;\n\t\t\tif (n < 2 * k) k = n - k;\n\t\t\tif (invfact.length > k) ret = invfact[k];\n\t\t\telse ret = inverse(factorial(k));\n\t\t\tfor (int i = n - k + 1;i <= n;++ i) ret = ret * i % mod;\n\t\t\treturn (int)ret;\n\t\t}\n\n\t\t/**\n\t\t * 他項係数をmodで割った余りを求めます。
]\n\t\t * 計算量はO(n)です。\n\t\t * @param n 左辺\n\t\t * @param k 右辺、合計がn以下である必要がある\n\t\t * @return 他項係数\n\t\t */\n\t\tpublic int multinomial(int n, int... k) {\n\t\t\tint sum = 0;\n\t\t\tfor (int i : k) sum += i;\n\t\t\tlong ret = factorial(n);\n\t\t\tif (fact.length > n) {\n\t\t\t\tfor (int i : k) {\n\t\t\t\t\tif (i < 0) throw new IllegalArgumentException();\n\t\t\t\t\tret = ret * invfact[i] % mod;\n\t\t\t\t\tsum += i;\n\t\t\t\t}\n\t\t\t\tif (sum > n) return 0;\n\t\t\t\tret = ret * invfact[n - sum] % mod;\n\t\t\t} else {\n\t\t\t\tfor (int i : k) {\n\t\t\t\t\tif (i < 0) throw new IllegalArgumentException();\n\t\t\t\t\tif (invfact.length > i) ret = ret * invfact[i] % mod;\n\t\t\t\t\telse ret = ret * inverse(factorial(i)) % mod;\n\t\t\t\t\tsum += i;\n\t\t\t\t}\n\t\t\t\tif (sum > n) return 0;\n\t\t\t\tif (invfact.length > n - sum) ret = ret * invfact[n - sum] % mod;\n\t\t\t\telse ret = ret * inverse(factorial(n - sum)) % mod;\n\t\t\t}\n\t\t\treturn (int)ret;\n\t\t}\n\n\t\t/**\n\t\t * n個からk個を選ぶ重複組み合わせnHkをmodで割った余りを求めます。
\n\t\t * 計算量はO(min(n, k))です。\n\t\t * @param n 左辺\n\t\t * @param k 右辺\n\t\t * @return nHkをmodで割った余り\n\t\t */\n\t\tpublic int multichoose(int n, int k) {\n\t\t\treturn combination(mod(n + k - 1), k);\n\t\t}\n\n\t\t/**\n\t\t * カタラン数C(n)をmodで割った余りを求めます。
\n\t\t * 計算量はO(n)です。\n\t\t * @param n 求めたいカタラン数の番号\n\t\t * @return カタラン数\n\t\t */\n\t\tpublic int catalan(int n) {\n\t\t\treturn divide(combination(mod(2 * n), n), mod(n + 1));\n\t\t}\n\n\t\t/**\n\t\t * nのm乗をmodで割った余りを求めます。
\n\t\t * 計算量はO(log m)です。\n\t\t * @param n 床\n\t\t * @param m 冪指数\n\t\t * @return n^mをmodで割った余り\n\t\t */\n\t\tpublic int pow(int n, int m) {\n\t\t\tlong ans = 1, num = n;\n\t\t\tif (m < 0) {\n\t\t\t\tm = -m;\n\t\t\t\twhile (m != 0) {\n\t\t\t\t\tif ((m & 1) != 0) ans = ans * num % mod;\n\t\t\t\t\tm >>>= 1;\n\t\t\t\t\tnum = num * num % mod;\n\t\t\t\t}\n\t\t\t\treturn inverse((int)ans);\n\t\t\t}\n\t\t\twhile (m != 0) {\n\t\t\t\tif ((m & 1) != 0) ans = ans * num % mod;\n\t\t\t\tm >>>= 1;\n\t\t\t\tnum = num * num % mod;\n\t\t\t}\n\t\t\treturn (int)ans;\n\t\t}\n\n\t\t/**\n\t\t * nのm乗をmodで割った余りを求めます。
\n\t\t * 計算量はO(log m)です。\n\t\t * @param n 床\n\t\t * @param m 冪指数\n\t\t * @return n^mをmodで割った余り\n\t\t */\n\t\tpublic int pow(long n, long m) {\n\t\t\treturn pow((int)(n % mod), (int)(n % (mod - 1)));\n\t\t}\n\n\t\t/**\n\t\t * 現在のmod値のトーシェント数を返します。
\n\t\t * なお、これはmod-1に等しいです。\n\t\t * @return トーシェント数\n\t\t */\n\t\tpublic int totient() {\n\t\t\treturn mod - 1;\n\t\t}\n\n\t\t/**\n\t\t * nのトーシェント数を返します。
\n\t\t * 計算量はO(sqrt n)です。\n\t\t * @param n トーシェント数を求めたい値\n\t\t * @return nのトーシェント数\n\t\t */\n\t\tpublic static int totient(int n) {\n\t\t\tint totient = n;\n\t\t\tfor (int i = 2;i * i <= n;++ i) {\n\t\t\t\tif (n % i == 0) {\n\t\t\t\t\ttotient = totient / i * (i - 1);\n\t\t\t\t\twhile ((n %= i) % i == 0);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (n != 1) totient = totient / n * (n - 1);\n\t\t\treturn totient;\n\t\t}\n\n\t\t/**\n\t\t * nをmodで割った余りを返します。\n\t\t * @param n 演算する値\n\t\t * @return nをmodで割った余り\n\t\t */\n\t\tpublic int mod(int n) {\n\t\t\treturn (n %= mod) < 0 ? n + mod : n;\n\t\t}\n\n\t\t/**\n\t\t * nをmodで割った余りを返します。\n\t\t * @param n 演算する値\n\t\t * @return nをmodで割った余り\n\t\t */\n\t\tpublic int mod(long n) {\n\t\t\treturn (int)((n %= mod) < 0 ? n + mod : n);\n\t\t}\n\n\t\t/**\n\t\t * n+mをmodで割った余りを返します。\n\t\t * @param n 足される値\n\t\t * @param m 足す値\n\t\t * @return n+mをmodで割った余り\n\t\t */\n\t\tpublic int add(int n, int m) {\n\t\t\treturn mod(n + m);\n\t\t}\n\n\t\t/**\n\t\t * n-mをmodで割った余りを返します。\n\t\t * @param n 引かれる値\n\t\t * @param m 引く値\n\t\t * @return n-mをmodで割った余り\n\t\t */\n\t\tpublic int subtract(int n, int m) {\n\t\t\treturn mod(n - m);\n\t\t}\n\n\t\t/**\n\t\t * n*mをmodで割った余りを返します。\n\t\t * @param n 掛けられる値\n\t\t * @param m 掛ける値\n\t\t * @return n*mをmodで割った余り\n\t\t */\n\t\tpublic int multiply(int n, int m) {\n\t\t\tint ans = (int)((long)n * m % mod);\n\t\t\treturn ans < 0 ? ans + mod : ans;\n\t\t}\n\n\t\t/**\n\t\t * n/mをmodで割った余りを返します。\n\t\t * @param n 割られる値\n\t\t * @param m 割る値\n\t\t * @return n/mをmodで割った余り\n\t\t */\n\t\tpublic int divide(int n, int m) {\n\t\t\treturn multiply(n, inverse(m));\n\t\t}\n\n\t\t/**\n\t\t * fを通ることが分かっているfの要素数-1次の関数について、xの位置における値をmodで割った余りを返します。
\n\t\t * 計算量はO(f)です。\n\t\t * @param f 関数の形\n\t\t * @param x 求める位置\n\t\t * @return 求めたい値をmodで割った余り\n\t\t */\n\t\tpublic ModInteger lagrangePolynomial(ModInteger[] f, int x) {\n\t\t\tif (f.length > x) return f[x];\n\t\t\tif (x > fact.length) precalc(x);\n\t\t\tModInteger ret = create(0);\n\t\t\tModInteger[] dp = new ModInteger[f.length], dp2 = new ModInteger[f.length];\n\t\t\tdp[0] = create(1);\n\t\t\tdp2[f.length - 1] = create(1);\n\t\t\tfor (int i = 1;i < f.length;++ i) {\n\t\t\t\tdp[i] = dp[i - 1].multiply(x - i - 1);\n\t\t\t\tdp2[f.length - i - 1] = dp2[f.length - i].multiply(x - f.length + i);\n\t\t\t}\n\t\t\tfor (int i = 0;i < f.length;++ i) {\n\t\t\t\tModInteger tmp = f[i].multiply(dp[i]).multiplyEqual(dp2[i]).multiplyEqual(inv[i]).multiplyEqual(inv[f.length - 1 - i]);\n\t\t\t\tif ((f.length - i & 1) == 0) ret.addEqual(tmp);\n\t\t\t\telse ret.subtractEqual(tmp);\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\t}\n\n\t/**\n\t * 素数を渡すためのクラスです。
\n\t * 中身が確実に素数であることを保証するときに使ってください。\n\t *\n\t * @author 31536000\n\t *\n\t */\n\tpublic static class Prime extends Number{\n\n\t\tprivate static final long serialVersionUID = 8216169308184181643L;\n\t\tpublic final int prime;\n\n\t\t/**\n\t\t * 素数を設定します。\n\t\t *\n\t\t * @param prime 素数\n\t\t * @throws IllegalArgumentException 素数以外を渡した時\n\t\t */\n\t\tpublic Prime(int prime) {\n\t\t\tif (!isPrime(prime)) throw new IllegalArgumentException(prime + \" is not prime\");\n\t\t\tthis.prime = prime;\n\t\t}\n\n\t\tprivate static final int bases[] = {15591, 2018, 166, 7429, 8064, 16045, 10503, 4399, 1949, 1295, 2776, 3620, 560, 3128, 5212, 2657, 2300, 2021, 4652, 1471, 9336, 4018, 2398, 20462, 10277, 8028, 2213, 6219, 620, 3763, 4852, 5012, 3185, 1333, 6227, 5298, 1074, 2391, 5113, 7061, 803, 1269, 3875, 422, 751, 580, 4729, 10239, 746, 2951, 556, 2206, 3778, 481, 1522, 3476, 481, 2487, 3266, 5633, 488, 3373, 6441, 3344, 17, 15105, 1490, 4154, 2036, 1882, 1813, 467, 3307, 14042, 6371, 658, 1005, 903, 737, 1887, 7447, 1888, 2848, 1784, 7559, 3400, 951, 13969, 4304, 177, 41, 19875, 3110, 13221, 8726, 571, 7043, 6943, 1199, 352, 6435, 165, 1169, 3315, 978, 233, 3003, 2562, 2994, 10587, 10030, 2377, 1902, 5354, 4447, 1555, 263, 27027, 2283, 305, 669, 1912, 601, 6186, 429, 1930, 14873, 1784, 1661, 524, 3577, 236, 2360, 6146, 2850, 55637, 1753, 4178, 8466, 222, 2579, 2743, 2031, 2226, 2276, 374, 2132, 813, 23788, 1610, 4422, 5159, 1725, 3597, 3366, 14336, 579, 165, 1375, 10018, 12616, 9816, 1371, 536, 1867, 10864, 857, 2206, 5788, 434, 8085, 17618, 727, 3639, 1595, 4944, 2129, 2029, 8195, 8344, 6232, 9183, 8126, 1870, 3296, 7455, 8947, 25017, 541, 19115, 368, 566, 5674, 411, 522, 1027, 8215, 2050, 6544, 10049, 614, 774, 2333, 3007, 35201, 4706, 1152, 1785, 1028, 1540, 3743, 493, 4474, 2521, 26845, 8354, 864, 18915, 5465, 2447, 42, 4511, 1660, 166, 1249, 6259, 2553, 304, 272, 7286, 73, 6554, 899, 2816, 5197, 13330, 7054, 2818, 3199, 811, 922, 350, 7514, 4452, 3449, 2663, 4708, 418, 1621, 1171, 3471, 88, 11345, 412, 1559, 194};\n\n\t\tprivate static boolean isSPRP(int n, int a) {\n\t\t\tint d = n - 1, s = 0;\n\t\t\twhile ((d & 1) == 0) {\n\t\t\t\t++s;\n\t\t\t\td >>= 1;\n\t\t\t}\n\t\t\tlong cur = 1, pw = d;\n\t\t\twhile (pw != 0) {\n\t\t\t\tif ((pw & 1) != 0) cur = (cur * a) % n;\n\t\t\t\ta = (int)(((long)a * a) % n);\n\t\t\t\tpw >>= 1;\n\t\t\t}\n\t\t\tif (cur == 1) return true;\n\t\t\tfor (int r = 0; r < s; r++ ) {\n\t\t\t\tif (cur == n - 1) return true;\n\t\t\t\tcur = (cur * cur) % n;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\t/**\n\t\t * 与えられた値が素数か否かを判定します。
\n\t\t * この実装はhttp://ceur-ws.org/Vol-1326/020-Forisek.pdfに基づきます。\n\t\t * @param x 判定したい値\n\t\t * @return xが素数ならtrue\n\t\t */\n\t\tpublic static boolean isPrime(int x) {\n\t\t\tif (x == 2 || x == 3 || x == 5 || x == 7) return true;\n\t\t\tif ((x & 1) == 0 || x % 3 == 0 || x % 5 == 0 || x % 7 == 0) return false;\n\t\t\tif (x < 121) return x > 1;\n\t\t\tlong h = x;\n\t\t\th = ((h >> 16) ^ h) * 0x45d9f3b;\n\t\t\th = ((h >> 16) ^ h) * 0x45d9f3b;\n\t\t\th = ((h >> 16) ^ h) & 0xFF;\n\t\t\treturn isSPRP(x, bases[(int)h]);\n\t\t}\n\n\t\t@Override\n\t\tpublic int intValue() {\n\t\t\treturn prime;\n\t\t}\n\n\t\t@Override\n\t\tpublic long longValue() {\n\t\t\treturn prime;\n\t\t}\n\n\t\t@Override\n\t\tpublic float floatValue() {\n\t\t\treturn prime;\n\t\t}\n\n\t\t@Override\n\t\tpublic double doubleValue() {\n\t\t\treturn prime;\n\t\t}\n\n\t\t@Override\n\t\tpublic String toString() {\n\t\t\treturn String.valueOf(prime);\n\t\t}\n\t}\n\n\tpublic static class AbstractArray extends AbstractList implements RandomAccess{\n\n\t\tprivate final Object[] array;\n\n\t\tpublic AbstractArray(int size) {\n\t\t\tarray = new Object[size];\n\t\t}\n\n\t\tpublic AbstractArray(T[] array) {\n\t\t\tthis(array.length);\n\t\t\tSystem.arraycopy(array, 0, this.array, 0, array.length);\n\t\t}\n\n\t\t@Override\n\t\tpublic T set(int index, T element) {\n\t\t\tT ret = get(index);\n\t\t\tarray[index] = element;\n\t\t\treturn ret;\n\t\t}\n\n\t\t@Override\n\t\tpublic T get(int index) {\n\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\tT ret = (T)array[index];\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic Object[] get() {\n\t\t\treturn array;\n\t\t}\n\n\t\tpublic T[] get(T[] array) {\n\t\t\tif (array.length < this.array.length) {\n\t\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\t\tT[] ret = (T[])Arrays.copyOfRange(this.array, 0, this.array.length, array.getClass());\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t\tSystem.arraycopy(this.array, 0, array, 0, this.array.length);\n\t\t\treturn array;\n\t\t}\n\n\t\t@Override\n\t\tpublic int size() {\n\t\t\treturn array.length;\n\t\t}\n\n\t\tpublic int length() {\n\t\t\treturn size();\n\t\t}\n\n\t\t@Override\n\t\tpublic int hashCode() {\n\t\t\treturn Arrays.hashCode(array);\n\t\t}\n\n\t\tprivate class Iter implements Iterator {\n\t\t\tprivate int index;\n\n\t\t\tprivate Iter() {\n\t\t\t\tindex = 0;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic boolean hasNext() {\n\t\t\t\treturn index < array.length;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic T next() {\n\t\t\t\treturn get(index++);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void remove() {\n\t\t\t\tthrow new UnsupportedOperationException();\n\t\t\t}\n\t\t}\n\n\t\t@Override\n\t\tpublic Iterator iterator() {\n\t\t\treturn new Iter();\n\t\t}\n\t}\n\n\tpublic static class Array extends AbstractArray implements Serializable{\n\n\t\tprivate static final long serialVersionUID = 2749604433067098063L;\n\n\t\tpublic Array(int size) {\n\t\t\tsuper(size);\n\t\t}\n\n\t\tpublic Array(T[] array) {\n\t\t\tsuper(array);\n\t\t}\n\n\t\tpublic T front() {\n\t\t\treturn get(0);\n\t\t}\n\n\t\tpublic T back() {\n\t\t\treturn get(size() - 1);\n\t\t}\n\t}\n\n\t/**\n\t * 要素とそのindexを効率的に取得する関数を提供します。\n\t * @author 31536000\n\t *\n\t */\n\tpublic static class Enumeration {\n\t\t/**\n\t\t * 要素とそのindexを管理するクラスです。\n\t\t * @author 31536000\n\t\t *\n\t\t * @param 保持する要素\n\t\t */\n\t\tpublic static class Enumerate {\n\t\t\tpublic final E value;\n\t\t\tpublic final int index;\n\n\t\t\t/**\n\t\t\t * 要素とそのindexを渡します。
\n\t\t\t * indexは必ずしも元の配列またはコレクションのindexと一致する必要はありませんが、一致する値を返すことが推奨されます。\n\t\t\t * @param value\n\t\t\t * @param index\n\t\t\t */\n\t\t\tpublic Enumerate(E value, int index) {\n\t\t\t\tthis.value = value;\n\t\t\t\tthis.index = index;\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * 要素を返します。\n\t\t\t * @return 要素\n\t\t\t */\n\t\t\tpublic E getValue() {\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * indexを返します。\n\t\t\t * @return index\n\t\t\t */\n\t\t\tpublic int getIndex() {\n\t\t\t\treturn index;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic boolean equals(Object o) {\n\t\t\t\tif (o instanceof Enumerate) return ((Enumerate)o).getValue().equals(value) && ((Enumerate)o).getIndex() == index;\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic int hashCode() {\n\t\t\t\treturn value.hashCode() ^ index;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic String toString() {\n\t\t\t\treturn \"{\" + value.toString() + \", \" + index + \"}\";\n\t\t\t}\n\t\t}\n\n\t\tprivate static class IteratorArray implements Iterator>{\n\t\t\tprivate final E[] array;\n\t\t\tprivate final int start;\n\t\t\tprivate int index;\n\n\t\t\tpublic IteratorArray(E[] array, int index) {\n\t\t\t\tthis.array = array;\n\t\t\t\tthis.start = index;\n\t\t\t\tthis.index = 0;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic boolean hasNext() {\n\t\t\t\treturn index < array.length;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic Enumerate next() {\n\t\t\t\tEnumerate ret = new Enumerate<>(array[index], index+++start);\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t}\n\n\t\tprivate static class IteratorCollection implements Iterator>{\n\t\t\tprivate final Iterator iter;\n\t\t\tprivate int start;\n\n\t\t\tpublic IteratorCollection(Iterator iter, int index) {\n\t\t\t\tthis.iter = iter;\n\t\t\t\tthis.start = index;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic boolean hasNext() {\n\t\t\t\treturn iter.hasNext();\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic Enumerate next() {\n\t\t\t\tEnumerate ret = new Enumerate<>(iter.next(), start++);\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * 配列の各要素とそのindexを順に返すIteratorを生成します。\n\t\t * @param 配列の型\n\t\t * @param array 配列\n\t\t * @return Enumerate<E>のIterator\n\t\t */\n\t\tpublic static Iterator> enumerate(E[] array) {\n\t\t\treturn enumerate(array, 0);\n\t\t}\n\n\t\t/**\n\t\t * 配列の各要素とそのindexを順に返すIteratorを生成します。\n\t\t * @param 配列の型\n\t\t * @param array 配列\n\t\t * @param start 添字の初期値、この値だけindexが足されたものが返る\n\t\t * @return Enumerate<E>のIterator\n\t\t */\n\t\tpublic static Iterator> enumerate(E[] array, int start) {\n\t\t\tif (array == null) throw new NullPointerException(\"array is null\");\n\t\t\treturn new IteratorArray(array, start);\n\t\t}\n\n\t\t/**\n\t\t * Iteratorの各要素とそのindexを順に返すIteratorを生成します。\n\t\t * @param Iteratorの型\n\t\t * @param iter Iterator\n\t\t * @return Enumerate<E>のIterator\n\t\t */\n\t\tpublic static Iterator> enumerate(Iterator iter) {\n\t\t\treturn enumerate(iter, 0);\n\t\t}\n\n\t\t/**\n\t\t * Iteratorの各要素とそのindexを順に返すIteratorを生成します。\n\t\t * @param Iteratorの型\n\t\t * @param iter Iterator\n\t\t * @param start 添字の初期値、この値だけindexが足されたものが返る\n\t\t * @return Enumerate<E>のIterator\n\t\t */\n\t\tpublic static Iterator> enumerate(Iterator iter, int start) {\n\t\t\tif (iter == null) throw new NullPointerException(\"iterator is null\");\n\t\t\treturn new IteratorCollection(iter, start);\n\t\t}\n\t}\n}\n", "language": "Java", "metadata": {"date": 1579382768, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02796.html", "problem_id": "p02796", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02796/input.txt", "sample_output_relpath": "derived/input_output/data/p02796/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02796/Java/s916025176.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s916025176", "user_id": "u550314572"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "\n\n\n\nimport java.awt.Point;\nimport java.io.File;\nimport java.io.FileInputStream;\nimport java.io.FileNotFoundException;\nimport java.io.FileOutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintStream;\nimport java.io.PrintWriter;\nimport java.io.Serializable;\nimport java.util.AbstractList;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.Comparator;\nimport java.util.HashMap;\nimport java.util.Iterator;\nimport java.util.List;\nimport java.util.Locale;\nimport java.util.Map;\nimport java.util.Map.Entry;\nimport java.util.NoSuchElementException;\nimport java.util.RandomAccess;\nimport java.util.Set;\nimport java.util.function.BinaryOperator;\nimport java.util.function.UnaryOperator;\n\npublic class Main implements Runnable{\n\n\tprivate void solve(FastIO io, String[] args) {\n\t\t/*\n\t\t * author: 31536000\n\t\t * キーエンスプログラミングコンテスト2020 B問題\n\t\t * 考察メモ\n\t\t * 区間で考えていく\n\t\t * 各ロボットは[X-L, X+L)の区間を持ち、仮に[L, R)とする\n\t\t * この時、この問題は重ならない区間の最大化になる\n\t\t * dp[i]:座標P_i以下におけるロボットの答え\n\t\t * とすると、各ロボットについて、dp[P_i](i>=r)にdp[P_l]+1以上でmaxを行う操作へ\n\t\t * 座圧で\n\t\t *\n\t\t */\n\t\tint N = io.nextInt();\n\t\tIntRange[] range = new IntRange[N];\n\t\tfor (int i = 0;i < N;++ i) {\n\t\t\tint X = io.nextInt(), L = io.nextInt();\n\t\t\trange[i] = IntRange.closed(X - L, X + L);\n\t\t}\n\t\tInteger[] comp = new Integer[2 * N];\n\t\tfor (int i = 0;i < N;++ i) {\n\t\t\tcomp[i << 1] = range[i].getClosedLower();\n\t\t\tcomp[i << 1 | 1] = range[i].getClosedUpper();\n\t\t}\n\t\tCompress compress = new Compress<>(comp); // 座圧\n\t\tArrays.sort(range, (l, r) -> Integer.compare(l.getClosedUpper(), r.getClosedUpper())); // 終点ソート\n\t\t//io.debugln(range);\n\t\tint rangeIndex = 0;\n\t\tint[] dp = new int[compress.size()]; // 答え\n\t\tfor (int i = 1;i < dp.length;++ i) {\n\t\t\tdp[i] = dp[i - 1]; // まず、ロボットを使わない時\n\t\t\tif (compress.zip(range[rangeIndex].getClosedUpper()) == i) { // 現在座標\n\t\t\t\tint get = compress.zip(range[rangeIndex++].getClosedLower());\n\t\t\t\tdp[i] = Math.max(dp[i], dp[get] + 1); // このロボットを採用するとき\n\t\t\t}\n\t\t}\n\t\t//io.debugln(dp);\n\t\tio.println(dp[dp.length - 1]);\n\t}\n\n\t/** デバッグ用コードのお供に */\n\tprivate static boolean DEBUG = false;\n\t/** 確保するメモリの大きさ(単位: MB)*/\n\tprivate static final long MEMORY = 64;\n\tprivate final FastIO io;\n\tprivate final String[] args;\n\n\tpublic static void main(String[] args) {\n\t Thread.setDefaultUncaughtExceptionHandler((t, e) -> e.printStackTrace());\n\t new Thread(null, new Main(args), \"\", MEMORY * 1048576).start();\n\t}\n\n\tpublic Main(String[] args) {\n\t\tthis(new FastIO(), args);\n\t}\n\n\tpublic Main(FastIO io, String... args) {\n\t\tthis.io = io;\n\t\tthis.args = args;\n\t\tif (DEBUG) io.setAutoFlush(true);\n\t}\n\n\t@Override\n\tpublic void run() {\n\t\ttry {\n\t\t\tsolve(io, args);\n\t\t} catch (Throwable e) {\n\t\t\tthrow e;\n\t\t} finally {\n\t\t\tio.flush();\n\t\t}\n\t}\n\n\t// 以下、ライブラリ\n\n\tpublic class Compress> {\n\n\t\tprivate Map zip;\n\t\tprivate Object[] unzip;\n\n\t\tpublic Compress(T[] dat) {\n\t\t\tArrays.sort(dat);\n\t\t\tzip = new HashMap();\n\t\t\tList unzip = new ArrayList();\n\t\t\tfor (int i = 0, j = 0; i < dat.length; ++i) {\n\t\t\t\tif (zip.put(dat[i], j++ ) != null) {\n\t\t\t\t\tzip.put(dat[i], --j - 1);\n\t\t\t\t} else unzip.add(dat[i]);\n\t\t\t}\n\t\t\tthis.unzip = unzip.toArray();\n\t\t}\n\n\t\tpublic Compress(List dat) {\n\t\t\tdat.sort(null);\n\t\t\tObject[] dats = dat.toArray();\n\t\t\tzip = new HashMap();\n\t\t\tList unzip = new ArrayList();\n\t\t\tfor (int i = 0, j = 0; i < dats.length; ++i) {\n\t\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\t\tT push = (T)dats[i];\n\t\t\t\tif (zip.put(push, j++ ) != null) {\n\t\t\t\t\tzip.put(push, --j - 1);\n\t\t\t\t} else unzip.add(push);\n\t\t\t}\n\t\t\tthis.unzip = unzip.toArray();\n\t\t}\n\n\t\tpublic int zip(T dat) {\n\t\t\treturn zip.get(dat);\n\t\t}\n\n\t\tpublic T unzip(int index) {\n\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\tT ret = (T)unzip[index];\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic int size() {\n\t\t\treturn unzip.length;\n\t\t}\n\t}\n\n\t/**\n\t * 高速な入出力を提供します。\n\t * @author 31536000\n\t *\n\t */\n\tpublic static class FastIO {\n\t\tprivate InputStream in;\n\t\tprivate final byte[] buffer = new byte[1024];\n\t\tprivate int read = 0;\n\t\tprivate int length = 0;\n\t\tprivate PrintWriter out;\n\t\tprivate PrintWriter err;\n\t\tprivate boolean autoFlush = false;\n\n\t\tpublic FastIO() {\n\t\t\tthis(System.in, System.out, System.err);\n\t\t}\n\n\t\tpublic FastIO(InputStream in, PrintStream out, PrintStream err) {\n\t\t\tthis.in = in;\n\t\t\tthis.out = new PrintWriter(out, false);\n\t\t\tthis.err = new PrintWriter(err, false);\n\t\t}\n\n\t\tpublic final void setInputStream(InputStream in) {\n\t\t\tthis.in = in;\n\t\t}\n\n\t\tpublic final void setInputStream(File in) {\n\t\t\ttry {\n\t\t\t\tthis.in = new FileInputStream(in);\n\t\t\t} catch (FileNotFoundException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t}\n\n\t\tpublic final void setOutputStream(PrintStream out) {\n\t\t\tthis.out = new PrintWriter(out, false);\n\t\t}\n\n\t\tpublic final void setOutputStream(File out) {\n\t\t\ttry {\n\t\t\t\tthis.out = new PrintWriter(new FileOutputStream(out), false);\n\t\t\t} catch (FileNotFoundException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t}\n\n\t\tpublic final void setErrorStream(PrintStream err) {\n\t\t\tthis.err = new PrintWriter(err, false);\n\t\t}\n\n\t\tpublic final void setErrorStream(File err) {\n\t\t\ttry {\n\t\t\t\tthis.err = new PrintWriter(new FileOutputStream(err), false);\n\t\t\t} catch (FileNotFoundException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t}\n\n\t\tpublic final void setAutoFlush(boolean flush) {\n\t\t\tautoFlush = flush;\n\t\t}\n\n\t\tprivate boolean hasNextByte() {\n\t\t\tif (read < length) return true;\n\t\t\tread = 0;\n\t\t\ttry {\n\t\t\t\tlength = in.read(buffer);\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn length > 0;\n\t\t}\n\n\t\tprivate int readByte() {\n\t\t\treturn hasNextByte() ? buffer[read++] : -1;\n\t\t}\n\n\t\tprivate static boolean isPrintableChar(int c) {\n\t\t\treturn 33 <= c && c <= 126;\n\t\t}\n\n\t\tprivate static boolean isNumber(int c) {\n\t\t\treturn '0' <= c && c <= '9';\n\t\t}\n\n\t\tpublic final boolean hasNext() {\n\t\t\twhile (hasNextByte() && !isPrintableChar(buffer[read])) read++;\n\t\t\treturn hasNextByte();\n\t\t}\n\n\t\tpublic final char nextChar() {\n\t\t\tif (!hasNextByte()) throw new NoSuchElementException();\n\t\t\treturn (char)readByte();\n\t\t}\n\n\t\tpublic final char[][] nextChar(int height) {\n\t\t\tchar[][] ret = new char[height][];\n\t\t\tfor (int i = 0;i < ret.length;++ i) ret[i] = next().toCharArray();\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic final String next() {\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tint b;\n\t\t\twhile (isPrintableChar(b = readByte())) sb.appendCodePoint(b);\n\t\t\treturn sb.toString();\n\t\t}\n\n\t\tpublic final String nextLine() {\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tint b;\n\t\t\twhile(!isPrintableChar(b = readByte()));\n\t\t\tdo sb.appendCodePoint(b); while(isPrintableChar(b = readByte()) || b == ' ');\n\t\t\treturn sb.toString();\n\t\t}\n\n\t\tpublic final long nextLong() {\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tlong n = 0;\n\t\t\tboolean minus = false;\n\t\t\tint b = readByte();\n\t\t\tif (b == '-') {\n\t\t\t\tminus = true;\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t\tif (!isNumber(b)) throw new NumberFormatException();\n\t\t\twhile (true) {\n\t\t\t\tif (isNumber(b)) {\n\t\t\t\t\tn *= 10;\n\t\t\t\t\tn += b - '0';\n\t\t\t\t} else if (b == -1 || !isPrintableChar(b)) return minus ? -n : n;\n\t\t\t\telse throw new NumberFormatException();\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t}\n\n\t\tpublic final int nextInt() {\n\t\t\tlong nl = nextLong();\n\t\t\tif (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n\t\t\treturn (int) nl;\n\t\t}\n\n\t\tpublic final double nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tpublic final int[] nextInt(int width) {\n\t\t\tint[] ret = new int[width];\n\t\t\tfor (int i = 0;i < width;++ i) ret[i] = nextInt();\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic final int[] nextInts() {\n\t\t\treturn nextInts(\" \");\n\t\t}\n\n\t\tpublic final int[] nextInts(String parse) {\n\t\t\tString[] get = nextLine().split(parse);\n\t\t\tint[] ret = new int[get.length];\n\t\t\tfor (int i = 0;i < ret.length;++ i) ret[i] = Integer.valueOf(get[i]);\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic final long[] nextLong(int width) {\n\t\t\tlong[] ret = new long[width];\n\t\t\tfor (int i = 0;i < width;++ i) ret[i] = nextLong();\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic final long[] nextLongs() {\n\t\t\treturn nextLongs(\" \");\n\t\t}\n\n\t\tpublic final long[] nextLongs(String parse) {\n\t\t\tString[] get = nextLine().split(parse);\n\t\t\tlong[] ret = new long[get.length];\n\t\t\tfor (int i = 0;i < ret.length;++ i) ret[i] = Long.valueOf(get[i]);\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic final int[][] nextInt(int width, int height) {\n\t\t\tint[][] ret = new int[height][width];\n\t\t\tfor (int i = 0, j;i < height;++ i) for (j = 0;j < width;++ j) ret[i][j] = nextInt();\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic final long[][] nextLong(int width, int height) {\n\t\t\tlong[][] ret = new long[height][width];\n\t\t\tfor (int i = 0, j;i < height;++ i) for (j = 0;j < width;++ j) ret[j][i] = nextLong();\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic final boolean[] nextBoolean(char T) {\n\t\t\tchar[] s = next().toCharArray();\n\t\t\tboolean[] ret = new boolean[s.length];\n\t\t\tfor (int i = 0;i < ret.length;++ i) ret[i] = s[i] == T;\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic final boolean[][] nextBoolean(char T, int height) {\n\t\t\tboolean[][] ret = new boolean[height][];\n\t\t\tfor (int i = 0;i < ret.length;++ i) {\n\t\t\t\tchar[] s = next().toCharArray();\n\t\t\t\tret[i] = new boolean[s.length];\n\t\t\t\tfor (int j = 0;j < ret[i].length;++ j) ret[i][j] = s[j] == T;\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic final Point nextPoint() {\n\t\t\treturn new Point(nextInt(), nextInt());\n\t\t}\n\n\t\tpublic final Point[] nextPoint(int width) {\n\t\t\tPoint[] ret = new Point[width];\n\t\t\tfor (int i = 0;i < width;++ i) ret[i] = nextPoint();\n\t\t\treturn ret;\n\t\t}\n\n\t\t@Override\n\t\tprotected void finalize() throws Throwable {\n\t\t\ttry {\n\t\t\t\tsuper.finalize();\n\t\t\t} finally {\n\t\t\t\tin.close();\n\t\t\t\tout.close();\n\t\t\t\terr.close();\n\t\t\t}\n\t\t}\n\n\t\tpublic final boolean print(boolean b) {\n\t\t\tout.print(b);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn b;\n\t\t}\n\n\t\tpublic final Object print(boolean b, Object t, Object f) {\n\t\t\treturn b ? print(t) : print(f);\n\t\t}\n\n\t\tpublic final char print(char c) {\n\t\t\tout.print(c);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn c;\n\t\t}\n\n\t\tpublic final char[] print(char[] s) {\n\t\t\tout.print(s);\n\t\t\treturn s;\n\t\t}\n\n\t\tpublic final double print(double d) {\n\t\t\tout.print(d);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn d;\n\t\t}\n\n\t\tpublic final double print(double d, int length) {\n\t\t\tif (d < 0) {\n\t\t\t\tout.print('-');\n\t\t\t\td = -d;\n\t\t\t}\n\t\t\td += Math.pow(10, -length) / 2;\n\t\t\tout.print((long)d);\n\t\t\tout.print('.');\n\t\t\td -= (long)d;\n\t\t\tfor (int i = 0;i < length;++ i) {\n\t\t\t\td *= 10;\n\t\t\t\tout.print((int)d);\n\t\t\t\td -= (int)d;\n\t\t\t}\n\t\t\tif (autoFlush) flush();\n\t\t\treturn d;\n\t\t}\n\n\t\tpublic final float print(float f) {\n\t\t\tout.print(f);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn f;\n\t\t}\n\n\t\tpublic final int print(int i) {\n\t\t\tout.print(i);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn i;\n\t\t}\n\n\t\tpublic final long print(long l) {\n\t\t\tout.print(l);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn l;\n\t\t}\n\n\t\tpublic final Object print(Object obj) {\n\t\t\tif (obj != null && obj.getClass().isArray()) {\n\t\t\t\tif (obj instanceof boolean[][]) print(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof byte[][]) print(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof short[][]) print(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof int[][]) print(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof long[][]) print(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof float[][]) print(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof double[][]) print(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof char[][]) print(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof Object[][]) print(obj, \"\\n\", \" \");\n\t\t\t\telse print(obj, \" \");\n\t\t\t} else {\n\t\t\t\tout.print(obj);\n\t\t\t\tif (autoFlush) flush();\n\t\t\t}\n\t\t\treturn obj;\n\t\t}\n\n\t\tpublic final String print(String s) {\n\t\t\tout.print(s);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn s;\n\t\t}\n\n\t\tpublic final Object print(Object array, String... parse) {\n\t\t\tprint(array, 0, parse);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn array;\n\t\t}\n\n\t\tprivate final Object print(Object array, int check, String... parse) {\n\t\t\tif (check >= parse.length) {\n\t\t\t\tif (array != null && array.getClass().isArray()) throw new IllegalArgumentException(\"not equal dimension\");\n\t\t\t\tprint(array);\n\t\t\t\treturn array;\n\t\t\t}\n\t\t\tString str = parse[check];\n\t\t\tif (array instanceof Object[]) {\n\t\t\t\tObject[] obj = (Object[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tprint(obj[0], check + 1, parse);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tprint(str);\n\t\t\t\t\tprint(obj[i], check + 1, parse);\n\t\t\t\t}\n\t\t\t\treturn array;\n\t\t\t}\n\t\t\tif (array instanceof Collection) {\n\t\t\t\tIterator iter = ((Collection)array).iterator();\n\t\t\t\tif (!iter.hasNext()) return array;\n\t\t\t\tprint(iter.next(), check + 1, parse);\n\t\t\t\twhile(iter.hasNext()) {\n\t\t\t\t\tprint(str);\n\t\t\t\t\tprint(iter.next(), check + 1, parse);\n\t\t\t\t}\n\t\t\t\treturn array;\n\t\t\t}\n\t\t\tif (!array.getClass().isArray()) throw new IllegalArgumentException(\"not equal dimension\");\n\t\t\tif (check != parse.length - 1) throw new IllegalArgumentException(\"not equal dimension\");\n\t\t\tif (array instanceof boolean[]) {\n\t\t\t\tboolean[] obj = (boolean[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tprint(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tprint(str);\n\t\t\t\t\tprint(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof byte[]) {\n\t\t\t\tbyte[] obj = (byte[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tprint(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tprint(str);\n\t\t\t\t\tprint(obj[i]);\n\t\t\t\t}\n\t\t\t\treturn array;\n\t\t\t} else if (array instanceof short[]) {\n\t\t\t\tshort[] obj = (short[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tprint(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tprint(str);\n\t\t\t\t\tprint(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof int[]) {\n\t\t\t\tint[] obj = (int[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tprint(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tprint(str);\n\t\t\t\t\tprint(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof long[]) {\n\t\t\t\tlong[] obj = (long[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tprint(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tprint(str);\n\t\t\t\t\tprint(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof float[]) {\n\t\t\t\tfloat[] obj = (float[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tprint(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tprint(str);\n\t\t\t\t\tprint(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof double[]) {\n\t\t\t\tdouble[] obj = (double[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tprint(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tprint(str);\n\t\t\t\t\tprint(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof char[]) {\n\t\t\t\tchar[] obj = (char[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tprint(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tprint(str);\n\t\t\t\t\tprint(obj[i]);\n\t\t\t\t}\n\t\t\t} else throw new AssertionError();\n\t\t\treturn array;\n\t\t}\n\n\t\tpublic final Object[] print(String parse, Object... args) {\n\t\t\tprint(args[0]);\n\t\t\tfor (int i = 1;i < args.length;++ i) {\n\t\t\t\tprint(parse);\n\t\t\t\tprint(args[i]);\n\t\t\t}\n\t\t\treturn args;\n\t\t}\n\n\t\tpublic final Object[] printf(String format, Object... args) {\n\t\t\tout.printf(format, args);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn args;\n\t\t}\n\n\t\tpublic final Object printf(Locale l, String format, Object... args) {\n\t\t\tout.printf(l, format, args);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn args;\n\t\t}\n\n\t\tpublic final void println() {\n\t\t\tout.println();\n\t\t\tif (autoFlush) flush();\n\t\t}\n\n\t\tpublic final boolean println(boolean b) {\n\t\t\tout.println(b);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn b;\n\t\t}\n\n\t\tpublic final Object println(boolean b, Object t, Object f) {\n\t\t\treturn b ? println(t) : println(f);\n\t\t}\n\n\t\tpublic final char println(char c) {\n\t\t\tout.println(c);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn c;\n\t\t}\n\n\t\tpublic final char[] println(char[] s) {\n\t\t\tout.println(s);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn s;\n\t\t}\n\n\t\tpublic final double println(double d) {\n\t\t\tout.println(d);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn d;\n\t\t}\n\n\t\tpublic final double println(double d, int length) {\n\t\t\tprint(d, length);\n\t\t\tprintln();\n\t\t\treturn d;\n\t\t}\n\n\t\tpublic final float println(float f) {\n\t\t\tout.println(f);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn f;\n\t\t}\n\n\t\tpublic final int println(int i) {\n\t\t\tout.println(i);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn i;\n\t\t}\n\n\t\tpublic final long println(long l) {\n\t\t\tout.println(l);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn l;\n\t\t}\n\n\t\tpublic final Object println(Object obj) {\n\t\t\tprint(obj);\n\t\t\tprintln();\n\t\t\treturn obj;\n\t\t}\n\n\t\tpublic final String println(String s) {\n\t\t\tout.println(s);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn s;\n\t\t}\n\n\t\tpublic final Object println(Object array, String... parse) {\n\t\t\tprint(array, parse);\n\t\t\tprintln();\n\t\t\treturn array;\n\t\t}\n\n\t\tpublic final boolean debug(boolean b) {\n\t\t\terr.print(b);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn b;\n\t\t}\n\n\t\tpublic final Object debug(boolean b, Object t, Object f) {\n\t\t\treturn b ? debug(t) : debug(f);\n\t\t}\n\n\t\tpublic final char debug(char c) {\n\t\t\terr.print(c);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn c;\n\t\t}\n\n\t\tpublic final char[] debug(char[] s) {\n\t\t\terr.print(s);\n\t\t\treturn s;\n\t\t}\n\n\t\tpublic final double debug(double d) {\n\t\t\terr.print(d);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn d;\n\t\t}\n\n\t\tpublic final double debug(double d, int length) {\n\t\t\tif (d < 0) {\n\t\t\t\terr.print('-');\n\t\t\t\td = -d;\n\t\t\t}\n\t\t\td += Math.pow(10, -length) / 2;\n\t\t\terr.print((long)d);\n\t\t\terr.print('.');\n\t\t\td -= (long)d;\n\t\t\tfor (int i = 0;i < length;++ i) {\n\t\t\t\td *= 10;\n\t\t\t\terr.print((int)d);\n\t\t\t\td -= (int)d;\n\t\t\t}\n\t\t\tif (autoFlush) flush();\n\t\t\treturn d;\n\t\t}\n\n\t\tpublic final float debug(float f) {\n\t\t\terr.print(f);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn f;\n\t\t}\n\n\t\tpublic final int debug(int i) {\n\t\t\terr.print(i);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn i;\n\t\t}\n\n\t\tpublic final long debug(long l) {\n\t\t\terr.print(l);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn l;\n\t\t}\n\n\t\tpublic final Object debug(Object obj) {\n\t\t\tif (obj != null && obj.getClass().isArray()) {\n\t\t\t\tif (obj instanceof boolean[][]) debug(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof byte[][]) debug(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof short[][]) debug(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof int[][]) debug(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof long[][]) debug(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof float[][]) debug(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof double[][]) debug(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof char[][]) debug(obj, \"\\n\", \" \");\n\t\t\t\telse if (obj instanceof Object[][]) debug(obj, \"\\n\", \" \");\n\t\t\t\telse debug(obj, \" \");\n\t\t\t} else {\n\t\t\t\terr.print(obj);\n\t\t\t\tif (autoFlush) flush();\n\t\t\t}\n\t\t\treturn obj;\n\t\t}\n\n\t\tpublic final String debug(String s) {\n\t\t\terr.print(s);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn s;\n\t\t}\n\n\t\tpublic final Object debug(Object array, String... parse) {\n\t\t\tdebug(array, 0, parse);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn array;\n\t\t}\n\n\t\tprivate final Object debug(Object array, int check, String... parse) {\n\t\t\tif (check >= parse.length) {\n\t\t\t\tif (array != null && array.getClass().isArray()) throw new IllegalArgumentException(\"not equal dimension\");\n\t\t\t\tdebug(array);\n\t\t\t\treturn array;\n\t\t\t}\n\t\t\tString str = parse[check];\n\t\t\tif (array instanceof Object[]) {\n\t\t\t\tObject[] obj = (Object[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tdebug(obj[0], check + 1, parse);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tdebug(str);\n\t\t\t\t\tdebug(obj[i], check + 1, parse);\n\t\t\t\t}\n\t\t\t\treturn array;\n\t\t\t}\n\t\t\tif (array instanceof Collection) {\n\t\t\t\tIterator iter = ((Collection)array).iterator();\n\t\t\t\tif (!iter.hasNext()) return array;\n\t\t\t\tdebug(iter.next(), check + 1, parse);\n\t\t\t\twhile(iter.hasNext()) {\n\t\t\t\t\tdebug(str);\n\t\t\t\t\tdebug(iter.next(), check + 1, parse);\n\t\t\t\t}\n\t\t\t\treturn array;\n\t\t\t}\n\t\t\tif (!array.getClass().isArray()) throw new IllegalArgumentException(\"not equal dimension\");\n\t\t\tif (check != parse.length - 1) throw new IllegalArgumentException(\"not equal dimension\");\n\t\t\tif (array instanceof boolean[]) {\n\t\t\t\tboolean[] obj = (boolean[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tdebug(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tdebug(str);\n\t\t\t\t\tdebug(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof byte[]) {\n\t\t\t\tbyte[] obj = (byte[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tdebug(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tdebug(str);\n\t\t\t\t\tdebug(obj[i]);\n\t\t\t\t}\n\t\t\t\treturn array;\n\t\t\t} else if (array instanceof short[]) {\n\t\t\t\tshort[] obj = (short[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tdebug(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tdebug(str);\n\t\t\t\t\tdebug(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof int[]) {\n\t\t\t\tint[] obj = (int[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tdebug(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tdebug(str);\n\t\t\t\t\tdebug(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof long[]) {\n\t\t\t\tlong[] obj = (long[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tdebug(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tdebug(str);\n\t\t\t\t\tdebug(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof float[]) {\n\t\t\t\tfloat[] obj = (float[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tdebug(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tdebug(str);\n\t\t\t\t\tdebug(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof double[]) {\n\t\t\t\tdouble[] obj = (double[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tdebug(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tdebug(str);\n\t\t\t\t\tdebug(obj[i]);\n\t\t\t\t}\n\t\t\t} else if (array instanceof char[]) {\n\t\t\t\tchar[] obj = (char[]) array;\n\t\t\t\tif (obj.length == 0) return array;\n\t\t\t\tdebug(obj[0]);\n\t\t\t\tfor (int i = 1;i < obj.length;++ i) {\n\t\t\t\t\tdebug(str);\n\t\t\t\t\tdebug(obj[i]);\n\t\t\t\t}\n\t\t\t} else throw new AssertionError();\n\t\t\treturn array;\n\t\t}\n\n\t\tpublic final Object[] debug(String parse, Object... args) {\n\t\t\tdebug(args[0]);\n\t\t\tfor (int i = 1;i < args.length;++ i) {\n\t\t\t\tdebug(parse);\n\t\t\t\tdebug(args[i]);\n\t\t\t}\n\t\t\treturn args;\n\t\t}\n\n\t\tpublic final Object[] debugf(String format, Object... args) {\n\t\t\terr.printf(format, args);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn args;\n\t\t}\n\n\t\tpublic final Object debugf(Locale l, String format, Object... args) {\n\t\t\terr.printf(l, format, args);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn args;\n\t\t}\n\n\t\tpublic final void debugln() {\n\t\t\terr.println();\n\t\t\tif (autoFlush) flush();\n\t\t}\n\n\t\tpublic final boolean debugln(boolean b) {\n\t\t\terr.println(b);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn b;\n\t\t}\n\n\t\tpublic final Object debugln(boolean b, Object t, Object f) {\n\t\t\treturn b ? debugln(t) : debugln(f);\n\t\t}\n\n\t\tpublic final char debugln(char c) {\n\t\t\terr.println(c);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn c;\n\t\t}\n\n\t\tpublic final char[] debugln(char[] s) {\n\t\t\terr.println(s);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn s;\n\t\t}\n\n\t\tpublic final double debugln(double d) {\n\t\t\terr.println(d);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn d;\n\t\t}\n\n\t\tpublic final double debugln(double d, int length) {\n\t\t\tdebug(d, length);\n\t\t\tdebugln();\n\t\t\treturn d;\n\t\t}\n\n\t\tpublic final float debugln(float f) {\n\t\t\terr.println(f);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn f;\n\t\t}\n\n\t\tpublic final int debugln(int i) {\n\t\t\terr.println(i);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn i;\n\t\t}\n\n\t\tpublic final long debugln(long l) {\n\t\t\terr.println(l);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn l;\n\t\t}\n\n\t\tpublic final Object debugln(Object obj) {\n\t\t\tdebug(obj);\n\t\t\tdebugln();\n\t\t\treturn obj;\n\t\t}\n\n\t\tpublic final String debugln(String s) {\n\t\t\terr.println(s);\n\t\t\tif (autoFlush) flush();\n\t\t\treturn s;\n\t\t}\n\n\t\tpublic final Object debugln(Object array, String... parse) {\n\t\t\tdebug(array, parse);\n\t\t\tdebugln();\n\t\t\treturn array;\n\t\t}\n\n\t\tpublic final void flush() {\n\t\t\tout.flush();\n\t\t\terr.flush();\n\t\t}\n\t}\n\n\tpublic enum BoundType {\n\t\tCLOSED, OPEN;\n\t}\n\n\tpublic static class Range implements Serializable{\n\n\t\tprivate static final long serialVersionUID = -4702828934863023392L;\n\t\tprotected C lower;\n\t\tprotected C upper;\n\t\tprotected BoundType lowerType;\n\t\tprotected BoundType upperType;\n\t\tprivate Comparator comparator;\n\n\t\tprotected Range(C lower, BoundType lowerType, C upper, BoundType upperType) {\n\t\t\tthis(lower, lowerType, upper, upperType, null);\n\t\t}\n\n\t\tprotected Range(C lower, BoundType lowerType, C upper, BoundType upperType, Comparator comparator) {\n\t\t\tthis.lower = lower;\n\t\t\tthis.upper = upper;\n\t\t\tthis.lowerType = lowerType;\n\t\t\tthis.upperType = upperType;\n\t\t\tthis.comparator = comparator;\n\t\t}\n\n\t\tpublic static > Range range(C lower, BoundType lowerType, C upper, BoundType upperType) {\n\t\t\tif (lower != null && upper != null) {\n\t\t\t\tint comp = lower.compareTo(upper);\n\t\t\t\tif (comp > 0) return new Range(null, BoundType.CLOSED, null, BoundType.CLOSED);\n\t\t\t\telse if (comp == 0 && (lowerType == BoundType.OPEN || upperType == BoundType.OPEN))return new Range(null, BoundType.CLOSED, null, BoundType.CLOSED);\n\t\t\t}\n\t\t\treturn new Range(lower, lowerType, upper, upperType);\n\t\t}\n\n\t\tpublic static Range range(C lower, BoundType lowerType, C upper, BoundType upperType, Comparator comparator) {\n\t\t\tif (lower != null && upper != null) {\n\t\t\t\tint comp = comparator.compare(lower, upper);\n\t\t\t\tif (comp > 0) return new Range(null, BoundType.CLOSED, null, BoundType.CLOSED, comparator);\n\t\t\t\telse if (comp == 0 && (lowerType == BoundType.OPEN || upperType == BoundType.OPEN)) return new Range(null, BoundType.CLOSED, null, BoundType.CLOSED, comparator);\n\t\t\t}\n\t\t\treturn new Range(lower, lowerType, upper, upperType, comparator);\n\t\t}\n\n\t\tpublic static > Range all() {\n\t\t\treturn range((C)null, BoundType.OPEN, null, BoundType.OPEN);\n\t\t}\n\n\t\tpublic static Range all(Comparator comparator) {\n\t\t\treturn range((C)null, BoundType.OPEN, null, BoundType.OPEN, comparator);\n\t\t}\n\n\t\tpublic static > Range atMost(C upper) {\n\t\t\treturn range(null, BoundType.OPEN, upper, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static Range atMost(C upper, Comparator comparator) {\n\t\t\treturn range(null, BoundType.OPEN, upper, BoundType.CLOSED, comparator);\n\t\t}\n\n\t\tpublic static > Range lessThan(C upper) {\n\t\t\treturn range(null, BoundType.OPEN, upper, BoundType.OPEN);\n\t\t}\n\n\t\tpublic static Range lessThan(C upper, Comparator comparator) {\n\t\t\treturn range(null, BoundType.OPEN, upper, BoundType.OPEN, comparator);\n\t\t}\n\n\t\tpublic static > Range downTo(C upper, BoundType boundType) {\n\t\t\treturn range(null, BoundType.OPEN, upper, boundType);\n\t\t}\n\n\t\tpublic static Range downTo(C upper, BoundType boundType, Comparator comparator) {\n\t\t\treturn range(null, BoundType.OPEN, upper, boundType, comparator);\n\t\t}\n\n\t\tpublic static > Range atLeast(C lower) {\n\t\t\treturn range(lower, BoundType.CLOSED, null, BoundType.OPEN);\n\t\t}\n\n\t\tpublic static Range atLeast(C lower, Comparator comparator) {\n\t\t\treturn range(lower, BoundType.CLOSED, null, BoundType.OPEN, comparator);\n\t\t}\n\n\t\tpublic static > Range greaterThan(C lower) {\n\t\t\treturn range(lower, BoundType.OPEN, null, BoundType.OPEN);\n\t\t}\n\n\t\tpublic static Range greaterThan(C lower, Comparator comparator) {\n\t\t\treturn range(lower, BoundType.OPEN, null, BoundType.OPEN, comparator);\n\t\t}\n\n\t\tpublic static > Range upTo(C lower, BoundType boundType) {\n\t\t\treturn range(lower, boundType, null, BoundType.OPEN);\n\t\t}\n\n\t\tpublic static Range upTo(C lower, BoundType boundType, Comparator comparator) {\n\t\t\treturn range(lower, boundType, null, BoundType.OPEN, comparator );\n\t\t}\n\n\t\tpublic static > Range open(C lower, C upper) {\n\t\t\treturn range(lower, BoundType.OPEN, upper, BoundType.OPEN);\n\t\t}\n\n\t\tpublic static Range open(C lower, C upper, Comparator comparator) {\n\t\t\treturn range(lower, BoundType.OPEN, upper, BoundType.OPEN, comparator);\n\t\t}\n\n\t\tpublic static > Range openClosed(C lower, C upper) {\n\t\t\treturn range(lower, BoundType.OPEN, upper, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static Range openClosed(C lower, C upper, Comparator comparator) {\n\t\t\treturn range(lower, BoundType.OPEN, upper, BoundType.CLOSED, comparator);\n\t\t}\n\n\t\tpublic static > Range closedOpen(C lower, C upper) {\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.OPEN);\n\t\t}\n\n\t\tpublic static Range closedOpen(C lower, C upper, Comparator comparator) {\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.OPEN, comparator);\n\t\t}\n\n\t\tpublic static > Range closed(C lower, C upper) {\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static Range closed(C lower, C upper, Comparator comparator) {\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.CLOSED, comparator);\n\t\t}\n\n\t\tpublic static > Range singleton(C value) {\n\t\t\treturn range(value, BoundType.CLOSED, value, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static Range singleton(C value, Comparator comparator) {\n\t\t\treturn range(value, BoundType.CLOSED, value, BoundType.CLOSED, comparator);\n\t\t}\n\n\t\tpublic static > Range empty() {\n\t\t\treturn range((C)null, BoundType.CLOSED, null, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static Range empty(Comparator comparator) {\n\t\t\treturn range((C)null, BoundType.CLOSED, null, BoundType.CLOSED, comparator);\n\t\t}\n\n\t\tpublic static > Range encloseAll(Iterable values) {\n\t\t\tC lower = values.iterator().next();\n\t\t\tC upper = lower;\n\t\t\tfor (C i : values) {\n\t\t\t\tif (lower.compareTo(i) > 0) lower = i;\n\t\t\t\tif (upper.compareTo(i) < 0) upper = i;\n\t\t\t}\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static Range encloseAll(Iterable values, Comparator comparator) {\n\t\t\tC lower = values.iterator().next();\n\t\t\tC upper = lower;\n\t\t\tfor (C i : values) {\n\t\t\t\tif (comparator.compare(lower, i) > 0) lower = i;\n\t\t\t\tif (comparator.compare(upper, i) < 0) upper = i;\n\t\t\t}\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.CLOSED, comparator);\n\t\t}\n\n\t\tprotected int compareLower(C value) {\n\t\t\treturn compareLower(value, BoundType.CLOSED);\n\t\t}\n\n\t\tprotected int compareLower(C value, BoundType boundType) {\n\t\t\treturn compareLower(lower, lowerType, value, boundType);\n\t\t}\n\n\t\tprotected int compareLower(C lower, BoundType lowerType, C value) {\n\t\t\treturn compareLower(lower, lowerType, value, BoundType.CLOSED);\n\t\t}\n\n\t\tprotected int compareLower(C lower, BoundType lowerType, C value, BoundType boundType) {\n\t\t\tif (lower == null) return value == null ? 0 : -1;\n\t\t\telse if (value == null) return 1;\n\t\t\tint compare;\n\t\t\tif (comparator == null) {\n\t\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\t\tComparable comp = (Comparable)lower;\n\t\t\t\tcompare = comp.compareTo(value);\n\t\t\t} else compare = comparator.compare(lower, value);\n\t\t\tif (compare == 0) {\n\t\t\t\tif (lowerType == BoundType.CLOSED) -- compare;\n\t\t\t\tif (boundType == BoundType.CLOSED) ++ compare;\n\t\t\t}\n\t\t\treturn compare;\n\t\t}\n\n\t\tprotected int compareUpper(C value) {\n\t\t\treturn compareUpper(value, BoundType.CLOSED);\n\t\t}\n\n\t\tprotected int compareUpper(C value, BoundType boundType) {\n\t\t\treturn compareUpper(upper, upperType, value, boundType);\n\t\t}\n\n\t\tprotected int compareUpper(C upper, BoundType upperType, C value) {\n\t\t\treturn compareUpper(upper, upperType, value, BoundType.CLOSED);\n\t\t}\n\n\t\tprotected int compareUpper(C upper, BoundType upperType, C value, BoundType boundType) {\n\t\t\tif (upper == null) return value == null ? 0 : 1;\n\t\t\tif (value == null) return -1;\n\t\t\tint compare;\n\t\t\tif (comparator == null) {\n\t\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\t\tComparable comp = (Comparable)upper;\n\t\t\t\tcompare = comp.compareTo(value);\n\t\t\t} else compare = comparator.compare(upper, value);\n\t\t\tif (compare == 0) {\n\t\t\t\tif (upperType == BoundType.CLOSED) ++ compare;\n\t\t\t\tif (boundType == BoundType.CLOSED) -- compare;\n\t\t\t}\n\t\t\treturn compare;\n\t\t}\n\n\t\tpublic boolean hasLowerBound() {\n\t\t\treturn lower != null;\n\t\t}\n\n\t\tpublic C lowerEndpoint() {\n\t\t\tif (hasLowerBound()) return lower;\n\t\t\tthrow new IllegalStateException();\n\t\t}\n\n\t\tpublic BoundType lowerBoundType() {\n\t\t\tif (hasLowerBound()) return lowerType;\n\t\t\tthrow new IllegalStateException();\n\t\t}\n\n\t\tpublic boolean hasUpperBound() {\n\t\t\treturn upper != null;\n\t\t}\n\n\t\tpublic C upperEndpoint() {\n\t\t\tif (hasUpperBound()) return upper;\n\t\t\tthrow new IllegalStateException();\n\t\t}\n\n\t\tpublic BoundType upperBoundType() {\n\t\t\tif (hasUpperBound()) return upperType;\n\t\t\tthrow new IllegalStateException();\n\t\t}\n\n\t\t/**\n\t\t * この区間が空集合か判定します。\n\t\t * @return 空集合ならばtrue\n\t\t */\n\t\tpublic boolean isEmpty() {\n\t\t\treturn lower == null && upper == null && lowerType == BoundType.CLOSED;\n\t\t}\n\n\t\t/**\n\t\t * 与えられた引数が区間の左側に位置するか判定します。
\n\t\t * 接する場合は区間の左側ではないと判定します。\n\t\t * @param value 調べる引数\n\t\t * @return 区間の左側に位置するならtrue\n\t\t */\n\t\tpublic boolean isLess(C value) {\n\t\t\treturn isLess(value, BoundType.CLOSED);\n\t\t}\n\n\t\tprotected boolean isLess(C value, BoundType boundType) {\n\t\t\treturn compareLower(value, boundType) > 0;\n\t\t}\n\n\t\t/**\n\t\t * 与えられた引数が区間の右側に位置するか判定します。
\n\t\t * 接する場合は区間の右側ではないと判定します。\n\t\t * @param value 調べる引数\n\t\t * @return 区間の右側に位置するならtrue\n\t\t */\n\t\tpublic boolean isGreater(C value) {\n\t\t\treturn isGreater(value, BoundType.CLOSED);\n\t\t}\n\n\t\tprivate boolean isGreater(C value, BoundType boundType) {\n\t\t\treturn compareUpper(value, boundType) < 0;\n\t\t}\n\n\t\t/**\n\t\t * 与えられた引数が区間内に位置するか判定します。
\n\t\t * 接する場合も区間内に位置すると判定します。\n\t\t * @param value 調べる引数\n\t\t * @return 区間内に位置するならtrue\n\t\t */\n\t\tpublic boolean contains(C value) {\n\t\t\treturn !isLess(value) && !isGreater(value) && !isEmpty();\n\t\t}\n\n\t\t/**\n\t\t * 与えられた引数すべてが区間内に位置するか判定します。
\n\t\t * 接する場合も区間内に位置すると判定します。\n\t\t * @param value 調べる要素\n\t\t * @return 全ての要素が区間内に位置するならtrue\n\t\t */\n\t\tpublic boolean containsAll(Iterable values) {\n\t\t\tfor (C i : values) if (!contains(i)) return false;\n\t\t\treturn true;\n\t\t}\n\n\t\t/**\n\t\t * 与えられた区間がこの区間に内包されるか判定します。
\n\t\t *\n\t\t * @param other\n\t\t * @return 与えられた区間がこの区間に内包されるならtrue\n\t\t */\n\t\tpublic boolean encloses(Range other) {\n\t\t\treturn !isLess(other.lower, other.lowerType) && !isGreater(other.upper, other.upperType);\n\t\t}\n\n\t\t/**\n\t\t * 与えられた区間がこの区間と公差するか判定します。
\n\t\t * 接する場合は公差するものとします。\n\t\t * @param value 調べる引数\n\t\t * @return 区間が交差するならtrue\n\t\t */\n\t\tpublic boolean isConnected(Range other) {\n\t\t\tif (this.isEmpty() || other.isEmpty()) return false;\n\t\t\tC lower, upper;\n\t\t\tBoundType lowerType, upperType;\n\t\t\tif (isLess(other.lower, other.lowerType)) {\n\t\t\t\tlower = other.lower;\n\t\t\t\tlowerType = other.lowerType;\n\t\t\t} else {\n\t\t\t\tlower = this.lower;\n\t\t\t\tlowerType = this.lowerType;\n\t\t\t}\n\t\t\tif (isGreater(other.upper, other.upperType)) {\n\t\t\t\tupper = other.upper;\n\t\t\t\tupperType = other.upperType;\n\t\t\t} else {\n\t\t\t\tupper = this.upper;\n\t\t\t\tupperType = this.upperType;\n\t\t\t}\n\t\t\tif (lower == null || upper == null) return true;\n\t\t\tint comp = compareLower(lower, lowerType, upper, upperType);\n\t\t\treturn comp <= 0;\n\t\t}\n\t\t/**\n\t\t * この区間との積集合を返します。\n\t\t * @param connectedRange 積集合を求める区間\n\t\t * @return 積集合\n\t\t */\n\t\tpublic Range intersection(Range connectedRange) {\n\t\t\tif (this.isEmpty() || connectedRange.isEmpty()) {\n\t\t\t\tif (comparator == null) return new Range(null, BoundType.CLOSED, null, BoundType.CLOSED);\n\t\t\t\treturn empty(comparator);\n\t\t\t}\n\t\t\tC lower, upper;\n\t\t\tBoundType lowerType, upperType;\n\t\t\tif (isLess(connectedRange.lower, connectedRange.lowerType)) {\n\t\t\t\tlower = connectedRange.lower;\n\t\t\t\tlowerType = connectedRange.lowerType;\n\t\t\t} else {\n\t\t\t\tlower = this.lower;\n\t\t\t\tlowerType = this.lowerType;\n\t\t\t}\n\t\t\tif (isGreater(connectedRange.upper, connectedRange.upperType)) {\n\t\t\t\tupper = connectedRange.upper;\n\t\t\t\tupperType = connectedRange.upperType;\n\t\t\t} else {\n\t\t\t\tupper = this.upper;\n\t\t\t\tupperType = this.upperType;\n\t\t\t}\n\t\t\tif (comparator == null) {\n\t\t\t\treturn new Range(lower, lowerType, upper, upperType);\n\t\t\t}\n\t\t\treturn range(lower, lowerType, upper, upperType, comparator);\n\t\t}\n\n\t\t/**\n\t\t * この区間との和集合を返します。\n\t\t * @param other 和集合を求める区間\n\t\t * @return 和集合\n\t\t */\n\t\tpublic Range span(Range other) {\n\t\t\tif (other.isEmpty()) return new Range(lower, lowerType, upper, upperType);\n\t\t\tC lower, upper;\n\t\t\tBoundType lowerType, upperType;\n\t\t\tif (isLess(other.lower, other.lowerType)) {\n\t\t\t\tlower = this.lower;\n\t\t\t\tlowerType = this.lowerType;\n\t\t\t} else {\n\t\t\t\tlower = other.lower;\n\t\t\t\tlowerType = other.lowerType;\n\t\t\t}\n\t\t\tif (isGreater(other.upper, other.upperType)) {\n\t\t\t\tupper = this.upper;\n\t\t\t\tupperType = this.upperType;\n\t\t\t} else {\n\t\t\t\tupper = other.upper;\n\t\t\t\tupperType = other.upperType;\n\t\t\t}\n\t\t\treturn new Range(lower, lowerType, upper, upperType, comparator);\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean equals(Object object) {\n\t\t\tif (this == object) return true;\n\t\t\tif (object instanceof Range) {\n\t\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\t\tRange comp = (Range) object;\n\t\t\t\treturn compareLower(comp.lower, comp.lowerType) == 0 && compareUpper(comp.upper, comp.upperType) == 0 && lowerType == comp.lowerType && upperType == comp.upperType;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\t@Override\n\t\tpublic int hashCode() {\n\t\t\tif (lower == null && upper == null) return 0;\n\t\t\telse if (lower == null) return upper.hashCode();\n\t\t\telse if (upper == null) return lower.hashCode();\n\t\t\treturn lower.hashCode() ^ upper.hashCode();\n\t\t}\n\n\t\t@Override\n\t\tpublic String toString() {\n\t\t\tif (isEmpty()) return \"()\";\n\t\t\treturn (lowerType == BoundType.OPEN ? \"(\" : \"[\") + (lower == null ? \"\" : lower.toString()) + \"..\" + (upper == null ? \"\" : upper.toString()) + (upperType == BoundType.OPEN ? \")\" : \"]\");\n\t\t}\n\t}\n\n\tpublic static class IterableRange extends Range implements Iterable{\n\n\t\tprivate static final long serialVersionUID = 9065915259748260688L;\n\t\tprotected UnaryOperator func;\n\n\t\tprotected IterableRange(C lower, BoundType lowerType, C upper, BoundType upperType, UnaryOperator func) {\n\t\t\tsuper(lower, lowerType, upper, upperType);\n\t\t\tthis.func = func;\n\t\t}\n\n\t\tpublic static > IterableRange range(C lower, BoundType lowerType, C upper, BoundType upperType, UnaryOperator func) {\n\t\t\tif (lower == null || upper == null) return new IterableRange(null, BoundType.CLOSED, null, BoundType.CLOSED, func);\n\t\t\tint comp = lower.compareTo(upper);\n\t\t\tif (comp > 0) return new IterableRange(null, BoundType.CLOSED, null, BoundType.CLOSED, func);\n\t\t\telse if (comp == 0 && (lowerType == BoundType.OPEN || upperType == BoundType.OPEN)) return new IterableRange(null, BoundType.CLOSED, null, BoundType.CLOSED, func);\n\t\t\treturn new IterableRange(lower, lowerType, upper, upperType, func);\n\t\t}\n\n\t\tpublic static > IterableRange open(C lower, C upper, UnaryOperator func) {\n\t\t\tif (lower == null) return new IterableRange(null, BoundType.CLOSED, null, BoundType.CLOSED, func);\n\t\t\treturn range(func.apply(lower), BoundType.CLOSED, upper, BoundType.OPEN, func);\n\t\t}\n\n\t\tpublic static > IterableRange openClosed(C lower, C upper, UnaryOperator func) {\n\t\t\tif (lower == null) return new IterableRange(null, BoundType.CLOSED, null, BoundType.CLOSED, func);\n\t\t\treturn range(func.apply(lower), BoundType.CLOSED, upper, BoundType.CLOSED, func);\n\t\t}\n\n\t\tpublic static > IterableRange closedOpen(C lower, C upper, UnaryOperator func) {\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.OPEN, func);\n\t\t}\n\n\t\tpublic static > IterableRange closed(C lower, C upper, UnaryOperator func) {\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.CLOSED, func);\n\t\t}\n\n\t\tpublic static > IterableRange singleton(C value, UnaryOperator func) {\n\t\t\treturn range(value, BoundType.CLOSED, value, BoundType.CLOSED, func);\n\t\t}\n\n\t\tprotected class Iter implements Iterator {\n\t\t\tC now;\n\t\t\tIter() {\n\t\t\t\tnow = lower;\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic final boolean hasNext() {\n\t\t\t\treturn !isGreater(now);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic final C next() {\n\t\t\t\tC ret = now;\n\t\t\t\tnow = func.apply(now);\n\t\t\t\treturn ret;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic final void remove() {\n\t\t\t\tthrow new UnsupportedOperationException();\n\t\t\t}\n\t\t}\n\n\t\tprotected class EmptyIter implements Iterator {\n\n\t\t\t@Override\n\t\t\tpublic boolean hasNext() {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic C next() {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic final void remove() {\n\t\t\t\tthrow new UnsupportedOperationException();\n\t\t\t}\n\n\t\t}\n\n\t\t@Override\n\t\tpublic Iterator iterator() {\n\t\t\treturn lower == null || upper == null ? new EmptyIter() : new Iter();\n\t\t}\n\n\t\tpublic int getDistance() {\n\t\t\tC check = upper;\n\t\t\tint ret = 0;\n\t\t\twhile (lower != check) {\n\t\t\t\tcheck = func.apply(check);\n\t\t\t\t++ ret;\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\t}\n\n\tpublic static class IntRange extends IterableRange{\n\n\t\tprivate static final long serialVersionUID = 5623995336491967216L;\n\t\tprivate final boolean useFastIter;\n\n\t\tprivate static class Next implements UnaryOperator {\n\n\t\t\t@Override\n\t\t\tpublic Integer apply(Integer value) {\n\t\t\t\treturn value + 1;\n\t\t\t}\n\t\t}\n\n\t\tprotected IntRange() {\n\t\t\tsuper(null, BoundType.CLOSED, null, BoundType.CLOSED, new Next());\n\t\t\tuseFastIter = true;\n\t\t}\n\n\t\tprotected IntRange(UnaryOperator func) {\n\t\t\tsuper(null, BoundType.CLOSED, null, BoundType.CLOSED, func);\n\t\t\tuseFastIter = false;\n\t\t}\n\n\t\tprotected IntRange(int lower, BoundType lowerType, int upper, BoundType upperType) {\n\t\t\tsuper(lower, lowerType, upper, upperType, new Next());\n\t\t\tuseFastIter = true;\n\t\t}\n\n\t\tprotected IntRange(int lower, BoundType lowerType, int upper, BoundType upperType, UnaryOperator func) {\n\t\t\tsuper(lower, lowerType, upper, upperType, func);\n\t\t\tuseFastIter = false;\n\t\t}\n\n\t\tpublic static IntRange range(int lower, BoundType lowerType, int upper, BoundType upperType) {\n\t\t\tif (lower > upper) return new IntRange();\n\t\t\tif (lowerType == BoundType.OPEN) ++ lower;\n\t\t\tif (upperType == BoundType.OPEN) -- upper;\n\t\t\treturn new IntRange(lower, BoundType.CLOSED, upper, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static IntRange range(int lower, BoundType lowerType, int upper, BoundType upperType, UnaryOperator func) {\n\t\t\tif (lower > upper) return new IntRange(func);\n\t\t\tif (lowerType == BoundType.OPEN) ++ lower;\n\t\t\tif (upperType == BoundType.OPEN) -- upper;\n\t\t\treturn new IntRange(lower, BoundType.CLOSED, upper, BoundType.CLOSED, func);\n\t\t}\n\n\t\tpublic static IntRange open(int lower, int upper) {\n\t\t\treturn range(lower, BoundType.OPEN, upper, BoundType.OPEN);\n\t\t}\n\n\t\tpublic static IntRange open(int lower, int upper, UnaryOperator func) {\n\t\t\treturn range(lower, BoundType.OPEN, upper, BoundType.OPEN, func);\n\t\t}\n\n\t\tpublic static IntRange open(int upper) {\n\t\t\treturn range(0, BoundType.CLOSED, upper, BoundType.OPEN);\n\t\t}\n\n\t\tpublic static IntRange open(int upper, UnaryOperator func) {\n\t\t\treturn range(0, BoundType.CLOSED, upper, BoundType.OPEN, func);\n\t\t}\n\n\t\tpublic static IntRange openClosed(int lower, int upper) {\n\t\t\treturn range(lower, BoundType.OPEN, upper, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static IntRange openClosed(int lower, int upper, UnaryOperator func) {\n\t\t\treturn range(lower, BoundType.OPEN, upper, BoundType.CLOSED, func);\n\t\t}\n\n\t\tpublic static IntRange closedOpen(int lower, int upper) {\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.OPEN);\n\t\t}\n\n\t\tpublic static IntRange closedOpen(int lower, int upper, UnaryOperator func) {\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.OPEN, func);\n\t\t}\n\n\t\tpublic static IntRange closed(int lower, int upper) {\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static IntRange closed(int lower, int upper, UnaryOperator func) {\n\t\t\treturn range(lower, BoundType.CLOSED, upper, BoundType.CLOSED, func);\n\t\t}\n\n\t\tpublic static IntRange closed(int upper) {\n\t\t\treturn range(0, BoundType.CLOSED, upper, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static IntRange closed(int upper, UnaryOperator func) {\n\t\t\treturn range(0, BoundType.CLOSED, upper, BoundType.CLOSED, func);\n\t\t}\n\n\t\tpublic static IntRange singleton(int value) {\n\t\t\treturn range(value, BoundType.CLOSED, value, BoundType.CLOSED);\n\t\t}\n\n\t\tpublic static IntRange singleton(int value, UnaryOperator func) {\n\t\t\treturn range(value, BoundType.CLOSED, value, BoundType.CLOSED, func);\n\t\t}\n\n\t\tprivate class FastIter implements Iterator {\n\t\t\tint now;\n\t\t\tpublic FastIter() {\n\t\t\t\tnow = lower;\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic final boolean hasNext() {\n\t\t\t\treturn now <= upper;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic final Integer next() {\n\t\t\t\treturn now++;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic final void remove() {\n\t\t\t\tthrow new UnsupportedOperationException();\n\t\t\t}\n\t\t}\n\n\t\tprivate class Iter implements Iterator {\n\t\t\tint now;\n\t\t\tpublic Iter() {\n\t\t\t\tnow = lower;\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic final boolean hasNext() {\n\t\t\t\treturn now <= upper;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic final Integer next() {\n\t\t\t\tint ret = now;\n\t\t\t\tnow = func.apply(now);\n\t\t\t\treturn ret;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic final void remove() {\n\t\t\t\tthrow new UnsupportedOperationException();\n\t\t\t}\n\t\t}\n\n\t\t@Override\n\t\tpublic Iterator iterator() {\n\t\t\treturn lower == null || upper == null ? new EmptyIter() : useFastIter ? new FastIter() : new Iter();\n\t\t}\n\n\t\t@Override\n\t\tpublic int getDistance() {\n\t\t\tint ret = upper - lower;\n\t\t\tif (upperType == BoundType.CLOSED) ++ ret;\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic int getClosedLower() {\n\t\t\treturn lower;\n\t\t}\n\n\t\tpublic int getOpenLower() {\n\t\t\treturn lower - 1;\n\t\t}\n\n\t\tpublic int getClosedUpper() {\n\t\t\treturn upperType == BoundType.CLOSED ? upper : upper - 1;\n\t\t}\n\n\t\tpublic int getOpenUpper() {\n\t\t\treturn upperType == BoundType.CLOSED ? upper + 1 : upper;\n\t\t}\n\t}\n\n\t/**\n\t * 演算が結合法則を満たすことを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t */\n\tpublic interface Associative extends BinaryOperator{\n\t\t/**\n\t\t * repeat個のelementを順次演算した値を返します。\n\t\t * @param element 演算する値\n\t\t * @param repeat 繰り返す回数、1以上であること\n\t\t * @return 演算を+として、element + element + ... + elementと演算をrepeat-1回行った値\n\t\t */\n\t\tpublic default T hyper(T element, int repeat) {\n\t\t\tif (repeat < 1) throw new IllegalArgumentException(\"undefined operation\");\n\t\t\tT ret = element;\n\t\t\t-- repeat;\n\t\t\tfor (T mul = element;repeat > 0;repeat >>= 1, mul = apply(mul, mul)) if ((repeat & 1) != 0) ret = apply(ret, mul);\n\t\t\treturn ret;\n\t\t}\n\t}\n\n\t/**\n\t* この演算が逆元を持つことを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t */\n\tpublic interface Inverse extends BinaryOperator{\n\t\tpublic T inverse(T element);\n\t}\n\n\t/**\n\t * 演算が交換法則を満たすことを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t */\n\tpublic interface Commutative extends BinaryOperator{\n\n\t}\n\n\t/**\n\t * 演算が単位元を持つことを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t */\n\tpublic interface Identity extends BinaryOperator{\n\t\t/**\n\t\t * 単位元を返します。\n\t\t * @return 単位元\n\t\t */\n\t\tpublic T identity();\n\t}\n\n\t/**\n\t * 演算が群であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t */\n\tpublic interface Group extends Monoid, Inverse{\n\t\t/**\n\t\t * repeat個のelementを順次演算した値を返します。\n\t\t * @param element 演算する値\n\t\t * @param repeat 繰り返す回数\n\t\t * @return 演算を+として、element + element + ... + elementと演算をrepeat-1回行った値\n\t\t */\n\t\t@Override\n\t\tpublic default T hyper(T element, int repeat) {\n\t\t\tT ret = identity();\n\t\t\tif (repeat < 0) {\n\t\t\t\trepeat = -repeat;\n\t\t\t\tfor (T mul = element;repeat > 0;repeat >>= 1, mul = apply(mul, mul)) if ((repeat & 1) != 0) ret = apply(ret, mul);\n\t\t\t\treturn inverse(ret);\n\t\t\t}\n\t\t\tfor (T mul = element;repeat > 0;repeat >>= 1, mul = apply(mul, mul)) if ((repeat & 1) != 0) ret = apply(ret, mul);\n\t\t\treturn ret;\n\t\t}\n\t}\n\n\t/**\n\t * 演算がモノイドであることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t */\n\tpublic interface Monoid extends Associative, Identity {\n\t\t/**\n\t\t * repeat個のelementを順次演算した値を返します。\n\t\t * @param element 演算する値\n\t\t * @param repeat 繰り返す回数、0以上であること\n\t\t * @return 演算を+として、element + element + ... + elementと演算をrepeat-1回行った値\n\t\t */\n\t\t@Override\n\t\tpublic default T hyper(T element, int repeat) {\n\t\t\tif (repeat < 0) throw new IllegalArgumentException(\"undefined operation\");\n\t\t\tT ret = identity();\n\t\t\tfor (T mul = element;repeat > 0;repeat >>= 1, mul = apply(mul, mul)) if ((repeat & 1) != 0) ret = apply(ret, mul);\n\t\t\treturn ret;\n\t\t}\n\t}\n\n\t/**\n\t * 演算が可換モノイドであることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t */\n\tpublic interface CommutativeMonoid extends Monoid, Commutative {\n\n\t}\n\n\t/**\n\t * 演算がアーベル群(可換群)であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t */\n\tpublic interface Abelian extends Group, CommutativeMonoid {\n\n\t}\n\n\t/**\n\t * 演算が半環であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t * @param
和に関する演算\n\t * @param 積に関する演算\n\t */\n\tpublic interface Semiring, M extends Monoid> {\n\t\tpublic A getAddition();\n\t\tpublic M getMultiplication();\n\t\tpublic default T add(T left, T right) {\n\t\t\treturn getAddition().apply(left, right);\n\t\t}\n\n\t\tpublic default T multiply(T left, T right) {\n\t\t\treturn getMultiplication().apply(left, right);\n\t\t}\n\n\t\tpublic default T additiveIdentity() {\n\t\t\treturn getAddition().identity();\n\t\t}\n\n\t\tpublic default T multipleIdentity() {\n\t\t\treturn getMultiplication().identity();\n\t\t}\n\n\t\tpublic default int characteristic() {\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\t/**\n\t * 演算が環であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t * @param 和に関する演算\n\t * @param 積に関する演算\n\t */\n\tpublic interface Ring, M extends Monoid> extends Semiring{\n\n\t}\n\n\t/**\n\t * 演算が可換環に属することを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t * @param 和に関する演算\n\t * @param 積に関する演算\n\t */\n\tpublic interface CommutativeRing, M extends CommutativeMonoid> extends Ring{\n\n\t}\n\n\t/**\n\t * 演算が整域であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t * @param 和に関する演算\n\t * @param 積に関する演算\n\t */\n\tpublic interface IntegralDomain, M extends CommutativeMonoid> extends CommutativeRing{\n\t\tpublic boolean isDivisible(T left, T right);\n\t\tpublic T divide(T left, T right);\n\t}\n\n\t/**\n\t * 演算が整閉整域であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t * @param 和に関する演算\n\t * @param 積に関する演算\n\t */\n\tpublic interface IntegrallyClosedDomain, M extends CommutativeMonoid> extends IntegralDomain{\n\n\t}\n\n\t/**\n\t * 演算がGCD整域であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t * @param 和に関する演算\n\t * @param 積に関する演算\n\t */\n\tpublic interface GCDDomain, M extends CommutativeMonoid> extends IntegrallyClosedDomain{\n\t\tpublic T gcd(T left, T right);\n\t\tpublic T lcm(T left, T right);\n\t}\n\n\t/**\n\t * 素元を提供します。\n\t * @author 31536000\n\t *\n\t * @param 演算の型\n\t */\n\tpublic static class PrimeElement {\n\t\tpublic final T element;\n\t\tpublic PrimeElement(T element) {\n\t\t\tthis.element = element;\n\t\t}\n\t}\n\n\tpublic interface MultiSet extends Collection{\n\t\tpublic int add(E element, int occurrences);\n\t\tpublic int count(Object element);\n\t\tpublic Set elementSet();\n\t\tpublic boolean remove(Object element, int occurrences);\n\t\tpublic int setCount(E element, int count);\n\t\tpublic boolean setCount(E element, int oldCount, int newCount);\n\t}\n\n\t/**\n\t * 演算が一意分解整域であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t * @param 和に関する演算\n\t * @param 積に関する演算\n\t */\n\tpublic interface UniqueFactorizationDomain, M extends CommutativeMonoid> extends GCDDomain{\n\t\tpublic MultiSet> PrimeFactorization(T x);\n\t}\n\n\t/**\n\t * 演算が主イデアル整域であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t * @param 和に関する演算\n\t * @param 積に関する演算\n\t */\n\tpublic interface PrincipalIdealDomain, M extends CommutativeMonoid> extends UniqueFactorizationDomain {\n\n\t}\n\n\t/**\n\t * 演算がユークリッド整域であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t * @param 和に関する演算\n\t * @param 積に関する演算\n\t */\n\tpublic interface EuclideanDomain, M extends CommutativeMonoid> extends PrincipalIdealDomain{\n\t\tpublic T reminder(T left, T right);\n\t}\n\n\t/**\n\t * 演算が体であることを示すために使用するマーカー・インターフェースです。\n\t * @author 31536000\n\t *\n\t * @param 二項演算の型\n\t * @param 和に関する演算\n\t * @param 積に関する演算\n\t */\n\tpublic interface Field, M extends Abelian> extends EuclideanDomain{\n\t\t@Override\n\t\tpublic default boolean isDivisible(T left, T right) {\n\t\t\treturn !right.equals(additiveIdentity());\n\t\t}\n\n\t\t@Override\n\t\tpublic default T divide(T left, T right) {\n\t\t\tif (isDivisible(left, right)) throw new ArithmeticException(\"divide by Additive Identify\");\n\t\t\treturn multiply(left, getMultiplication().inverse(right));\n\t\t}\n\n\t\t@Override\n\t\tpublic default T reminder(T left, T right) {\n\t\t\tif (isDivisible(left, right)) throw new ArithmeticException(\"divide by Additive Identify\");\n\t\t\treturn additiveIdentity();\n\t\t}\n\n\t\t@Override\n\t\tpublic default T gcd(T left, T right) {\n\t\t\treturn multipleIdentity();\n\t\t}\n\n\t\t@Override\n\t\tpublic default T lcm(T left, T right) {\n\t\t\treturn multipleIdentity();\n\t\t}\n\n\t\t@Override\n\t\tpublic default MultiSet> PrimeFactorization(T x) {\n\t\t\tHashMultiSet> ret = HashMultiSet.create(1);\n\t\t\tret.add(new PrimeElement(x));\n\t\t\treturn ret;\n\t\t}\n\t}\n\n\tpublic static class HashMultiSet implements MultiSet, Serializable{\n\n\t\tprivate static final long serialVersionUID = -8378919645386251159L;\n\t\tprivate final transient HashMap map;\n\t\tprivate transient int size;\n\n\t\tprivate HashMultiSet() {\n\t\t\tmap = new HashMap<>();\n\t\t\tsize = 0;\n\t\t}\n\n\t\tprivate HashMultiSet(int distinctElements) {\n\t\t\tmap = new HashMap<>(distinctElements);\n\t\t\tsize = 0;\n\t\t}\n\n\t\tpublic static HashMultiSet create() {\n\t\t\treturn new HashMultiSet<>();\n\t\t}\n\n\t\tpublic static HashMultiSet create(int distinctElements) {\n\t\t\treturn new HashMultiSet<>(distinctElements);\n\t\t}\n\n\t\tpublic static HashMultiSet create(Iterable elements) {\n\t\t\tHashMultiSet ret = new HashMultiSet<>();\n\t\t\tfor (E i : elements) ret.map.compute(i, (v, e) -> e == null ? 1 : ++e);\n\t\t\treturn ret;\n\t\t}\n\n\t\t@Override\n\t\tpublic int size() {\n\t\t\treturn size;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean isEmpty() {\n\t\t\treturn size == 0;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean contains(Object o) {\n\t\t\treturn map.containsKey(o);\n\t\t}\n\n\t\tprivate class Iter implements Iterator {\n\n\t\t\tprivate final Iterator> iter = map.entrySet().iterator();\n\t\t\tprivate E value;\n\t\t\tprivate int count = 0;\n\n\t\t\t@Override\n\t\t\tpublic boolean hasNext() {\n\t\t\t\tif (count > 0) return true;\n\t\t\t\tif (iter.hasNext()) {\n\t\t\t\t\tEntry entry = iter.next();\n\t\t\t\t\tvalue = entry.getKey();\n\t\t\t\t\tcount = entry.getValue();\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic E next() {\n\t\t\t\t-- count;\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t}\n\n\t\t@Override\n\t\tpublic Iterator iterator() {\n\t\t\treturn new Iter();\n\t\t}\n\n\t\t@Override\n\t\tpublic Object[] toArray() {\n\t\t\tObject[] ret = new Object[size];\n\t\t\tint read = 0;\n\t\t\tfor (Entry i : map.entrySet()) Arrays.fill(ret, read, read += i.getValue(), i.getKey());\n\t\t\treturn ret;\n\t\t}\n\n\t\t@Override\n\t\tpublic T[] toArray(T[] a) {\n\t\t\tObject[] src = toArray();\n\t\t\tif (a.length < src.length) {\n\t\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\t\tT[] ret = (T[])Arrays.copyOfRange(src, 0, src.length, a.getClass());\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t\tSystem.arraycopy(src, 0, a, 0, src.length);\n\t\t\treturn a;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean add(E e) {\n\t\t\tadd(e, 1);\n\t\t\treturn true;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean remove(Object o) {\n\t\t\treturn remove(o, 1);\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean containsAll(Collection c) {\n\t\t\tboolean ret = true;\n\t\t\tfor (Object i : c) ret |= contains(i);\n\t\t\treturn ret;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean addAll(Collection c) {\n\t\t\tboolean ret = false;\n\t\t\tfor (E i : c) ret |= add(i);\n\t\t\treturn ret;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean removeAll(Collection c) {\n\t\t\tboolean ret = false;\n\t\t\tfor (Object i : c) ret |= remove(i);\n\t\t\treturn ret;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean retainAll(Collection c) {\n\t\t\treturn removeAll(c);\n\t\t}\n\n\t\t@Override\n\t\tpublic void clear() {\n\t\t\tmap.clear();\n\t\t\tsize = 0;\n\t\t}\n\n\t\t@Override\n\t\tpublic int add(E element, int occurrences) {\n\t\t\tsize += occurrences;\n\t\t\treturn map.compute(element, (k, v) -> v == null ? occurrences : v + occurrences) - occurrences;\n\t\t}\n\n\t\t@Override\n\t\tpublic int count(Object element) {\n\t\t\treturn map.getOrDefault(element, 0);\n\t\t}\n\n\t\t@Override\n\t\tpublic Set elementSet() {\n\t\t\treturn map.keySet();\n\t\t}\n\n\t\tpublic Set> entrySet() {\n\t\t\treturn map.entrySet();\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean remove(Object element, int occurrences) {\n\t\t\ttry {\n\t\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\t\tE put = (E) element;\n\t\t\t\treturn map.compute(put, (k, v) -> {\n\t\t\t\t\tif (v == null) return null;\n\t\t\t\t\tif (v < occurrences) {\n\t\t\t\t\t\tsize -= v;\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tsize -= occurrences;\n\t\t\t\t\treturn v - occurrences;\n\t\t\t\t}) != null;\n\t\t\t} catch (ClassCastException E) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t@Override\n\t\tpublic int setCount(E element, int count) {\n\t\t\tInteger ret = map.put(element, count);\n\t\t\tint ret2 = ret == null ? 0 : ret;\n\t\t\tsize += count - ret2;\n\t\t\treturn ret2;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean setCount(E element, int oldCount, int newCount) {\n\t\t\tboolean ret = map.replace(element, oldCount, newCount);\n\t\t\tif (ret) size += newCount - oldCount;\n\t\t\treturn ret;\n\t\t}\n\n\t}\n\n\tpublic static class ModInteger extends Number implements Field, Abelian>{\n\n\t\tprivate static final long serialVersionUID = -8595710127161317579L;\n\t\tprivate final int mod;\n\t\tprivate int num;\n\n\t\tprivate final Addition add;\n\t\tprivate final Multiplication mul;\n\n\t\tprivate class Addition implements Abelian {\n\n\t\t\t@Override\n\t\t\tpublic ModInteger identity() {\n\t\t\t\treturn new ModInteger(mod, 0);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic ModInteger inverse(ModInteger element) {\n\t\t\t\treturn new ModInteger(element, element.mod - element.num);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic ModInteger apply(ModInteger left, ModInteger right) {\n\t\t\t\treturn new ModInteger(left).addEqual(right);\n\t\t\t}\n\t\t}\n\n\t\tprivate class Multiplication implements Abelian {\n\n\t\t\t@Override\n\t\t\tpublic ModInteger identity() {\n\t\t\t\treturn new ModInteger(mod, 1);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic ModInteger apply(ModInteger left, ModInteger right) {\n\t\t\t\treturn new ModInteger(left).multiplyEqual(right);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic ModInteger inverse(ModInteger element) {\n\t\t\t\treturn new ModInteger(element, element.inverse(element.num));\n\t\t\t}\n\n\t\t}\n\n\t\t@Override\n\t\tpublic int characteristic() {\n\t\t\treturn mod;\n\t\t}\n\n\t\tpublic ModInteger(int mod) {\n\t\t\tthis.mod = mod;\n\t\t\tnum = 0;\n\t\t\tadd = new Addition();\n\t\t\tmul = new Multiplication();\n\t\t}\n\n\t\tpublic ModInteger(int mod, int num) {\n\t\t\tthis.mod = mod;\n\t\t\tthis.num = validNum(num);\n\t\t\tadd = new Addition();\n\t\t\tmul = new Multiplication();\n\t\t}\n\n\t\tpublic ModInteger(ModInteger n) {\n\t\t\tmod = n.mod;\n\t\t\tnum = n.num;\n\t\t\tadd = n.add;\n\t\t\tmul = n.mul;\n\t\t}\n\n\t\tprivate ModInteger(ModInteger n, int num) {\n\t\t\tmod = n.mod;\n\t\t\tthis.num = num;\n\t\t\tadd = n.add;\n\t\t\tmul = n.mul;\n\t\t}\n\n\t\tprivate int validNum(int n) {\n\t\t\tn %= mod;\n\t\t\tif (n < 0) n += mod;\n\t\t\treturn n;\n\t\t}\n\n\t\tprivate int validNum(long n) {\n\t\t\tn %= mod;\n\t\t\tif (n < 0) n += mod;\n\t\t\treturn (int)n;\n\t\t}\n\n\t\tprotected int inverse(int n) {\n\t\t\tint m = mod, u = 0, v = 1, t;\n\t\t\twhile(n != 0) {\n\t\t\t\tt = m / n;\n\t\t\t\tm -= t * n;\n\t\t\t\tu -= t * v;\n\t\t\t\tif (m != 0) {\n\t\t\t\t\tt = n / m;\n\t\t\t\t\tn -= t * m;\n\t\t\t\t\tv -= t * u;\n\t\t\t\t} else {\n\t\t\t\t\tv %= mod;\n\t\t\t\t\tif (v < 0) v += mod;\n\t\t\t\t\treturn v;\n\t\t\t\t}\n\t\t\t}\n\t\t\tu %= mod;\n\t\t\tif (u < 0) u += mod;\n\t\t\treturn u;\n\t\t}\n\n\t\tpublic boolean isPrime(int n) {\n\t\t\tif ((n & 1) == 0) return false; // 偶数\n\t\t\tfor (int i = 3, j = 8, k = 9;k <= n;i += 2, k += j += 8) if (n % i == 0) return false;\n\t\t\treturn true;\n\t\t}\n\n\t\t@Override\n\t\tpublic int intValue() {\n\t\t\treturn num;\n\t\t}\n\n\t\t@Override\n\t\tpublic long longValue() {\n\t\t\treturn num;\n\t\t}\n\n\t\t@Override\n\t\tpublic float floatValue() {\n\t\t\treturn num;\n\t\t}\n\n\t\t@Override\n\t\tpublic double doubleValue() {\n\t\t\treturn num;\n\t\t}\n\n\t\tprotected ModInteger getNewInstance(ModInteger mod) {\n\t\t\treturn new ModInteger(mod);\n\t\t}\n\n\t\tpublic ModInteger add(int n) {\n\t\t\treturn getNewInstance(this).addEqual(n);\n\t\t}\n\n\t\tpublic ModInteger add(long n) {\n\t\t\treturn getNewInstance(this).addEqual(n);\n\t\t}\n\n\t\tpublic ModInteger add(ModInteger n) {\n\t\t\treturn getNewInstance(this).addEqual(n);\n\t\t}\n\n\t\tpublic ModInteger addEqual(int n) {\n\t\t\tnum = validNum(num + n);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger addEqual(long n) {\n\t\t\tnum = validNum(num + n);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger addEqual(ModInteger n) {\n\t\t\tif ((num += n.num) >= mod) num -= mod;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger subtract(int n) {\n\t\t\treturn getNewInstance(this).subtractEqual(n);\n\t\t}\n\n\t\tpublic ModInteger subtract(long n) {\n\t\t\treturn getNewInstance(this).subtractEqual(n);\n\t\t}\n\n\t\tpublic ModInteger subtract(ModInteger n) {\n\t\t\treturn getNewInstance(this).subtractEqual(n);\n\t\t}\n\n\t\tpublic ModInteger subtractEqual(int n) {\n\t\t\tnum = validNum(num - n);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger subtractEqual(long n) {\n\t\t\tnum = validNum(num - n);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger subtractEqual(ModInteger n) {\n\t\t\tif ((num -= n.num) < 0) num += mod;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger multiply(int n) {\n\t\t\treturn getNewInstance(this).multiplyEqual(n);\n\t\t}\n\n\t\tpublic ModInteger multiply(long n) {\n\t\t\treturn getNewInstance(this).multiplyEqual(n);\n\t\t}\n\n\t\tpublic ModInteger multiply(ModInteger n) {\n\t\t\treturn getNewInstance(this).multiplyEqual(n);\n\t\t}\n\n\t\tpublic ModInteger multiplyEqual(int n) {\n\t\t\tnum = (int)((long)num * n % mod);\n\t\t\tif (num < 0) num += mod;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger multiplyEqual(long n) {\n\t\t\treturn multiplyEqual((int) (n % mod));\n\t\t}\n\n\t\tpublic ModInteger multiplyEqual(ModInteger n) {\n\t\t\tnum = (int)((long)num * n.num % mod);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger divide(int n) {\n\t\t\treturn getNewInstance(this).divideEqual(n);\n\t\t}\n\n\t\tpublic ModInteger divide(long n) {\n\t\t\treturn getNewInstance(this).divideEqual(n);\n\t\t}\n\n\t\tpublic ModInteger divide(ModInteger n) {\n\t\t\treturn getNewInstance(this).divideEqual(n);\n\t\t}\n\n\t\tpublic ModInteger divideEqual(int n) {\n\t\t\tnum = (int)((long)num * inverse(validNum(n)) % mod);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger divideEqual(long n) {\n\t\t\treturn divideEqual((int)(n % mod));\n\t\t}\n\n\t\tpublic ModInteger divideEqual(ModInteger n) {\n\t\t\tnum = (int)((long)num * n.inverse(n.num) % mod);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger pow(int n) {\n\t\t\treturn getNewInstance(this).powEqual(n);\n\t\t}\n\n\t\tpublic ModInteger pow(long n) {\n\t\t\treturn getNewInstance(this).powEqual(n);\n\t\t}\n\n\t\tpublic ModInteger pow(ModInteger n) {\n\t\t\treturn getNewInstance(this).powEqual(n);\n\t\t}\n\n\t\tpublic ModInteger powEqual(int n) {\n\t\t\tlong ans = 1, num = this.num;\n\t\t\tif (n < 0) {\n\t\t\t\tn = -n;\n\t\t\t\twhile (n != 0) {\n\t\t\t\t\tif ((n & 1) != 0) ans = ans * num % mod;\n\t\t\t\t\tn >>>= 1;\n\t\t\tnum = num * num % mod;\n\t\t\t\t}\n\t\t\t\tthis.num = inverse((int)ans);\n\t\t\t\treturn this;\n\t\t\t}\n\t\t\twhile (n != 0) {\n\t\t\t\tif ((n & 1) != 0) ans = ans * num % mod;\n\t\t\t\tn >>>= 1;\n\t\t\t\t\tnum = num * num % mod;\n\t\t\t}\n\t\t\tthis.num = (int)ans;\n\t\t\treturn this;\n\t\t}\n\t\tpublic ModInteger powEqual(long n) {\n\t\t\treturn powEqual((int)(n % (mod - 1)));\n\t\t}\n\n\t\tpublic ModInteger powEqual(ModInteger n) {\n\t\t\tlong num = this.num;\n\t\t\tthis.num = 1;\n\t\t\tint mul = n.num;\n\t\t\twhile (mul != 0) {\n\t\t\t\tif ((mul & 1) != 0) this.num *= num;\n\t\t\t\tmul >>>= 1;\n\t\t\t\tnum *= num;\n\t\t\t\tnum %= mod;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger equal(int n) {\n\t\t\tnum = validNum(n);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger equal(long n) {\n\t\t\tnum = validNum(n);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ModInteger equal(ModInteger n) {\n\t\t\tnum = n.num;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic int toInt() {\n\t\t\treturn num;\n\t\t}\n\n\t\tpublic int getMod() {\n\t\t\treturn mod;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean equals(Object x) {\n\t\t\tif (x instanceof ModInteger) return ((ModInteger)x).num == num && ((ModInteger)x).mod == mod;\n\t\t\treturn false;\n\t\t}\n\n\t\t@Override\n\t\tpublic int hashCode() {\n\t\t\treturn num ^ mod;\n\t\t}\n\n\t\t@Override\n\t\tpublic String toString() {\n\t\t\treturn String.valueOf(num);\n\t\t}\n\n\t\t@Deprecated\n\t\tpublic String debug() {\n\t\t\tint min = num, ans = 1;\n\t\t\tfor (int i = 2;i < min;++ i) {\n\t\t\t\tint tmp = multiply(i).num;\n\t\t\t\tif (min > tmp) {\n\t\t\t\t\tmin = tmp;\n\t\t\t\t\tans = i;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn min + \"/\" + ans;\n\t\t}\n\n\t\t@Override\n\t\tpublic Addition getAddition() {\n\t\t\treturn add;\n\t\t}\n\n\t\t@Override\n\t\tpublic Multiplication getMultiplication() {\n\t\t\treturn mul;\n\t\t}\n\t}\n\n\t/**\n\t * 素数を法とする演算上で、組み合わせの計算を高速に行います。\n\t * @author 31536000\n\t *\n\t */\n\tpublic static class ModUtility {\n\t\tprivate final int mod;\n\t\tprivate int[] fact, inv, invfact;\n\n\t\t/**\n\t\t * modを法として、演算を行います。\n\t\t * @param mod 法とする素数\n\t\t */\n\t\tpublic ModUtility(Prime mod) {\n\t\t\tthis(mod, 2);\n\t\t}\n\n\t\t/**\n\t\t * modを法として、演算を行います。\n\t\t * @param mod 法とする素数\n\t\t * @param calc 予め前計算しておく大きさ\n\t\t */\n\t\tpublic ModUtility(Prime mod, int calc) {\n\t\t\tthis.mod = mod.prime;\n\t\t\tprecalc(calc);\n\t\t}\n\n\t\t/**\n\t\t * calcの大きさだけ、前計算を行います。\n\t\t * @param calc 前計算をする大きさ\n\t\t */\n\t\tpublic void precalc(int calc) {\n\t\t\t++ calc;\n\t\t\tif (calc < 2) calc = 2;\n\t\t\tfact = new int[calc];\n\t\t\tinv = new int[calc];\n\t\t\tinvfact = new int[calc];\n\t\t\tfact[0] = invfact[0] = fact[1] = invfact[1] = inv[1] = 1;\n\t\t\tfor (int i = 2;i < calc;++ i) {\n\t\t\t\tfact[i] = (int)((long)fact[i - 1] * i % mod);\n\t\t\t\tinv[i] = (int)(mod - (long)inv[mod % i] * (mod / i) % mod);\n\t\t\t\tinvfact[i] = (int)((long)invfact[i - 1] * inv[i] % mod);\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * modを法とする剰余環上で振舞う整数を返します。\n\t\t * @return modを法とする整数、初期値は0\n\t\t */\n\t\tpublic ModInteger create() {\n\t\t\treturn new ModInt();\n\t\t}\n\n\t\t/**\n\t\t * modを法とする剰余環上で振舞う整数を返します。\n\t\t * @param n 初期値\n\t\t * @return modを法とする整数\n\t\t */\n\t\tpublic ModInteger create(int n) {\n\t\t\treturn new ModInt(n);\n\t\t}\n\n\t\tprivate class ModInt extends ModInteger {\n\n\t\t\tprivate static final long serialVersionUID = -2435281861935422575L;\n\n\t\t\tpublic ModInt() {\n\t\t\t\tsuper(mod);\n\t\t\t}\n\n\t\t\tpublic ModInt(int n) {\n\t\t\t\tsuper(mod, n);\n\t\t\t}\n\n\t\t\tpublic ModInt(ModInteger mod) {\n\t\t\t\tsuper(mod);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tprotected ModInteger getNewInstance(ModInteger mod) {\n\t\t\t\treturn new ModInt(mod);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tprotected int inverse(int n) {\n\t\t\t\treturn ModUtility.this.inverse(n);\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * modを法として、nの逆元を返します。
\n\t\t * 計算量はO(log n)です。\n\t\t * @param n 逆元を求めたい値\n\t\t * @return 逆元\n\t\t */\n\t\tpublic int inverse(int n) {\n\t\t\ttry {\n\t\t\t\tif (inv.length > n) return inv[n];\n\t\t\t\t int m = mod, u = 0, v = 1, t;\n\t\t\t\t while(n != 0) {\n\t\t\t\t\t t = m / n;\n\t\t\t\t\t m -= t * n;\n\t\t\t\t\t u -= t * v;\n\t\t\t\t\t if (m != 0) {\n\t\t\t\t\t\t t = n / m;\n\t\t\t\t\t\t n -= t * m;\n\t\t\t\t\t\t v -= t * u;\n\t\t\t\t\t } else {\n\t\t\t\t\t\t v %= mod;\n\t\t\t\t\t\t if (v < 0) v += mod;\n\t\t\t\t\t\t return v;\n\t\t\t\t\t }\n\t\t\t\t }\n\t\t\t\t u %= mod;\n\t\t\t\t if (u < 0) u += mod;\n\t\t\t\t return u;\n\t\t\t} catch (ArrayIndexOutOfBoundsException e) {\n\t\t\t\tthrow new IllegalArgumentException();\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * n!を、modを法として求めた値を返します。
\n\t\t * 計算量はO(n)です。\n\t\t * @param n 階乗を求めたい値\n\t\t * @return nの階乗をmodで割った余り\n\t\t */\n\t\tpublic int factorial(int n) {\n\t\t\ttry {\n\t\t\t\tif (fact.length > n) return fact[n];\n\t\t\t\tlong ret = fact[fact.length - 1];\n\t\t\t\tfor (int i = fact.length;i <= n;++ i) ret = ret * i % mod;\n\t\t\t\treturn (int)ret;\n\t\t\t} catch (ArrayIndexOutOfBoundsException e) {\n\t\t\t\tthrow new IllegalArgumentException();\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * nPkをmodで割った余りを求めます。
\n\t\t * 計算量はO(n-k)です。\n\t\t * @param n 左辺\n\t\t * @param k 右辺\n\t\t * @return nPkをmodで割った余り\n\t\t */\n\t\tpublic int permutation(int n, int k) {\n\t\t\tif (n < 0) throw new IllegalArgumentException();\n\t\t\tif (n < k) return 0;\n\t\t\tif (fact.length > n) return (int)((long)fact[n] * invfact[n - k] % mod);\n\t\t\tlong ret = 1;\n\t\t\tfor (int i = n - k + 1;i <= n;++ i) ret = ret * i % mod;\n\t\t\treturn (int)ret;\n\t\t}\n\n\t\t/**\n\t\t * nCkをmodで割った余りを求めます。
\n\t\t * 計算量はO(n-k)です。\n\t\t * @param n 左辺\n\t\t * @param k 右辺\n\t\t * @return nCkをmodで割った余り\n\t\t */\n\t\tpublic int combination(int n, int k) {\n\t\t\tif (n < 0) throw new IllegalArgumentException();\n\t\t\tif (n < k) return 0;\n\t\t\tif (fact.length > n) return (int)((long)fact[n] * invfact[k] % mod * invfact[n - k] % mod);\n\t\t\tlong ret = 1;\n\t\t\tif (n < 2 * k) k = n - k;\n\t\t\tif (invfact.length > k) ret = invfact[k];\n\t\t\telse ret = inverse(factorial(k));\n\t\t\tfor (int i = n - k + 1;i <= n;++ i) ret = ret * i % mod;\n\t\t\treturn (int)ret;\n\t\t}\n\n\t\t/**\n\t\t * 他項係数をmodで割った余りを求めます。
]\n\t\t * 計算量はO(n)です。\n\t\t * @param n 左辺\n\t\t * @param k 右辺、合計がn以下である必要がある\n\t\t * @return 他項係数\n\t\t */\n\t\tpublic int multinomial(int n, int... k) {\n\t\t\tint sum = 0;\n\t\t\tfor (int i : k) sum += i;\n\t\t\tlong ret = factorial(n);\n\t\t\tif (fact.length > n) {\n\t\t\t\tfor (int i : k) {\n\t\t\t\t\tif (i < 0) throw new IllegalArgumentException();\n\t\t\t\t\tret = ret * invfact[i] % mod;\n\t\t\t\t\tsum += i;\n\t\t\t\t}\n\t\t\t\tif (sum > n) return 0;\n\t\t\t\tret = ret * invfact[n - sum] % mod;\n\t\t\t} else {\n\t\t\t\tfor (int i : k) {\n\t\t\t\t\tif (i < 0) throw new IllegalArgumentException();\n\t\t\t\t\tif (invfact.length > i) ret = ret * invfact[i] % mod;\n\t\t\t\t\telse ret = ret * inverse(factorial(i)) % mod;\n\t\t\t\t\tsum += i;\n\t\t\t\t}\n\t\t\t\tif (sum > n) return 0;\n\t\t\t\tif (invfact.length > n - sum) ret = ret * invfact[n - sum] % mod;\n\t\t\t\telse ret = ret * inverse(factorial(n - sum)) % mod;\n\t\t\t}\n\t\t\treturn (int)ret;\n\t\t}\n\n\t\t/**\n\t\t * n個からk個を選ぶ重複組み合わせnHkをmodで割った余りを求めます。
\n\t\t * 計算量はO(min(n, k))です。\n\t\t * @param n 左辺\n\t\t * @param k 右辺\n\t\t * @return nHkをmodで割った余り\n\t\t */\n\t\tpublic int multichoose(int n, int k) {\n\t\t\treturn combination(mod(n + k - 1), k);\n\t\t}\n\n\t\t/**\n\t\t * カタラン数C(n)をmodで割った余りを求めます。
\n\t\t * 計算量はO(n)です。\n\t\t * @param n 求めたいカタラン数の番号\n\t\t * @return カタラン数\n\t\t */\n\t\tpublic int catalan(int n) {\n\t\t\treturn divide(combination(mod(2 * n), n), mod(n + 1));\n\t\t}\n\n\t\t/**\n\t\t * nのm乗をmodで割った余りを求めます。
\n\t\t * 計算量はO(log m)です。\n\t\t * @param n 床\n\t\t * @param m 冪指数\n\t\t * @return n^mをmodで割った余り\n\t\t */\n\t\tpublic int pow(int n, int m) {\n\t\t\tlong ans = 1, num = n;\n\t\t\tif (m < 0) {\n\t\t\t\tm = -m;\n\t\t\t\twhile (m != 0) {\n\t\t\t\t\tif ((m & 1) != 0) ans = ans * num % mod;\n\t\t\t\t\tm >>>= 1;\n\t\t\t\t\tnum = num * num % mod;\n\t\t\t\t}\n\t\t\t\treturn inverse((int)ans);\n\t\t\t}\n\t\t\twhile (m != 0) {\n\t\t\t\tif ((m & 1) != 0) ans = ans * num % mod;\n\t\t\t\tm >>>= 1;\n\t\t\t\tnum = num * num % mod;\n\t\t\t}\n\t\t\treturn (int)ans;\n\t\t}\n\n\t\t/**\n\t\t * nのm乗をmodで割った余りを求めます。
\n\t\t * 計算量はO(log m)です。\n\t\t * @param n 床\n\t\t * @param m 冪指数\n\t\t * @return n^mをmodで割った余り\n\t\t */\n\t\tpublic int pow(long n, long m) {\n\t\t\treturn pow((int)(n % mod), (int)(n % (mod - 1)));\n\t\t}\n\n\t\t/**\n\t\t * 現在のmod値のトーシェント数を返します。
\n\t\t * なお、これはmod-1に等しいです。\n\t\t * @return トーシェント数\n\t\t */\n\t\tpublic int totient() {\n\t\t\treturn mod - 1;\n\t\t}\n\n\t\t/**\n\t\t * nのトーシェント数を返します。
\n\t\t * 計算量はO(sqrt n)です。\n\t\t * @param n トーシェント数を求めたい値\n\t\t * @return nのトーシェント数\n\t\t */\n\t\tpublic static int totient(int n) {\n\t\t\tint totient = n;\n\t\t\tfor (int i = 2;i * i <= n;++ i) {\n\t\t\t\tif (n % i == 0) {\n\t\t\t\t\ttotient = totient / i * (i - 1);\n\t\t\t\t\twhile ((n %= i) % i == 0);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (n != 1) totient = totient / n * (n - 1);\n\t\t\treturn totient;\n\t\t}\n\n\t\t/**\n\t\t * nをmodで割った余りを返します。\n\t\t * @param n 演算する値\n\t\t * @return nをmodで割った余り\n\t\t */\n\t\tpublic int mod(int n) {\n\t\t\treturn (n %= mod) < 0 ? n + mod : n;\n\t\t}\n\n\t\t/**\n\t\t * nをmodで割った余りを返します。\n\t\t * @param n 演算する値\n\t\t * @return nをmodで割った余り\n\t\t */\n\t\tpublic int mod(long n) {\n\t\t\treturn (int)((n %= mod) < 0 ? n + mod : n);\n\t\t}\n\n\t\t/**\n\t\t * n+mをmodで割った余りを返します。\n\t\t * @param n 足される値\n\t\t * @param m 足す値\n\t\t * @return n+mをmodで割った余り\n\t\t */\n\t\tpublic int add(int n, int m) {\n\t\t\treturn mod(n + m);\n\t\t}\n\n\t\t/**\n\t\t * n-mをmodで割った余りを返します。\n\t\t * @param n 引かれる値\n\t\t * @param m 引く値\n\t\t * @return n-mをmodで割った余り\n\t\t */\n\t\tpublic int subtract(int n, int m) {\n\t\t\treturn mod(n - m);\n\t\t}\n\n\t\t/**\n\t\t * n*mをmodで割った余りを返します。\n\t\t * @param n 掛けられる値\n\t\t * @param m 掛ける値\n\t\t * @return n*mをmodで割った余り\n\t\t */\n\t\tpublic int multiply(int n, int m) {\n\t\t\tint ans = (int)((long)n * m % mod);\n\t\t\treturn ans < 0 ? ans + mod : ans;\n\t\t}\n\n\t\t/**\n\t\t * n/mをmodで割った余りを返します。\n\t\t * @param n 割られる値\n\t\t * @param m 割る値\n\t\t * @return n/mをmodで割った余り\n\t\t */\n\t\tpublic int divide(int n, int m) {\n\t\t\treturn multiply(n, inverse(m));\n\t\t}\n\n\t\t/**\n\t\t * fを通ることが分かっているfの要素数-1次の関数について、xの位置における値をmodで割った余りを返します。
\n\t\t * 計算量はO(f)です。\n\t\t * @param f 関数の形\n\t\t * @param x 求める位置\n\t\t * @return 求めたい値をmodで割った余り\n\t\t */\n\t\tpublic ModInteger lagrangePolynomial(ModInteger[] f, int x) {\n\t\t\tif (f.length > x) return f[x];\n\t\t\tif (x > fact.length) precalc(x);\n\t\t\tModInteger ret = create(0);\n\t\t\tModInteger[] dp = new ModInteger[f.length], dp2 = new ModInteger[f.length];\n\t\t\tdp[0] = create(1);\n\t\t\tdp2[f.length - 1] = create(1);\n\t\t\tfor (int i = 1;i < f.length;++ i) {\n\t\t\t\tdp[i] = dp[i - 1].multiply(x - i - 1);\n\t\t\t\tdp2[f.length - i - 1] = dp2[f.length - i].multiply(x - f.length + i);\n\t\t\t}\n\t\t\tfor (int i = 0;i < f.length;++ i) {\n\t\t\t\tModInteger tmp = f[i].multiply(dp[i]).multiplyEqual(dp2[i]).multiplyEqual(inv[i]).multiplyEqual(inv[f.length - 1 - i]);\n\t\t\t\tif ((f.length - i & 1) == 0) ret.addEqual(tmp);\n\t\t\t\telse ret.subtractEqual(tmp);\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\t}\n\n\t/**\n\t * 素数を渡すためのクラスです。
\n\t * 中身が確実に素数であることを保証するときに使ってください。\n\t *\n\t * @author 31536000\n\t *\n\t */\n\tpublic static class Prime extends Number{\n\n\t\tprivate static final long serialVersionUID = 8216169308184181643L;\n\t\tpublic final int prime;\n\n\t\t/**\n\t\t * 素数を設定します。\n\t\t *\n\t\t * @param prime 素数\n\t\t * @throws IllegalArgumentException 素数以外を渡した時\n\t\t */\n\t\tpublic Prime(int prime) {\n\t\t\tif (!isPrime(prime)) throw new IllegalArgumentException(prime + \" is not prime\");\n\t\t\tthis.prime = prime;\n\t\t}\n\n\t\tprivate static final int bases[] = {15591, 2018, 166, 7429, 8064, 16045, 10503, 4399, 1949, 1295, 2776, 3620, 560, 3128, 5212, 2657, 2300, 2021, 4652, 1471, 9336, 4018, 2398, 20462, 10277, 8028, 2213, 6219, 620, 3763, 4852, 5012, 3185, 1333, 6227, 5298, 1074, 2391, 5113, 7061, 803, 1269, 3875, 422, 751, 580, 4729, 10239, 746, 2951, 556, 2206, 3778, 481, 1522, 3476, 481, 2487, 3266, 5633, 488, 3373, 6441, 3344, 17, 15105, 1490, 4154, 2036, 1882, 1813, 467, 3307, 14042, 6371, 658, 1005, 903, 737, 1887, 7447, 1888, 2848, 1784, 7559, 3400, 951, 13969, 4304, 177, 41, 19875, 3110, 13221, 8726, 571, 7043, 6943, 1199, 352, 6435, 165, 1169, 3315, 978, 233, 3003, 2562, 2994, 10587, 10030, 2377, 1902, 5354, 4447, 1555, 263, 27027, 2283, 305, 669, 1912, 601, 6186, 429, 1930, 14873, 1784, 1661, 524, 3577, 236, 2360, 6146, 2850, 55637, 1753, 4178, 8466, 222, 2579, 2743, 2031, 2226, 2276, 374, 2132, 813, 23788, 1610, 4422, 5159, 1725, 3597, 3366, 14336, 579, 165, 1375, 10018, 12616, 9816, 1371, 536, 1867, 10864, 857, 2206, 5788, 434, 8085, 17618, 727, 3639, 1595, 4944, 2129, 2029, 8195, 8344, 6232, 9183, 8126, 1870, 3296, 7455, 8947, 25017, 541, 19115, 368, 566, 5674, 411, 522, 1027, 8215, 2050, 6544, 10049, 614, 774, 2333, 3007, 35201, 4706, 1152, 1785, 1028, 1540, 3743, 493, 4474, 2521, 26845, 8354, 864, 18915, 5465, 2447, 42, 4511, 1660, 166, 1249, 6259, 2553, 304, 272, 7286, 73, 6554, 899, 2816, 5197, 13330, 7054, 2818, 3199, 811, 922, 350, 7514, 4452, 3449, 2663, 4708, 418, 1621, 1171, 3471, 88, 11345, 412, 1559, 194};\n\n\t\tprivate static boolean isSPRP(int n, int a) {\n\t\t\tint d = n - 1, s = 0;\n\t\t\twhile ((d & 1) == 0) {\n\t\t\t\t++s;\n\t\t\t\td >>= 1;\n\t\t\t}\n\t\t\tlong cur = 1, pw = d;\n\t\t\twhile (pw != 0) {\n\t\t\t\tif ((pw & 1) != 0) cur = (cur * a) % n;\n\t\t\t\ta = (int)(((long)a * a) % n);\n\t\t\t\tpw >>= 1;\n\t\t\t}\n\t\t\tif (cur == 1) return true;\n\t\t\tfor (int r = 0; r < s; r++ ) {\n\t\t\t\tif (cur == n - 1) return true;\n\t\t\t\tcur = (cur * cur) % n;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\t/**\n\t\t * 与えられた値が素数か否かを判定します。
\n\t\t * この実装はhttp://ceur-ws.org/Vol-1326/020-Forisek.pdfに基づきます。\n\t\t * @param x 判定したい値\n\t\t * @return xが素数ならtrue\n\t\t */\n\t\tpublic static boolean isPrime(int x) {\n\t\t\tif (x == 2 || x == 3 || x == 5 || x == 7) return true;\n\t\t\tif ((x & 1) == 0 || x % 3 == 0 || x % 5 == 0 || x % 7 == 0) return false;\n\t\t\tif (x < 121) return x > 1;\n\t\t\tlong h = x;\n\t\t\th = ((h >> 16) ^ h) * 0x45d9f3b;\n\t\t\th = ((h >> 16) ^ h) * 0x45d9f3b;\n\t\t\th = ((h >> 16) ^ h) & 0xFF;\n\t\t\treturn isSPRP(x, bases[(int)h]);\n\t\t}\n\n\t\t@Override\n\t\tpublic int intValue() {\n\t\t\treturn prime;\n\t\t}\n\n\t\t@Override\n\t\tpublic long longValue() {\n\t\t\treturn prime;\n\t\t}\n\n\t\t@Override\n\t\tpublic float floatValue() {\n\t\t\treturn prime;\n\t\t}\n\n\t\t@Override\n\t\tpublic double doubleValue() {\n\t\t\treturn prime;\n\t\t}\n\n\t\t@Override\n\t\tpublic String toString() {\n\t\t\treturn String.valueOf(prime);\n\t\t}\n\t}\n\n\tpublic static class AbstractArray extends AbstractList implements RandomAccess{\n\n\t\tprivate final Object[] array;\n\n\t\tpublic AbstractArray(int size) {\n\t\t\tarray = new Object[size];\n\t\t}\n\n\t\tpublic AbstractArray(T[] array) {\n\t\t\tthis(array.length);\n\t\t\tSystem.arraycopy(array, 0, this.array, 0, array.length);\n\t\t}\n\n\t\t@Override\n\t\tpublic T set(int index, T element) {\n\t\t\tT ret = get(index);\n\t\t\tarray[index] = element;\n\t\t\treturn ret;\n\t\t}\n\n\t\t@Override\n\t\tpublic T get(int index) {\n\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\tT ret = (T)array[index];\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic Object[] get() {\n\t\t\treturn array;\n\t\t}\n\n\t\tpublic T[] get(T[] array) {\n\t\t\tif (array.length < this.array.length) {\n\t\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\t\tT[] ret = (T[])Arrays.copyOfRange(this.array, 0, this.array.length, array.getClass());\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t\tSystem.arraycopy(this.array, 0, array, 0, this.array.length);\n\t\t\treturn array;\n\t\t}\n\n\t\t@Override\n\t\tpublic int size() {\n\t\t\treturn array.length;\n\t\t}\n\n\t\tpublic int length() {\n\t\t\treturn size();\n\t\t}\n\n\t\t@Override\n\t\tpublic int hashCode() {\n\t\t\treturn Arrays.hashCode(array);\n\t\t}\n\n\t\tprivate class Iter implements Iterator {\n\t\t\tprivate int index;\n\n\t\t\tprivate Iter() {\n\t\t\t\tindex = 0;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic boolean hasNext() {\n\t\t\t\treturn index < array.length;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic T next() {\n\t\t\t\treturn get(index++);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void remove() {\n\t\t\t\tthrow new UnsupportedOperationException();\n\t\t\t}\n\t\t}\n\n\t\t@Override\n\t\tpublic Iterator iterator() {\n\t\t\treturn new Iter();\n\t\t}\n\t}\n\n\tpublic static class Array extends AbstractArray implements Serializable{\n\n\t\tprivate static final long serialVersionUID = 2749604433067098063L;\n\n\t\tpublic Array(int size) {\n\t\t\tsuper(size);\n\t\t}\n\n\t\tpublic Array(T[] array) {\n\t\t\tsuper(array);\n\t\t}\n\n\t\tpublic T front() {\n\t\t\treturn get(0);\n\t\t}\n\n\t\tpublic T back() {\n\t\t\treturn get(size() - 1);\n\t\t}\n\t}\n\n\t/**\n\t * 要素とそのindexを効率的に取得する関数を提供します。\n\t * @author 31536000\n\t *\n\t */\n\tpublic static class Enumeration {\n\t\t/**\n\t\t * 要素とそのindexを管理するクラスです。\n\t\t * @author 31536000\n\t\t *\n\t\t * @param 保持する要素\n\t\t */\n\t\tpublic static class Enumerate {\n\t\t\tpublic final E value;\n\t\t\tpublic final int index;\n\n\t\t\t/**\n\t\t\t * 要素とそのindexを渡します。
\n\t\t\t * indexは必ずしも元の配列またはコレクションのindexと一致する必要はありませんが、一致する値を返すことが推奨されます。\n\t\t\t * @param value\n\t\t\t * @param index\n\t\t\t */\n\t\t\tpublic Enumerate(E value, int index) {\n\t\t\t\tthis.value = value;\n\t\t\t\tthis.index = index;\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * 要素を返します。\n\t\t\t * @return 要素\n\t\t\t */\n\t\t\tpublic E getValue() {\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * indexを返します。\n\t\t\t * @return index\n\t\t\t */\n\t\t\tpublic int getIndex() {\n\t\t\t\treturn index;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic boolean equals(Object o) {\n\t\t\t\tif (o instanceof Enumerate) return ((Enumerate)o).getValue().equals(value) && ((Enumerate)o).getIndex() == index;\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic int hashCode() {\n\t\t\t\treturn value.hashCode() ^ index;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic String toString() {\n\t\t\t\treturn \"{\" + value.toString() + \", \" + index + \"}\";\n\t\t\t}\n\t\t}\n\n\t\tprivate static class IteratorArray implements Iterator>{\n\t\t\tprivate final E[] array;\n\t\t\tprivate final int start;\n\t\t\tprivate int index;\n\n\t\t\tpublic IteratorArray(E[] array, int index) {\n\t\t\t\tthis.array = array;\n\t\t\t\tthis.start = index;\n\t\t\t\tthis.index = 0;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic boolean hasNext() {\n\t\t\t\treturn index < array.length;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic Enumerate next() {\n\t\t\t\tEnumerate ret = new Enumerate<>(array[index], index+++start);\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t}\n\n\t\tprivate static class IteratorCollection implements Iterator>{\n\t\t\tprivate final Iterator iter;\n\t\t\tprivate int start;\n\n\t\t\tpublic IteratorCollection(Iterator iter, int index) {\n\t\t\t\tthis.iter = iter;\n\t\t\t\tthis.start = index;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic boolean hasNext() {\n\t\t\t\treturn iter.hasNext();\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic Enumerate next() {\n\t\t\t\tEnumerate ret = new Enumerate<>(iter.next(), start++);\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * 配列の各要素とそのindexを順に返すIteratorを生成します。\n\t\t * @param 配列の型\n\t\t * @param array 配列\n\t\t * @return Enumerate<E>のIterator\n\t\t */\n\t\tpublic static Iterator> enumerate(E[] array) {\n\t\t\treturn enumerate(array, 0);\n\t\t}\n\n\t\t/**\n\t\t * 配列の各要素とそのindexを順に返すIteratorを生成します。\n\t\t * @param 配列の型\n\t\t * @param array 配列\n\t\t * @param start 添字の初期値、この値だけindexが足されたものが返る\n\t\t * @return Enumerate<E>のIterator\n\t\t */\n\t\tpublic static Iterator> enumerate(E[] array, int start) {\n\t\t\tif (array == null) throw new NullPointerException(\"array is null\");\n\t\t\treturn new IteratorArray(array, start);\n\t\t}\n\n\t\t/**\n\t\t * Iteratorの各要素とそのindexを順に返すIteratorを生成します。\n\t\t * @param Iteratorの型\n\t\t * @param iter Iterator\n\t\t * @return Enumerate<E>のIterator\n\t\t */\n\t\tpublic static Iterator> enumerate(Iterator iter) {\n\t\t\treturn enumerate(iter, 0);\n\t\t}\n\n\t\t/**\n\t\t * Iteratorの各要素とそのindexを順に返すIteratorを生成します。\n\t\t * @param Iteratorの型\n\t\t * @param iter Iterator\n\t\t * @param start 添字の初期値、この値だけindexが足されたものが返る\n\t\t * @return Enumerate<E>のIterator\n\t\t */\n\t\tpublic static Iterator> enumerate(Iterator iter, int start) {\n\t\t\tif (iter == null) throw new NullPointerException(\"iterator is null\");\n\t\t\treturn new IteratorCollection(iter, start);\n\t\t}\n\t}\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn a factory, there are N robots placed on a number line.\nRobot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.\n\nWe want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect.\nHere, for each i (1 \\leq i \\leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints.\n\nFind the maximum number of robots that we can keep.\n\nConstraints\n\n1 \\leq N \\leq 100,000\n\n0 \\leq X_i \\leq 10^9 (1 \\leq i \\leq N)\n\n1 \\leq L_i \\leq 10^9 (1 \\leq i \\leq N)\n\nIf i \\neq j, X_i \\neq X_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 L_1\nX_2 L_2\n\\vdots\nX_N L_N\n\nOutput\n\nPrint the maximum number of robots that we can keep.\n\nSample Input 1\n\n4\n2 4\n4 3\n9 3\n100 5\n\nSample Output 1\n\n3\n\nBy removing Robot 2, we can keep the other three robots.\n\nSample Input 2\n\n2\n8 20\n1 10\n\nSample Output 2\n\n1\n\nSample Input 3\n\n5\n10 1\n2 1\n4 1\n6 1\n8 1\n\nSample Output 3\n\n5", "sample_input": "4\n2 4\n4 3\n9 3\n100 5\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02796", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn a factory, there are N robots placed on a number line.\nRobot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.\n\nWe want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect.\nHere, for each i (1 \\leq i \\leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints.\n\nFind the maximum number of robots that we can keep.\n\nConstraints\n\n1 \\leq N \\leq 100,000\n\n0 \\leq X_i \\leq 10^9 (1 \\leq i \\leq N)\n\n1 \\leq L_i \\leq 10^9 (1 \\leq i \\leq N)\n\nIf i \\neq j, X_i \\neq X_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 L_1\nX_2 L_2\n\\vdots\nX_N L_N\n\nOutput\n\nPrint the maximum number of robots that we can keep.\n\nSample Input 1\n\n4\n2 4\n4 3\n9 3\n100 5\n\nSample Output 1\n\n3\n\nBy removing Robot 2, we can keep the other three robots.\n\nSample Input 2\n\n2\n8 20\n1 10\n\nSample Output 2\n\n1\n\nSample Input 3\n\n5\n10 1\n2 1\n4 1\n6 1\n8 1\n\nSample Output 3\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 86975, "cpu_time_ms": 763, "memory_kb": 72444}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s829960809", "group_id": "codeNet:p02796", "input_text": "import java.util.*;\nimport java.io.*;\nimport java.math.*;\n \npublic class Main {\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n ArrayList li = new ArrayList();\n //ArrayList> li = new ArrayList>();\n HashMap map = new HashMap();\n int ans = 0;\n for(int i = 0; i < n; i++){\n int x = sc.nextInt();\n int l = sc.nextInt();\n li.add(x);\n map.put(x,l);\n }\n Collections.sort(li);\n int i = 0;\n int left = 0;\n int right = 0;\n for(int v: li){\n if(i == 0){\n left = v-map.get(v);\n right = v+map.get(v);\n ans++;\n //System.out.println(left+\" \"+right);\n }else{\n int nl = v-map.get(v);\n int nr = v+map.get(v);\n //System.out.println(nl+\" \"+nr);\n if(nl-right >= 0){\n ans++;\n left = nl;\n right = nr;\n }else if(nl-right < 0 && nr-right >= 0){\n continue;\n }else if(nl-right < 0 && nr-right < 0){\n right = nr;\n }\n }\n i++;\n }\n System.out.println(ans);\n }\n}\n ", "language": "Java", "metadata": {"date": 1579379511, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02796.html", "problem_id": "p02796", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02796/input.txt", "sample_output_relpath": "derived/input_output/data/p02796/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02796/Java/s829960809.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s829960809", "user_id": "u072631296"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\nimport java.math.*;\n \npublic class Main {\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n ArrayList li = new ArrayList();\n //ArrayList> li = new ArrayList>();\n HashMap map = new HashMap();\n int ans = 0;\n for(int i = 0; i < n; i++){\n int x = sc.nextInt();\n int l = sc.nextInt();\n li.add(x);\n map.put(x,l);\n }\n Collections.sort(li);\n int i = 0;\n int left = 0;\n int right = 0;\n for(int v: li){\n if(i == 0){\n left = v-map.get(v);\n right = v+map.get(v);\n ans++;\n //System.out.println(left+\" \"+right);\n }else{\n int nl = v-map.get(v);\n int nr = v+map.get(v);\n //System.out.println(nl+\" \"+nr);\n if(nl-right >= 0){\n ans++;\n left = nl;\n right = nr;\n }else if(nl-right < 0 && nr-right >= 0){\n continue;\n }else if(nl-right < 0 && nr-right < 0){\n right = nr;\n }\n }\n i++;\n }\n System.out.println(ans);\n }\n}\n ", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn a factory, there are N robots placed on a number line.\nRobot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.\n\nWe want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect.\nHere, for each i (1 \\leq i \\leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints.\n\nFind the maximum number of robots that we can keep.\n\nConstraints\n\n1 \\leq N \\leq 100,000\n\n0 \\leq X_i \\leq 10^9 (1 \\leq i \\leq N)\n\n1 \\leq L_i \\leq 10^9 (1 \\leq i \\leq N)\n\nIf i \\neq j, X_i \\neq X_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 L_1\nX_2 L_2\n\\vdots\nX_N L_N\n\nOutput\n\nPrint the maximum number of robots that we can keep.\n\nSample Input 1\n\n4\n2 4\n4 3\n9 3\n100 5\n\nSample Output 1\n\n3\n\nBy removing Robot 2, we can keep the other three robots.\n\nSample Input 2\n\n2\n8 20\n1 10\n\nSample Output 2\n\n1\n\nSample Input 3\n\n5\n10 1\n2 1\n4 1\n6 1\n8 1\n\nSample Output 3\n\n5", "sample_input": "4\n2 4\n4 3\n9 3\n100 5\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02796", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn a factory, there are N robots placed on a number line.\nRobot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.\n\nWe want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect.\nHere, for each i (1 \\leq i \\leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints.\n\nFind the maximum number of robots that we can keep.\n\nConstraints\n\n1 \\leq N \\leq 100,000\n\n0 \\leq X_i \\leq 10^9 (1 \\leq i \\leq N)\n\n1 \\leq L_i \\leq 10^9 (1 \\leq i \\leq N)\n\nIf i \\neq j, X_i \\neq X_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 L_1\nX_2 L_2\n\\vdots\nX_N L_N\n\nOutput\n\nPrint the maximum number of robots that we can keep.\n\nSample Input 1\n\n4\n2 4\n4 3\n9 3\n100 5\n\nSample Output 1\n\n3\n\nBy removing Robot 2, we can keep the other three robots.\n\nSample Input 2\n\n2\n8 20\n1 10\n\nSample Output 2\n\n1\n\nSample Input 3\n\n5\n10 1\n2 1\n4 1\n6 1\n8 1\n\nSample Output 3\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1453, "cpu_time_ms": 779, "memory_kb": 101416}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s416028217", "group_id": "codeNet:p02797", "input_text": "import java.util.*;\nimport java.io.*;\n\nclass Main{\n public static void main(String[] args){\n FastScanner fsc=new FastScanner();\n int n=fsc.nextInt();\n int k=fsc.nextInt();\n long s=fsc.nextLong();\n fsc.close();\n long[] a=new long[n];\n if(s>=3){\n for(int i=0;i Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n public double nextDouble() { return Double.parseDouble(next());}\n public void close(){\n try{in.close();}\n catch(IOException e){e.printStackTrace();}\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1579379224, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02797.html", "problem_id": "p02797", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02797/input.txt", "sample_output_relpath": "derived/input_output/data/p02797/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02797/Java/s416028217.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s416028217", "user_id": "u541055501"}, "prompt_components": {"gold_output": "1 2 3 4\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\n\nclass Main{\n public static void main(String[] args){\n FastScanner fsc=new FastScanner();\n int n=fsc.nextInt();\n int k=fsc.nextInt();\n long s=fsc.nextLong();\n fsc.close();\n long[] a=new long[n];\n if(s>=3){\n for(int i=0;i Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n public double nextDouble() { return Double.parseDouble(next());}\n public void close(){\n try{in.close();}\n catch(IOException e){e.printStackTrace();}\n }\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are three integers N, K, and S.\n\nFind a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below.\nWe can prove that, under the conditions in Constraints, such a sequence always exists.\n\nThere are exactly K pairs (l, r) of integers such that 1 \\leq l \\leq r \\leq N and A_l + A_{l + 1} + \\cdots + A_r = S.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N\n\n1 \\leq S \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K S\n\nOutput\n\nPrint a sequence satisfying the condition, in the following format:\n\nA_1 A_2 ... A_N\n\nSample Input 1\n\n4 2 3\n\nSample Output 1\n\n1 2 3 4\n\nTwo pairs (l, r) = (1, 2) and (3, 3) satisfy the condition in the statement.\n\nSample Input 2\n\n5 3 100\n\nSample Output 2\n\n50 50 50 30 70", "sample_input": "4 2 3\n"}, "reference_outputs": ["1 2 3 4\n"], "source_document_id": "p02797", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are three integers N, K, and S.\n\nFind a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below.\nWe can prove that, under the conditions in Constraints, such a sequence always exists.\n\nThere are exactly K pairs (l, r) of integers such that 1 \\leq l \\leq r \\leq N and A_l + A_{l + 1} + \\cdots + A_r = S.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N\n\n1 \\leq S \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K S\n\nOutput\n\nPrint a sequence satisfying the condition, in the following format:\n\nA_1 A_2 ... A_N\n\nSample Input 1\n\n4 2 3\n\nSample Output 1\n\n1 2 3 4\n\nTwo pairs (l, r) = (1, 2) and (3, 3) satisfy the condition in the statement.\n\nSample Input 2\n\n5 3 100\n\nSample Output 2\n\n50 50 50 30 70", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3154, "cpu_time_ms": 461, "memory_kb": 46696}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s165552377", "group_id": "codeNet:p02799", "input_text": "import java.util.*;\nimport java.util.stream.Collectors;\nimport java.util.stream.IntStream;\n\nimport static java.util.stream.Collectors.toSet;\n\npublic class Main {\n public static final int MAX_WEIGHT = 1_000_000_000;\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int n = scanner.nextInt();\n int m = scanner.nextInt();\n int[] d = new int[n];\n HashMap[] graph = new HashMap[n];\n for (int i = 0; i < n; i++) {\n d[i] = scanner.nextInt();\n graph[i] = new HashMap<>();\n }\n\n int u,v;\n for (int i = 0; i < m; i++) {\n u = scanner.nextInt();\n v = scanner.nextInt();\n graph[u-1].put(v-1, i);\n graph[v-1].put(u-1, i);\n }\n Pair result = bichrome(graph, d, m);\n if(result!=null){\n Boolean[] colors = result.getFirst();\n for (int i = 0; i < n; i++) {\n System.out.print(colors[i]? \"B\" : \"W\");\n }\n System.out.println();\n for (int w : result.second) {\n System.out.println(w);\n }\n }else{\n System.out.println(-1);\n }\n }\n\n public static Pair bichrome(HashMap[] graph, int[] weights, int numM) {\n Boolean[] nodeColors = new Boolean[weights.length];\n Integer[] edgeWeights = new Integer[numM];\n\n TreeMap> treeMap = IntStream.range(0, weights.length).boxed()\n .collect(Collectors.groupingBy(i -> weights[i], TreeMap::new, toSet()));\n\n for (Map.Entry> setEntry : treeMap.entrySet()) {\n Set entryValue = setEntry.getValue();\n Integer minWeight = setEntry.getKey();\n for (Integer withMinWeightNode : entryValue) {\n if(nodeColors[withMinWeightNode]!=null) continue;\n for (Map.Entry entry : graph[withMinWeightNode].entrySet()) {\n if(nodeColors[entry.getKey()]!=null){\n nodeColors[withMinWeightNode] = !nodeColors[entry.getKey()];\n edgeWeights[entry.getValue()] = minWeight;\n break;\n }else if(entryValue.contains(entry.getKey())){\n //нужно покрасить два\n nodeColors[withMinWeightNode] = true;\n nodeColors[entry.getKey()] = false;\n edgeWeights[entry.getValue()] = minWeight;\n break;\n }\n }\n if(nodeColors[withMinWeightNode]==null){\n return null;\n }\n }\n }\n\n\n for (int i = 0; i < edgeWeights.length; i++) {\n if(edgeWeights[i]==null) edgeWeights[i] = MAX_WEIGHT;\n }\n return new Pair<>(nodeColors, edgeWeights);\n }\n\n public static class Pair {\n private A first;\n private B second;\n\n public Pair(A first, B second) {\n this.first = first;\n this.second = second;\n }\n\n @Override\n public boolean equals(Object o) {\n if (this == o) return true;\n if (o == null || getClass() != o.getClass()) return false;\n Pair pair = (Pair) o;\n return first.equals(pair.first) &&\n second.equals(pair.second);\n }\n\n @Override\n public int hashCode() {\n return Objects.hash(first, second);\n }\n\n public A getFirst() {\n return first;\n }\n\n public B getSecond() {\n return second;\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1582951817, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02799.html", "problem_id": "p02799", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02799/input.txt", "sample_output_relpath": "derived/input_output/data/p02799/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02799/Java/s165552377.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s165552377", "user_id": "u846370851"}, "prompt_components": {"gold_output": "BWWBB\n4\n3\n1\n5\n2\n", "input_to_evaluate": "import java.util.*;\nimport java.util.stream.Collectors;\nimport java.util.stream.IntStream;\n\nimport static java.util.stream.Collectors.toSet;\n\npublic class Main {\n public static final int MAX_WEIGHT = 1_000_000_000;\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int n = scanner.nextInt();\n int m = scanner.nextInt();\n int[] d = new int[n];\n HashMap[] graph = new HashMap[n];\n for (int i = 0; i < n; i++) {\n d[i] = scanner.nextInt();\n graph[i] = new HashMap<>();\n }\n\n int u,v;\n for (int i = 0; i < m; i++) {\n u = scanner.nextInt();\n v = scanner.nextInt();\n graph[u-1].put(v-1, i);\n graph[v-1].put(u-1, i);\n }\n Pair result = bichrome(graph, d, m);\n if(result!=null){\n Boolean[] colors = result.getFirst();\n for (int i = 0; i < n; i++) {\n System.out.print(colors[i]? \"B\" : \"W\");\n }\n System.out.println();\n for (int w : result.second) {\n System.out.println(w);\n }\n }else{\n System.out.println(-1);\n }\n }\n\n public static Pair bichrome(HashMap[] graph, int[] weights, int numM) {\n Boolean[] nodeColors = new Boolean[weights.length];\n Integer[] edgeWeights = new Integer[numM];\n\n TreeMap> treeMap = IntStream.range(0, weights.length).boxed()\n .collect(Collectors.groupingBy(i -> weights[i], TreeMap::new, toSet()));\n\n for (Map.Entry> setEntry : treeMap.entrySet()) {\n Set entryValue = setEntry.getValue();\n Integer minWeight = setEntry.getKey();\n for (Integer withMinWeightNode : entryValue) {\n if(nodeColors[withMinWeightNode]!=null) continue;\n for (Map.Entry entry : graph[withMinWeightNode].entrySet()) {\n if(nodeColors[entry.getKey()]!=null){\n nodeColors[withMinWeightNode] = !nodeColors[entry.getKey()];\n edgeWeights[entry.getValue()] = minWeight;\n break;\n }else if(entryValue.contains(entry.getKey())){\n //нужно покрасить два\n nodeColors[withMinWeightNode] = true;\n nodeColors[entry.getKey()] = false;\n edgeWeights[entry.getValue()] = minWeight;\n break;\n }\n }\n if(nodeColors[withMinWeightNode]==null){\n return null;\n }\n }\n }\n\n\n for (int i = 0; i < edgeWeights.length; i++) {\n if(edgeWeights[i]==null) edgeWeights[i] = MAX_WEIGHT;\n }\n return new Pair<>(nodeColors, edgeWeights);\n }\n\n public static class Pair {\n private A first;\n private B second;\n\n public Pair(A first, B second) {\n this.first = first;\n this.second = second;\n }\n\n @Override\n public boolean equals(Object o) {\n if (this == o) return true;\n if (o == null || getClass() != o.getClass()) return false;\n Pair pair = (Pair) o;\n return first.equals(pair.first) &&\n second.equals(pair.second);\n }\n\n @Override\n public int hashCode() {\n return Objects.hash(first, second);\n }\n\n public A getFirst() {\n return first;\n }\n\n public B getSecond() {\n return second;\n }\n }\n}\n", "problem_context": "Score : 900 points\n\nProblem Statement\n\nWe have a connected undirected graph with N vertices and M edges.\nEdge i in this graph (1 \\leq i \\leq M) connects Vertex U_i and Vertex V_i bidirectionally.\nWe are additionally given N integers D_1, D_2, ..., D_N.\n\nDetermine whether the conditions below can be satisfied by assigning a color - white or black - to each vertex and an integer weight between 1 and 10^9 (inclusive) to each edge in this graph.\nIf the answer is yes, find one such assignment of colors and integers, too.\n\nThere is at least one vertex assigned white and at least one vertex assigned black.\n\nFor each vertex v (1 \\leq v \\leq N), the following holds.\n\nThe minimum cost to travel from Vertex v to a vertex whose color assigned is different from that of Vertex v by traversing the edges is equal to D_v.\n\nHere, the cost of traversing the edges is the sum of the weights of the edges traversed.\n\nConstraints\n\n2 \\leq N \\leq 100,000\n\n1 \\leq M \\leq 200,000\n\n1 \\leq D_i \\leq 10^9\n\n1 \\leq U_i, V_i \\leq N\n\nThe given graph is connected and has no self-loops or multiple edges.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nD_1 D_2 ... D_N\nU_1 V_1\nU_2 V_2\n\\vdots\nU_M V_M\n\nOutput\n\nIf there is no assignment satisfying the conditions, print a single line containing -1.\n\nIf such an assignment exists, print one such assignment in the following format:\n\nS\nC_1\nC_2\n\\vdots\nC_M\n\nHere,\n\nthe first line should contain the string S of length N. Its i-th character (1 \\leq i \\leq N) should be W if Vertex i is assigned white and B if it is assigned black.\n\nThe (i + 1)-th line (1 \\leq i \\leq M) should contain the integer weight C_i assigned to Edge i.\n\nSample Input 1\n\n5 5\n3 4 3 5 7\n1 2\n1 3\n3 2\n4 2\n4 5\n\nSample Output 1\n\nBWWBB\n4\n3\n1\n5\n2\n\nAssume that we assign the colors and integers as the sample output, and let us consider Vertex 5, for example. To travel from Vertex 5, which is assigned black, to a vertex that is assigned white with the minimum cost, we should make these moves: Vertex 5 \\to Vertex 4 \\to Vertex 2. The total cost of these moves is 7, which satisfies the condition. We can also verify that the condition is satisfied for other vertices.\n\nSample Input 2\n\n5 7\n1 2 3 4 5\n1 2\n1 3\n1 4\n2 3\n2 5\n3 5\n4 5\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n4 6\n1 1 1 1\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n\nSample Output 3\n\nBBBW\n1\n1\n1\n2\n1\n1", "sample_input": "5 5\n3 4 3 5 7\n1 2\n1 3\n3 2\n4 2\n4 5\n"}, "reference_outputs": ["BWWBB\n4\n3\n1\n5\n2\n"], "source_document_id": "p02799", "source_text": "Score : 900 points\n\nProblem Statement\n\nWe have a connected undirected graph with N vertices and M edges.\nEdge i in this graph (1 \\leq i \\leq M) connects Vertex U_i and Vertex V_i bidirectionally.\nWe are additionally given N integers D_1, D_2, ..., D_N.\n\nDetermine whether the conditions below can be satisfied by assigning a color - white or black - to each vertex and an integer weight between 1 and 10^9 (inclusive) to each edge in this graph.\nIf the answer is yes, find one such assignment of colors and integers, too.\n\nThere is at least one vertex assigned white and at least one vertex assigned black.\n\nFor each vertex v (1 \\leq v \\leq N), the following holds.\n\nThe minimum cost to travel from Vertex v to a vertex whose color assigned is different from that of Vertex v by traversing the edges is equal to D_v.\n\nHere, the cost of traversing the edges is the sum of the weights of the edges traversed.\n\nConstraints\n\n2 \\leq N \\leq 100,000\n\n1 \\leq M \\leq 200,000\n\n1 \\leq D_i \\leq 10^9\n\n1 \\leq U_i, V_i \\leq N\n\nThe given graph is connected and has no self-loops or multiple edges.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nD_1 D_2 ... D_N\nU_1 V_1\nU_2 V_2\n\\vdots\nU_M V_M\n\nOutput\n\nIf there is no assignment satisfying the conditions, print a single line containing -1.\n\nIf such an assignment exists, print one such assignment in the following format:\n\nS\nC_1\nC_2\n\\vdots\nC_M\n\nHere,\n\nthe first line should contain the string S of length N. Its i-th character (1 \\leq i \\leq N) should be W if Vertex i is assigned white and B if it is assigned black.\n\nThe (i + 1)-th line (1 \\leq i \\leq M) should contain the integer weight C_i assigned to Edge i.\n\nSample Input 1\n\n5 5\n3 4 3 5 7\n1 2\n1 3\n3 2\n4 2\n4 5\n\nSample Output 1\n\nBWWBB\n4\n3\n1\n5\n2\n\nAssume that we assign the colors and integers as the sample output, and let us consider Vertex 5, for example. To travel from Vertex 5, which is assigned black, to a vertex that is assigned white with the minimum cost, we should make these moves: Vertex 5 \\to Vertex 4 \\to Vertex 2. The total cost of these moves is 7, which satisfies the condition. We can also verify that the condition is satisfied for other vertices.\n\nSample Input 2\n\n5 7\n1 2 3 4 5\n1 2\n1 3\n1 4\n2 3\n2 5\n3 5\n4 5\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n4 6\n1 1 1 1\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n\nSample Output 3\n\nBBBW\n1\n1\n1\n2\n1\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3814, "cpu_time_ms": 2110, "memory_kb": 197216}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s122880905", "group_id": "codeNet:p02801", "input_text": "/*Author: Satyajeet Singh, Delhi Technological University*/\n import java.io.*;\n import java.util.*;\n import java.text.*; \n import java.lang.*;\n import java.math.*;\npublic class Main{\n/*********************************************Constants******************************************/\n static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out)); \n static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n static long mod=(long)1e9+7;\n static long mod1=998244353;\n static boolean sieve[];\n static ArrayList primes;\n static long factorial[],invFactorial[];\n static ArrayList graph[];\n static int pptr=0;\n static String st[];\n/****************************************Solutions Begins***************************************/\n public static void main(String args[]) throws Exception{\n nl();\n char ch=ps().charAt(0);\n ch++;\n out.println(ch);\n/****************************************Solutions Ends**************************************************/\n out.flush();\n out.close();\n }\n/****************************************Template Begins************************************************/\n static void nl() throws Exception{\n pptr=0;\n st=br.readLine().split(\" \");\n }\n static void nls() throws Exception{\n pptr=0;\n st=br.readLine().split(\"\");\n }\n static int pi(){\n return Integer.parseInt(st[pptr++]);\n }\n static long pl(){\n return Long.parseLong(st[pptr++]);\n }\n static double pd(){\n return Double.parseDouble(st[pptr++]);\n }\n static String ps(){\n return st[pptr++];\n }\n/***************************************Precision Printing**********************************************/\n static void printPrecision(double d){\n DecimalFormat ft = new DecimalFormat(\"0.00000000000000\"); \n out.print(ft.format(d));\n }\n/**************************************Bit Manipulation**************************************************/\n static void printMask(long mask){\n System.out.println(Long.toBinaryString(mask));\n }\n static int countBit(long mask){\n int ans=0;\n while(mask!=0){\n mask&=(mask-1);\n ans++;\n }\n return ans;\n }\n/******************************************Graph*********************************************************/\n static void Makegraph(int n){\n graph=new ArrayList[n];\n for(int i=0;i();\n }\n }\n static void addEdge(int a,int b){\n graph[a].add(b);\n }\n // static void addEdge(int a,int b,int c){\n // graph[a].add(new Pair(b,c));\n // } \n/*********************************************PAIR********************************************************/\n static class Pair implements Comparable {\n int u;\n int v;\n int index=-1;\n public Pair(int u, int v) {\n this.u = u;\n this.v = v;\n }\n public int hashCode() {\n int hu = (int) (u ^ (u >>> 32));\n int hv = (int) (v ^ (v >>> 32));\n return 31 * hu + hv;\n }\n public boolean equals(Object o) {\n Pair other = (Pair) o;\n return u == other.u && v == other.v;\n }\n public int compareTo(Pair other) {\n if(index!=other.index)\n return Long.compare(index, other.index);\n return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);\n }\n public String toString() {\n return \"[u=\" + u + \", v=\" + v + \"]\";\n }\n }\n/******************************************Long Pair*******************************************************/\n static class Pairl implements Comparable {\n long u;\n long v;\n int index=-1;\n public Pairl(long u, long v) {\n this.u = u;\n this.v = v;\n }\n public int hashCode() {\n int hu = (int) (u ^ (u >>> 32));\n int hv = (int) (v ^ (v >>> 32));\n return 31 * hu + hv;\n }\n public boolean equals(Object o) {\n Pairl other = (Pairl) o;\n return u == other.u && v == other.v;\n }\n public int compareTo(Pairl other) {\n if(index!=other.index)\n return Long.compare(index, other.index);\n return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);\n }\n public String toString() {\n return \"[u=\" + u + \", v=\" + v + \"]\";\n }\n }\n/*****************************************DEBUG***********************************************************/\n public static void debug(Object... o){\n System.out.println(Arrays.deepToString(o));\n }\n/************************************MODULAR EXPONENTIATION***********************************************/\n static long modulo(long a,long b,long c){\n long x=1;\n long y=a%c;\n while(b > 0){\n if(b%2 == 1){\n x=(x*y)%c;\n }\n y = (y*y)%c; // squaring the base\n b /= 2;\n }\n return x%c;\n }\n/********************************************GCD**********************************************************/\n static long gcd(long x, long y){\n if(x==0)\n return y;\n if(y==0)\n return x;\n long r=0, a, b;\n a = (x > y) ? x : y; // a is greater number\n b = (x < y) ? x : y; // b is smaller number\n r = b;\n while(a % b != 0){\n r = a % b;\n a = b;\n b = r;\n }\n return r;\n }\n/******************************************SIEVE**********************************************************/\n static void sieveMake(int n){\n sieve=new boolean[n];\n Arrays.fill(sieve,true);\n sieve[0]=false;\n sieve[1]=false;\n for(int i=2;i*i();\n for(int i=0;i primes;\n static long factorial[],invFactorial[];\n static ArrayList graph[];\n static int pptr=0;\n static String st[];\n/****************************************Solutions Begins***************************************/\n public static void main(String args[]) throws Exception{\n nl();\n char ch=ps().charAt(0);\n ch++;\n out.println(ch);\n/****************************************Solutions Ends**************************************************/\n out.flush();\n out.close();\n }\n/****************************************Template Begins************************************************/\n static void nl() throws Exception{\n pptr=0;\n st=br.readLine().split(\" \");\n }\n static void nls() throws Exception{\n pptr=0;\n st=br.readLine().split(\"\");\n }\n static int pi(){\n return Integer.parseInt(st[pptr++]);\n }\n static long pl(){\n return Long.parseLong(st[pptr++]);\n }\n static double pd(){\n return Double.parseDouble(st[pptr++]);\n }\n static String ps(){\n return st[pptr++];\n }\n/***************************************Precision Printing**********************************************/\n static void printPrecision(double d){\n DecimalFormat ft = new DecimalFormat(\"0.00000000000000\"); \n out.print(ft.format(d));\n }\n/**************************************Bit Manipulation**************************************************/\n static void printMask(long mask){\n System.out.println(Long.toBinaryString(mask));\n }\n static int countBit(long mask){\n int ans=0;\n while(mask!=0){\n mask&=(mask-1);\n ans++;\n }\n return ans;\n }\n/******************************************Graph*********************************************************/\n static void Makegraph(int n){\n graph=new ArrayList[n];\n for(int i=0;i();\n }\n }\n static void addEdge(int a,int b){\n graph[a].add(b);\n }\n // static void addEdge(int a,int b,int c){\n // graph[a].add(new Pair(b,c));\n // } \n/*********************************************PAIR********************************************************/\n static class Pair implements Comparable {\n int u;\n int v;\n int index=-1;\n public Pair(int u, int v) {\n this.u = u;\n this.v = v;\n }\n public int hashCode() {\n int hu = (int) (u ^ (u >>> 32));\n int hv = (int) (v ^ (v >>> 32));\n return 31 * hu + hv;\n }\n public boolean equals(Object o) {\n Pair other = (Pair) o;\n return u == other.u && v == other.v;\n }\n public int compareTo(Pair other) {\n if(index!=other.index)\n return Long.compare(index, other.index);\n return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);\n }\n public String toString() {\n return \"[u=\" + u + \", v=\" + v + \"]\";\n }\n }\n/******************************************Long Pair*******************************************************/\n static class Pairl implements Comparable {\n long u;\n long v;\n int index=-1;\n public Pairl(long u, long v) {\n this.u = u;\n this.v = v;\n }\n public int hashCode() {\n int hu = (int) (u ^ (u >>> 32));\n int hv = (int) (v ^ (v >>> 32));\n return 31 * hu + hv;\n }\n public boolean equals(Object o) {\n Pairl other = (Pairl) o;\n return u == other.u && v == other.v;\n }\n public int compareTo(Pairl other) {\n if(index!=other.index)\n return Long.compare(index, other.index);\n return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);\n }\n public String toString() {\n return \"[u=\" + u + \", v=\" + v + \"]\";\n }\n }\n/*****************************************DEBUG***********************************************************/\n public static void debug(Object... o){\n System.out.println(Arrays.deepToString(o));\n }\n/************************************MODULAR EXPONENTIATION***********************************************/\n static long modulo(long a,long b,long c){\n long x=1;\n long y=a%c;\n while(b > 0){\n if(b%2 == 1){\n x=(x*y)%c;\n }\n y = (y*y)%c; // squaring the base\n b /= 2;\n }\n return x%c;\n }\n/********************************************GCD**********************************************************/\n static long gcd(long x, long y){\n if(x==0)\n return y;\n if(y==0)\n return x;\n long r=0, a, b;\n a = (x > y) ? x : y; // a is greater number\n b = (x < y) ? x : y; // b is smaller number\n r = b;\n while(a % b != 0){\n r = a % b;\n a = b;\n b = r;\n }\n return r;\n }\n/******************************************SIEVE**********************************************************/\n static void sieveMake(int n){\n sieve=new boolean[n];\n Arrays.fill(sieve,true);\n sieve[0]=false;\n sieve[1]=false;\n for(int i=2;i*i();\n for(int i=0;i deque = new ArrayDeque();\n int qcount = scanner.nextInt();\n int submitCount = scanner.nextInt();\n for (int i = 1 ; i <= submitCount ; i++) {\n scanner.nextLine();\n deque.push(scanner.next());\n deque.push(scanner.next());\n }\n \n int ac = 0;\n int wa = 0;\n int waMemo = 0;\n String qnum = \"\";\n String result = \"\";\n Map submitted = new HashMap();\n \n while (deque.peek() != null) {\n qnum = deque.pollLast();\n result = deque.pollLast();\n // 正解済みなら何もしない。\n if (submitted.containsKey(qnum) && submitted.get(qnum).equals(\"AC\")) {\n continue;\n }\n // 正解してなくてWAなら誤答数のメモを1増やす。\n if (result.equals(\"WA\")) {\n if (submitted.containsKey(qnum)) {\n waMemo = Integer.valueOf(submitted.get(qnum));\n } else {\n waMemo = 0;\n }\n waMemo++;\n submitted.put(qnum, String.valueOf(waMemo));\n continue;\n }\n // 正解した時に正答数を1増やす、正解した問題を記録する。\n if (result.equals(\"AC\")) {\n ac++;\n if (submitted.containsKey(qnum)) {\n wa = wa + Integer.valueOf(submitted.get(qnum));\n }\n submitted.put(qnum, result);\n waMemo = 0;\n continue;\n }\n \n }\n StringBuilder sb = new StringBuilder();\n sb.append(ac).append(\" \").append(wa);\n System.out.println(sb.toString());\n }\n}", "language": "Java", "metadata": {"date": 1580598241, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02802.html", "problem_id": "p02802", "resource_group": "high_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/Java/s078673970.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s078673970", "user_id": "u950333884"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "\nimport java.util.ArrayDeque;\nimport java.util.Deque;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.Scanner;\n\n/**\n * @author yoshizaki\n *151\n */\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner= new Scanner(System.in);\n Deque deque = new ArrayDeque();\n int qcount = scanner.nextInt();\n int submitCount = scanner.nextInt();\n for (int i = 1 ; i <= submitCount ; i++) {\n scanner.nextLine();\n deque.push(scanner.next());\n deque.push(scanner.next());\n }\n \n int ac = 0;\n int wa = 0;\n int waMemo = 0;\n String qnum = \"\";\n String result = \"\";\n Map submitted = new HashMap();\n \n while (deque.peek() != null) {\n qnum = deque.pollLast();\n result = deque.pollLast();\n // 正解済みなら何もしない。\n if (submitted.containsKey(qnum) && submitted.get(qnum).equals(\"AC\")) {\n continue;\n }\n // 正解してなくてWAなら誤答数のメモを1増やす。\n if (result.equals(\"WA\")) {\n if (submitted.containsKey(qnum)) {\n waMemo = Integer.valueOf(submitted.get(qnum));\n } else {\n waMemo = 0;\n }\n waMemo++;\n submitted.put(qnum, String.valueOf(waMemo));\n continue;\n }\n // 正解した時に正答数を1増やす、正解した問題を記録する。\n if (result.equals(\"AC\")) {\n ac++;\n if (submitted.containsKey(qnum)) {\n wa = wa + Integer.valueOf(submitted.get(qnum));\n }\n submitted.put(qnum, result);\n waMemo = 0;\n continue;\n }\n \n }\n StringBuilder sb = new StringBuilder();\n sb.append(ac).append(\" \").append(wa);\n System.out.println(sb.toString());\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "sample_input": "2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n"}, "reference_outputs": ["2 2\n"], "source_document_id": "p02802", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2101, "cpu_time_ms": 718, "memory_kb": 155860}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s124691839", "group_id": "codeNet:p02802", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.Map;\nimport java.util.Set;\nimport java.util.StringTokenizer;\n\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n Task solver = new Task();\n solver.solve(in, out);\n out.close();\n }\n\n static class Task {\n\n void solve(InputReader in, PrintWriter out) {\n Set correctSet = new HashSet<>();\n Map penaltyMap = new HashMap<>();\n \n int N = in.nextInt();\n int M = in.nextInt();\n \n for (int i = 0; i < M; ++i) {\n int num = in.nextInt();\n String result = in.next();\n \n if (\"AC\".equals(result)) {\n correctSet.add(num);\n } else if (!correctSet.contains(num)) {\n int val = penaltyMap.containsKey(num) ? penaltyMap.get(num) : 0;\n penaltyMap.put(num, val + 1);\n }\n }\n \n int correct = correctSet.size();\n int penalty = 0;\n \n for (int num : correctSet) {\n penalty += penaltyMap.containsKey(num) ? penaltyMap.get(num) : 0;\n }\n \n String ans = correct + \" \" + penalty;\n out.println(ans);\n }\n }\n\n static class InputReader {\n BufferedReader reader;\n StringTokenizer tokenizer;\n\n InputReader(InputStream stream) {\n reader = new BufferedReader(new InputStreamReader(stream));\n tokenizer = null;\n }\n\n String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n int[] nextIntArray(int size) {\n int[] arr = new int[size];\n for (int i = 0; i < size; i++) {\n arr[i] = nextInt();\n }\n return arr;\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n long[] nextLongArray(int size) {\n long[] arr = new long[size];\n for (int i = 0; i < size; i++) {\n arr[i] = nextLong();\n }\n return arr;\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1580073933, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02802.html", "problem_id": "p02802", "resource_group": "high_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/Java/s124691839.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s124691839", "user_id": "u762955009"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.Map;\nimport java.util.Set;\nimport java.util.StringTokenizer;\n\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n Task solver = new Task();\n solver.solve(in, out);\n out.close();\n }\n\n static class Task {\n\n void solve(InputReader in, PrintWriter out) {\n Set correctSet = new HashSet<>();\n Map penaltyMap = new HashMap<>();\n \n int N = in.nextInt();\n int M = in.nextInt();\n \n for (int i = 0; i < M; ++i) {\n int num = in.nextInt();\n String result = in.next();\n \n if (\"AC\".equals(result)) {\n correctSet.add(num);\n } else if (!correctSet.contains(num)) {\n int val = penaltyMap.containsKey(num) ? penaltyMap.get(num) : 0;\n penaltyMap.put(num, val + 1);\n }\n }\n \n int correct = correctSet.size();\n int penalty = 0;\n \n for (int num : correctSet) {\n penalty += penaltyMap.containsKey(num) ? penaltyMap.get(num) : 0;\n }\n \n String ans = correct + \" \" + penalty;\n out.println(ans);\n }\n }\n\n static class InputReader {\n BufferedReader reader;\n StringTokenizer tokenizer;\n\n InputReader(InputStream stream) {\n reader = new BufferedReader(new InputStreamReader(stream));\n tokenizer = null;\n }\n\n String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n int[] nextIntArray(int size) {\n int[] arr = new int[size];\n for (int i = 0; i < size; i++) {\n arr[i] = nextInt();\n }\n return arr;\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n long[] nextLongArray(int size) {\n long[] arr = new long[size];\n for (int i = 0; i < size; i++) {\n arr[i] = nextLong();\n }\n return arr;\n }\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "sample_input": "2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n"}, "reference_outputs": ["2 2\n"], "source_document_id": "p02802", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2967, "cpu_time_ms": 266, "memory_kb": 44144}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s430333544", "group_id": "codeNet:p02802", "input_text": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.util.InputMismatchException;\nimport java.util.Iterator;\nimport java.util.NoSuchElementException;\n\npublic class Main {\n static void solve(MyScanner in, MyWriter out) {\n int n = in.nextInt();\n int m = in.nextInt();\n int[] p = new int[m];\n String[] s = new String[m];\n for (int i = 0; i < m; i++) {\n p[i] = in.nextInt() - 1;\n s[i] = in.next();\n }\n boolean[] ac = new boolean[n];\n int[] a = new int[n];\n for (int i = 0; i < m; i++) {\n if (s[i].equals(\"AC\")) {\n ac[p[i]] = true;\n } else if (!ac[p[i]]) {\n a[p[i]]++;\n }\n }\n int acCount = 0;\n int b = 0;\n for (int i = 0; i < n; i++) {\n if (ac[i]) {\n acCount++;\n b += a[i];\n }\n }\n out.println(acCount + \" \" + b);\n }\n\n public static void main(String[] args) {\n MyWriter w = new MyWriter(System.out);\n solve(new MyScanner(System.in), w);\n w.flush();\n }\n\n static final class MyScanner {\n static final int BUFFER_SIZE = 8192;\n private final InputStream in;\n private final byte[] buffer = new byte[BUFFER_SIZE];\n private int point;\n private int readLength;\n MyScanner(InputStream in) {\n this.in = in;\n }\n private byte readByte() {\n if (point < readLength) {\n byte result = buffer[point];\n point += 1;\n return result;\n }\n try {\n readLength = in.read(buffer);\n } catch (IOException e) {\n throw new AssertionError(null, e);\n }\n if (readLength == -1) {\n return -1;\n }\n point = 1;\n return buffer[0];\n }\n private static boolean isPrintableCharExceptSpace(byte c) {\n return 33 <= c && c <= 126;\n }\n public char nextChar() {\n byte c = readByte();\n while (!(c == -1 || isPrintableCharExceptSpace(c))) {\n c = readByte();\n }\n if (c == -1) {\n throw new NoSuchElementException();\n }\n return (char)c;\n }\n public String next() {\n return next(16);\n }\n public String next(int n) {\n byte c = readByte();\n while (!(c == -1 || isPrintableCharExceptSpace(c))) {\n c = readByte();\n }\n if (c == -1) {\n throw new NoSuchElementException();\n }\n StringBuilder b = new StringBuilder(n);\n do {\n b.append((char)c);\n c = readByte();\n } while (c != -1 && isPrintableCharExceptSpace(c));\n return b.toString();\n }\n public long nextLong() {\n byte c = readByte();\n while (!(c == -1 || isPrintableCharExceptSpace(c))) {\n c = readByte();\n }\n if (c == -1) {\n throw new NoSuchElementException();\n }\n boolean minus = false;\n if (c == '-') {\n minus = true;\n c = readByte();\n }\n long result = 0L;\n do {\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n result = result * 10L + (c - '0');\n c = readByte();\n } while (c != -1 && isPrintableCharExceptSpace(c));\n return minus ? -result : result;\n }\n public int nextInt() {\n long n = nextLong();\n if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE) {\n throw new InputMismatchException();\n }\n return (int)n;\n }\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n public int[] nextIntArray(int n) {\n int[] result = new int[n];\n for (int i = 0; i < n; i++) {\n result[i] = nextInt();\n }\n return result;\n }\n public long[] nextLongArray(int n) {\n long[] result = new long[n];\n for (int i = 0; i < n; i++) {\n result[i] = nextLong();\n }\n return result;\n }\n public char[] nextCharArray(int n) {\n char[] result = new char[n];\n for (int i = 0; i < n; i++) {\n result[i] = nextChar();\n }\n return result;\n }\n public char[][] next2dCharArray(int n, int m) {\n char[][] result = new char[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n result[i][j] = nextChar();\n }\n }\n return result;\n }\n public int[][] nextVerticalIntArrays(int arrayCount, int arrayLength) {\n int[][] result = new int[arrayCount][arrayLength];\n for (int i = 0; i < arrayLength; i++) {\n for (int j = 0; j < arrayCount; j++) {\n result[j][i] = nextInt();\n }\n }\n return result;\n }\n public long[][] nextVerticalLongArrays(int arrayCount,\n int arrayLength) {\n long[][] result = new long[arrayCount][arrayLength];\n for (int i = 0; i < arrayLength; i++) {\n for (int j = 0; j < arrayCount; j++) {\n result[j][i] = nextLong();\n }\n }\n return result;\n }\n public char[][] nextVerticalCharArrays(int arrayCount,\n int arrayLength) {\n char[][] result = new char[arrayCount][arrayLength];\n for (int i = 0; i < arrayLength; i++) {\n for (int j = 0; j < arrayCount; j++) {\n result[j][i] = nextChar();\n }\n }\n return result;\n }\n }\n static final class MyWriter extends PrintWriter {\n MyWriter(OutputStream out) {\n super(out);\n }\n public void joinAndPrintln(int[] x) {\n joinAndPrintln(x, \" \");\n }\n public void joinAndPrintln(int[] x, String delimiter) {\n StringBuilder b = new StringBuilder();\n if (x.length > 0) {\n b.append(x[0]);\n for (int i = 1; i < x.length; i++) {\n b.append(delimiter).append(x[i]);\n }\n }\n println(b.toString());\n }\n public void joinAndPrintln(long[] x) {\n joinAndPrintln(x, \" \");\n }\n public void joinAndPrintln(long[] x, String delimiter) {\n StringBuilder b = new StringBuilder();\n if (x.length > 0) {\n b.append(x[0]);\n for (int i = 1; i < x.length; i++) {\n b.append(delimiter).append(x[i]);\n }\n }\n println(b.toString());\n }\n public void joinAndPrintln(Iterable iterable) {\n joinAndPrintln(iterable, \" \");\n }\n public void joinAndPrintln(Iterable iterable, String delimiter) {\n StringBuilder b = new StringBuilder();\n for (Iterator i = iterable.iterator(); i.hasNext();) {\n b.append(i.next());\n while (i.hasNext()) {\n b.append(delimiter).append(i.next());\n }\n }\n println(b.toString());\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1578881992, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02802.html", "problem_id": "p02802", "resource_group": "high_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/Java/s430333544.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s430333544", "user_id": "u097304477"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.util.InputMismatchException;\nimport java.util.Iterator;\nimport java.util.NoSuchElementException;\n\npublic class Main {\n static void solve(MyScanner in, MyWriter out) {\n int n = in.nextInt();\n int m = in.nextInt();\n int[] p = new int[m];\n String[] s = new String[m];\n for (int i = 0; i < m; i++) {\n p[i] = in.nextInt() - 1;\n s[i] = in.next();\n }\n boolean[] ac = new boolean[n];\n int[] a = new int[n];\n for (int i = 0; i < m; i++) {\n if (s[i].equals(\"AC\")) {\n ac[p[i]] = true;\n } else if (!ac[p[i]]) {\n a[p[i]]++;\n }\n }\n int acCount = 0;\n int b = 0;\n for (int i = 0; i < n; i++) {\n if (ac[i]) {\n acCount++;\n b += a[i];\n }\n }\n out.println(acCount + \" \" + b);\n }\n\n public static void main(String[] args) {\n MyWriter w = new MyWriter(System.out);\n solve(new MyScanner(System.in), w);\n w.flush();\n }\n\n static final class MyScanner {\n static final int BUFFER_SIZE = 8192;\n private final InputStream in;\n private final byte[] buffer = new byte[BUFFER_SIZE];\n private int point;\n private int readLength;\n MyScanner(InputStream in) {\n this.in = in;\n }\n private byte readByte() {\n if (point < readLength) {\n byte result = buffer[point];\n point += 1;\n return result;\n }\n try {\n readLength = in.read(buffer);\n } catch (IOException e) {\n throw new AssertionError(null, e);\n }\n if (readLength == -1) {\n return -1;\n }\n point = 1;\n return buffer[0];\n }\n private static boolean isPrintableCharExceptSpace(byte c) {\n return 33 <= c && c <= 126;\n }\n public char nextChar() {\n byte c = readByte();\n while (!(c == -1 || isPrintableCharExceptSpace(c))) {\n c = readByte();\n }\n if (c == -1) {\n throw new NoSuchElementException();\n }\n return (char)c;\n }\n public String next() {\n return next(16);\n }\n public String next(int n) {\n byte c = readByte();\n while (!(c == -1 || isPrintableCharExceptSpace(c))) {\n c = readByte();\n }\n if (c == -1) {\n throw new NoSuchElementException();\n }\n StringBuilder b = new StringBuilder(n);\n do {\n b.append((char)c);\n c = readByte();\n } while (c != -1 && isPrintableCharExceptSpace(c));\n return b.toString();\n }\n public long nextLong() {\n byte c = readByte();\n while (!(c == -1 || isPrintableCharExceptSpace(c))) {\n c = readByte();\n }\n if (c == -1) {\n throw new NoSuchElementException();\n }\n boolean minus = false;\n if (c == '-') {\n minus = true;\n c = readByte();\n }\n long result = 0L;\n do {\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n result = result * 10L + (c - '0');\n c = readByte();\n } while (c != -1 && isPrintableCharExceptSpace(c));\n return minus ? -result : result;\n }\n public int nextInt() {\n long n = nextLong();\n if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE) {\n throw new InputMismatchException();\n }\n return (int)n;\n }\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n public int[] nextIntArray(int n) {\n int[] result = new int[n];\n for (int i = 0; i < n; i++) {\n result[i] = nextInt();\n }\n return result;\n }\n public long[] nextLongArray(int n) {\n long[] result = new long[n];\n for (int i = 0; i < n; i++) {\n result[i] = nextLong();\n }\n return result;\n }\n public char[] nextCharArray(int n) {\n char[] result = new char[n];\n for (int i = 0; i < n; i++) {\n result[i] = nextChar();\n }\n return result;\n }\n public char[][] next2dCharArray(int n, int m) {\n char[][] result = new char[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n result[i][j] = nextChar();\n }\n }\n return result;\n }\n public int[][] nextVerticalIntArrays(int arrayCount, int arrayLength) {\n int[][] result = new int[arrayCount][arrayLength];\n for (int i = 0; i < arrayLength; i++) {\n for (int j = 0; j < arrayCount; j++) {\n result[j][i] = nextInt();\n }\n }\n return result;\n }\n public long[][] nextVerticalLongArrays(int arrayCount,\n int arrayLength) {\n long[][] result = new long[arrayCount][arrayLength];\n for (int i = 0; i < arrayLength; i++) {\n for (int j = 0; j < arrayCount; j++) {\n result[j][i] = nextLong();\n }\n }\n return result;\n }\n public char[][] nextVerticalCharArrays(int arrayCount,\n int arrayLength) {\n char[][] result = new char[arrayCount][arrayLength];\n for (int i = 0; i < arrayLength; i++) {\n for (int j = 0; j < arrayCount; j++) {\n result[j][i] = nextChar();\n }\n }\n return result;\n }\n }\n static final class MyWriter extends PrintWriter {\n MyWriter(OutputStream out) {\n super(out);\n }\n public void joinAndPrintln(int[] x) {\n joinAndPrintln(x, \" \");\n }\n public void joinAndPrintln(int[] x, String delimiter) {\n StringBuilder b = new StringBuilder();\n if (x.length > 0) {\n b.append(x[0]);\n for (int i = 1; i < x.length; i++) {\n b.append(delimiter).append(x[i]);\n }\n }\n println(b.toString());\n }\n public void joinAndPrintln(long[] x) {\n joinAndPrintln(x, \" \");\n }\n public void joinAndPrintln(long[] x, String delimiter) {\n StringBuilder b = new StringBuilder();\n if (x.length > 0) {\n b.append(x[0]);\n for (int i = 1; i < x.length; i++) {\n b.append(delimiter).append(x[i]);\n }\n }\n println(b.toString());\n }\n public void joinAndPrintln(Iterable iterable) {\n joinAndPrintln(iterable, \" \");\n }\n public void joinAndPrintln(Iterable iterable, String delimiter) {\n StringBuilder b = new StringBuilder();\n for (Iterator i = iterable.iterator(); i.hasNext();) {\n b.append(i.next());\n while (i.hasNext()) {\n b.append(delimiter).append(i.next());\n }\n }\n println(b.toString());\n }\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "sample_input": "2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n"}, "reference_outputs": ["2 2\n"], "source_document_id": "p02802", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7844, "cpu_time_ms": 131, "memory_kb": 35748}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s023583993", "group_id": "codeNet:p02803", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.AbstractCollection;\nimport java.util.InputMismatchException;\nimport java.io.IOException;\nimport java.util.LinkedList;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author KharYusuf\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n FastReader in = new FastReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n DMazeMaster solver = new DMazeMaster();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class DMazeMaster {\n int lx = 0;\n int ly = 0;\n int mxcnt = 0;\n char[][] c;\n boolean[][] vis;\n int[] xi = {1, -1, 0, 0};\n int[] yi = {0, 0, -1, 1};\n\n public void solve(int testNumber, FastReader s, PrintWriter w) {\n int h = s.nextInt(), wi = s.nextInt();\n c = new char[h][];\n vis = new boolean[h][wi];\n for (int i = 0; i < h; i++) c[i] = s.next().toCharArray();\n boolean done = false;\n for (int i = 0; i < h; i++) {\n for (int j = 0; j < wi; j++) {\n if (c[i][j] == '.') {\n vis[i][j] = true;\n LinkedList l = new LinkedList<>();\n l.add(new dist(i, j, 0));\n bfs(h, wi, l);\n done = true;\n break;\n }\n }\n if (done) break;\n }\n vis = new boolean[h][wi];\n vis[lx][ly] = true;\n LinkedList l = new LinkedList<>();\n l.add(new dist(lx, ly, 0));\n bfs(h, wi, l);\n w.println(mxcnt);\n }\n\n void bfs(int h, int wi, LinkedList l) {\n while (!l.isEmpty()) {\n dist d = l.poll();\n int x = d.x, y = d.y;\n if (d.z >= mxcnt) {\n mxcnt = d.z;\n lx = x;\n ly = y;\n }\n for (int i = 0; i < 4; i++) {\n if (x + xi[i] < h && x + xi[i] >= 0 && y + yi[i] < wi && y + yi[i] >= 0 && !vis[x + xi[i]][y + yi[i]] && c[x + xi[i]][y + yi[i]] == '.') {\n vis[x + xi[i]][y + yi[i]] = true;\n l.add(new dist(x + xi[i], y + yi[i], d.z + 1));\n }\n }\n }\n }\n\n }\n\n static class dist implements Comparable {\n public int x;\n public int y;\n public int z;\n\n public dist(int xi, int yi, int zi) {\n x = xi;\n y = yi;\n z = zi;\n }\n\n public int compareTo(dist other) {\n if (this.z > other.z) {\n return 1;\n }\n if (this.z < other.z) {\n return -1;\n }\n return 0;\n }\n\n }\n\n static class FastReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private FastReader.SpaceCharFilter filter;\n\n public FastReader(InputStream stream) {\n this.stream = stream;\n }\n\n public int read() {\n\n if (numChars == -1)\n throw new InputMismatchException();\n\n if (curChar >= numChars) {\n\n curChar = 0;\n\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n\n if (numChars <= 0)\n return -1;\n }\n\n return buf[curChar++];\n }\n\n public int nextInt() {\n\n int c = read();\n\n while (isSpaceChar(c))\n c = read();\n\n int sgn = 1;\n\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n\n int res = 0;\n\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n\n res *= 10;\n res += c - '0';\n c = read();\n }\n while (!isSpaceChar(c));\n\n return res * sgn;\n }\n\n public String next() {\n\n int c = read();\n\n while (isSpaceChar(c))\n c = read();\n\n StringBuilder res = new StringBuilder();\n\n do {\n res.appendCodePoint(c);\n c = read();\n }\n while (!isSpaceChar(c));\n\n return res.toString();\n }\n\n public boolean isSpaceChar(int c) {\n\n if (filter != null)\n return filter.isSpaceChar(c);\n\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1578882936, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02803.html", "problem_id": "p02803", "resource_group": "high_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/Java/s023583993.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s023583993", "user_id": "u537747009"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.AbstractCollection;\nimport java.util.InputMismatchException;\nimport java.io.IOException;\nimport java.util.LinkedList;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author KharYusuf\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n FastReader in = new FastReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n DMazeMaster solver = new DMazeMaster();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class DMazeMaster {\n int lx = 0;\n int ly = 0;\n int mxcnt = 0;\n char[][] c;\n boolean[][] vis;\n int[] xi = {1, -1, 0, 0};\n int[] yi = {0, 0, -1, 1};\n\n public void solve(int testNumber, FastReader s, PrintWriter w) {\n int h = s.nextInt(), wi = s.nextInt();\n c = new char[h][];\n vis = new boolean[h][wi];\n for (int i = 0; i < h; i++) c[i] = s.next().toCharArray();\n boolean done = false;\n for (int i = 0; i < h; i++) {\n for (int j = 0; j < wi; j++) {\n if (c[i][j] == '.') {\n vis[i][j] = true;\n LinkedList l = new LinkedList<>();\n l.add(new dist(i, j, 0));\n bfs(h, wi, l);\n done = true;\n break;\n }\n }\n if (done) break;\n }\n vis = new boolean[h][wi];\n vis[lx][ly] = true;\n LinkedList l = new LinkedList<>();\n l.add(new dist(lx, ly, 0));\n bfs(h, wi, l);\n w.println(mxcnt);\n }\n\n void bfs(int h, int wi, LinkedList l) {\n while (!l.isEmpty()) {\n dist d = l.poll();\n int x = d.x, y = d.y;\n if (d.z >= mxcnt) {\n mxcnt = d.z;\n lx = x;\n ly = y;\n }\n for (int i = 0; i < 4; i++) {\n if (x + xi[i] < h && x + xi[i] >= 0 && y + yi[i] < wi && y + yi[i] >= 0 && !vis[x + xi[i]][y + yi[i]] && c[x + xi[i]][y + yi[i]] == '.') {\n vis[x + xi[i]][y + yi[i]] = true;\n l.add(new dist(x + xi[i], y + yi[i], d.z + 1));\n }\n }\n }\n }\n\n }\n\n static class dist implements Comparable {\n public int x;\n public int y;\n public int z;\n\n public dist(int xi, int yi, int zi) {\n x = xi;\n y = yi;\n z = zi;\n }\n\n public int compareTo(dist other) {\n if (this.z > other.z) {\n return 1;\n }\n if (this.z < other.z) {\n return -1;\n }\n return 0;\n }\n\n }\n\n static class FastReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private FastReader.SpaceCharFilter filter;\n\n public FastReader(InputStream stream) {\n this.stream = stream;\n }\n\n public int read() {\n\n if (numChars == -1)\n throw new InputMismatchException();\n\n if (curChar >= numChars) {\n\n curChar = 0;\n\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n\n if (numChars <= 0)\n return -1;\n }\n\n return buf[curChar++];\n }\n\n public int nextInt() {\n\n int c = read();\n\n while (isSpaceChar(c))\n c = read();\n\n int sgn = 1;\n\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n\n int res = 0;\n\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n\n res *= 10;\n res += c - '0';\n c = read();\n }\n while (!isSpaceChar(c));\n\n return res * sgn;\n }\n\n public String next() {\n\n int c = read();\n\n while (isSpaceChar(c))\n c = read();\n\n StringBuilder res = new StringBuilder();\n\n do {\n res.appendCodePoint(c);\n c = read();\n }\n while (!isSpaceChar(c));\n\n return res.toString();\n }\n\n public boolean isSpaceChar(int c) {\n\n if (filter != null)\n return filter.isSpaceChar(c);\n\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\n\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": 5224, "cpu_time_ms": 75, "memory_kb": 22868}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s214015768", "group_id": "codeNet:p02811", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner stdIn = new Scanner(System.in);\n\t\tint K = stdIn.nextInt();\n\t\tint X = stdIn.nextInt();\n\t\tint ans = 0;\n\t\tans = K * 500;\n\t\tif(ans >= X){\n\t\t\tSystem.out.println(\"Yes\");\n\t\t}\n\t\telse{\n\t\t\tSystem.out.println(\"No\");\n\t\t}\n\t\tstdIn.close();\n\t}\n}", "language": "Java", "metadata": {"date": 1597433305, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02811.html", "problem_id": "p02811", "resource_group": "high_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/Java/s214015768.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s214015768", "user_id": "u580919774"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner stdIn = new Scanner(System.in);\n\t\tint K = stdIn.nextInt();\n\t\tint X = stdIn.nextInt();\n\t\tint ans = 0;\n\t\tans = K * 500;\n\t\tif(ans >= X){\n\t\t\tSystem.out.println(\"Yes\");\n\t\t}\n\t\telse{\n\t\t\tSystem.out.println(\"No\");\n\t\t}\n\t\tstdIn.close();\n\t}\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": 328, "cpu_time_ms": 121, "memory_kb": 35148}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s838556950", "group_id": "codeNet:p02811", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n System.out.println((500 * sc.nextInt() >= sc.nextInt()) ? \"Yes\" : \"No\");\n }\n}", "language": "Java", "metadata": {"date": 1579911901, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02811.html", "problem_id": "p02811", "resource_group": "high_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/Java/s838556950.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s838556950", "user_id": "u045289115"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n System.out.println((500 * sc.nextInt() >= sc.nextInt()) ? \"Yes\" : \"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": 207, "cpu_time_ms": 94, "memory_kb": 22608}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s378075445", "group_id": "codeNet:p02813", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.io.BufferedWriter;\nimport java.io.Writer;\nimport java.io.OutputStreamWriter;\nimport java.util.InputMismatchException;\nimport java.io.IOException;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n OutputWriter out = new OutputWriter(outputStream);\n CCountOrder solver = new CCountOrder();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class CCountOrder {\n public void solve(int testNumber, InputReader in, OutputWriter out) {\n int n = in.readInt();\n int[] p = in.readIntArray(n);\n int[] q = in.readIntArray(n);\n out.printLine(Math.abs(f(p) - f(q)));\n }\n\n int f(int[] a) {\n int n = a.length;\n int ret = 0;\n int base = 1;\n for (int i = 1; i < n; i++) {\n base *= i;\n }\n for (int i = 0; i < n; i++) {\n ret += (a[i] - 1) * base;\n if (i < n - 1) base /= n - 1 - i;\n for (int j = i + 1; j < n; j++) {\n if (a[j] > a[i]) a[j]--;\n }\n }\n return ret;\n }\n\n }\n\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private InputReader.SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n\n public int[] readIntArray(int size) {\n int[] array = new int[size];\n for (int i = 0; i < size; i++) {\n array[i] = readInt();\n }\n return array;\n }\n\n public int read() {\n if (numChars == -1) {\n throw new InputMismatchException();\n }\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0) {\n return -1;\n }\n }\n return buf[curChar++];\n }\n\n public int readInt() {\n int c = read();\n while (isSpaceChar(c)) {\n c = read();\n }\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n res *= 10;\n res += c - '0';\n c = read();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n\n public boolean isSpaceChar(int c) {\n if (filter != null) {\n return filter.isSpaceChar(c);\n }\n return isWhitespace(c);\n }\n\n public static boolean isWhitespace(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\n\n }\n\n static class OutputWriter {\n private final PrintWriter writer;\n\n public OutputWriter(OutputStream outputStream) {\n writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));\n }\n\n public OutputWriter(Writer writer) {\n this.writer = new PrintWriter(writer);\n }\n\n public void close() {\n writer.close();\n }\n\n public void printLine(int i) {\n writer.println(i);\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1578718113, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02813.html", "problem_id": "p02813", "resource_group": "high_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/Java/s378075445.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s378075445", "user_id": "u038084150"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.io.BufferedWriter;\nimport java.io.Writer;\nimport java.io.OutputStreamWriter;\nimport java.util.InputMismatchException;\nimport java.io.IOException;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n OutputWriter out = new OutputWriter(outputStream);\n CCountOrder solver = new CCountOrder();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class CCountOrder {\n public void solve(int testNumber, InputReader in, OutputWriter out) {\n int n = in.readInt();\n int[] p = in.readIntArray(n);\n int[] q = in.readIntArray(n);\n out.printLine(Math.abs(f(p) - f(q)));\n }\n\n int f(int[] a) {\n int n = a.length;\n int ret = 0;\n int base = 1;\n for (int i = 1; i < n; i++) {\n base *= i;\n }\n for (int i = 0; i < n; i++) {\n ret += (a[i] - 1) * base;\n if (i < n - 1) base /= n - 1 - i;\n for (int j = i + 1; j < n; j++) {\n if (a[j] > a[i]) a[j]--;\n }\n }\n return ret;\n }\n\n }\n\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private InputReader.SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n\n public int[] readIntArray(int size) {\n int[] array = new int[size];\n for (int i = 0; i < size; i++) {\n array[i] = readInt();\n }\n return array;\n }\n\n public int read() {\n if (numChars == -1) {\n throw new InputMismatchException();\n }\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0) {\n return -1;\n }\n }\n return buf[curChar++];\n }\n\n public int readInt() {\n int c = read();\n while (isSpaceChar(c)) {\n c = read();\n }\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n res *= 10;\n res += c - '0';\n c = read();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n\n public boolean isSpaceChar(int c) {\n if (filter != null) {\n return filter.isSpaceChar(c);\n }\n return isWhitespace(c);\n }\n\n public static boolean isWhitespace(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\n\n }\n\n static class OutputWriter {\n private final PrintWriter writer;\n\n public OutputWriter(OutputStream outputStream) {\n writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));\n }\n\n public OutputWriter(Writer writer) {\n this.writer = new PrintWriter(writer);\n }\n\n public void close() {\n writer.close();\n }\n\n public void printLine(int i) {\n writer.println(i);\n }\n\n }\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": 4157, "cpu_time_ms": 72, "memory_kb": 22740}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s371939076", "group_id": "codeNet:p02814", "input_text": "import java.util.*;\n\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int M = sc.nextInt();\n int[] a = new int[N];\n for (int i = 0; i < N; i++) {\n a[i] = sc.nextInt();\n }\n\n Arrays.sort(a);\n int gcd = a[0];\n for (int i = 1; i < N; i++) {\n if (a[i]%2 == 1) {\n System.out.println(0);\n return;\n } \n gcd = calcGcd(gcd, a[i]/2);\n }\n\n boolean ok = true;\n int xx = f(a[0]);\n for (int i = 1; i < N; i++) {\n if (f(a[i]) != xx) {\n ok = false;\n break;\n }\n }\n if (!ok) {\n System.out.println(0);\n return;\n }\n\n long lcm = a[0]/2;\n for (int i = 1; i < N; i++) {\n if (a[i]/2 % lcm == 0) {\n lcm *= a[i]/2/lcm;\n } else {\n lcm *= a[i]/2/gcd;\n }\n }\n //System.out.println(lcm);\n\n System.out.println((M/lcm+1)/2);\n }\n\n private static int calcGcd(int a, int b) {\n if (b == 0) {\n return a;\n }\n\n return calcGcd(b, a%b);\n }\n\n private static int f(int x) {\n int ret = 0;\n while (x%2 == 0) {\n ret++;\n x /= 2;\n }\n\n return ret;\n }\n}\n", "language": "Java", "metadata": {"date": 1587861299, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02814.html", "problem_id": "p02814", "resource_group": "high_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/Java/s371939076.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s371939076", "user_id": "u507706381"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*;\n\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int M = sc.nextInt();\n int[] a = new int[N];\n for (int i = 0; i < N; i++) {\n a[i] = sc.nextInt();\n }\n\n Arrays.sort(a);\n int gcd = a[0];\n for (int i = 1; i < N; i++) {\n if (a[i]%2 == 1) {\n System.out.println(0);\n return;\n } \n gcd = calcGcd(gcd, a[i]/2);\n }\n\n boolean ok = true;\n int xx = f(a[0]);\n for (int i = 1; i < N; i++) {\n if (f(a[i]) != xx) {\n ok = false;\n break;\n }\n }\n if (!ok) {\n System.out.println(0);\n return;\n }\n\n long lcm = a[0]/2;\n for (int i = 1; i < N; i++) {\n if (a[i]/2 % lcm == 0) {\n lcm *= a[i]/2/lcm;\n } else {\n lcm *= a[i]/2/gcd;\n }\n }\n //System.out.println(lcm);\n\n System.out.println((M/lcm+1)/2);\n }\n\n private static int calcGcd(int a, int b) {\n if (b == 0) {\n return a;\n }\n\n return calcGcd(b, a%b);\n }\n\n private static int f(int x) {\n int ret = 0;\n while (x%2 == 0) {\n ret++;\n x /= 2;\n }\n\n return ret;\n }\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": 1437, "cpu_time_ms": 512, "memory_kb": 49680}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s337927893", "group_id": "codeNet:p02814", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.*;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\n\npublic class Main {\n static void bin(int n) {\n if (n > 1)\n bin(n/2);\n\n System.out.print(n % 2);\n }\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskA solver = new TaskA();\n solver.solve(1, in, out);\n out.close();\n }\n static class Pair
{\n a v1;\n b v2;\n Pair(a v1 , b v2){\n this.v1 = v1;\n this.v2 = v2;\n }\n }\n static class TaskA {\n public void solve(int testNumber, InputReader in, PrintWriter out){\n int n = in.nextInt();\n int m = in.nextInt();\n long [] arr = new long[n];\n for (int i = 0; i m){\n ans=0;\n break;\n }\n }\n if (ans == 0) System.out.println(0);\n else {\n System.out.println((int)Math.ceil(((double)m)/val)/2);\n }\n\n\n\n\n\n }\n }\n\n static class InputReader {\n public BufferedReader reader;\n public StringTokenizer tokenizer;\n\n public InputReader(InputStream stream) {\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\n tokenizer = null;\n }\n\n public String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n public int nextInt(){return Integer.parseInt(next());}\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n }\n}", "language": "Java", "metadata": {"date": 1579473190, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02814.html", "problem_id": "p02814", "resource_group": "high_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/Java/s337927893.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s337927893", "user_id": "u210850855"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.*;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\n\npublic class Main {\n static void bin(int n) {\n if (n > 1)\n bin(n/2);\n\n System.out.print(n % 2);\n }\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskA solver = new TaskA();\n solver.solve(1, in, out);\n out.close();\n }\n static class Pair{\n a v1;\n b v2;\n Pair(a v1 , b v2){\n this.v1 = v1;\n this.v2 = v2;\n }\n }\n static class TaskA {\n public void solve(int testNumber, InputReader in, PrintWriter out){\n int n = in.nextInt();\n int m = in.nextInt();\n long [] arr = new long[n];\n for (int i = 0; i m){\n ans=0;\n break;\n }\n }\n if (ans == 0) System.out.println(0);\n else {\n System.out.println((int)Math.ceil(((double)m)/val)/2);\n }\n\n\n\n\n\n }\n }\n\n static class InputReader {\n public BufferedReader reader;\n public StringTokenizer tokenizer;\n\n public InputReader(InputStream stream) {\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\n tokenizer = null;\n }\n\n public String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n public int nextInt(){return Integer.parseInt(next());}\n public long nextLong() {\n return Long.parseLong(next());\n }\n\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": 2385, "cpu_time_ms": 195, "memory_kb": 40072}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s251010400", "group_id": "codeNet:p02817", "input_text": "import java.io.ByteArrayInputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.*;\n\npublic class Main {\n static InputStream is;\n static PrintWriter out;\n static String INPUT = \"\";\n\n static void solve() {\n String s = ns();\n String t = ns();\n out.println(t + s);\n }\n\n public static void main(String[] args) throws Exception {\n long S = System.currentTimeMillis();\n is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n out = new PrintWriter(System.out);\n\n solve();\n out.flush();\n long G = System.currentTimeMillis();\n tr(G-S+\"ms\");\n }\n\n private static boolean eof() {\n if(lenbuf == -1)return true;\n int lptr = ptrbuf;\n while(lptr < lenbuf)if(!isSpaceChar(inbuf[lptr++]))return false;\n\n try {\n is.mark(1000);\n while(true){\n int b = is.read();\n if(b == -1){\n is.reset();\n return true;\n }else if(!isSpaceChar(b)){\n is.reset();\n return false;\n }\n }\n } catch (IOException e) {\n return true;\n }\n }\n\n private static byte[] inbuf = new byte[1024];\n static int lenbuf = 0, ptrbuf = 0;\n\n private static int readByte() {\n if(lenbuf == -1)throw new InputMismatchException();\n if(ptrbuf >= lenbuf){\n ptrbuf = 0;\n try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }\n if(lenbuf <= 0)return -1;\n }\n return inbuf[ptrbuf++];\n }\n\n private static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }\n\n private static int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }\n\n private static double nd() { return Double.parseDouble(ns()); }\n private static char nc() { return (char)skip(); }\n\n private static String ns() {\n int b = skip();\n StringBuilder sb = new StringBuilder();\n while(!(isSpaceChar(b))){\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n private static char[] ns(int n) {\n char[] buf = new char[n];\n int b = skip(), p = 0;\n while(p < n && !(isSpaceChar(b))){\n buf[p++] = (char)b;\n b = readByte();\n }\n return n == p ? buf : Arrays.copyOf(buf, p);\n }\n\n private static char[][] nm(int n, int m) {\n char[][] map = new char[n][];\n for(int i = 0;i < n;i++)map[i] = ns(m);\n return map;\n }\n\n private static int[] na(int n) {\n int[] a = new int[n];\n for(int i = 0;i < n;i++)a[i] = ni();\n return a;\n }\n\n private static int ni() {\n int num = 0, b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-'){\n minus = true;\n b = readByte();\n }\n\n while(true){\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n }else{\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n\n private static long nl() {\n long num = 0;\n int b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-'){\n minus = true;\n b = readByte();\n }\n\n while(true){\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n }else{\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n\n private static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }\n\n // Union-Find\n // https://algs4.cs.princeton.edu/15uf/UF.java.html\n public static class UnionFind {\n private int count = 0;\n private int[] parent, rank;\n\n public UnionFind(int n) {\n count = n;\n parent = new int[n];\n rank = new int[n];\n for (int i = 0; i < n; i++) {\n parent[i] = i;\n }\n }\n\n public int find(int p) {\n while (p != parent[p]) {\n parent[p] = parent[parent[p]];\n p = parent[p];\n }\n return p;\n }\n\n public void union(int p, int q) {\n int rootP = find(p);\n int rootQ = find(q);\n if (rootP ==rootQ) return;\n if (rank[rootQ] > rank[rootP]) {\n parent[rootP] = rootQ;\n } else {\n parent[rootQ] = rootP;\n if (rank[rootP] == rank[rootQ]) {\n rank[rootP]++;\n }\n }\n count--;\n }\n\n public int count() {\n return count;\n }\n\n public void print() {\n out.println(\"Parent:\");\n for (int i : parent) {\n out.print(i);\n out.print(\" \");\n }\n out.println();\n out.println(\"Rank:\");\n for (int i : rank) {\n out.print(i);\n out.print(\" \");\n }\n out.println();\n }\n }\n\n // Dijkstra\n // Return min distance from start to end O(ElogV) (negative cost is prohibited)\n // edge is int[3] array {from,to,cost}\n // edges is edge list from specific node\n // all_edges is Map\n static int dijkstra(Map> all_edges,int start,int end,int max_node_number) {\n int[] distance = new int[max_node_number + 1];\n Arrays.fill(distance, -1);\n PriorityQueue p_que = new PriorityQueue<>((a,b) -> ((distance[a[0]] + a[2]) - (distance[b[0]] + b[2])));\n distance[start] = 0;\n List edges = all_edges.get(start);\n p_que.addAll(edges);\n while (distance[end] < 0) {\n int[] nearest_edge = p_que.poll();\n assert nearest_edge != null;\n if (distance[nearest_edge[1]] < 0) {\n distance[nearest_edge[1]] = distance[nearest_edge[0]] + nearest_edge[2];\n if (all_edges.containsKey(nearest_edge[1])) {\n edges = all_edges.get(nearest_edge[1]);\n for (int[] edge : edges) {\n if (distance[edge[1]] < 0) p_que.add(edge);\n }\n }\n }\n }\n return distance[end];\n }\n\n // Enumerate primes in [2, n] with O(n log log n)\n public static List sieveOfEratosthenes(int n) {\n boolean[] isPrime = new boolean[n+1];\n Arrays.fill(isPrime, true);\n for (int i = 2; i * i <= n; i++) {\n if (isPrime[i]) {\n for (int j = i + i; j <= n; j += i) {\n isPrime[j] = false;\n }\n }\n }\n List primes = new ArrayList<>();\n for (int i = 2; i <= n; i++) {\n if (isPrime[i]) {\n primes.add(i);\n }\n }\n return primes;\n }\n\n // Count divisor\n public static int countDivisor(int n) {\n int[] list = new int[n + 1];\n Arrays.fill(list, 0);\n int num = n;\n for (int i = 2; i <= n; i++) {\n while (num % i == 0) {\n list[i] = list[i] + 1;\n num /= i;\n }\n }\n int ans = 1;\n for (int i : list) {\n ans *= (i + 1);\n }\n return ans;\n }\n}\n", "language": "Java", "metadata": {"date": 1592887103, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02817.html", "problem_id": "p02817", "resource_group": "high_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/Java/s251010400.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s251010400", "user_id": "u381460455"}, "prompt_components": {"gold_output": "atcoder\n", "input_to_evaluate": "import java.io.ByteArrayInputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.*;\n\npublic class Main {\n static InputStream is;\n static PrintWriter out;\n static String INPUT = \"\";\n\n static void solve() {\n String s = ns();\n String t = ns();\n out.println(t + s);\n }\n\n public static void main(String[] args) throws Exception {\n long S = System.currentTimeMillis();\n is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n out = new PrintWriter(System.out);\n\n solve();\n out.flush();\n long G = System.currentTimeMillis();\n tr(G-S+\"ms\");\n }\n\n private static boolean eof() {\n if(lenbuf == -1)return true;\n int lptr = ptrbuf;\n while(lptr < lenbuf)if(!isSpaceChar(inbuf[lptr++]))return false;\n\n try {\n is.mark(1000);\n while(true){\n int b = is.read();\n if(b == -1){\n is.reset();\n return true;\n }else if(!isSpaceChar(b)){\n is.reset();\n return false;\n }\n }\n } catch (IOException e) {\n return true;\n }\n }\n\n private static byte[] inbuf = new byte[1024];\n static int lenbuf = 0, ptrbuf = 0;\n\n private static int readByte() {\n if(lenbuf == -1)throw new InputMismatchException();\n if(ptrbuf >= lenbuf){\n ptrbuf = 0;\n try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }\n if(lenbuf <= 0)return -1;\n }\n return inbuf[ptrbuf++];\n }\n\n private static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }\n\n private static int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }\n\n private static double nd() { return Double.parseDouble(ns()); }\n private static char nc() { return (char)skip(); }\n\n private static String ns() {\n int b = skip();\n StringBuilder sb = new StringBuilder();\n while(!(isSpaceChar(b))){\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n private static char[] ns(int n) {\n char[] buf = new char[n];\n int b = skip(), p = 0;\n while(p < n && !(isSpaceChar(b))){\n buf[p++] = (char)b;\n b = readByte();\n }\n return n == p ? buf : Arrays.copyOf(buf, p);\n }\n\n private static char[][] nm(int n, int m) {\n char[][] map = new char[n][];\n for(int i = 0;i < n;i++)map[i] = ns(m);\n return map;\n }\n\n private static int[] na(int n) {\n int[] a = new int[n];\n for(int i = 0;i < n;i++)a[i] = ni();\n return a;\n }\n\n private static int ni() {\n int num = 0, b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-'){\n minus = true;\n b = readByte();\n }\n\n while(true){\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n }else{\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n\n private static long nl() {\n long num = 0;\n int b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-'){\n minus = true;\n b = readByte();\n }\n\n while(true){\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n }else{\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n\n private static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }\n\n // Union-Find\n // https://algs4.cs.princeton.edu/15uf/UF.java.html\n public static class UnionFind {\n private int count = 0;\n private int[] parent, rank;\n\n public UnionFind(int n) {\n count = n;\n parent = new int[n];\n rank = new int[n];\n for (int i = 0; i < n; i++) {\n parent[i] = i;\n }\n }\n\n public int find(int p) {\n while (p != parent[p]) {\n parent[p] = parent[parent[p]];\n p = parent[p];\n }\n return p;\n }\n\n public void union(int p, int q) {\n int rootP = find(p);\n int rootQ = find(q);\n if (rootP ==rootQ) return;\n if (rank[rootQ] > rank[rootP]) {\n parent[rootP] = rootQ;\n } else {\n parent[rootQ] = rootP;\n if (rank[rootP] == rank[rootQ]) {\n rank[rootP]++;\n }\n }\n count--;\n }\n\n public int count() {\n return count;\n }\n\n public void print() {\n out.println(\"Parent:\");\n for (int i : parent) {\n out.print(i);\n out.print(\" \");\n }\n out.println();\n out.println(\"Rank:\");\n for (int i : rank) {\n out.print(i);\n out.print(\" \");\n }\n out.println();\n }\n }\n\n // Dijkstra\n // Return min distance from start to end O(ElogV) (negative cost is prohibited)\n // edge is int[3] array {from,to,cost}\n // edges is edge list from specific node\n // all_edges is Map\n static int dijkstra(Map> all_edges,int start,int end,int max_node_number) {\n int[] distance = new int[max_node_number + 1];\n Arrays.fill(distance, -1);\n PriorityQueue p_que = new PriorityQueue<>((a,b) -> ((distance[a[0]] + a[2]) - (distance[b[0]] + b[2])));\n distance[start] = 0;\n List edges = all_edges.get(start);\n p_que.addAll(edges);\n while (distance[end] < 0) {\n int[] nearest_edge = p_que.poll();\n assert nearest_edge != null;\n if (distance[nearest_edge[1]] < 0) {\n distance[nearest_edge[1]] = distance[nearest_edge[0]] + nearest_edge[2];\n if (all_edges.containsKey(nearest_edge[1])) {\n edges = all_edges.get(nearest_edge[1]);\n for (int[] edge : edges) {\n if (distance[edge[1]] < 0) p_que.add(edge);\n }\n }\n }\n }\n return distance[end];\n }\n\n // Enumerate primes in [2, n] with O(n log log n)\n public static List sieveOfEratosthenes(int n) {\n boolean[] isPrime = new boolean[n+1];\n Arrays.fill(isPrime, true);\n for (int i = 2; i * i <= n; i++) {\n if (isPrime[i]) {\n for (int j = i + i; j <= n; j += i) {\n isPrime[j] = false;\n }\n }\n }\n List primes = new ArrayList<>();\n for (int i = 2; i <= n; i++) {\n if (isPrime[i]) {\n primes.add(i);\n }\n }\n return primes;\n }\n\n // Count divisor\n public static int countDivisor(int n) {\n int[] list = new int[n + 1];\n Arrays.fill(list, 0);\n int num = n;\n for (int i = 2; i <= n; i++) {\n while (num % i == 0) {\n list[i] = list[i] + 1;\n num /= i;\n }\n }\n int ans = 1;\n for (int i : list) {\n ans *= (i + 1);\n }\n return ans;\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\nThe lengths of S and T are between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\noder atc\n\nSample Output 1\n\natcoder\n\nWhen S = oder and T = atc, concatenating T and S in this order results in atcoder.\n\nSample Input 2\n\nhumu humu\n\nSample Output 2\n\nhumuhumu", "sample_input": "oder atc\n"}, "reference_outputs": ["atcoder\n"], "source_document_id": "p02817", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\nThe lengths of S and T are between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\noder atc\n\nSample Output 1\n\natcoder\n\nWhen S = oder and T = atc, concatenating T and S in this order results in atcoder.\n\nSample Input 2\n\nhumu humu\n\nSample Output 2\n\nhumuhumu", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7719, "cpu_time_ms": 159, "memory_kb": 37888}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s958718175", "group_id": "codeNet:p02817", "input_text": "\nimport java.text.DecimalFormat;\nimport java.util.stream.LongStream;\nimport java.util.stream.IntStream;\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n \n public static void main(String[] args) {\n FastScanner sc = new FastScanner();\n PrintWriter out = new PrintWriter(System.out);\n \n AtCoder problem = new AtCoder(sc);\n problem.solve(out);\n \n out.flush();\n }\n \n}\n\nclass AtCoder {\n final String S,T;\n AtCoder(FastScanner sc) {\n S = sc.next();\n T = sc.next();\n }\n\n void solve(PrintWriter out) {\n out.println(T + S);\n }\n \n}\n\n// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4\nclass FastScanner {\n \n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n \n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n \n private int readByte() {\n if (hasNextByte()) {\n return buffer[ptr++];\n } else {\n return -1;\n }\n }\n \n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n \n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) {\n ptr++;\n }\n return hasNextByte();\n }\n \n public String next() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n \n public long nextLong() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n \n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {\n throw new NumberFormatException();\n }\n return (int) nl;\n }\n \n public double nextDouble() {\n return Double.parseDouble(next());\n }\n}\n", "language": "Java", "metadata": {"date": 1589512401, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02817.html", "problem_id": "p02817", "resource_group": "high_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/Java/s958718175.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s958718175", "user_id": "u871244227"}, "prompt_components": {"gold_output": "atcoder\n", "input_to_evaluate": "\nimport java.text.DecimalFormat;\nimport java.util.stream.LongStream;\nimport java.util.stream.IntStream;\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n \n public static void main(String[] args) {\n FastScanner sc = new FastScanner();\n PrintWriter out = new PrintWriter(System.out);\n \n AtCoder problem = new AtCoder(sc);\n problem.solve(out);\n \n out.flush();\n }\n \n}\n\nclass AtCoder {\n final String S,T;\n AtCoder(FastScanner sc) {\n S = sc.next();\n T = sc.next();\n }\n\n void solve(PrintWriter out) {\n out.println(T + S);\n }\n \n}\n\n// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4\nclass FastScanner {\n \n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n \n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n \n private int readByte() {\n if (hasNextByte()) {\n return buffer[ptr++];\n } else {\n return -1;\n }\n }\n \n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n \n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) {\n ptr++;\n }\n return hasNextByte();\n }\n \n public String next() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n \n public long nextLong() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n \n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {\n throw new NumberFormatException();\n }\n return (int) nl;\n }\n \n public double nextDouble() {\n return Double.parseDouble(next());\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\nThe lengths of S and T are between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\noder atc\n\nSample Output 1\n\natcoder\n\nWhen S = oder and T = atc, concatenating T and S in this order results in atcoder.\n\nSample Input 2\n\nhumu humu\n\nSample Output 2\n\nhumuhumu", "sample_input": "oder atc\n"}, "reference_outputs": ["atcoder\n"], "source_document_id": "p02817", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\nThe lengths of S and T are between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\noder atc\n\nSample Output 1\n\natcoder\n\nWhen S = oder and T = atc, concatenating T and S in this order results in atcoder.\n\nSample Input 2\n\nhumu humu\n\nSample Output 2\n\nhumuhumu", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3037, "cpu_time_ms": 73, "memory_kb": 20692}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s031962006", "group_id": "codeNet:p02817", "input_text": "import java.util.*;\n\nclass Main{\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String s = sc.next();\n String t = sc.next();\n System.out.println(t+s);\n }\n}", "language": "Java", "metadata": {"date": 1582314914, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02817.html", "problem_id": "p02817", "resource_group": "high_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/Java/s031962006.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s031962006", "user_id": "u626353997"}, "prompt_components": {"gold_output": "atcoder\n", "input_to_evaluate": "import java.util.*;\n\nclass Main{\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String s = sc.next();\n String t = sc.next();\n System.out.println(t+s);\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\nThe lengths of S and T are between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\noder atc\n\nSample Output 1\n\natcoder\n\nWhen S = oder and T = atc, concatenating T and S in this order results in atcoder.\n\nSample Input 2\n\nhumu humu\n\nSample Output 2\n\nhumuhumu", "sample_input": "oder atc\n"}, "reference_outputs": ["atcoder\n"], "source_document_id": "p02817", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\nThe lengths of S and T are between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\noder atc\n\nSample Output 1\n\natcoder\n\nWhen S = oder and T = atc, concatenating T and S in this order results in atcoder.\n\nSample Input 2\n\nhumu humu\n\nSample Output 2\n\nhumuhumu", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 94, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s641616340", "group_id": "codeNet:p02818", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tlong a = sc.nextLong(), b = sc.nextLong(), k = sc.nextLong();\n\n\t\tif(a + b <= k) {\n\t\t\ta = b = 0;\n\t\t} else if(a <= k && k < a + b) {\n\t\t\tb = a + b - k;\n\t\t\ta = 0;\n\t\t} else {\n\t\t\ta = a - k;\n\t\t}\n\n\t\tSystem.out.println(a + \" \" + b);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1597057760, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02818.html", "problem_id": "p02818", "resource_group": "high_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/Java/s641616340.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s641616340", "user_id": "u078168851"}, "prompt_components": {"gold_output": "0 2\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tlong a = sc.nextLong(), b = sc.nextLong(), k = sc.nextLong();\n\n\t\tif(a + b <= k) {\n\t\t\ta = b = 0;\n\t\t} else if(a <= k && k < a + b) {\n\t\t\tb = a + b - k;\n\t\t\ta = 0;\n\t\t} else {\n\t\t\ta = a - k;\n\t\t}\n\n\t\tSystem.out.println(a + \" \" + b);\n\t}\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": 362, "cpu_time_ms": 162, "memory_kb": 38744}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s373262093", "group_id": "codeNet:p02818", "input_text": "import java.util.*;\n\npublic class Main{\n public static void main(String[] args){\n Scanner scan = new Scanner(System.in);\n long a = scan.nextLong();\n long b = scan.nextLong();\n long c = scan.nextLong();\n if (a<=c){\n long d = a;\n a = 0;\n c -= d;\n }\n else{\n a -= c;\n c = 0;\n }\n b -= c;\n if (b<0){\n b=0;\n }\n\n System.out.println(a+\" \"+b);\n }\n}\n", "language": "Java", "metadata": {"date": 1593907659, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02818.html", "problem_id": "p02818", "resource_group": "high_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/Java/s373262093.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s373262093", "user_id": "u114053864"}, "prompt_components": {"gold_output": "0 2\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main{\n public static void main(String[] args){\n Scanner scan = new Scanner(System.in);\n long a = scan.nextLong();\n long b = scan.nextLong();\n long c = scan.nextLong();\n if (a<=c){\n long d = a;\n a = 0;\n c -= d;\n }\n else{\n a -= c;\n c = 0;\n }\n b -= c;\n if (b<0){\n b=0;\n }\n\n System.out.println(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": 407, "cpu_time_ms": 162, "memory_kb": 38828}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s129749867", "group_id": "codeNet:p02818", "input_text": "import java.io.*;\nimport java.util.*;\n\npublic class Main{\n static MyReader in = new MyReader();\n static PrintWriter out = new PrintWriter(System.out);\n\n public static void main(String[] args){\n long A, B, K;\n {long[] a = in.ll(); A = a[0]; B = a[1]; K = a[2];}\n long i = Math.min(A, K);\n long j = Math.min(K-i, B);\n A -= i;\n B -= j;\n out.println(A+\" \"+B);\n out.flush();\n }\n\n static class MyReader extends BufferedReader{\n MyReader(){\n super(new InputStreamReader(System.in));\n }\n\n String s(){\n try{return readLine();}catch(IOException e){return \"\";}\n }\n\n String[] ss(){\n return s().split(\" \");\n }\n\n int i(){\n return Integer.parseInt(s());\n }\n\n int[] ii(){\n String[] ss = ss();\n int[] ii = new int[ss.length];\n for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);\n return ii;\n }\n\n ArrayList li(){\n String[] ss = ss();\n ArrayList li = new ArrayList<>();\n for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));\n return li;\n }\n\n long l(){\n return Long.parseLong(s());\n }\n\n long[] ll(){\n String[] ss = ss();\n long[] ll = new long[ss.length];\n for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);\n return ll;\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1577667949, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02818.html", "problem_id": "p02818", "resource_group": "high_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/Java/s129749867.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s129749867", "user_id": "u752907799"}, "prompt_components": {"gold_output": "0 2\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\n\npublic class Main{\n static MyReader in = new MyReader();\n static PrintWriter out = new PrintWriter(System.out);\n\n public static void main(String[] args){\n long A, B, K;\n {long[] a = in.ll(); A = a[0]; B = a[1]; K = a[2];}\n long i = Math.min(A, K);\n long j = Math.min(K-i, B);\n A -= i;\n B -= j;\n out.println(A+\" \"+B);\n out.flush();\n }\n\n static class MyReader extends BufferedReader{\n MyReader(){\n super(new InputStreamReader(System.in));\n }\n\n String s(){\n try{return readLine();}catch(IOException e){return \"\";}\n }\n\n String[] ss(){\n return s().split(\" \");\n }\n\n int i(){\n return Integer.parseInt(s());\n }\n\n int[] ii(){\n String[] ss = ss();\n int[] ii = new int[ss.length];\n for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);\n return ii;\n }\n\n ArrayList li(){\n String[] ss = ss();\n ArrayList li = new ArrayList<>();\n for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));\n return li;\n }\n\n long l(){\n return Long.parseLong(s());\n }\n\n long[] ll(){\n String[] ss = ss();\n long[] ll = new long[ss.length];\n for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);\n return ll;\n }\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A cookies, and Aoki has B cookies.\nTakahashi will do the following action K times:\n\nIf Takahashi has one or more cookies, eat one of his cookies.\n\nOtherwise, if Aoki has one or more cookies, eat one of Aoki's cookies.\n\nIf they both have no cookies, do nothing.\n\nIn the end, how many cookies will Takahashi and Aoki have, respectively?\n\nConstraints\n\n0 \\leq A \\leq 10^{12}\n\n0 \\leq B \\leq 10^{12}\n\n0 \\leq K \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the numbers of Takahashi's and Aoki's cookies after K actions.\n\nSample Input 1\n\n2 3 3\n\nSample Output 1\n\n0 2\n\nTakahashi will do the following:\n\nHe has two cookies, so he eats one of them.\n\nNow he has one cookie left, and he eats it.\n\nNow he has no cookies left, but Aoki has three, so Takahashi eats one of them.\n\nThus, in the end, Takahashi will have 0 cookies, and Aoki will have 2.\n\nSample Input 2\n\n500000000000 500000000000 1000000000000\n\nSample Output 2\n\n0 0\n\nWatch out for overflows.", "sample_input": "2 3 3\n"}, "reference_outputs": ["0 2\n"], "source_document_id": "p02818", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A cookies, and Aoki has B cookies.\nTakahashi will do the following action K times:\n\nIf Takahashi has one or more cookies, eat one of his cookies.\n\nOtherwise, if Aoki has one or more cookies, eat one of Aoki's cookies.\n\nIf they both have no cookies, do nothing.\n\nIn the end, how many cookies will Takahashi and Aoki have, respectively?\n\nConstraints\n\n0 \\leq A \\leq 10^{12}\n\n0 \\leq B \\leq 10^{12}\n\n0 \\leq K \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the numbers of Takahashi's and Aoki's cookies after K actions.\n\nSample Input 1\n\n2 3 3\n\nSample Output 1\n\n0 2\n\nTakahashi will do the following:\n\nHe has two cookies, so he eats one of them.\n\nNow he has one cookie left, and he eats it.\n\nNow he has no cookies left, but Aoki has three, so Takahashi eats one of them.\n\nThus, in the end, Takahashi will have 0 cookies, and Aoki will have 2.\n\nSample Input 2\n\n500000000000 500000000000 1000000000000\n\nSample Output 2\n\n0 0\n\nWatch out for overflows.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1543, "cpu_time_ms": 75, "memory_kb": 24532}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s311874869", "group_id": "codeNet:p02823", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tlong N = scan.nextLong();\n\t\tlong A = scan.nextLong();\n\t\tlong B = scan.nextLong();\n\n\t\tif ((B - A) % 2 == 0) System.out.println(Math.min((B - A) / 2, Math.min(B - 1, N - A)));\n\t\telse System.out.println(Math.min(B - 1, N - A));\n \t}\n}", "language": "Java", "metadata": {"date": 1590275939, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02823.html", "problem_id": "p02823", "resource_group": "high_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/Java/s311874869.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s311874869", "user_id": "u632131476"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tlong N = scan.nextLong();\n\t\tlong A = scan.nextLong();\n\t\tlong B = scan.nextLong();\n\n\t\tif ((B - A) % 2 == 0) System.out.println(Math.min((B - A) / 2, Math.min(B - 1, N - A)));\n\t\telse System.out.println(Math.min(B - 1, N - A));\n \t}\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": 365, "cpu_time_ms": 96, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s886603437", "group_id": "codeNet:p02823", "input_text": "import java.util.*;\n \npublic class Main {\n \n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n long n = Long.parseLong(sc.next());\n long a = Long.parseLong(sc.next());\n long b = Long.parseLong(sc.next());\n long ans = 0;\n if((b-a) % 2 == 0) {\n System.out.println((b-a)/2);\n }else {\n if(n-a < b-1) {\n ans = n-b+1;\n a += (n-b)+1;\n b = n;\n \n System.out.println(ans + (b-a)/2); \n }else {\n ans = a;\n b -= a-1;\n a = 1;\n System.out.println(ans + (b-a)/2); \n \n }\n }\n }\n \n}", "language": "Java", "metadata": {"date": 1590275419, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02823.html", "problem_id": "p02823", "resource_group": "high_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/Java/s886603437.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s886603437", "user_id": "u873167698"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*;\n \npublic class Main {\n \n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n long n = Long.parseLong(sc.next());\n long a = Long.parseLong(sc.next());\n long b = Long.parseLong(sc.next());\n long ans = 0;\n if((b-a) % 2 == 0) {\n System.out.println((b-a)/2);\n }else {\n if(n-a < b-1) {\n ans = n-b+1;\n a += (n-b)+1;\n b = n;\n \n System.out.println(ans + (b-a)/2); \n }else {\n ans = a;\n b -= a-1;\n a = 1;\n System.out.println(ans + (b-a)/2); \n \n }\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": 759, "cpu_time_ms": 91, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s624211110", "group_id": "codeNet:p02823", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n long n = sc.nextLong();\n long a = sc.nextLong();\n long b = sc.nextLong();\n long ans = (b - a) / 2;\n if(((b - a) % 2) == 1) ans = Math.min((a + (b - a - 1) / 2), (n - b + 1 + (b - a - 1) / 2)); \n System.out.println(ans);\n }\n}\n\n", "language": "Java", "metadata": {"date": 1585699066, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02823.html", "problem_id": "p02823", "resource_group": "high_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/Java/s624211110.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s624211110", "user_id": "u653981267"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n long n = sc.nextLong();\n long a = sc.nextLong();\n long b = sc.nextLong();\n long ans = (b - a) / 2;\n if(((b - a) % 2) == 1) ans = Math.min((a + (b - a - 1) / 2), (n - b + 1 + (b - a - 1) / 2)); \n System.out.println(ans);\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": 371, "cpu_time_ms": 95, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s477450762", "group_id": "codeNet:p02823", "input_text": "import java.util.Scanner;\n\npublic class Main implements Runnable {\n\n private static int MOD = 1_000_000_007;\n\n public static void main(String[] args) {\n // Run with 32MB stack\n Thread thread = new Thread(null, new Main(), \"\", 32 * 1024 * 1024);\n thread.start();\n }\n\n @Override\n public void run() {\n final Scanner scanner = new Scanner(System.in);\n solve(scanner);\n }\n\n static void solve(Scanner scanner) {\n long N = Long.parseLong(scanner.next());\n long A = Long.parseLong(scanner.next());\n long B = Long.parseLong(scanner.next());\n long abs = Math.abs(A - B);\n System.out.println((abs / 2) + (abs % 2) == 1 ? 1 : 0);\n }\n\n}\n", "language": "Java", "metadata": {"date": 1577585029, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02823.html", "problem_id": "p02823", "resource_group": "high_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/Java/s477450762.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s477450762", "user_id": "u241874341"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main implements Runnable {\n\n private static int MOD = 1_000_000_007;\n\n public static void main(String[] args) {\n // Run with 32MB stack\n Thread thread = new Thread(null, new Main(), \"\", 32 * 1024 * 1024);\n thread.start();\n }\n\n @Override\n public void run() {\n final Scanner scanner = new Scanner(System.in);\n solve(scanner);\n }\n\n static void solve(Scanner scanner) {\n long N = Long.parseLong(scanner.next());\n long A = Long.parseLong(scanner.next());\n long B = Long.parseLong(scanner.next());\n long abs = Math.abs(A - B);\n System.out.println((abs / 2) + (abs % 2) == 1 ? 1 : 0);\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": 718, "cpu_time_ms": 115, "memory_kb": 25300}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s315614220", "group_id": "codeNet:p02829", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int num1 = sc.nextInt();\n int num2 = sc.nextInt();\n System.out.println(6 - num1 - num2);\n \n }\n }", "language": "Java", "metadata": {"date": 1587874889, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02829.html", "problem_id": "p02829", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02829/input.txt", "sample_output_relpath": "derived/input_output/data/p02829/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02829/Java/s315614220.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s315614220", "user_id": "u073606136"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int num1 = sc.nextInt();\n int num2 = sc.nextInt();\n System.out.println(6 - num1 - num2);\n \n }\n }", "problem_context": "Score: 100 points\n\nProblem Statement\n\nTakahashi is solving quizzes. He has easily solved all but the last one.\n\nThe last quiz has three choices: 1, 2, and 3.\n\nWith his supernatural power, Takahashi has found out that the choices A and B are both wrong.\n\nPrint the correct choice for this problem.\n\nConstraints\n\nEach of the numbers A and B is 1, 2, or 3.\n\nA and B are different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\n\nOutput\n\nPrint the correct choice.\n\nSample Input 1\n\n3\n1\n\nSample Output 1\n\n2\n\nWhen we know 3 and 1 are both wrong, the correct choice is 2.\n\nSample Input 2\n\n1\n2\n\nSample Output 2\n\n3", "sample_input": "3\n1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02829", "source_text": "Score: 100 points\n\nProblem Statement\n\nTakahashi is solving quizzes. He has easily solved all but the last one.\n\nThe last quiz has three choices: 1, 2, and 3.\n\nWith his supernatural power, Takahashi has found out that the choices A and B are both wrong.\n\nPrint the correct choice for this problem.\n\nConstraints\n\nEach of the numbers A and B is 1, 2, or 3.\n\nA and B are different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\n\nOutput\n\nPrint the correct choice.\n\nSample Input 1\n\n3\n1\n\nSample Output 1\n\n2\n\nWhen we know 3 and 1 are both wrong, the correct choice is 2.\n\nSample Input 2\n\n1\n2\n\nSample Output 2\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 274, "cpu_time_ms": 95, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s709466331", "group_id": "codeNet:p02830", "input_text": "import java.util.*;\npublic class Main{\n\tpublic static void main(String []args){\n \tScanner sc = new Scanner(System.in) ;\n \tint n = sc.nextInt() ;\n \tsc.nextLine() ;\n //\tString s1 = sc.next() ;\n //\tString s2 = sc.next() ;\n String s[] = sc.nextLine().split(\" \") ;\n String s1 = s[0] ; \n String s2 = s[1] ;\n \n String res = \"\" ;\n \tfor(int i = 0 ; i < 2 *s1.length() ; i++) {\n \tif(i%2 == 0) res+=s1.charAt(i);\n \telse res+=s2.charAt(i) ; \n }\n System.out.println(res) ;\n }\n}", "language": "Java", "metadata": {"date": 1577432526, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02830.html", "problem_id": "p02830", "resource_group": "high_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/Java/s709466331.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s709466331", "user_id": "u631728946"}, "prompt_components": {"gold_output": "icpc\n", "input_to_evaluate": "import java.util.*;\npublic class Main{\n\tpublic static void main(String []args){\n \tScanner sc = new Scanner(System.in) ;\n \tint n = sc.nextInt() ;\n \tsc.nextLine() ;\n //\tString s1 = sc.next() ;\n //\tString s2 = sc.next() ;\n String s[] = sc.nextLine().split(\" \") ;\n String s1 = s[0] ; \n String s2 = s[1] ;\n \n String res = \"\" ;\n \tfor(int i = 0 ; i < 2 *s1.length() ; i++) {\n \tif(i%2 == 0) res+=s1.charAt(i);\n \telse res+=s2.charAt(i) ; \n }\n System.out.println(res) ;\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": 550, "cpu_time_ms": 122, "memory_kb": 23380}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s741283355", "group_id": "codeNet:p02830", "input_text": "import java.io.*;\nimport java.util.*;\npublic class Main {\n\tpublic static class FS {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tStringTokenizer st = new StringTokenizer(\"\");\n\t\tString next() {\n\t\t\twhile (!st.hasMoreTokens()) {\n\t\t\t\ttry { st = new StringTokenizer(br.readLine()); }\n\t\t\t\tcatch (Exception e) {}\n\t\t\t} return st.nextToken();\n\t\t}\n\t\tint nextInt() { return Integer.parseInt(next()); }\n\t\tlong nextLong() { return Long.parseLong(next()); }\n\t}\n\n\tpublic static int abs(int x) { if (x < 0) return -x; return x; }\n\n\tpublic static void main(String[] args) {\n\t\tFS in = new FS();\n\t\n\t\tint n = in.nextInt();\n\t\tchar[] A = in.next().toCharArray();\n\t\tchar[] B = in.next().toCharArray();\n\t\tchar[] C = new char[n << 1];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tC[2 * i] = A[i];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tC[2 * i + 1] = B[i];\n\t\tSystem.out.println((new String(C)));\n\t}\n}\n", "language": "Java", "metadata": {"date": 1577128525, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02830.html", "problem_id": "p02830", "resource_group": "high_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/Java/s741283355.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s741283355", "user_id": "u068098242"}, "prompt_components": {"gold_output": "icpc\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\npublic class Main {\n\tpublic static class FS {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tStringTokenizer st = new StringTokenizer(\"\");\n\t\tString next() {\n\t\t\twhile (!st.hasMoreTokens()) {\n\t\t\t\ttry { st = new StringTokenizer(br.readLine()); }\n\t\t\t\tcatch (Exception e) {}\n\t\t\t} return st.nextToken();\n\t\t}\n\t\tint nextInt() { return Integer.parseInt(next()); }\n\t\tlong nextLong() { return Long.parseLong(next()); }\n\t}\n\n\tpublic static int abs(int x) { if (x < 0) return -x; return x; }\n\n\tpublic static void main(String[] args) {\n\t\tFS in = new FS();\n\t\n\t\tint n = in.nextInt();\n\t\tchar[] A = in.next().toCharArray();\n\t\tchar[] B = in.next().toCharArray();\n\t\tchar[] C = new char[n << 1];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tC[2 * i] = A[i];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tC[2 * i + 1] = B[i];\n\t\tSystem.out.println((new String(C)));\n\t}\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": 891, "cpu_time_ms": 71, "memory_kb": 22868}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s966186863", "group_id": "codeNet:p02831", "input_text": "import java.util.*;\n\nclass Main {\n private static long gcd(long m, long n) {\n if(m < n) return gcd(n, m);\n if(n == 0) return m;\n return gcd(n, m % n);\n }\n\n public static void main (String[] args){\n Scanner stdIn = new Scanner(System.in);\n int A = stdIn.nextInt();\n int B = stdIn.nextInt();\n\n long C=0;\n\n C = A*B / gcd(A,B);\n System.out.print(C);\n\n\n\n }\n}", "language": "Java", "metadata": {"date": 1587914739, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02831.html", "problem_id": "p02831", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02831/input.txt", "sample_output_relpath": "derived/input_output/data/p02831/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02831/Java/s966186863.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s966186863", "user_id": "u969270038"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.util.*;\n\nclass Main {\n private static long gcd(long m, long n) {\n if(m < n) return gcd(n, m);\n if(n == 0) return m;\n return gcd(n, m % n);\n }\n\n public static void main (String[] args){\n Scanner stdIn = new Scanner(System.in);\n int A = stdIn.nextInt();\n int B = stdIn.nextInt();\n\n long C=0;\n\n C = A*B / gcd(A,B);\n System.out.print(C);\n\n\n\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is organizing a party.\n\nAt the party, each guest will receive one or more snack pieces.\n\nTakahashi predicts that the number of guests at this party will be A or B.\n\nFind the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.\n\nWe assume that a piece cannot be divided and distributed to multiple guests.\n\nConstraints\n\n1 \\leq A, B \\leq 10^5\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of pieces that can be evenly distributed to the guests in both of the cases with A guests and B guests.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n6\n\nWhen we have six snack pieces, each guest can take three pieces if we have two guests, and each guest can take two if we have three guests.\n\nSample Input 2\n\n123 456\n\nSample Output 2\n\n18696\n\nSample Input 3\n\n100000 99999\n\nSample Output 3\n\n9999900000", "sample_input": "2 3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02831", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is organizing a party.\n\nAt the party, each guest will receive one or more snack pieces.\n\nTakahashi predicts that the number of guests at this party will be A or B.\n\nFind the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.\n\nWe assume that a piece cannot be divided and distributed to multiple guests.\n\nConstraints\n\n1 \\leq A, B \\leq 10^5\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of pieces that can be evenly distributed to the guests in both of the cases with A guests and B guests.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n6\n\nWhen we have six snack pieces, each guest can take three pieces if we have two guests, and each guest can take two if we have three guests.\n\nSample Input 2\n\n123 456\n\nSample Output 2\n\n18696\n\nSample Input 3\n\n100000 99999\n\nSample Output 3\n\n9999900000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 432, "cpu_time_ms": 91, "memory_kb": 21716}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s510373728", "group_id": "codeNet:p02833", "input_text": "import java.util.Scanner;\npublic class Main {\n\tstatic long fn(long n) {\n\t\tif(n < 2) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn n*fn(n-2);\n\t}\n\n\n\n\n\tpublic static void main(String[] args) {\n\t\tScanner stdIn = new Scanner(System.in);\n\t\tlong n = stdIn.nextLong();\n\t\tif(n%2 != 0) {\n\t\t\tSystem.out.println(0);\n\t\t\tSystem.exit(0);\n\t\t}\n\n\t\tlong a = fn(n);\n\n\t\tlong cnt = 0;\n\n\t\twhile(a%10 == 0) {\n\t\t\tcnt++;\n\t\t\ta /=10;\n\t\t}\n\t\tSystem.out.println(cnt);\n\n\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1577077307, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02833.html", "problem_id": "p02833", "resource_group": "high_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/Java/s510373728.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s510373728", "user_id": "u015418292"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main {\n\tstatic long fn(long n) {\n\t\tif(n < 2) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn n*fn(n-2);\n\t}\n\n\n\n\n\tpublic static void main(String[] args) {\n\t\tScanner stdIn = new Scanner(System.in);\n\t\tlong n = stdIn.nextLong();\n\t\tif(n%2 != 0) {\n\t\t\tSystem.out.println(0);\n\t\t\tSystem.exit(0);\n\t\t}\n\n\t\tlong a = fn(n);\n\n\t\tlong cnt = 0;\n\n\t\twhile(a%10 == 0) {\n\t\t\tcnt++;\n\t\t\ta /=10;\n\t\t}\n\t\tSystem.out.println(cnt);\n\n\n\t}\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": 428, "cpu_time_ms": 660, "memory_kb": 282580}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s090343385", "group_id": "codeNet:p02833", "input_text": "import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tString Ns = sc.next();\n\t\tsc.close();\n\t\tlong N = Long.parseLong(Ns);\n\t\tlong cal = 1;\n\t\tlong now = N;\n\t\tfor (long n = 0; n < N ; n++){\n\t\t\tif (now == 0 || now == 1) {\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tcal = cal * now;\n\t\t\t\tnow = now - 2;\n\t\t\t}\n\t\t}\n\t\tlong zero = 0;\n\t\tlong zerocal = cal;\n\t\tfor (long i = 0;; i++){\n\t\t\tif (zerocal % 10 == 0){\n\t\t\t\tzerocal = zerocal / 10;\n\t\t\t\tzero++;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(zero);\n\t}}", "language": "Java", "metadata": {"date": 1577070334, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02833.html", "problem_id": "p02833", "resource_group": "high_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/Java/s090343385.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s090343385", "user_id": "u464576495"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tString Ns = sc.next();\n\t\tsc.close();\n\t\tlong N = Long.parseLong(Ns);\n\t\tlong cal = 1;\n\t\tlong now = N;\n\t\tfor (long n = 0; n < N ; n++){\n\t\t\tif (now == 0 || now == 1) {\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tcal = cal * now;\n\t\t\t\tnow = now - 2;\n\t\t\t}\n\t\t}\n\t\tlong zero = 0;\n\t\tlong zerocal = cal;\n\t\tfor (long i = 0;; i++){\n\t\t\tif (zerocal % 10 == 0){\n\t\t\t\tzerocal = zerocal / 10;\n\t\t\t\tzero++;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(zero);\n\t}}", "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": 554, "cpu_time_ms": 2108, "memory_kb": 21972}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s375931747", "group_id": "codeNet:p02835", "input_text": "import java.util.*;\nclass Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n int c = sc.nextInt();\n\n a = a + b + c;\n if(a>=22){\n System.out.println(\"bust\");\n } else {\n System.out.println(\"win\");\n }\n } \n}", "language": "Java", "metadata": {"date": 1587484452, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02835.html", "problem_id": "p02835", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02835/input.txt", "sample_output_relpath": "derived/input_output/data/p02835/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02835/Java/s375931747.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s375931747", "user_id": "u176982046"}, "prompt_components": {"gold_output": "win\n", "input_to_evaluate": "import java.util.*;\nclass Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n int c = sc.nextInt();\n\n a = a + b + c;\n if(a>=22){\n System.out.println(\"bust\");\n } else {\n System.out.println(\"win\");\n }\n } \n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven are three integers A_1, A_2, and A_3.\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nConstraints\n\n1 \\leq A_i \\leq 13 \\ \\ (i=1,2,3)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nSample Input 1\n\n5 7 9\n\nSample Output 1\n\nwin\n\n5+7+9=21, so print win.\n\nSample Input 2\n\n13 7 2\n\nSample Output 2\n\nbust\n\n13+7+2=22, so print bust.", "sample_input": "5 7 9\n"}, "reference_outputs": ["win\n"], "source_document_id": "p02835", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven are three integers A_1, A_2, and A_3.\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nConstraints\n\n1 \\leq A_i \\leq 13 \\ \\ (i=1,2,3)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nSample Input 1\n\n5 7 9\n\nSample Output 1\n\nwin\n\n5+7+9=21, so print win.\n\nSample Input 2\n\n13 7 2\n\nSample Output 2\n\nbust\n\n13+7+2=22, so print bust.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 368, "cpu_time_ms": 104, "memory_kb": 25172}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s374580345", "group_id": "codeNet:p02836", "input_text": "import java.util.*;\n\nclass Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String S = sc.next();\n int ans = 0;\n\n char[] C = S.toCharArray();\n for(int i = 0; i < (C.length+1)/2; i++) {\n if(C[i] != C[C.length-i-1]) {\n ans++;\n }\n }\n System.out.println(ans);\n }\n}", "language": "Java", "metadata": {"date": 1576793513, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02836.html", "problem_id": "p02836", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02836/input.txt", "sample_output_relpath": "derived/input_output/data/p02836/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02836/Java/s374580345.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s374580345", "user_id": "u919444715"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*;\n\nclass Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String S = sc.next();\n int ans = 0;\n\n char[] C = S.toCharArray();\n for(int i = 0; i < (C.length+1)/2; i++) {\n if(C[i] != C[C.length-i-1]) {\n ans++;\n }\n }\n System.out.println(ans);\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice.\n\nGiven is a string S. Find the minimum number of hugs needed to make S palindromic.\n\nConstraints\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of hugs needed to make S palindromic.\n\nSample Input 1\n\nredcoder\n\nSample Output 1\n\n1\n\nFor example, we can change the fourth character to o and get a palindrome redooder.\n\nSample Input 2\n\nvvvvvv\n\nSample Output 2\n\n0\n\nWe might need no hugs at all.\n\nSample Input 3\n\nabcdabc\n\nSample Output 3\n\n2", "sample_input": "redcoder\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02836", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice.\n\nGiven is a string S. Find the minimum number of hugs needed to make S palindromic.\n\nConstraints\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of hugs needed to make S palindromic.\n\nSample Input 1\n\nredcoder\n\nSample Output 1\n\n1\n\nFor example, we can change the fourth character to o and get a palindrome redooder.\n\nSample Input 2\n\nvvvvvv\n\nSample Output 2\n\n0\n\nWe might need no hugs at all.\n\nSample Input 3\n\nabcdabc\n\nSample Output 3\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 105, "memory_kb": 23636}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s612566553", "group_id": "codeNet:p02836", "input_text": "package palindrom;\n\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner input = new Scanner(System.in); \n String s = input.nextLine();\n int count = 0;\n int l = s.length() - 1;\n\n for(int i=0;i<=l;i++){\n if (s.charAt(i) != s.charAt(l)) {\n count++;\n i++;\n l--;\n\n }\n\n }\n System.out.println(count);\n }\n\n}\n", "language": "Java", "metadata": {"date": 1576215074, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02836.html", "problem_id": "p02836", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02836/input.txt", "sample_output_relpath": "derived/input_output/data/p02836/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02836/Java/s612566553.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s612566553", "user_id": "u708774407"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "package palindrom;\n\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner input = new Scanner(System.in); \n String s = input.nextLine();\n int count = 0;\n int l = s.length() - 1;\n\n for(int i=0;i<=l;i++){\n if (s.charAt(i) != s.charAt(l)) {\n count++;\n i++;\n l--;\n\n }\n\n }\n System.out.println(count);\n }\n\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice.\n\nGiven is a string S. Find the minimum number of hugs needed to make S palindromic.\n\nConstraints\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of hugs needed to make S palindromic.\n\nSample Input 1\n\nredcoder\n\nSample Output 1\n\n1\n\nFor example, we can change the fourth character to o and get a palindrome redooder.\n\nSample Input 2\n\nvvvvvv\n\nSample Output 2\n\n0\n\nWe might need no hugs at all.\n\nSample Input 3\n\nabcdabc\n\nSample Output 3\n\n2", "sample_input": "redcoder\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02836", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice.\n\nGiven is a string S. Find the minimum number of hugs needed to make S palindromic.\n\nConstraints\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of hugs needed to make S palindromic.\n\nSample Input 1\n\nredcoder\n\nSample Output 1\n\n1\n\nFor example, we can change the fourth character to o and get a palindrome redooder.\n\nSample Input 2\n\nvvvvvv\n\nSample Output 2\n\n0\n\nWe might need no hugs at all.\n\nSample Input 3\n\nabcdabc\n\nSample Output 3\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 77, "memory_kb": 21588}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s248434902", "group_id": "codeNet:p02837", "input_text": "import java.io.*;\nimport java.util.*;\n\npublic class Main{\n\n static int n;\n static int[] hu=new int[15];\n\n static int[][] a=new int[15][15];\n\n static boolean dfs(int i){\n for(int j=0;j-1&&hu[j]<0){\n hu[j]=a[i][j];\n if(i!=j&&a[i][j]==1&&!dfs(j)){\n return false;\n }\n }else if(hu[j]>-1&&hu[j]!=a[i][j]){\n return false;\n }\n }\n return true;\n }\n public static void main(String[] args)throws Exception{\n Scanner sc=new Scanner(System.in);\n n=sc.nextInt();\n int inp=0;\n for(int i=0;i q=new ArrayDeque<>();\n int ans=0,count=0;\n boolean flag=true;\n for(int bit=0;bit<(1<0){\n q.add(i);\n }\n }\n while(q.peek()!=null){\n int l=q.remove();\n if((flag=dfs(l))==false){\n q.clear();\n break;\n }\n }\n if(flag){\n for(int j=0;j-1&&hu[j]<0){\n hu[j]=a[i][j];\n if(i!=j&&a[i][j]==1&&!dfs(j)){\n return false;\n }\n }else if(hu[j]>-1&&hu[j]!=a[i][j]){\n return false;\n }\n }\n return true;\n }\n public static void main(String[] args)throws Exception{\n Scanner sc=new Scanner(System.in);\n n=sc.nextInt();\n int inp=0;\n for(int i=0;i q=new ArrayDeque<>();\n int ans=0,count=0;\n boolean flag=true;\n for(int bit=0;bit<(1<0){\n q.add(i);\n }\n }\n while(q.peek()!=null){\n int l=q.remove();\n if((flag=dfs(l))==false){\n q.clear();\n break;\n }\n }\n if(flag){\n for(int j=0;j 0) {\n A[i][j] = (int)(a%2);\n j++;\n a /= 2;\n }\n }\n\n long ans = 0;\n long pow = 1;\n for (int j = 0; j < 60; j++) {\n int num = 0;\n for (int i = 0; i < N; i++) {\n if (A[i][j] == 1) {\n num++;\n }\n }\n ans += ((num*(N-num))%MOD)*pow%MOD;\n ans %= MOD;\n\n pow *= 2;\n }\n\n System.out.println(ans);\n }\n}\n", "language": "Java", "metadata": {"date": 1575950655, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02838.html", "problem_id": "p02838", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02838/input.txt", "sample_output_relpath": "derived/input_output/data/p02838/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02838/Java/s899369945.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s899369945", "user_id": "u507706381"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.util.*;\n \npublic class Main {\n private static final long MOD = 1_000_000_007;\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int[][] A = new int[N][60];\n for (int i = 0; i < N; i++ ) {\n long a = sc.nextLong();\n int j = 0;\n while (a > 0) {\n A[i][j] = (int)(a%2);\n j++;\n a /= 2;\n }\n }\n\n long ans = 0;\n long pow = 1;\n for (int j = 0; j < 60; j++) {\n int num = 0;\n for (int i = 0; i < N; i++) {\n if (A[i][j] == 1) {\n num++;\n }\n }\n ans += ((num*(N-num))%MOD)*pow%MOD;\n ans %= MOD;\n\n pow *= 2;\n }\n\n System.out.println(ans);\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N integers. The i-th integer is A_i.\n\nFind \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nWhat is \\mbox{ XOR }?\n\nThe XOR of integers A and B, A \\mbox{ XOR } B, is defined as follows:\n\nWhen A \\mbox{ XOR } B is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise.\n\nFor example, 3 \\mbox{ XOR } 5 = 6. (In base two: 011 \\mbox{ XOR } 101 = 110.)\n\nConstraints\n\n2 \\leq N \\leq 3 \\times 10^5\n\n0 \\leq A_i < 2^{60}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the value \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n6\n\nWe have (1\\mbox{ XOR } 2)+(1\\mbox{ XOR } 3)+(2\\mbox{ XOR } 3)=3+2+1=6.\n\nSample Input 2\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 2\n\n237\n\nSample Input 3\n\n10\n3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820\n\nSample Output 3\n\n103715602\n\nPrint the sum modulo (10^9+7).", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02838", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N integers. The i-th integer is A_i.\n\nFind \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nWhat is \\mbox{ XOR }?\n\nThe XOR of integers A and B, A \\mbox{ XOR } B, is defined as follows:\n\nWhen A \\mbox{ XOR } B is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise.\n\nFor example, 3 \\mbox{ XOR } 5 = 6. (In base two: 011 \\mbox{ XOR } 101 = 110.)\n\nConstraints\n\n2 \\leq N \\leq 3 \\times 10^5\n\n0 \\leq A_i < 2^{60}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the value \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n6\n\nWe have (1\\mbox{ XOR } 2)+(1\\mbox{ XOR } 3)+(2\\mbox{ XOR } 3)=3+2+1=6.\n\nSample Input 2\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 2\n\n237\n\nSample Input 3\n\n10\n3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820\n\nSample Output 3\n\n103715602\n\nPrint the sum modulo (10^9+7).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 875, "cpu_time_ms": 1100, "memory_kb": 181856}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s967054828", "group_id": "codeNet:p02838", "input_text": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args) throws IOException {\n\t\ttry (BufferedReader in =\nnew BufferedReader(new InputStreamReader(System.in))) {\n\t\t\t\nString line;\nline = in.readLine();\n\nint n = Integer.parseInt(line);\n\nint[][] sayTable = new int[n][];\nfor (int i = 0; i < n; ++i) {\nline = in.readLine();\nint a = Integer.parseInt(line);\nsayTable[i] = new int[a];\nfor (int j = 0; j < a; ++j) {\nline = in.readLine();\nString[] params = line.split(\" \");\n\tint x = Integer.parseInt(params[0]) - 1;\n\tint y = Integer.parseInt(params[1]);\n\t\tsayTable[i][x] = y + 1;\n\t}\n}\nint maxHonest = search(sayTable, new int[n], 0);\nSystem.out.println(maxHonest);\n}\n\t}\n\n\tpublic static int search(\nint[][] sayTable, int[] honest, int i) {\n\n\t\tif (i >= sayTable.length) {\n\t\t\treturn (int) Arrays.stream(honest)\n.filter(say -> say == 2)\n.count();\n\t\t}\n\n\t\tint[] sayArray = sayTable[i];\n\n\t\tint count = 0;\n\t\tif (checkHonest(honest, sayArray)) {\n\tint[] copyHonest = Arrays.copyOf(honest, honest.length);\n\tsetHonest(copyHonest, sayArray);\nint c = search(sayTable, copyHonest, i + 1);\ncount = Math.max(c, count);\n\t}\n\t\tif (checkUnkind(honest, sayArray)) {\n\t\tint[] copyHonest = Arrays.copyOf(honest, honest.length);\nsetUnkind(copyHonest, sayArray);\nint c = search(sayTable, copyHonest, i + 1);\ncount = Math.max(c, count);\n\t}\nreturn count;\n}\n\n\n\n\tpublic static boolean checkHonest(int[] honest, int[] sayArray) {\n\t\tfor (int i = 0; i < sayArray.length; ++i) {\n\t\t\tint say = sayArray[i];\n\t\t\tif (say <= 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tint h = honest[i];\n\t\t\tif (h != 0 || h != say) {\nreturn false;\t\t\t\t\n\t\t\t}\n\t\t}\nreturn true;\n\t}\n\n\tpublic static boolean checkUnkind(int[] honest, int[] sayArray) {\n\t\tfor (int i = 0; i < sayArray.length; ++i) {\n\t\t\tint say = sayArray[i];\n\t\t\tif (say <= 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tint h = honest[i];\n\t\t\tif (h != 0 || h == say) {\nreturn false;\t\t\t\t\n\t\t\t}\n\t\t}\nreturn true;\n\t}\n\npublic static void setHonest(int[] honest, int[] sayArray) {\n\t\tfor (int i = 0; i < sayArray.length; ++i) {\n\t\t\tint say = sayArray[i];\n\t\t\tif (say == 1) {\n\t\t\t\thonest[i] = 1;\n\t\t\t} else if (say == 2) {\n\t\t\t\thonest[i] = 2;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static void setUnkind(int[] honest, int[] sayArray) {\n\t\tfor (int i = 0; i < sayArray.length; ++i) {\n\t\t\tint say = sayArray[i];\n\t\t\tif (say == 1) {\n\t\t\t\thonest[i] = 2;\n\t\t\t} else if (say == 2) {\n\t\t\t\thonest[i] = 1;\n\t\t\t}\n\t\t}\n\t}\n}\n\n", "language": "Java", "metadata": {"date": 1575861284, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02838.html", "problem_id": "p02838", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02838/input.txt", "sample_output_relpath": "derived/input_output/data/p02838/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02838/Java/s967054828.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s967054828", "user_id": "u006883624"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args) throws IOException {\n\t\ttry (BufferedReader in =\nnew BufferedReader(new InputStreamReader(System.in))) {\n\t\t\t\nString line;\nline = in.readLine();\n\nint n = Integer.parseInt(line);\n\nint[][] sayTable = new int[n][];\nfor (int i = 0; i < n; ++i) {\nline = in.readLine();\nint a = Integer.parseInt(line);\nsayTable[i] = new int[a];\nfor (int j = 0; j < a; ++j) {\nline = in.readLine();\nString[] params = line.split(\" \");\n\tint x = Integer.parseInt(params[0]) - 1;\n\tint y = Integer.parseInt(params[1]);\n\t\tsayTable[i][x] = y + 1;\n\t}\n}\nint maxHonest = search(sayTable, new int[n], 0);\nSystem.out.println(maxHonest);\n}\n\t}\n\n\tpublic static int search(\nint[][] sayTable, int[] honest, int i) {\n\n\t\tif (i >= sayTable.length) {\n\t\t\treturn (int) Arrays.stream(honest)\n.filter(say -> say == 2)\n.count();\n\t\t}\n\n\t\tint[] sayArray = sayTable[i];\n\n\t\tint count = 0;\n\t\tif (checkHonest(honest, sayArray)) {\n\tint[] copyHonest = Arrays.copyOf(honest, honest.length);\n\tsetHonest(copyHonest, sayArray);\nint c = search(sayTable, copyHonest, i + 1);\ncount = Math.max(c, count);\n\t}\n\t\tif (checkUnkind(honest, sayArray)) {\n\t\tint[] copyHonest = Arrays.copyOf(honest, honest.length);\nsetUnkind(copyHonest, sayArray);\nint c = search(sayTable, copyHonest, i + 1);\ncount = Math.max(c, count);\n\t}\nreturn count;\n}\n\n\n\n\tpublic static boolean checkHonest(int[] honest, int[] sayArray) {\n\t\tfor (int i = 0; i < sayArray.length; ++i) {\n\t\t\tint say = sayArray[i];\n\t\t\tif (say <= 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tint h = honest[i];\n\t\t\tif (h != 0 || h != say) {\nreturn false;\t\t\t\t\n\t\t\t}\n\t\t}\nreturn true;\n\t}\n\n\tpublic static boolean checkUnkind(int[] honest, int[] sayArray) {\n\t\tfor (int i = 0; i < sayArray.length; ++i) {\n\t\t\tint say = sayArray[i];\n\t\t\tif (say <= 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tint h = honest[i];\n\t\t\tif (h != 0 || h == say) {\nreturn false;\t\t\t\t\n\t\t\t}\n\t\t}\nreturn true;\n\t}\n\npublic static void setHonest(int[] honest, int[] sayArray) {\n\t\tfor (int i = 0; i < sayArray.length; ++i) {\n\t\t\tint say = sayArray[i];\n\t\t\tif (say == 1) {\n\t\t\t\thonest[i] = 1;\n\t\t\t} else if (say == 2) {\n\t\t\t\thonest[i] = 2;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static void setUnkind(int[] honest, int[] sayArray) {\n\t\tfor (int i = 0; i < sayArray.length; ++i) {\n\t\t\tint say = sayArray[i];\n\t\t\tif (say == 1) {\n\t\t\t\thonest[i] = 2;\n\t\t\t} else if (say == 2) {\n\t\t\t\thonest[i] = 1;\n\t\t\t}\n\t\t}\n\t}\n}\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N integers. The i-th integer is A_i.\n\nFind \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nWhat is \\mbox{ XOR }?\n\nThe XOR of integers A and B, A \\mbox{ XOR } B, is defined as follows:\n\nWhen A \\mbox{ XOR } B is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise.\n\nFor example, 3 \\mbox{ XOR } 5 = 6. (In base two: 011 \\mbox{ XOR } 101 = 110.)\n\nConstraints\n\n2 \\leq N \\leq 3 \\times 10^5\n\n0 \\leq A_i < 2^{60}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the value \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n6\n\nWe have (1\\mbox{ XOR } 2)+(1\\mbox{ XOR } 3)+(2\\mbox{ XOR } 3)=3+2+1=6.\n\nSample Input 2\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 2\n\n237\n\nSample Input 3\n\n10\n3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820\n\nSample Output 3\n\n103715602\n\nPrint the sum modulo (10^9+7).", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02838", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N integers. The i-th integer is A_i.\n\nFind \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nWhat is \\mbox{ XOR }?\n\nThe XOR of integers A and B, A \\mbox{ XOR } B, is defined as follows:\n\nWhen A \\mbox{ XOR } B is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise.\n\nFor example, 3 \\mbox{ XOR } 5 = 6. (In base two: 011 \\mbox{ XOR } 101 = 110.)\n\nConstraints\n\n2 \\leq N \\leq 3 \\times 10^5\n\n0 \\leq A_i < 2^{60}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the value \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n6\n\nWe have (1\\mbox{ XOR } 2)+(1\\mbox{ XOR } 3)+(2\\mbox{ XOR } 3)=3+2+1=6.\n\nSample Input 2\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 2\n\n237\n\nSample Input 3\n\n10\n3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820\n\nSample Output 3\n\n103715602\n\nPrint the sum modulo (10^9+7).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2368, "cpu_time_ms": 231, "memory_kb": 137208}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s927103933", "group_id": "codeNet:p02842", "input_text": "import java.util.Scanner;\n \npublic class Main {\n public static void main(String args[]){\n Scanner stdIn = new Scanner(System.in);\n \n int n = stdIn.nextInt();\n //int d1 = stdIn.nextInt();\n //int x = stdIn.nextInt();\n //int num[] = new int[3];\n //String s = stdIn.next();\n //char c[] = s.toCharArray();\n //int sum = 0;\n boolean flag = false;\n //for(int i = 0; i < s.length(); i++){\n //}\n \n for(int i = 1; i < 54001; i++){\n if(i * 1.08 == n){\n System.out.println(i);\n flag = true;\n break;\n }\n }\n \n if(!flag){\n System.out.println(\":(\");\n }\n \n //System.out.println();\n //System.out.print();\n }\n}", "language": "Java", "metadata": {"date": 1575252550, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02842.html", "problem_id": "p02842", "resource_group": "high_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/Java/s927103933.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s927103933", "user_id": "u672402312"}, "prompt_components": {"gold_output": "400\n", "input_to_evaluate": "import java.util.Scanner;\n \npublic class Main {\n public static void main(String args[]){\n Scanner stdIn = new Scanner(System.in);\n \n int n = stdIn.nextInt();\n //int d1 = stdIn.nextInt();\n //int x = stdIn.nextInt();\n //int num[] = new int[3];\n //String s = stdIn.next();\n //char c[] = s.toCharArray();\n //int sum = 0;\n boolean flag = false;\n //for(int i = 0; i < s.length(); i++){\n //}\n \n for(int i = 1; i < 54001; i++){\n if(i * 1.08 == n){\n System.out.println(i);\n flag = true;\n break;\n }\n }\n \n if(!flag){\n System.out.println(\":(\");\n }\n \n //System.out.println();\n //System.out.print();\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": 821, "cpu_time_ms": 95, "memory_kb": 23764}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s716202540", "group_id": "codeNet:p02843", "input_text": "import java.util.*;\npublic class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint check = 0;\n\t\tint a = n/100;\n\t\tint b = n%100;\n\t\tif(a>=b){\n\t\t check = 1;\n\t\t}\n\t\tSystem.out.println(check);\n }\n}", "language": "Java", "metadata": {"date": 1593716027, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02843.html", "problem_id": "p02843", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02843/input.txt", "sample_output_relpath": "derived/input_output/data/p02843/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02843/Java/s716202540.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s716202540", "user_id": "u659156129"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*;\npublic class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint check = 0;\n\t\tint a = n/100;\n\t\tint b = n%100;\n\t\tif(a>=b){\n\t\t check = 1;\n\t\t}\n\t\tSystem.out.println(check);\n }\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nAtCoder Mart sells 1000000 of each of the six items below:\n\nRiceballs, priced at 100 yen (the currency of Japan) each\n\nSandwiches, priced at 101 yen each\n\nCookies, priced at 102 yen each\n\nCakes, priced at 103 yen each\n\nCandies, priced at 104 yen each\n\nComputers, priced at 105 yen each\n\nTakahashi wants to buy some of them that cost exactly X yen in total.\nDetermine whether this is possible.\n\n(Ignore consumption tax.)\n\nConstraints\n\n1 \\leq X \\leq 100000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf it is possible to buy some set of items that cost exactly X yen in total, print 1; otherwise, print 0.\n\nSample Input 1\n\n615\n\nSample Output 1\n\n1\n\nFor example, we can buy one of each kind of item, which will cost 100+101+102+103+104+105=615 yen in total.\n\nSample Input 2\n\n217\n\nSample Output 2\n\n0\n\nNo set of items costs 217 yen in total.", "sample_input": "615\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02843", "source_text": "Score: 300 points\n\nProblem Statement\n\nAtCoder Mart sells 1000000 of each of the six items below:\n\nRiceballs, priced at 100 yen (the currency of Japan) each\n\nSandwiches, priced at 101 yen each\n\nCookies, priced at 102 yen each\n\nCakes, priced at 103 yen each\n\nCandies, priced at 104 yen each\n\nComputers, priced at 105 yen each\n\nTakahashi wants to buy some of them that cost exactly X yen in total.\nDetermine whether this is possible.\n\n(Ignore consumption tax.)\n\nConstraints\n\n1 \\leq X \\leq 100000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf it is possible to buy some set of items that cost exactly X yen in total, print 1; otherwise, print 0.\n\nSample Input 1\n\n615\n\nSample Output 1\n\n1\n\nFor example, we can buy one of each kind of item, which will cost 100+101+102+103+104+105=615 yen in total.\n\nSample Input 2\n\n217\n\nSample Output 2\n\n0\n\nNo set of items costs 217 yen in total.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 123, "memory_kb": 35680}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s957262601", "group_id": "codeNet:p02843", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n \n int X = sc.nextInt();\n int limit = X/100;\n \n if (X%100 <= limit * 5){\n System.out.println('1');\n }\n \n else{\n System.out.println('0');\n }\n \n }\n}\n", "language": "Java", "metadata": {"date": 1591885503, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02843.html", "problem_id": "p02843", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02843/input.txt", "sample_output_relpath": "derived/input_output/data/p02843/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02843/Java/s957262601.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s957262601", "user_id": "u250978519"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n \n int X = sc.nextInt();\n int limit = X/100;\n \n if (X%100 <= limit * 5){\n System.out.println('1');\n }\n \n else{\n System.out.println('0');\n }\n \n }\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nAtCoder Mart sells 1000000 of each of the six items below:\n\nRiceballs, priced at 100 yen (the currency of Japan) each\n\nSandwiches, priced at 101 yen each\n\nCookies, priced at 102 yen each\n\nCakes, priced at 103 yen each\n\nCandies, priced at 104 yen each\n\nComputers, priced at 105 yen each\n\nTakahashi wants to buy some of them that cost exactly X yen in total.\nDetermine whether this is possible.\n\n(Ignore consumption tax.)\n\nConstraints\n\n1 \\leq X \\leq 100000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf it is possible to buy some set of items that cost exactly X yen in total, print 1; otherwise, print 0.\n\nSample Input 1\n\n615\n\nSample Output 1\n\n1\n\nFor example, we can buy one of each kind of item, which will cost 100+101+102+103+104+105=615 yen in total.\n\nSample Input 2\n\n217\n\nSample Output 2\n\n0\n\nNo set of items costs 217 yen in total.", "sample_input": "615\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02843", "source_text": "Score: 300 points\n\nProblem Statement\n\nAtCoder Mart sells 1000000 of each of the six items below:\n\nRiceballs, priced at 100 yen (the currency of Japan) each\n\nSandwiches, priced at 101 yen each\n\nCookies, priced at 102 yen each\n\nCakes, priced at 103 yen each\n\nCandies, priced at 104 yen each\n\nComputers, priced at 105 yen each\n\nTakahashi wants to buy some of them that cost exactly X yen in total.\nDetermine whether this is possible.\n\n(Ignore consumption tax.)\n\nConstraints\n\n1 \\leq X \\leq 100000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf it is possible to buy some set of items that cost exactly X yen in total, print 1; otherwise, print 0.\n\nSample Input 1\n\n615\n\nSample Output 1\n\n1\n\nFor example, we can buy one of each kind of item, which will cost 100+101+102+103+104+105=615 yen in total.\n\nSample Input 2\n\n217\n\nSample Output 2\n\n0\n\nNo set of items costs 217 yen in total.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 373, "cpu_time_ms": 101, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s124012381", "group_id": "codeNet:p02843", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) throws Exception {\n Scanner stdin = new Scanner(System.in);\n int list[] = {100,101,102,103,104,105};\n \n int X = stdin.nextInt();\n int flag=0;\n\n for(int i=0;i<6;i++) {\n \tif(X%list[i] == 0) {\n \t\tSystem.out.print(\"1\");\n \t\tflag=1;\n \t\tbreak;\n \t}\n \tfor(int j=list.length-1;i> ptnList = new ArrayList<>();\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tString s = sc.next();\n\t\tsc.close();\n\n\t\tList pinList = new ArrayList<>();\n\n\t\tfor (int i = 0; i < n - 2; i++) {\n\t\t\tfor (int j = 1; j < n - 1; j++) {\n\t\t\t\tfor (int k = 2; k < n; k++) {\n\n\t\t\t\t\tif (i == j || j == k || i == k) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (i > j || j > k) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tString pin = s.substring(i, i + 1) + s.substring(j, j + 1) + s.substring(k, k + 1);\n\t\t\t\t\tpinList.add(pin);\n\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tList distinctList = pinList.stream().distinct().collect(Collectors.toList());\n\n\t\tSystem.out.println(distinctList.size());\n\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1575257368, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02844.html", "problem_id": "p02844", "resource_group": "high_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/Java/s334117608.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s334117608", "user_id": "u674330862"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.List;\nimport java.util.Scanner;\nimport java.util.stream.Collectors;\n\npublic class Main {\n\n\tstatic List> ptnList = new ArrayList<>();\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tString s = sc.next();\n\t\tsc.close();\n\n\t\tList pinList = new ArrayList<>();\n\n\t\tfor (int i = 0; i < n - 2; i++) {\n\t\t\tfor (int j = 1; j < n - 1; j++) {\n\t\t\t\tfor (int k = 2; k < n; k++) {\n\n\t\t\t\t\tif (i == j || j == k || i == k) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (i > j || j > k) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tString pin = s.substring(i, i + 1) + s.substring(j, j + 1) + s.substring(k, k + 1);\n\t\t\t\t\tpinList.add(pin);\n\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tList distinctList = pinList.stream().distinct().collect(Collectors.toList());\n\n\t\tSystem.out.println(distinctList.size());\n\n\t}\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": 873, "cpu_time_ms": 2112, "memory_kb": 453836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s495884061", "group_id": "codeNet:p02847", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n List week = Arrays.asList(\"SUN\", \"MON\", \"TUE\", \"WED\", \"THU\", \"FRI\", \"SAT\");\n System.out.println(7 - week.indexOf(sc.next()));\n }\n}", "language": "Java", "metadata": {"date": 1574647884, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02847.html", "problem_id": "p02847", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02847/input.txt", "sample_output_relpath": "derived/input_output/data/p02847/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02847/Java/s495884061.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s495884061", "user_id": "u531730314"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n List week = Arrays.asList(\"SUN\", \"MON\", \"TUE\", \"WED\", \"THU\", \"FRI\", \"SAT\");\n System.out.println(7 - week.indexOf(sc.next()));\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is a string S representing the day of the week today.\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.\n\nAfter how many days is the next Sunday (tomorrow or later)?\n\nConstraints\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of days before the next Sunday.\n\nSample Input 1\n\nSAT\n\nSample Output 1\n\n1\n\nIt is Saturday today, and tomorrow will be Sunday.\n\nSample Input 2\n\nSUN\n\nSample Output 2\n\n7\n\nIt is Sunday today, and seven days later, it will be Sunday again.", "sample_input": "SAT\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02847", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is a string S representing the day of the week today.\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.\n\nAfter how many days is the next Sunday (tomorrow or later)?\n\nConstraints\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of days before the next Sunday.\n\nSample Input 1\n\nSAT\n\nSample Output 1\n\n1\n\nIt is Saturday today, and tomorrow will be Sunday.\n\nSample Input 2\n\nSUN\n\nSample Output 2\n\n7\n\nIt is Sunday today, and seven days later, it will be Sunday again.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 287, "cpu_time_ms": 110, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s673698552", "group_id": "codeNet:p02847", "input_text": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.lang.reflect.Array;\nimport java.math.BigDecimal;\nimport java.math.BigInteger;\nimport java.util.ArrayDeque;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.Comparator;\nimport java.util.HashMap;\nimport java.util.Map.Entry;\nimport java.util.NoSuchElementException;\nimport java.util.Set;\nimport java.util.TreeMap;\nimport java.util.TreeSet;\n\npublic class Main {\n\tprivate static void solve() {\n\t\tString s = \"SUN,MON,TUE,WED,THU,FRI,SAT,\";\n\t\tint n = s.indexOf(ns() + \",\") / 4;\n\t\tfor (int i = 1; i <= 7; i++) {\n\t\t\tif((n+i)%7==0)kil(i);\n\t\t}\n\t}\n\n\tstatic int min(int a, int b) {\n\t\treturn a < b ? a : b;\n\t}\n\n\tstatic long min(long a, long b) {\n\t\treturn a < b ? a : b;\n\t}\n\n\tstatic > A min(A a, A b) {\n\t\treturn a.compareTo(b) < 0 ? a : b;\n\t}\n\n\tstatic int max(int a, int b) {\n\t\treturn a > b ? a : b;\n\t}\n\n\tstatic long max(long a, long b) {\n\t\treturn a > b ? a : b;\n\t}\n\n\tstatic > A max(A a, A b) {\n\t\treturn a.compareTo(b) > 0 ? a : b;\n\t}\n\n\tstatic int clamp(int a, int min, int max) {\n\t\treturn a < min ? min : a > max ? max : a;\n\t}\n\n\tstatic long clamp(long a, long min, long max) {\n\t\treturn a < min ? min : a > max ? max : a;\n\t}\n\n\tstatic int abs(int a) {\n\t\treturn a < 0 ? -a : a;\n\t}\n\n\tstatic long abs(long a) {\n\t\treturn a < 0 ? -a : a;\n\t}\n\n\tstatic > A clamp(A a, A min, A max) {\n\t\treturn a.compareTo(min) < 0 ? min : a.compareTo(max) > 0 ? max : a;\n\t}\n\n\tstatic void out(String val) {\n\t\tIO.out(val);\n\t}\n\n\tstatic void out(Object val) {\n\t\tIO.out(String.valueOf(val));\n\t}\n\n\tstatic void out(int val) {\n\t\tIO.out(String.valueOf(val));\n\t}\n\n\tstatic void out(long val) {\n\t\tIO.out(String.valueOf(val));\n\t}\n\n\tstatic void out(char val) {\n\t\tIO.out(String.valueOf(val));\n\t}\n\n\tstatic void out(double val) {\n\t\tIO.out(Double.isFinite(val) ? BigDecimal.valueOf(val).toPlainString() : String.valueOf(val));\n\t}\n\n\tstatic void out(boolean val) {\n\t\tIO.out(val ? \"true\" : \"false\");\n\t}\n\n\tstatic void outn(String val) {\n\t\tIO.outn(val);\n\t}\n\n\tstatic void outn(Object val) {\n\t\tIO.outn(String.valueOf(val));\n\t}\n\n\tstatic void outn(int val) {\n\t\tIO.outn(String.valueOf(val));\n\t}\n\n\tstatic void outn(long val) {\n\t\tIO.outn(String.valueOf(val));\n\t}\n\n\tstatic void outn(char val) {\n\t\tIO.outn(String.valueOf(val));\n\t}\n\n\tstatic void outn(double val) {\n\t\tIO.outn(Double.isFinite(val) ? BigDecimal.valueOf(val).toPlainString() : String.valueOf(val));\n\t}\n\n\tstatic void outn(boolean val) {\n\t\tIO.outn(val ? \"true\" : \"false\");\n\t}\n\n\tstatic void kil(String val) {\n\t\tIO.out(val);\n\t\tIO.flush();\n\t\tSystem.exit(0);\n\t}\n\n\tstatic void kil(Object val) {\n\t\tIO.out(String.valueOf(val));\n\t\tIO.flush();\n\t\tSystem.exit(0);\n\t}\n\n\tstatic void kil(int val) {\n\t\tIO.out(String.valueOf(val));\n\t\tIO.flush();\n\t\tSystem.exit(0);\n\t}\n\n\tstatic void kil(long val) {\n\t\tIO.out(String.valueOf(val));\n\t\tIO.flush();\n\t\tSystem.exit(0);\n\t}\n\n\tstatic void kil(char val) {\n\t\tIO.out(String.valueOf(val));\n\t\tIO.flush();\n\t\tSystem.exit(0);\n\t}\n\n\tstatic void kil(double val) {\n\t\tIO.out(Double.isFinite(val) ? BigDecimal.valueOf(val).toPlainString() : String.valueOf(val));\n\t\tIO.flush();\n\t\tSystem.exit(0);\n\t}\n\n\tstatic void kil(boolean val) {\n\t\tIO.out(val ? \"true\" : \"false\");\n\t\tIO.flush();\n\t\tSystem.exit(0);\n\t}\n\n\tstatic String ns() {\n\t\treturn IO.next();\n\t}\n\n\tstatic int ni() {\n\t\treturn IO.nextInt();\n\t}\n\n\tstatic long nl() {\n\t\treturn IO.nextLong();\n\t}\n\n\tstatic double nd() {\n\t\treturn IO.nextDouble();\n\t}\n\n\tstatic char nc() {\n\t\treturn IO.nextChar();\n\t}\n\n\tstatic String[] nss(int n) {\n\t\tString[] as = new String[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tas[i] = IO.next();\n\t\t}\n\t\treturn as;\n\t}\n\n\tstatic int[] nis(int n) {\n\t\tint[] as = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tas[i] = IO.nextInt();\n\t\t}\n\t\treturn as;\n\t}\n\n\tstatic long[] nls(int n) {\n\t\tlong[] as = new long[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tas[i] = IO.nextLong();\n\t\t}\n\t\treturn as;\n\t}\n\n\tstatic double[] nds(int n) {\n\t\tdouble[] as = new double[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tas[i] = IO.nextDouble();\n\t\t}\n\t\treturn as;\n\t}\n\n\tstatic char[] ncs(int n) {\n\t\tchar[] as = new char[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tas[i] = IO.nextChar();\n\t\t}\n\t\treturn as;\n\t}\n\n\tstatic String[][] nss2(int n, int m) {\n\t\tString[][] as = new String[n][m];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tfor (int j = 0; j < m; j++) {\n\t\t\t\tas[i][j] = IO.next();\n\t\t\t}\n\t\t}\n\t\treturn as;\n\t}\n\n\tstatic int[][] nis2(int n, int m) {\n\t\tint[][] as = new int[n][m];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tfor (int j = 0; j < m; j++) {\n\t\t\t\tas[i][j] = IO.nextInt();\n\t\t\t}\n\t\t}\n\t\treturn as;\n\t}\n\n\tstatic long[][] nls2(int n, int m) {\n\t\tlong[][] as = new long[n][m];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tfor (int j = 0; j < m; j++) {\n\t\t\t\tas[i][j] = IO.nextLong();\n\t\t\t}\n\t\t}\n\t\treturn as;\n\t}\n\n\tstatic double[][] nds2(int n, int m) {\n\t\tdouble[][] as = new double[n][m];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tfor (int j = 0; j < m; j++) {\n\t\t\t\tas[i][j] = IO.nextDouble();\n\t\t\t}\n\t\t}\n\t\treturn as;\n\t}\n\n\tstatic char[][] ncs2(int n, int m) {\n\t\tchar[][] as = new char[n][m];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tfor (int j = 0; j < m; j++) {\n\t\t\t\tas[i][j] = IO.nextChar();\n\t\t\t}\n\t\t}\n\t\treturn as;\n\t}\n\n\tstatic int parseInt(String val) {\n\t\treturn Integer.parseInt(val);\n\t}\n\n\tstatic long parseLong(String val) {\n\t\treturn Long.parseLong(val);\n\t}\n\n\tpublic static void main(String[] args) {\n\t\ttry {\n\t\t\tsolve();\n\t\t\tIO.flush();\n\t\t} catch (NumberFormatException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (OutOfMemoryError e) {\n\t\t\te.printStackTrace(); // this will be detected as RE\n\t\t}\n\t}\n}\n\nfinal class IO {\n\tprivate static final InputStream in = System.in;\n\tprivate static final PrintWriter out = new PrintWriter(System.out, false);\n\tprivate static final byte[] buffer = new byte[1024];\n\tprivate static int ptr = 0;\n\tprivate static int len = 0;\n\n\tprivate static boolean hasNextByte() {\n\t\tif (ptr < len)\n\t\t\treturn true;\n\t\tptr = 0;\n\t\ttry {\n\t\t\tlen = in.read(buffer);\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn len > 0;\n\t}\n\n\tprivate static int readByte() {\n\t\tif (hasNextByte())\n\t\t\treturn buffer[ptr++];\n\t\telse\n\t\t\treturn -1;\n\t}\n\n\tstatic boolean hasNext() {\n\t\tbyte c;\n\t\twhile (hasNextByte() && ((c = buffer[ptr]) < '!' || c > '~'))\n\t\t\tptr++;\n\t\treturn hasNextByte();\n\t}\n\n\tstatic String next() {\n\t\tif (!hasNext())\n\t\t\tthrow new NoSuchElementException();\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint b = readByte();\n\t\twhile (b >= '!' && b <= '~') {\n\t\t\tsb.append((char) b);\n\t\t\tb = readByte();\n\t\t}\n\t\treturn sb.toString();\n\t}\n\n\tstatic char nextChar() {\n\t\tif (!hasNext())\n\t\t\tthrow new NoSuchElementException();\n\t\treturn (char) readByte();\n\t}\n\n\tstatic long nextLong() {\n\t\tif (!hasNext())\n\t\t\tthrow new NoSuchElementException();\n\t\tlong n = 0;\n\t\tint sign = 1;\n\t\tint b = readByte();\n\t\tif (b == '-') {\n\t\t\tsign = -1;\n\t\t\tb = readByte();\n\t\t}\n\t\tif (b < '0' || '9' < b)\n\t\t\tthrow new NumberFormatException();\n\t\twhile (true) {\n\t\t\tif ('0' <= b && b <= '9')\n\t\t\t\tn = n * 10 + b - '0';\n\t\t\telse if (b == -1 || b < '!' || b > '~')\n\t\t\t\treturn n * sign;\n\t\t\telse\n\t\t\t\tthrow new NumberFormatException();\n\t\t\tb = readByte();\n\t\t}\n\t}\n\n\tstatic int nextInt() {\n\t\tif (!hasNext())\n\t\t\tthrow new NoSuchElementException();\n\t\tint n = 0;\n\t\tint sign = 1;\n\t\tint b = readByte();\n\t\tif (b == '-') {\n\t\t\tsign = -1;\n\t\t\tb = readByte();\n\t\t}\n\t\tif (b < '0' || '9' < b)\n\t\t\tthrow new NumberFormatException();\n\t\twhile (true) {\n\t\t\tif ('0' <= b && b <= '9')\n\t\t\t\tn = n * 10 + b - '0';\n\t\t\telse if (b == -1 || b < '!' || b > '~')\n\t\t\t\treturn n * sign;\n\t\t\telse\n\t\t\t\tthrow new NumberFormatException();\n\t\t\tb = readByte();\n\t\t}\n\t}\n\n\tstatic double nextDouble() {\n\t\treturn Double.parseDouble(next());\n\t}\n\n\tstatic void out(String val) {\n\t\tout.println(val);\n\t}\n\n\tstatic void outn(String val) {\n\t\tout.print(val);\n\t}\n\n\tstatic void flush() {\n\t\tout.flush();\n\t}\n}\n\n// TODO: paste library here\n\nclass MS {\n\tprivate TreeMap tm;\n\n\tMS() {\n\t\ttm = new TreeMap();\n\t}\n\n\tMS(Comparator comp) {\n\t\ttm = new TreeMap(comp);\n\t}\n\n\tvoid add(A a, long num) {\n\t\tif (tm.containsKey(a))\n\t\t\ttm.put(a, tm.get(a) + num);\n\t\telse\n\t\t\ttm.put(a, num);\n\t}\n\n\tvoid add(A a) {\n\t\tadd(a, 1);\n\t}\n\n\tlong remove(A a, long num) {\n\t\tif (tm.containsKey(a)) {\n\t\t\tlong n = tm.get(a);\n\t\t\tif (n <= num) {\n\t\t\t\ttm.remove(a);\n\t\t\t\treturn n;\n\t\t\t}\n\t\t\ttm.put(a, n - num);\n\t\t\treturn num;\n\t\t}\n\t\treturn 0;\n\t}\n\n\tboolean remove(A a) {\n\t\treturn remove(a, 1) == 1;\n\t}\n\n\tlong removeAll(A a) {\n\t\treturn remove(a, Long.MAX_VALUE);\n\t}\n\n\tlong num(A a) {\n\t\treturn tm.containsKey(a) ? tm.get(a) : 0;\n\t}\n\n\tint size() {\n\t\treturn tm.size();\n\t}\n\n\tA floor(A a) {\n\t\treturn tm.floorKey(a);\n\t}\n\n\tUP floorNum(A a) {\n\t\tEntry e = tm.floorEntry(a);\n\t\treturn e == null ? null : UP.make(e.getKey(), e.getValue());\n\t}\n\n\tA ceil(A a) {\n\t\treturn tm.ceilingKey(a);\n\t}\n\n\tUP ceilNum(A a) {\n\t\tEntry e = tm.ceilingEntry(a);\n\t\treturn e == null ? null : UP.make(e.getKey(), e.getValue());\n\t}\n\n\tvoid clear() {\n\t\ttm.clear();\n\t}\n\n\tSet keySet() {\n\t\treturn tm.keySet();\n\t}\n\n\tCollection valueSet() {\n\t\treturn tm.values();\n\t}\n\n\tSet> entrySet() {\n\t\treturn tm.entrySet();\n\t}\n\n\tpublic String toString() {\n\t\treturn tm.toString();\n\t}\n}\n\nclass WUF { // Weighted Union Find Tree\n\tprivate int[] parents;\n\tprivate int[] ranks;\n\tprivate ArrayList roots;\n\tprivate ArrayList weights;\n\tprivate F.XXX merger;\n\tprivate F.XXX add;\n\tprivate F.XX inv;\n\tprivate W e;\n\n\tWUF(int n, F.IX maker, F.XXX merger, F.XXX add, F.XX inv, W e) {\n\t\tthis.merger = merger;\n\t\tthis.add = add;\n\t\tthis.inv = inv;\n\t\tthis.e = e;\n\t\tparents = new int[n];\n\t\tranks = new int[n];\n\t\troots = U.make(n, maker);\n\t\tweights = U.make(n, i -> e);\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tparents[i] = i;\n\t\t}\n\t}\n\n\tint index(int i) {\n\t\tint p = parents[i];\n\t\tif (i == p) {\n\t\t\treturn i;\n\t\t}\n\t\tint r = index(p);\n\t\tweights.set(i, add.f(weights.get(i), weights.get(p)));\n\t\treturn parents[i] = r;\n\t}\n\n\tboolean same(int i, int j) {\n\t\treturn index(i) == index(j);\n\t}\n\n\tA root(int i) {\n\t\treturn roots.get(index(i));\n\t}\n\n\tW weight(int i) {\n\t\tindex(i);\n\t\treturn weights.get(i);\n\t}\n\n\tW diff(int i, int j) {\n\t\treturn sub(weight(j), weight(i));\n\t}\n\n\tvoid unite(int i, int j, W w) {\n\t\tw = add(w, weight(i));\n\t\tw = sub(w, weight(j));\n\t\ti = index(i);\n\t\tj = index(j);\n\t\tif (i == j)\n\t\t\treturn;\n\t\tA r = merger.f(root(i), root(j));\n\t\tif (ranks[i] < ranks[j]) {\n\t\t\ti ^= j;\n\t\t\tj ^= i;\n\t\t\ti ^= j;\n\t\t\tw = inv.f(w);\n\t\t}\n\t\tparents[j] = i;\n\t\troots.set(i, r);\n\t\tif (ranks[i] == ranks[j])\n\t\t\tranks[i]++;\n\t\tweights.set(j, w);\n\t}\n\n\tprivate W add(W a, W b) {\n\t\treturn a == e ? b : b == e ? a : add.f(a, b);\n\t}\n\n\tprivate W sub(W a, W b) {\n\t\treturn b == e ? a : add(a, inv.f(b));\n\t}\n}\n\nclass PQ { // Priority Queue\n\tstatic class E { // Entry\n\t\tprivate Object a;\n\t\tprivate int index;\n\n\t\tprivate E(Object a, int index) {\n\t\t\tthis.a = a;\n\t\t\tthis.index = index;\n\t\t}\n\t}\n\n\tprivate int n;\n\tprivate E[] as;\n\tprivate Comparator comp;\n\n\tPQ(Comparator comp) {\n\t\tthis.comp = comp;\n\t\tas = new E[64];\n\t\tn = 1;\n\t}\n\n\tE add(A a) {\n\t\tE res = addEntry(a);\n\t\tfixUp(n - 1);\n\t\treturn res;\n\t}\n\n\tA pop() {\n\t\tint max = n - 1;\n\t\tif (max == 0)\n\t\t\treturn null;\n\t\tif (max == 1) {\n\t\t\treturn removeLast();\n\t\t}\n\n\t\tE tmp = as[1];\n\t\tas[1] = as[max];\n\t\tas[max] = tmp;\n\t\tas[1].index = 1;\n\t\tas[max].index = max;\n\n\t\tA res = removeLast();\n\t\tfixDown(1);\n\t\treturn res;\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tA get(E e) {\n\t\treturn (A) e.a;\n\t}\n\n\tvoid remove(E e) {\n\t\tint k = ((E) e).index;\n\t\tint max = n - 1;\n\t\tif (k == max) {\n\t\t\tremoveLast();\n\t\t\treturn;\n\t\t}\n\n\t\tE tmp = as[k];\n\t\tas[k] = as[max];\n\t\tas[max] = tmp;\n\t\tas[k].index = k;\n\t\tas[max].index = max;\n\n\t\tremoveLast();\n\t\tif (!fixDown(k))\n\t\t\tfixUp(k);\n\t}\n\n\tvoid update(E e, A a) {\n\t\tint k = e.index;\n\t\tas[k].a = a;\n\t\tif (!fixDown(k))\n\t\t\tfixUp(k);\n\t}\n\n\tboolean isEmpty() {\n\t\treturn n == 1;\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tprivate A removeLast() {\n\t\tn--;\n\t\tE res = as[n];\n\t\tres.index = -1;\n\t\tas[n] = null;\n\t\treturn (A) res.a;\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tprivate boolean fixUp(int k) {\n\t\tboolean res = false;\n\t\twhile (k > 1) {\n\t\t\tint nk = k >> 1;\n\t\t\tif (comp.compare((A) as[k].a, (A) as[nk].a) < 0) {\n\t\t\t\tE tmp = as[k];\n\t\t\t\tas[k] = as[nk];\n\t\t\t\tas[nk] = tmp;\n\t\t\t\tas[k].index = k;\n\t\t\t\tas[nk].index = nk;\n\t\t\t\tk = nk;\n\t\t\t\tres = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\treturn res;\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tprivate boolean fixDown(int k) {\n\t\tboolean res = false;\n\t\twhile (k << 1 < n) {\n\t\t\tA a = (A) as[k].a;\n\t\t\tA l = (A) as[k << 1].a;\n\t\t\tif (k << 1 == n - 1) {\n\t\t\t\tif (comp.compare(a, l) <= 0)\n\t\t\t\t\tbreak;\n\t\t\t\tres = true;\n\t\t\t\tE tmp = as[k];\n\t\t\t\tas[k] = as[k << 1];\n\t\t\t\tas[k << 1] = tmp;\n\t\t\t\tas[k].index = k;\n\t\t\t\tas[k << 1].index = k << 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tA r = (A) as[k << 1 | 1].a;\n\t\t\tif (comp.compare(a, l) <= 0 && comp.compare(a, r) <= 0)\n\t\t\t\tbreak;\n\t\t\tres = true;\n\t\t\tif (comp.compare(l, r) < 0) {\n\t\t\t\tint nk = k << 1;\n\t\t\t\tE tmp = as[k];\n\t\t\t\tas[k] = as[nk];\n\t\t\t\tas[nk] = tmp;\n\t\t\t\tas[k].index = k;\n\t\t\t\tas[nk].index = nk;\n\t\t\t\tk = nk;\n\t\t\t} else {\n\t\t\t\tint nk = k << 1 | 1;\n\t\t\t\tE tmp = as[k];\n\t\t\t\tas[k] = as[nk];\n\t\t\t\tas[nk] = tmp;\n\t\t\t\tas[k].index = k;\n\t\t\t\tas[nk].index = nk;\n\t\t\t\tk = nk;\n\t\t\t}\n\t\t}\n\t\treturn res;\n\t}\n\n\tprivate E addEntry(A a) {\n\t\tif (n == as.length)\n\t\t\tas = U.doubleSize(as);\n\t\treturn as[n] = new E(a, n++);\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tpublic String toString() {\n\t\tif (n == 1)\n\t\t\treturn \"[]\";\n\t\tString s = null;\n\t\tfor (int i = 1; i < n; i++) {\n\t\t\tA a = (A) as[i].a;\n\t\t\tif (s == null)\n\t\t\t\ts = \"[\" + a;\n\t\t\telse\n\t\t\t\ts += \", \" + a;\n\t\t}\n\t\treturn s + \"]\";\n\t}\n}\n\nclass G { // Graph\n\tprivate int vSize;\n\tprivate Object[] vs; // V\n\tprivate int numEdges;\n\tprivate Object[] allEdges; // UT\n\tprivate Object[] esFrom; // EdgeSet\n\tprivate Object[] esTo; // EdgeSet\n\tprivate Integer[] ints;\n\n\tprivate class EdgeSet {\n//\t\tHashMap map;\n\t\tInteger[] is;\n\t\tObject[] es;\n\t\tint size;\n\n\t\tEdgeSet() {\n\t\t\tis = new Integer[2];\n\t\t\tes = new Object[2];\n\t\t\tsize = 0;\n\t\t}\n\n//\t\t@SuppressWarnings(\"unchecked\")\n\t\tvoid add(Integer i, E e) {\n//\t\t\tif (size > 1600000) {\n//\t\t\t\tmap.put(i, e);\n//\t\t\t\tsize++;\n//\t\t\t\treturn;\n//\t\t\t}\n\t\t\tif (size == is.length) {\n\t\t\t\tis = Arrays.copyOf(is, size << 1);\n\t\t\t\tes = Arrays.copyOf(es, size << 1);\n\t\t\t}\n\t\t\tis[size] = i;\n\t\t\tes[size] = e;\n//\t\t\tif (++size > 1600000) {\n//\t\t\t\tmap = new HashMap();\n//\t\t\t\tfor (int j = 0; j < size; j++) {\n//\t\t\t\t\tmap.put(is[j], (E) es[j]);\n//\t\t\t\t}\n//\t\t\t\tis = null;\n//\t\t\t\tes = null;\n//\t\t\t}\n\t\t}\n\n\t\t@SuppressWarnings(\"unchecked\")\n\t\tvoid iter(F.IXV f) {\n//\t\t\tif (map == null)\n\t\t\tfor (int i = 0; i < size; i++)\n\t\t\t\tf.f(is[i], (E) es[i]);\n//\t\t\telse\n//\t\t\t\tfor (Entry e : map.entrySet())\n//\t\t\t\t\tf.f(e.getKey(), e.getValue());\n\t\t}\n\t}\n\n\tG() {\n\t\tvs = new Object[64];\n\t\tallEdges = new Object[64];\n\t\tesFrom = new Object[64];\n\t\tesTo = new Object[64];\n\t\tints = new Integer[64];\n\t\tvSize = 0;\n\t\tnumEdges = 0;\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tV getV(int i) {\n\t\treturn i < 0 || i >= vs.length ? null : (V) vs[i];\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tArrayList getSortedVs() {\n\t\tArrayList res = new ArrayList();\n\t\tfor (int i = 0; i < vs.length; i++) {\n\t\t\tif (vs[i] != null)\n\t\t\t\tres.add((V) vs[i]);\n\t\t}\n\t\treturn res;\n\t}\n\n\tvoid addV(int i, V v) {\n\t\tif (getV(i) != null)\n\t\t\tthrow new RuntimeException(\"duplicate vtx: \" + i);\n\t\twhile (vs.length <= i) {\n\t\t\tvs = U.doubleSize(vs);\n\t\t\tints = U.doubleSize(ints);\n\t\t\tesFrom = U.doubleSize(esFrom);\n\t\t\tesTo = U.doubleSize(esTo);\n\t\t}\n\t\tvSize = U.max(vSize, i + 1);\n\t\tvs[i] = v;\n\t\tints[i] = Integer.valueOf(i);\n\t\tesFrom[i] = new EdgeSet();\n\t\tesTo[i] = new EdgeSet();\n\t}\n\n\tvoid setV(int i, V v) {\n\t\tif (getV(i) == null)\n\t\t\tthrow new RuntimeException(\"no such vtx: \" + i);\n\t\tvs[i] = v;\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tvoid addE(int from, int to, E e) {\n\t\t((EdgeSet) esFrom[from]).add(ints[to], e);\n\t\t((EdgeSet) esTo[to]).add(ints[from], e);\n\t\tif (numEdges == allEdges.length) {\n\t\t\tallEdges = U.doubleSize(allEdges);\n\t\t}\n\t\tallEdges[numEdges++] = UT.make(from, to, e);\n\t}\n\n\tvoid addUE(int i, int j, E e) {\n\t\taddE(i, j, e);\n\t\taddE(j, i, e);\n\t}\n\n\t void dfs(int firstIdx, State firstS, F.XXXXX nextState,\n\t\t\tF.XXXV> visit) {\n\t\tArrayDeque> deque = new ArrayDeque>();\n\t\tsearch(firstIdx, firstS, nextState, visit, deque::push, deque::pop, deque::isEmpty);\n\t}\n\n\t void bfs(int firstIdx, State firstS, F.XXXXX nextState,\n\t\t\tF.XXXV> visit) {\n\t\tArrayDeque> deque = new ArrayDeque>();\n\t\tsearch(firstIdx, firstS, nextState, visit, deque::addLast, deque::pollFirst, deque::isEmpty);\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tArrayList> getEs() {\n\t\tArrayList> res = new ArrayList>();\n\t\tfor (int i = 0; i < numEdges; i++) {\n\t\t\tres.add((UT) allEdges[i]);\n\t\t}\n\t\treturn res;\n\t}\n\n\t/**\n\t * !!多重辺があるとバグる!!\n\t * !!多重辺があるとバグる!!\n\t * !!多重辺があるとバグる!!\n\t */\n\tArrayList> dijkstraL(int from, F.XL getWeight) {\n\t\treturn dijkstra(from, e -> getWeight.f(e), (a, b) -> a + b, Long::compare, 0l, Long.MAX_VALUE);\n\t}\n\n\t/**\n\t * !!多重辺があるとバグる!!\n\t * !!多重辺があるとバグる!!\n\t * !!多重辺があるとバグる!!\n\t */\n\t@SuppressWarnings(\"unchecked\")\n\t ArrayList> dijkstra(int from, F.XX getWeight, F.XXX add, Comparator comp,\n\t\t\tA zero, A inf) {\n\t\tint n = vSize;\n\t\tArrayList> res = U.make(n, i -> getV(i) == null ? null : UP.make(i == from ? zero : inf, -1));\n\t\tPQ> q = new PQ>((i, j) -> comp.compare(i.b, j.b));\n\n\t\tPQ.E[] qes = new PQ.E[n];\n\t\tArrayList> ups = new ArrayList>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tups.add(UP.make(i, inf));\n\t\t}\n\n\t\tboolean[] fixed = new boolean[n];\n\t\tups.get(from).b = zero;\n\t\tqes[from] = q.add(ups.get(from));\n\n\t\twhile (!q.isEmpty()) {\n\t\t\tUP up = q.pop();\n\t\t\tInteger i = up.a;\n\t\t\tif (fixed[i])\n\t\t\t\tcontinue;\n\t\t\tfixed[i] = true;\n\t\t\tA dist = up.b;\n\t\t\tif (dist == inf)\n\t\t\t\tbreak;\n\t\t\t((EdgeSet) esFrom[i]).iter((j, e) -> {\n\t\t\t\tif (fixed[j])\n\t\t\t\t\treturn;\n\t\t\t\tUP resj = res.get(j);\n\t\t\t\tA newDist = add.f(dist, getWeight.f(e));\n\t\t\t\tif (comp.compare(resj.a, newDist) > 0) {\n\t\t\t\t\tresj.a = newDist;\n\t\t\t\t\tresj.b = i;\n\n\t\t\t\t\tq.add(UP.make(j, newDist));\n\n//\t\t\t\t\tUP upj = ups.get(j);\n//\t\t\t\t\tupj.b = newDist;\n//\t\t\t\t\tif (qes[j] == null)\n//\t\t\t\t\t\tqes[j] = q.add(upj);\n//\t\t\t\t\telse\n//\t\t\t\t\t\tq.update(qes[j], upj);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\treturn res;\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tprivate void search(int firstIdx, State firstS, F.XXXXX nextState,\n\t\t\tF.XXXV> visit, F.XV> push,\n\t\t\tF.VX> pop, F.VX isEmpty) {\n\t\tboolean[] visited = new boolean[vSize];\n\t\tArrayList movedTo = new ArrayList();\n\t\tpush.f(UP.make(firstS, firstIdx));\n\t\tvisited[firstIdx] = true;\n\t\twhile (!isEmpty.f()) {\n\t\t\tUP si = pop.f();\n\t\t\tState s = (State) si.a;\n\t\t\tInteger i = si.b;\n\t\t\tmovedTo.clear();\n\t\t\t((EdgeSet) esFrom[i]).iter((j, e) -> {\n\t\t\t\tif (visited[j])\n\t\t\t\t\treturn;\n\t\t\t\tState ns = nextState.f(s, i, j, e);\n\t\t\t\tif (ns != null) {\n\t\t\t\t\tmovedTo.add(j);\n\t\t\t\t\tpush.f(P.make(ns, j));\n\t\t\t\t\tvisited[j] = true;\n\t\t\t\t}\n\t\t\t});\n\t\t\tvisit.f(s, i, movedTo);\n\t\t}\n\t}\n}\n\nclass UP { // Unordered Pair\n\tA a;\n\tB b;\n\n\tUP(A a, B b) {\n\t\tthis.a = a;\n\t\tthis.b = b;\n\t}\n\n\tstatic UP make(A a, B b) {\n\t\treturn new UP(a, b);\n\t}\n\n\tpublic boolean equals(Object o) {\n\t\tif (o == this)\n\t\t\treturn true;\n\t\tif (!(o instanceof UP))\n\t\t\treturn false;\n\t\tUP p = (UP) o;\n\t\tboolean aok = a == null ? p.a == null : a.equals(p.a);\n\t\tboolean bok = b == null ? p.b == null : b.equals(p.b);\n\t\treturn aok && bok;\n\t}\n\n\tpublic String toString() {\n\t\treturn \"(\" + a.toString() + \", \" + b.toString() + \")\";\n\t}\n}\n\nclass P, B extends Comparable> extends UP\n\t\timplements Comparable> { // Pair\n\tP(A a, B b) {\n\t\tsuper(a, b);\n\t}\n\n\tstatic , B extends Comparable> P make(A a, B b) {\n\t\treturn new P(a, b);\n\t}\n\n\tpublic int compareTo(P o) {\n\t\tint sa = a.compareTo(o.a);\n\t\tint sb = b.compareTo(o.b);\n\t\treturn sa != 0 ? sa : sb;\n\t}\n}\n\nclass PI implements Comparable { // Pair int\n\tint a;\n\tint b;\n\n\tPI(int a, int b) {\n\t\tthis.a = a;\n\t\tthis.b = b;\n\t}\n\n\tstatic PI make(int a, int b) {\n\t\treturn new PI(a, b);\n\t}\n\n\tpublic boolean equals(Object o) {\n\t\tif (o == this)\n\t\t\treturn true;\n\t\tif (!(o instanceof PI))\n\t\t\treturn false;\n\t\tPI p = (PI) o;\n\t\treturn a == p.a && b == p.b;\n\t}\n\n\tpublic int compareTo(PI o) {\n\t\tint sa = a - o.a;\n\t\tint sb = b - o.b;\n\t\treturn sa > 0 ? 1 : sa < 0 ? -1 : sb > 0 ? 1 : sb < 0 ? -1 : 0;\n\t}\n\n\tpublic String toString() {\n\t\treturn \"(\" + a + \", \" + b + \")\";\n\t}\n}\n\nclass PL implements Comparable { // Pair long\n\tlong a;\n\tlong b;\n\n\tPL(long a, long b) {\n\t\tthis.a = a;\n\t\tthis.b = b;\n\t}\n\n\tstatic PL make(long a, long b) {\n\t\treturn new PL(a, b);\n\t}\n\n\tpublic boolean equals(Object o) {\n\t\tif (o == this)\n\t\t\treturn true;\n\t\tif (!(o instanceof PL))\n\t\t\treturn false;\n\t\tPL p = (PL) o;\n\t\treturn a == p.a && b == p.b;\n\t}\n\n\tpublic int compareTo(PL o) {\n\t\tlong sa = a - o.a;\n\t\tlong sb = b - o.b;\n\t\treturn sa > 0 ? 1 : sa < 0 ? -1 : sb > 0 ? 1 : sb < 0 ? -1 : 0;\n\t}\n\n\tpublic String toString() {\n\t\treturn \"(\" + a + \", \" + b + \")\";\n\t}\n}\n\nclass UT { // Unordered Tuple\n\tA a;\n\tB b;\n\tC c;\n\n\tUT(A a, B b, C c) {\n\t\tthis.a = a;\n\t\tthis.b = b;\n\t\tthis.c = c;\n\t}\n\n\tstatic UT make(A a, B b, C c) {\n\t\treturn new UT(a, b, c);\n\t}\n\n\tpublic boolean equals(Object o) {\n\t\tif (o == this)\n\t\t\treturn true;\n\t\tif (!(o instanceof UT))\n\t\t\treturn false;\n\t\tUT t = (UT) o;\n\t\tboolean aok = a == null ? t.a == null : a.equals(t.a);\n\t\tboolean bok = b == null ? t.b == null : b.equals(t.b);\n\t\tboolean cok = c == null ? t.c == null : c.equals(t.c);\n\t\treturn aok && bok && cok;\n\t}\n\n\tpublic String toString() {\n\t\treturn \"(\" + a.toString() + \", \" + b.toString() + \", \" + c.toString() + \")\";\n\t}\n}\n\nclass T, B extends Comparable, C extends Comparable>\n\t\textends UT implements Comparable> { // Tuple\n\tT(A a, B b, C c) {\n\t\tsuper(a, b, c);\n\t}\n\n\tstatic , B extends Comparable, C extends Comparable> T make(\n\t\t\tA a, B b, C c) {\n\t\treturn new T(a, b, c);\n\t}\n\n\tpublic int compareTo(T o) {\n\t\tint sa = a.compareTo(o.a);\n\t\tint sb = b.compareTo(o.b);\n\t\tint sc = c.compareTo(o.c);\n\t\treturn sa != 0 ? sa : sb != 0 ? sb : sc;\n\t}\n}\n\nclass TI implements Comparable { // Tuple int\n\tint a;\n\tint b;\n\tint c;\n\n\tTI(int a, int b, int c) {\n\t\tthis.a = a;\n\t\tthis.b = b;\n\t\tthis.c = c;\n\t}\n\n\tstatic TI make(int a, int b, int c) {\n\t\treturn new TI(a, b, c);\n\t}\n\n\tTL toLong() {\n\t\treturn TL.make(a, b, c);\n\t}\n\n\tpublic boolean equals(Object o) {\n\t\tif (o == this)\n\t\t\treturn true;\n\t\tif (!(o instanceof TI))\n\t\t\treturn false;\n\t\tTI t = (TI) o;\n\t\treturn a == t.a && b == t.b && c == t.c;\n\t}\n\n\tpublic int compareTo(TI o) {\n\t\tint sa = a - o.a;\n\t\tint sb = b - o.b;\n\t\tint sc = c - o.c;\n\t\treturn sa > 0 ? 1 : sa < 0 ? -1 : sb > 0 ? 1 : sb < 0 ? -1 : sc > 0 ? 1 : sc < 0 ? -1 : 0;\n\t}\n\n\tpublic String toString() {\n\t\treturn \"(\" + a + \", \" + b + \", \" + c + \")\";\n\t}\n}\n\nclass TL implements Comparable { // Tuple long\n\tlong a;\n\tlong b;\n\tlong c;\n\n\tTL(long a, long b, long c) {\n\t\tthis.a = a;\n\t\tthis.b = b;\n\t\tthis.c = c;\n\t}\n\n\tstatic TL make(long a, long b, long c) {\n\t\treturn new TL(a, b, c);\n\t}\n\n\tTI toInt() {\n\t\treturn TI.make((int) a, (int) b, (int) c);\n\t}\n\n\tpublic boolean equals(Object o) {\n\t\tif (o == this)\n\t\t\treturn true;\n\t\tif (!(o instanceof TL))\n\t\t\treturn false;\n\t\tTL t = (TL) o;\n\t\treturn a == t.a && b == t.b && c == t.c;\n\t}\n\n\tpublic int compareTo(TL o) {\n\t\tlong sa = a - o.a;\n\t\tlong sb = b - o.b;\n\t\tlong sc = c - o.c;\n\t\treturn sa > 0 ? 1 : sa < 0 ? -1 : sb > 0 ? 1 : sb < 0 ? -1 : sc > 0 ? 1 : sc < 0 ? -1 : 0;\n\t}\n\n\tpublic String toString() {\n\t\treturn \"(\" + a + \", \" + b + \", \" + c + \")\";\n\t}\n}\n\nfinal class U { // Utilities\n\tprivate U() {\n\t}\n\n\tstatic ArrayList make(int n, F.IX maker) {\n\t\tArrayList res = new ArrayList();\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tres.add(maker.f(i));\n\t\treturn res;\n\t}\n\n\tstatic boolean[] makeB(int n, F.IB maker) {\n\t\tboolean[] res = new boolean[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tres[i] = maker.f(i);\n\t\treturn res;\n\t}\n\n\tstatic int[] makeI(int n, F.II maker) {\n\t\tint[] res = new int[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tres[i] = maker.f(i);\n\t\treturn res;\n\t}\n\n\tstatic long[] makeL(int n, F.IL maker) {\n\t\tlong[] res = new long[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tres[i] = maker.f(i);\n\t\treturn res;\n\t}\n\n\tstatic A[] makeX(int n, F.IX maker, A[] as) {\n\t\tA[] res = Arrays.copyOf(as, n);\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tres[i] = maker.f(i);\n\t\treturn res;\n\t}\n\n\tstatic ArrayList filter(ArrayList as, F.XB pred) {\n\t\tArrayList res = new ArrayList();\n\t\tfor (A a : as)\n\t\t\tif (pred.f(a))\n\t\t\t\tres.add(a);\n\t\treturn res;\n\t}\n\n\tstatic int count(ArrayList as, F.XB pred) {\n\t\tint res = 0;\n\t\tfor (A a : as)\n\t\t\tif (pred.f(a))\n\t\t\t\tres++;\n\t\treturn res;\n\t}\n\n\tstatic ArrayList concat(ArrayList as, ArrayList bs) {\n\t\tArrayList res = new ArrayList();\n\t\tres.addAll(as);\n\t\tres.addAll(bs);\n\t\treturn res;\n\t}\n\n\tstatic boolean any(ArrayList as, F.XB pred) {\n\t\tfor (A a : as)\n\t\t\tif (pred.f(a))\n\t\t\t\treturn true;\n\t\treturn false;\n\t}\n\n\tstatic boolean all(ArrayList as, F.XB pred) {\n\t\tfor (A a : as)\n\t\t\tif (!pred.f(a))\n\t\t\t\treturn false;\n\t\treturn true;\n\t}\n\n\tstatic ArrayList flatten(ArrayList> ass) {\n\t\tArrayList res = new ArrayList();\n\t\tfor (ArrayList as : ass)\n\t\t\tres.addAll(as);\n\t\treturn res;\n\t}\n\n\tstatic B foldl(ArrayList as, F.XXX f, B e) {\n\t\tB res = e;\n\t\tfor (A a : as)\n\t\t\tres = f.f(res, a);\n\t\treturn res;\n\t}\n\n\tstatic B foldr(ArrayList as, F.XXX f, B e) {\n\t\tB res = e;\n\t\tfor (int i = as.size() - 1; i >= 0; i--)\n\t\t\tres = f.f(as.get(i), res);\n\t\treturn res;\n\t}\n\n\tstatic ArrayList reverse(ArrayList as) {\n\t\tint size = as.size();\n\t\treturn make(size, i -> as.get(size - 1 - i));\n\t}\n\n\tstatic boolean[] reverse(boolean[] as) {\n\t\tint size = as.length;\n\t\treturn makeB(size, i -> as[size - 1 - i]);\n\t}\n\n\tstatic int[] reverse(int[] as) {\n\t\tint size = as.length;\n\t\treturn makeI(size, i -> as[size - 1 - i]);\n\t}\n\n\tstatic long[] reverse(long[] as) {\n\t\tint size = as.length;\n\t\treturn makeL(size, i -> as[size - 1 - i]);\n\t}\n\n\tstatic A[] reverse(A[] as) {\n\t\tint size = as.length;\n\t\treturn makeX(size, i -> as[size - 1 - i], as);\n\t}\n\n\tstatic > UP, ArrayList> compress(ArrayList as) {\n\t\tTreeSet set = new TreeSet(as);\n\t\tTreeMap map = new TreeMap();\n\t\tArrayList imap = new ArrayList();\n\t\tint i = 0;\n\t\tfor (A a : set) {\n\t\t\tmap.put(a, i++);\n\t\t\timap.add(a);\n\t\t}\n\t\treturn UP.make(map, imap);\n\t}\n\n\tstatic ArrayList map(ArrayList as, F.XX f) {\n\t\treturn make(as.size(), (i) -> f.f(as.get(i)));\n\t}\n\n\tstatic ArrayList mapi(ArrayList as, F.XIX f) {\n\t\treturn make(as.size(), (i) -> f.f(as.get(i), i));\n\t}\n\n\tstatic ArrayList> zip(ArrayList as, ArrayList bs) {\n\t\treturn make(min(as.size(), bs.size()), (i) -> UP.make(as.get(i), bs.get(i)));\n\t}\n\n\tstatic int min(int a, int b) {\n\t\treturn a < b ? a : b;\n\t}\n\n\tstatic long min(long a, long b) {\n\t\treturn a < b ? a : b;\n\t}\n\n\tstatic > A min(A a, A b) {\n\t\treturn a.compareTo(b) < 0 ? a : b;\n\t}\n\n\tstatic int max(int a, int b) {\n\t\treturn a > b ? a : b;\n\t}\n\n\tstatic long max(long a, long b) {\n\t\treturn a > b ? a : b;\n\t}\n\n\tstatic > A max(A a, A b) {\n\t\treturn a.compareTo(b) > 0 ? a : b;\n\t}\n\n\tstatic int clamp(int a, int min, int max) {\n\t\treturn a < min ? min : a > max ? max : a;\n\t}\n\n\tstatic long clamp(long a, long min, long max) {\n\t\treturn a < min ? min : a > max ? max : a;\n\t}\n\n\tstatic > A clamp(A a, A min, A max) {\n\t\treturn a.compareTo(min) < 0 ? min : a.compareTo(max) > 0 ? max : a;\n\t}\n\n\tstatic int abs(int a) {\n\t\treturn a < 0 ? -a : a;\n\t}\n\n\tstatic long abs(long a) {\n\t\treturn a < 0 ? -a : a;\n\t}\n\n\tstatic void forEachBitPerm(int n, int k, F.IV f) {\n\t\tfor (int i = (1 << k) - 1; i < 1 << n;) {\n\t\t\tf.f(i);\n\t\t\tint t = (i | i - 1) + 1;\n\t\t\ti = t | ((t & -t) / (i & -i) >> 1) - 1;\n\t\t}\n\t}\n\n\tstatic int nextBitPerm(int a) {\n\t\tint t = (a | a - 1) + 1;\n\t\treturn t | ((t & -t) / (a & -a) >> 1) - 1;\n\t}\n\n\tstatic void mebius(int n, F.IIV f) { // s, i\n\t\tint bit = 1;\n\t\tint exp = 0;\n\t\tfor (int i = 1; i < 1 << n; i++) {\n\t\t\tf.f(i ^ bit, exp);\n\t\t\tif ((i & i + 1) == 0) {\n\t\t\t\tbit <<= 1;\n\t\t\t\texp++;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic void zeta(int n, F.IIV f) { // s, i\n\t\tint m = (1 << n) - 1;\n\t\tint bit = 1;\n\t\tint exp = 0;\n\t\tfor (int i = (1 << n) - 2; i >= 0; i--) {\n\t\t\tf.f(i ^ bit, exp);\n\t\t\tif ((~i & ~i + 1 & m) == 0) {\n\t\t\t\tbit <<= 1;\n\t\t\t\texp++;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic ArrayList toAL(A[] as) {\n\t\treturn make(as.length, i -> as[i]);\n\t}\n\n\tstatic A[] doubleSize(A[] as) {\n\t\treturn Arrays.copyOf(as, as.length << 1);\n\t}\n\n\tstatic long searchL(long ng, long ok, F.LB isOk) {\n\t\twhile (ng - ok > 1 || ok - ng > 1) {\n\t\t\tlong mid = ng + ok >> 1;\n\t\t\tif (isOk.f(mid))\n\t\t\t\tok = mid;\n\t\t\telse\n\t\t\t\tng = mid;\n\t\t}\n\t\treturn ok;\n\t}\n\n\tstatic int searchI(int ng, int ok, F.IB isOk) {\n\t\treturn (int) searchL((long) ng, (long) ok, (mid) -> isOk.f((int) mid));\n\t}\n}\n\nfinal class F { // Functions\n\tprivate F() {\n\t}\n\n\tinterface VV {\n\t\tvoid f();\n\t}\n\n\tinterface BV {\n\t\tvoid f(boolean a);\n\t}\n\n\tinterface BXV {\n\t\tvoid f(boolean a, A b);\n\t}\n\n\tinterface BXXV {\n\t\tvoid f(boolean a, A b, B c);\n\t}\n\n\tinterface BXXXV {\n\t\tvoid f(boolean a, A b, B c, C d);\n\t}\n\n\tinterface XBV {\n\t\tvoid f(A a, boolean b);\n\t}\n\n\tinterface XXBV {\n\t\tvoid f(A a, B b, boolean c);\n\t}\n\n\tinterface XXXBV {\n\t\tvoid f(A a, B b, C c, boolean d);\n\t}\n\n\tinterface IV {\n\t\tvoid f(int a);\n\t}\n\n\tinterface IXV {\n\t\tvoid f(int a, A b);\n\t}\n\n\tinterface IXXV {\n\t\tvoid f(int a, A b, B c);\n\t}\n\n\tinterface IXXXV {\n\t\tvoid f(int a, A b, B c, C d);\n\t}\n\n\tinterface XIV {\n\t\tvoid f(A a, int b);\n\t}\n\n\tinterface XXIV {\n\t\tvoid f(A a, B b, int c);\n\t}\n\n\tinterface XXXIV {\n\t\tvoid f(A a, B b, C c, int d);\n\t}\n\n\tinterface LV {\n\t\tvoid f(long a);\n\t}\n\n\tinterface LXV {\n\t\tvoid f(long a, A b);\n\t}\n\n\tinterface LXXV {\n\t\tvoid f(long a, A b, B c);\n\t}\n\n\tinterface LXXXV {\n\t\tvoid f(long a, A b, B c, C d);\n\t}\n\n\tinterface XLV {\n\t\tvoid f(A a, long b);\n\t}\n\n\tinterface XXLV {\n\t\tvoid f(A a, B b, long c);\n\t}\n\n\tinterface XXXLV {\n\t\tvoid f(A a, B b, C c, long d);\n\t}\n\n\tinterface DV {\n\t\tvoid f(double a);\n\t}\n\n\tinterface DXV {\n\t\tvoid f(double a, A b);\n\t}\n\n\tinterface DXXV {\n\t\tvoid f(double a, A b, B c);\n\t}\n\n\tinterface DXXXV {\n\t\tvoid f(double a, A b, B c, C d);\n\t}\n\n\tinterface XDV {\n\t\tvoid f(A a, double b);\n\t}\n\n\tinterface XXDV {\n\t\tvoid f(A a, B b, double c);\n\t}\n\n\tinterface XXXDV {\n\t\tvoid f(A a, B b, C c, double d);\n\t}\n\n\tinterface XV {\n\t\tvoid f(A a);\n\t}\n\n\tinterface XXV {\n\t\tvoid f(A a, B b);\n\t}\n\n\tinterface XXXV {\n\t\tvoid f(A a, B b, C c);\n\t}\n\n\tinterface XXXXV {\n\t\tvoid f(A a, B b, C c, D d);\n\t}\n\n\tinterface BBV {\n\t\tvoid f(boolean a, boolean b);\n\t}\n\n\tinterface BIV {\n\t\tvoid f(boolean a, int b);\n\t}\n\n\tinterface BLV {\n\t\tvoid f(boolean a, long b);\n\t}\n\n\tinterface BDV {\n\t\tvoid f(boolean a, double b);\n\t}\n\n\tinterface IBV {\n\t\tvoid f(int a, boolean b);\n\t}\n\n\tinterface IIV {\n\t\tvoid f(int a, int b);\n\t}\n\n\tinterface ILV {\n\t\tvoid f(int a, long b);\n\t}\n\n\tinterface IDV {\n\t\tvoid f(int a, double b);\n\t}\n\n\tinterface LBV {\n\t\tvoid f(long a, boolean b);\n\t}\n\n\tinterface LIV {\n\t\tvoid f(long a, int b);\n\t}\n\n\tinterface LLV {\n\t\tvoid f(long a, long b);\n\t}\n\n\tinterface LDV {\n\t\tvoid f(long a, double b);\n\t}\n\n\tinterface DBV {\n\t\tvoid f(double a, boolean b);\n\t}\n\n\tinterface DIV {\n\t\tvoid f(double a, int b);\n\t}\n\n\tinterface DLV {\n\t\tvoid f(double a, long b);\n\t}\n\n\tinterface DDV {\n\t\tvoid f(double a, double b);\n\t}\n\n\tinterface VB {\n\t\tboolean f();\n\t}\n\n\tinterface BB {\n\t\tboolean f(boolean a);\n\t}\n\n\tinterface BXB {\n\t\tboolean f(boolean a, A b);\n\t}\n\n\tinterface BXXB {\n\t\tboolean f(boolean a, A b, B c);\n\t}\n\n\tinterface BXXXB {\n\t\tboolean f(boolean a, A b, B c, C d);\n\t}\n\n\tinterface XBB {\n\t\tboolean f(A a, boolean b);\n\t}\n\n\tinterface XXBB {\n\t\tboolean f(A a, B b, boolean c);\n\t}\n\n\tinterface XXXBB {\n\t\tboolean f(A a, B b, C c, boolean d);\n\t}\n\n\tinterface IB {\n\t\tboolean f(int a);\n\t}\n\n\tinterface IXB {\n\t\tboolean f(int a, A b);\n\t}\n\n\tinterface IXXB {\n\t\tboolean f(int a, A b, B c);\n\t}\n\n\tinterface IXXXB {\n\t\tboolean f(int a, A b, B c, C d);\n\t}\n\n\tinterface XIB {\n\t\tboolean f(A a, int b);\n\t}\n\n\tinterface XXIB {\n\t\tboolean f(A a, B b, int c);\n\t}\n\n\tinterface XXXIB {\n\t\tboolean f(A a, B b, C c, int d);\n\t}\n\n\tinterface LB {\n\t\tboolean f(long a);\n\t}\n\n\tinterface LXB {\n\t\tboolean f(long a, A b);\n\t}\n\n\tinterface LXXB {\n\t\tboolean f(long a, A b, B c);\n\t}\n\n\tinterface LXXXB {\n\t\tboolean f(long a, A b, B c, C d);\n\t}\n\n\tinterface XLB {\n\t\tboolean f(A a, long b);\n\t}\n\n\tinterface XXLB {\n\t\tboolean f(A a, B b, long c);\n\t}\n\n\tinterface XXXLB {\n\t\tboolean f(A a, B b, C c, long d);\n\t}\n\n\tinterface DB {\n\t\tboolean f(double a);\n\t}\n\n\tinterface DXB {\n\t\tboolean f(double a, A b);\n\t}\n\n\tinterface DXXB {\n\t\tboolean f(double a, A b, B c);\n\t}\n\n\tinterface DXXXB {\n\t\tboolean f(double a, A b, B c, C d);\n\t}\n\n\tinterface XDB {\n\t\tboolean f(A a, double b);\n\t}\n\n\tinterface XXDB {\n\t\tboolean f(A a, B b, double c);\n\t}\n\n\tinterface XXXDB {\n\t\tboolean f(A a, B b, C c, double d);\n\t}\n\n\tinterface XB {\n\t\tboolean f(A a);\n\t}\n\n\tinterface XXB {\n\t\tboolean f(A a, B b);\n\t}\n\n\tinterface XXXB {\n\t\tboolean f(A a, B b, C c);\n\t}\n\n\tinterface XXXXB {\n\t\tboolean f(A a, B b, C c, D d);\n\t}\n\n\tinterface BBB {\n\t\tboolean f(boolean a, boolean b);\n\t}\n\n\tinterface BIB {\n\t\tboolean f(boolean a, int b);\n\t}\n\n\tinterface BLB {\n\t\tboolean f(boolean a, long b);\n\t}\n\n\tinterface BDB {\n\t\tboolean f(boolean a, double b);\n\t}\n\n\tinterface IBB {\n\t\tboolean f(int a, boolean b);\n\t}\n\n\tinterface IIB {\n\t\tboolean f(int a, int b);\n\t}\n\n\tinterface ILB {\n\t\tboolean f(int a, long b);\n\t}\n\n\tinterface IDB {\n\t\tboolean f(int a, double b);\n\t}\n\n\tinterface LBB {\n\t\tboolean f(long a, boolean b);\n\t}\n\n\tinterface LIB {\n\t\tboolean f(long a, int b);\n\t}\n\n\tinterface LLB {\n\t\tboolean f(long a, long b);\n\t}\n\n\tinterface LDB {\n\t\tboolean f(long a, double b);\n\t}\n\n\tinterface DBB {\n\t\tboolean f(double a, boolean b);\n\t}\n\n\tinterface DIB {\n\t\tboolean f(double a, int b);\n\t}\n\n\tinterface DLB {\n\t\tboolean f(double a, long b);\n\t}\n\n\tinterface DDB {\n\t\tboolean f(double a, double b);\n\t}\n\n\tinterface VI {\n\t\tint f();\n\t}\n\n\tinterface BI {\n\t\tint f(boolean a);\n\t}\n\n\tinterface BXI {\n\t\tint f(boolean a, A b);\n\t}\n\n\tinterface BXXI {\n\t\tint f(boolean a, A b, B c);\n\t}\n\n\tinterface BXXXI {\n\t\tint f(boolean a, A b, B c, C d);\n\t}\n\n\tinterface XBI {\n\t\tint f(A a, boolean b);\n\t}\n\n\tinterface XXBI {\n\t\tint f(A a, B b, boolean c);\n\t}\n\n\tinterface XXXBI {\n\t\tint f(A a, B b, C c, boolean d);\n\t}\n\n\tinterface II {\n\t\tint f(int a);\n\t}\n\n\tinterface IXI {\n\t\tint f(int a, A b);\n\t}\n\n\tinterface IXXI {\n\t\tint f(int a, A b, B c);\n\t}\n\n\tinterface IXXXI {\n\t\tint f(int a, A b, B c, C d);\n\t}\n\n\tinterface XII {\n\t\tint f(A a, int b);\n\t}\n\n\tinterface XXII {\n\t\tint f(A a, B b, int c);\n\t}\n\n\tinterface XXXII {\n\t\tint f(A a, B b, C c, int d);\n\t}\n\n\tinterface LI {\n\t\tint f(long a);\n\t}\n\n\tinterface LXI {\n\t\tint f(long a, A b);\n\t}\n\n\tinterface LXXI {\n\t\tint f(long a, A b, B c);\n\t}\n\n\tinterface LXXXI {\n\t\tint f(long a, A b, B c, C d);\n\t}\n\n\tinterface XLI {\n\t\tint f(A a, long b);\n\t}\n\n\tinterface XXLI {\n\t\tint f(A a, B b, long c);\n\t}\n\n\tinterface XXXLI {\n\t\tint f(A a, B b, C c, long d);\n\t}\n\n\tinterface DI {\n\t\tint f(double a);\n\t}\n\n\tinterface DXI {\n\t\tint f(double a, A b);\n\t}\n\n\tinterface DXXI {\n\t\tint f(double a, A b, B c);\n\t}\n\n\tinterface DXXXI {\n\t\tint f(double a, A b, B c, C d);\n\t}\n\n\tinterface XDI {\n\t\tint f(A a, double b);\n\t}\n\n\tinterface XXDI {\n\t\tint f(A a, B b, double c);\n\t}\n\n\tinterface XXXDI {\n\t\tint f(A a, B b, C c, double d);\n\t}\n\n\tinterface XI {\n\t\tint f(A a);\n\t}\n\n\tinterface XXI {\n\t\tint f(A a, B b);\n\t}\n\n\tinterface XXXI {\n\t\tint f(A a, B b, C c);\n\t}\n\n\tinterface XXXXI {\n\t\tint f(A a, B b, C c, D d);\n\t}\n\n\tinterface BBI {\n\t\tint f(boolean a, boolean b);\n\t}\n\n\tinterface BII {\n\t\tint f(boolean a, int b);\n\t}\n\n\tinterface BLI {\n\t\tint f(boolean a, long b);\n\t}\n\n\tinterface BDI {\n\t\tint f(boolean a, double b);\n\t}\n\n\tinterface IBI {\n\t\tint f(int a, boolean b);\n\t}\n\n\tinterface III {\n\t\tint f(int a, int b);\n\t}\n\n\tinterface ILI {\n\t\tint f(int a, long b);\n\t}\n\n\tinterface IDI {\n\t\tint f(int a, double b);\n\t}\n\n\tinterface LBI {\n\t\tint f(long a, boolean b);\n\t}\n\n\tinterface LII {\n\t\tint f(long a, int b);\n\t}\n\n\tinterface LLI {\n\t\tint f(long a, long b);\n\t}\n\n\tinterface LDI {\n\t\tint f(long a, double b);\n\t}\n\n\tinterface DBI {\n\t\tint f(double a, boolean b);\n\t}\n\n\tinterface DII {\n\t\tint f(double a, int b);\n\t}\n\n\tinterface DLI {\n\t\tint f(double a, long b);\n\t}\n\n\tinterface DDI {\n\t\tint f(double a, double b);\n\t}\n\n\tinterface VL {\n\t\tlong f();\n\t}\n\n\tinterface BL {\n\t\tlong f(boolean a);\n\t}\n\n\tinterface BXL {\n\t\tlong f(boolean a, A b);\n\t}\n\n\tinterface BXXL {\n\t\tlong f(boolean a, A b, B c);\n\t}\n\n\tinterface BXXXL {\n\t\tlong f(boolean a, A b, B c, C d);\n\t}\n\n\tinterface XBL {\n\t\tlong f(A a, boolean b);\n\t}\n\n\tinterface XXBL {\n\t\tlong f(A a, B b, boolean c);\n\t}\n\n\tinterface XXXBL {\n\t\tlong f(A a, B b, C c, boolean d);\n\t}\n\n\tinterface IL {\n\t\tlong f(int a);\n\t}\n\n\tinterface IXL {\n\t\tlong f(int a, A b);\n\t}\n\n\tinterface IXXL {\n\t\tlong f(int a, A b, B c);\n\t}\n\n\tinterface IXXXL {\n\t\tlong f(int a, A b, B c, C d);\n\t}\n\n\tinterface XIL {\n\t\tlong f(A a, int b);\n\t}\n\n\tinterface XXIL {\n\t\tlong f(A a, B b, int c);\n\t}\n\n\tinterface XXXIL {\n\t\tlong f(A a, B b, C c, int d);\n\t}\n\n\tinterface LL {\n\t\tlong f(long a);\n\t}\n\n\tinterface LXL {\n\t\tlong f(long a, A b);\n\t}\n\n\tinterface LXXL {\n\t\tlong f(long a, A b, B c);\n\t}\n\n\tinterface LXXXL {\n\t\tlong f(long a, A b, B c, C d);\n\t}\n\n\tinterface XLL {\n\t\tlong f(A a, long b);\n\t}\n\n\tinterface XXLL {\n\t\tlong f(A a, B b, long c);\n\t}\n\n\tinterface XXXLL {\n\t\tlong f(A a, B b, C c, long d);\n\t}\n\n\tinterface DL {\n\t\tlong f(double a);\n\t}\n\n\tinterface DXL {\n\t\tlong f(double a, A b);\n\t}\n\n\tinterface DXXL {\n\t\tlong f(double a, A b, B c);\n\t}\n\n\tinterface DXXXL {\n\t\tlong f(double a, A b, B c, C d);\n\t}\n\n\tinterface XDL {\n\t\tlong f(A a, double b);\n\t}\n\n\tinterface XXDL {\n\t\tlong f(A a, B b, double c);\n\t}\n\n\tinterface XXXDL {\n\t\tlong f(A a, B b, C c, double d);\n\t}\n\n\tinterface XL {\n\t\tlong f(A a);\n\t}\n\n\tinterface XXL {\n\t\tlong f(A a, B b);\n\t}\n\n\tinterface XXXL {\n\t\tlong f(A a, B b, C c);\n\t}\n\n\tinterface XXXXL {\n\t\tlong f(A a, B b, C c, D d);\n\t}\n\n\tinterface BBL {\n\t\tlong f(boolean a, boolean b);\n\t}\n\n\tinterface BIL {\n\t\tlong f(boolean a, int b);\n\t}\n\n\tinterface BLL {\n\t\tlong f(boolean a, long b);\n\t}\n\n\tinterface BDL {\n\t\tlong f(boolean a, double b);\n\t}\n\n\tinterface IBL {\n\t\tlong f(int a, boolean b);\n\t}\n\n\tinterface IIL {\n\t\tlong f(int a, int b);\n\t}\n\n\tinterface ILL {\n\t\tlong f(int a, long b);\n\t}\n\n\tinterface IDL {\n\t\tlong f(int a, double b);\n\t}\n\n\tinterface LBL {\n\t\tlong f(long a, boolean b);\n\t}\n\n\tinterface LIL {\n\t\tlong f(long a, int b);\n\t}\n\n\tinterface LLL {\n\t\tlong f(long a, long b);\n\t}\n\n\tinterface LDL {\n\t\tlong f(long a, double b);\n\t}\n\n\tinterface DBL {\n\t\tlong f(double a, boolean b);\n\t}\n\n\tinterface DIL {\n\t\tlong f(double a, int b);\n\t}\n\n\tinterface DLL {\n\t\tlong f(double a, long b);\n\t}\n\n\tinterface DDL {\n\t\tlong f(double a, double b);\n\t}\n\n\tinterface VD {\n\t\tdouble f();\n\t}\n\n\tinterface BD {\n\t\tdouble f(boolean a);\n\t}\n\n\tinterface BXD {\n\t\tdouble f(boolean a, A b);\n\t}\n\n\tinterface BXXD {\n\t\tdouble f(boolean a, A b, B c);\n\t}\n\n\tinterface BXXXD {\n\t\tdouble f(boolean a, A b, B c, C d);\n\t}\n\n\tinterface XBD {\n\t\tdouble f(A a, boolean b);\n\t}\n\n\tinterface XXBD {\n\t\tdouble f(A a, B b, boolean c);\n\t}\n\n\tinterface XXXBD {\n\t\tdouble f(A a, B b, C c, boolean d);\n\t}\n\n\tinterface ID {\n\t\tdouble f(int a);\n\t}\n\n\tinterface IXD {\n\t\tdouble f(int a, A b);\n\t}\n\n\tinterface IXXD {\n\t\tdouble f(int a, A b, B c);\n\t}\n\n\tinterface IXXXD {\n\t\tdouble f(int a, A b, B c, C d);\n\t}\n\n\tinterface XID {\n\t\tdouble f(A a, int b);\n\t}\n\n\tinterface XXID {\n\t\tdouble f(A a, B b, int c);\n\t}\n\n\tinterface XXXID {\n\t\tdouble f(A a, B b, C c, int d);\n\t}\n\n\tinterface LD {\n\t\tdouble f(long a);\n\t}\n\n\tinterface LXD {\n\t\tdouble f(long a, A b);\n\t}\n\n\tinterface LXXD {\n\t\tdouble f(long a, A b, B c);\n\t}\n\n\tinterface LXXXD {\n\t\tdouble f(long a, A b, B c, C d);\n\t}\n\n\tinterface XLD {\n\t\tdouble f(A a, long b);\n\t}\n\n\tinterface XXLD {\n\t\tdouble f(A a, B b, long c);\n\t}\n\n\tinterface XXXLD {\n\t\tdouble f(A a, B b, C c, long d);\n\t}\n\n\tinterface DD {\n\t\tdouble f(double a);\n\t}\n\n\tinterface DXD {\n\t\tdouble f(double a, A b);\n\t}\n\n\tinterface DXXD {\n\t\tdouble f(double a, A b, B c);\n\t}\n\n\tinterface DXXXD {\n\t\tdouble f(double a, A b, B c, C d);\n\t}\n\n\tinterface XDD {\n\t\tdouble f(A a, double b);\n\t}\n\n\tinterface XXDD {\n\t\tdouble f(A a, B b, double c);\n\t}\n\n\tinterface XXXDD {\n\t\tdouble f(A a, B b, C c, double d);\n\t}\n\n\tinterface XD {\n\t\tdouble f(A a);\n\t}\n\n\tinterface XXD {\n\t\tdouble f(A a, B b);\n\t}\n\n\tinterface XXXD {\n\t\tdouble f(A a, B b, C c);\n\t}\n\n\tinterface XXXXD {\n\t\tdouble f(A a, B b, C c, D d);\n\t}\n\n\tinterface BBD {\n\t\tdouble f(boolean a, boolean b);\n\t}\n\n\tinterface BID {\n\t\tdouble f(boolean a, int b);\n\t}\n\n\tinterface BLD {\n\t\tdouble f(boolean a, long b);\n\t}\n\n\tinterface BDD {\n\t\tdouble f(boolean a, double b);\n\t}\n\n\tinterface IBD {\n\t\tdouble f(int a, boolean b);\n\t}\n\n\tinterface IID {\n\t\tdouble f(int a, int b);\n\t}\n\n\tinterface ILD {\n\t\tdouble f(int a, long b);\n\t}\n\n\tinterface IDD {\n\t\tdouble f(int a, double b);\n\t}\n\n\tinterface LBD {\n\t\tdouble f(long a, boolean b);\n\t}\n\n\tinterface LID {\n\t\tdouble f(long a, int b);\n\t}\n\n\tinterface LLD {\n\t\tdouble f(long a, long b);\n\t}\n\n\tinterface LDD {\n\t\tdouble f(long a, double b);\n\t}\n\n\tinterface DBD {\n\t\tdouble f(double a, boolean b);\n\t}\n\n\tinterface DID {\n\t\tdouble f(double a, int b);\n\t}\n\n\tinterface DLD {\n\t\tdouble f(double a, long b);\n\t}\n\n\tinterface DDD {\n\t\tdouble f(double a, double b);\n\t}\n\n\tinterface VX {\n\t\tA f();\n\t}\n\n\tinterface BX {\n\t\tA f(boolean a);\n\t}\n\n\tinterface BXX {\n\t\tB f(boolean a, A b);\n\t}\n\n\tinterface BXXX {\n\t\tC f(boolean a, A b, B c);\n\t}\n\n\tinterface BXXXX {\n\t\tD f(boolean a, A b, B c, C d);\n\t}\n\n\tinterface XBX {\n\t\tB f(A a, boolean b);\n\t}\n\n\tinterface XXBX {\n\t\tC f(A a, B b, boolean c);\n\t}\n\n\tinterface XXXBX {\n\t\tD f(A a, B b, C c, boolean d);\n\t}\n\n\tinterface IX {\n\t\tA f(int a);\n\t}\n\n\tinterface IXX {\n\t\tB f(int a, A b);\n\t}\n\n\tinterface IXXX {\n\t\tC f(int a, A b, B c);\n\t}\n\n\tinterface IXXXX {\n\t\tD f(int a, A b, B c, C d);\n\t}\n\n\tinterface XIX {\n\t\tB f(A a, int b);\n\t}\n\n\tinterface XXIX {\n\t\tC f(A a, B b, int c);\n\t}\n\n\tinterface XXXIX {\n\t\tD f(A a, B b, C c, int d);\n\t}\n\n\tinterface LX {\n\t\tA f(long a);\n\t}\n\n\tinterface LXX {\n\t\tB f(long a, A b);\n\t}\n\n\tinterface LXXX {\n\t\tC f(long a, A b, B c);\n\t}\n\n\tinterface LXXXX {\n\t\tD f(long a, A b, B c, C d);\n\t}\n\n\tinterface XLX {\n\t\tB f(A a, long b);\n\t}\n\n\tinterface XXLX {\n\t\tC f(A a, B b, long c);\n\t}\n\n\tinterface XXXLX {\n\t\tD f(A a, B b, C c, long d);\n\t}\n\n\tinterface DX {\n\t\tA f(double a);\n\t}\n\n\tinterface DXX {\n\t\tB f(double a, A b);\n\t}\n\n\tinterface DXXX {\n\t\tC f(double a, A b, B c);\n\t}\n\n\tinterface DXXXX {\n\t\tD f(double a, A b, B c, C d);\n\t}\n\n\tinterface XDX {\n\t\tB f(A a, double b);\n\t}\n\n\tinterface XXDX {\n\t\tC f(A a, B b, double c);\n\t}\n\n\tinterface XXXDX {\n\t\tD f(A a, B b, C c, double d);\n\t}\n\n\tinterface XX {\n\t\tB f(A a);\n\t}\n\n\tinterface XXX {\n\t\tC f(A a, B b);\n\t}\n\n\tinterface XXXX {\n\t\tD f(A a, B b, C c);\n\t}\n\n\tinterface XXXXX {\n\t\tE f(A a, B b, C c, D d);\n\t}\n\n\tinterface BBX {\n\t\tA f(boolean a, boolean b);\n\t}\n\n\tinterface BIX {\n\t\tA f(boolean a, int b);\n\t}\n\n\tinterface BLX {\n\t\tA f(boolean a, long b);\n\t}\n\n\tinterface BDX {\n\t\tA f(boolean a, double b);\n\t}\n\n\tinterface IBX {\n\t\tA f(int a, boolean b);\n\t}\n\n\tinterface IIX {\n\t\tA f(int a, int b);\n\t}\n\n\tinterface ILX {\n\t\tA f(int a, long b);\n\t}\n\n\tinterface IDX {\n\t\tA f(int a, double b);\n\t}\n\n\tinterface LBX {\n\t\tA f(long a, boolean b);\n\t}\n\n\tinterface LIX {\n\t\tA f(long a, int b);\n\t}\n\n\tinterface LLX {\n\t\tA f(long a, long b);\n\t}\n\n\tinterface LDX {\n\t\tA f(long a, double b);\n\t}\n\n\tinterface DBX {\n\t\tA f(double a, boolean b);\n\t}\n\n\tinterface DIX {\n\t\tA f(double a, int b);\n\t}\n\n\tinterface DLX {\n\t\tA f(double a, long b);\n\t}\n\n\tinterface DDX {\n\t\tA f(double a, double b);\n\t}\n}\n\nclass SA { // suffix array\n\tstatic int[] makeSA(String s) {\n\t\tint n = s.length() + 1;\n\t\tint[] cs = new int[n];\n\t\tcs[n - 1] = 0;\n\t\tfor (int i = 0; i < n - 1; i++)\n\t\t\tcs[i] = s.charAt(i) + 1;\n\t\tArrayList acs = U.make(n, i -> cs[i]);\n\t\tTreeMap tm = U.compress(acs).a;\n\t\tint k = tm.size();\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tcs[i] = tm.get(cs[i]);\n\t\treturn makeSA(cs, n, k);\n\t}\n\n\tstatic int[] makeLCP(String s, int[] sa) { // lcp(i, i+1)\n\t\tint n = sa.length;\n\t\tint[] r = new int[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tr[sa[i]] = i;\n\t\tint[] lcp = new int[n];\n\t\tint l = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tint idx = r[i];\n\t\t\tif (idx == n - 1) {\n\t\t\t\tlcp[idx] = -1;\n\t\t\t\tl = 0;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tint p = sa[idx];\n\t\t\tint q = sa[idx + 1];\n\t\t\tif (l > 0)\n\t\t\t\tl--;\n\t\t\twhile (p + l < n - 1 && q + l < n - 1 && s.charAt(p + l) == s.charAt(q + l))\n\t\t\t\tl++;\n\t\t\tlcp[idx] = l;\n\t\t}\n\t\treturn lcp;\n\t}\n\n\tstatic F.III lcpQuery(String s) {\n\t\tint n = s.length() + 1;\n\t\tint[] sa = makeSA(s);\n\t\tint[] lcp = makeLCP(s, sa);\n\t\tint[] inv = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tinv[sa[i]] = i;\n\t\t}\n\t\tST st = new ST(n, (a, b) -> a < b ? a : b, Integer.MAX_VALUE);\n\t\tst.init(i -> i < n ? lcp[i] : Integer.MAX_VALUE);\n\t\treturn (i, j) -> {\n\t\t\tif (i == j)\n\t\t\t\treturn n - 1 - i;\n\t\t\ti = inv[i];\n\t\t\tj = inv[j];\n\t\t\tif (i > j) {\n\t\t\t\ti ^= j;\n\t\t\t\tj ^= i;\n\t\t\t\ti ^= j;\n\t\t\t}\n\t\t\treturn st.query(i, j);\n\t\t};\n\t}\n\n\tprivate static int[] makeSA(int[] cs, int n, int k) {\n\t\tboolean[] isS = new boolean[n];\n\t\tboolean[] isLms = new boolean[n];\n\t\tint[] lmss = new int[n];\n\t\tint numLmss = 0;\n\t\tisS[n - 1] = true;\n\t\tfor (int i = n - 2; i >= 0; i--)\n\t\t\tisS[i] = cs[i] < cs[i + 1] || cs[i] == cs[i + 1] && isS[i + 1];\n\t\tfor (int i = 1; i < n; i++)\n\t\t\tif (!isS[i - 1] && isS[i]) {\n\t\t\t\tlmss[numLmss++] = i;\n\t\t\t\tisLms[i] = true;\n\t\t\t}\n\t\tint[] sa = inducedSort(cs, n, numLmss, k, lmss, isS);\n\t\tint[] lmss2 = new int[numLmss];\n\t\tnumLmss = 0;\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tif (isLms[sa[i]])\n\t\t\t\tlmss2[numLmss++] = sa[i];\n\t\tint num = 0;\n\t\tsa[lmss2[0]] = 0;\n\t\tfor (int i = 0; i < numLmss - 1; i++) {\n\t\t\tint p = lmss2[i];\n\t\t\tint q = lmss2[i + 1];\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tif (cs[p] != cs[q] || isLms[p] != isLms[q]) {\n\t\t\t\t\tsa[lmss2[i + 1]] = ++num;\n\t\t\t\t\tbreak;\n\t\t\t\t} else if (j > 0 && (isLms[p] || isLms[q])) {\n\t\t\t\t\tsa[lmss2[i + 1]] = num;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tp++;\n\t\t\t\tq++;\n\t\t\t}\n\t\t}\n\t\tif (num + 1 < numLmss) {\n\t\t\tnumLmss = 0;\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\tif (isLms[i])\n\t\t\t\t\tlmss2[numLmss++] = sa[i];\n\t\t\tlmss2 = makeSA(lmss2, numLmss, num + 1);\n\t\t\tfor (int i = 0; i < numLmss; i++)\n\t\t\t\tlmss2[i] = lmss[lmss2[i]];\n\t\t}\n\t\treturn inducedSort(cs, n, numLmss, k, lmss2, isS);\n\t}\n\n\tprivate static int[] inducedSort(int[] cs, int n, int numLmss, int k, int[] lmss, boolean[] isS) {\n\t\tint[] sa = new int[n];\n\t\tint[] bin = new int[k + 1];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tbin[cs[i] + 1]++;\n\t\tfor (int i = 0; i < k; i++)\n\t\t\tbin[i + 1] += bin[i];\n\t\tint[] counts = new int[k];\n\t\tfor (int i = numLmss - 1; i >= 0; i--) { // put LMS backward\n\t\t\tint c = cs[lmss[i]];\n\t\t\tsa[bin[c + 1] - 1 - counts[c]++] = lmss[i];\n\t\t}\n\t\tfor (int i = 0; i < k; i++)\n\t\t\tcounts[i] = 0;\n\t\tfor (int i = 0; i < n; i++) { // put L forward\n\t\t\tint s = sa[i] - 1;\n\t\t\tif (s < 0 || isS[s])\n\t\t\t\tcontinue;\n\t\t\tint c = cs[s];\n\t\t\tsa[bin[c] + counts[c]++] = s;\n\t\t}\n\t\tfor (int i = 0; i < k; i++)\n\t\t\tcounts[i] = 0;\n\t\tfor (int i = n - 1; i >= 0; i--) { // put S backward\n\t\t\tint s = sa[i] - 1;\n\t\t\tif (s < 0 || !isS[s])\n\t\t\t\tcontinue;\n\t\t\tint c = cs[s];\n\t\t\tsa[bin[c + 1] - 1 - counts[c]++] = s;\n\t\t}\n\t\treturn sa;\n\t}\n}\n\nclass ST { // Segment Tree\n\tprivate ArrayList as;\n\tprivate int h;\n\tprivate int n;\n\tprivate F.XXX merger;\n\tprivate A e;\n\n\tST(int num, F.XXX merger, A e) {\n\t\tthis.merger = merger;\n\t\tthis.e = e;\n\t\th = 0;\n\t\twhile ((1 << h) < num)\n\t\t\th++;\n\t\tn = 1 << h;\n\t\tas = U.make(2 * n, i -> e);\n\t}\n\n\tvoid init(A a) {\n\t\tinit(i -> a);\n\t}\n\n\tvoid init(A[] as) {\n\t\tinit(i -> i < as.length ? as[i] : e);\n\t}\n\n\tvoid init(F.IX maker) {\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tas.set(n + i, maker.f(i));\n\t\tfor (int i = n - 1; i > 0; i--)\n\t\t\tas.set(i, merge(as.get(i << 1), as.get(i << 1 | 1)));\n\t}\n\n\tA get(int i) {\n\t\treturn query(i, i + 1);\n\t}\n\n\tvoid set(int i, A a) {\n\t\tas.set(i += n, a);\n\t\twhile ((i >>= 1) > 0)\n\t\t\tas.set(i, merge(as.get(i << 1), as.get(i << 1 | 1)));\n\t}\n\n\tA query(int l, int r) {\n\t\tl += n;\n\t\tr += n;\n\t\tA al = e;\n\t\tA ar = e;\n\t\twhile (l < r) {\n\t\t\tif ((l & 1) != 0)\n\t\t\t\tal = merge(al, as.get(l++));\n\t\t\tif ((r & 1) != 0)\n\t\t\t\tar = merge(as.get(--r), ar);\n\t\t\tl >>= 1;\n\t\t\tr >>= 1;\n\t\t}\n\t\treturn merge(al, ar);\n\t}\n\n\tprivate A merge(A a, A b) {\n\t\treturn a == e ? b : b == e ? a : merger.f(a, b);\n\t}\n}\n\nclass LST { // Lazy Segment Tree\n\tprivate ArrayList as;\n\tprivate ArrayList lazy;\n\tprivate F.XXX merger;\n\tprivate F.XXIX applier;\n\tprivate F.XXX opMerger;\n\tprivate A e;\n\tprivate Op id;\n\tprivate int h;\n\tprivate int n;\n\n\tLST(int num, F.XXX merger, F.XXIX applier, F.XXX opMerger, A e, Op id) {\n\t\tthis.merger = merger;\n\t\tthis.applier = applier;\n\t\tthis.opMerger = opMerger;\n\t\tthis.e = e;\n\t\tthis.id = id;\n\t\th = 0;\n\t\twhile ((1 << h) < num)\n\t\t\th++;\n\t\tn = 1 << h;\n\t\tint size = n << 1;\n\t\tas = U.make(size, i -> e);\n\t\tlazy = U.make(size, i -> id);\n\t}\n\n\tvoid init(A a) {\n\t\tinit(i -> a);\n\t}\n\n\tvoid init(A[] as) {\n\t\tinit(i -> i < as.length ? as[i] : e);\n\t}\n\n\tvoid init(F.IX maker) {\n\t\tfor (int i = 0; i < n << 1; i++)\n\t\t\tlazy.set(i, id);\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tas.set(n + i, maker.f(i));\n\t\tfor (int i = n - 1; i > 0; i--)\n\t\t\tas.set(i, merge(as.get(i << 1), as.get(i << 1 | 1)));\n\t}\n\n\tA get(int i) {\n\t\treturn query(i, i + 1);\n\t}\n\n\tvoid set(int i, A a) {\n\t\tprop(i += n);\n\t\tas.set(i, a);\n\t\tlazy.set(i, id);\n\t\tbackprop(i);\n\t}\n\n\tA query(int l, int r) {\n\t\tprop(l += n);\n\t\tprop(r += n - 1);\n\t\tr++;\n\t\tA al = e;\n\t\tA ar = e;\n\t\tint len = 1;\n\t\twhile (l < r) {\n\t\t\tif ((l & 1) != 0)\n\t\t\t\tal = merge(al, eval(l++, len));\n\t\t\tif ((r & 1) != 0)\n\t\t\t\tar = merge(eval(--r, len), ar);\n\t\t\tl >>= 1;\n\t\t\tr >>= 1;\n\t\t\tlen <<= 1;\n\t\t}\n\t\treturn merge(al, ar);\n\t}\n\n\tvoid apply(int l, int r, Op o) {\n\t\tprop(l += n);\n\t\tprop(r += n - 1);\n\t\tint a = l;\n\t\tint b = r;\n\t\tr++;\n\t\twhile (l < r) {\n\t\t\tif ((l & 1) != 0)\n\t\t\t\tlazy.set(l, mergeOp(lazy.get(l++), o));\n\t\t\tif ((r & 1) != 0)\n\t\t\t\tlazy.set(--r, mergeOp(lazy.get(r), o));\n\t\t\tl >>= 1;\n\t\t\tr >>= 1;\n\t\t}\n\t\tbackprop(a);\n\t\tbackprop(b);\n\t}\n\n\tint size() {\n\t\treturn n;\n\t}\n\n\tprivate A merge(A a, A b) {\n\t\treturn a == e ? b : b == e ? a : merger.f(a, b);\n\t}\n\n\tprivate Op mergeOp(Op o, Op p) {\n\t\treturn o == id ? p : p == id ? o : opMerger.f(o, p);\n\t}\n\n\tprivate A apply(A a, Op o, int len) {\n\t\treturn o == id ? a : applier.f(a, o, len);\n\t}\n\n\tprivate A eval(int k, int len) {\n\t\treturn apply(as.get(k), lazy.get(k), len);\n\t}\n\n\tprivate void flush(int k, int len) {\n\t\tOp o = lazy.get(k);\n\t\tif (o == id)\n\t\t\treturn;\n\t\tlazy.set(k << 1, mergeOp(lazy.get(k << 1), o));\n\t\tlazy.set(k << 1 | 1, mergeOp(lazy.get(k << 1 | 1), o));\n\t\tas.set(k, apply(as.get(k), o, len));\n\t\tlazy.set(k, id);\n\t}\n\n\tprivate void prop(int k) {\n\t\tfor (int i = h; i > 0; i--)\n\t\t\tflush(k >> i, 1 << i);\n\t}\n\n\tprivate void backprop(int k) {\n\t\tint len = 1;\n\t\twhile ((k >>= 1) > 0) {\n\t\t\tas.set(k, merge(eval(k << 1, len), eval(k << 1 | 1, len)));\n\t\t\tlen <<= 1;\n\t\t}\n\t}\n}\n\ninterface Magma {\n\tA g(A a, A b);\n}\n\ninterface Associative {\n}\n\ninterface Unital {\n\tA e();\n}\n\ninterface Invertible {\n\tA inv(A a);\n}\n\ninterface Commutative {\n}\n\ninterface SemiGroup extends Magma, Associative {\n}\n\ninterface Monoid extends SemiGroup, Unital {\n\tstatic Monoid make(F.XXX g, A e) {\n\t\treturn new Monoid() {\n\t\t\tpublic A g(A a, A b) {\n\t\t\t\treturn a.equals(e) ? b : b.equals(e) ? a : g.f(a, b);\n\t\t\t}\n\n\t\t\tpublic A e() {\n\t\t\t\treturn e;\n\t\t\t}\n\t\t};\n\t}\n}\n\ninterface CommutativeMonoid extends Monoid, Commutative {\n\tstatic CommutativeMonoid make(F.XXX g, A e) {\n\t\treturn new CommutativeMonoid() {\n\t\t\tpublic A g(A a, A b) {\n\t\t\t\treturn a.equals(e) ? b : b.equals(e) ? a : g.f(a, b);\n\t\t\t}\n\n\t\t\tpublic A e() {\n\t\t\t\treturn e;\n\t\t\t}\n\t\t};\n\t}\n}\n\ninterface Group extends Monoid, Invertible {\n\tstatic Group make(F.XXX g, F.XX inv, A e) {\n\t\treturn new Group() {\n\t\t\tpublic A g(A a, A b) {\n\t\t\t\treturn a.equals(e) ? b : b.equals(e) ? a : g.f(a, b);\n\t\t\t}\n\n\t\t\tpublic A e() {\n\t\t\t\treturn e;\n\t\t\t}\n\n\t\t\tpublic A inv(A a) {\n\t\t\t\treturn a.equals(e) ? e : inv.f(a);\n\t\t\t}\n\t\t};\n\t}\n}\n\ninterface AbelianGroup extends Group, CommutativeMonoid {\n\tstatic AbelianGroup make(F.XXX g, F.XX inv, A e) {\n\t\treturn new AbelianGroup() {\n\t\t\tpublic A g(A a, A b) {\n\t\t\t\treturn a.equals(e) ? b : b.equals(e) ? a : g.f(a, b);\n\t\t\t}\n\n\t\t\tpublic A e() {\n\t\t\t\treturn e;\n\t\t\t}\n\n\t\t\tpublic A inv(A a) {\n\t\t\t\treturn a.equals(e) ? e : inv.f(a);\n\t\t\t}\n\t\t};\n\t}\n}\n\ninterface Ring {\n\tAbelianGroup add();\n\n\tMonoid mul();\n\n\tdefault A zero() {\n\t\treturn add().e();\n\t}\n\n\tdefault A one() {\n\t\treturn mul().e();\n\t}\n\n\tstatic Ring make(F.XXX add, F.XX neg, F.XXX mul, A zero, A one) {\n\t\treturn make(AbelianGroup.make(add, neg, zero), Monoid.make(mul, one));\n\t}\n\n\tstatic Ring make(AbelianGroup add, Monoid mul) {\n\t\treturn new Ring() {\n\t\t\tpublic AbelianGroup add() {\n\t\t\t\treturn add;\n\t\t\t}\n\n\t\t\tpublic Monoid mul() {\n\t\t\t\treturn mul;\n\t\t\t}\n\t\t};\n\t}\n}\n\ninterface CommutativeRing extends Ring {\n\tCommutativeMonoid mul();\n\n\tstatic CommutativeRing make(F.XXX add, F.XX neg, F.XXX mul, A zero, A one) {\n\t\treturn make(AbelianGroup.make(add, neg, zero), CommutativeMonoid.make(mul, one));\n\t}\n\n\tstatic CommutativeRing make(AbelianGroup add, CommutativeMonoid mul) {\n\t\treturn new CommutativeRing() {\n\t\t\tpublic AbelianGroup add() {\n\t\t\t\treturn add;\n\t\t\t}\n\n\t\t\tpublic CommutativeMonoid mul() {\n\t\t\t\treturn mul;\n\t\t\t}\n\t\t};\n\t}\n}\n\ninterface EuclideanRing extends CommutativeRing {\n\tA div(A a, A b);\n\n\tA mod(A a, A b);\n\n\tstatic EuclideanRing make(F.XXX add, F.XX neg, F.XXX mul, F.XXX div,\n\t\t\tF.XXX mod, A zero, A one) {\n\t\treturn make(AbelianGroup.make(add, neg, zero), CommutativeMonoid.make(mul, one), div, mod);\n\t}\n\n\tstatic EuclideanRing make(AbelianGroup add, CommutativeMonoid mul, F.XXX div,\n\t\t\tF.XXX mod) {\n\t\tfinal A zero = add.e();\n\t\tfinal A one = mul.e();\n\t\treturn new EuclideanRing() {\n\t\t\tpublic AbelianGroup add() {\n\t\t\t\treturn add;\n\t\t\t}\n\n\t\t\tpublic CommutativeMonoid mul() {\n\t\t\t\treturn mul;\n\t\t\t}\n\n\t\t\tpublic A div(A a, A b) {\n\t\t\t\tif (b.equals(zero))\n\t\t\t\t\tthrow new ArithmeticException(\"division by zero\");\n\t\t\t\treturn b.equals(one) ? a : div.f(a, b);\n\t\t\t}\n\n\t\t\tpublic A mod(A a, A b) {\n\t\t\t\tif (b.equals(zero))\n\t\t\t\t\tthrow new ArithmeticException(\"division by zero\");\n\t\t\t\treturn b.equals(one) ? zero : mod.f(a, b);\n\t\t\t}\n\t\t};\n\t}\n}\n\ninterface Field extends EuclideanRing {\n\tAbelianGroup mul();\n\n\tstatic Field make(F.XXX add, F.XX neg, F.XXX mul, F.XX inv, A zero, A one) {\n\t\treturn make(AbelianGroup.make(add, neg, zero), AbelianGroup.make(mul, inv, one));\n\t}\n\n\tstatic Field make(AbelianGroup add, AbelianGroup mul) {\n\t\tfinal A zero = add.e();\n\t\tfinal A one = mul.e();\n\t\treturn new Field() {\n\t\t\tpublic AbelianGroup add() {\n\t\t\t\treturn add;\n\t\t\t}\n\n\t\t\tpublic AbelianGroup mul() {\n\t\t\t\treturn mul;\n\t\t\t}\n\n\t\t\tpublic A div(A a, A b) {\n\t\t\t\tif (b.equals(zero))\n\t\t\t\t\tthrow new ArithmeticException(\"division by zero\");\n\t\t\t\treturn b.equals(one) ? a : mul.g(a, mul.inv(b));\n\t\t\t}\n\n\t\t\tpublic A mod(A a, A b) {\n\t\t\t\tif (b.equals(zero))\n\t\t\t\t\tthrow new ArithmeticException(\"division by zero\");\n\t\t\t\treturn zero;\n\t\t\t}\n\t\t};\n\t}\n}\n\nfinal class Alg {\n\tprivate Alg() {\n\t}\n\n\tstatic > A gcd(A a, A b, EuclideanRing ring) {\n\t\tAbelianGroup add = ring.add();\n\t\tA zero = add.e();\n\t\tint sa = a.compareTo(zero);\n\t\tint sb = b.compareTo(zero);\n\t\tif (sa == 0)\n\t\t\treturn b;\n\t\tif (sb == 0)\n\t\t\treturn a;\n\t\tif (sa < 0)\n\t\t\ta = add.inv(a);\n\t\tif (sb < 0)\n\t\t\tb = add.inv(b);\n\t\tif (a.compareTo(b) < 0) {\n\t\t\tA tmp = a;\n\t\t\ta = b;\n\t\t\tb = tmp;\n\t\t}\n\t\twhile (true) {\n\t\t\tA c = ring.mod(a, b);\n\t\t\tif (c.compareTo(zero) == 0)\n\t\t\t\treturn b;\n\t\t\ta = b;\n\t\t\tb = c;\n\t\t}\n\t}\n\n\tstatic long gcd(long a, long b) {\n\t\tif (a == 0)\n\t\t\treturn b;\n\t\tif (b == 0)\n\t\t\treturn a;\n\t\tif (a < 0)\n\t\t\ta = -a;\n\t\tif (b < 0)\n\t\t\tb = -b;\n\t\tif (a < b) {\n\t\t\ta ^= b;\n\t\t\tb ^= a;\n\t\t\ta ^= b;\n\t\t}\n\t\twhile (true) {\n\t\t\tlong c = a % b;\n\t\t\tif (c == 0)\n\t\t\t\treturn b;\n\t\t\ta = b;\n\t\t\tb = c;\n\t\t}\n\t}\n\n\tstatic int gcd(int a, int b) {\n\t\treturn (int) gcd((long) a, (long) b);\n\t}\n\n\tstatic > int[] lis(F.IX access, int size) {\n\t\tObject[] dp = new Object[size];\n\t\tint[][] dpIndices = new int[size][2];\n\t\tdp[0] = access.f(0);\n\t\tint len = 1;\n\t\tint lidx = 0;\n\t\tfor (int i = 1; i < size; i++) {\n\t\t\tA ai = access.f(i);\n\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\tint idx = U.searchI(-1, len, j -> ai.compareTo((A) dp[j]) <= 0); // replace <= with < to return NLDS\n\t\t\tdp[idx] = ai;\n\t\t\tdpIndices[idx][0] = i;\n\t\t\tif (idx == len) {\n\t\t\t\tlidx = i;\n\t\t\t\tlen++;\n\t\t\t}\n\t\t\tif (idx > 0)\n\t\t\t\tdpIndices[i][1] = dpIndices[idx - 1][0];\n\t\t}\n\t\tint[] res = new int[len];\n\t\tres[len - 1] = lidx;\n\t\tfor (int i = len - 1; i >= 0; i--) {\n\t\t\tres[i] = lidx;\n\t\t\tlidx = dpIndices[lidx][1];\n\t\t}\n\t\treturn res;\n\t}\n\n\tstatic A pow(A a, long b, Monoid monoid) {\n\t\tA res = monoid.e();\n\t\twhile (b > 0) {\n\t\t\tif ((b & 1) != 0)\n\t\t\t\tres = monoid.g(res, a);\n\t\t\ta = monoid.g(a, a);\n\t\t\tb >>= 1;\n\t\t}\n\t\treturn res;\n\t}\n\n\tstatic A pow(A a, BigInteger b, Monoid monoid) {\n\t\tA res = monoid.e();\n\t\twhile (b.compareTo(BigInteger.ZERO) > 0) {\n\t\t\tif ((b.and(BigInteger.ONE)).intValueExact() != 0)\n\t\t\t\tres = monoid.g(res, a);\n\t\t\ta = monoid.g(a, a);\n\t\t\tb = b.divide(BigInteger.valueOf(2));\n\t\t}\n\t\treturn res;\n\t}\n\n\tstatic long pow(long a, long b) {\n\t\tlong res = 1;\n\t\twhile (b > 0) {\n\t\t\tif ((b & 1) != 0)\n\t\t\t\tres *= a;\n\t\t\ta *= a;\n\t\t\tb >>= 1;\n\t\t}\n\t\treturn res;\n\t}\n\n\tstatic > T extgcd(A a, A b, EuclideanRing ring) { // returns (x, y, d) s.t. ax + by = d\n\t\tAbelianGroup add = ring.add();\n\t\tCommutativeMonoid mul = ring.mul();\n\t\tA zero = add.e();\n\t\tA one = mul.e();\n\t\tA sa = a.compareTo(zero) < 0 ? add.inv(one) : one;\n\t\tA sb = b.compareTo(zero) < 0 ? add.inv(one) : one;\n\t\ta = mul.g(a, sa);\n\t\tb = mul.g(b, sb);\n\t\tA x = one;\n\t\tA y = zero;\n\t\tA z = zero;\n\t\tA w = one;\n\t\twhile (b.compareTo(zero) > 0) {\n\t\t\tA q = ring.div(a, b);\n\t\t\tA t = z;\n\t\t\tz = add.g(x, add.inv(mul.g(q, z)));\n\t\t\tx = t;\n\t\t\tt = w;\n\t\t\tw = add.g(y, add.inv(mul.g(q, w)));\n\t\t\ty = t;\n\t\t\tt = b;\n\t\t\tb = add.g(a, add.inv(mul.g(q, b)));\n\t\t\ta = t;\n\t\t}\n\t\treturn T.make(mul.g(x, sa), mul.g(y, sb), a);\n\t}\n\n\tstatic TL extgcd(long a, long b) {\n\t\tint sa = a < 0 ? -1 : 1;\n\t\tint sb = b < 0 ? -1 : 1;\n\t\ta *= sa;\n\t\tb *= sb;\n\t\tlong x = 1;\n\t\tlong y = 0;\n\t\tlong z = 0;\n\t\tlong w = 1;\n\t\twhile (b > 0) {\n\t\t\tlong q = a / b;\n\t\t\tlong t = z;\n\t\t\tz = x - q * z;\n\t\t\tx = t;\n\t\t\tt = w;\n\t\t\tw = y - q * w;\n\t\t\ty = t;\n\t\t\tt = b;\n\t\t\tb = a - q * b;\n\t\t\ta = t;\n\t\t}\n\t\treturn TL.make(x * sa, y * sb, a);\n\t}\n\n\tstatic TI extgcd(int a, int b) {\n\t\treturn extgcd((long) a, (long) b).toInt();\n\t}\n\n\tstatic ArrayList factorize(int n) { // factor, exponent\n\t\tArrayList res = new ArrayList();\n\t\tfor (int i = 2; i * i <= n; i++) {\n\t\t\tint count = 0;\n\t\t\twhile (n % i == 0) {\n\t\t\t\tn /= i;\n\t\t\t\tcount++;\n\t\t\t}\n\t\t\tif (count > 0)\n\t\t\t\tres.add(PI.make(i, count));\n\t\t}\n\t\tif (n > 1)\n\t\t\tres.add(PI.make(n, 1));\n\t\treturn res;\n\t}\n\n\tstatic ArrayList factorize(long n) { // factor, exponent\n\t\tArrayList res = new ArrayList();\n\t\tfor (int i = 2; i * i <= n; i++) {\n\t\t\tint count = 0;\n\t\t\twhile (n % i == 0) {\n\t\t\t\tn /= i;\n\t\t\t\tcount++;\n\t\t\t}\n\t\t\tif (count > 0)\n\t\t\t\tres.add(PL.make(i, count));\n\t\t}\n\t\tif (n > 1)\n\t\t\tres.add(PL.make(n, 1));\n\t\treturn res;\n\t}\n\n\tstatic A arithSum(A a, A d, long num, Ring ring) {\n\t\treturn arithGeomSum(a, d, ring.one(), ring.one(), num, ring);\n\t}\n\n\tstatic A geomSum(A b, A r, long num, Ring ring) {\n\t\treturn arithGeomSum(ring.one(), ring.zero(), b, r, num, ring);\n\t}\n\n\tstatic A arithGeomSum(A a, A d, A b, A r, long num, Ring ring) { // Σ(a+(i-1)d)br^(i-1)\n\t\tAbelianGroup add = ring.add();\n\t\tMonoid mul = ring.mul();\n\t\tMonoid> matMul = Mat.mulRing(3, ring);\n\t\tA zero = ring.zero();\n\t\tA one = ring.one();\n\t\tMN mat = pow(Mat.make(new Object[][] { { r, d, a }, { zero, r, r }, { zero, zero, one } }), num - 1, matMul);\n\t\treturn mul.g(add.g(add.g(mul.g(mat.at(0, 0), a), mul.g(mat.at(0, 1), r)), mat.at(0, 2)), b);\n\t}\n}\n\nclass MN {\n\tfinal int m;\n\tfinal int n;\n\tprivate final Object[][] as;\n\n\tstatic class Scalar extends MN {\n\t\tfinal long l;\n\t\tA a;\n\n\t\tScalar(int m, int n, long l, A zero, A oneTimesL) {\n\t\t\tsuper(m, n, (i, j) -> i == j ? oneTimesL : zero);\n\t\t\tthis.a = oneTimesL;\n\t\t\tthis.l = l;\n\t\t}\n\t}\n\n\tMN(int m, int n, Mat.Accessor accessor) {\n\t\tthis.m = m;\n\t\tthis.n = n;\n\t\tas = new Object[m][n];\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tas[i][j] = accessor.at(i, j);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic String toString() {\n\t\tString s = \"\";\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\ts += i == 0 ? \"[[ \" : \" [ \";\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\ts += (j == 0 ? \"\" : \", \") + as[i][j];\n\t\t\t}\n\t\t\ts += i == m - 1 ? \" ]]\" : \" ]\\n\";\n\t\t}\n\t\treturn s;\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tA at(int i, int j) {\n\t\treturn (A) as[i][j];\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tA[][] toArray() {\n\t\tA[][] res = (A[][]) Array.newInstance(as[0][0].getClass(), m, n);\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tres[i][j] = (A) as[i][j];\n\t\t\t}\n\t\t}\n\t\treturn res;\n\t}\n\n\tint[][] toIntArray() {\n\t\tint[][] res = new int[m][n];\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tres[i][j] = (int) as[i][j];\n\t\t\t}\n\t\t}\n\t\treturn res;\n\t}\n\n\tlong[][] toLongArray() {\n\t\tlong[][] res = new long[m][n];\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tres[i][j] = (long) as[i][j];\n\t\t\t}\n\t\t}\n\t\treturn res;\n\t}\n\n\tdouble[][] toDoubleArray() {\n\t\tdouble[][] res = new double[m][n];\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tres[i][j] = (double) as[i][j];\n\t\t\t}\n\t\t}\n\t\treturn res;\n\t}\n}\n\nclass Mat {\n\tinterface Accessor {\n\t\tA at(int i, int j);\n\t}\n\n\tprivate static MN.Scalar make(int m, int n, long l, A zero, A oneTimesL) {\n\t\treturn new MN.Scalar(m, n, l, zero, oneTimesL);\n\t}\n\n\tstatic MN make(int m, int n, Accessor accessor) {\n\t\treturn new MN(m, n, accessor);\n\t}\n\n\tstatic MN make(int m, int n, A[][] as) {\n\t\treturn new MN(m, n, (i, j) -> as[i][j]);\n\t}\n\n\tstatic MN make(int[][] as) {\n\t\treturn new MN(as.length, as.length == 0 ? 0 : as[0].length, (i, j) -> (long) as[i][j]);\n\t}\n\n\tstatic MN make(long[][] as) {\n\t\treturn new MN(as.length, as.length == 0 ? 0 : as[0].length, (i, j) -> as[i][j]);\n\t}\n\n\tstatic MN make(double[][] as) {\n\t\treturn new MN(as.length, as.length == 0 ? 0 : as[0].length, (i, j) -> as[i][j]);\n\t}\n\n\tstatic MN make(int[][] as, F.IX toA) {\n\t\treturn new MN(as.length, as.length == 0 ? 0 : as[0].length, (i, j) -> toA.f(as[i][j]));\n\t}\n\n\tstatic MN make(long[][] as, F.LX toA) {\n\t\treturn new MN(as.length, as.length == 0 ? 0 : as[0].length, (i, j) -> toA.f(as[i][j]));\n\t}\n\n\tstatic MN make(double[][] as, F.DX toA) {\n\t\treturn new MN(as.length, as.length == 0 ? 0 : as[0].length, (i, j) -> toA.f(as[i][j]));\n\t}\n\n\tstatic MN make(B[][] as, F.XX toA) {\n\t\treturn new MN(as.length, as.length == 0 ? 0 : as[0].length, (i, j) -> toA.f(as[i][j]));\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tstatic MN make(Object[][] as) {\n\t\treturn new MN(as.length, as.length == 0 ? 0 : as[0].length, (i, j) -> (A) as[i][j]);\n\t}\n\n\tstatic MN eye(int n, Ring ring) {\n\t\treturn make(n, n, (i, j) -> i == j ? ring.mul().e() : ring.add().e());\n\t}\n\n\tstatic AbelianGroup> add(int m, int n, Ring ring) {\n\t\treturn AbelianGroup.make((a, b) -> add(a, b, ring), a -> neg(a, ring), make(m, n, 0, ring.zero(), ring.zero()));\n\t}\n\n\tstatic Monoid> mulRing(int n, Ring ring) {\n\t\treturn Monoid.make((a, b) -> mul(a, b, ring), make(n, n, 1, ring.zero(), ring.one()));\n\t}\n\n\tstatic AbelianGroup> mulField(int n, Field field) {\n\t\treturn AbelianGroup.make((a, b) -> mul(a, b, field), a -> inv(a, field),\n\t\t\t\tmake(n, n, 1, field.zero(), field.one()));\n\t}\n\n\tstatic MN add(MN a, MN b, Ring ring) {\n\t\tint m = U.max(a.m, b.m);\n\t\tint n = U.max(a.n, b.n);\n\t\tAbelianGroup add = ring.add();\n\t\tif (a instanceof MN.Scalar && b instanceof MN.Scalar) {\n\t\t\tMN.Scalar as = ((MN.Scalar) a);\n\t\t\tMN.Scalar bs = ((MN.Scalar) b);\n\t\t\treturn make(m, n, as.l + bs.l, ring.zero(), add.g(as.a, bs.a));\n\t\t}\n\t\treturn make(m, n, (i, j) -> add.g(a.at(i, j), b.at(i, j)));\n\t}\n\n\tstatic MN neg(MN a, Ring ring) {\n\t\tif (a instanceof MN.Scalar) {\n\t\t\tMN.Scalar as = ((MN.Scalar) a);\n\t\t\treturn make(a.m, a.n, -as.l, ring.zero(), ring.add().inv(as.a));\n\t\t}\n\t\treturn make(a.m, a.n, (i, j) -> ring.add().inv(a.at(i, j)));\n\t}\n\n\tstatic MN mul(MN a, MN b, Ring ring) {\n\t\tint m = a.m;\n\t\tint u = U.max(a.n, b.m);\n\t\tint n = b.n;\n\t\tAbelianGroup add = ring.add();\n\t\tMonoid mul = ring.mul();\n\t\tif (a instanceof MN.Scalar && b instanceof MN.Scalar) {\n\t\t\tMN.Scalar as = ((MN.Scalar) a);\n\t\t\tMN.Scalar bs = ((MN.Scalar) b);\n\t\t\treturn make(m, n, as.l * bs.l, ring.zero(), mul.g(as.a, bs.a));\n\t\t}\n\t\treturn make(m, n, (i, j) -> {\n\t\t\tA res = ring.zero();\n\t\t\tfor (int k = 0; k < u; k++)\n\t\t\t\tres = add.g(res, mul.g(a.at(i, k), b.at(k, j)));\n\t\t\treturn res;\n\t\t});\n\t}\n\n\tstatic A det(MN a, Field field) {\n\t\treturn detInv(a, field).a;\n\t}\n\n\tstatic MN inv(MN a, Field field) {\n\t\tUP> detInv = detInv(a, field);\n\t\tif (detInv.a.equals(field.zero()))\n\t\t\tthrow new ArithmeticException(\"inverse does not exist: det=0\");\n\t\treturn detInv.b;\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tprivate static UP> detInv(MN a, Field field) {\n\t\tif (a.m != a.n)\n\t\t\tthrow new IllegalArgumentException(\"matrix not square\");\n\t\tif (field.zero() instanceof Long) {\n\t\t\tUP> detInv = detInvLong((MN) a, (Field) field);\n\t\t\treturn UP.make((A) detInv.a, (MN) detInv.b);\n\t\t}\n\t\tint n = a.n;\n\t\tAbelianGroup add = field.add();\n\t\tAbelianGroup mul = field.mul();\n\t\tA zero = field.zero();\n\t\tA one = field.one();\n\t\tA[][] m1 = a.toArray();\n\t\tA[][] m2 = eye(n, field).toArray();\n\t\tA res = one;\n\t\tint sign = 1;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tint pivot = -1;\n\t\t\tfor (int j = i; j < n; j++) {\n\t\t\t\tif (!m1[j][i].equals(zero)) {\n\t\t\t\t\tpivot = j;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (pivot == -1) {\n\t\t\t\treturn UP.make(zero, null);\n\t\t\t}\n\t\t\tif (pivot != i) {\n\t\t\t\tsign = -sign;\n\t\t\t\tA tmp;\n\t\t\t\tfor (int j = i; j < n; j++) { // [0, i) are zero\n\t\t\t\t\ttmp = m1[i][j];\n\t\t\t\t\tm1[i][j] = m1[pivot][j];\n\t\t\t\t\tm1[pivot][j] = tmp;\n\t\t\t\t}\n\t\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\t\ttmp = m2[i][j];\n\t\t\t\t\tm2[i][j] = m2[pivot][j];\n\t\t\t\t\tm2[pivot][j] = tmp;\n\t\t\t\t}\n\t\t\t}\n\t\t\tA d = m1[i][i];\n\t\t\tres = mul.g(res, d);\n\t\t\td = mul.inv(d);\n\t\t\tm1[i][i] = one;\n\t\t\tfor (int j = i + 1; j < n; j++) {\n\t\t\t\tm1[i][j] = mul.g(m1[i][j], d);\n\t\t\t}\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tm2[i][j] = mul.g(m2[i][j], d);\n\t\t\t}\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tif (i == j)\n\t\t\t\t\tcontinue;\n\t\t\t\tA mult = m1[j][i];\n\t\t\t\tm1[j][i] = zero;\n\t\t\t\tfor (int k = i + 1; k < n; k++) {\n\t\t\t\t\tm1[j][k] = add.g(m1[j][k], add.inv(mul.g(m1[i][k], mult)));\n\t\t\t\t}\n\t\t\t\tfor (int k = 0; k < n; k++) {\n\t\t\t\t\tm2[j][k] = add.g(m2[j][k], add.inv(mul.g(m2[i][k], mult)));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn UP.make(sign == 1 ? res : add.inv(res), make(m2));\n\t}\n\n\tprivate static UP> detInvLong(MN a, Field field) {\n\t\tif (a.m != a.n)\n\t\t\tthrow new IllegalArgumentException(\"matrix not square\");\n\t\tint n = a.n;\n\t\tAbelianGroup add = field.add();\n\t\tAbelianGroup mul = field.mul();\n\t\tlong zero = field.zero();\n\t\tlong one = field.one();\n\t\tlong[][] m1 = a.toLongArray();\n\t\tlong[][] m2 = eye(n, field).toLongArray();\n\t\tlong res = one;\n\t\tint sign = 1;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tint pivot = -1;\n\t\t\tfor (int j = i; j < n; j++) {\n\t\t\t\tif (m1[j][i] != zero) {\n\t\t\t\t\tpivot = j;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (pivot == -1) {\n\t\t\t\treturn UP.make(zero, null);\n\t\t\t}\n\t\t\tif (pivot != i) {\n\t\t\t\tsign = -sign;\n\t\t\t\tlong tmp;\n\t\t\t\tfor (int j = i; j < n; j++) { // [0, i) are zero\n\t\t\t\t\ttmp = m1[i][j];\n\t\t\t\t\tm1[i][j] = m1[pivot][j];\n\t\t\t\t\tm1[pivot][j] = tmp;\n\t\t\t\t}\n\t\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\t\ttmp = m2[i][j];\n\t\t\t\t\tm2[i][j] = m2[pivot][j];\n\t\t\t\t\tm2[pivot][j] = tmp;\n\t\t\t\t}\n\t\t\t}\n\t\t\tlong d = m1[i][i];\n\t\t\tres = mul.g(res, d);\n\t\t\td = mul.inv(d);\n\t\t\tm1[i][i] = one;\n\t\t\tfor (int j = i + 1; j < n; j++) {\n\t\t\t\tm1[i][j] = mul.g(m1[i][j], d);\n\t\t\t}\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tm2[i][j] = mul.g(m2[i][j], d);\n\t\t\t}\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tif (i == j)\n\t\t\t\t\tcontinue;\n\t\t\t\tlong mult = m1[j][i];\n\t\t\t\tm1[j][i] = zero;\n\t\t\t\tfor (int k = i + 1; k < n; k++) {\n\t\t\t\t\tm1[j][k] = add.g(m1[j][k], add.inv(mul.g(m1[i][k], mult)));\n\t\t\t\t}\n\t\t\t\tfor (int k = 0; k < n; k++) {\n\t\t\t\t\tm2[j][k] = add.g(m2[j][k], add.inv(mul.g(m2[i][k], mult)));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn UP.make(sign == 1 ? res : add.inv(res), make(m2));\n\t}\n\n\tstatic Ring> ring(int n, Ring ring) {\n\t\treturn Ring.make(add(n, n, ring), mulRing(n, ring));\n\t}\n\n\tstatic Field> field(int n, Field field) {\n\t\treturn Field.make(add(n, n, field), mulField(n, field));\n\t}\n\n\tstatic VM> vm(int n, Ring ring) {\n\t\tif (ring instanceof Field)\n\t\t\treturn vmField(n, (Field) ring);\n\t\treturn vmRing(n, ring);\n\t}\n\n\tprivate static VM> vmRing(int n, Ring ring) {\n\t\tRing> matRing = ring(n, ring);\n\t\tMonoid> matMul = matRing.mul();\n\t\tAbelianGroup add = ring.add();\n\t\tMonoid mul = ring.mul();\n\t\tA zero = add.e();\n\t\tA one = mul.e();\n\t\treturn new VM>(matRing, null, null, (a, b) -> {\n\t\t\tif (b instanceof MN.Scalar) {\n\t\t\t\tMN.Scalar bs = ((MN.Scalar) b);\n\t\t\t\tif (bs.l < 0)\n\t\t\t\t\tthrow new RuntimeException(\"pow(MN, <0) is not defined\");\n\t\t\t\treturn Alg.pow(a, bs.l, matMul);\n\t\t\t}\n\t\t\tthrow new RuntimeException(\"pow(MN, MN) is not defined\");\n\t\t}, null, l -> make(n, n, l, zero, Alg.pow(one, l, add)), a -> a);\n\t}\n\n\tprivate static VM> vmField(int n, Field field) {\n\t\tField> matField = field(n, field);\n\t\tAbelianGroup> matMul = matField.mul();\n\t\tA zero = field.zero();\n\t\tA one = field.one();\n\t\treturn new VM>(matField, (a, b) -> {\n\t\t\tif (b instanceof MN.Scalar) {\n\t\t\t\tMN.Scalar bs = ((MN.Scalar) b);\n\t\t\t\tif (bs.l < 0)\n\t\t\t\t\treturn Alg.pow(inv(a, field), -bs.l, matMul);\n\t\t\t\treturn Alg.pow(a, bs.l, matMul);\n\t\t\t}\n\t\t\tthrow new RuntimeException(\"pow(MN, MN) is not defined\");\n\t\t}, a -> inv(a, field), l -> make(n, n, l, zero, Alg.pow(one, l, field.add())), a -> a);\n\t}\n}\n\nclass VM {\n\tprivate final HashMap env;\n\tprivate final Evaluator etor;\n\tprivate final F.XX filter;\n\n\tVM(F.XXX add, F.XXX sub, F.XXX mul, F.XXX div, F.XXX mod,\n\t\t\tF.XXX pow, F.XX neg, F.XX fact, F.LX fromInt, F.XX filter) {\n\t\tenv = new HashMap();\n\t\tetor = SimpleLang.makeEvaluator((s, a) -> {\n\t\t\tenv.put(s, a);\n\t\t\treturn a;\n\t\t}, add, sub, mul, div, mod, pow, neg, fact, fromInt, s -> {\n\t\t\tif (env.containsKey(s))\n\t\t\t\treturn env.get(s);\n\t\t\tthrow new RuntimeException(\"no such variable: \" + s);\n\t\t});\n\t\tthis.filter = filter;\n\t}\n\n\tVM(Ring ring, F.XXX div, F.XXX mod, F.XXX pow, F.XX fact, F.LX fromInt,\n\t\t\tF.XX filter) {\n\t\tthis(ring.add()::g, (a, b) -> ring.add().g(a, ring.add().inv(b)), ring.mul()::g, div, mod, pow, ring.add()::inv,\n\t\t\t\tfact, fromInt, filter);\n\t}\n\n\tVM(EuclideanRing ring, F.XXX pow, F.XX fact, F.LX fromInt, F.XX filter) {\n\t\tthis(ring, ring::div, ring::mod, pow, fact, fromInt, filter);\n\t}\n\n\tvoid clear() {\n\t\tenv.clear();\n\t}\n\n\tA get(String id) {\n\t\treturn env.get(id);\n\t}\n\n\tvoid print(String id, F.XV printer) {\n\t\tprinter.f(\"\" + get(id));\n\t}\n\n\t@SafeVarargs\n\tfinal void set(String idsSp, A... as) {\n\t\tString[] ids = idsSp.trim().split(\" +\");\n\t\tint n = ids.length;\n\t\tif (as.length != n)\n\t\t\tthrow new IllegalArgumentException(\"argument size mismatch: \" + n + \" != \" + as.length);\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tset(ids[i], as[i]);\n\t}\n\n\tvoid set(String id, A a) {\n\t\tenv.put(id, filter.f(a));\n\t}\n\n\tA run(String expr) {\n\t\treturn AST.eval(SimpleLang.parse(expr), etor);\n\t}\n}\n\nclass AST { // Abstract Syntax Tree\n\tstatic class AssignOp extends AST {\n\t\tString id;\n\t\tAST r;\n\n\t\tAssignOp(String id, AST r) {\n\t\t\tthis.id = id;\n\t\t\tthis.r = r;\n\t\t}\n\n\t\tpublic String toString() {\n\t\t\treturn \"Assign(\" + id + \", \" + r + \")\";\n\t\t}\n\t}\n\n\tstatic class Multi extends AST {\n\t\tArrayList as;\n\n\t\tMulti(ArrayList as) {\n\t\t\tthis.as = as;\n\t\t}\n\n\t\tpublic String toString() {\n\t\t\tString s = \"\";\n\t\t\tfor (AST a : as)\n\t\t\t\ts += s.isEmpty() ? a : \"; \" + a;\n\t\t\treturn \"Multi(\" + s + \")\";\n\t\t}\n\t}\n\n\tstatic class BinOp extends AST {\n\t\tAST l;\n\t\tAST r;\n\t\tString op;\n\n\t\tBinOp(AST l, String op, AST r) {\n\t\t\tthis.l = l;\n\t\t\tthis.op = op;\n\t\t\tthis.r = r;\n\t\t}\n\n\t\tpublic String toString() {\n\t\t\treturn \"BinOp(\" + l + \", \" + op + \", \" + r + \")\";\n\t\t}\n\t}\n\n\tstatic class UnOp extends AST {\n\t\tAST a;\n\t\tString op;\n\n\t\tUnOp(String op, AST a) {\n\t\t\tthis.op = op;\n\t\t\tthis.a = a;\n\t\t}\n\n\t\tpublic String toString() {\n\t\t\treturn \"UnOp(\" + op + \", \" + a + \")\";\n\t\t}\n\t}\n\n\tstatic class Int extends AST {\n\t\tlong v;\n\n\t\tInt(long v) {\n\t\t\tthis.v = v;\n\t\t}\n\n\t\tpublic String toString() {\n\t\t\treturn \"Int(\" + v + \")\";\n\t\t}\n\t}\n\n\tstatic class Id extends AST {\n\t\tString s;\n\n\t\tId(String s) {\n\t\t\tthis.s = s;\n\t\t}\n\n\t\tpublic String toString() {\n\t\t\treturn \"Id(\" + s + \")\";\n\t\t}\n\t}\n\n\tstatic A eval(AST a, Evaluator etor) {\n\t\tif (a instanceof AssignOp)\n\t\t\treturn etor.assign(((AssignOp) a).id, eval(((AssignOp) a).r, etor));\n\t\tif (a instanceof Multi) {\n\t\t\tA last = null;\n\t\t\tfor (AST a2 : ((Multi) a).as)\n\t\t\t\tlast = eval(a2, etor);\n\t\t\treturn last;\n\t\t}\n\t\tif (a instanceof BinOp)\n\t\t\treturn etor.binOp(((BinOp) a).op, eval(((BinOp) a).l, etor), eval(((BinOp) a).r, etor));\n\t\tif (a instanceof UnOp)\n\t\t\treturn etor.unOp(((UnOp) a).op, eval(((UnOp) a).a, etor));\n\t\tif (a instanceof Int)\n\t\t\treturn etor.fromInt(((Int) a).v);\n\t\tif (a instanceof Id)\n\t\t\treturn etor.id(((Id) a).s);\n\t\tthrow new RuntimeException(\"unexpected ast: \" + a);\n\t}\n}\n\ninterface Evaluator {\n\tA assign(String s, A a);\n\n\tA binOp(String op, A a, A b);\n\n\tA unOp(String op, A a);\n\n\tA fromInt(long a);\n\n\tA id(String s);\n}\n\nclass Seq {\n\tArrayList as;\n\tint ptr;\n\n\tSeq(ArrayList as) {\n\t\tthis.as = as;\n\t\tptr = 0;\n\t}\n\n\tboolean hasNext(int num) {\n\t\treturn ptr + num < as.size();\n\t}\n\n\tboolean hasNext() {\n\t\treturn hasNext(0);\n\t}\n\n\tA next(int num) {\n\t\treturn ptr + num < as.size() ? as.get(ptr + num) : null;\n\t}\n\n\tA next() {\n\t\treturn next(0);\n\t}\n\n\tA read() {\n\t\treturn hasNext() ? as.get(ptr++) : null;\n\t}\n\n\tA read(A a) {\n\t\tif (!hasNext())\n\t\t\tthrow new RuntimeException(\"unexpected EOF\");\n\t\tif (!isNext(a))\n\t\t\tthrow new RuntimeException(\"expected \" + a + \" but got\" + next());\n\t\treturn read();\n\t}\n\n\tA read(F.XX f) {\n\t\tif (!hasNext())\n\t\t\tthrow new RuntimeException(\"unexpected EOF\");\n\t\tif (!f.f(next()))\n\t\t\tthrow new RuntimeException(\"f(\" + next() + \") returned false\");\n\t\treturn read();\n\t}\n\n\tboolean isNext(A a) {\n\t\treturn a.equals(next());\n\t}\n\n\tboolean isNext(@SuppressWarnings(\"unchecked\") A... as) {\n\t\tfor (A a : as)\n\t\t\tif (isNext(a))\n\t\t\t\treturn true;\n\t\treturn false;\n\t}\n\n\tboolean isNext(F.XX f) {\n\t\treturn hasNext() && f.f(next());\n\t}\n\n\tA readIf(F.XX f) {\n\t\tif (isNext(f))\n\t\t\treturn read();\n\t\treturn null;\n\t}\n\n\tA readIf(@SuppressWarnings(\"unchecked\") A... as) {\n\t\tfor (A a : as)\n\t\t\tif (isNext(a)) {\n\t\t\t\tptr++;\n\t\t\t\treturn a;\n\t\t\t}\n\t\treturn null;\n\t}\n\n\tpublic String toString() {\n\t\treturn as.toString();\n\t}\n}\n\nclass Token extends P {\n\tprivate static final int ID = 1;\n\tprivate static final int SYM = 2;\n\tprivate static final int INT = 3;\n\n\tToken(String s, int type) {\n\t\tsuper(s, type);\n\t}\n\n\tboolean is(String s) {\n\t\treturn a.equals(s);\n\t}\n\n\tstatic Token ofId(String s) {\n\t\treturn new Token(s, ID);\n\t}\n\n\tstatic Token ofSym(String s) {\n\t\treturn new Token(s, SYM);\n\t}\n\n\tstatic Token ofInt(String s) {\n\t\treturn new Token(s, INT);\n\t}\n\n\tboolean isId() {\n\t\treturn b == ID;\n\t}\n\n\tboolean isSym() {\n\t\treturn b == SYM;\n\t}\n\n\tboolean isInt() {\n\t\treturn b == INT;\n\t}\n}\n\nclass SimpleLang {\n\tprivate static class Tokenizer {\n\t\tprivate static final String SYMS = \"+-*/%^!()=;\";\n\n\t\tSeq sc;\n\t\tArrayList ts;\n\n\t\tTokenizer(String s) {\n\t\t\tsc = new Seq(U.make(s.length(), i -> s.charAt(i)));\n\t\t}\n\n\t\tSeq parse() {\n\t\t\tts = new ArrayList();\n\t\t\tparseAll();\n\t\t\treturn new Seq(ts);\n\t\t}\n\n\t\tprivate static boolean isSpace(char c) {\n\t\t\treturn c == ' ' || c == '\\t' || c == '\\r' || c == '\\n';\n\t\t}\n\n\t\tprivate static boolean isDigit(char c) {\n\t\t\treturn c >= '0' && c <= '9';\n\t\t}\n\n\t\tprivate static boolean isSymbol(char c) {\n\t\t\treturn SYMS.indexOf(c) != -1;\n\t\t}\n\n\t\tprivate static boolean isAlpha(char c) {\n\t\t\treturn c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_';\n\t\t}\n\n\t\tprivate void parseAll() {\n\t\t\twhile (sc.hasNext()) {\n\t\t\t\twhile (sc.isNext(Tokenizer::isSpace))\n\t\t\t\t\tsc.read();\n\t\t\t\tif (!sc.hasNext())\n\t\t\t\t\tbreak;\n\t\t\t\tif (sc.isNext(Tokenizer::isAlpha)) {\n\t\t\t\t\tparseId();\n\t\t\t\t} else if (sc.isNext(Tokenizer::isDigit)) {\n\t\t\t\t\tparseInt();\n\t\t\t\t} else if (sc.isNext(Tokenizer::isSymbol)) {\n\t\t\t\t\tparseSym();\n\t\t\t\t} else {\n\t\t\t\t\tthrow new RuntimeException(\"invalid character: \" + sc.next());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tprivate void parseId() {\n\t\t\tString s = sc.read().toString();\n\t\t\twhile (sc.isNext(Tokenizer::isAlpha) || sc.isNext(Tokenizer::isDigit))\n\t\t\t\ts += sc.read().toString();\n\t\t\tts.add(Token.ofId(s));\n\t\t}\n\n\t\tprivate void parseInt() {\n\t\t\tString s = sc.read().toString();\n\t\t\twhile (sc.isNext(Tokenizer::isDigit))\n\t\t\t\ts += sc.read().toString();\n\t\t\tts.add(Token.ofInt(s));\n\t\t}\n\n\t\tprivate void parseSym() {\n\t\t\tString s = sc.read().toString();\n\t\t\tts.add(Token.ofSym(s));\n\t\t}\n\t}\n\n\tprivate static class Parser {\n\t\tSeq ts;\n\n\t\tParser(Seq ts) {\n\t\t\tthis.ts = ts;\n\t\t}\n\n\t\tAST parse() {\n\t\t\treturn parseExpr();\n\t\t}\n\n\t\tprivate AST parseExpr() {\n\t\t\treturn parseMultiExpr();\n\t\t}\n\n\t\tprivate AST parseMultiExpr() {\n\t\t\treadSemicolons();\n\t\t\tAST a = parseAssignExpr();\n\t\t\tif (readSemicolons()) {\n\t\t\t\tArrayList as = new ArrayList();\n\t\t\t\tas.add(a);\n\t\t\t\tdo {\n\t\t\t\t\tif (!ts.hasNext())\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tas.add(parseAssignExpr());\n\t\t\t\t} while (readSemicolons());\n\t\t\t\tif (as.size() == 1)\n\t\t\t\t\treturn a;\n\t\t\t\treturn new AST.Multi(as);\n\t\t\t}\n\t\t\treturn a;\n\t\t}\n\n\t\tprivate boolean readSemicolons() {\n\t\t\tif (!ts.isNext(t -> t.is(\";\")))\n\t\t\t\treturn false;\n\t\t\tdo {\n\t\t\t\tts.read();\n\t\t\t} while (ts.isNext(t -> t.is(\";\")));\n\t\t\treturn true;\n\t\t}\n\n\t\tprivate AST parseAssignExpr() {\n\t\t\tAST a = parseAddSubOp();\n\t\t\tif (ts.isNext(t -> t.is(\"=\"))) {\n\t\t\t\tts.read();\n\t\t\t\tif (!(a instanceof AST.Id))\n\t\t\t\t\tthrow new RuntimeException(\"cannot assign to \" + a);\n\t\t\t\treturn new AST.AssignOp(((AST.Id) a).s, parseAssignExpr());\n\t\t\t}\n\t\t\treturn a;\n\t\t}\n\n\t\tprivate AST parseAddSubOp() {\n\t\t\tAST a = parseMulDivModOp();\n\t\t\twhile (ts.isNext(t -> t.is(\"+\") || t.is(\"-\")))\n\t\t\t\ta = new AST.BinOp(a, ts.read().a, parseMulDivModOp());\n\t\t\treturn a;\n\t\t}\n\n\t\tprivate AST parseMulDivModOp() {\n\t\t\tAST a = parsePowOp();\n\t\t\twhile (ts.isNext(t -> t.is(\"*\") || t.is(\"/\") || t.is(\"%\")))\n\t\t\t\ta = new AST.BinOp(a, ts.read().a, parsePowOp());\n\t\t\treturn a;\n\t\t}\n\n\t\tprivate AST parsePowOp() {\n\t\t\tAST a = parseNegateOp();\n\t\t\tif (ts.isNext(t -> t.is(\"^\")))\n\t\t\t\treturn new AST.BinOp(a, ts.read().a, parsePowOp());\n\t\t\treturn a;\n\t\t}\n\n\t\tprivate AST parseNegateOp() {\n\t\t\tif (ts.isNext(t -> t.is(\"-\")))\n\t\t\t\treturn new AST.UnOp(ts.read().a, parseNegateOp());\n\t\t\treturn parseFactOp();\n\t\t}\n\n\t\tprivate AST parseFactOp() {\n\t\t\tAST a = parsePrimary();\n\t\t\twhile (ts.isNext(t -> t.is(\"!\")))\n\t\t\t\ta = new AST.UnOp(ts.read().a, a);\n\t\t\treturn a;\n\t\t}\n\n\t\tprivate AST parsePrimary() {\n\t\t\tif (ts.isNext(t -> t.isId()))\n\t\t\t\treturn new AST.Id(ts.read().a);\n\t\t\tif (ts.isNext(t -> t.isInt()))\n\t\t\t\treturn new AST.Int(Long.parseLong(ts.read().a));\n\t\t\tif (ts.readIf(t -> t.is(\"(\")) != null) {\n\t\t\t\tAST e = parseExpr();\n\t\t\t\tts.read(t -> t.is(\")\"));\n\t\t\t\treturn e;\n\t\t\t}\n\t\t\tthrow new RuntimeException(\"unexpected token: \" + ts.next());\n\t\t}\n\t}\n\n\tstatic HashMap cache = new HashMap();\n\n\tstatic Evaluator makeEvaluator(F.XXX assign, F.XXX add, F.XXX sub,\n\t\t\tF.XXX mul, F.XXX div, F.XXX mod, F.XXX pow, F.XX neg,\n\t\t\tF.XX fact, F.LX fromInt, F.XX id) {\n\t\treturn new Evaluator() {\n\t\t\tpublic A assign(String s, A a) {\n\t\t\t\treturn assign.f(s, a);\n\t\t\t}\n\n\t\t\tpublic A binOp(String op, A a, A b) {\n\t\t\t\tswitch (op) {\n\t\t\t\tcase \"+\":\n\t\t\t\t\treturn add.f(a, b);\n\t\t\t\tcase \"-\":\n\t\t\t\t\treturn sub.f(a, b);\n\t\t\t\tcase \"*\":\n\t\t\t\t\treturn mul.f(a, b);\n\t\t\t\tcase \"/\":\n\t\t\t\t\treturn div.f(a, b);\n\t\t\t\tcase \"%\":\n\t\t\t\t\treturn mod.f(a, b);\n\t\t\t\tcase \"^\":\n\t\t\t\t\treturn pow.f(a, b);\n\t\t\t\t}\n\t\t\t\tthrow new RuntimeException(\"invalid binOp: \" + op);\n\t\t\t}\n\n\t\t\tpublic A unOp(String op, A a) {\n\t\t\t\tswitch (op) {\n\t\t\t\tcase \"-\":\n\t\t\t\t\treturn neg.f(a);\n\t\t\t\tcase \"!\":\n\t\t\t\t\treturn fact.f(a);\n\t\t\t\t}\n\t\t\t\tthrow new RuntimeException(\"invalid unOp: \" + op);\n\t\t\t}\n\n\t\t\tpublic A fromInt(long a) {\n\t\t\t\treturn fromInt.f(a);\n\t\t\t}\n\n\t\t\tpublic A id(String s) {\n\t\t\t\treturn id.f(s);\n\t\t\t}\n\t\t};\n\t}\n\n\tstatic AST parse(String s) {\n\t\tif (cache.containsKey(cache)) {\n\t\t\treturn cache.get(s);\n\t\t}\n\t\tTokenizer l = new Tokenizer(s);\n\t\tSeq ts = l.parse();\n\t\tParser p = new Parser(ts);\n\t\tAST a = p.parse();\n\t\tcache.put(s, a);\n\t\treturn a;\n\t}\n}\n\nclass Mod {\n\tfinal long mod;\n\tfinal AbelianGroup add;\n\tfinal AbelianGroup mul;\n\tfinal Field field;\n\tfinal VM vm;\n\tprivate final boolean prime;\n\tprivate final HashMap logMap;\n\tprivate long[] facts;\n\tprivate long[] invs;\n\tprivate long[] invFacts;\n\tprivate long[] factors;\n\n\tMod(long mod) {\n\t\tthis.mod = mod;\n\t\tprepareFacts(0);\n\t\tprime = BigInteger.valueOf(mod).isProbablePrime(100);\n\t\tadd = AbelianGroup.make((a, b) -> (a + b) % mod, a -> mod - a, 0l);\n\t\tmul = AbelianGroup.make((a, b) -> (a * b) % mod, a -> {\n\t\t\tif (prime)\n\t\t\t\treturn pow(a, mod - 2);\n\t\t\tTL t = Alg.extgcd(a, mod);\n\t\t\tif (t.c != 1)\n\t\t\t\tthrow new ArithmeticException(\"inv(\" + a + \") does not exist\");\n\t\t\treturn (t.a % mod + mod) % mod;\n\t\t}, 1l);\n\t\tfield = Field.make(add, mul);\n\t\tlogMap = new HashMap();\n\t\tvm = new VM(field, this::pow, this::fact, a -> (a % mod + mod) % mod, a -> (a % mod + mod) % mod);\n\t}\n\n\tlong fact(long a) {\n\t\tif (a >= Integer.MAX_VALUE)\n\t\t\tthrow new RuntimeException(\"fact(\" + a + \") too big\");\n\t\tprepareFacts((int) a);\n\t\treturn facts[(int) (a % mod)];\n\t}\n\n\tlong invFact(int a) {\n\t\tprepareFacts(a);\n\t\treturn invFacts[(int) (a % mod)];\n\t}\n\n\tlong inv(long a) {\n\t\treturn mul.inv(a);\n\t}\n\n\tlong pow(long a, long b) {\n\t\tif (b == 0)\n\t\t\treturn 1;\n\t\tif (b == 1)\n\t\t\treturn a;\n\t\tif (b < 0) {\n\t\t\ta = inv(a);\n\t\t\tb = -b;\n\t\t}\n\t\ta %= mod;\n\t\tlong res = 1;\n\t\twhile (b > 0) {\n\t\t\tif ((b & 1) != 0)\n\t\t\t\tres = res * a % mod;\n\t\t\ta = a * a % mod;\n\t\t\tb >>= 1;\n\t\t}\n\t\treturn res;\n\t}\n\n\tlong order(long a) { // computes the order of `a` in O(sqrt(mod)) time\n\t\ta %= mod;\n\t\tif (a == 0)\n\t\t\treturn 0;\n\t\tif (a == 1)\n\t\t\treturn 1;\n\t\tif (factors == null) {\n\t\t\tArrayList fs = new ArrayList();\n\t\t\tfor (long i = 2; i * i < mod; i++) {\n\t\t\t\tif ((mod - 1) % i == 0)\n\t\t\t\t\tfs.add(i);\n\t\t\t}\n\t\t\tfactors = new long[fs.size()];\n\t\t\tfor (int i = 0; i < fs.size(); i++) {\n\t\t\t\tfactors[i] = fs.get(i);\n\t\t\t}\n\t\t}\n\t\tfor (long f : factors) {\n\t\t\tif (pow(a, f) == 1)\n\t\t\t\treturn f;\n\t\t}\n\t\treturn mod - 1;\n\t}\n\n\tPL log(long a, long b) { // log_b(a) in O(sqrt(mod)) time\n\t\ta %= mod;\n\t\tb %= mod;\n\t\tif (b == 1 || b == 0)\n\t\t\treturn a == b ? PL.make(1, 1) : PL.make(-1, 0);\n\t\tif (a == 0)\n\t\t\treturn PL.make(-1, 0);\n\t\tlong order = order(b);\n\t\tif (a == 1)\n\t\t\treturn PL.make(0, order);\n\t\tlong orderSqrtL = sqrtCeil(order);\n\t\tif (orderSqrtL > Integer.MAX_VALUE)\n\t\t\tthrow new RuntimeException(\"order(\" + b + \") too big: \" + order);\n\t\tint orderSqrt = (int) sqrtCeil(order);\n\t\tlogMap.clear();\n\t\tlogMap.put(1l, 0);\n\t\tlong p = 1;\n\t\tfor (int i = 1; i < orderSqrt; i++) {\n\t\t\tp = p * b % mod;\n\t\t\tlogMap.put(p, i);\n\t\t}\n\t\tlong ib = pow(b, mod - orderSqrt - 1);\n\t\tp = a;\n\t\tfor (int i = 1; i < orderSqrt; i++) {\n\t\t\tp = p * ib % mod;\n\t\t\tif (logMap.containsKey(p))\n\t\t\t\treturn PL.make((i * orderSqrt + logMap.get(p)) % order, order);\n\t\t}\n\t\treturn PL.make(-1, 0);\n\t}\n\n\tprivate long sqrtCeil(long a) {\n\t\treturn U.searchL((long) Math.sqrt(a * 0.9), (long) Math.sqrt(a * 1.1) + 1, mid -> mid * mid >= a);\n\t}\n\n\tprivate void prepareFacts(int n) {\n\t\tif (facts == null) {\n\t\t\tfacts = new long[1024];\n\t\t\tinvs = new long[1024];\n\t\t\tinvFacts = new long[1024];\n\t\t\tprepareFactsIn(0, 1024);\n\t\t}\n\t\tif (n >= mod)\n\t\t\tn = (int) (mod - 1);\n\t\twhile (facts.length <= n) {\n\t\t\tint prevL = facts.length;\n\t\t\tint newL = prevL << 1;\n\t\t\tfacts = Arrays.copyOf(facts, newL);\n\t\t\tinvs = Arrays.copyOf(invs, newL);\n\t\t\tinvFacts = Arrays.copyOf(invFacts, newL);\n\t\t\tprepareFactsIn(prevL, newL);\n\t\t}\n\t}\n\n\tprivate void prepareFactsIn(int from, int until) {\n\t\tif (until > mod)\n\t\t\tuntil = (int) mod;\n\t\tfor (int i = from; i < until; i++) {\n\t\t\tif (i == 0) {\n\t\t\t\tfacts[0] = 1;\n\t\t\t\tinvs[0] = 0;\n\t\t\t\tinvFacts[0] = 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (i == 1) {\n\t\t\t\tfacts[1] = 1;\n\t\t\t\tinvs[1] = 1;\n\t\t\t\tinvFacts[1] = 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfacts[i] = facts[i - 1] * i % mod;\n\t\t\tinvs[i] = (mod - mod / i) * invs[(int) (mod % i)] % mod;\n\t\t\tinvFacts[i] = invFacts[i - 1] * invs[i] % mod;\n\t\t}\n\t}\n}\n", "language": "Java", "metadata": {"date": 1574647350, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02847.html", "problem_id": "p02847", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02847/input.txt", "sample_output_relpath": "derived/input_output/data/p02847/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02847/Java/s673698552.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s673698552", "user_id": "u160281075"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.lang.reflect.Array;\nimport java.math.BigDecimal;\nimport java.math.BigInteger;\nimport java.util.ArrayDeque;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.Comparator;\nimport java.util.HashMap;\nimport java.util.Map.Entry;\nimport java.util.NoSuchElementException;\nimport java.util.Set;\nimport java.util.TreeMap;\nimport java.util.TreeSet;\n\npublic class Main {\n\tprivate static void solve() {\n\t\tString s = \"SUN,MON,TUE,WED,THU,FRI,SAT,\";\n\t\tint n = s.indexOf(ns() + \",\") / 4;\n\t\tfor (int i = 1; i <= 7; i++) {\n\t\t\tif((n+i)%7==0)kil(i);\n\t\t}\n\t}\n\n\tstatic int min(int a, int b) {\n\t\treturn a < b ? a : b;\n\t}\n\n\tstatic long min(long a, long b) {\n\t\treturn a < b ? a : b;\n\t}\n\n\tstatic > A min(A a, A b) {\n\t\treturn a.compareTo(b) < 0 ? a : b;\n\t}\n\n\tstatic int max(int a, int b) {\n\t\treturn a > b ? a : b;\n\t}\n\n\tstatic long max(long a, long b) {\n\t\treturn a > b ? a : b;\n\t}\n\n\tstatic > A max(A a, A b) {\n\t\treturn a.compareTo(b) > 0 ? a : b;\n\t}\n\n\tstatic int clamp(int a, int min, int max) {\n\t\treturn a < min ? min : a > max ? max : a;\n\t}\n\n\tstatic long clamp(long a, long min, long max) {\n\t\treturn a < min ? min : a > max ? max : a;\n\t}\n\n\tstatic int abs(int a) {\n\t\treturn a < 0 ? -a : a;\n\t}\n\n\tstatic long abs(long a) {\n\t\treturn a < 0 ? -a : a;\n\t}\n\n\tstatic > A clamp(A a, A min, A max) {\n\t\treturn a.compareTo(min) < 0 ? min : a.compareTo(max) > 0 ? max : a;\n\t}\n\n\tstatic void out(String val) {\n\t\tIO.out(val);\n\t}\n\n\tstatic void out(Object val) {\n\t\tIO.out(String.valueOf(val));\n\t}\n\n\tstatic void out(int val) {\n\t\tIO.out(String.valueOf(val));\n\t}\n\n\tstatic void out(long val) {\n\t\tIO.out(String.valueOf(val));\n\t}\n\n\tstatic void out(char val) {\n\t\tIO.out(String.valueOf(val));\n\t}\n\n\tstatic void out(double val) {\n\t\tIO.out(Double.isFinite(val) ? BigDecimal.valueOf(val).toPlainString() : String.valueOf(val));\n\t}\n\n\tstatic void out(boolean val) {\n\t\tIO.out(val ? \"true\" : \"false\");\n\t}\n\n\tstatic void outn(String val) {\n\t\tIO.outn(val);\n\t}\n\n\tstatic void outn(Object val) {\n\t\tIO.outn(String.valueOf(val));\n\t}\n\n\tstatic void outn(int val) {\n\t\tIO.outn(String.valueOf(val));\n\t}\n\n\tstatic void outn(long val) {\n\t\tIO.outn(String.valueOf(val));\n\t}\n\n\tstatic void outn(char val) {\n\t\tIO.outn(String.valueOf(val));\n\t}\n\n\tstatic void outn(double val) {\n\t\tIO.outn(Double.isFinite(val) ? BigDecimal.valueOf(val).toPlainString() : String.valueOf(val));\n\t}\n\n\tstatic void outn(boolean val) {\n\t\tIO.outn(val ? \"true\" : \"false\");\n\t}\n\n\tstatic void kil(String val) {\n\t\tIO.out(val);\n\t\tIO.flush();\n\t\tSystem.exit(0);\n\t}\n\n\tstatic void kil(Object val) {\n\t\tIO.out(String.valueOf(val));\n\t\tIO.flush();\n\t\tSystem.exit(0);\n\t}\n\n\tstatic void kil(int val) {\n\t\tIO.out(String.valueOf(val));\n\t\tIO.flush();\n\t\tSystem.exit(0);\n\t}\n\n\tstatic void kil(long val) {\n\t\tIO.out(String.valueOf(val));\n\t\tIO.flush();\n\t\tSystem.exit(0);\n\t}\n\n\tstatic void kil(char val) {\n\t\tIO.out(String.valueOf(val));\n\t\tIO.flush();\n\t\tSystem.exit(0);\n\t}\n\n\tstatic void kil(double val) {\n\t\tIO.out(Double.isFinite(val) ? BigDecimal.valueOf(val).toPlainString() : String.valueOf(val));\n\t\tIO.flush();\n\t\tSystem.exit(0);\n\t}\n\n\tstatic void kil(boolean val) {\n\t\tIO.out(val ? \"true\" : \"false\");\n\t\tIO.flush();\n\t\tSystem.exit(0);\n\t}\n\n\tstatic String ns() {\n\t\treturn IO.next();\n\t}\n\n\tstatic int ni() {\n\t\treturn IO.nextInt();\n\t}\n\n\tstatic long nl() {\n\t\treturn IO.nextLong();\n\t}\n\n\tstatic double nd() {\n\t\treturn IO.nextDouble();\n\t}\n\n\tstatic char nc() {\n\t\treturn IO.nextChar();\n\t}\n\n\tstatic String[] nss(int n) {\n\t\tString[] as = new String[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tas[i] = IO.next();\n\t\t}\n\t\treturn as;\n\t}\n\n\tstatic int[] nis(int n) {\n\t\tint[] as = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tas[i] = IO.nextInt();\n\t\t}\n\t\treturn as;\n\t}\n\n\tstatic long[] nls(int n) {\n\t\tlong[] as = new long[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tas[i] = IO.nextLong();\n\t\t}\n\t\treturn as;\n\t}\n\n\tstatic double[] nds(int n) {\n\t\tdouble[] as = new double[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tas[i] = IO.nextDouble();\n\t\t}\n\t\treturn as;\n\t}\n\n\tstatic char[] ncs(int n) {\n\t\tchar[] as = new char[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tas[i] = IO.nextChar();\n\t\t}\n\t\treturn as;\n\t}\n\n\tstatic String[][] nss2(int n, int m) {\n\t\tString[][] as = new String[n][m];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tfor (int j = 0; j < m; j++) {\n\t\t\t\tas[i][j] = IO.next();\n\t\t\t}\n\t\t}\n\t\treturn as;\n\t}\n\n\tstatic int[][] nis2(int n, int m) {\n\t\tint[][] as = new int[n][m];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tfor (int j = 0; j < m; j++) {\n\t\t\t\tas[i][j] = IO.nextInt();\n\t\t\t}\n\t\t}\n\t\treturn as;\n\t}\n\n\tstatic long[][] nls2(int n, int m) {\n\t\tlong[][] as = new long[n][m];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tfor (int j = 0; j < m; j++) {\n\t\t\t\tas[i][j] = IO.nextLong();\n\t\t\t}\n\t\t}\n\t\treturn as;\n\t}\n\n\tstatic double[][] nds2(int n, int m) {\n\t\tdouble[][] as = new double[n][m];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tfor (int j = 0; j < m; j++) {\n\t\t\t\tas[i][j] = IO.nextDouble();\n\t\t\t}\n\t\t}\n\t\treturn as;\n\t}\n\n\tstatic char[][] ncs2(int n, int m) {\n\t\tchar[][] as = new char[n][m];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tfor (int j = 0; j < m; j++) {\n\t\t\t\tas[i][j] = IO.nextChar();\n\t\t\t}\n\t\t}\n\t\treturn as;\n\t}\n\n\tstatic int parseInt(String val) {\n\t\treturn Integer.parseInt(val);\n\t}\n\n\tstatic long parseLong(String val) {\n\t\treturn Long.parseLong(val);\n\t}\n\n\tpublic static void main(String[] args) {\n\t\ttry {\n\t\t\tsolve();\n\t\t\tIO.flush();\n\t\t} catch (NumberFormatException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (OutOfMemoryError e) {\n\t\t\te.printStackTrace(); // this will be detected as RE\n\t\t}\n\t}\n}\n\nfinal class IO {\n\tprivate static final InputStream in = System.in;\n\tprivate static final PrintWriter out = new PrintWriter(System.out, false);\n\tprivate static final byte[] buffer = new byte[1024];\n\tprivate static int ptr = 0;\n\tprivate static int len = 0;\n\n\tprivate static boolean hasNextByte() {\n\t\tif (ptr < len)\n\t\t\treturn true;\n\t\tptr = 0;\n\t\ttry {\n\t\t\tlen = in.read(buffer);\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn len > 0;\n\t}\n\n\tprivate static int readByte() {\n\t\tif (hasNextByte())\n\t\t\treturn buffer[ptr++];\n\t\telse\n\t\t\treturn -1;\n\t}\n\n\tstatic boolean hasNext() {\n\t\tbyte c;\n\t\twhile (hasNextByte() && ((c = buffer[ptr]) < '!' || c > '~'))\n\t\t\tptr++;\n\t\treturn hasNextByte();\n\t}\n\n\tstatic String next() {\n\t\tif (!hasNext())\n\t\t\tthrow new NoSuchElementException();\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint b = readByte();\n\t\twhile (b >= '!' && b <= '~') {\n\t\t\tsb.append((char) b);\n\t\t\tb = readByte();\n\t\t}\n\t\treturn sb.toString();\n\t}\n\n\tstatic char nextChar() {\n\t\tif (!hasNext())\n\t\t\tthrow new NoSuchElementException();\n\t\treturn (char) readByte();\n\t}\n\n\tstatic long nextLong() {\n\t\tif (!hasNext())\n\t\t\tthrow new NoSuchElementException();\n\t\tlong n = 0;\n\t\tint sign = 1;\n\t\tint b = readByte();\n\t\tif (b == '-') {\n\t\t\tsign = -1;\n\t\t\tb = readByte();\n\t\t}\n\t\tif (b < '0' || '9' < b)\n\t\t\tthrow new NumberFormatException();\n\t\twhile (true) {\n\t\t\tif ('0' <= b && b <= '9')\n\t\t\t\tn = n * 10 + b - '0';\n\t\t\telse if (b == -1 || b < '!' || b > '~')\n\t\t\t\treturn n * sign;\n\t\t\telse\n\t\t\t\tthrow new NumberFormatException();\n\t\t\tb = readByte();\n\t\t}\n\t}\n\n\tstatic int nextInt() {\n\t\tif (!hasNext())\n\t\t\tthrow new NoSuchElementException();\n\t\tint n = 0;\n\t\tint sign = 1;\n\t\tint b = readByte();\n\t\tif (b == '-') {\n\t\t\tsign = -1;\n\t\t\tb = readByte();\n\t\t}\n\t\tif (b < '0' || '9' < b)\n\t\t\tthrow new NumberFormatException();\n\t\twhile (true) {\n\t\t\tif ('0' <= b && b <= '9')\n\t\t\t\tn = n * 10 + b - '0';\n\t\t\telse if (b == -1 || b < '!' || b > '~')\n\t\t\t\treturn n * sign;\n\t\t\telse\n\t\t\t\tthrow new NumberFormatException();\n\t\t\tb = readByte();\n\t\t}\n\t}\n\n\tstatic double nextDouble() {\n\t\treturn Double.parseDouble(next());\n\t}\n\n\tstatic void out(String val) {\n\t\tout.println(val);\n\t}\n\n\tstatic void outn(String val) {\n\t\tout.print(val);\n\t}\n\n\tstatic void flush() {\n\t\tout.flush();\n\t}\n}\n\n// TODO: paste library here\n\nclass MS {\n\tprivate TreeMap tm;\n\n\tMS() {\n\t\ttm = new TreeMap();\n\t}\n\n\tMS(Comparator comp) {\n\t\ttm = new TreeMap(comp);\n\t}\n\n\tvoid add(A a, long num) {\n\t\tif (tm.containsKey(a))\n\t\t\ttm.put(a, tm.get(a) + num);\n\t\telse\n\t\t\ttm.put(a, num);\n\t}\n\n\tvoid add(A a) {\n\t\tadd(a, 1);\n\t}\n\n\tlong remove(A a, long num) {\n\t\tif (tm.containsKey(a)) {\n\t\t\tlong n = tm.get(a);\n\t\t\tif (n <= num) {\n\t\t\t\ttm.remove(a);\n\t\t\t\treturn n;\n\t\t\t}\n\t\t\ttm.put(a, n - num);\n\t\t\treturn num;\n\t\t}\n\t\treturn 0;\n\t}\n\n\tboolean remove(A a) {\n\t\treturn remove(a, 1) == 1;\n\t}\n\n\tlong removeAll(A a) {\n\t\treturn remove(a, Long.MAX_VALUE);\n\t}\n\n\tlong num(A a) {\n\t\treturn tm.containsKey(a) ? tm.get(a) : 0;\n\t}\n\n\tint size() {\n\t\treturn tm.size();\n\t}\n\n\tA floor(A a) {\n\t\treturn tm.floorKey(a);\n\t}\n\n\tUP floorNum(A a) {\n\t\tEntry e = tm.floorEntry(a);\n\t\treturn e == null ? null : UP.make(e.getKey(), e.getValue());\n\t}\n\n\tA ceil(A a) {\n\t\treturn tm.ceilingKey(a);\n\t}\n\n\tUP ceilNum(A a) {\n\t\tEntry e = tm.ceilingEntry(a);\n\t\treturn e == null ? null : UP.make(e.getKey(), e.getValue());\n\t}\n\n\tvoid clear() {\n\t\ttm.clear();\n\t}\n\n\tSet keySet() {\n\t\treturn tm.keySet();\n\t}\n\n\tCollection valueSet() {\n\t\treturn tm.values();\n\t}\n\n\tSet> entrySet() {\n\t\treturn tm.entrySet();\n\t}\n\n\tpublic String toString() {\n\t\treturn tm.toString();\n\t}\n}\n\nclass WUF { // Weighted Union Find Tree\n\tprivate int[] parents;\n\tprivate int[] ranks;\n\tprivate ArrayList roots;\n\tprivate ArrayList weights;\n\tprivate F.XXX merger;\n\tprivate F.XXX add;\n\tprivate F.XX inv;\n\tprivate W e;\n\n\tWUF(int n, F.IX maker, F.XXX merger, F.XXX add, F.XX inv, W e) {\n\t\tthis.merger = merger;\n\t\tthis.add = add;\n\t\tthis.inv = inv;\n\t\tthis.e = e;\n\t\tparents = new int[n];\n\t\tranks = new int[n];\n\t\troots = U.make(n, maker);\n\t\tweights = U.make(n, i -> e);\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tparents[i] = i;\n\t\t}\n\t}\n\n\tint index(int i) {\n\t\tint p = parents[i];\n\t\tif (i == p) {\n\t\t\treturn i;\n\t\t}\n\t\tint r = index(p);\n\t\tweights.set(i, add.f(weights.get(i), weights.get(p)));\n\t\treturn parents[i] = r;\n\t}\n\n\tboolean same(int i, int j) {\n\t\treturn index(i) == index(j);\n\t}\n\n\tA root(int i) {\n\t\treturn roots.get(index(i));\n\t}\n\n\tW weight(int i) {\n\t\tindex(i);\n\t\treturn weights.get(i);\n\t}\n\n\tW diff(int i, int j) {\n\t\treturn sub(weight(j), weight(i));\n\t}\n\n\tvoid unite(int i, int j, W w) {\n\t\tw = add(w, weight(i));\n\t\tw = sub(w, weight(j));\n\t\ti = index(i);\n\t\tj = index(j);\n\t\tif (i == j)\n\t\t\treturn;\n\t\tA r = merger.f(root(i), root(j));\n\t\tif (ranks[i] < ranks[j]) {\n\t\t\ti ^= j;\n\t\t\tj ^= i;\n\t\t\ti ^= j;\n\t\t\tw = inv.f(w);\n\t\t}\n\t\tparents[j] = i;\n\t\troots.set(i, r);\n\t\tif (ranks[i] == ranks[j])\n\t\t\tranks[i]++;\n\t\tweights.set(j, w);\n\t}\n\n\tprivate W add(W a, W b) {\n\t\treturn a == e ? b : b == e ? a : add.f(a, b);\n\t}\n\n\tprivate W sub(W a, W b) {\n\t\treturn b == e ? a : add(a, inv.f(b));\n\t}\n}\n\nclass PQ { // Priority Queue\n\tstatic class E { // Entry\n\t\tprivate Object a;\n\t\tprivate int index;\n\n\t\tprivate E(Object a, int index) {\n\t\t\tthis.a = a;\n\t\t\tthis.index = index;\n\t\t}\n\t}\n\n\tprivate int n;\n\tprivate E[] as;\n\tprivate Comparator comp;\n\n\tPQ(Comparator comp) {\n\t\tthis.comp = comp;\n\t\tas = new E[64];\n\t\tn = 1;\n\t}\n\n\tE add(A a) {\n\t\tE res = addEntry(a);\n\t\tfixUp(n - 1);\n\t\treturn res;\n\t}\n\n\tA pop() {\n\t\tint max = n - 1;\n\t\tif (max == 0)\n\t\t\treturn null;\n\t\tif (max == 1) {\n\t\t\treturn removeLast();\n\t\t}\n\n\t\tE tmp = as[1];\n\t\tas[1] = as[max];\n\t\tas[max] = tmp;\n\t\tas[1].index = 1;\n\t\tas[max].index = max;\n\n\t\tA res = removeLast();\n\t\tfixDown(1);\n\t\treturn res;\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tA get(E e) {\n\t\treturn (A) e.a;\n\t}\n\n\tvoid remove(E e) {\n\t\tint k = ((E) e).index;\n\t\tint max = n - 1;\n\t\tif (k == max) {\n\t\t\tremoveLast();\n\t\t\treturn;\n\t\t}\n\n\t\tE tmp = as[k];\n\t\tas[k] = as[max];\n\t\tas[max] = tmp;\n\t\tas[k].index = k;\n\t\tas[max].index = max;\n\n\t\tremoveLast();\n\t\tif (!fixDown(k))\n\t\t\tfixUp(k);\n\t}\n\n\tvoid update(E e, A a) {\n\t\tint k = e.index;\n\t\tas[k].a = a;\n\t\tif (!fixDown(k))\n\t\t\tfixUp(k);\n\t}\n\n\tboolean isEmpty() {\n\t\treturn n == 1;\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tprivate A removeLast() {\n\t\tn--;\n\t\tE res = as[n];\n\t\tres.index = -1;\n\t\tas[n] = null;\n\t\treturn (A) res.a;\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tprivate boolean fixUp(int k) {\n\t\tboolean res = false;\n\t\twhile (k > 1) {\n\t\t\tint nk = k >> 1;\n\t\t\tif (comp.compare((A) as[k].a, (A) as[nk].a) < 0) {\n\t\t\t\tE tmp = as[k];\n\t\t\t\tas[k] = as[nk];\n\t\t\t\tas[nk] = tmp;\n\t\t\t\tas[k].index = k;\n\t\t\t\tas[nk].index = nk;\n\t\t\t\tk = nk;\n\t\t\t\tres = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\treturn res;\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tprivate boolean fixDown(int k) {\n\t\tboolean res = false;\n\t\twhile (k << 1 < n) {\n\t\t\tA a = (A) as[k].a;\n\t\t\tA l = (A) as[k << 1].a;\n\t\t\tif (k << 1 == n - 1) {\n\t\t\t\tif (comp.compare(a, l) <= 0)\n\t\t\t\t\tbreak;\n\t\t\t\tres = true;\n\t\t\t\tE tmp = as[k];\n\t\t\t\tas[k] = as[k << 1];\n\t\t\t\tas[k << 1] = tmp;\n\t\t\t\tas[k].index = k;\n\t\t\t\tas[k << 1].index = k << 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tA r = (A) as[k << 1 | 1].a;\n\t\t\tif (comp.compare(a, l) <= 0 && comp.compare(a, r) <= 0)\n\t\t\t\tbreak;\n\t\t\tres = true;\n\t\t\tif (comp.compare(l, r) < 0) {\n\t\t\t\tint nk = k << 1;\n\t\t\t\tE tmp = as[k];\n\t\t\t\tas[k] = as[nk];\n\t\t\t\tas[nk] = tmp;\n\t\t\t\tas[k].index = k;\n\t\t\t\tas[nk].index = nk;\n\t\t\t\tk = nk;\n\t\t\t} else {\n\t\t\t\tint nk = k << 1 | 1;\n\t\t\t\tE tmp = as[k];\n\t\t\t\tas[k] = as[nk];\n\t\t\t\tas[nk] = tmp;\n\t\t\t\tas[k].index = k;\n\t\t\t\tas[nk].index = nk;\n\t\t\t\tk = nk;\n\t\t\t}\n\t\t}\n\t\treturn res;\n\t}\n\n\tprivate E addEntry(A a) {\n\t\tif (n == as.length)\n\t\t\tas = U.doubleSize(as);\n\t\treturn as[n] = new E(a, n++);\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tpublic String toString() {\n\t\tif (n == 1)\n\t\t\treturn \"[]\";\n\t\tString s = null;\n\t\tfor (int i = 1; i < n; i++) {\n\t\t\tA a = (A) as[i].a;\n\t\t\tif (s == null)\n\t\t\t\ts = \"[\" + a;\n\t\t\telse\n\t\t\t\ts += \", \" + a;\n\t\t}\n\t\treturn s + \"]\";\n\t}\n}\n\nclass G { // Graph\n\tprivate int vSize;\n\tprivate Object[] vs; // V\n\tprivate int numEdges;\n\tprivate Object[] allEdges; // UT\n\tprivate Object[] esFrom; // EdgeSet\n\tprivate Object[] esTo; // EdgeSet\n\tprivate Integer[] ints;\n\n\tprivate class EdgeSet {\n//\t\tHashMap map;\n\t\tInteger[] is;\n\t\tObject[] es;\n\t\tint size;\n\n\t\tEdgeSet() {\n\t\t\tis = new Integer[2];\n\t\t\tes = new Object[2];\n\t\t\tsize = 0;\n\t\t}\n\n//\t\t@SuppressWarnings(\"unchecked\")\n\t\tvoid add(Integer i, E e) {\n//\t\t\tif (size > 1600000) {\n//\t\t\t\tmap.put(i, e);\n//\t\t\t\tsize++;\n//\t\t\t\treturn;\n//\t\t\t}\n\t\t\tif (size == is.length) {\n\t\t\t\tis = Arrays.copyOf(is, size << 1);\n\t\t\t\tes = Arrays.copyOf(es, size << 1);\n\t\t\t}\n\t\t\tis[size] = i;\n\t\t\tes[size] = e;\n//\t\t\tif (++size > 1600000) {\n//\t\t\t\tmap = new HashMap();\n//\t\t\t\tfor (int j = 0; j < size; j++) {\n//\t\t\t\t\tmap.put(is[j], (E) es[j]);\n//\t\t\t\t}\n//\t\t\t\tis = null;\n//\t\t\t\tes = null;\n//\t\t\t}\n\t\t}\n\n\t\t@SuppressWarnings(\"unchecked\")\n\t\tvoid iter(F.IXV f) {\n//\t\t\tif (map == null)\n\t\t\tfor (int i = 0; i < size; i++)\n\t\t\t\tf.f(is[i], (E) es[i]);\n//\t\t\telse\n//\t\t\t\tfor (Entry e : map.entrySet())\n//\t\t\t\t\tf.f(e.getKey(), e.getValue());\n\t\t}\n\t}\n\n\tG() {\n\t\tvs = new Object[64];\n\t\tallEdges = new Object[64];\n\t\tesFrom = new Object[64];\n\t\tesTo = new Object[64];\n\t\tints = new Integer[64];\n\t\tvSize = 0;\n\t\tnumEdges = 0;\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tV getV(int i) {\n\t\treturn i < 0 || i >= vs.length ? null : (V) vs[i];\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tArrayList getSortedVs() {\n\t\tArrayList res = new ArrayList();\n\t\tfor (int i = 0; i < vs.length; i++) {\n\t\t\tif (vs[i] != null)\n\t\t\t\tres.add((V) vs[i]);\n\t\t}\n\t\treturn res;\n\t}\n\n\tvoid addV(int i, V v) {\n\t\tif (getV(i) != null)\n\t\t\tthrow new RuntimeException(\"duplicate vtx: \" + i);\n\t\twhile (vs.length <= i) {\n\t\t\tvs = U.doubleSize(vs);\n\t\t\tints = U.doubleSize(ints);\n\t\t\tesFrom = U.doubleSize(esFrom);\n\t\t\tesTo = U.doubleSize(esTo);\n\t\t}\n\t\tvSize = U.max(vSize, i + 1);\n\t\tvs[i] = v;\n\t\tints[i] = Integer.valueOf(i);\n\t\tesFrom[i] = new EdgeSet();\n\t\tesTo[i] = new EdgeSet();\n\t}\n\n\tvoid setV(int i, V v) {\n\t\tif (getV(i) == null)\n\t\t\tthrow new RuntimeException(\"no such vtx: \" + i);\n\t\tvs[i] = v;\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tvoid addE(int from, int to, E e) {\n\t\t((EdgeSet) esFrom[from]).add(ints[to], e);\n\t\t((EdgeSet) esTo[to]).add(ints[from], e);\n\t\tif (numEdges == allEdges.length) {\n\t\t\tallEdges = U.doubleSize(allEdges);\n\t\t}\n\t\tallEdges[numEdges++] = UT.make(from, to, e);\n\t}\n\n\tvoid addUE(int i, int j, E e) {\n\t\taddE(i, j, e);\n\t\taddE(j, i, e);\n\t}\n\n\t void dfs(int firstIdx, State firstS, F.XXXXX nextState,\n\t\t\tF.XXXV> visit) {\n\t\tArrayDeque> deque = new ArrayDeque>();\n\t\tsearch(firstIdx, firstS, nextState, visit, deque::push, deque::pop, deque::isEmpty);\n\t}\n\n\t void bfs(int firstIdx, State firstS, F.XXXXX nextState,\n\t\t\tF.XXXV> visit) {\n\t\tArrayDeque> deque = new ArrayDeque>();\n\t\tsearch(firstIdx, firstS, nextState, visit, deque::addLast, deque::pollFirst, deque::isEmpty);\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tArrayList> getEs() {\n\t\tArrayList> res = new ArrayList>();\n\t\tfor (int i = 0; i < numEdges; i++) {\n\t\t\tres.add((UT) allEdges[i]);\n\t\t}\n\t\treturn res;\n\t}\n\n\t/**\n\t * !!多重辺があるとバグる!!\n\t * !!多重辺があるとバグる!!\n\t * !!多重辺があるとバグる!!\n\t */\n\tArrayList> dijkstraL(int from, F.XL getWeight) {\n\t\treturn dijkstra(from, e -> getWeight.f(e), (a, b) -> a + b, Long::compare, 0l, Long.MAX_VALUE);\n\t}\n\n\t/**\n\t * !!多重辺があるとバグる!!\n\t * !!多重辺があるとバグる!!\n\t * !!多重辺があるとバグる!!\n\t */\n\t@SuppressWarnings(\"unchecked\")\n\t ArrayList> dijkstra(int from, F.XX getWeight, F.XXX add, Comparator comp,\n\t\t\tA zero, A inf) {\n\t\tint n = vSize;\n\t\tArrayList> res = U.make(n, i -> getV(i) == null ? null : UP.make(i == from ? zero : inf, -1));\n\t\tPQ> q = new PQ>((i, j) -> comp.compare(i.b, j.b));\n\n\t\tPQ.E[] qes = new PQ.E[n];\n\t\tArrayList> ups = new ArrayList>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tups.add(UP.make(i, inf));\n\t\t}\n\n\t\tboolean[] fixed = new boolean[n];\n\t\tups.get(from).b = zero;\n\t\tqes[from] = q.add(ups.get(from));\n\n\t\twhile (!q.isEmpty()) {\n\t\t\tUP up = q.pop();\n\t\t\tInteger i = up.a;\n\t\t\tif (fixed[i])\n\t\t\t\tcontinue;\n\t\t\tfixed[i] = true;\n\t\t\tA dist = up.b;\n\t\t\tif (dist == inf)\n\t\t\t\tbreak;\n\t\t\t((EdgeSet) esFrom[i]).iter((j, e) -> {\n\t\t\t\tif (fixed[j])\n\t\t\t\t\treturn;\n\t\t\t\tUP resj = res.get(j);\n\t\t\t\tA newDist = add.f(dist, getWeight.f(e));\n\t\t\t\tif (comp.compare(resj.a, newDist) > 0) {\n\t\t\t\t\tresj.a = newDist;\n\t\t\t\t\tresj.b = i;\n\n\t\t\t\t\tq.add(UP.make(j, newDist));\n\n//\t\t\t\t\tUP upj = ups.get(j);\n//\t\t\t\t\tupj.b = newDist;\n//\t\t\t\t\tif (qes[j] == null)\n//\t\t\t\t\t\tqes[j] = q.add(upj);\n//\t\t\t\t\telse\n//\t\t\t\t\t\tq.update(qes[j], upj);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\treturn res;\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tprivate void search(int firstIdx, State firstS, F.XXXXX nextState,\n\t\t\tF.XXXV> visit, F.XV> push,\n\t\t\tF.VX> pop, F.VX isEmpty) {\n\t\tboolean[] visited = new boolean[vSize];\n\t\tArrayList movedTo = new ArrayList();\n\t\tpush.f(UP.make(firstS, firstIdx));\n\t\tvisited[firstIdx] = true;\n\t\twhile (!isEmpty.f()) {\n\t\t\tUP si = pop.f();\n\t\t\tState s = (State) si.a;\n\t\t\tInteger i = si.b;\n\t\t\tmovedTo.clear();\n\t\t\t((EdgeSet) esFrom[i]).iter((j, e) -> {\n\t\t\t\tif (visited[j])\n\t\t\t\t\treturn;\n\t\t\t\tState ns = nextState.f(s, i, j, e);\n\t\t\t\tif (ns != null) {\n\t\t\t\t\tmovedTo.add(j);\n\t\t\t\t\tpush.f(P.make(ns, j));\n\t\t\t\t\tvisited[j] = true;\n\t\t\t\t}\n\t\t\t});\n\t\t\tvisit.f(s, i, movedTo);\n\t\t}\n\t}\n}\n\nclass UP { // Unordered Pair\n\tA a;\n\tB b;\n\n\tUP(A a, B b) {\n\t\tthis.a = a;\n\t\tthis.b = b;\n\t}\n\n\tstatic UP make(A a, B b) {\n\t\treturn new UP(a, b);\n\t}\n\n\tpublic boolean equals(Object o) {\n\t\tif (o == this)\n\t\t\treturn true;\n\t\tif (!(o instanceof UP))\n\t\t\treturn false;\n\t\tUP p = (UP) o;\n\t\tboolean aok = a == null ? p.a == null : a.equals(p.a);\n\t\tboolean bok = b == null ? p.b == null : b.equals(p.b);\n\t\treturn aok && bok;\n\t}\n\n\tpublic String toString() {\n\t\treturn \"(\" + a.toString() + \", \" + b.toString() + \")\";\n\t}\n}\n\nclass P, B extends Comparable> extends UP\n\t\timplements Comparable> { // Pair\n\tP(A a, B b) {\n\t\tsuper(a, b);\n\t}\n\n\tstatic , B extends Comparable> P make(A a, B b) {\n\t\treturn new P(a, b);\n\t}\n\n\tpublic int compareTo(P o) {\n\t\tint sa = a.compareTo(o.a);\n\t\tint sb = b.compareTo(o.b);\n\t\treturn sa != 0 ? sa : sb;\n\t}\n}\n\nclass PI implements Comparable { // Pair int\n\tint a;\n\tint b;\n\n\tPI(int a, int b) {\n\t\tthis.a = a;\n\t\tthis.b = b;\n\t}\n\n\tstatic PI make(int a, int b) {\n\t\treturn new PI(a, b);\n\t}\n\n\tpublic boolean equals(Object o) {\n\t\tif (o == this)\n\t\t\treturn true;\n\t\tif (!(o instanceof PI))\n\t\t\treturn false;\n\t\tPI p = (PI) o;\n\t\treturn a == p.a && b == p.b;\n\t}\n\n\tpublic int compareTo(PI o) {\n\t\tint sa = a - o.a;\n\t\tint sb = b - o.b;\n\t\treturn sa > 0 ? 1 : sa < 0 ? -1 : sb > 0 ? 1 : sb < 0 ? -1 : 0;\n\t}\n\n\tpublic String toString() {\n\t\treturn \"(\" + a + \", \" + b + \")\";\n\t}\n}\n\nclass PL implements Comparable { // Pair long\n\tlong a;\n\tlong b;\n\n\tPL(long a, long b) {\n\t\tthis.a = a;\n\t\tthis.b = b;\n\t}\n\n\tstatic PL make(long a, long b) {\n\t\treturn new PL(a, b);\n\t}\n\n\tpublic boolean equals(Object o) {\n\t\tif (o == this)\n\t\t\treturn true;\n\t\tif (!(o instanceof PL))\n\t\t\treturn false;\n\t\tPL p = (PL) o;\n\t\treturn a == p.a && b == p.b;\n\t}\n\n\tpublic int compareTo(PL o) {\n\t\tlong sa = a - o.a;\n\t\tlong sb = b - o.b;\n\t\treturn sa > 0 ? 1 : sa < 0 ? -1 : sb > 0 ? 1 : sb < 0 ? -1 : 0;\n\t}\n\n\tpublic String toString() {\n\t\treturn \"(\" + a + \", \" + b + \")\";\n\t}\n}\n\nclass UT { // Unordered Tuple\n\tA a;\n\tB b;\n\tC c;\n\n\tUT(A a, B b, C c) {\n\t\tthis.a = a;\n\t\tthis.b = b;\n\t\tthis.c = c;\n\t}\n\n\tstatic UT make(A a, B b, C c) {\n\t\treturn new UT(a, b, c);\n\t}\n\n\tpublic boolean equals(Object o) {\n\t\tif (o == this)\n\t\t\treturn true;\n\t\tif (!(o instanceof UT))\n\t\t\treturn false;\n\t\tUT t = (UT) o;\n\t\tboolean aok = a == null ? t.a == null : a.equals(t.a);\n\t\tboolean bok = b == null ? t.b == null : b.equals(t.b);\n\t\tboolean cok = c == null ? t.c == null : c.equals(t.c);\n\t\treturn aok && bok && cok;\n\t}\n\n\tpublic String toString() {\n\t\treturn \"(\" + a.toString() + \", \" + b.toString() + \", \" + c.toString() + \")\";\n\t}\n}\n\nclass T, B extends Comparable, C extends Comparable>\n\t\textends UT implements Comparable> { // Tuple\n\tT(A a, B b, C c) {\n\t\tsuper(a, b, c);\n\t}\n\n\tstatic , B extends Comparable, C extends Comparable> T make(\n\t\t\tA a, B b, C c) {\n\t\treturn new T(a, b, c);\n\t}\n\n\tpublic int compareTo(T o) {\n\t\tint sa = a.compareTo(o.a);\n\t\tint sb = b.compareTo(o.b);\n\t\tint sc = c.compareTo(o.c);\n\t\treturn sa != 0 ? sa : sb != 0 ? sb : sc;\n\t}\n}\n\nclass TI implements Comparable { // Tuple int\n\tint a;\n\tint b;\n\tint c;\n\n\tTI(int a, int b, int c) {\n\t\tthis.a = a;\n\t\tthis.b = b;\n\t\tthis.c = c;\n\t}\n\n\tstatic TI make(int a, int b, int c) {\n\t\treturn new TI(a, b, c);\n\t}\n\n\tTL toLong() {\n\t\treturn TL.make(a, b, c);\n\t}\n\n\tpublic boolean equals(Object o) {\n\t\tif (o == this)\n\t\t\treturn true;\n\t\tif (!(o instanceof TI))\n\t\t\treturn false;\n\t\tTI t = (TI) o;\n\t\treturn a == t.a && b == t.b && c == t.c;\n\t}\n\n\tpublic int compareTo(TI o) {\n\t\tint sa = a - o.a;\n\t\tint sb = b - o.b;\n\t\tint sc = c - o.c;\n\t\treturn sa > 0 ? 1 : sa < 0 ? -1 : sb > 0 ? 1 : sb < 0 ? -1 : sc > 0 ? 1 : sc < 0 ? -1 : 0;\n\t}\n\n\tpublic String toString() {\n\t\treturn \"(\" + a + \", \" + b + \", \" + c + \")\";\n\t}\n}\n\nclass TL implements Comparable { // Tuple long\n\tlong a;\n\tlong b;\n\tlong c;\n\n\tTL(long a, long b, long c) {\n\t\tthis.a = a;\n\t\tthis.b = b;\n\t\tthis.c = c;\n\t}\n\n\tstatic TL make(long a, long b, long c) {\n\t\treturn new TL(a, b, c);\n\t}\n\n\tTI toInt() {\n\t\treturn TI.make((int) a, (int) b, (int) c);\n\t}\n\n\tpublic boolean equals(Object o) {\n\t\tif (o == this)\n\t\t\treturn true;\n\t\tif (!(o instanceof TL))\n\t\t\treturn false;\n\t\tTL t = (TL) o;\n\t\treturn a == t.a && b == t.b && c == t.c;\n\t}\n\n\tpublic int compareTo(TL o) {\n\t\tlong sa = a - o.a;\n\t\tlong sb = b - o.b;\n\t\tlong sc = c - o.c;\n\t\treturn sa > 0 ? 1 : sa < 0 ? -1 : sb > 0 ? 1 : sb < 0 ? -1 : sc > 0 ? 1 : sc < 0 ? -1 : 0;\n\t}\n\n\tpublic String toString() {\n\t\treturn \"(\" + a + \", \" + b + \", \" + c + \")\";\n\t}\n}\n\nfinal class U { // Utilities\n\tprivate U() {\n\t}\n\n\tstatic ArrayList make(int n, F.IX maker) {\n\t\tArrayList res = new ArrayList();\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tres.add(maker.f(i));\n\t\treturn res;\n\t}\n\n\tstatic boolean[] makeB(int n, F.IB maker) {\n\t\tboolean[] res = new boolean[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tres[i] = maker.f(i);\n\t\treturn res;\n\t}\n\n\tstatic int[] makeI(int n, F.II maker) {\n\t\tint[] res = new int[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tres[i] = maker.f(i);\n\t\treturn res;\n\t}\n\n\tstatic long[] makeL(int n, F.IL maker) {\n\t\tlong[] res = new long[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tres[i] = maker.f(i);\n\t\treturn res;\n\t}\n\n\tstatic A[] makeX(int n, F.IX maker, A[] as) {\n\t\tA[] res = Arrays.copyOf(as, n);\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tres[i] = maker.f(i);\n\t\treturn res;\n\t}\n\n\tstatic ArrayList filter(ArrayList as, F.XB pred) {\n\t\tArrayList res = new ArrayList();\n\t\tfor (A a : as)\n\t\t\tif (pred.f(a))\n\t\t\t\tres.add(a);\n\t\treturn res;\n\t}\n\n\tstatic int count(ArrayList as, F.XB pred) {\n\t\tint res = 0;\n\t\tfor (A a : as)\n\t\t\tif (pred.f(a))\n\t\t\t\tres++;\n\t\treturn res;\n\t}\n\n\tstatic ArrayList concat(ArrayList as, ArrayList bs) {\n\t\tArrayList res = new ArrayList();\n\t\tres.addAll(as);\n\t\tres.addAll(bs);\n\t\treturn res;\n\t}\n\n\tstatic boolean any(ArrayList as, F.XB pred) {\n\t\tfor (A a : as)\n\t\t\tif (pred.f(a))\n\t\t\t\treturn true;\n\t\treturn false;\n\t}\n\n\tstatic boolean all(ArrayList as, F.XB pred) {\n\t\tfor (A a : as)\n\t\t\tif (!pred.f(a))\n\t\t\t\treturn false;\n\t\treturn true;\n\t}\n\n\tstatic ArrayList flatten(ArrayList> ass) {\n\t\tArrayList res = new ArrayList();\n\t\tfor (ArrayList as : ass)\n\t\t\tres.addAll(as);\n\t\treturn res;\n\t}\n\n\tstatic B foldl(ArrayList as, F.XXX f, B e) {\n\t\tB res = e;\n\t\tfor (A a : as)\n\t\t\tres = f.f(res, a);\n\t\treturn res;\n\t}\n\n\tstatic B foldr(ArrayList as, F.XXX f, B e) {\n\t\tB res = e;\n\t\tfor (int i = as.size() - 1; i >= 0; i--)\n\t\t\tres = f.f(as.get(i), res);\n\t\treturn res;\n\t}\n\n\tstatic ArrayList reverse(ArrayList as) {\n\t\tint size = as.size();\n\t\treturn make(size, i -> as.get(size - 1 - i));\n\t}\n\n\tstatic boolean[] reverse(boolean[] as) {\n\t\tint size = as.length;\n\t\treturn makeB(size, i -> as[size - 1 - i]);\n\t}\n\n\tstatic int[] reverse(int[] as) {\n\t\tint size = as.length;\n\t\treturn makeI(size, i -> as[size - 1 - i]);\n\t}\n\n\tstatic long[] reverse(long[] as) {\n\t\tint size = as.length;\n\t\treturn makeL(size, i -> as[size - 1 - i]);\n\t}\n\n\tstatic A[] reverse(A[] as) {\n\t\tint size = as.length;\n\t\treturn makeX(size, i -> as[size - 1 - i], as);\n\t}\n\n\tstatic > UP, ArrayList> compress(ArrayList as) {\n\t\tTreeSet set = new TreeSet(as);\n\t\tTreeMap map = new TreeMap();\n\t\tArrayList imap = new ArrayList();\n\t\tint i = 0;\n\t\tfor (A a : set) {\n\t\t\tmap.put(a, i++);\n\t\t\timap.add(a);\n\t\t}\n\t\treturn UP.make(map, imap);\n\t}\n\n\tstatic ArrayList map(ArrayList as, F.XX f) {\n\t\treturn make(as.size(), (i) -> f.f(as.get(i)));\n\t}\n\n\tstatic ArrayList mapi(ArrayList as, F.XIX f) {\n\t\treturn make(as.size(), (i) -> f.f(as.get(i), i));\n\t}\n\n\tstatic ArrayList> zip(ArrayList as, ArrayList bs) {\n\t\treturn make(min(as.size(), bs.size()), (i) -> UP.make(as.get(i), bs.get(i)));\n\t}\n\n\tstatic int min(int a, int b) {\n\t\treturn a < b ? a : b;\n\t}\n\n\tstatic long min(long a, long b) {\n\t\treturn a < b ? a : b;\n\t}\n\n\tstatic > A min(A a, A b) {\n\t\treturn a.compareTo(b) < 0 ? a : b;\n\t}\n\n\tstatic int max(int a, int b) {\n\t\treturn a > b ? a : b;\n\t}\n\n\tstatic long max(long a, long b) {\n\t\treturn a > b ? a : b;\n\t}\n\n\tstatic > A max(A a, A b) {\n\t\treturn a.compareTo(b) > 0 ? a : b;\n\t}\n\n\tstatic int clamp(int a, int min, int max) {\n\t\treturn a < min ? min : a > max ? max : a;\n\t}\n\n\tstatic long clamp(long a, long min, long max) {\n\t\treturn a < min ? min : a > max ? max : a;\n\t}\n\n\tstatic > A clamp(A a, A min, A max) {\n\t\treturn a.compareTo(min) < 0 ? min : a.compareTo(max) > 0 ? max : a;\n\t}\n\n\tstatic int abs(int a) {\n\t\treturn a < 0 ? -a : a;\n\t}\n\n\tstatic long abs(long a) {\n\t\treturn a < 0 ? -a : a;\n\t}\n\n\tstatic void forEachBitPerm(int n, int k, F.IV f) {\n\t\tfor (int i = (1 << k) - 1; i < 1 << n;) {\n\t\t\tf.f(i);\n\t\t\tint t = (i | i - 1) + 1;\n\t\t\ti = t | ((t & -t) / (i & -i) >> 1) - 1;\n\t\t}\n\t}\n\n\tstatic int nextBitPerm(int a) {\n\t\tint t = (a | a - 1) + 1;\n\t\treturn t | ((t & -t) / (a & -a) >> 1) - 1;\n\t}\n\n\tstatic void mebius(int n, F.IIV f) { // s, i\n\t\tint bit = 1;\n\t\tint exp = 0;\n\t\tfor (int i = 1; i < 1 << n; i++) {\n\t\t\tf.f(i ^ bit, exp);\n\t\t\tif ((i & i + 1) == 0) {\n\t\t\t\tbit <<= 1;\n\t\t\t\texp++;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic void zeta(int n, F.IIV f) { // s, i\n\t\tint m = (1 << n) - 1;\n\t\tint bit = 1;\n\t\tint exp = 0;\n\t\tfor (int i = (1 << n) - 2; i >= 0; i--) {\n\t\t\tf.f(i ^ bit, exp);\n\t\t\tif ((~i & ~i + 1 & m) == 0) {\n\t\t\t\tbit <<= 1;\n\t\t\t\texp++;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic ArrayList toAL(A[] as) {\n\t\treturn make(as.length, i -> as[i]);\n\t}\n\n\tstatic A[] doubleSize(A[] as) {\n\t\treturn Arrays.copyOf(as, as.length << 1);\n\t}\n\n\tstatic long searchL(long ng, long ok, F.LB isOk) {\n\t\twhile (ng - ok > 1 || ok - ng > 1) {\n\t\t\tlong mid = ng + ok >> 1;\n\t\t\tif (isOk.f(mid))\n\t\t\t\tok = mid;\n\t\t\telse\n\t\t\t\tng = mid;\n\t\t}\n\t\treturn ok;\n\t}\n\n\tstatic int searchI(int ng, int ok, F.IB isOk) {\n\t\treturn (int) searchL((long) ng, (long) ok, (mid) -> isOk.f((int) mid));\n\t}\n}\n\nfinal class F { // Functions\n\tprivate F() {\n\t}\n\n\tinterface VV {\n\t\tvoid f();\n\t}\n\n\tinterface BV {\n\t\tvoid f(boolean a);\n\t}\n\n\tinterface BXV {\n\t\tvoid f(boolean a, A b);\n\t}\n\n\tinterface BXXV {\n\t\tvoid f(boolean a, A b, B c);\n\t}\n\n\tinterface BXXXV {\n\t\tvoid f(boolean a, A b, B c, C d);\n\t}\n\n\tinterface XBV {\n\t\tvoid f(A a, boolean b);\n\t}\n\n\tinterface XXBV {\n\t\tvoid f(A a, B b, boolean c);\n\t}\n\n\tinterface XXXBV {\n\t\tvoid f(A a, B b, C c, boolean d);\n\t}\n\n\tinterface IV {\n\t\tvoid f(int a);\n\t}\n\n\tinterface IXV {\n\t\tvoid f(int a, A b);\n\t}\n\n\tinterface IXXV {\n\t\tvoid f(int a, A b, B c);\n\t}\n\n\tinterface IXXXV {\n\t\tvoid f(int a, A b, B c, C d);\n\t}\n\n\tinterface XIV {\n\t\tvoid f(A a, int b);\n\t}\n\n\tinterface XXIV {\n\t\tvoid f(A a, B b, int c);\n\t}\n\n\tinterface XXXIV {\n\t\tvoid f(A a, B b, C c, int d);\n\t}\n\n\tinterface LV {\n\t\tvoid f(long a);\n\t}\n\n\tinterface LXV {\n\t\tvoid f(long a, A b);\n\t}\n\n\tinterface LXXV {\n\t\tvoid f(long a, A b, B c);\n\t}\n\n\tinterface LXXXV {\n\t\tvoid f(long a, A b, B c, C d);\n\t}\n\n\tinterface XLV {\n\t\tvoid f(A a, long b);\n\t}\n\n\tinterface XXLV {\n\t\tvoid f(A a, B b, long c);\n\t}\n\n\tinterface XXXLV {\n\t\tvoid f(A a, B b, C c, long d);\n\t}\n\n\tinterface DV {\n\t\tvoid f(double a);\n\t}\n\n\tinterface DXV {\n\t\tvoid f(double a, A b);\n\t}\n\n\tinterface DXXV {\n\t\tvoid f(double a, A b, B c);\n\t}\n\n\tinterface DXXXV {\n\t\tvoid f(double a, A b, B c, C d);\n\t}\n\n\tinterface XDV {\n\t\tvoid f(A a, double b);\n\t}\n\n\tinterface XXDV {\n\t\tvoid f(A a, B b, double c);\n\t}\n\n\tinterface XXXDV {\n\t\tvoid f(A a, B b, C c, double d);\n\t}\n\n\tinterface XV {\n\t\tvoid f(A a);\n\t}\n\n\tinterface XXV {\n\t\tvoid f(A a, B b);\n\t}\n\n\tinterface XXXV {\n\t\tvoid f(A a, B b, C c);\n\t}\n\n\tinterface XXXXV {\n\t\tvoid f(A a, B b, C c, D d);\n\t}\n\n\tinterface BBV {\n\t\tvoid f(boolean a, boolean b);\n\t}\n\n\tinterface BIV {\n\t\tvoid f(boolean a, int b);\n\t}\n\n\tinterface BLV {\n\t\tvoid f(boolean a, long b);\n\t}\n\n\tinterface BDV {\n\t\tvoid f(boolean a, double b);\n\t}\n\n\tinterface IBV {\n\t\tvoid f(int a, boolean b);\n\t}\n\n\tinterface IIV {\n\t\tvoid f(int a, int b);\n\t}\n\n\tinterface ILV {\n\t\tvoid f(int a, long b);\n\t}\n\n\tinterface IDV {\n\t\tvoid f(int a, double b);\n\t}\n\n\tinterface LBV {\n\t\tvoid f(long a, boolean b);\n\t}\n\n\tinterface LIV {\n\t\tvoid f(long a, int b);\n\t}\n\n\tinterface LLV {\n\t\tvoid f(long a, long b);\n\t}\n\n\tinterface LDV {\n\t\tvoid f(long a, double b);\n\t}\n\n\tinterface DBV {\n\t\tvoid f(double a, boolean b);\n\t}\n\n\tinterface DIV {\n\t\tvoid f(double a, int b);\n\t}\n\n\tinterface DLV {\n\t\tvoid f(double a, long b);\n\t}\n\n\tinterface DDV {\n\t\tvoid f(double a, double b);\n\t}\n\n\tinterface VB {\n\t\tboolean f();\n\t}\n\n\tinterface BB {\n\t\tboolean f(boolean a);\n\t}\n\n\tinterface BXB {\n\t\tboolean f(boolean a, A b);\n\t}\n\n\tinterface BXXB {\n\t\tboolean f(boolean a, A b, B c);\n\t}\n\n\tinterface BXXXB {\n\t\tboolean f(boolean a, A b, B c, C d);\n\t}\n\n\tinterface XBB {\n\t\tboolean f(A a, boolean b);\n\t}\n\n\tinterface XXBB {\n\t\tboolean f(A a, B b, boolean c);\n\t}\n\n\tinterface XXXBB {\n\t\tboolean f(A a, B b, C c, boolean d);\n\t}\n\n\tinterface IB {\n\t\tboolean f(int a);\n\t}\n\n\tinterface IXB {\n\t\tboolean f(int a, A b);\n\t}\n\n\tinterface IXXB {\n\t\tboolean f(int a, A b, B c);\n\t}\n\n\tinterface IXXXB {\n\t\tboolean f(int a, A b, B c, C d);\n\t}\n\n\tinterface XIB {\n\t\tboolean f(A a, int b);\n\t}\n\n\tinterface XXIB {\n\t\tboolean f(A a, B b, int c);\n\t}\n\n\tinterface XXXIB {\n\t\tboolean f(A a, B b, C c, int d);\n\t}\n\n\tinterface LB {\n\t\tboolean f(long a);\n\t}\n\n\tinterface LXB {\n\t\tboolean f(long a, A b);\n\t}\n\n\tinterface LXXB {\n\t\tboolean f(long a, A b, B c);\n\t}\n\n\tinterface LXXXB {\n\t\tboolean f(long a, A b, B c, C d);\n\t}\n\n\tinterface XLB {\n\t\tboolean f(A a, long b);\n\t}\n\n\tinterface XXLB {\n\t\tboolean f(A a, B b, long c);\n\t}\n\n\tinterface XXXLB {\n\t\tboolean f(A a, B b, C c, long d);\n\t}\n\n\tinterface DB {\n\t\tboolean f(double a);\n\t}\n\n\tinterface DXB {\n\t\tboolean f(double a, A b);\n\t}\n\n\tinterface DXXB {\n\t\tboolean f(double a, A b, B c);\n\t}\n\n\tinterface DXXXB {\n\t\tboolean f(double a, A b, B c, C d);\n\t}\n\n\tinterface XDB {\n\t\tboolean f(A a, double b);\n\t}\n\n\tinterface XXDB {\n\t\tboolean f(A a, B b, double c);\n\t}\n\n\tinterface XXXDB {\n\t\tboolean f(A a, B b, C c, double d);\n\t}\n\n\tinterface XB {\n\t\tboolean f(A a);\n\t}\n\n\tinterface XXB {\n\t\tboolean f(A a, B b);\n\t}\n\n\tinterface XXXB {\n\t\tboolean f(A a, B b, C c);\n\t}\n\n\tinterface XXXXB {\n\t\tboolean f(A a, B b, C c, D d);\n\t}\n\n\tinterface BBB {\n\t\tboolean f(boolean a, boolean b);\n\t}\n\n\tinterface BIB {\n\t\tboolean f(boolean a, int b);\n\t}\n\n\tinterface BLB {\n\t\tboolean f(boolean a, long b);\n\t}\n\n\tinterface BDB {\n\t\tboolean f(boolean a, double b);\n\t}\n\n\tinterface IBB {\n\t\tboolean f(int a, boolean b);\n\t}\n\n\tinterface IIB {\n\t\tboolean f(int a, int b);\n\t}\n\n\tinterface ILB {\n\t\tboolean f(int a, long b);\n\t}\n\n\tinterface IDB {\n\t\tboolean f(int a, double b);\n\t}\n\n\tinterface LBB {\n\t\tboolean f(long a, boolean b);\n\t}\n\n\tinterface LIB {\n\t\tboolean f(long a, int b);\n\t}\n\n\tinterface LLB {\n\t\tboolean f(long a, long b);\n\t}\n\n\tinterface LDB {\n\t\tboolean f(long a, double b);\n\t}\n\n\tinterface DBB {\n\t\tboolean f(double a, boolean b);\n\t}\n\n\tinterface DIB {\n\t\tboolean f(double a, int b);\n\t}\n\n\tinterface DLB {\n\t\tboolean f(double a, long b);\n\t}\n\n\tinterface DDB {\n\t\tboolean f(double a, double b);\n\t}\n\n\tinterface VI {\n\t\tint f();\n\t}\n\n\tinterface BI {\n\t\tint f(boolean a);\n\t}\n\n\tinterface BXI {\n\t\tint f(boolean a, A b);\n\t}\n\n\tinterface BXXI {\n\t\tint f(boolean a, A b, B c);\n\t}\n\n\tinterface BXXXI {\n\t\tint f(boolean a, A b, B c, C d);\n\t}\n\n\tinterface XBI {\n\t\tint f(A a, boolean b);\n\t}\n\n\tinterface XXBI {\n\t\tint f(A a, B b, boolean c);\n\t}\n\n\tinterface XXXBI {\n\t\tint f(A a, B b, C c, boolean d);\n\t}\n\n\tinterface II {\n\t\tint f(int a);\n\t}\n\n\tinterface IXI {\n\t\tint f(int a, A b);\n\t}\n\n\tinterface IXXI {\n\t\tint f(int a, A b, B c);\n\t}\n\n\tinterface IXXXI {\n\t\tint f(int a, A b, B c, C d);\n\t}\n\n\tinterface XII {\n\t\tint f(A a, int b);\n\t}\n\n\tinterface XXII {\n\t\tint f(A a, B b, int c);\n\t}\n\n\tinterface XXXII {\n\t\tint f(A a, B b, C c, int d);\n\t}\n\n\tinterface LI {\n\t\tint f(long a);\n\t}\n\n\tinterface LXI {\n\t\tint f(long a, A b);\n\t}\n\n\tinterface LXXI {\n\t\tint f(long a, A b, B c);\n\t}\n\n\tinterface LXXXI {\n\t\tint f(long a, A b, B c, C d);\n\t}\n\n\tinterface XLI {\n\t\tint f(A a, long b);\n\t}\n\n\tinterface XXLI {\n\t\tint f(A a, B b, long c);\n\t}\n\n\tinterface XXXLI {\n\t\tint f(A a, B b, C c, long d);\n\t}\n\n\tinterface DI {\n\t\tint f(double a);\n\t}\n\n\tinterface DXI {\n\t\tint f(double a, A b);\n\t}\n\n\tinterface DXXI {\n\t\tint f(double a, A b, B c);\n\t}\n\n\tinterface DXXXI {\n\t\tint f(double a, A b, B c, C d);\n\t}\n\n\tinterface XDI {\n\t\tint f(A a, double b);\n\t}\n\n\tinterface XXDI {\n\t\tint f(A a, B b, double c);\n\t}\n\n\tinterface XXXDI {\n\t\tint f(A a, B b, C c, double d);\n\t}\n\n\tinterface XI {\n\t\tint f(A a);\n\t}\n\n\tinterface XXI {\n\t\tint f(A a, B b);\n\t}\n\n\tinterface XXXI {\n\t\tint f(A a, B b, C c);\n\t}\n\n\tinterface XXXXI {\n\t\tint f(A a, B b, C c, D d);\n\t}\n\n\tinterface BBI {\n\t\tint f(boolean a, boolean b);\n\t}\n\n\tinterface BII {\n\t\tint f(boolean a, int b);\n\t}\n\n\tinterface BLI {\n\t\tint f(boolean a, long b);\n\t}\n\n\tinterface BDI {\n\t\tint f(boolean a, double b);\n\t}\n\n\tinterface IBI {\n\t\tint f(int a, boolean b);\n\t}\n\n\tinterface III {\n\t\tint f(int a, int b);\n\t}\n\n\tinterface ILI {\n\t\tint f(int a, long b);\n\t}\n\n\tinterface IDI {\n\t\tint f(int a, double b);\n\t}\n\n\tinterface LBI {\n\t\tint f(long a, boolean b);\n\t}\n\n\tinterface LII {\n\t\tint f(long a, int b);\n\t}\n\n\tinterface LLI {\n\t\tint f(long a, long b);\n\t}\n\n\tinterface LDI {\n\t\tint f(long a, double b);\n\t}\n\n\tinterface DBI {\n\t\tint f(double a, boolean b);\n\t}\n\n\tinterface DII {\n\t\tint f(double a, int b);\n\t}\n\n\tinterface DLI {\n\t\tint f(double a, long b);\n\t}\n\n\tinterface DDI {\n\t\tint f(double a, double b);\n\t}\n\n\tinterface VL {\n\t\tlong f();\n\t}\n\n\tinterface BL {\n\t\tlong f(boolean a);\n\t}\n\n\tinterface BXL {\n\t\tlong f(boolean a, A b);\n\t}\n\n\tinterface BXXL {\n\t\tlong f(boolean a, A b, B c);\n\t}\n\n\tinterface BXXXL {\n\t\tlong f(boolean a, A b, B c, C d);\n\t}\n\n\tinterface XBL {\n\t\tlong f(A a, boolean b);\n\t}\n\n\tinterface XXBL {\n\t\tlong f(A a, B b, boolean c);\n\t}\n\n\tinterface XXXBL {\n\t\tlong f(A a, B b, C c, boolean d);\n\t}\n\n\tinterface IL {\n\t\tlong f(int a);\n\t}\n\n\tinterface IXL {\n\t\tlong f(int a, A b);\n\t}\n\n\tinterface IXXL {\n\t\tlong f(int a, A b, B c);\n\t}\n\n\tinterface IXXXL {\n\t\tlong f(int a, A b, B c, C d);\n\t}\n\n\tinterface XIL {\n\t\tlong f(A a, int b);\n\t}\n\n\tinterface XXIL {\n\t\tlong f(A a, B b, int c);\n\t}\n\n\tinterface XXXIL {\n\t\tlong f(A a, B b, C c, int d);\n\t}\n\n\tinterface LL {\n\t\tlong f(long a);\n\t}\n\n\tinterface LXL {\n\t\tlong f(long a, A b);\n\t}\n\n\tinterface LXXL {\n\t\tlong f(long a, A b, B c);\n\t}\n\n\tinterface LXXXL {\n\t\tlong f(long a, A b, B c, C d);\n\t}\n\n\tinterface XLL {\n\t\tlong f(A a, long b);\n\t}\n\n\tinterface XXLL {\n\t\tlong f(A a, B b, long c);\n\t}\n\n\tinterface XXXLL {\n\t\tlong f(A a, B b, C c, long d);\n\t}\n\n\tinterface DL {\n\t\tlong f(double a);\n\t}\n\n\tinterface DXL {\n\t\tlong f(double a, A b);\n\t}\n\n\tinterface DXXL {\n\t\tlong f(double a, A b, B c);\n\t}\n\n\tinterface DXXXL {\n\t\tlong f(double a, A b, B c, C d);\n\t}\n\n\tinterface XDL {\n\t\tlong f(A a, double b);\n\t}\n\n\tinterface XXDL {\n\t\tlong f(A a, B b, double c);\n\t}\n\n\tinterface XXXDL {\n\t\tlong f(A a, B b, C c, double d);\n\t}\n\n\tinterface XL {\n\t\tlong f(A a);\n\t}\n\n\tinterface XXL {\n\t\tlong f(A a, B b);\n\t}\n\n\tinterface XXXL {\n\t\tlong f(A a, B b, C c);\n\t}\n\n\tinterface XXXXL {\n\t\tlong f(A a, B b, C c, D d);\n\t}\n\n\tinterface BBL {\n\t\tlong f(boolean a, boolean b);\n\t}\n\n\tinterface BIL {\n\t\tlong f(boolean a, int b);\n\t}\n\n\tinterface BLL {\n\t\tlong f(boolean a, long b);\n\t}\n\n\tinterface BDL {\n\t\tlong f(boolean a, double b);\n\t}\n\n\tinterface IBL {\n\t\tlong f(int a, boolean b);\n\t}\n\n\tinterface IIL {\n\t\tlong f(int a, int b);\n\t}\n\n\tinterface ILL {\n\t\tlong f(int a, long b);\n\t}\n\n\tinterface IDL {\n\t\tlong f(int a, double b);\n\t}\n\n\tinterface LBL {\n\t\tlong f(long a, boolean b);\n\t}\n\n\tinterface LIL {\n\t\tlong f(long a, int b);\n\t}\n\n\tinterface LLL {\n\t\tlong f(long a, long b);\n\t}\n\n\tinterface LDL {\n\t\tlong f(long a, double b);\n\t}\n\n\tinterface DBL {\n\t\tlong f(double a, boolean b);\n\t}\n\n\tinterface DIL {\n\t\tlong f(double a, int b);\n\t}\n\n\tinterface DLL {\n\t\tlong f(double a, long b);\n\t}\n\n\tinterface DDL {\n\t\tlong f(double a, double b);\n\t}\n\n\tinterface VD {\n\t\tdouble f();\n\t}\n\n\tinterface BD {\n\t\tdouble f(boolean a);\n\t}\n\n\tinterface BXD {\n\t\tdouble f(boolean a, A b);\n\t}\n\n\tinterface BXXD {\n\t\tdouble f(boolean a, A b, B c);\n\t}\n\n\tinterface BXXXD {\n\t\tdouble f(boolean a, A b, B c, C d);\n\t}\n\n\tinterface XBD {\n\t\tdouble f(A a, boolean b);\n\t}\n\n\tinterface XXBD {\n\t\tdouble f(A a, B b, boolean c);\n\t}\n\n\tinterface XXXBD {\n\t\tdouble f(A a, B b, C c, boolean d);\n\t}\n\n\tinterface ID {\n\t\tdouble f(int a);\n\t}\n\n\tinterface IXD {\n\t\tdouble f(int a, A b);\n\t}\n\n\tinterface IXXD {\n\t\tdouble f(int a, A b, B c);\n\t}\n\n\tinterface IXXXD {\n\t\tdouble f(int a, A b, B c, C d);\n\t}\n\n\tinterface XID {\n\t\tdouble f(A a, int b);\n\t}\n\n\tinterface XXID {\n\t\tdouble f(A a, B b, int c);\n\t}\n\n\tinterface XXXID {\n\t\tdouble f(A a, B b, C c, int d);\n\t}\n\n\tinterface LD {\n\t\tdouble f(long a);\n\t}\n\n\tinterface LXD {\n\t\tdouble f(long a, A b);\n\t}\n\n\tinterface LXXD {\n\t\tdouble f(long a, A b, B c);\n\t}\n\n\tinterface LXXXD {\n\t\tdouble f(long a, A b, B c, C d);\n\t}\n\n\tinterface XLD {\n\t\tdouble f(A a, long b);\n\t}\n\n\tinterface XXLD {\n\t\tdouble f(A a, B b, long c);\n\t}\n\n\tinterface XXXLD {\n\t\tdouble f(A a, B b, C c, long d);\n\t}\n\n\tinterface DD {\n\t\tdouble f(double a);\n\t}\n\n\tinterface DXD {\n\t\tdouble f(double a, A b);\n\t}\n\n\tinterface DXXD {\n\t\tdouble f(double a, A b, B c);\n\t}\n\n\tinterface DXXXD {\n\t\tdouble f(double a, A b, B c, C d);\n\t}\n\n\tinterface XDD {\n\t\tdouble f(A a, double b);\n\t}\n\n\tinterface XXDD {\n\t\tdouble f(A a, B b, double c);\n\t}\n\n\tinterface XXXDD {\n\t\tdouble f(A a, B b, C c, double d);\n\t}\n\n\tinterface XD {\n\t\tdouble f(A a);\n\t}\n\n\tinterface XXD {\n\t\tdouble f(A a, B b);\n\t}\n\n\tinterface XXXD {\n\t\tdouble f(A a, B b, C c);\n\t}\n\n\tinterface XXXXD {\n\t\tdouble f(A a, B b, C c, D d);\n\t}\n\n\tinterface BBD {\n\t\tdouble f(boolean a, boolean b);\n\t}\n\n\tinterface BID {\n\t\tdouble f(boolean a, int b);\n\t}\n\n\tinterface BLD {\n\t\tdouble f(boolean a, long b);\n\t}\n\n\tinterface BDD {\n\t\tdouble f(boolean a, double b);\n\t}\n\n\tinterface IBD {\n\t\tdouble f(int a, boolean b);\n\t}\n\n\tinterface IID {\n\t\tdouble f(int a, int b);\n\t}\n\n\tinterface ILD {\n\t\tdouble f(int a, long b);\n\t}\n\n\tinterface IDD {\n\t\tdouble f(int a, double b);\n\t}\n\n\tinterface LBD {\n\t\tdouble f(long a, boolean b);\n\t}\n\n\tinterface LID {\n\t\tdouble f(long a, int b);\n\t}\n\n\tinterface LLD {\n\t\tdouble f(long a, long b);\n\t}\n\n\tinterface LDD {\n\t\tdouble f(long a, double b);\n\t}\n\n\tinterface DBD {\n\t\tdouble f(double a, boolean b);\n\t}\n\n\tinterface DID {\n\t\tdouble f(double a, int b);\n\t}\n\n\tinterface DLD {\n\t\tdouble f(double a, long b);\n\t}\n\n\tinterface DDD {\n\t\tdouble f(double a, double b);\n\t}\n\n\tinterface VX {\n\t\tA f();\n\t}\n\n\tinterface BX {\n\t\tA f(boolean a);\n\t}\n\n\tinterface BXX {\n\t\tB f(boolean a, A b);\n\t}\n\n\tinterface BXXX {\n\t\tC f(boolean a, A b, B c);\n\t}\n\n\tinterface BXXXX {\n\t\tD f(boolean a, A b, B c, C d);\n\t}\n\n\tinterface XBX {\n\t\tB f(A a, boolean b);\n\t}\n\n\tinterface XXBX {\n\t\tC f(A a, B b, boolean c);\n\t}\n\n\tinterface XXXBX {\n\t\tD f(A a, B b, C c, boolean d);\n\t}\n\n\tinterface IX {\n\t\tA f(int a);\n\t}\n\n\tinterface IXX {\n\t\tB f(int a, A b);\n\t}\n\n\tinterface IXXX {\n\t\tC f(int a, A b, B c);\n\t}\n\n\tinterface IXXXX {\n\t\tD f(int a, A b, B c, C d);\n\t}\n\n\tinterface XIX {\n\t\tB f(A a, int b);\n\t}\n\n\tinterface XXIX {\n\t\tC f(A a, B b, int c);\n\t}\n\n\tinterface XXXIX {\n\t\tD f(A a, B b, C c, int d);\n\t}\n\n\tinterface LX {\n\t\tA f(long a);\n\t}\n\n\tinterface LXX {\n\t\tB f(long a, A b);\n\t}\n\n\tinterface LXXX {\n\t\tC f(long a, A b, B c);\n\t}\n\n\tinterface LXXXX {\n\t\tD f(long a, A b, B c, C d);\n\t}\n\n\tinterface XLX {\n\t\tB f(A a, long b);\n\t}\n\n\tinterface XXLX {\n\t\tC f(A a, B b, long c);\n\t}\n\n\tinterface XXXLX {\n\t\tD f(A a, B b, C c, long d);\n\t}\n\n\tinterface DX {\n\t\tA f(double a);\n\t}\n\n\tinterface DXX {\n\t\tB f(double a, A b);\n\t}\n\n\tinterface DXXX {\n\t\tC f(double a, A b, B c);\n\t}\n\n\tinterface DXXXX {\n\t\tD f(double a, A b, B c, C d);\n\t}\n\n\tinterface XDX {\n\t\tB f(A a, double b);\n\t}\n\n\tinterface XXDX {\n\t\tC f(A a, B b, double c);\n\t}\n\n\tinterface XXXDX {\n\t\tD f(A a, B b, C c, double d);\n\t}\n\n\tinterface XX {\n\t\tB f(A a);\n\t}\n\n\tinterface XXX {\n\t\tC f(A a, B b);\n\t}\n\n\tinterface XXXX {\n\t\tD f(A a, B b, C c);\n\t}\n\n\tinterface XXXXX {\n\t\tE f(A a, B b, C c, D d);\n\t}\n\n\tinterface BBX {\n\t\tA f(boolean a, boolean b);\n\t}\n\n\tinterface BIX {\n\t\tA f(boolean a, int b);\n\t}\n\n\tinterface BLX {\n\t\tA f(boolean a, long b);\n\t}\n\n\tinterface BDX {\n\t\tA f(boolean a, double b);\n\t}\n\n\tinterface IBX {\n\t\tA f(int a, boolean b);\n\t}\n\n\tinterface IIX {\n\t\tA f(int a, int b);\n\t}\n\n\tinterface ILX {\n\t\tA f(int a, long b);\n\t}\n\n\tinterface IDX {\n\t\tA f(int a, double b);\n\t}\n\n\tinterface LBX {\n\t\tA f(long a, boolean b);\n\t}\n\n\tinterface LIX {\n\t\tA f(long a, int b);\n\t}\n\n\tinterface LLX {\n\t\tA f(long a, long b);\n\t}\n\n\tinterface LDX {\n\t\tA f(long a, double b);\n\t}\n\n\tinterface DBX {\n\t\tA f(double a, boolean b);\n\t}\n\n\tinterface DIX {\n\t\tA f(double a, int b);\n\t}\n\n\tinterface DLX {\n\t\tA f(double a, long b);\n\t}\n\n\tinterface DDX {\n\t\tA f(double a, double b);\n\t}\n}\n\nclass SA { // suffix array\n\tstatic int[] makeSA(String s) {\n\t\tint n = s.length() + 1;\n\t\tint[] cs = new int[n];\n\t\tcs[n - 1] = 0;\n\t\tfor (int i = 0; i < n - 1; i++)\n\t\t\tcs[i] = s.charAt(i) + 1;\n\t\tArrayList acs = U.make(n, i -> cs[i]);\n\t\tTreeMap tm = U.compress(acs).a;\n\t\tint k = tm.size();\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tcs[i] = tm.get(cs[i]);\n\t\treturn makeSA(cs, n, k);\n\t}\n\n\tstatic int[] makeLCP(String s, int[] sa) { // lcp(i, i+1)\n\t\tint n = sa.length;\n\t\tint[] r = new int[n];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tr[sa[i]] = i;\n\t\tint[] lcp = new int[n];\n\t\tint l = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tint idx = r[i];\n\t\t\tif (idx == n - 1) {\n\t\t\t\tlcp[idx] = -1;\n\t\t\t\tl = 0;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tint p = sa[idx];\n\t\t\tint q = sa[idx + 1];\n\t\t\tif (l > 0)\n\t\t\t\tl--;\n\t\t\twhile (p + l < n - 1 && q + l < n - 1 && s.charAt(p + l) == s.charAt(q + l))\n\t\t\t\tl++;\n\t\t\tlcp[idx] = l;\n\t\t}\n\t\treturn lcp;\n\t}\n\n\tstatic F.III lcpQuery(String s) {\n\t\tint n = s.length() + 1;\n\t\tint[] sa = makeSA(s);\n\t\tint[] lcp = makeLCP(s, sa);\n\t\tint[] inv = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tinv[sa[i]] = i;\n\t\t}\n\t\tST st = new ST(n, (a, b) -> a < b ? a : b, Integer.MAX_VALUE);\n\t\tst.init(i -> i < n ? lcp[i] : Integer.MAX_VALUE);\n\t\treturn (i, j) -> {\n\t\t\tif (i == j)\n\t\t\t\treturn n - 1 - i;\n\t\t\ti = inv[i];\n\t\t\tj = inv[j];\n\t\t\tif (i > j) {\n\t\t\t\ti ^= j;\n\t\t\t\tj ^= i;\n\t\t\t\ti ^= j;\n\t\t\t}\n\t\t\treturn st.query(i, j);\n\t\t};\n\t}\n\n\tprivate static int[] makeSA(int[] cs, int n, int k) {\n\t\tboolean[] isS = new boolean[n];\n\t\tboolean[] isLms = new boolean[n];\n\t\tint[] lmss = new int[n];\n\t\tint numLmss = 0;\n\t\tisS[n - 1] = true;\n\t\tfor (int i = n - 2; i >= 0; i--)\n\t\t\tisS[i] = cs[i] < cs[i + 1] || cs[i] == cs[i + 1] && isS[i + 1];\n\t\tfor (int i = 1; i < n; i++)\n\t\t\tif (!isS[i - 1] && isS[i]) {\n\t\t\t\tlmss[numLmss++] = i;\n\t\t\t\tisLms[i] = true;\n\t\t\t}\n\t\tint[] sa = inducedSort(cs, n, numLmss, k, lmss, isS);\n\t\tint[] lmss2 = new int[numLmss];\n\t\tnumLmss = 0;\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tif (isLms[sa[i]])\n\t\t\t\tlmss2[numLmss++] = sa[i];\n\t\tint num = 0;\n\t\tsa[lmss2[0]] = 0;\n\t\tfor (int i = 0; i < numLmss - 1; i++) {\n\t\t\tint p = lmss2[i];\n\t\t\tint q = lmss2[i + 1];\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tif (cs[p] != cs[q] || isLms[p] != isLms[q]) {\n\t\t\t\t\tsa[lmss2[i + 1]] = ++num;\n\t\t\t\t\tbreak;\n\t\t\t\t} else if (j > 0 && (isLms[p] || isLms[q])) {\n\t\t\t\t\tsa[lmss2[i + 1]] = num;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tp++;\n\t\t\t\tq++;\n\t\t\t}\n\t\t}\n\t\tif (num + 1 < numLmss) {\n\t\t\tnumLmss = 0;\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\tif (isLms[i])\n\t\t\t\t\tlmss2[numLmss++] = sa[i];\n\t\t\tlmss2 = makeSA(lmss2, numLmss, num + 1);\n\t\t\tfor (int i = 0; i < numLmss; i++)\n\t\t\t\tlmss2[i] = lmss[lmss2[i]];\n\t\t}\n\t\treturn inducedSort(cs, n, numLmss, k, lmss2, isS);\n\t}\n\n\tprivate static int[] inducedSort(int[] cs, int n, int numLmss, int k, int[] lmss, boolean[] isS) {\n\t\tint[] sa = new int[n];\n\t\tint[] bin = new int[k + 1];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tbin[cs[i] + 1]++;\n\t\tfor (int i = 0; i < k; i++)\n\t\t\tbin[i + 1] += bin[i];\n\t\tint[] counts = new int[k];\n\t\tfor (int i = numLmss - 1; i >= 0; i--) { // put LMS backward\n\t\t\tint c = cs[lmss[i]];\n\t\t\tsa[bin[c + 1] - 1 - counts[c]++] = lmss[i];\n\t\t}\n\t\tfor (int i = 0; i < k; i++)\n\t\t\tcounts[i] = 0;\n\t\tfor (int i = 0; i < n; i++) { // put L forward\n\t\t\tint s = sa[i] - 1;\n\t\t\tif (s < 0 || isS[s])\n\t\t\t\tcontinue;\n\t\t\tint c = cs[s];\n\t\t\tsa[bin[c] + counts[c]++] = s;\n\t\t}\n\t\tfor (int i = 0; i < k; i++)\n\t\t\tcounts[i] = 0;\n\t\tfor (int i = n - 1; i >= 0; i--) { // put S backward\n\t\t\tint s = sa[i] - 1;\n\t\t\tif (s < 0 || !isS[s])\n\t\t\t\tcontinue;\n\t\t\tint c = cs[s];\n\t\t\tsa[bin[c + 1] - 1 - counts[c]++] = s;\n\t\t}\n\t\treturn sa;\n\t}\n}\n\nclass ST { // Segment Tree\n\tprivate ArrayList as;\n\tprivate int h;\n\tprivate int n;\n\tprivate F.XXX merger;\n\tprivate A e;\n\n\tST(int num, F.XXX merger, A e) {\n\t\tthis.merger = merger;\n\t\tthis.e = e;\n\t\th = 0;\n\t\twhile ((1 << h) < num)\n\t\t\th++;\n\t\tn = 1 << h;\n\t\tas = U.make(2 * n, i -> e);\n\t}\n\n\tvoid init(A a) {\n\t\tinit(i -> a);\n\t}\n\n\tvoid init(A[] as) {\n\t\tinit(i -> i < as.length ? as[i] : e);\n\t}\n\n\tvoid init(F.IX maker) {\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tas.set(n + i, maker.f(i));\n\t\tfor (int i = n - 1; i > 0; i--)\n\t\t\tas.set(i, merge(as.get(i << 1), as.get(i << 1 | 1)));\n\t}\n\n\tA get(int i) {\n\t\treturn query(i, i + 1);\n\t}\n\n\tvoid set(int i, A a) {\n\t\tas.set(i += n, a);\n\t\twhile ((i >>= 1) > 0)\n\t\t\tas.set(i, merge(as.get(i << 1), as.get(i << 1 | 1)));\n\t}\n\n\tA query(int l, int r) {\n\t\tl += n;\n\t\tr += n;\n\t\tA al = e;\n\t\tA ar = e;\n\t\twhile (l < r) {\n\t\t\tif ((l & 1) != 0)\n\t\t\t\tal = merge(al, as.get(l++));\n\t\t\tif ((r & 1) != 0)\n\t\t\t\tar = merge(as.get(--r), ar);\n\t\t\tl >>= 1;\n\t\t\tr >>= 1;\n\t\t}\n\t\treturn merge(al, ar);\n\t}\n\n\tprivate A merge(A a, A b) {\n\t\treturn a == e ? b : b == e ? a : merger.f(a, b);\n\t}\n}\n\nclass LST { // Lazy Segment Tree\n\tprivate ArrayList as;\n\tprivate ArrayList lazy;\n\tprivate F.XXX merger;\n\tprivate F.XXIX applier;\n\tprivate F.XXX opMerger;\n\tprivate A e;\n\tprivate Op id;\n\tprivate int h;\n\tprivate int n;\n\n\tLST(int num, F.XXX merger, F.XXIX applier, F.XXX opMerger, A e, Op id) {\n\t\tthis.merger = merger;\n\t\tthis.applier = applier;\n\t\tthis.opMerger = opMerger;\n\t\tthis.e = e;\n\t\tthis.id = id;\n\t\th = 0;\n\t\twhile ((1 << h) < num)\n\t\t\th++;\n\t\tn = 1 << h;\n\t\tint size = n << 1;\n\t\tas = U.make(size, i -> e);\n\t\tlazy = U.make(size, i -> id);\n\t}\n\n\tvoid init(A a) {\n\t\tinit(i -> a);\n\t}\n\n\tvoid init(A[] as) {\n\t\tinit(i -> i < as.length ? as[i] : e);\n\t}\n\n\tvoid init(F.IX maker) {\n\t\tfor (int i = 0; i < n << 1; i++)\n\t\t\tlazy.set(i, id);\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tas.set(n + i, maker.f(i));\n\t\tfor (int i = n - 1; i > 0; i--)\n\t\t\tas.set(i, merge(as.get(i << 1), as.get(i << 1 | 1)));\n\t}\n\n\tA get(int i) {\n\t\treturn query(i, i + 1);\n\t}\n\n\tvoid set(int i, A a) {\n\t\tprop(i += n);\n\t\tas.set(i, a);\n\t\tlazy.set(i, id);\n\t\tbackprop(i);\n\t}\n\n\tA query(int l, int r) {\n\t\tprop(l += n);\n\t\tprop(r += n - 1);\n\t\tr++;\n\t\tA al = e;\n\t\tA ar = e;\n\t\tint len = 1;\n\t\twhile (l < r) {\n\t\t\tif ((l & 1) != 0)\n\t\t\t\tal = merge(al, eval(l++, len));\n\t\t\tif ((r & 1) != 0)\n\t\t\t\tar = merge(eval(--r, len), ar);\n\t\t\tl >>= 1;\n\t\t\tr >>= 1;\n\t\t\tlen <<= 1;\n\t\t}\n\t\treturn merge(al, ar);\n\t}\n\n\tvoid apply(int l, int r, Op o) {\n\t\tprop(l += n);\n\t\tprop(r += n - 1);\n\t\tint a = l;\n\t\tint b = r;\n\t\tr++;\n\t\twhile (l < r) {\n\t\t\tif ((l & 1) != 0)\n\t\t\t\tlazy.set(l, mergeOp(lazy.get(l++), o));\n\t\t\tif ((r & 1) != 0)\n\t\t\t\tlazy.set(--r, mergeOp(lazy.get(r), o));\n\t\t\tl >>= 1;\n\t\t\tr >>= 1;\n\t\t}\n\t\tbackprop(a);\n\t\tbackprop(b);\n\t}\n\n\tint size() {\n\t\treturn n;\n\t}\n\n\tprivate A merge(A a, A b) {\n\t\treturn a == e ? b : b == e ? a : merger.f(a, b);\n\t}\n\n\tprivate Op mergeOp(Op o, Op p) {\n\t\treturn o == id ? p : p == id ? o : opMerger.f(o, p);\n\t}\n\n\tprivate A apply(A a, Op o, int len) {\n\t\treturn o == id ? a : applier.f(a, o, len);\n\t}\n\n\tprivate A eval(int k, int len) {\n\t\treturn apply(as.get(k), lazy.get(k), len);\n\t}\n\n\tprivate void flush(int k, int len) {\n\t\tOp o = lazy.get(k);\n\t\tif (o == id)\n\t\t\treturn;\n\t\tlazy.set(k << 1, mergeOp(lazy.get(k << 1), o));\n\t\tlazy.set(k << 1 | 1, mergeOp(lazy.get(k << 1 | 1), o));\n\t\tas.set(k, apply(as.get(k), o, len));\n\t\tlazy.set(k, id);\n\t}\n\n\tprivate void prop(int k) {\n\t\tfor (int i = h; i > 0; i--)\n\t\t\tflush(k >> i, 1 << i);\n\t}\n\n\tprivate void backprop(int k) {\n\t\tint len = 1;\n\t\twhile ((k >>= 1) > 0) {\n\t\t\tas.set(k, merge(eval(k << 1, len), eval(k << 1 | 1, len)));\n\t\t\tlen <<= 1;\n\t\t}\n\t}\n}\n\ninterface Magma {\n\tA g(A a, A b);\n}\n\ninterface Associative {\n}\n\ninterface Unital {\n\tA e();\n}\n\ninterface Invertible {\n\tA inv(A a);\n}\n\ninterface Commutative {\n}\n\ninterface SemiGroup extends Magma, Associative {\n}\n\ninterface Monoid extends SemiGroup, Unital {\n\tstatic Monoid make(F.XXX g, A e) {\n\t\treturn new Monoid() {\n\t\t\tpublic A g(A a, A b) {\n\t\t\t\treturn a.equals(e) ? b : b.equals(e) ? a : g.f(a, b);\n\t\t\t}\n\n\t\t\tpublic A e() {\n\t\t\t\treturn e;\n\t\t\t}\n\t\t};\n\t}\n}\n\ninterface CommutativeMonoid extends Monoid, Commutative {\n\tstatic CommutativeMonoid make(F.XXX g, A e) {\n\t\treturn new CommutativeMonoid() {\n\t\t\tpublic A g(A a, A b) {\n\t\t\t\treturn a.equals(e) ? b : b.equals(e) ? a : g.f(a, b);\n\t\t\t}\n\n\t\t\tpublic A e() {\n\t\t\t\treturn e;\n\t\t\t}\n\t\t};\n\t}\n}\n\ninterface Group extends Monoid, Invertible {\n\tstatic Group make(F.XXX g, F.XX inv, A e) {\n\t\treturn new Group() {\n\t\t\tpublic A g(A a, A b) {\n\t\t\t\treturn a.equals(e) ? b : b.equals(e) ? a : g.f(a, b);\n\t\t\t}\n\n\t\t\tpublic A e() {\n\t\t\t\treturn e;\n\t\t\t}\n\n\t\t\tpublic A inv(A a) {\n\t\t\t\treturn a.equals(e) ? e : inv.f(a);\n\t\t\t}\n\t\t};\n\t}\n}\n\ninterface AbelianGroup extends Group, CommutativeMonoid {\n\tstatic AbelianGroup make(F.XXX g, F.XX inv, A e) {\n\t\treturn new AbelianGroup() {\n\t\t\tpublic A g(A a, A b) {\n\t\t\t\treturn a.equals(e) ? b : b.equals(e) ? a : g.f(a, b);\n\t\t\t}\n\n\t\t\tpublic A e() {\n\t\t\t\treturn e;\n\t\t\t}\n\n\t\t\tpublic A inv(A a) {\n\t\t\t\treturn a.equals(e) ? e : inv.f(a);\n\t\t\t}\n\t\t};\n\t}\n}\n\ninterface Ring {\n\tAbelianGroup add();\n\n\tMonoid mul();\n\n\tdefault A zero() {\n\t\treturn add().e();\n\t}\n\n\tdefault A one() {\n\t\treturn mul().e();\n\t}\n\n\tstatic Ring make(F.XXX add, F.XX neg, F.XXX mul, A zero, A one) {\n\t\treturn make(AbelianGroup.make(add, neg, zero), Monoid.make(mul, one));\n\t}\n\n\tstatic Ring make(AbelianGroup add, Monoid mul) {\n\t\treturn new Ring() {\n\t\t\tpublic AbelianGroup add() {\n\t\t\t\treturn add;\n\t\t\t}\n\n\t\t\tpublic Monoid mul() {\n\t\t\t\treturn mul;\n\t\t\t}\n\t\t};\n\t}\n}\n\ninterface CommutativeRing extends Ring {\n\tCommutativeMonoid mul();\n\n\tstatic CommutativeRing make(F.XXX add, F.XX neg, F.XXX mul, A zero, A one) {\n\t\treturn make(AbelianGroup.make(add, neg, zero), CommutativeMonoid.make(mul, one));\n\t}\n\n\tstatic CommutativeRing make(AbelianGroup add, CommutativeMonoid mul) {\n\t\treturn new CommutativeRing() {\n\t\t\tpublic AbelianGroup add() {\n\t\t\t\treturn add;\n\t\t\t}\n\n\t\t\tpublic CommutativeMonoid mul() {\n\t\t\t\treturn mul;\n\t\t\t}\n\t\t};\n\t}\n}\n\ninterface EuclideanRing extends CommutativeRing {\n\tA div(A a, A b);\n\n\tA mod(A a, A b);\n\n\tstatic EuclideanRing make(F.XXX add, F.XX neg, F.XXX mul, F.XXX div,\n\t\t\tF.XXX mod, A zero, A one) {\n\t\treturn make(AbelianGroup.make(add, neg, zero), CommutativeMonoid.make(mul, one), div, mod);\n\t}\n\n\tstatic EuclideanRing make(AbelianGroup add, CommutativeMonoid mul, F.XXX div,\n\t\t\tF.XXX mod) {\n\t\tfinal A zero = add.e();\n\t\tfinal A one = mul.e();\n\t\treturn new EuclideanRing() {\n\t\t\tpublic AbelianGroup add() {\n\t\t\t\treturn add;\n\t\t\t}\n\n\t\t\tpublic CommutativeMonoid mul() {\n\t\t\t\treturn mul;\n\t\t\t}\n\n\t\t\tpublic A div(A a, A b) {\n\t\t\t\tif (b.equals(zero))\n\t\t\t\t\tthrow new ArithmeticException(\"division by zero\");\n\t\t\t\treturn b.equals(one) ? a : div.f(a, b);\n\t\t\t}\n\n\t\t\tpublic A mod(A a, A b) {\n\t\t\t\tif (b.equals(zero))\n\t\t\t\t\tthrow new ArithmeticException(\"division by zero\");\n\t\t\t\treturn b.equals(one) ? zero : mod.f(a, b);\n\t\t\t}\n\t\t};\n\t}\n}\n\ninterface Field extends EuclideanRing {\n\tAbelianGroup mul();\n\n\tstatic Field make(F.XXX add, F.XX neg, F.XXX mul, F.XX inv, A zero, A one) {\n\t\treturn make(AbelianGroup.make(add, neg, zero), AbelianGroup.make(mul, inv, one));\n\t}\n\n\tstatic Field make(AbelianGroup add, AbelianGroup mul) {\n\t\tfinal A zero = add.e();\n\t\tfinal A one = mul.e();\n\t\treturn new Field() {\n\t\t\tpublic AbelianGroup add() {\n\t\t\t\treturn add;\n\t\t\t}\n\n\t\t\tpublic AbelianGroup mul() {\n\t\t\t\treturn mul;\n\t\t\t}\n\n\t\t\tpublic A div(A a, A b) {\n\t\t\t\tif (b.equals(zero))\n\t\t\t\t\tthrow new ArithmeticException(\"division by zero\");\n\t\t\t\treturn b.equals(one) ? a : mul.g(a, mul.inv(b));\n\t\t\t}\n\n\t\t\tpublic A mod(A a, A b) {\n\t\t\t\tif (b.equals(zero))\n\t\t\t\t\tthrow new ArithmeticException(\"division by zero\");\n\t\t\t\treturn zero;\n\t\t\t}\n\t\t};\n\t}\n}\n\nfinal class Alg {\n\tprivate Alg() {\n\t}\n\n\tstatic > A gcd(A a, A b, EuclideanRing ring) {\n\t\tAbelianGroup add = ring.add();\n\t\tA zero = add.e();\n\t\tint sa = a.compareTo(zero);\n\t\tint sb = b.compareTo(zero);\n\t\tif (sa == 0)\n\t\t\treturn b;\n\t\tif (sb == 0)\n\t\t\treturn a;\n\t\tif (sa < 0)\n\t\t\ta = add.inv(a);\n\t\tif (sb < 0)\n\t\t\tb = add.inv(b);\n\t\tif (a.compareTo(b) < 0) {\n\t\t\tA tmp = a;\n\t\t\ta = b;\n\t\t\tb = tmp;\n\t\t}\n\t\twhile (true) {\n\t\t\tA c = ring.mod(a, b);\n\t\t\tif (c.compareTo(zero) == 0)\n\t\t\t\treturn b;\n\t\t\ta = b;\n\t\t\tb = c;\n\t\t}\n\t}\n\n\tstatic long gcd(long a, long b) {\n\t\tif (a == 0)\n\t\t\treturn b;\n\t\tif (b == 0)\n\t\t\treturn a;\n\t\tif (a < 0)\n\t\t\ta = -a;\n\t\tif (b < 0)\n\t\t\tb = -b;\n\t\tif (a < b) {\n\t\t\ta ^= b;\n\t\t\tb ^= a;\n\t\t\ta ^= b;\n\t\t}\n\t\twhile (true) {\n\t\t\tlong c = a % b;\n\t\t\tif (c == 0)\n\t\t\t\treturn b;\n\t\t\ta = b;\n\t\t\tb = c;\n\t\t}\n\t}\n\n\tstatic int gcd(int a, int b) {\n\t\treturn (int) gcd((long) a, (long) b);\n\t}\n\n\tstatic > int[] lis(F.IX access, int size) {\n\t\tObject[] dp = new Object[size];\n\t\tint[][] dpIndices = new int[size][2];\n\t\tdp[0] = access.f(0);\n\t\tint len = 1;\n\t\tint lidx = 0;\n\t\tfor (int i = 1; i < size; i++) {\n\t\t\tA ai = access.f(i);\n\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\tint idx = U.searchI(-1, len, j -> ai.compareTo((A) dp[j]) <= 0); // replace <= with < to return NLDS\n\t\t\tdp[idx] = ai;\n\t\t\tdpIndices[idx][0] = i;\n\t\t\tif (idx == len) {\n\t\t\t\tlidx = i;\n\t\t\t\tlen++;\n\t\t\t}\n\t\t\tif (idx > 0)\n\t\t\t\tdpIndices[i][1] = dpIndices[idx - 1][0];\n\t\t}\n\t\tint[] res = new int[len];\n\t\tres[len - 1] = lidx;\n\t\tfor (int i = len - 1; i >= 0; i--) {\n\t\t\tres[i] = lidx;\n\t\t\tlidx = dpIndices[lidx][1];\n\t\t}\n\t\treturn res;\n\t}\n\n\tstatic A pow(A a, long b, Monoid monoid) {\n\t\tA res = monoid.e();\n\t\twhile (b > 0) {\n\t\t\tif ((b & 1) != 0)\n\t\t\t\tres = monoid.g(res, a);\n\t\t\ta = monoid.g(a, a);\n\t\t\tb >>= 1;\n\t\t}\n\t\treturn res;\n\t}\n\n\tstatic A pow(A a, BigInteger b, Monoid monoid) {\n\t\tA res = monoid.e();\n\t\twhile (b.compareTo(BigInteger.ZERO) > 0) {\n\t\t\tif ((b.and(BigInteger.ONE)).intValueExact() != 0)\n\t\t\t\tres = monoid.g(res, a);\n\t\t\ta = monoid.g(a, a);\n\t\t\tb = b.divide(BigInteger.valueOf(2));\n\t\t}\n\t\treturn res;\n\t}\n\n\tstatic long pow(long a, long b) {\n\t\tlong res = 1;\n\t\twhile (b > 0) {\n\t\t\tif ((b & 1) != 0)\n\t\t\t\tres *= a;\n\t\t\ta *= a;\n\t\t\tb >>= 1;\n\t\t}\n\t\treturn res;\n\t}\n\n\tstatic > T extgcd(A a, A b, EuclideanRing ring) { // returns (x, y, d) s.t. ax + by = d\n\t\tAbelianGroup add = ring.add();\n\t\tCommutativeMonoid mul = ring.mul();\n\t\tA zero = add.e();\n\t\tA one = mul.e();\n\t\tA sa = a.compareTo(zero) < 0 ? add.inv(one) : one;\n\t\tA sb = b.compareTo(zero) < 0 ? add.inv(one) : one;\n\t\ta = mul.g(a, sa);\n\t\tb = mul.g(b, sb);\n\t\tA x = one;\n\t\tA y = zero;\n\t\tA z = zero;\n\t\tA w = one;\n\t\twhile (b.compareTo(zero) > 0) {\n\t\t\tA q = ring.div(a, b);\n\t\t\tA t = z;\n\t\t\tz = add.g(x, add.inv(mul.g(q, z)));\n\t\t\tx = t;\n\t\t\tt = w;\n\t\t\tw = add.g(y, add.inv(mul.g(q, w)));\n\t\t\ty = t;\n\t\t\tt = b;\n\t\t\tb = add.g(a, add.inv(mul.g(q, b)));\n\t\t\ta = t;\n\t\t}\n\t\treturn T.make(mul.g(x, sa), mul.g(y, sb), a);\n\t}\n\n\tstatic TL extgcd(long a, long b) {\n\t\tint sa = a < 0 ? -1 : 1;\n\t\tint sb = b < 0 ? -1 : 1;\n\t\ta *= sa;\n\t\tb *= sb;\n\t\tlong x = 1;\n\t\tlong y = 0;\n\t\tlong z = 0;\n\t\tlong w = 1;\n\t\twhile (b > 0) {\n\t\t\tlong q = a / b;\n\t\t\tlong t = z;\n\t\t\tz = x - q * z;\n\t\t\tx = t;\n\t\t\tt = w;\n\t\t\tw = y - q * w;\n\t\t\ty = t;\n\t\t\tt = b;\n\t\t\tb = a - q * b;\n\t\t\ta = t;\n\t\t}\n\t\treturn TL.make(x * sa, y * sb, a);\n\t}\n\n\tstatic TI extgcd(int a, int b) {\n\t\treturn extgcd((long) a, (long) b).toInt();\n\t}\n\n\tstatic ArrayList factorize(int n) { // factor, exponent\n\t\tArrayList res = new ArrayList();\n\t\tfor (int i = 2; i * i <= n; i++) {\n\t\t\tint count = 0;\n\t\t\twhile (n % i == 0) {\n\t\t\t\tn /= i;\n\t\t\t\tcount++;\n\t\t\t}\n\t\t\tif (count > 0)\n\t\t\t\tres.add(PI.make(i, count));\n\t\t}\n\t\tif (n > 1)\n\t\t\tres.add(PI.make(n, 1));\n\t\treturn res;\n\t}\n\n\tstatic ArrayList factorize(long n) { // factor, exponent\n\t\tArrayList res = new ArrayList();\n\t\tfor (int i = 2; i * i <= n; i++) {\n\t\t\tint count = 0;\n\t\t\twhile (n % i == 0) {\n\t\t\t\tn /= i;\n\t\t\t\tcount++;\n\t\t\t}\n\t\t\tif (count > 0)\n\t\t\t\tres.add(PL.make(i, count));\n\t\t}\n\t\tif (n > 1)\n\t\t\tres.add(PL.make(n, 1));\n\t\treturn res;\n\t}\n\n\tstatic A arithSum(A a, A d, long num, Ring ring) {\n\t\treturn arithGeomSum(a, d, ring.one(), ring.one(), num, ring);\n\t}\n\n\tstatic A geomSum(A b, A r, long num, Ring ring) {\n\t\treturn arithGeomSum(ring.one(), ring.zero(), b, r, num, ring);\n\t}\n\n\tstatic A arithGeomSum(A a, A d, A b, A r, long num, Ring ring) { // Σ(a+(i-1)d)br^(i-1)\n\t\tAbelianGroup add = ring.add();\n\t\tMonoid mul = ring.mul();\n\t\tMonoid> matMul = Mat.mulRing(3, ring);\n\t\tA zero = ring.zero();\n\t\tA one = ring.one();\n\t\tMN mat = pow(Mat.make(new Object[][] { { r, d, a }, { zero, r, r }, { zero, zero, one } }), num - 1, matMul);\n\t\treturn mul.g(add.g(add.g(mul.g(mat.at(0, 0), a), mul.g(mat.at(0, 1), r)), mat.at(0, 2)), b);\n\t}\n}\n\nclass MN {\n\tfinal int m;\n\tfinal int n;\n\tprivate final Object[][] as;\n\n\tstatic class Scalar extends MN {\n\t\tfinal long l;\n\t\tA a;\n\n\t\tScalar(int m, int n, long l, A zero, A oneTimesL) {\n\t\t\tsuper(m, n, (i, j) -> i == j ? oneTimesL : zero);\n\t\t\tthis.a = oneTimesL;\n\t\t\tthis.l = l;\n\t\t}\n\t}\n\n\tMN(int m, int n, Mat.Accessor accessor) {\n\t\tthis.m = m;\n\t\tthis.n = n;\n\t\tas = new Object[m][n];\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tas[i][j] = accessor.at(i, j);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic String toString() {\n\t\tString s = \"\";\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\ts += i == 0 ? \"[[ \" : \" [ \";\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\ts += (j == 0 ? \"\" : \", \") + as[i][j];\n\t\t\t}\n\t\t\ts += i == m - 1 ? \" ]]\" : \" ]\\n\";\n\t\t}\n\t\treturn s;\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tA at(int i, int j) {\n\t\treturn (A) as[i][j];\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tA[][] toArray() {\n\t\tA[][] res = (A[][]) Array.newInstance(as[0][0].getClass(), m, n);\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tres[i][j] = (A) as[i][j];\n\t\t\t}\n\t\t}\n\t\treturn res;\n\t}\n\n\tint[][] toIntArray() {\n\t\tint[][] res = new int[m][n];\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tres[i][j] = (int) as[i][j];\n\t\t\t}\n\t\t}\n\t\treturn res;\n\t}\n\n\tlong[][] toLongArray() {\n\t\tlong[][] res = new long[m][n];\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tres[i][j] = (long) as[i][j];\n\t\t\t}\n\t\t}\n\t\treturn res;\n\t}\n\n\tdouble[][] toDoubleArray() {\n\t\tdouble[][] res = new double[m][n];\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tres[i][j] = (double) as[i][j];\n\t\t\t}\n\t\t}\n\t\treturn res;\n\t}\n}\n\nclass Mat {\n\tinterface Accessor {\n\t\tA at(int i, int j);\n\t}\n\n\tprivate static MN.Scalar make(int m, int n, long l, A zero, A oneTimesL) {\n\t\treturn new MN.Scalar(m, n, l, zero, oneTimesL);\n\t}\n\n\tstatic MN make(int m, int n, Accessor accessor) {\n\t\treturn new MN(m, n, accessor);\n\t}\n\n\tstatic MN make(int m, int n, A[][] as) {\n\t\treturn new MN(m, n, (i, j) -> as[i][j]);\n\t}\n\n\tstatic MN make(int[][] as) {\n\t\treturn new MN(as.length, as.length == 0 ? 0 : as[0].length, (i, j) -> (long) as[i][j]);\n\t}\n\n\tstatic MN make(long[][] as) {\n\t\treturn new MN(as.length, as.length == 0 ? 0 : as[0].length, (i, j) -> as[i][j]);\n\t}\n\n\tstatic MN make(double[][] as) {\n\t\treturn new MN(as.length, as.length == 0 ? 0 : as[0].length, (i, j) -> as[i][j]);\n\t}\n\n\tstatic MN make(int[][] as, F.IX toA) {\n\t\treturn new MN(as.length, as.length == 0 ? 0 : as[0].length, (i, j) -> toA.f(as[i][j]));\n\t}\n\n\tstatic MN make(long[][] as, F.LX toA) {\n\t\treturn new MN(as.length, as.length == 0 ? 0 : as[0].length, (i, j) -> toA.f(as[i][j]));\n\t}\n\n\tstatic MN make(double[][] as, F.DX toA) {\n\t\treturn new MN(as.length, as.length == 0 ? 0 : as[0].length, (i, j) -> toA.f(as[i][j]));\n\t}\n\n\tstatic MN make(B[][] as, F.XX toA) {\n\t\treturn new MN(as.length, as.length == 0 ? 0 : as[0].length, (i, j) -> toA.f(as[i][j]));\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tstatic MN make(Object[][] as) {\n\t\treturn new MN(as.length, as.length == 0 ? 0 : as[0].length, (i, j) -> (A) as[i][j]);\n\t}\n\n\tstatic MN eye(int n, Ring ring) {\n\t\treturn make(n, n, (i, j) -> i == j ? ring.mul().e() : ring.add().e());\n\t}\n\n\tstatic AbelianGroup> add(int m, int n, Ring ring) {\n\t\treturn AbelianGroup.make((a, b) -> add(a, b, ring), a -> neg(a, ring), make(m, n, 0, ring.zero(), ring.zero()));\n\t}\n\n\tstatic Monoid> mulRing(int n, Ring ring) {\n\t\treturn Monoid.make((a, b) -> mul(a, b, ring), make(n, n, 1, ring.zero(), ring.one()));\n\t}\n\n\tstatic AbelianGroup> mulField(int n, Field field) {\n\t\treturn AbelianGroup.make((a, b) -> mul(a, b, field), a -> inv(a, field),\n\t\t\t\tmake(n, n, 1, field.zero(), field.one()));\n\t}\n\n\tstatic MN add(MN a, MN b, Ring ring) {\n\t\tint m = U.max(a.m, b.m);\n\t\tint n = U.max(a.n, b.n);\n\t\tAbelianGroup add = ring.add();\n\t\tif (a instanceof MN.Scalar && b instanceof MN.Scalar) {\n\t\t\tMN.Scalar as = ((MN.Scalar) a);\n\t\t\tMN.Scalar bs = ((MN.Scalar) b);\n\t\t\treturn make(m, n, as.l + bs.l, ring.zero(), add.g(as.a, bs.a));\n\t\t}\n\t\treturn make(m, n, (i, j) -> add.g(a.at(i, j), b.at(i, j)));\n\t}\n\n\tstatic MN neg(MN a, Ring ring) {\n\t\tif (a instanceof MN.Scalar) {\n\t\t\tMN.Scalar as = ((MN.Scalar) a);\n\t\t\treturn make(a.m, a.n, -as.l, ring.zero(), ring.add().inv(as.a));\n\t\t}\n\t\treturn make(a.m, a.n, (i, j) -> ring.add().inv(a.at(i, j)));\n\t}\n\n\tstatic MN mul(MN a, MN b, Ring ring) {\n\t\tint m = a.m;\n\t\tint u = U.max(a.n, b.m);\n\t\tint n = b.n;\n\t\tAbelianGroup add = ring.add();\n\t\tMonoid mul = ring.mul();\n\t\tif (a instanceof MN.Scalar && b instanceof MN.Scalar) {\n\t\t\tMN.Scalar as = ((MN.Scalar) a);\n\t\t\tMN.Scalar bs = ((MN.Scalar) b);\n\t\t\treturn make(m, n, as.l * bs.l, ring.zero(), mul.g(as.a, bs.a));\n\t\t}\n\t\treturn make(m, n, (i, j) -> {\n\t\t\tA res = ring.zero();\n\t\t\tfor (int k = 0; k < u; k++)\n\t\t\t\tres = add.g(res, mul.g(a.at(i, k), b.at(k, j)));\n\t\t\treturn res;\n\t\t});\n\t}\n\n\tstatic A det(MN a, Field field) {\n\t\treturn detInv(a, field).a;\n\t}\n\n\tstatic MN inv(MN a, Field field) {\n\t\tUP> detInv = detInv(a, field);\n\t\tif (detInv.a.equals(field.zero()))\n\t\t\tthrow new ArithmeticException(\"inverse does not exist: det=0\");\n\t\treturn detInv.b;\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tprivate static UP> detInv(MN a, Field field) {\n\t\tif (a.m != a.n)\n\t\t\tthrow new IllegalArgumentException(\"matrix not square\");\n\t\tif (field.zero() instanceof Long) {\n\t\t\tUP> detInv = detInvLong((MN) a, (Field) field);\n\t\t\treturn UP.make((A) detInv.a, (MN) detInv.b);\n\t\t}\n\t\tint n = a.n;\n\t\tAbelianGroup add = field.add();\n\t\tAbelianGroup mul = field.mul();\n\t\tA zero = field.zero();\n\t\tA one = field.one();\n\t\tA[][] m1 = a.toArray();\n\t\tA[][] m2 = eye(n, field).toArray();\n\t\tA res = one;\n\t\tint sign = 1;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tint pivot = -1;\n\t\t\tfor (int j = i; j < n; j++) {\n\t\t\t\tif (!m1[j][i].equals(zero)) {\n\t\t\t\t\tpivot = j;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (pivot == -1) {\n\t\t\t\treturn UP.make(zero, null);\n\t\t\t}\n\t\t\tif (pivot != i) {\n\t\t\t\tsign = -sign;\n\t\t\t\tA tmp;\n\t\t\t\tfor (int j = i; j < n; j++) { // [0, i) are zero\n\t\t\t\t\ttmp = m1[i][j];\n\t\t\t\t\tm1[i][j] = m1[pivot][j];\n\t\t\t\t\tm1[pivot][j] = tmp;\n\t\t\t\t}\n\t\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\t\ttmp = m2[i][j];\n\t\t\t\t\tm2[i][j] = m2[pivot][j];\n\t\t\t\t\tm2[pivot][j] = tmp;\n\t\t\t\t}\n\t\t\t}\n\t\t\tA d = m1[i][i];\n\t\t\tres = mul.g(res, d);\n\t\t\td = mul.inv(d);\n\t\t\tm1[i][i] = one;\n\t\t\tfor (int j = i + 1; j < n; j++) {\n\t\t\t\tm1[i][j] = mul.g(m1[i][j], d);\n\t\t\t}\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tm2[i][j] = mul.g(m2[i][j], d);\n\t\t\t}\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tif (i == j)\n\t\t\t\t\tcontinue;\n\t\t\t\tA mult = m1[j][i];\n\t\t\t\tm1[j][i] = zero;\n\t\t\t\tfor (int k = i + 1; k < n; k++) {\n\t\t\t\t\tm1[j][k] = add.g(m1[j][k], add.inv(mul.g(m1[i][k], mult)));\n\t\t\t\t}\n\t\t\t\tfor (int k = 0; k < n; k++) {\n\t\t\t\t\tm2[j][k] = add.g(m2[j][k], add.inv(mul.g(m2[i][k], mult)));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn UP.make(sign == 1 ? res : add.inv(res), make(m2));\n\t}\n\n\tprivate static UP> detInvLong(MN a, Field field) {\n\t\tif (a.m != a.n)\n\t\t\tthrow new IllegalArgumentException(\"matrix not square\");\n\t\tint n = a.n;\n\t\tAbelianGroup add = field.add();\n\t\tAbelianGroup mul = field.mul();\n\t\tlong zero = field.zero();\n\t\tlong one = field.one();\n\t\tlong[][] m1 = a.toLongArray();\n\t\tlong[][] m2 = eye(n, field).toLongArray();\n\t\tlong res = one;\n\t\tint sign = 1;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tint pivot = -1;\n\t\t\tfor (int j = i; j < n; j++) {\n\t\t\t\tif (m1[j][i] != zero) {\n\t\t\t\t\tpivot = j;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (pivot == -1) {\n\t\t\t\treturn UP.make(zero, null);\n\t\t\t}\n\t\t\tif (pivot != i) {\n\t\t\t\tsign = -sign;\n\t\t\t\tlong tmp;\n\t\t\t\tfor (int j = i; j < n; j++) { // [0, i) are zero\n\t\t\t\t\ttmp = m1[i][j];\n\t\t\t\t\tm1[i][j] = m1[pivot][j];\n\t\t\t\t\tm1[pivot][j] = tmp;\n\t\t\t\t}\n\t\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\t\ttmp = m2[i][j];\n\t\t\t\t\tm2[i][j] = m2[pivot][j];\n\t\t\t\t\tm2[pivot][j] = tmp;\n\t\t\t\t}\n\t\t\t}\n\t\t\tlong d = m1[i][i];\n\t\t\tres = mul.g(res, d);\n\t\t\td = mul.inv(d);\n\t\t\tm1[i][i] = one;\n\t\t\tfor (int j = i + 1; j < n; j++) {\n\t\t\t\tm1[i][j] = mul.g(m1[i][j], d);\n\t\t\t}\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tm2[i][j] = mul.g(m2[i][j], d);\n\t\t\t}\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tif (i == j)\n\t\t\t\t\tcontinue;\n\t\t\t\tlong mult = m1[j][i];\n\t\t\t\tm1[j][i] = zero;\n\t\t\t\tfor (int k = i + 1; k < n; k++) {\n\t\t\t\t\tm1[j][k] = add.g(m1[j][k], add.inv(mul.g(m1[i][k], mult)));\n\t\t\t\t}\n\t\t\t\tfor (int k = 0; k < n; k++) {\n\t\t\t\t\tm2[j][k] = add.g(m2[j][k], add.inv(mul.g(m2[i][k], mult)));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn UP.make(sign == 1 ? res : add.inv(res), make(m2));\n\t}\n\n\tstatic Ring> ring(int n, Ring ring) {\n\t\treturn Ring.make(add(n, n, ring), mulRing(n, ring));\n\t}\n\n\tstatic Field> field(int n, Field field) {\n\t\treturn Field.make(add(n, n, field), mulField(n, field));\n\t}\n\n\tstatic VM> vm(int n, Ring ring) {\n\t\tif (ring instanceof Field)\n\t\t\treturn vmField(n, (Field) ring);\n\t\treturn vmRing(n, ring);\n\t}\n\n\tprivate static VM> vmRing(int n, Ring ring) {\n\t\tRing> matRing = ring(n, ring);\n\t\tMonoid> matMul = matRing.mul();\n\t\tAbelianGroup add = ring.add();\n\t\tMonoid mul = ring.mul();\n\t\tA zero = add.e();\n\t\tA one = mul.e();\n\t\treturn new VM>(matRing, null, null, (a, b) -> {\n\t\t\tif (b instanceof MN.Scalar) {\n\t\t\t\tMN.Scalar bs = ((MN.Scalar) b);\n\t\t\t\tif (bs.l < 0)\n\t\t\t\t\tthrow new RuntimeException(\"pow(MN, <0) is not defined\");\n\t\t\t\treturn Alg.pow(a, bs.l, matMul);\n\t\t\t}\n\t\t\tthrow new RuntimeException(\"pow(MN, MN) is not defined\");\n\t\t}, null, l -> make(n, n, l, zero, Alg.pow(one, l, add)), a -> a);\n\t}\n\n\tprivate static VM> vmField(int n, Field field) {\n\t\tField> matField = field(n, field);\n\t\tAbelianGroup> matMul = matField.mul();\n\t\tA zero = field.zero();\n\t\tA one = field.one();\n\t\treturn new VM>(matField, (a, b) -> {\n\t\t\tif (b instanceof MN.Scalar) {\n\t\t\t\tMN.Scalar bs = ((MN.Scalar) b);\n\t\t\t\tif (bs.l < 0)\n\t\t\t\t\treturn Alg.pow(inv(a, field), -bs.l, matMul);\n\t\t\t\treturn Alg.pow(a, bs.l, matMul);\n\t\t\t}\n\t\t\tthrow new RuntimeException(\"pow(MN, MN) is not defined\");\n\t\t}, a -> inv(a, field), l -> make(n, n, l, zero, Alg.pow(one, l, field.add())), a -> a);\n\t}\n}\n\nclass VM {\n\tprivate final HashMap env;\n\tprivate final Evaluator etor;\n\tprivate final F.XX filter;\n\n\tVM(F.XXX add, F.XXX sub, F.XXX mul, F.XXX div, F.XXX mod,\n\t\t\tF.XXX pow, F.XX neg, F.XX fact, F.LX fromInt, F.XX filter) {\n\t\tenv = new HashMap();\n\t\tetor = SimpleLang.makeEvaluator((s, a) -> {\n\t\t\tenv.put(s, a);\n\t\t\treturn a;\n\t\t}, add, sub, mul, div, mod, pow, neg, fact, fromInt, s -> {\n\t\t\tif (env.containsKey(s))\n\t\t\t\treturn env.get(s);\n\t\t\tthrow new RuntimeException(\"no such variable: \" + s);\n\t\t});\n\t\tthis.filter = filter;\n\t}\n\n\tVM(Ring ring, F.XXX div, F.XXX mod, F.XXX pow, F.XX fact, F.LX fromInt,\n\t\t\tF.XX filter) {\n\t\tthis(ring.add()::g, (a, b) -> ring.add().g(a, ring.add().inv(b)), ring.mul()::g, div, mod, pow, ring.add()::inv,\n\t\t\t\tfact, fromInt, filter);\n\t}\n\n\tVM(EuclideanRing ring, F.XXX pow, F.XX fact, F.LX fromInt, F.XX filter) {\n\t\tthis(ring, ring::div, ring::mod, pow, fact, fromInt, filter);\n\t}\n\n\tvoid clear() {\n\t\tenv.clear();\n\t}\n\n\tA get(String id) {\n\t\treturn env.get(id);\n\t}\n\n\tvoid print(String id, F.XV printer) {\n\t\tprinter.f(\"\" + get(id));\n\t}\n\n\t@SafeVarargs\n\tfinal void set(String idsSp, A... as) {\n\t\tString[] ids = idsSp.trim().split(\" +\");\n\t\tint n = ids.length;\n\t\tif (as.length != n)\n\t\t\tthrow new IllegalArgumentException(\"argument size mismatch: \" + n + \" != \" + as.length);\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tset(ids[i], as[i]);\n\t}\n\n\tvoid set(String id, A a) {\n\t\tenv.put(id, filter.f(a));\n\t}\n\n\tA run(String expr) {\n\t\treturn AST.eval(SimpleLang.parse(expr), etor);\n\t}\n}\n\nclass AST { // Abstract Syntax Tree\n\tstatic class AssignOp extends AST {\n\t\tString id;\n\t\tAST r;\n\n\t\tAssignOp(String id, AST r) {\n\t\t\tthis.id = id;\n\t\t\tthis.r = r;\n\t\t}\n\n\t\tpublic String toString() {\n\t\t\treturn \"Assign(\" + id + \", \" + r + \")\";\n\t\t}\n\t}\n\n\tstatic class Multi extends AST {\n\t\tArrayList as;\n\n\t\tMulti(ArrayList as) {\n\t\t\tthis.as = as;\n\t\t}\n\n\t\tpublic String toString() {\n\t\t\tString s = \"\";\n\t\t\tfor (AST a : as)\n\t\t\t\ts += s.isEmpty() ? a : \"; \" + a;\n\t\t\treturn \"Multi(\" + s + \")\";\n\t\t}\n\t}\n\n\tstatic class BinOp extends AST {\n\t\tAST l;\n\t\tAST r;\n\t\tString op;\n\n\t\tBinOp(AST l, String op, AST r) {\n\t\t\tthis.l = l;\n\t\t\tthis.op = op;\n\t\t\tthis.r = r;\n\t\t}\n\n\t\tpublic String toString() {\n\t\t\treturn \"BinOp(\" + l + \", \" + op + \", \" + r + \")\";\n\t\t}\n\t}\n\n\tstatic class UnOp extends AST {\n\t\tAST a;\n\t\tString op;\n\n\t\tUnOp(String op, AST a) {\n\t\t\tthis.op = op;\n\t\t\tthis.a = a;\n\t\t}\n\n\t\tpublic String toString() {\n\t\t\treturn \"UnOp(\" + op + \", \" + a + \")\";\n\t\t}\n\t}\n\n\tstatic class Int extends AST {\n\t\tlong v;\n\n\t\tInt(long v) {\n\t\t\tthis.v = v;\n\t\t}\n\n\t\tpublic String toString() {\n\t\t\treturn \"Int(\" + v + \")\";\n\t\t}\n\t}\n\n\tstatic class Id extends AST {\n\t\tString s;\n\n\t\tId(String s) {\n\t\t\tthis.s = s;\n\t\t}\n\n\t\tpublic String toString() {\n\t\t\treturn \"Id(\" + s + \")\";\n\t\t}\n\t}\n\n\tstatic A eval(AST a, Evaluator etor) {\n\t\tif (a instanceof AssignOp)\n\t\t\treturn etor.assign(((AssignOp) a).id, eval(((AssignOp) a).r, etor));\n\t\tif (a instanceof Multi) {\n\t\t\tA last = null;\n\t\t\tfor (AST a2 : ((Multi) a).as)\n\t\t\t\tlast = eval(a2, etor);\n\t\t\treturn last;\n\t\t}\n\t\tif (a instanceof BinOp)\n\t\t\treturn etor.binOp(((BinOp) a).op, eval(((BinOp) a).l, etor), eval(((BinOp) a).r, etor));\n\t\tif (a instanceof UnOp)\n\t\t\treturn etor.unOp(((UnOp) a).op, eval(((UnOp) a).a, etor));\n\t\tif (a instanceof Int)\n\t\t\treturn etor.fromInt(((Int) a).v);\n\t\tif (a instanceof Id)\n\t\t\treturn etor.id(((Id) a).s);\n\t\tthrow new RuntimeException(\"unexpected ast: \" + a);\n\t}\n}\n\ninterface Evaluator {\n\tA assign(String s, A a);\n\n\tA binOp(String op, A a, A b);\n\n\tA unOp(String op, A a);\n\n\tA fromInt(long a);\n\n\tA id(String s);\n}\n\nclass Seq {\n\tArrayList as;\n\tint ptr;\n\n\tSeq(ArrayList as) {\n\t\tthis.as = as;\n\t\tptr = 0;\n\t}\n\n\tboolean hasNext(int num) {\n\t\treturn ptr + num < as.size();\n\t}\n\n\tboolean hasNext() {\n\t\treturn hasNext(0);\n\t}\n\n\tA next(int num) {\n\t\treturn ptr + num < as.size() ? as.get(ptr + num) : null;\n\t}\n\n\tA next() {\n\t\treturn next(0);\n\t}\n\n\tA read() {\n\t\treturn hasNext() ? as.get(ptr++) : null;\n\t}\n\n\tA read(A a) {\n\t\tif (!hasNext())\n\t\t\tthrow new RuntimeException(\"unexpected EOF\");\n\t\tif (!isNext(a))\n\t\t\tthrow new RuntimeException(\"expected \" + a + \" but got\" + next());\n\t\treturn read();\n\t}\n\n\tA read(F.XX f) {\n\t\tif (!hasNext())\n\t\t\tthrow new RuntimeException(\"unexpected EOF\");\n\t\tif (!f.f(next()))\n\t\t\tthrow new RuntimeException(\"f(\" + next() + \") returned false\");\n\t\treturn read();\n\t}\n\n\tboolean isNext(A a) {\n\t\treturn a.equals(next());\n\t}\n\n\tboolean isNext(@SuppressWarnings(\"unchecked\") A... as) {\n\t\tfor (A a : as)\n\t\t\tif (isNext(a))\n\t\t\t\treturn true;\n\t\treturn false;\n\t}\n\n\tboolean isNext(F.XX f) {\n\t\treturn hasNext() && f.f(next());\n\t}\n\n\tA readIf(F.XX f) {\n\t\tif (isNext(f))\n\t\t\treturn read();\n\t\treturn null;\n\t}\n\n\tA readIf(@SuppressWarnings(\"unchecked\") A... as) {\n\t\tfor (A a : as)\n\t\t\tif (isNext(a)) {\n\t\t\t\tptr++;\n\t\t\t\treturn a;\n\t\t\t}\n\t\treturn null;\n\t}\n\n\tpublic String toString() {\n\t\treturn as.toString();\n\t}\n}\n\nclass Token extends P {\n\tprivate static final int ID = 1;\n\tprivate static final int SYM = 2;\n\tprivate static final int INT = 3;\n\n\tToken(String s, int type) {\n\t\tsuper(s, type);\n\t}\n\n\tboolean is(String s) {\n\t\treturn a.equals(s);\n\t}\n\n\tstatic Token ofId(String s) {\n\t\treturn new Token(s, ID);\n\t}\n\n\tstatic Token ofSym(String s) {\n\t\treturn new Token(s, SYM);\n\t}\n\n\tstatic Token ofInt(String s) {\n\t\treturn new Token(s, INT);\n\t}\n\n\tboolean isId() {\n\t\treturn b == ID;\n\t}\n\n\tboolean isSym() {\n\t\treturn b == SYM;\n\t}\n\n\tboolean isInt() {\n\t\treturn b == INT;\n\t}\n}\n\nclass SimpleLang {\n\tprivate static class Tokenizer {\n\t\tprivate static final String SYMS = \"+-*/%^!()=;\";\n\n\t\tSeq sc;\n\t\tArrayList ts;\n\n\t\tTokenizer(String s) {\n\t\t\tsc = new Seq(U.make(s.length(), i -> s.charAt(i)));\n\t\t}\n\n\t\tSeq parse() {\n\t\t\tts = new ArrayList();\n\t\t\tparseAll();\n\t\t\treturn new Seq(ts);\n\t\t}\n\n\t\tprivate static boolean isSpace(char c) {\n\t\t\treturn c == ' ' || c == '\\t' || c == '\\r' || c == '\\n';\n\t\t}\n\n\t\tprivate static boolean isDigit(char c) {\n\t\t\treturn c >= '0' && c <= '9';\n\t\t}\n\n\t\tprivate static boolean isSymbol(char c) {\n\t\t\treturn SYMS.indexOf(c) != -1;\n\t\t}\n\n\t\tprivate static boolean isAlpha(char c) {\n\t\t\treturn c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_';\n\t\t}\n\n\t\tprivate void parseAll() {\n\t\t\twhile (sc.hasNext()) {\n\t\t\t\twhile (sc.isNext(Tokenizer::isSpace))\n\t\t\t\t\tsc.read();\n\t\t\t\tif (!sc.hasNext())\n\t\t\t\t\tbreak;\n\t\t\t\tif (sc.isNext(Tokenizer::isAlpha)) {\n\t\t\t\t\tparseId();\n\t\t\t\t} else if (sc.isNext(Tokenizer::isDigit)) {\n\t\t\t\t\tparseInt();\n\t\t\t\t} else if (sc.isNext(Tokenizer::isSymbol)) {\n\t\t\t\t\tparseSym();\n\t\t\t\t} else {\n\t\t\t\t\tthrow new RuntimeException(\"invalid character: \" + sc.next());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tprivate void parseId() {\n\t\t\tString s = sc.read().toString();\n\t\t\twhile (sc.isNext(Tokenizer::isAlpha) || sc.isNext(Tokenizer::isDigit))\n\t\t\t\ts += sc.read().toString();\n\t\t\tts.add(Token.ofId(s));\n\t\t}\n\n\t\tprivate void parseInt() {\n\t\t\tString s = sc.read().toString();\n\t\t\twhile (sc.isNext(Tokenizer::isDigit))\n\t\t\t\ts += sc.read().toString();\n\t\t\tts.add(Token.ofInt(s));\n\t\t}\n\n\t\tprivate void parseSym() {\n\t\t\tString s = sc.read().toString();\n\t\t\tts.add(Token.ofSym(s));\n\t\t}\n\t}\n\n\tprivate static class Parser {\n\t\tSeq ts;\n\n\t\tParser(Seq ts) {\n\t\t\tthis.ts = ts;\n\t\t}\n\n\t\tAST parse() {\n\t\t\treturn parseExpr();\n\t\t}\n\n\t\tprivate AST parseExpr() {\n\t\t\treturn parseMultiExpr();\n\t\t}\n\n\t\tprivate AST parseMultiExpr() {\n\t\t\treadSemicolons();\n\t\t\tAST a = parseAssignExpr();\n\t\t\tif (readSemicolons()) {\n\t\t\t\tArrayList as = new ArrayList();\n\t\t\t\tas.add(a);\n\t\t\t\tdo {\n\t\t\t\t\tif (!ts.hasNext())\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tas.add(parseAssignExpr());\n\t\t\t\t} while (readSemicolons());\n\t\t\t\tif (as.size() == 1)\n\t\t\t\t\treturn a;\n\t\t\t\treturn new AST.Multi(as);\n\t\t\t}\n\t\t\treturn a;\n\t\t}\n\n\t\tprivate boolean readSemicolons() {\n\t\t\tif (!ts.isNext(t -> t.is(\";\")))\n\t\t\t\treturn false;\n\t\t\tdo {\n\t\t\t\tts.read();\n\t\t\t} while (ts.isNext(t -> t.is(\";\")));\n\t\t\treturn true;\n\t\t}\n\n\t\tprivate AST parseAssignExpr() {\n\t\t\tAST a = parseAddSubOp();\n\t\t\tif (ts.isNext(t -> t.is(\"=\"))) {\n\t\t\t\tts.read();\n\t\t\t\tif (!(a instanceof AST.Id))\n\t\t\t\t\tthrow new RuntimeException(\"cannot assign to \" + a);\n\t\t\t\treturn new AST.AssignOp(((AST.Id) a).s, parseAssignExpr());\n\t\t\t}\n\t\t\treturn a;\n\t\t}\n\n\t\tprivate AST parseAddSubOp() {\n\t\t\tAST a = parseMulDivModOp();\n\t\t\twhile (ts.isNext(t -> t.is(\"+\") || t.is(\"-\")))\n\t\t\t\ta = new AST.BinOp(a, ts.read().a, parseMulDivModOp());\n\t\t\treturn a;\n\t\t}\n\n\t\tprivate AST parseMulDivModOp() {\n\t\t\tAST a = parsePowOp();\n\t\t\twhile (ts.isNext(t -> t.is(\"*\") || t.is(\"/\") || t.is(\"%\")))\n\t\t\t\ta = new AST.BinOp(a, ts.read().a, parsePowOp());\n\t\t\treturn a;\n\t\t}\n\n\t\tprivate AST parsePowOp() {\n\t\t\tAST a = parseNegateOp();\n\t\t\tif (ts.isNext(t -> t.is(\"^\")))\n\t\t\t\treturn new AST.BinOp(a, ts.read().a, parsePowOp());\n\t\t\treturn a;\n\t\t}\n\n\t\tprivate AST parseNegateOp() {\n\t\t\tif (ts.isNext(t -> t.is(\"-\")))\n\t\t\t\treturn new AST.UnOp(ts.read().a, parseNegateOp());\n\t\t\treturn parseFactOp();\n\t\t}\n\n\t\tprivate AST parseFactOp() {\n\t\t\tAST a = parsePrimary();\n\t\t\twhile (ts.isNext(t -> t.is(\"!\")))\n\t\t\t\ta = new AST.UnOp(ts.read().a, a);\n\t\t\treturn a;\n\t\t}\n\n\t\tprivate AST parsePrimary() {\n\t\t\tif (ts.isNext(t -> t.isId()))\n\t\t\t\treturn new AST.Id(ts.read().a);\n\t\t\tif (ts.isNext(t -> t.isInt()))\n\t\t\t\treturn new AST.Int(Long.parseLong(ts.read().a));\n\t\t\tif (ts.readIf(t -> t.is(\"(\")) != null) {\n\t\t\t\tAST e = parseExpr();\n\t\t\t\tts.read(t -> t.is(\")\"));\n\t\t\t\treturn e;\n\t\t\t}\n\t\t\tthrow new RuntimeException(\"unexpected token: \" + ts.next());\n\t\t}\n\t}\n\n\tstatic HashMap cache = new HashMap();\n\n\tstatic Evaluator makeEvaluator(F.XXX assign, F.XXX add, F.XXX sub,\n\t\t\tF.XXX mul, F.XXX div, F.XXX mod, F.XXX pow, F.XX neg,\n\t\t\tF.XX fact, F.LX fromInt, F.XX id) {\n\t\treturn new Evaluator() {\n\t\t\tpublic A assign(String s, A a) {\n\t\t\t\treturn assign.f(s, a);\n\t\t\t}\n\n\t\t\tpublic A binOp(String op, A a, A b) {\n\t\t\t\tswitch (op) {\n\t\t\t\tcase \"+\":\n\t\t\t\t\treturn add.f(a, b);\n\t\t\t\tcase \"-\":\n\t\t\t\t\treturn sub.f(a, b);\n\t\t\t\tcase \"*\":\n\t\t\t\t\treturn mul.f(a, b);\n\t\t\t\tcase \"/\":\n\t\t\t\t\treturn div.f(a, b);\n\t\t\t\tcase \"%\":\n\t\t\t\t\treturn mod.f(a, b);\n\t\t\t\tcase \"^\":\n\t\t\t\t\treturn pow.f(a, b);\n\t\t\t\t}\n\t\t\t\tthrow new RuntimeException(\"invalid binOp: \" + op);\n\t\t\t}\n\n\t\t\tpublic A unOp(String op, A a) {\n\t\t\t\tswitch (op) {\n\t\t\t\tcase \"-\":\n\t\t\t\t\treturn neg.f(a);\n\t\t\t\tcase \"!\":\n\t\t\t\t\treturn fact.f(a);\n\t\t\t\t}\n\t\t\t\tthrow new RuntimeException(\"invalid unOp: \" + op);\n\t\t\t}\n\n\t\t\tpublic A fromInt(long a) {\n\t\t\t\treturn fromInt.f(a);\n\t\t\t}\n\n\t\t\tpublic A id(String s) {\n\t\t\t\treturn id.f(s);\n\t\t\t}\n\t\t};\n\t}\n\n\tstatic AST parse(String s) {\n\t\tif (cache.containsKey(cache)) {\n\t\t\treturn cache.get(s);\n\t\t}\n\t\tTokenizer l = new Tokenizer(s);\n\t\tSeq ts = l.parse();\n\t\tParser p = new Parser(ts);\n\t\tAST a = p.parse();\n\t\tcache.put(s, a);\n\t\treturn a;\n\t}\n}\n\nclass Mod {\n\tfinal long mod;\n\tfinal AbelianGroup add;\n\tfinal AbelianGroup mul;\n\tfinal Field field;\n\tfinal VM vm;\n\tprivate final boolean prime;\n\tprivate final HashMap logMap;\n\tprivate long[] facts;\n\tprivate long[] invs;\n\tprivate long[] invFacts;\n\tprivate long[] factors;\n\n\tMod(long mod) {\n\t\tthis.mod = mod;\n\t\tprepareFacts(0);\n\t\tprime = BigInteger.valueOf(mod).isProbablePrime(100);\n\t\tadd = AbelianGroup.make((a, b) -> (a + b) % mod, a -> mod - a, 0l);\n\t\tmul = AbelianGroup.make((a, b) -> (a * b) % mod, a -> {\n\t\t\tif (prime)\n\t\t\t\treturn pow(a, mod - 2);\n\t\t\tTL t = Alg.extgcd(a, mod);\n\t\t\tif (t.c != 1)\n\t\t\t\tthrow new ArithmeticException(\"inv(\" + a + \") does not exist\");\n\t\t\treturn (t.a % mod + mod) % mod;\n\t\t}, 1l);\n\t\tfield = Field.make(add, mul);\n\t\tlogMap = new HashMap();\n\t\tvm = new VM(field, this::pow, this::fact, a -> (a % mod + mod) % mod, a -> (a % mod + mod) % mod);\n\t}\n\n\tlong fact(long a) {\n\t\tif (a >= Integer.MAX_VALUE)\n\t\t\tthrow new RuntimeException(\"fact(\" + a + \") too big\");\n\t\tprepareFacts((int) a);\n\t\treturn facts[(int) (a % mod)];\n\t}\n\n\tlong invFact(int a) {\n\t\tprepareFacts(a);\n\t\treturn invFacts[(int) (a % mod)];\n\t}\n\n\tlong inv(long a) {\n\t\treturn mul.inv(a);\n\t}\n\n\tlong pow(long a, long b) {\n\t\tif (b == 0)\n\t\t\treturn 1;\n\t\tif (b == 1)\n\t\t\treturn a;\n\t\tif (b < 0) {\n\t\t\ta = inv(a);\n\t\t\tb = -b;\n\t\t}\n\t\ta %= mod;\n\t\tlong res = 1;\n\t\twhile (b > 0) {\n\t\t\tif ((b & 1) != 0)\n\t\t\t\tres = res * a % mod;\n\t\t\ta = a * a % mod;\n\t\t\tb >>= 1;\n\t\t}\n\t\treturn res;\n\t}\n\n\tlong order(long a) { // computes the order of `a` in O(sqrt(mod)) time\n\t\ta %= mod;\n\t\tif (a == 0)\n\t\t\treturn 0;\n\t\tif (a == 1)\n\t\t\treturn 1;\n\t\tif (factors == null) {\n\t\t\tArrayList fs = new ArrayList();\n\t\t\tfor (long i = 2; i * i < mod; i++) {\n\t\t\t\tif ((mod - 1) % i == 0)\n\t\t\t\t\tfs.add(i);\n\t\t\t}\n\t\t\tfactors = new long[fs.size()];\n\t\t\tfor (int i = 0; i < fs.size(); i++) {\n\t\t\t\tfactors[i] = fs.get(i);\n\t\t\t}\n\t\t}\n\t\tfor (long f : factors) {\n\t\t\tif (pow(a, f) == 1)\n\t\t\t\treturn f;\n\t\t}\n\t\treturn mod - 1;\n\t}\n\n\tPL log(long a, long b) { // log_b(a) in O(sqrt(mod)) time\n\t\ta %= mod;\n\t\tb %= mod;\n\t\tif (b == 1 || b == 0)\n\t\t\treturn a == b ? PL.make(1, 1) : PL.make(-1, 0);\n\t\tif (a == 0)\n\t\t\treturn PL.make(-1, 0);\n\t\tlong order = order(b);\n\t\tif (a == 1)\n\t\t\treturn PL.make(0, order);\n\t\tlong orderSqrtL = sqrtCeil(order);\n\t\tif (orderSqrtL > Integer.MAX_VALUE)\n\t\t\tthrow new RuntimeException(\"order(\" + b + \") too big: \" + order);\n\t\tint orderSqrt = (int) sqrtCeil(order);\n\t\tlogMap.clear();\n\t\tlogMap.put(1l, 0);\n\t\tlong p = 1;\n\t\tfor (int i = 1; i < orderSqrt; i++) {\n\t\t\tp = p * b % mod;\n\t\t\tlogMap.put(p, i);\n\t\t}\n\t\tlong ib = pow(b, mod - orderSqrt - 1);\n\t\tp = a;\n\t\tfor (int i = 1; i < orderSqrt; i++) {\n\t\t\tp = p * ib % mod;\n\t\t\tif (logMap.containsKey(p))\n\t\t\t\treturn PL.make((i * orderSqrt + logMap.get(p)) % order, order);\n\t\t}\n\t\treturn PL.make(-1, 0);\n\t}\n\n\tprivate long sqrtCeil(long a) {\n\t\treturn U.searchL((long) Math.sqrt(a * 0.9), (long) Math.sqrt(a * 1.1) + 1, mid -> mid * mid >= a);\n\t}\n\n\tprivate void prepareFacts(int n) {\n\t\tif (facts == null) {\n\t\t\tfacts = new long[1024];\n\t\t\tinvs = new long[1024];\n\t\t\tinvFacts = new long[1024];\n\t\t\tprepareFactsIn(0, 1024);\n\t\t}\n\t\tif (n >= mod)\n\t\t\tn = (int) (mod - 1);\n\t\twhile (facts.length <= n) {\n\t\t\tint prevL = facts.length;\n\t\t\tint newL = prevL << 1;\n\t\t\tfacts = Arrays.copyOf(facts, newL);\n\t\t\tinvs = Arrays.copyOf(invs, newL);\n\t\t\tinvFacts = Arrays.copyOf(invFacts, newL);\n\t\t\tprepareFactsIn(prevL, newL);\n\t\t}\n\t}\n\n\tprivate void prepareFactsIn(int from, int until) {\n\t\tif (until > mod)\n\t\t\tuntil = (int) mod;\n\t\tfor (int i = from; i < until; i++) {\n\t\t\tif (i == 0) {\n\t\t\t\tfacts[0] = 1;\n\t\t\t\tinvs[0] = 0;\n\t\t\t\tinvFacts[0] = 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (i == 1) {\n\t\t\t\tfacts[1] = 1;\n\t\t\t\tinvs[1] = 1;\n\t\t\t\tinvFacts[1] = 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfacts[i] = facts[i - 1] * i % mod;\n\t\t\tinvs[i] = (mod - mod / i) * invs[(int) (mod % i)] % mod;\n\t\t\tinvFacts[i] = invFacts[i - 1] * invs[i] % mod;\n\t\t}\n\t}\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is a string S representing the day of the week today.\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.\n\nAfter how many days is the next Sunday (tomorrow or later)?\n\nConstraints\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of days before the next Sunday.\n\nSample Input 1\n\nSAT\n\nSample Output 1\n\n1\n\nIt is Saturday today, and tomorrow will be Sunday.\n\nSample Input 2\n\nSUN\n\nSample Output 2\n\n7\n\nIt is Sunday today, and seven days later, it will be Sunday again.", "sample_input": "SAT\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02847", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is a string S representing the day of the week today.\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.\n\nAfter how many days is the next Sunday (tomorrow or later)?\n\nConstraints\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of days before the next Sunday.\n\nSample Input 1\n\nSAT\n\nSample Output 1\n\n1\n\nIt is Saturday today, and tomorrow will be Sunday.\n\nSample Input 2\n\nSUN\n\nSample Output 2\n\n7\n\nIt is Sunday today, and seven days later, it will be Sunday again.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 86801, "cpu_time_ms": 73, "memory_kb": 23124}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s685987140", "group_id": "codeNet:p02850", "input_text": "import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Main main = new Main();\n main.solve();\n }\n public void solve() {\n Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));\n int N = scan.nextInt();\n Node[] nodes = new Node[N+1];\n Edge[] edges = new Edge[N-1];\n for (int i = 1; i <= N; i++) {\n nodes[i] = new Node(i);\n }\n for (int i = 0; i < N-1; i++){\n Edge edge = new Edge(i, scan.nextInt(), scan.nextInt());\n edges[i] = edge;\n nodes[edge.from].addEdge(edge);\n nodes[edge.to].addEdge(edge);\n }\n Node top = null;\n int max = 0;\n for (int i = 1; i <= N; i++) {\n Node node = nodes[i];\n int d = node.degree();\n if (max < d) {\n top = node;\n max = d;\n }\n }\n int K = top.degree();\n PriorityQueue deque = new PriorityQueue<>(new NodeComparator());\n deque.add(top);\n while(!deque.isEmpty()) {\n Node node = deque.poll();\n node.color(K);\n node.visited = true;\n for (int id : node.edges.keySet()) {\n Edge edge = node.edges.get(id);\n if (edge.from != node.no) {\n Node next = nodes[edge.from];\n if (!next.visited) {\n deque.add(next);\n }\n }\n if (edge.to != node.no) {\n Node next = nodes[edge.to];\n if (!next.visited) {\n deque.add(next);\n }\n }\n }\n }\n System.out.println(K);\n for (int i = 0; i < N-1; i++) {\n System.out.println(edges[i].color);\n }\n }\n class NodeComparator implements Comparator {\n @Override\n public int compare(Node o1, Node o2) {\n int d1 = o1.degree();\n int d2 = o2.degree();\n if (d1 != d2) {\n return -Integer.compare(d1, d2);\n }\n return Integer.compare(o1.no, o2.no);\n }\n }\n class Node {\n int no;\n boolean visited = false;\n HashMap edges = new HashMap<>();\n Node(int no) {\n this.no = no;\n }\n void addEdge(Edge edge) {\n edges.put(edge.id, edge);\n }\n int degree() {\n return edges.size();\n }\n void color(int K) {\n boolean[] colors = new boolean[K+1];\n List possible = new ArrayList();\n for (Edge edge : edges.values()) {\n if (0 < edge.color) {\n colors[edge.color] = true;\n }\n }\n for (int i = 1; i <= K; i++) {\n if (colors[i]) {\n continue;\n }\n possible.add(i);\n }\n for (Edge edge : edges.values()) {\n if (0 < edge.color) {\n continue;\n }\n edge.color = possible.remove(0);\n }\n }\n }\n class Edge {\n int id;\n int from;\n int to;\n int color;\n Edge(int id, int from, int to) {\n this.id = id;\n this.from = from;\n this.to = to;\n this.color = -1;\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1574652856, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02850.html", "problem_id": "p02850", "resource_group": "high_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/Java/s685987140.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s685987140", "user_id": "u451080461"}, "prompt_components": {"gold_output": "2\n1\n2\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Main main = new Main();\n main.solve();\n }\n public void solve() {\n Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));\n int N = scan.nextInt();\n Node[] nodes = new Node[N+1];\n Edge[] edges = new Edge[N-1];\n for (int i = 1; i <= N; i++) {\n nodes[i] = new Node(i);\n }\n for (int i = 0; i < N-1; i++){\n Edge edge = new Edge(i, scan.nextInt(), scan.nextInt());\n edges[i] = edge;\n nodes[edge.from].addEdge(edge);\n nodes[edge.to].addEdge(edge);\n }\n Node top = null;\n int max = 0;\n for (int i = 1; i <= N; i++) {\n Node node = nodes[i];\n int d = node.degree();\n if (max < d) {\n top = node;\n max = d;\n }\n }\n int K = top.degree();\n PriorityQueue deque = new PriorityQueue<>(new NodeComparator());\n deque.add(top);\n while(!deque.isEmpty()) {\n Node node = deque.poll();\n node.color(K);\n node.visited = true;\n for (int id : node.edges.keySet()) {\n Edge edge = node.edges.get(id);\n if (edge.from != node.no) {\n Node next = nodes[edge.from];\n if (!next.visited) {\n deque.add(next);\n }\n }\n if (edge.to != node.no) {\n Node next = nodes[edge.to];\n if (!next.visited) {\n deque.add(next);\n }\n }\n }\n }\n System.out.println(K);\n for (int i = 0; i < N-1; i++) {\n System.out.println(edges[i].color);\n }\n }\n class NodeComparator implements Comparator {\n @Override\n public int compare(Node o1, Node o2) {\n int d1 = o1.degree();\n int d2 = o2.degree();\n if (d1 != d2) {\n return -Integer.compare(d1, d2);\n }\n return Integer.compare(o1.no, o2.no);\n }\n }\n class Node {\n int no;\n boolean visited = false;\n HashMap edges = new HashMap<>();\n Node(int no) {\n this.no = no;\n }\n void addEdge(Edge edge) {\n edges.put(edge.id, edge);\n }\n int degree() {\n return edges.size();\n }\n void color(int K) {\n boolean[] colors = new boolean[K+1];\n List possible = new ArrayList();\n for (Edge edge : edges.values()) {\n if (0 < edge.color) {\n colors[edge.color] = true;\n }\n }\n for (int i = 1; i <= K; i++) {\n if (colors[i]) {\n continue;\n }\n possible.add(i);\n }\n for (Edge edge : edges.values()) {\n if (0 < edge.color) {\n continue;\n }\n edge.color = possible.remove(0);\n }\n }\n }\n class Edge {\n int id;\n int from;\n int to;\n int color;\n Edge(int id, int from, int to) {\n this.id = id;\n this.from = from;\n this.to = to;\n this.color = -1;\n }\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": 3577, "cpu_time_ms": 2110, "memory_kb": 354340}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s535520409", "group_id": "codeNet:p02852", "input_text": "import java.util.Scanner;\n\npublic class Main \n{\n\n\tpublic static void main(String[] args) \n\t{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt()+1;\n\t\tint m = sc.nextInt(); //largest step\n\t\t\n\t\tOAVL con = new OAVL();\n\t\t\n\t\tString s = sc.next();\n\t\t\n\t\tboolean[] hole = new boolean[n];\n\t\tfor(int i = 0; i < n; i++)\n\t\t{\n\t\t\tif(s.charAt(i) == '1')hole[i] = true;\n\t\t}\n\t\t\n\t\tint[] dp = new int[n];\n\t\tint[] step = new int[n];\n\t\t\n\t\tint[] minid = new int[n]; //smallest id for each step-to-fin\n\t\t\n\t\tfor(int i = n-2; i >= 0; i--)\n\t\t{\n\t\t\t//remove i+m+1 from consideration\n\t\t\tif(i+m+1 < n-1 && !hole[i+m+1])\n\t\t\t{\n\t\t\t\tcon.remove(dp[i+m+1]);\n\t\t\t}\n\t\t\tif(hole[i])continue;\n\t\t\t\n\t\t\t//n-1 is already finish!\n\t\t\t//1 step from fin?\n\t\t\tif(i+m >= n-1)\n\t\t\t{\n\t\t\t\tdp[i] = 1;\n\t\t\t\tstep[i] = n-1;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t//step into one of the considered places\n\t\t\t\tif(con.getSmallest(con.root) == null || con.getSmallest(con.root).value >= 999999999)\n\t\t\t\t{ //no way from here!!\n\t\t\t\t\tdp[i] = 999999999;\n\t\t\t\t\tstep[i] = n-1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tint cur = (int)con.getSmallest(con.root).value;\n\t\t\t\t\tdp[i] = cur+1;\n\t\t\t\t\tstep[i] = minid[cur];\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n//\t\t\tSystem.out.println(i + \": \" + dp[i] + \", step \" + step[i]);\n\t\t\t//add to consideration\n\t\t\tcon.add(dp[i]);\n\t\t\t\n\t\t\tif(dp[i] < 999999999)\n\t\t\t\tminid[dp[i]] = i;\n\t\t}\n//\t\tSystem.out.println(dp[0] + \" steps\");\n\t\tint steps = dp[0];\n\t\t\n\t\tif(steps >= 999999999)\n\t\t{\n\t\t\tSystem.out.println(-1);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tint pos = 0;\n\t\t\n\t\tStringBuilder sb = new StringBuilder();\n\t\tfor(int i = 0; i < steps; i++)\n\t\t{\n\t\t\tif(i>0)sb.append(' ');\n\t\t\tsb.append((step[pos]-pos));\n\t\t\tpos = step[pos];\n\t\t}\n\t\tSystem.out.println(sb);\n\t}\n\t\n\t\n\tstatic class OAVL\n\t{ //Occurrence AVL Tree!\n\t\tNode root = null;\n\t\tint nodes = 0;\n\t\t\n\t\t//I think this was O(log n)\n\t\tint getNumberOfEqualOrGreater(long val)\n\t\t{\n\t\t\treturn getNumberOfEqualOrGreater(val, root);\n\t\t}\n\t\t\n\t\tprivate int getNumberOfEqualOrGreater(long val, Node pos)\n\t\t{\n\t\t\tif(pos==null)return 0;\n\t\t\tif(val == pos.value)\n\t\t\t{\n\t\t\t\tif(pos.r != null)return pos.r.subsize+1;\n\t\t\t\telse return 1;\n\t\t\t}\n\t\t\telse if(val < pos.value)\n\t\t\t{\n\t\t\t\tint fromR = 0;\n\t\t\t\tif(pos.r != null)fromR = pos.r.subsize;\n\t\t\t\treturn getNumberOfEqualOrGreater(val, pos.l) + fromR + 1;\n\t\t\t}\n\t\t\telse if(val > pos.value)\n\t\t\t{\n\t\t\t\treturn getNumberOfEqualOrGreater(val, pos.r);\n\t\t\t}\n\t\t\t\n\t\t\treturn 0;\n\t\t}\n\t\t\n\t\t//I think this was O(log n)\n\t\tint getNumberOfEqualOrLesser(long val)\n\t\t{\n\t\t\treturn getNumberOfEqualOrLesser(val, root);\n\t\t}\n\t\t\n\t\tprivate int getNumberOfEqualOrLesser(long val, Node pos)\n\t\t{\n\t\t\tif(pos==null)return 0;\n\t\t\tif(val == pos.value)\n\t\t\t{\n\t\t\t\tif(pos.l != null)return pos.l.subsize+1;\n\t\t\t\telse return 1;\n\t\t\t}\n\t\t\telse if(val > pos.value)\n\t\t\t{\n\t\t\t\tint fromL = 0;\n\t\t\t\tif(pos.l != null)fromL = pos.l.subsize;\n\t\t\t\treturn getNumberOfEqualOrLesser(val, pos.r) + fromL + 1;\n\t\t\t}\n\t\t\telse if(val < pos.value)\n\t\t\t{\n\t\t\t\treturn getNumberOfEqualOrLesser(val, pos.l);\n\t\t\t}\n\t\t\t\n\t\t\treturn 0;\n\t\t}\n\t\t\n\t\tvoid add(long i)\n\t\t{\n\t\t\troot = insert(root, i);\n\t\t}\n\t\t\n\t\tprivate Node insert(Node pos, long i)\n\t\t{\n\t\t\tif(pos == null)\n\t\t\t{ //place here\n\t\t\t\tnodes++;\n\t\t\t\treturn new Node(i);\n\t\t\t}\n\t\t\tif(pos.value == i)\n\t\t\t{\n\t\t\t\tpos.number++;\n\t\t\t\treturn pos; //already here!\n\t\t\t}\n\t\t\t\n\t\t\tif(i < pos.value)\n\t\t\t{ //go left\n\t\t\t\tpos.l = insert(pos.l, i);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tpos.r = insert(pos.r, i);\n\t\t\t}\n\t\t\t\n\t\t\tpos.update();\n\t\t\treturn balance(pos);\n\t\t}\n\t\t\n\t\tlong getSmallestThatIsBiggerThan(long val)\n\t\t{\n\t\t\treturn getSmallestThatIsBiggerThan(root, val);\n\t\t}\n\t\t\n\t\tprivate long getSmallestThatIsBiggerThan(Node pos, long val)\n\t\t{\n//\t\t\tif(pos == null)System.out.println(\"Pos null\");\n//\t\t\tSystem.out.println(\"Searching at \" + pos.value);\n\t\t\tif(pos.value <= val)\n\t\t\t{ //need bigger\n\t\t\t\tif(pos.r != null)\n\t\t\t\t\treturn getSmallestThatIsBiggerThan(pos.r, val);\n\t\t\t\telse \n\t\t\t\t{\n\t\t\t\t\treturn 999999999;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{ //this or smaller\n\t\t\t\tif(pos.l != null)\n\t\t\t\t{\n\t\t\t\t\treturn Math.min(pos.value, getSmallestThatIsBiggerThan(pos.l, val));\n\t\t\t\t}\n\t\t\t\telse return pos.value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tlong getBiggestThatIsSmallerThan(long val)\n\t\t{\n\t\t\treturn getBiggestThatIsSmallerThan(root, val);\n\t\t}\n\t\t\n\t\tprivate long getBiggestThatIsSmallerThan(Node pos, long val)\n\t\t{\n\t\t\tif(pos.value >= val)\n\t\t\t{ //need smaller\n\t\t\t\tif(pos.l != null)\n\t\t\t\t\treturn getBiggestThatIsSmallerThan(pos.l, val);\n\t\t\t\telse \n\t\t\t\t{\n\t\t\t\t\treturn -999999999;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{ //this or bigger\n\t\t\t\tif(pos.r != null)\n\t\t\t\t{\n\t\t\t\t\treturn Math.max(pos.value, getBiggestThatIsSmallerThan(pos.r, val));\n\t\t\t\t}\n\t\t\t\telse return pos.value;\n\t\t\t}\n\t\t}\t\t\n\t\tNode getSmallest(Node pos)\n\t\t{\n\t\t\tif(pos == null)return pos;\n\t\t\tif(pos.l == null)\n\t\t\t\treturn pos;\n\t\t\telse return getSmallest(pos.l);\n\t\t}\n\t\t\n\t\tNode getLargest(Node pos)\n\t\t{\n\t\t\tif(pos.r == null)\n\t\t\t\treturn pos;\n\t\t\telse return getLargest(pos.r);\n\t\t}\n\t\t\n\t\tvoid remove(long i)\n\t\t{\n\t\t\troot = delete(root, i);\n\t\t}\n\t\t\n\t\tprivate Node delete(Node pos, long i)\n\t\t{\n\t\t\tif(pos == null)\n\t\t\t{ //already non-existent\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tif(pos.value == i)\n\t\t\t{\n\t\t\t\t//delete this\n\t\t\t\tif(pos.number > 1) //when there's only 1 left, delete.\n\t\t\t\t{\n\t\t\t\t\tpos.number--;\n\t\t\t\t\treturn pos;\n\t\t\t\t}\n\t\t\t\t//MARK\n\t\t\t\t\n\t\t\t\t\n\t\t\t\tif(pos.l != null && pos.r != null)\n\t\t\t\t{\n\t\t\t\t\t//you can do either but let's remove from the subtree with bigger height.\n\t\t\t\t\tif(pos.l.height >= pos.r.height)\n\t\t\t\t\t{\n\t\t\t\t\t\tNode dum = getLargest(pos.l); //return largest of left subtree\n\t\t\t\t\t\tpos.value = dum.value; //copy its value\n\t\t\t\t\t\tpos.l = delete(pos.l, dum.value); //then remove that, while updating all nodes necessary\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tNode dum = getSmallest(pos.r); //return smallest of right subtree\n\t\t\t\t\t\tpos.value = dum.value; //copy its value\n\t\t\t\t\t\tpos.r = delete(pos.r, dum.value); //then remove that, while updating all nodes necessary\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if(pos.l != null)\n\t\t\t\t{\n\t\t\t\t\tpos = pos.l;\n\t\t\t\t}\n\t\t\t\telse if(pos.r != null)pos = pos.r;\n\t\t\t\telse //both are null\n\t\t\t\t{\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\telse if(i < pos.value)\n\t\t\t{ //go left\n\t\t\t\tpos.l = delete(pos.l, i);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tpos.r = delete(pos.r, i);\n\t\t\t}\n\t\t\t\n\t\t\tpos.update();\n\t\t\treturn balance(pos);\n\t\t}\n\t\t\n\t\tNode leftRotate(Node node)\n\t\t{\n\t\t\tNode b = node.r;\n\t\t\tnode.subsize -= b.subsize;\n\t\t\tnode.r = b.l;\n\t\t\tif(b.l!=null)node.subsize += b.l.subsize;\n\t\t\t\n\t\t\tif(b.l!=null)b.subsize -= b.l.subsize;\n\t\t\tb.l = node;\n\t\t\tb.subsize += node.subsize;\n\t\t\t\n\t\t\tnode.update();\n\t\t\tb.update();\n\t\t\treturn b;\n\t\t}\n\t\t\n\t\tNode rightRotate(Node node)\n\t\t{\n\t\t\tNode b = node.l;\n\t\t\tnode.subsize -= b.subsize;\n\t\t\tnode.l = b.r;\n\t\t\tif(b.r!=null)node.subsize += b.r.subsize;\n\t\t\t\n\t\t\tif(b.r!=null)b.subsize -= b.r.subsize;\n\t\t\tb.r = node;\n\t\t\tb.subsize += node.subsize;\n\t\t\t\n\t\t\tnode.update();\n\t\t\tb.update();\n\t\t\treturn b;\n\t\t}\n\t\t\n\t\tNode llCase(Node node)\n\t\t{\n\t\t\treturn rightRotate(node);\n\t\t}\n\t\t\n\t\tNode lrCase(Node node)\n\t\t{\n\t\t\tnode.l = leftRotate(node.l);\n\t\t\treturn rightRotate(node);\n\t\t}\n\t\t\n\t\tNode rrCase(Node node)\n\t\t{\n\t\t\treturn leftRotate(node);\n\t\t}\n\t\t\n\t\tNode rlCase(Node node)\n\t\t{\n\t\t\tnode.r = rightRotate(node.r);\n\t\t\treturn leftRotate(node);\n\t\t}\n\t\t\n\t\tNode balance(Node node)\n\t\t{\n\t\t\tif(node.balance <= -2)\n\t\t\t{\n\t\t\t\tif(node.l.balance <= 0)\n\t\t\t\t\treturn llCase(node);\n\t\t\t\telse\n\t\t\t\t\treturn lrCase(node);\n\t\t\t}\n\t\t\telse if(node.balance >= 2)\n\t\t\t{\n\t\t\t\tif(node.r.balance >= 0)\n\t\t\t\t\treturn rrCase(node);\n\t\t\t\telse\n\t\t\t\t\treturn rlCase(node);\n\t\t\t}\n\t\t\t\n\t\t\treturn node; //already balanced!\n\t\t}\n\t\t\n\t\tvoid printout(Node pos)\n\t\t{\n\t\t\tif(pos == null)return;\n\t\t\tpos.printout();\n\t\t\tif(pos.l != null)System.out.println(pos.value + \"'s L\");\n\t\t\tprintout(pos.l);\n\t\t\tif(pos.r != null)System.out.println(pos.value + \"'s R\");\n\t\t\tprintout(pos.r);\n\t\t}\n\t\t\n\t\tstatic class Node\n\t\t{\n\t\t\tint balance = 0;\n\t\t\tint height = 0;\n\t\t\tlong value;\n\t\t\t\n\t\t\tint number = 1;\n\t\t\t\n\t\t\tint subsize = 1; //size of subtree rooted here, i.e. descendants + 1 (self)\n\t\t\t\n\t\t\tNode l = null;\n\t\t\tNode r = null;\n\t\t\t\n\t\t\tvoid printout()\n\t\t\t{\n\t\t\t\tSystem.out.println(\"Value \" + value + \" height \" + height + \" subsize \" + subsize + \" balance \" + balance);\n\t\t\t}\n\t\t\t\n\t\t\tvoid update()\n\t\t\t{ //leaf has height of 0.\n\t\t\t\tsubsize = 1;\n\t\t\t\tif(l != null)subsize += l.subsize;\n\t\t\t\tif(r != null)subsize += r.subsize;\n\t\t\t\t\n\t\t\t\tint lh = -1;\n\t\t\t\tint rh = -1;\n\t\t\t\tif(l!=null)lh = l.height;\n\t\t\t\tif(r!=null)rh = r.height;\n\t\t\t\theight = 1 + Math.max(lh, rh);\n\t\t\t\t\n\t\t\t\tbalance = rh - lh;\n\t\t\t}\n\t\t\t\n\t\t\tpublic Node(long i)\n\t\t\t{\n\t\t\t\tvalue = i;\n\t\t\t}\n\t\t}\n\t}\n\n\n}\n", "language": "Java", "metadata": {"date": 1588179464, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02852.html", "problem_id": "p02852", "resource_group": "high_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/Java/s535520409.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s535520409", "user_id": "u245815044"}, "prompt_components": {"gold_output": "1 3 2 3\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main \n{\n\n\tpublic static void main(String[] args) \n\t{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt()+1;\n\t\tint m = sc.nextInt(); //largest step\n\t\t\n\t\tOAVL con = new OAVL();\n\t\t\n\t\tString s = sc.next();\n\t\t\n\t\tboolean[] hole = new boolean[n];\n\t\tfor(int i = 0; i < n; i++)\n\t\t{\n\t\t\tif(s.charAt(i) == '1')hole[i] = true;\n\t\t}\n\t\t\n\t\tint[] dp = new int[n];\n\t\tint[] step = new int[n];\n\t\t\n\t\tint[] minid = new int[n]; //smallest id for each step-to-fin\n\t\t\n\t\tfor(int i = n-2; i >= 0; i--)\n\t\t{\n\t\t\t//remove i+m+1 from consideration\n\t\t\tif(i+m+1 < n-1 && !hole[i+m+1])\n\t\t\t{\n\t\t\t\tcon.remove(dp[i+m+1]);\n\t\t\t}\n\t\t\tif(hole[i])continue;\n\t\t\t\n\t\t\t//n-1 is already finish!\n\t\t\t//1 step from fin?\n\t\t\tif(i+m >= n-1)\n\t\t\t{\n\t\t\t\tdp[i] = 1;\n\t\t\t\tstep[i] = n-1;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t//step into one of the considered places\n\t\t\t\tif(con.getSmallest(con.root) == null || con.getSmallest(con.root).value >= 999999999)\n\t\t\t\t{ //no way from here!!\n\t\t\t\t\tdp[i] = 999999999;\n\t\t\t\t\tstep[i] = n-1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tint cur = (int)con.getSmallest(con.root).value;\n\t\t\t\t\tdp[i] = cur+1;\n\t\t\t\t\tstep[i] = minid[cur];\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n//\t\t\tSystem.out.println(i + \": \" + dp[i] + \", step \" + step[i]);\n\t\t\t//add to consideration\n\t\t\tcon.add(dp[i]);\n\t\t\t\n\t\t\tif(dp[i] < 999999999)\n\t\t\t\tminid[dp[i]] = i;\n\t\t}\n//\t\tSystem.out.println(dp[0] + \" steps\");\n\t\tint steps = dp[0];\n\t\t\n\t\tif(steps >= 999999999)\n\t\t{\n\t\t\tSystem.out.println(-1);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tint pos = 0;\n\t\t\n\t\tStringBuilder sb = new StringBuilder();\n\t\tfor(int i = 0; i < steps; i++)\n\t\t{\n\t\t\tif(i>0)sb.append(' ');\n\t\t\tsb.append((step[pos]-pos));\n\t\t\tpos = step[pos];\n\t\t}\n\t\tSystem.out.println(sb);\n\t}\n\t\n\t\n\tstatic class OAVL\n\t{ //Occurrence AVL Tree!\n\t\tNode root = null;\n\t\tint nodes = 0;\n\t\t\n\t\t//I think this was O(log n)\n\t\tint getNumberOfEqualOrGreater(long val)\n\t\t{\n\t\t\treturn getNumberOfEqualOrGreater(val, root);\n\t\t}\n\t\t\n\t\tprivate int getNumberOfEqualOrGreater(long val, Node pos)\n\t\t{\n\t\t\tif(pos==null)return 0;\n\t\t\tif(val == pos.value)\n\t\t\t{\n\t\t\t\tif(pos.r != null)return pos.r.subsize+1;\n\t\t\t\telse return 1;\n\t\t\t}\n\t\t\telse if(val < pos.value)\n\t\t\t{\n\t\t\t\tint fromR = 0;\n\t\t\t\tif(pos.r != null)fromR = pos.r.subsize;\n\t\t\t\treturn getNumberOfEqualOrGreater(val, pos.l) + fromR + 1;\n\t\t\t}\n\t\t\telse if(val > pos.value)\n\t\t\t{\n\t\t\t\treturn getNumberOfEqualOrGreater(val, pos.r);\n\t\t\t}\n\t\t\t\n\t\t\treturn 0;\n\t\t}\n\t\t\n\t\t//I think this was O(log n)\n\t\tint getNumberOfEqualOrLesser(long val)\n\t\t{\n\t\t\treturn getNumberOfEqualOrLesser(val, root);\n\t\t}\n\t\t\n\t\tprivate int getNumberOfEqualOrLesser(long val, Node pos)\n\t\t{\n\t\t\tif(pos==null)return 0;\n\t\t\tif(val == pos.value)\n\t\t\t{\n\t\t\t\tif(pos.l != null)return pos.l.subsize+1;\n\t\t\t\telse return 1;\n\t\t\t}\n\t\t\telse if(val > pos.value)\n\t\t\t{\n\t\t\t\tint fromL = 0;\n\t\t\t\tif(pos.l != null)fromL = pos.l.subsize;\n\t\t\t\treturn getNumberOfEqualOrLesser(val, pos.r) + fromL + 1;\n\t\t\t}\n\t\t\telse if(val < pos.value)\n\t\t\t{\n\t\t\t\treturn getNumberOfEqualOrLesser(val, pos.l);\n\t\t\t}\n\t\t\t\n\t\t\treturn 0;\n\t\t}\n\t\t\n\t\tvoid add(long i)\n\t\t{\n\t\t\troot = insert(root, i);\n\t\t}\n\t\t\n\t\tprivate Node insert(Node pos, long i)\n\t\t{\n\t\t\tif(pos == null)\n\t\t\t{ //place here\n\t\t\t\tnodes++;\n\t\t\t\treturn new Node(i);\n\t\t\t}\n\t\t\tif(pos.value == i)\n\t\t\t{\n\t\t\t\tpos.number++;\n\t\t\t\treturn pos; //already here!\n\t\t\t}\n\t\t\t\n\t\t\tif(i < pos.value)\n\t\t\t{ //go left\n\t\t\t\tpos.l = insert(pos.l, i);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tpos.r = insert(pos.r, i);\n\t\t\t}\n\t\t\t\n\t\t\tpos.update();\n\t\t\treturn balance(pos);\n\t\t}\n\t\t\n\t\tlong getSmallestThatIsBiggerThan(long val)\n\t\t{\n\t\t\treturn getSmallestThatIsBiggerThan(root, val);\n\t\t}\n\t\t\n\t\tprivate long getSmallestThatIsBiggerThan(Node pos, long val)\n\t\t{\n//\t\t\tif(pos == null)System.out.println(\"Pos null\");\n//\t\t\tSystem.out.println(\"Searching at \" + pos.value);\n\t\t\tif(pos.value <= val)\n\t\t\t{ //need bigger\n\t\t\t\tif(pos.r != null)\n\t\t\t\t\treturn getSmallestThatIsBiggerThan(pos.r, val);\n\t\t\t\telse \n\t\t\t\t{\n\t\t\t\t\treturn 999999999;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{ //this or smaller\n\t\t\t\tif(pos.l != null)\n\t\t\t\t{\n\t\t\t\t\treturn Math.min(pos.value, getSmallestThatIsBiggerThan(pos.l, val));\n\t\t\t\t}\n\t\t\t\telse return pos.value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tlong getBiggestThatIsSmallerThan(long val)\n\t\t{\n\t\t\treturn getBiggestThatIsSmallerThan(root, val);\n\t\t}\n\t\t\n\t\tprivate long getBiggestThatIsSmallerThan(Node pos, long val)\n\t\t{\n\t\t\tif(pos.value >= val)\n\t\t\t{ //need smaller\n\t\t\t\tif(pos.l != null)\n\t\t\t\t\treturn getBiggestThatIsSmallerThan(pos.l, val);\n\t\t\t\telse \n\t\t\t\t{\n\t\t\t\t\treturn -999999999;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{ //this or bigger\n\t\t\t\tif(pos.r != null)\n\t\t\t\t{\n\t\t\t\t\treturn Math.max(pos.value, getBiggestThatIsSmallerThan(pos.r, val));\n\t\t\t\t}\n\t\t\t\telse return pos.value;\n\t\t\t}\n\t\t}\t\t\n\t\tNode getSmallest(Node pos)\n\t\t{\n\t\t\tif(pos == null)return pos;\n\t\t\tif(pos.l == null)\n\t\t\t\treturn pos;\n\t\t\telse return getSmallest(pos.l);\n\t\t}\n\t\t\n\t\tNode getLargest(Node pos)\n\t\t{\n\t\t\tif(pos.r == null)\n\t\t\t\treturn pos;\n\t\t\telse return getLargest(pos.r);\n\t\t}\n\t\t\n\t\tvoid remove(long i)\n\t\t{\n\t\t\troot = delete(root, i);\n\t\t}\n\t\t\n\t\tprivate Node delete(Node pos, long i)\n\t\t{\n\t\t\tif(pos == null)\n\t\t\t{ //already non-existent\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tif(pos.value == i)\n\t\t\t{\n\t\t\t\t//delete this\n\t\t\t\tif(pos.number > 1) //when there's only 1 left, delete.\n\t\t\t\t{\n\t\t\t\t\tpos.number--;\n\t\t\t\t\treturn pos;\n\t\t\t\t}\n\t\t\t\t//MARK\n\t\t\t\t\n\t\t\t\t\n\t\t\t\tif(pos.l != null && pos.r != null)\n\t\t\t\t{\n\t\t\t\t\t//you can do either but let's remove from the subtree with bigger height.\n\t\t\t\t\tif(pos.l.height >= pos.r.height)\n\t\t\t\t\t{\n\t\t\t\t\t\tNode dum = getLargest(pos.l); //return largest of left subtree\n\t\t\t\t\t\tpos.value = dum.value; //copy its value\n\t\t\t\t\t\tpos.l = delete(pos.l, dum.value); //then remove that, while updating all nodes necessary\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tNode dum = getSmallest(pos.r); //return smallest of right subtree\n\t\t\t\t\t\tpos.value = dum.value; //copy its value\n\t\t\t\t\t\tpos.r = delete(pos.r, dum.value); //then remove that, while updating all nodes necessary\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if(pos.l != null)\n\t\t\t\t{\n\t\t\t\t\tpos = pos.l;\n\t\t\t\t}\n\t\t\t\telse if(pos.r != null)pos = pos.r;\n\t\t\t\telse //both are null\n\t\t\t\t{\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\telse if(i < pos.value)\n\t\t\t{ //go left\n\t\t\t\tpos.l = delete(pos.l, i);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tpos.r = delete(pos.r, i);\n\t\t\t}\n\t\t\t\n\t\t\tpos.update();\n\t\t\treturn balance(pos);\n\t\t}\n\t\t\n\t\tNode leftRotate(Node node)\n\t\t{\n\t\t\tNode b = node.r;\n\t\t\tnode.subsize -= b.subsize;\n\t\t\tnode.r = b.l;\n\t\t\tif(b.l!=null)node.subsize += b.l.subsize;\n\t\t\t\n\t\t\tif(b.l!=null)b.subsize -= b.l.subsize;\n\t\t\tb.l = node;\n\t\t\tb.subsize += node.subsize;\n\t\t\t\n\t\t\tnode.update();\n\t\t\tb.update();\n\t\t\treturn b;\n\t\t}\n\t\t\n\t\tNode rightRotate(Node node)\n\t\t{\n\t\t\tNode b = node.l;\n\t\t\tnode.subsize -= b.subsize;\n\t\t\tnode.l = b.r;\n\t\t\tif(b.r!=null)node.subsize += b.r.subsize;\n\t\t\t\n\t\t\tif(b.r!=null)b.subsize -= b.r.subsize;\n\t\t\tb.r = node;\n\t\t\tb.subsize += node.subsize;\n\t\t\t\n\t\t\tnode.update();\n\t\t\tb.update();\n\t\t\treturn b;\n\t\t}\n\t\t\n\t\tNode llCase(Node node)\n\t\t{\n\t\t\treturn rightRotate(node);\n\t\t}\n\t\t\n\t\tNode lrCase(Node node)\n\t\t{\n\t\t\tnode.l = leftRotate(node.l);\n\t\t\treturn rightRotate(node);\n\t\t}\n\t\t\n\t\tNode rrCase(Node node)\n\t\t{\n\t\t\treturn leftRotate(node);\n\t\t}\n\t\t\n\t\tNode rlCase(Node node)\n\t\t{\n\t\t\tnode.r = rightRotate(node.r);\n\t\t\treturn leftRotate(node);\n\t\t}\n\t\t\n\t\tNode balance(Node node)\n\t\t{\n\t\t\tif(node.balance <= -2)\n\t\t\t{\n\t\t\t\tif(node.l.balance <= 0)\n\t\t\t\t\treturn llCase(node);\n\t\t\t\telse\n\t\t\t\t\treturn lrCase(node);\n\t\t\t}\n\t\t\telse if(node.balance >= 2)\n\t\t\t{\n\t\t\t\tif(node.r.balance >= 0)\n\t\t\t\t\treturn rrCase(node);\n\t\t\t\telse\n\t\t\t\t\treturn rlCase(node);\n\t\t\t}\n\t\t\t\n\t\t\treturn node; //already balanced!\n\t\t}\n\t\t\n\t\tvoid printout(Node pos)\n\t\t{\n\t\t\tif(pos == null)return;\n\t\t\tpos.printout();\n\t\t\tif(pos.l != null)System.out.println(pos.value + \"'s L\");\n\t\t\tprintout(pos.l);\n\t\t\tif(pos.r != null)System.out.println(pos.value + \"'s R\");\n\t\t\tprintout(pos.r);\n\t\t}\n\t\t\n\t\tstatic class Node\n\t\t{\n\t\t\tint balance = 0;\n\t\t\tint height = 0;\n\t\t\tlong value;\n\t\t\t\n\t\t\tint number = 1;\n\t\t\t\n\t\t\tint subsize = 1; //size of subtree rooted here, i.e. descendants + 1 (self)\n\t\t\t\n\t\t\tNode l = null;\n\t\t\tNode r = null;\n\t\t\t\n\t\t\tvoid printout()\n\t\t\t{\n\t\t\t\tSystem.out.println(\"Value \" + value + \" height \" + height + \" subsize \" + subsize + \" balance \" + balance);\n\t\t\t}\n\t\t\t\n\t\t\tvoid update()\n\t\t\t{ //leaf has height of 0.\n\t\t\t\tsubsize = 1;\n\t\t\t\tif(l != null)subsize += l.subsize;\n\t\t\t\tif(r != null)subsize += r.subsize;\n\t\t\t\t\n\t\t\t\tint lh = -1;\n\t\t\t\tint rh = -1;\n\t\t\t\tif(l!=null)lh = l.height;\n\t\t\t\tif(r!=null)rh = r.height;\n\t\t\t\theight = 1 + Math.max(lh, rh);\n\t\t\t\t\n\t\t\t\tbalance = rh - lh;\n\t\t\t}\n\t\t\t\n\t\t\tpublic Node(long i)\n\t\t\t{\n\t\t\t\tvalue = i;\n\t\t\t}\n\t\t}\n\t}\n\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": 8287, "cpu_time_ms": 208, "memory_kb": 31048}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s078018958", "group_id": "codeNet:p02852", "input_text": "import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n\n final long INF = 1_000_000_000;\n int N = scanner.nextInt();\n int M = scanner.nextInt();\n char[] s = scanner.next().toCharArray();\n\n long[] dp = new long[N + 1];\n Arrays.fill(dp, INF);\n dp[N] = 0;\n for (int i = N - 1; i >= 0; i--)\n if (s[i] == '0')\n for (int j = i + 1; j <= i + M && j <= N; j++) dp[i] = Math.min(dp[i], dp[j] + 1);\n if (dp[0] == INF) {\n System.out.println(-1);\n } else {\n StringBuilder sb = new StringBuilder();\n int next = 0;\n while (next < N) {\n for (int i = next + 1; i <= next + M && i <= N; i++) {\n if (dp[i] == dp[next] - 1) {\n sb.append(i - next).append(' ');\n next = i;\n break;\n }\n }\n }\n sb.setLength(sb.length() - 1);\n System.out.println(sb.toString());\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1577158467, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02852.html", "problem_id": "p02852", "resource_group": "high_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/Java/s078018958.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s078018958", "user_id": "u189832798"}, "prompt_components": {"gold_output": "1 3 2 3\n", "input_to_evaluate": "import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n\n final long INF = 1_000_000_000;\n int N = scanner.nextInt();\n int M = scanner.nextInt();\n char[] s = scanner.next().toCharArray();\n\n long[] dp = new long[N + 1];\n Arrays.fill(dp, INF);\n dp[N] = 0;\n for (int i = N - 1; i >= 0; i--)\n if (s[i] == '0')\n for (int j = i + 1; j <= i + M && j <= N; j++) dp[i] = Math.min(dp[i], dp[j] + 1);\n if (dp[0] == INF) {\n System.out.println(-1);\n } else {\n StringBuilder sb = new StringBuilder();\n int next = 0;\n while (next < N) {\n for (int i = next + 1; i <= next + M && i <= N; i++) {\n if (dp[i] == dp[next] - 1) {\n sb.append(i - next).append(' ');\n next = i;\n break;\n }\n }\n }\n sb.setLength(sb.length() - 1);\n System.out.println(sb.toString());\n }\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": 997, "cpu_time_ms": 2109, "memory_kb": 28044}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s403279368", "group_id": "codeNet:p02853", "input_text": "import java.util.Scanner;\nclass Main\n{\n\tpublic static void main(String args[])\n\t{\n Scanner sc=new Scanner(System.in);\n int x=sc.nextInt();\n\t\tint y=sc.nextInt();\n\n\t\tint sum=0;\n\n\t\tif(x==1){\n\t\tsum+=300000;\n\t\t}\n\t\telse if(x==2){\n\t\tsum+=200000;\n\t\t}\n\t\telse if(x==3){\n\t\tsum+=100000;\n\t\t}\n\t\telse{\n\t\tsum+=0;\n\t\t}\n\n\t\tif(y==1){\n\t\tsum+=300000;\n\t\t}\n\t\telse if(y==2){\n\t\tsum+=200000;\n\t\t}\n\t\telse if(y==3){\n\t\tsum+=100000;\n\t\t}\n\t\telse{\n\t\tsum+=0;\n\t\t}\n\n\t\tif(x==1 && y==1){\n\t\tsum+=400000;\n\t\t}\n\t\t\n\t\tSystem.out.println(sum);\n\t}\n}", "language": "Java", "metadata": {"date": 1574561952, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02853.html", "problem_id": "p02853", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02853/input.txt", "sample_output_relpath": "derived/input_output/data/p02853/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02853/Java/s403279368.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s403279368", "user_id": "u720439461"}, "prompt_components": {"gold_output": "1000000\n", "input_to_evaluate": "import java.util.Scanner;\nclass Main\n{\n\tpublic static void main(String args[])\n\t{\n Scanner sc=new Scanner(System.in);\n int x=sc.nextInt();\n\t\tint y=sc.nextInt();\n\n\t\tint sum=0;\n\n\t\tif(x==1){\n\t\tsum+=300000;\n\t\t}\n\t\telse if(x==2){\n\t\tsum+=200000;\n\t\t}\n\t\telse if(x==3){\n\t\tsum+=100000;\n\t\t}\n\t\telse{\n\t\tsum+=0;\n\t\t}\n\n\t\tif(y==1){\n\t\tsum+=300000;\n\t\t}\n\t\telse if(y==2){\n\t\tsum+=200000;\n\t\t}\n\t\telse if(y==3){\n\t\tsum+=100000;\n\t\t}\n\t\telse{\n\t\tsum+=0;\n\t\t}\n\n\t\tif(x==1 && y==1){\n\t\tsum+=400000;\n\t\t}\n\t\t\n\t\tSystem.out.println(sum);\n\t}\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nWe held two competitions: Coding Contest and Robot Maneuver.\n\nIn each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen.\n\nDISCO-Kun took the X-th place in Coding Contest and the Y-th place in Robot Maneuver.\nFind the total amount of money he earned.\n\nConstraints\n\n1 \\leq X \\leq 205\n\n1 \\leq Y \\leq 205\n\nX and Y are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the amount of money DISCO-Kun earned, as an integer.\n\nSample Input 1\n\n1 1\n\nSample Output 1\n\n1000000\n\nIn this case, he earned 300000 yen in Coding Contest and another 300000 yen in Robot Maneuver. Furthermore, as he won both competitions, he got an additional 400000 yen.\nIn total, he made 300000 + 300000 + 400000 = 1000000 yen.\n\nSample Input 2\n\n3 101\n\nSample Output 2\n\n100000\n\nIn this case, he earned 100000 yen in Coding Contest.\n\nSample Input 3\n\n4 4\n\nSample Output 3\n\n0\n\nIn this case, unfortunately, he was the highest-ranked contestant without prize money in both competitions.", "sample_input": "1 1\n"}, "reference_outputs": ["1000000\n"], "source_document_id": "p02853", "source_text": "Score: 100 points\n\nProblem Statement\n\nWe held two competitions: Coding Contest and Robot Maneuver.\n\nIn each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen.\n\nDISCO-Kun took the X-th place in Coding Contest and the Y-th place in Robot Maneuver.\nFind the total amount of money he earned.\n\nConstraints\n\n1 \\leq X \\leq 205\n\n1 \\leq Y \\leq 205\n\nX and Y are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the amount of money DISCO-Kun earned, as an integer.\n\nSample Input 1\n\n1 1\n\nSample Output 1\n\n1000000\n\nIn this case, he earned 300000 yen in Coding Contest and another 300000 yen in Robot Maneuver. Furthermore, as he won both competitions, he got an additional 400000 yen.\nIn total, he made 300000 + 300000 + 400000 = 1000000 yen.\n\nSample Input 2\n\n3 101\n\nSample Output 2\n\n100000\n\nIn this case, he earned 100000 yen in Coding Contest.\n\nSample Input 3\n\n4 4\n\nSample Output 3\n\n0\n\nIn this case, unfortunately, he was the highest-ranked contestant without prize money in both competitions.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 515, "cpu_time_ms": 108, "memory_kb": 23764}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s985149441", "group_id": "codeNet:p02856", "input_text": "import java.io.BufferedReader;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint m = Integer.parseInt(br.readLine());\n\t\tint[] d = new int[m];\n\t\tlong[] c = new long[m];\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tString[] sa = br.readLine().split(\" \");\n\t\t\td[i] = Integer.parseInt(sa[0]);\n\t\t\tc[i] = Long.parseLong(sa[1]);\n\t\t}\n\t\tbr.close();\n\n\t\tlong ans = 0;\n\t\tlong val = 0;\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tans += c[i];\n\t\t\tval += d[i] * c[i];\n\t\t\tans += val / 9;\n\t\t\tval %= 9;\n\t\t}\n\t\tans--;\n\t\tif (val == 0) {\n\t\t\tans--;\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1574566358, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02856.html", "problem_id": "p02856", "resource_group": "high_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/Java/s985149441.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s985149441", "user_id": "u522636435"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint m = Integer.parseInt(br.readLine());\n\t\tint[] d = new int[m];\n\t\tlong[] c = new long[m];\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tString[] sa = br.readLine().split(\" \");\n\t\t\td[i] = Integer.parseInt(sa[0]);\n\t\t\tc[i] = Long.parseLong(sa[1]);\n\t\t}\n\t\tbr.close();\n\n\t\tlong ans = 0;\n\t\tlong val = 0;\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tans += c[i];\n\t\t\tval += d[i] * c[i];\n\t\t\tans += val / 9;\n\t\t\tval %= 9;\n\t\t}\n\t\tans--;\n\t\tif (val == 0) {\n\t\t\tans--;\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\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": 688, "cpu_time_ms": 386, "memory_kb": 62456}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s833984269", "group_id": "codeNet:p02859", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int r = sc.nextInt();\n sc.close();\n\n int origin = 1 * 3;\n\n int thisTime = r * r * 3;\n\n int result = thisTime / origin;\n \n System.out.println(result);\n\n\n }\n}\n", "language": "Java", "metadata": {"date": 1573956261, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02859.html", "problem_id": "p02859", "resource_group": "high_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/Java/s833984269.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s833984269", "user_id": "u761516097"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int r = sc.nextInt();\n sc.close();\n\n int origin = 1 * 3;\n\n int thisTime = r * r * 3;\n\n int result = thisTime / origin;\n \n System.out.println(result);\n\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": 341, "cpu_time_ms": 117, "memory_kb": 21972}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s365518893", "group_id": "codeNet:p02859", "input_text": "import java.util.*;\n\npublic class Main {\n\tpublic static void main (String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint nam = sc.nextInt();\n\t\t\n\t\t\n\t\tSystem.out.println((nam*nam)/1);\n\t}\n}", "language": "Java", "metadata": {"date": 1573956193, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02859.html", "problem_id": "p02859", "resource_group": "high_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/Java/s365518893.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s365518893", "user_id": "u646483356"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\tpublic static void main (String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint nam = sc.nextInt();\n\t\t\n\t\t\n\t\tSystem.out.println((nam*nam)/1);\n\t}\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": 194, "cpu_time_ms": 98, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s623004902", "group_id": "codeNet:p02860", "input_text": "import java.util.*;\n\npublic class Main{\n public static void main(String[] args) {\n Scanner sc= new Scanner(System.in);\n int N = sc.nextInt(), T=N/2;\n String S = sc.next();\n if(N % 2 !=0) {\n System.out.println(\"No\");\n } else if(S.substring(0,T).equals(S.substring(T,N))){\n System.out.println(\"Yes\");\n } else {\n System.out.println(\"No\");\n }\n }\n}", "language": "Java", "metadata": {"date": 1595112274, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02860.html", "problem_id": "p02860", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02860/input.txt", "sample_output_relpath": "derived/input_output/data/p02860/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02860/Java/s623004902.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s623004902", "user_id": "u997005069"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main{\n public static void main(String[] args) {\n Scanner sc= new Scanner(System.in);\n int N = sc.nextInt(), T=N/2;\n String S = sc.next();\n if(N % 2 !=0) {\n System.out.println(\"No\");\n } else if(S.substring(0,T).equals(S.substring(T,N))){\n System.out.println(\"Yes\");\n } else {\n System.out.println(\"No\");\n }\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are a positive integer N and a string S of length N consisting of lowercase English letters.\n\nDetermine whether the string is a concatenation of two copies of some string.\nThat is, determine whether there is a string T such that S = T + T.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nS consists of lowercase English letters.\n\n|S| = N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nIf S is a concatenation of two copies of some string, print Yes; otherwise, print No.\n\nSample Input 1\n\n6\nabcabc\n\nSample Output 1\n\nYes\n\nLet T = abc, and S = T + T.\n\nSample Input 2\n\n6\nabcadc\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1\nz\n\nSample Output 3\n\nNo", "sample_input": "6\nabcabc\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02860", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are a positive integer N and a string S of length N consisting of lowercase English letters.\n\nDetermine whether the string is a concatenation of two copies of some string.\nThat is, determine whether there is a string T such that S = T + T.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nS consists of lowercase English letters.\n\n|S| = N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nIf S is a concatenation of two copies of some string, print Yes; otherwise, print No.\n\nSample Input 1\n\n6\nabcabc\n\nSample Output 1\n\nYes\n\nLet T = abc, and S = T + T.\n\nSample Input 2\n\n6\nabcadc\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1\nz\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 381, "cpu_time_ms": 118, "memory_kb": 35596}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s576501885", "group_id": "codeNet:p02860", "input_text": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n String s = sc.next();\n\n String a = s.substring(0, n / 2);\n String b = s.substring(n / 2, n);\n\n if (a.equals(b)) {\n System.out.println(\"Yes\");\n } else {\n System.out.println(\"No\");\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1587763220, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02860.html", "problem_id": "p02860", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02860/input.txt", "sample_output_relpath": "derived/input_output/data/p02860/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02860/Java/s576501885.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s576501885", "user_id": "u532585581"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n String s = sc.next();\n\n String a = s.substring(0, n / 2);\n String b = s.substring(n / 2, n);\n\n if (a.equals(b)) {\n System.out.println(\"Yes\");\n } else {\n System.out.println(\"No\");\n }\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are a positive integer N and a string S of length N consisting of lowercase English letters.\n\nDetermine whether the string is a concatenation of two copies of some string.\nThat is, determine whether there is a string T such that S = T + T.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nS consists of lowercase English letters.\n\n|S| = N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nIf S is a concatenation of two copies of some string, print Yes; otherwise, print No.\n\nSample Input 1\n\n6\nabcabc\n\nSample Output 1\n\nYes\n\nLet T = abc, and S = T + T.\n\nSample Input 2\n\n6\nabcadc\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1\nz\n\nSample Output 3\n\nNo", "sample_input": "6\nabcabc\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02860", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are a positive integer N and a string S of length N consisting of lowercase English letters.\n\nDetermine whether the string is a concatenation of two copies of some string.\nThat is, determine whether there is a string T such that S = T + T.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nS consists of lowercase English letters.\n\n|S| = N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nIf S is a concatenation of two copies of some string, print Yes; otherwise, print No.\n\nSample Input 1\n\n6\nabcabc\n\nSample Output 1\n\nYes\n\nLet T = abc, and S = T + T.\n\nSample Input 2\n\n6\nabcadc\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1\nz\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 95, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s639987404", "group_id": "codeNet:p02860", "input_text": "import java.util.*;\n\npublic class Main {\n\tpublic static void main (String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint nam = sc.nextInt();\n\t\tint har = nam/2;\n\t\tString stc = sc.next();\n\t\t\n\t\t String ans = \"No\";\n\t \tString front = stc.substring(0, har);\n\t \tString back = stc.substring(har, nam);\n\t \tif (front.equals(back)){\n\t\t ans = \"Yes\";\n\t \t}\n\t\tSystem.out.println(ans);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1573957529, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02860.html", "problem_id": "p02860", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02860/input.txt", "sample_output_relpath": "derived/input_output/data/p02860/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02860/Java/s639987404.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s639987404", "user_id": "u646483356"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\tpublic static void main (String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint nam = sc.nextInt();\n\t\tint har = nam/2;\n\t\tString stc = sc.next();\n\t\t\n\t\t String ans = \"No\";\n\t \tString front = stc.substring(0, har);\n\t \tString back = stc.substring(har, nam);\n\t \tif (front.equals(back)){\n\t\t ans = \"Yes\";\n\t \t}\n\t\tSystem.out.println(ans);\n\t}\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are a positive integer N and a string S of length N consisting of lowercase English letters.\n\nDetermine whether the string is a concatenation of two copies of some string.\nThat is, determine whether there is a string T such that S = T + T.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nS consists of lowercase English letters.\n\n|S| = N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nIf S is a concatenation of two copies of some string, print Yes; otherwise, print No.\n\nSample Input 1\n\n6\nabcabc\n\nSample Output 1\n\nYes\n\nLet T = abc, and S = T + T.\n\nSample Input 2\n\n6\nabcadc\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1\nz\n\nSample Output 3\n\nNo", "sample_input": "6\nabcabc\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02860", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are a positive integer N and a string S of length N consisting of lowercase English letters.\n\nDetermine whether the string is a concatenation of two copies of some string.\nThat is, determine whether there is a string T such that S = T + T.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nS consists of lowercase English letters.\n\n|S| = N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nIf S is a concatenation of two copies of some string, print Yes; otherwise, print No.\n\nSample Input 1\n\n6\nabcabc\n\nSample Output 1\n\nYes\n\nLet T = abc, and S = T + T.\n\nSample Input 2\n\n6\nabcadc\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1\nz\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 407, "cpu_time_ms": 115, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s500843454", "group_id": "codeNet:p02861", "input_text": "import java.util.*;\nimport java.lang.*;\npublic class Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint N = sc.nextInt();\n\t\tdouble[] x = new double[N];\n\t\tdouble[] y = new double[N];\n\t\tdouble[] ans = new double[40320];\n\t\tdouble[] aa = new double[]{1,2,4,8,16,32,64,128,256};\n\t\tdouble[] bb = new double[]{0,1,2,6,24,120,720,5040,40320};\n\t\tfor( int i=0; i 0) {\n System.out.println(0);\n return;\n }\n long v = pow(array[i - 1], array[i], 998244353);\n ans *= v;\n ans %= 998244353;\n }\n\n System.out.println(ans);\n }\n\n //return a^b mod M O(logB)\n private static long pow(long a, long b, int M) {\n long ret = 1;\n long tmp = a;\n while (b > 0) {\n if ((b & 1) == 1) ret = (ret * tmp) % M;\n tmp = (tmp * tmp) % M;\n b = b >> 1;\n }\n return ret;\n }\n}", "language": "Java", "metadata": {"date": 1598144148, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02866.html", "problem_id": "p02866", "resource_group": "high_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/Java/s854592888.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s854592888", "user_id": "u711620077"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n // write your code here\n Scanner scanner = new Scanner(System.in);\n int n = scanner.nextInt();\n long[] array = new long[n];\n\n for (int i = 0; i < n; i++) {\n array[scanner.nextInt()]++;\n }\n\n if (n < 2 || array[2] == 0) {\n System.out.println(0);\n return;\n }\n\n long ans = 1;\n\n for (int i = 2; i < n; i++) {\n if (array[i - 1] == 0 && array[i] > 0) {\n System.out.println(0);\n return;\n }\n long v = pow(array[i - 1], array[i], 998244353);\n ans *= v;\n ans %= 998244353;\n }\n\n System.out.println(ans);\n }\n\n //return a^b mod M O(logB)\n private static long pow(long a, long b, int M) {\n long ret = 1;\n long tmp = a;\n while (b > 0) {\n if ((b & 1) == 1) ret = (ret * tmp) % M;\n tmp = (tmp * tmp) % M;\n b = b >> 1;\n }\n return ret;\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": 1090, "cpu_time_ms": 431, "memory_kb": 59676}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s683203618", "group_id": "codeNet:p02866", "input_text": "import java.util.*;\n//import java.math.BigDecimal;\n\npublic class Main{\n public static void main(String args[]){\n\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int[] m = new int[n];\n long answer = 1;\n //BigDecimal answer = BigDecimal.valueOf(1);\n\n if(sc.nextInt() != 0) answer = 0;\n //if(sc.nextInt() != 0) answer = BigDecimal.valueOf(0);\n else m[0]++;\n for(int i = 1; i < n; i++){\n int x;\n if((x = sc.nextInt()) == 0){\n answer = 0;\n //answer = BigDecimal.valueOf(0);\n break;\n }\n m[x]++;\n }\n\n for(int i = 1; i < n; i++){\n //answer *= ((long)Math.pow(m[i-1], m[i]) % 998244353);\n //answer = answer.multiply(BigDecimal.valueOf(Math.pow(m[i-1], m[i])));\n for(int j = 0; j < m[i]; j++){\n answer *= m[i-1] % 998244353;\n }\n }\n\n //System.out.println(answer % 998244353);\n //System.out.println(answer.remainder(BigDecimal.valueOf(998244353)).toBigInteger());\n System.out.println(answer);\n\n }\n\n}\n", "language": "Java", "metadata": {"date": 1573359930, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02866.html", "problem_id": "p02866", "resource_group": "high_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/Java/s683203618.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s683203618", "user_id": "u521293705"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*;\n//import java.math.BigDecimal;\n\npublic class Main{\n public static void main(String args[]){\n\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int[] m = new int[n];\n long answer = 1;\n //BigDecimal answer = BigDecimal.valueOf(1);\n\n if(sc.nextInt() != 0) answer = 0;\n //if(sc.nextInt() != 0) answer = BigDecimal.valueOf(0);\n else m[0]++;\n for(int i = 1; i < n; i++){\n int x;\n if((x = sc.nextInt()) == 0){\n answer = 0;\n //answer = BigDecimal.valueOf(0);\n break;\n }\n m[x]++;\n }\n\n for(int i = 1; i < n; i++){\n //answer *= ((long)Math.pow(m[i-1], m[i]) % 998244353);\n //answer = answer.multiply(BigDecimal.valueOf(Math.pow(m[i-1], m[i])));\n for(int j = 0; j < m[i]; j++){\n answer *= m[i-1] % 998244353;\n }\n }\n\n //System.out.println(answer % 998244353);\n //System.out.println(answer.remainder(BigDecimal.valueOf(998244353)).toBigInteger());\n System.out.println(answer);\n\n }\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": 1162, "cpu_time_ms": 430, "memory_kb": 52288}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s711107633", "group_id": "codeNet:p02866", "input_text": "import java.util.Map;\nimport java.util.Scanner;\nimport java.util.TreeMap;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tLong n = Long.valueOf(sc.nextLine());\n\n\t\tMap map = new TreeMap<>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tLong input = sc.nextLong();\n\t\t\tLong c = map.getOrDefault(input, 0L);\n\t\t\tc++;\n\t\t\tmap.put(input, c);\n\t\t}\n\t\tsc.close();\n\t\tif (!map.containsKey(0L)) {\n\t\t\tSystem.out.println(0);\n\t\t\treturn;\n\t\t}\n\t\tLong before = -1L;\n\t\tfor (Long key : map.keySet()) {\n\t\t\tif (key != before + 1L) {\n\t\t\t\tSystem.out.println(0L);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbefore = key;\n\t\t}\n\t\tLong size = (long) map.values().size();\n\t\tlong ans = 1L;\n\t\tfor (Long i = 0L; i < size - 1L; i++) {\n\t\t\tLong a = map.get(i);\n\t\t\tLong b = map.get(i + 1l);\n\t\t\tans = ans * (long) Math.pow(a, b);\n\t\t}\n\t\tSystem.out.println(ans % 998244353L);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1573354749, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02866.html", "problem_id": "p02866", "resource_group": "high_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/Java/s711107633.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s711107633", "user_id": "u279005807"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Map;\nimport java.util.Scanner;\nimport java.util.TreeMap;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tLong n = Long.valueOf(sc.nextLine());\n\n\t\tMap map = new TreeMap<>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tLong input = sc.nextLong();\n\t\t\tLong c = map.getOrDefault(input, 0L);\n\t\t\tc++;\n\t\t\tmap.put(input, c);\n\t\t}\n\t\tsc.close();\n\t\tif (!map.containsKey(0L)) {\n\t\t\tSystem.out.println(0);\n\t\t\treturn;\n\t\t}\n\t\tLong before = -1L;\n\t\tfor (Long key : map.keySet()) {\n\t\t\tif (key != before + 1L) {\n\t\t\t\tSystem.out.println(0L);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbefore = key;\n\t\t}\n\t\tLong size = (long) map.values().size();\n\t\tlong ans = 1L;\n\t\tfor (Long i = 0L; i < size - 1L; i++) {\n\t\t\tLong a = map.get(i);\n\t\t\tLong b = map.get(i + 1l);\n\t\t\tans = ans * (long) Math.pow(a, b);\n\t\t}\n\t\tSystem.out.println(ans % 998244353L);\n\t}\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": 873, "cpu_time_ms": 592, "memory_kb": 64748}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s054638352", "group_id": "codeNet:p02880", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\t//\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint ans = sc.nextInt();\n\t\tif(ans <= 81 &&((ans %2 ==0) || (ans %3 ==0) || (ans %4 ==0)|| (ans %5 ==0)|| (ans %6 ==0)|| (ans %7 ==0)|| (ans %8 ==0)|| (ans %9 ==0))) {\n\t\t\tSystem.out.println(\"Yes\");\n\t\t} else {\n\t\t\tSystem.out.println(\"No\");\n\t\t}\n\t\t// Scannerクラスのインスタンスをクローズ\n\t\tsc.close();\n\t}\n}", "language": "Java", "metadata": {"date": 1572226341, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02880.html", "problem_id": "p02880", "resource_group": "high_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/Java/s054638352.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s054638352", "user_id": "u701556667"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\t//\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint ans = sc.nextInt();\n\t\tif(ans <= 81 &&((ans %2 ==0) || (ans %3 ==0) || (ans %4 ==0)|| (ans %5 ==0)|| (ans %6 ==0)|| (ans %7 ==0)|| (ans %8 ==0)|| (ans %9 ==0))) {\n\t\t\tSystem.out.println(\"Yes\");\n\t\t} else {\n\t\t\tSystem.out.println(\"No\");\n\t\t}\n\t\t// Scannerクラスのインスタンスをクローズ\n\t\tsc.close();\n\t}\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": 452, "cpu_time_ms": 96, "memory_kb": 23892}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s016422842", "group_id": "codeNet:p02881", "input_text": "import java.util.*;\npublic class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n long a = sc.nextLong();\n\n long b = Long.MAX_VALUE /2;\n long c = Long.MAX_VALUE /2;\n List list = factorization(a);\n for (long i : list) {\n if((a/i + i) < (b + c) ){\n b = a/i;\n c = i;\n }\n }\n System.out.println(b + c -2);\n }\n\n static List factorization(long x) {\n List result = new ArrayList<>();\n\n while (x >= 4 && x % 2 == 0) {\n result.add((long)2);\n x /= 2;\n }\n long d = 3;\n long q = x / d;\n while (q >= d) {\n if (x % d == 0) {\n result.add(d);\n x = q;\n } else {\n d += 2;\n }\n q = x / d;\n }\n result.add(x);\n return result;\n }\n}", "language": "Java", "metadata": {"date": 1572228964, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02881.html", "problem_id": "p02881", "resource_group": "high_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/Java/s016422842.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s016422842", "user_id": "u786488524"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*;\npublic class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n long a = sc.nextLong();\n\n long b = Long.MAX_VALUE /2;\n long c = Long.MAX_VALUE /2;\n List list = factorization(a);\n for (long i : list) {\n if((a/i + i) < (b + c) ){\n b = a/i;\n c = i;\n }\n }\n System.out.println(b + c -2);\n }\n\n static List factorization(long x) {\n List result = new ArrayList<>();\n\n while (x >= 4 && x % 2 == 0) {\n result.add((long)2);\n x /= 2;\n }\n long d = 3;\n long q = x / d;\n while (q >= d) {\n if (x % d == 0) {\n result.add(d);\n x = q;\n } else {\n d += 2;\n }\n q = x / d;\n }\n result.add(x);\n return result;\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": 825, "cpu_time_ms": 107, "memory_kb": 23764}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s835942452", "group_id": "codeNet:p02881", "input_text": "import java.util.Scanner;\nimport java.lang.Math;\nclass Main {\n public static void main (String[] args) {\n Scanner sc = new Scanner(System.in);\n long n = sc.nextLong();\n long i = 100000000000L;\n for (long j=1; j<=Math.sqrt((double)n); j++) {\n \t\tif(n%j == 0) {\n \t\t\tlong k = n/j;\n \t\t\tif (i > (j+k-2)) i = j+k-2;\n \t\t}\n }\n System.out.println(i);\n }\n}", "language": "Java", "metadata": {"date": 1572227499, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02881.html", "problem_id": "p02881", "resource_group": "high_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/Java/s835942452.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s835942452", "user_id": "u858464419"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.Scanner;\nimport java.lang.Math;\nclass Main {\n public static void main (String[] args) {\n Scanner sc = new Scanner(System.in);\n long n = sc.nextLong();\n long i = 100000000000L;\n for (long j=1; j<=Math.sqrt((double)n); j++) {\n \t\tif(n%j == 0) {\n \t\t\tlong k = n/j;\n \t\t\tif (i > (j+k-2)) i = j+k-2;\n \t\t}\n }\n System.out.println(i);\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": 421, "cpu_time_ms": 109, "memory_kb": 23636}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s560304079", "group_id": "codeNet:p02881", "input_text": "import java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n long n = sc.nextInt();\n long s = n;\n\n for (long i = 1; i < n; i++) {\n for (long j = 1; j < n; j++) {\n if(i * j == n) {\n s = Math.min(s,i-1+j-1);\n break;\n }\n }\n }\n\n System.out.println(s);\n\n\n }\n\n}\n", "language": "Java", "metadata": {"date": 1572225468, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02881.html", "problem_id": "p02881", "resource_group": "high_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/Java/s560304079.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s560304079", "user_id": "u387775763"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n long n = sc.nextInt();\n long s = n;\n\n for (long i = 1; i < n; i++) {\n for (long j = 1; j < n; j++) {\n if(i * j == n) {\n s = Math.min(s,i-1+j-1);\n break;\n }\n }\n }\n\n System.out.println(s);\n\n\n }\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": 380, "cpu_time_ms": 2109, "memory_kb": 23764}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s103919634", "group_id": "codeNet:p02885", "input_text": "\n\nimport java.util.*;\n\nclass Main {\n\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n int x = in.nextInt();\n int y = in.nextInt();\n if (x >= 1 && x <= 100 && y >= 1 && y <= 100) {\n if (x - (y * 2) >= 0) {\n System.out.println(x - (y * 2));\n } else {\n System.out.println(0);\n }\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1578899619, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02885.html", "problem_id": "p02885", "resource_group": "high_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/Java/s103919634.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s103919634", "user_id": "u096087819"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "\n\nimport java.util.*;\n\nclass Main {\n\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n int x = in.nextInt();\n int y = in.nextInt();\n if (x >= 1 && x <= 100 && y >= 1 && y <= 100) {\n if (x - (y * 2) >= 0) {\n System.out.println(x - (y * 2));\n } else {\n System.out.println(0);\n }\n }\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": 420, "cpu_time_ms": 97, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s553853113", "group_id": "codeNet:p02885", "input_text": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.NoSuchElementException;\nimport java.util.PriorityQueue;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tFastScanner sc = new FastScanner();\n\t\tint A = sc.nextInt();\n\t\tint B = sc.nextInt();\n\t\tint ans = Math.max(0, A - B*2);\n\t\tSystem.out.println(ans);\n\t}\n\t\n\tpublic static long gcd(long a, long b) {\n\t\tlong remainder = a % b;\n\t\tif (remainder == 0) {\n\t\t\treturn b;\n\t\t} else {\n\t\t\treturn gcd(b, remainder);\n\t\t}\n\t}\n}\n\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte())\n return buffer[ptr++];\n else\n return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr]))\n ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext())\n throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext())\n throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)\n throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n}\n", "language": "Java", "metadata": {"date": 1572824857, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02885.html", "problem_id": "p02885", "resource_group": "high_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/Java/s553853113.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s553853113", "user_id": "u893188242"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.NoSuchElementException;\nimport java.util.PriorityQueue;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tFastScanner sc = new FastScanner();\n\t\tint A = sc.nextInt();\n\t\tint B = sc.nextInt();\n\t\tint ans = Math.max(0, A - B*2);\n\t\tSystem.out.println(ans);\n\t}\n\t\n\tpublic static long gcd(long a, long b) {\n\t\tlong remainder = a % b;\n\t\tif (remainder == 0) {\n\t\t\treturn b;\n\t\t} else {\n\t\t\treturn gcd(b, remainder);\n\t\t}\n\t}\n}\n\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte())\n return buffer[ptr++];\n else\n return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr]))\n ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext())\n throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext())\n throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)\n throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\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": 2743, "cpu_time_ms": 72, "memory_kb": 22996}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s215238599", "group_id": "codeNet:p02885", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int A = sc.nextInt();\n int B = sc.nextInt();\n\n System.out.println(Math.max(0, A-2*B));\n\n\n }\n\n\n\n}\n", "language": "Java", "metadata": {"date": 1571533453, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02885.html", "problem_id": "p02885", "resource_group": "high_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/Java/s215238599.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s215238599", "user_id": "u584924463"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int A = sc.nextInt();\n int B = sc.nextInt();\n\n System.out.println(Math.max(0, A-2*B));\n\n\n }\n\n\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": 240, "cpu_time_ms": 113, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s581087897", "group_id": "codeNet:p02886", "input_text": "import java.util.*;\npublic class Main {\n\tpublic static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint sum = 0;\n\t\tint arry[]=new int[N+1];\n\t\tfor(int i=1;i<=N;i++){\n\t\t\tarry[i]=sc.nextInt();\n\t\t}\n\t\tfor(int i=1;i<=N-1;i++){\n\t\t\tfor(int k=i+1;k<=N;k++){\n\t\t\t\tsum=sum+arry[i]*arry[k];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n }\n}", "language": "Java", "metadata": {"date": 1585116993, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02886.html", "problem_id": "p02886", "resource_group": "high_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/Java/s581087897.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s581087897", "user_id": "u832153770"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "import java.util.*;\npublic class Main {\n\tpublic static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint sum = 0;\n\t\tint arry[]=new int[N+1];\n\t\tfor(int i=1;i<=N;i++){\n\t\t\tarry[i]=sc.nextInt();\n\t\t}\n\t\tfor(int i=1;i<=N-1;i++){\n\t\t\tfor(int k=i+1;k<=N;k++){\n\t\t\t\tsum=sum+arry[i]*arry[k];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sum);\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIt's now the season of TAKOYAKI FESTIVAL!\n\nThis year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i-th takoyaki is d_i.\n\nAs is commonly known, when you eat two takoyaki of deliciousness x and y together, you restore x \\times y health points.\n\nThere are \\frac{N \\times (N - 1)}{2} ways to choose two from the N takoyaki served in the festival. For each of these choices, find the health points restored from eating the two takoyaki, then compute the sum of these \\frac{N \\times (N - 1)}{2} values.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\n0 \\leq d_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the sum of the health points restored from eating two takoyaki over all possible choices of two takoyaki from the N takoyaki served.\n\nSample Input 1\n\n3\n3 1 2\n\nSample Output 1\n\n11\n\nThere are three possible choices:\n\nEat the first and second takoyaki. You will restore 3 health points.\n\nEat the second and third takoyaki. You will restore 2 health points.\n\nEat the first and third takoyaki. You will restore 6 health points.\n\nThe sum of these values is 11.\n\nSample Input 2\n\n7\n5 0 7 8 3 3 2\n\nSample Output 2\n\n312", "sample_input": "3\n3 1 2\n"}, "reference_outputs": ["11\n"], "source_document_id": "p02886", "source_text": "Score : 200 points\n\nProblem Statement\n\nIt's now the season of TAKOYAKI FESTIVAL!\n\nThis year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i-th takoyaki is d_i.\n\nAs is commonly known, when you eat two takoyaki of deliciousness x and y together, you restore x \\times y health points.\n\nThere are \\frac{N \\times (N - 1)}{2} ways to choose two from the N takoyaki served in the festival. For each of these choices, find the health points restored from eating the two takoyaki, then compute the sum of these \\frac{N \\times (N - 1)}{2} values.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\n0 \\leq d_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the sum of the health points restored from eating two takoyaki over all possible choices of two takoyaki from the N takoyaki served.\n\nSample Input 1\n\n3\n3 1 2\n\nSample Output 1\n\n11\n\nThere are three possible choices:\n\nEat the first and second takoyaki. You will restore 3 health points.\n\nEat the second and third takoyaki. You will restore 2 health points.\n\nEat the first and third takoyaki. You will restore 6 health points.\n\nThe sum of these values is 11.\n\nSample Input 2\n\n7\n5 0 7 8 3 3 2\n\nSample Output 2\n\n312", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 106, "memory_kb": 22612}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s177065953", "group_id": "codeNet:p02886", "input_text": "import java.util.Scanner;\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint total = 0;\n\t\tint N = sc.nextInt();\n\t\tint[] tako = new int[N];\n\t\tfor(int i = 0; i s[p])\n\t\t\t\t\t\t\t&& (Math.abs(s[i] - s[o]) < s[p])) {\n\t\t\t\t\t\t//System.out.println(s[i]+\" \"+s[o]+\" \"+s[p]);\n\t\t\t\t\t\tans++;\n\t\t\t\t\t}\n\t\t\t\t\tif(Math.abs(s[i] - s[o]) < s[p]){\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\tSystem.out.println(ans);\n\t}\n}", "language": "Java", "metadata": {"date": 1572466514, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02888.html", "problem_id": "p02888", "resource_group": "high_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/Java/s239660528.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s239660528", "user_id": "u533017901"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint s[] = new int[n];\n\t\tint ans = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ts[i] = sc.nextInt();\n\t\t}\n\t\tArrays.sort(s);\n\t\tfor (int i = 0; i < n - 2; i++) {\n\t\t\tfor (int o = i + 1; o < n - 1; o++) {\n\t\t\t\t// s[i]+s[o]\n\t\t\t\tfor (int p = o + 1; p < n; p++) {\n\t\t\t\t\tif ((s[i] + s[o] > s[p])\n\t\t\t\t\t\t\t&& (Math.abs(s[i] - s[o]) < s[p])) {\n\t\t\t\t\t\t//System.out.println(s[i]+\" \"+s[o]+\" \"+s[p]);\n\t\t\t\t\t\tans++;\n\t\t\t\t\t}\n\t\t\t\t\tif(Math.abs(s[i] - s[o]) < s[p]){\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\tSystem.out.println(ans);\n\t}\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": 678, "cpu_time_ms": 197, "memory_kb": 25932}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s667727861", "group_id": "codeNet:p02888", "input_text": "import java.util.Scanner;\nimport java.util.Arrays;\n\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int list[] = new int[n];\n \n for(int i = 0; i < n; i++)\n list[i] = sc.nextInt();\n Arrays.sort(list);\n \n int count = 0;\n int a,b,c;\n a: for(int ai = 0; ai < n-2; ai++){\n b: for(int bi = ai+1; bi < n-1; bi++){\n c: for(int ci = bi+1; ci < n; ci++){\n \t\ta = list[ai];\n \t\tb = list[bi];\n \t\tc = list[ci];\n \t\tif(a >= (b+c)){\n\t\t\t\tbreak a;\n }\n \tif(b >= (c+a))\n continue a;\n \tif(c >= (a+b)) \n continue b;\n \tcount++; \t\n }\n }\n }\n System.out.println(count);\n }\n}", "language": "Java", "metadata": {"date": 1571538436, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02888.html", "problem_id": "p02888", "resource_group": "high_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/Java/s667727861.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s667727861", "user_id": "u852798899"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner;\nimport java.util.Arrays;\n\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int list[] = new int[n];\n \n for(int i = 0; i < n; i++)\n list[i] = sc.nextInt();\n Arrays.sort(list);\n \n int count = 0;\n int a,b,c;\n a: for(int ai = 0; ai < n-2; ai++){\n b: for(int bi = ai+1; bi < n-1; bi++){\n c: for(int ci = bi+1; ci < n; ci++){\n \t\ta = list[ai];\n \t\tb = list[bi];\n \t\tc = list[ci];\n \t\tif(a >= (b+c)){\n\t\t\t\tbreak a;\n }\n \tif(b >= (c+a))\n continue a;\n \tif(c >= (a+b)) \n continue b;\n \tcount++; \t\n }\n }\n }\n System.out.println(count);\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": 766, "cpu_time_ms": 1747, "memory_kb": 26128}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s346498119", "group_id": "codeNet:p02889", "input_text": "import java.util.*; import java.io.*; import java.math.*;\npublic class Main{\n\t//Don't have to see. start------------------------------------------\n\tstatic class InputIterator{\n\t\tArrayList inputLine = new ArrayList(1024);\n\t\tint index = 0; int max; String read;\n\t\tInputIterator(){\n\t\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t\ttry{\n\t\t\t\twhile((read = br.readLine()) != null){\n\t\t\t\t\tinputLine.add(read);\n\t\t\t\t}\n\t\t\t}catch(IOException e){}\n\t\t\tmax = inputLine.size();\n\t\t}\n\t\tboolean hasNext(){return (index < max);}\n\t\tString next(){\n\t\t\tif(hasNext()){\n\t\t\t\treturn inputLine.get(index++);\n\t\t\t}else{\n\t\t\t\tthrow new IndexOutOfBoundsException(\"There is no more input\");\n\t\t\t}\n\t\t}\n\t}\n\tstatic HashMap CONVSTR = new HashMap();\n\tstatic InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.\n\tstatic PrintWriter out = new PrintWriter(System.out);\n\tstatic void flush(){out.flush();}\n\tstatic void myout(Object t){out.println(t);}\n\tstatic void myerr(Object t){System.err.print(\"debug:\");System.err.println(t);}\n\tstatic String next(){return ii.next();}\n\tstatic boolean hasNext(){return ii.hasNext();}\n\tstatic int nextInt(){return Integer.parseInt(next());}\n\tstatic long nextLong(){return Long.parseLong(next());}\n\tstatic double nextDouble(){return Double.parseDouble(next());}\n\tstatic ArrayList nextStrArray(){return myconv(next(), 8);}\n\tstatic ArrayList nextCharArray(){return myconv(next(), 0);}\n\tstatic ArrayList nextIntArray(){\n\t\tArrayList input = nextStrArray(); ArrayList ret = new ArrayList(input.size());\n\t\tfor(int i = 0; i < input.size(); i++){\n\t\t\tret.add(Integer.parseInt(input.get(i)));\n\t\t}\n\t\treturn ret;\n\t}\n\tstatic ArrayList nextLongArray(){\n\t\tArrayList input = nextStrArray(); ArrayList ret = new ArrayList(input.size());\n\t\tfor(int i = 0; i < input.size(); i++){\n\t\t\tret.add(Long.parseLong(input.get(i)));\n\t\t}\n\t\treturn ret;\n\t}\n\tstatic String myconv(Object list, int no){//only join\n\t\tString joinString = CONVSTR.get(no);\n\t\tif(list instanceof String[]){\n\t\t\treturn String.join(joinString, (String[])list);\n\t\t}else if(list instanceof ArrayList){\n\t\t\treturn String.join(joinString, (ArrayList)list);\n\t\t}else{\n\t\t\tthrow new ClassCastException(\"Don't join\");\n\t\t}\n\t}\n\tstatic ArrayList myconv(String str, int no){//only split\n\t\tString splitString = CONVSTR.get(no);\n\t\treturn new ArrayList(Arrays.asList(str.split(splitString)));\n\t}\n\tpublic static void main(String[] args){\n\t\tCONVSTR.put(8, \" \"); CONVSTR.put(9, \"\\n\"); CONVSTR.put(0, \"\");\n\t\tsolve();flush();\n\t}\n\t//Don't have to see. end------------------------------------------\n\tstatic void solve(){//Here is the main function\n ArrayList one = nextIntArray();\n int N = one.get(0);\n int M = one.get(1);\n int L = one.get(2);\n long[][] kyori = new long[N][N];\n long max = (long)Math.pow(10,15);\n for(int i = 0; i < N; i++){\n Arrays.fill(kyori[i], max);\n kyori[i][i] = 0;\n }\n for(int i = 0; i < M; i++){\n ArrayList tmp = nextIntArray();\n kyori[tmp.get(0) - 1][tmp.get(1) - 1] = tmp.get(2);\n kyori[tmp.get(1) - 1][tmp.get(0) - 1] = tmp.get(2);\n }\n for(int k = 0; k < N; k++){\n for(int i = 0; i < N; i++){\n for(int j = 0; j < N; j++){\n if(kyori[i][j] > kyori[i][k] + kyori[k][j]){\n kyori[i][j] = kyori[i][k] + kyori[k][j];\n }\n }\n }\n }\n long[][] count = new long[N][N];\n for(int i = 0; i < N; i++){\n Arrays.fill(count[i], max);\n for(int j = 0; j < N; j++){\n if(kyori[i][j] <= L){\n count[i][j] = 1;\n }else{\n count[i][j] = max;\n }\n }\n count[i][i] = 0;\n }\n for(int k = 0; k < N; k++){\n for(int i = 0; i < N; i++){\n for(int j = 0; j < N; j++){\n if(count[i][j] > count[i][k] + count[k][j]){\n count[i][j] = count[i][k] + count[k][j];\n }\n }\n }\n }\n int Q = nextInt();\n for(int i = 0; i < Q; i++){\n ArrayList query = nextIntArray();\n long getCount = count[query.get(0) - 1][query.get(1) - 1];\n if(getCount >= max){\n getCount = 0;\n }\n myout(getCount - 1);\n }\n\t}\n\t//Method addition frame start\n\n\n\n\t//Method addition frame end\n}\n", "language": "Java", "metadata": {"date": 1598975404, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02889.html", "problem_id": "p02889", "resource_group": "high_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/Java/s346498119.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s346498119", "user_id": "u222822036"}, "prompt_components": {"gold_output": "0\n1\n", "input_to_evaluate": "import java.util.*; import java.io.*; import java.math.*;\npublic class Main{\n\t//Don't have to see. start------------------------------------------\n\tstatic class InputIterator{\n\t\tArrayList inputLine = new ArrayList(1024);\n\t\tint index = 0; int max; String read;\n\t\tInputIterator(){\n\t\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t\ttry{\n\t\t\t\twhile((read = br.readLine()) != null){\n\t\t\t\t\tinputLine.add(read);\n\t\t\t\t}\n\t\t\t}catch(IOException e){}\n\t\t\tmax = inputLine.size();\n\t\t}\n\t\tboolean hasNext(){return (index < max);}\n\t\tString next(){\n\t\t\tif(hasNext()){\n\t\t\t\treturn inputLine.get(index++);\n\t\t\t}else{\n\t\t\t\tthrow new IndexOutOfBoundsException(\"There is no more input\");\n\t\t\t}\n\t\t}\n\t}\n\tstatic HashMap CONVSTR = new HashMap();\n\tstatic InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.\n\tstatic PrintWriter out = new PrintWriter(System.out);\n\tstatic void flush(){out.flush();}\n\tstatic void myout(Object t){out.println(t);}\n\tstatic void myerr(Object t){System.err.print(\"debug:\");System.err.println(t);}\n\tstatic String next(){return ii.next();}\n\tstatic boolean hasNext(){return ii.hasNext();}\n\tstatic int nextInt(){return Integer.parseInt(next());}\n\tstatic long nextLong(){return Long.parseLong(next());}\n\tstatic double nextDouble(){return Double.parseDouble(next());}\n\tstatic ArrayList nextStrArray(){return myconv(next(), 8);}\n\tstatic ArrayList nextCharArray(){return myconv(next(), 0);}\n\tstatic ArrayList nextIntArray(){\n\t\tArrayList input = nextStrArray(); ArrayList ret = new ArrayList(input.size());\n\t\tfor(int i = 0; i < input.size(); i++){\n\t\t\tret.add(Integer.parseInt(input.get(i)));\n\t\t}\n\t\treturn ret;\n\t}\n\tstatic ArrayList nextLongArray(){\n\t\tArrayList input = nextStrArray(); ArrayList ret = new ArrayList(input.size());\n\t\tfor(int i = 0; i < input.size(); i++){\n\t\t\tret.add(Long.parseLong(input.get(i)));\n\t\t}\n\t\treturn ret;\n\t}\n\tstatic String myconv(Object list, int no){//only join\n\t\tString joinString = CONVSTR.get(no);\n\t\tif(list instanceof String[]){\n\t\t\treturn String.join(joinString, (String[])list);\n\t\t}else if(list instanceof ArrayList){\n\t\t\treturn String.join(joinString, (ArrayList)list);\n\t\t}else{\n\t\t\tthrow new ClassCastException(\"Don't join\");\n\t\t}\n\t}\n\tstatic ArrayList myconv(String str, int no){//only split\n\t\tString splitString = CONVSTR.get(no);\n\t\treturn new ArrayList(Arrays.asList(str.split(splitString)));\n\t}\n\tpublic static void main(String[] args){\n\t\tCONVSTR.put(8, \" \"); CONVSTR.put(9, \"\\n\"); CONVSTR.put(0, \"\");\n\t\tsolve();flush();\n\t}\n\t//Don't have to see. end------------------------------------------\n\tstatic void solve(){//Here is the main function\n ArrayList one = nextIntArray();\n int N = one.get(0);\n int M = one.get(1);\n int L = one.get(2);\n long[][] kyori = new long[N][N];\n long max = (long)Math.pow(10,15);\n for(int i = 0; i < N; i++){\n Arrays.fill(kyori[i], max);\n kyori[i][i] = 0;\n }\n for(int i = 0; i < M; i++){\n ArrayList tmp = nextIntArray();\n kyori[tmp.get(0) - 1][tmp.get(1) - 1] = tmp.get(2);\n kyori[tmp.get(1) - 1][tmp.get(0) - 1] = tmp.get(2);\n }\n for(int k = 0; k < N; k++){\n for(int i = 0; i < N; i++){\n for(int j = 0; j < N; j++){\n if(kyori[i][j] > kyori[i][k] + kyori[k][j]){\n kyori[i][j] = kyori[i][k] + kyori[k][j];\n }\n }\n }\n }\n long[][] count = new long[N][N];\n for(int i = 0; i < N; i++){\n Arrays.fill(count[i], max);\n for(int j = 0; j < N; j++){\n if(kyori[i][j] <= L){\n count[i][j] = 1;\n }else{\n count[i][j] = max;\n }\n }\n count[i][i] = 0;\n }\n for(int k = 0; k < N; k++){\n for(int i = 0; i < N; i++){\n for(int j = 0; j < N; j++){\n if(count[i][j] > count[i][k] + count[k][j]){\n count[i][j] = count[i][k] + count[k][j];\n }\n }\n }\n }\n int Q = nextInt();\n for(int i = 0; i < Q; i++){\n ArrayList query = nextIntArray();\n long getCount = count[query.get(0) - 1][query.get(1) - 1];\n if(getCount >= max){\n getCount = 0;\n }\n myout(getCount - 1);\n }\n\t}\n\t//Method addition frame start\n\n\n\n\t//Method addition frame end\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N towns numbered 1 to N and M roads. The i-th road connects Town A_i and Town B_i bidirectionally and has a length of C_i.\n\nTakahashi will travel between these towns by car, passing through these roads. The fuel tank of his car can contain at most L liters of fuel, and one liter of fuel is consumed for each unit distance traveled. When visiting a town while traveling, he can full the tank (or choose not to do so). Travel that results in the tank becoming empty halfway on the road cannot be done.\n\nProcess the following Q queries:\n\nThe tank is now full. Find the minimum number of times he needs to full his tank while traveling from Town s_i to Town t_i. If Town t_i is unreachable, print -1.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 300\n\n0 \\leq M \\leq \\frac{N(N-1)}{2}\n\n1 \\leq L \\leq 10^9\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n\\left(A_i, B_i\\right) \\neq \\left(A_j, B_j\\right) (if i \\neq j)\n\n\\left(A_i, B_i\\right) \\neq \\left(B_j, A_j\\right) (if i \\neq j)\n\n1 \\leq C_i \\leq 10^9\n\n1 \\leq Q \\leq N\\left(N-1\\right)\n\n1 \\leq s_i, t_i \\leq N\n\ns_i \\neq t_i\n\n\\left(s_i, t_i\\right) \\neq \\left(s_j, t_j\\right) (if i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M L\nA_1 B_1 C_1\n:\nA_M B_M C_M\nQ\ns_1 t_1\n:\ns_Q t_Q\n\nOutput\n\nPrint Q lines.\n\nThe i-th line should contain the minimum number of times the tank needs to be fulled while traveling from Town s_i to Town t_i. If Town t_i is unreachable, the line should contain -1 instead.\n\nSample Input 1\n\n3 2 5\n1 2 3\n2 3 3\n2\n3 2\n1 3\n\nSample Output 1\n\n0\n1\n\nTo travel from Town 3 to Town 2, we can use the second road to reach Town 2 without fueling the tank on the way.\n\nTo travel from Town 1 to Town 3, we can first use the first road to get to Town 2, full the tank, and use the second road to reach Town 3.\n\nSample Input 2\n\n4 0 1\n1\n2 1\n\nSample Output 2\n\n-1\n\nThere may be no road at all.\n\nSample Input 3\n\n5 4 4\n1 2 2\n2 3 2\n3 4 3\n4 5 2\n20\n2 1\n3 1\n4 1\n5 1\n1 2\n3 2\n4 2\n5 2\n1 3\n2 3\n4 3\n5 3\n1 4\n2 4\n3 4\n5 4\n1 5\n2 5\n3 5\n4 5\n\nSample Output 3\n\n0\n0\n1\n2\n0\n0\n1\n2\n0\n0\n0\n1\n1\n1\n0\n0\n2\n2\n1\n0", "sample_input": "3 2 5\n1 2 3\n2 3 3\n2\n3 2\n1 3\n"}, "reference_outputs": ["0\n1\n"], "source_document_id": "p02889", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N towns numbered 1 to N and M roads. The i-th road connects Town A_i and Town B_i bidirectionally and has a length of C_i.\n\nTakahashi will travel between these towns by car, passing through these roads. The fuel tank of his car can contain at most L liters of fuel, and one liter of fuel is consumed for each unit distance traveled. When visiting a town while traveling, he can full the tank (or choose not to do so). Travel that results in the tank becoming empty halfway on the road cannot be done.\n\nProcess the following Q queries:\n\nThe tank is now full. Find the minimum number of times he needs to full his tank while traveling from Town s_i to Town t_i. If Town t_i is unreachable, print -1.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 300\n\n0 \\leq M \\leq \\frac{N(N-1)}{2}\n\n1 \\leq L \\leq 10^9\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n\\left(A_i, B_i\\right) \\neq \\left(A_j, B_j\\right) (if i \\neq j)\n\n\\left(A_i, B_i\\right) \\neq \\left(B_j, A_j\\right) (if i \\neq j)\n\n1 \\leq C_i \\leq 10^9\n\n1 \\leq Q \\leq N\\left(N-1\\right)\n\n1 \\leq s_i, t_i \\leq N\n\ns_i \\neq t_i\n\n\\left(s_i, t_i\\right) \\neq \\left(s_j, t_j\\right) (if i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M L\nA_1 B_1 C_1\n:\nA_M B_M C_M\nQ\ns_1 t_1\n:\ns_Q t_Q\n\nOutput\n\nPrint Q lines.\n\nThe i-th line should contain the minimum number of times the tank needs to be fulled while traveling from Town s_i to Town t_i. If Town t_i is unreachable, the line should contain -1 instead.\n\nSample Input 1\n\n3 2 5\n1 2 3\n2 3 3\n2\n3 2\n1 3\n\nSample Output 1\n\n0\n1\n\nTo travel from Town 3 to Town 2, we can use the second road to reach Town 2 without fueling the tank on the way.\n\nTo travel from Town 1 to Town 3, we can first use the first road to get to Town 2, full the tank, and use the second road to reach Town 3.\n\nSample Input 2\n\n4 0 1\n1\n2 1\n\nSample Output 2\n\n-1\n\nThere may be no road at all.\n\nSample Input 3\n\n5 4 4\n1 2 2\n2 3 2\n3 4 3\n4 5 2\n20\n2 1\n3 1\n4 1\n5 1\n1 2\n3 2\n4 2\n5 2\n1 3\n2 3\n4 3\n5 3\n1 4\n2 4\n3 4\n5 4\n1 5\n2 5\n3 5\n4 5\n\nSample Output 3\n\n0\n0\n1\n2\n0\n0\n1\n2\n0\n0\n0\n1\n1\n1\n0\n0\n2\n2\n1\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4248, "cpu_time_ms": 1176, "memory_kb": 69508}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s230485876", "group_id": "codeNet:p02889", "input_text": "import java.io.*;\nimport java.lang.reflect.Array;\nimport java.util.*;\n\n@SuppressWarnings(\"unused\")\npublic class Main {\n private FastScanner in = new FastScanner(System.in);\n private PrintWriter out = new PrintWriter(System.out);\n final int MOD = (int)1e9+7;\n long ceil(long a, long b){return (a + b - 1) / b;}\n\n void solve() throws Exception{\n int N = in.nextInt(), M = in.nextInt(), L = in.nextInt();\n ArrayList> G = new ArrayList<>();\n long[][] g = new long[N][N];\n long INF = Long.MAX_VALUE / 2;\n for(int i = 0; i < N; i++){\n //G.add(new ArrayList<>());\n Arrays.fill(g[i], INF);\n }\n for(int i = 0; i < M; i++){\n int from = in.nextInt()-1;\n int to = in.nextInt()-1;\n long cost = in.nextLong();\n /*\n G.get(from).add(new Edge(from, to, cost));\n G.get(to).add(new Edge(to, from, cost));\n */\n g[from][to] = cost;\n g[to][from] = cost;\n }\n\n long[][] res = warshallFloyd(g, INF);\n ArrayList> list = new ArrayList<>();\n for(int i = 0; i < N; i++){\n list.add(new ArrayList<>());\n for(int j = 0; j < N; j++){\n if(j == i) continue;\n if(res[i][j] <= L) list.get(i).add(j);\n }\n }\n\n int Q = in.nextInt();\n for(int i = 0; i < Q; i++){\n int s = in.nextInt()-1, t = in.nextInt()-1;\n int[] num = new int[N];\n Arrays.fill(num, Integer.MAX_VALUE / 2);\n ArrayDeque queue = new ArrayDeque();\n queue.addLast(s);\n num[s] = -1;\n\n while(!queue.isEmpty()){\n int v = queue.removeFirst();\n for(int next : list.get(v)){\n if(num[next] > num[v] + 1){\n num[next] = num[v] + 1;\n queue.addLast(next);\n }\n }\n }\n\n out.println(num[t] == Integer.MAX_VALUE / 2 ? \"-1\" : num[t]);\n }\n }\n\n class Edge implements Comparable{\n int from;\n int to;\n long cost;\n public Edge(int f, int t, long c){\n from = f;to = t;cost = c;\n }\n @Override\n public int compareTo(Edge o) {\n return Long.compare(this.cost, o.cost);\n }\n }\n\n long[][] warshallFloyd(long[][] g, long INF){\n int N = g.length;\n long[][] res = new long[N][N];\n for(int i = 0; i < N; i++){\n for(int j = 0; j < N; j++){\n res[i][j] = g[i][j];\n }\n }\n\n for(int k = 0; k < N; k++){\n for(int i = 0; i < N; i++){\n for(int j = 0; j < N; j++){\n if(res[i][k] == INF || res[k][j] == INF) continue;\n res[i][j] = Math.min(res[i][j], res[i][k] + res[k][j]);\n }\n }\n }\n\n return res;\n }\n\n //end solve\n\n public static void main(String[] args) throws Exception {\n new Main().m();\n }\n\n private void m() throws Exception {\n solve();\n out.flush();\n }\n\n static class FastScanner {\n Reader input;\n\n FastScanner() {this(System.in);}\n FastScanner(InputStream stream) {this.input = new BufferedReader(new InputStreamReader(stream));}\n\n int nextInt() {return (int) nextLong();}\n\n long nextLong() {\n try {\n int sign = 1;\n int b = input.read();\n while ((b < '0' || '9' < b) && b != '-' && b != '+') {\n b = input.read();\n }\n if (b == '-') {\n sign = -1;\n b = input.read();\n } else if (b == '+') {\n b = input.read();\n }\n long ret = b - '0';\n while (true) {\n b = input.read();\n if (b < '0' || '9' < b) return ret * sign;\n ret *= 10;\n ret += b - '0';\n }\n } catch (IOException e) {\n e.printStackTrace();\n return -1;\n }\n }\n\n double nextDouble() {\n try {\n double sign = 1;\n int b = input.read();\n while ((b < '0' || '9' < b) && b != '-' && b != '+') {\n b = input.read();\n }\n if (b == '-') {\n sign = -1;\n b = input.read();\n } else if (b == '+') {\n b = input.read();\n }\n double ret = b - '0';\n while (true) {\n b = input.read();\n if (b < '0' || '9' < b) break;\n ret *= 10;\n ret += b - '0';\n }\n if (b != '.') return sign * ret;\n double div = 1;\n b = input.read();\n while ('0' <= b && b <= '9') {\n ret *= 10;\n ret += b - '0';\n div *= 10;\n b = input.read();\n }\n return sign * ret / div;\n } catch (IOException e) {\n e.printStackTrace();\n return Double.NaN;\n }\n }\n\n char nextChar() {\n try {\n int b = input.read();\n while (Character.isWhitespace(b)) {\n b = input.read();\n }\n return (char) b;\n } catch (IOException e) {\n e.printStackTrace();\n return 0;\n }\n }\n\n String nextStr() {\n try {\n StringBuilder sb = new StringBuilder();\n int b = input.read();\n while (Character.isWhitespace(b)) {\n b = input.read();\n }\n while (b != -1 && !Character.isWhitespace(b)) {\n sb.append((char) b);\n b = input.read();\n }\n return sb.toString();\n } catch (IOException e) {\n e.printStackTrace();\n return \"\";\n }\n }\n\n public int[] nextIntArray(int n) {\n int[] res = new int[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextInt();\n }\n return res;\n }\n\n public int[] nextIntArrayDec(int n) {\n int[] res = new int[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextInt() - 1;\n }\n return res;\n }\n\n public int[] nextIntArray1Index(int n) {\n int[] res = new int[n + 1];\n for (int i = 0; i < n; i++) {\n res[i + 1] = nextInt();\n }\n return res;\n }\n\n public long[] nextLongArray(int n) {\n long[] res = new long[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextLong();\n }\n return res;\n }\n\n public long[] nextLongArrayDec(int n) {\n long[] res = new long[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextLong() - 1;\n }\n return res;\n }\n\n public long[] nextLongArray1Index(int n) {\n long[] res = new long[n + 1];\n for (int i = 0; i < n; i++) {\n res[i + 1] = nextLong();\n }\n return res;\n }\n\n public double[] nextDoubleArray(int n) {\n double[] res = new double[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextDouble();\n }\n return res;\n }\n }\n}", "language": "Java", "metadata": {"date": 1571536914, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02889.html", "problem_id": "p02889", "resource_group": "high_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/Java/s230485876.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s230485876", "user_id": "u234826697"}, "prompt_components": {"gold_output": "0\n1\n", "input_to_evaluate": "import java.io.*;\nimport java.lang.reflect.Array;\nimport java.util.*;\n\n@SuppressWarnings(\"unused\")\npublic class Main {\n private FastScanner in = new FastScanner(System.in);\n private PrintWriter out = new PrintWriter(System.out);\n final int MOD = (int)1e9+7;\n long ceil(long a, long b){return (a + b - 1) / b;}\n\n void solve() throws Exception{\n int N = in.nextInt(), M = in.nextInt(), L = in.nextInt();\n ArrayList> G = new ArrayList<>();\n long[][] g = new long[N][N];\n long INF = Long.MAX_VALUE / 2;\n for(int i = 0; i < N; i++){\n //G.add(new ArrayList<>());\n Arrays.fill(g[i], INF);\n }\n for(int i = 0; i < M; i++){\n int from = in.nextInt()-1;\n int to = in.nextInt()-1;\n long cost = in.nextLong();\n /*\n G.get(from).add(new Edge(from, to, cost));\n G.get(to).add(new Edge(to, from, cost));\n */\n g[from][to] = cost;\n g[to][from] = cost;\n }\n\n long[][] res = warshallFloyd(g, INF);\n ArrayList> list = new ArrayList<>();\n for(int i = 0; i < N; i++){\n list.add(new ArrayList<>());\n for(int j = 0; j < N; j++){\n if(j == i) continue;\n if(res[i][j] <= L) list.get(i).add(j);\n }\n }\n\n int Q = in.nextInt();\n for(int i = 0; i < Q; i++){\n int s = in.nextInt()-1, t = in.nextInt()-1;\n int[] num = new int[N];\n Arrays.fill(num, Integer.MAX_VALUE / 2);\n ArrayDeque queue = new ArrayDeque();\n queue.addLast(s);\n num[s] = -1;\n\n while(!queue.isEmpty()){\n int v = queue.removeFirst();\n for(int next : list.get(v)){\n if(num[next] > num[v] + 1){\n num[next] = num[v] + 1;\n queue.addLast(next);\n }\n }\n }\n\n out.println(num[t] == Integer.MAX_VALUE / 2 ? \"-1\" : num[t]);\n }\n }\n\n class Edge implements Comparable{\n int from;\n int to;\n long cost;\n public Edge(int f, int t, long c){\n from = f;to = t;cost = c;\n }\n @Override\n public int compareTo(Edge o) {\n return Long.compare(this.cost, o.cost);\n }\n }\n\n long[][] warshallFloyd(long[][] g, long INF){\n int N = g.length;\n long[][] res = new long[N][N];\n for(int i = 0; i < N; i++){\n for(int j = 0; j < N; j++){\n res[i][j] = g[i][j];\n }\n }\n\n for(int k = 0; k < N; k++){\n for(int i = 0; i < N; i++){\n for(int j = 0; j < N; j++){\n if(res[i][k] == INF || res[k][j] == INF) continue;\n res[i][j] = Math.min(res[i][j], res[i][k] + res[k][j]);\n }\n }\n }\n\n return res;\n }\n\n //end solve\n\n public static void main(String[] args) throws Exception {\n new Main().m();\n }\n\n private void m() throws Exception {\n solve();\n out.flush();\n }\n\n static class FastScanner {\n Reader input;\n\n FastScanner() {this(System.in);}\n FastScanner(InputStream stream) {this.input = new BufferedReader(new InputStreamReader(stream));}\n\n int nextInt() {return (int) nextLong();}\n\n long nextLong() {\n try {\n int sign = 1;\n int b = input.read();\n while ((b < '0' || '9' < b) && b != '-' && b != '+') {\n b = input.read();\n }\n if (b == '-') {\n sign = -1;\n b = input.read();\n } else if (b == '+') {\n b = input.read();\n }\n long ret = b - '0';\n while (true) {\n b = input.read();\n if (b < '0' || '9' < b) return ret * sign;\n ret *= 10;\n ret += b - '0';\n }\n } catch (IOException e) {\n e.printStackTrace();\n return -1;\n }\n }\n\n double nextDouble() {\n try {\n double sign = 1;\n int b = input.read();\n while ((b < '0' || '9' < b) && b != '-' && b != '+') {\n b = input.read();\n }\n if (b == '-') {\n sign = -1;\n b = input.read();\n } else if (b == '+') {\n b = input.read();\n }\n double ret = b - '0';\n while (true) {\n b = input.read();\n if (b < '0' || '9' < b) break;\n ret *= 10;\n ret += b - '0';\n }\n if (b != '.') return sign * ret;\n double div = 1;\n b = input.read();\n while ('0' <= b && b <= '9') {\n ret *= 10;\n ret += b - '0';\n div *= 10;\n b = input.read();\n }\n return sign * ret / div;\n } catch (IOException e) {\n e.printStackTrace();\n return Double.NaN;\n }\n }\n\n char nextChar() {\n try {\n int b = input.read();\n while (Character.isWhitespace(b)) {\n b = input.read();\n }\n return (char) b;\n } catch (IOException e) {\n e.printStackTrace();\n return 0;\n }\n }\n\n String nextStr() {\n try {\n StringBuilder sb = new StringBuilder();\n int b = input.read();\n while (Character.isWhitespace(b)) {\n b = input.read();\n }\n while (b != -1 && !Character.isWhitespace(b)) {\n sb.append((char) b);\n b = input.read();\n }\n return sb.toString();\n } catch (IOException e) {\n e.printStackTrace();\n return \"\";\n }\n }\n\n public int[] nextIntArray(int n) {\n int[] res = new int[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextInt();\n }\n return res;\n }\n\n public int[] nextIntArrayDec(int n) {\n int[] res = new int[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextInt() - 1;\n }\n return res;\n }\n\n public int[] nextIntArray1Index(int n) {\n int[] res = new int[n + 1];\n for (int i = 0; i < n; i++) {\n res[i + 1] = nextInt();\n }\n return res;\n }\n\n public long[] nextLongArray(int n) {\n long[] res = new long[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextLong();\n }\n return res;\n }\n\n public long[] nextLongArrayDec(int n) {\n long[] res = new long[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextLong() - 1;\n }\n return res;\n }\n\n public long[] nextLongArray1Index(int n) {\n long[] res = new long[n + 1];\n for (int i = 0; i < n; i++) {\n res[i + 1] = nextLong();\n }\n return res;\n }\n\n public double[] nextDoubleArray(int n) {\n double[] res = new double[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextDouble();\n }\n return res;\n }\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N towns numbered 1 to N and M roads. The i-th road connects Town A_i and Town B_i bidirectionally and has a length of C_i.\n\nTakahashi will travel between these towns by car, passing through these roads. The fuel tank of his car can contain at most L liters of fuel, and one liter of fuel is consumed for each unit distance traveled. When visiting a town while traveling, he can full the tank (or choose not to do so). Travel that results in the tank becoming empty halfway on the road cannot be done.\n\nProcess the following Q queries:\n\nThe tank is now full. Find the minimum number of times he needs to full his tank while traveling from Town s_i to Town t_i. If Town t_i is unreachable, print -1.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 300\n\n0 \\leq M \\leq \\frac{N(N-1)}{2}\n\n1 \\leq L \\leq 10^9\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n\\left(A_i, B_i\\right) \\neq \\left(A_j, B_j\\right) (if i \\neq j)\n\n\\left(A_i, B_i\\right) \\neq \\left(B_j, A_j\\right) (if i \\neq j)\n\n1 \\leq C_i \\leq 10^9\n\n1 \\leq Q \\leq N\\left(N-1\\right)\n\n1 \\leq s_i, t_i \\leq N\n\ns_i \\neq t_i\n\n\\left(s_i, t_i\\right) \\neq \\left(s_j, t_j\\right) (if i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M L\nA_1 B_1 C_1\n:\nA_M B_M C_M\nQ\ns_1 t_1\n:\ns_Q t_Q\n\nOutput\n\nPrint Q lines.\n\nThe i-th line should contain the minimum number of times the tank needs to be fulled while traveling from Town s_i to Town t_i. If Town t_i is unreachable, the line should contain -1 instead.\n\nSample Input 1\n\n3 2 5\n1 2 3\n2 3 3\n2\n3 2\n1 3\n\nSample Output 1\n\n0\n1\n\nTo travel from Town 3 to Town 2, we can use the second road to reach Town 2 without fueling the tank on the way.\n\nTo travel from Town 1 to Town 3, we can first use the first road to get to Town 2, full the tank, and use the second road to reach Town 3.\n\nSample Input 2\n\n4 0 1\n1\n2 1\n\nSample Output 2\n\n-1\n\nThere may be no road at all.\n\nSample Input 3\n\n5 4 4\n1 2 2\n2 3 2\n3 4 3\n4 5 2\n20\n2 1\n3 1\n4 1\n5 1\n1 2\n3 2\n4 2\n5 2\n1 3\n2 3\n4 3\n5 3\n1 4\n2 4\n3 4\n5 4\n1 5\n2 5\n3 5\n4 5\n\nSample Output 3\n\n0\n0\n1\n2\n0\n0\n1\n2\n0\n0\n0\n1\n1\n1\n0\n0\n2\n2\n1\n0", "sample_input": "3 2 5\n1 2 3\n2 3 3\n2\n3 2\n1 3\n"}, "reference_outputs": ["0\n1\n"], "source_document_id": "p02889", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N towns numbered 1 to N and M roads. The i-th road connects Town A_i and Town B_i bidirectionally and has a length of C_i.\n\nTakahashi will travel between these towns by car, passing through these roads. The fuel tank of his car can contain at most L liters of fuel, and one liter of fuel is consumed for each unit distance traveled. When visiting a town while traveling, he can full the tank (or choose not to do so). Travel that results in the tank becoming empty halfway on the road cannot be done.\n\nProcess the following Q queries:\n\nThe tank is now full. Find the minimum number of times he needs to full his tank while traveling from Town s_i to Town t_i. If Town t_i is unreachable, print -1.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 300\n\n0 \\leq M \\leq \\frac{N(N-1)}{2}\n\n1 \\leq L \\leq 10^9\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n\\left(A_i, B_i\\right) \\neq \\left(A_j, B_j\\right) (if i \\neq j)\n\n\\left(A_i, B_i\\right) \\neq \\left(B_j, A_j\\right) (if i \\neq j)\n\n1 \\leq C_i \\leq 10^9\n\n1 \\leq Q \\leq N\\left(N-1\\right)\n\n1 \\leq s_i, t_i \\leq N\n\ns_i \\neq t_i\n\n\\left(s_i, t_i\\right) \\neq \\left(s_j, t_j\\right) (if i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M L\nA_1 B_1 C_1\n:\nA_M B_M C_M\nQ\ns_1 t_1\n:\ns_Q t_Q\n\nOutput\n\nPrint Q lines.\n\nThe i-th line should contain the minimum number of times the tank needs to be fulled while traveling from Town s_i to Town t_i. If Town t_i is unreachable, the line should contain -1 instead.\n\nSample Input 1\n\n3 2 5\n1 2 3\n2 3 3\n2\n3 2\n1 3\n\nSample Output 1\n\n0\n1\n\nTo travel from Town 3 to Town 2, we can use the second road to reach Town 2 without fueling the tank on the way.\n\nTo travel from Town 1 to Town 3, we can first use the first road to get to Town 2, full the tank, and use the second road to reach Town 3.\n\nSample Input 2\n\n4 0 1\n1\n2 1\n\nSample Output 2\n\n-1\n\nThere may be no road at all.\n\nSample Input 3\n\n5 4 4\n1 2 2\n2 3 2\n3 4 3\n4 5 2\n20\n2 1\n3 1\n4 1\n5 1\n1 2\n3 2\n4 2\n5 2\n1 3\n2 3\n4 3\n5 3\n1 4\n2 4\n3 4\n5 4\n1 5\n2 5\n3 5\n4 5\n\nSample Output 3\n\n0\n0\n1\n2\n0\n0\n1\n2\n0\n0\n0\n1\n1\n1\n0\n0\n2\n2\n1\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7921, "cpu_time_ms": 2108, "memory_kb": 351620}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s131110752", "group_id": "codeNet:p02890", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int nums = sc.nextInt();\n int[] list = new int[nums];\n for(int i = 0; i < nums; i++){\n int num = sc.nextInt();\n list[i]= num;\n }\n Arrays.sort(list);\n System.out.println(nums);\n for (int k= 2; k <= nums ; k++) {\n int[] copied = Arrays.copyOfRange(list, 0, list.length);\n int count = eatCards(k, copied);\n Arrays.sort(list);\n System.out.println(count);\n }\n }\n\n public static int eatCards(int k, int[] list){\n int counter = 0;\n for (int j = 0; j < list.length; j++) {\n int num = k;\n if(list[j]!=-1){\n int first = list[j];\n list[j] = -1;\n num--;\n for(int i= j + 1; i < list.length; i++) {\n if (first != list[i] && list[i] != -1) {\n num--;\n first = list[i];\n list[i] = -1;\n if(num == 0){\n counter++;\n break;\n }\n }\n }\n }\n }\n return counter;\n }\n}\n", "language": "Java", "metadata": {"date": 1572149803, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02890.html", "problem_id": "p02890", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02890/input.txt", "sample_output_relpath": "derived/input_output/data/p02890/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02890/Java/s131110752.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s131110752", "user_id": "u475382171"}, "prompt_components": {"gold_output": "3\n1\n0\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int nums = sc.nextInt();\n int[] list = new int[nums];\n for(int i = 0; i < nums; i++){\n int num = sc.nextInt();\n list[i]= num;\n }\n Arrays.sort(list);\n System.out.println(nums);\n for (int k= 2; k <= nums ; k++) {\n int[] copied = Arrays.copyOfRange(list, 0, list.length);\n int count = eatCards(k, copied);\n Arrays.sort(list);\n System.out.println(count);\n }\n }\n\n public static int eatCards(int k, int[] list){\n int counter = 0;\n for (int j = 0; j < list.length; j++) {\n int num = k;\n if(list[j]!=-1){\n int first = list[j];\n list[j] = -1;\n num--;\n for(int i= j + 1; i < list.length; i++) {\n if (first != list[i] && list[i] != -1) {\n num--;\n first = list[i];\n list[i] = -1;\n if(num == 0){\n counter++;\n break;\n }\n }\n }\n }\n }\n return counter;\n }\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nTakahashi has N cards. The i-th of these cards has an integer A_i written on it.\n\nTakahashi will choose an integer K, and then repeat the following operation some number of times:\n\nChoose exactly K cards such that the integers written on them are all different, and eat those cards. (The eaten cards disappear.)\n\nFor each K = 1,2, \\ldots, N, find the maximum number of times Takahashi can do the operation.\n\nConstraints\n\n1 \\le N \\le 3 \\times 10^5\n\n1 \\le A_i \\le N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint N integers.\nThe t-th (1 \\le t \\le N) of them should be the answer for the case K=t.\n\nSample Input 1\n\n3\n2 1 2\n\nSample Output 1\n\n3\n1\n0\n\nFor K = 1, we can do the operation as follows:\n\nChoose the first card to eat.\n\nChoose the second card to eat.\n\nChoose the third card to eat.\n\nFor K = 2, we can do the operation as follows:\n\nChoose the first and second cards to eat.\n\nFor K = 3, we cannot do the operation at all. Note that we cannot choose the first and third cards at the same time.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n5\n2\n1\n1\n1\n\nSample Input 3\n\n4\n1 3 3 3\n\nSample Output 3\n\n4\n1\n0\n0", "sample_input": "3\n2 1 2\n"}, "reference_outputs": ["3\n1\n0\n"], "source_document_id": "p02890", "source_text": "Score : 600 points\n\nProblem Statement\n\nTakahashi has N cards. The i-th of these cards has an integer A_i written on it.\n\nTakahashi will choose an integer K, and then repeat the following operation some number of times:\n\nChoose exactly K cards such that the integers written on them are all different, and eat those cards. (The eaten cards disappear.)\n\nFor each K = 1,2, \\ldots, N, find the maximum number of times Takahashi can do the operation.\n\nConstraints\n\n1 \\le N \\le 3 \\times 10^5\n\n1 \\le A_i \\le N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint N integers.\nThe t-th (1 \\le t \\le N) of them should be the answer for the case K=t.\n\nSample Input 1\n\n3\n2 1 2\n\nSample Output 1\n\n3\n1\n0\n\nFor K = 1, we can do the operation as follows:\n\nChoose the first card to eat.\n\nChoose the second card to eat.\n\nChoose the third card to eat.\n\nFor K = 2, we can do the operation as follows:\n\nChoose the first and second cards to eat.\n\nFor K = 3, we cannot do the operation at all. Note that we cannot choose the first and third cards at the same time.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n5\n2\n1\n1\n1\n\nSample Input 3\n\n4\n1 3 3 3\n\nSample Output 3\n\n4\n1\n0\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1347, "cpu_time_ms": 2109, "memory_kb": 225364}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s639556798", "group_id": "codeNet:p02897", "input_text": "import java.util.*;\n\npublic class Main{\n\tpublic static void main (String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint counter=0;\n\t\tint N= sc.nextInt();\n\t\tint f = 0;\n\t\tint count = 0;\n\t\tfor(int i = 1; i <= N; i++){\n\t\t\tf = i%2;\n\t\t\tif(f == 1){\n\t\t\t\tcounter+=1;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println((double)counter/N);\n\t}\n}", "language": "Java", "metadata": {"date": 1574421641, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02897.html", "problem_id": "p02897", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02897/input.txt", "sample_output_relpath": "derived/input_output/data/p02897/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02897/Java/s639556798.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s639556798", "user_id": "u863370423"}, "prompt_components": {"gold_output": "0.5000000000\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main{\n\tpublic static void main (String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint counter=0;\n\t\tint N= sc.nextInt();\n\t\tint f = 0;\n\t\tint count = 0;\n\t\tfor(int i = 1; i <= N; i++){\n\t\t\tf = i%2;\n\t\t\tif(f == 1){\n\t\t\t\tcounter+=1;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println((double)counter/N);\n\t}\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer N.\n\nTakahashi chooses an integer a from the positive integers not greater than N with equal probability.\n\nFind the probability that a is odd.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the probability that a is odd.\nYour output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n0.5000000000\n\nThere are four positive integers not greater than 4: 1, 2, 3, and 4. Among them, we have two odd numbers: 1 and 3. Thus, the answer is \\frac{2}{4} = 0.5.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0.6000000000\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1.0000000000", "sample_input": "4\n"}, "reference_outputs": ["0.5000000000\n"], "source_document_id": "p02897", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer N.\n\nTakahashi chooses an integer a from the positive integers not greater than N with equal probability.\n\nFind the probability that a is odd.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the probability that a is odd.\nYour output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n0.5000000000\n\nThere are four positive integers not greater than 4: 1, 2, 3, and 4. Among them, we have two odd numbers: 1 and 3. Thus, the answer is \\frac{2}{4} = 0.5.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0.6000000000\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1.0000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 319, "cpu_time_ms": 95, "memory_kb": 23892}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s230358123", "group_id": "codeNet:p02897", "input_text": "import java.util.*;\npublic class Main{\n public static void main(String [] args){\n Scanner sc = new Scanner(System.in);\n double N = sc.nextInt();\n double a = 0;\nif(N%2 == 0) a = (double)(1.0/2.0);\nelse a = ((int)((N/2)+1))/N;\n \nSystem.out.println(a);\n }\n}\n", "language": "Java", "metadata": {"date": 1569719795, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02897.html", "problem_id": "p02897", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02897/input.txt", "sample_output_relpath": "derived/input_output/data/p02897/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02897/Java/s230358123.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s230358123", "user_id": "u870915337"}, "prompt_components": {"gold_output": "0.5000000000\n", "input_to_evaluate": "import java.util.*;\npublic class Main{\n public static void main(String [] args){\n Scanner sc = new Scanner(System.in);\n double N = sc.nextInt();\n double a = 0;\nif(N%2 == 0) a = (double)(1.0/2.0);\nelse a = ((int)((N/2)+1))/N;\n \nSystem.out.println(a);\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer N.\n\nTakahashi chooses an integer a from the positive integers not greater than N with equal probability.\n\nFind the probability that a is odd.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the probability that a is odd.\nYour output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n0.5000000000\n\nThere are four positive integers not greater than 4: 1, 2, 3, and 4. Among them, we have two odd numbers: 1 and 3. Thus, the answer is \\frac{2}{4} = 0.5.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0.6000000000\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1.0000000000", "sample_input": "4\n"}, "reference_outputs": ["0.5000000000\n"], "source_document_id": "p02897", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer N.\n\nTakahashi chooses an integer a from the positive integers not greater than N with equal probability.\n\nFind the probability that a is odd.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the probability that a is odd.\nYour output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n0.5000000000\n\nThere are four positive integers not greater than 4: 1, 2, 3, and 4. Among them, we have two odd numbers: 1 and 3. Thus, the answer is \\frac{2}{4} = 0.5.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0.6000000000\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1.0000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 289, "cpu_time_ms": 96, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s972082983", "group_id": "codeNet:p02898", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint K = sc.nextInt();\n\t\tint H[] = new int[N];\n\t\tfor(int i = 0 ; i < N ; ++i){\n\t\t\tH[i] = sc.nextInt();\n\t\t}\n\t\tint ret = 0;\n\t\tfor(int h : H){\n\t\t\tif(h >= K){\n\t\t\t\t++ret;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ret);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1569718987, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02898.html", "problem_id": "p02898", "resource_group": "high_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/Java/s972082983.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s972082983", "user_id": "u745266708"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint K = sc.nextInt();\n\t\tint H[] = new int[N];\n\t\tfor(int i = 0 ; i < N ; ++i){\n\t\t\tH[i] = sc.nextInt();\n\t\t}\n\t\tint ret = 0;\n\t\tfor(int h : H){\n\t\t\tif(h >= K){\n\t\t\t\t++ret;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ret);\n\t}\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": 360, "cpu_time_ms": 414, "memory_kb": 49508}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s890454428", "group_id": "codeNet:p02899", "input_text": "import java.util.*;\n\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint h[] = new int[n];\n\t\tint a[] = new int[n];\n\t\tint c = 0;\n\t\t\n\t\tfor(int i = 0;i primes = _primeFactorize(c);\n debug(() -> Arrays.toString(primes.toArray()));\n Set set = new HashSet<>(primes);\n out.println(set.size() + 1);\n }\n\n static final int MOD = 1_000_000_007;\n static long[] fac, finv, inv;\n\n // 階乗(n!)\n static long factorial(long n) {\n long ans = 1;\n for (long i = n; i > 0; i--) {\n ans = ans * i % MOD;\n }\n return ans;\n }\n\n // nCkの初期化\n static void comInit(int max) {\n fac = new long[max];\n finv = new long[max];\n inv = new long[max];\n fac[0] = fac[1] = 1;\n finv[0] = finv[1] = 1;\n inv[1] = 1;\n\n for (int i = 2; i < max; i++) {\n fac[i] = fac[i - 1] * i % MOD;\n inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;\n finv[i] = finv[i - 1] * inv[i] % MOD;\n }\n }\n\n // nCkの計算\n static long com(int n, int k) {\n if (n < k)\n return 0;\n if (n < 0 || k < 0)\n return 0;\n return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;\n }\n\n // 素因数分解\n static List primeFactorize(long n) {\n List list = new ArrayList<>();\n long tmp = n;\n for (int i = 2; i * i <= n; i++) {\n while (true) {\n if (tmp % i == 0) {\n list.add((long) i);\n tmp /= i;\n } else {\n break;\n }\n }\n }\n if (tmp != 1)\n list.add(tmp);\n return list;\n }\n\n static Map> primeFactors = new HashMap<>();\n\n // 素因数分解\n static List _primeFactorize(long n) {\n if (primeFactors.containsKey(n))\n return primeFactors.get(n);\n\n List list = new ArrayList<>();\n if (n % 2 == 0) {\n list.addAll(_primeFactorize(n / 2));\n list.add(2l);\n } else {\n boolean ok = true;\n for (int j = 3; j * j <= n; j += 2) {\n if (n % j == 0) {\n list.addAll(_primeFactorize(n / j));\n list.addAll(_primeFactorize(j));\n ok = false;\n break;\n }\n }\n if (ok) {\n if (n != 1)\n list.add(n);\n }\n }\n\n primeFactors.put(n, Collections.unmodifiableList(list));\n return list;\n }\n\n // 2〜nまでの数値を素因数分解したmapを返す.\n // map: 数値 -> (素因数)\n // ex)\n // 2 -> (2)\n // 4 -> (2,2)\n // 12 -> (2,2,3)\n @Deprecated // primeFactorizeを使うべき\n static Map> primeFactorizeTo(int n) {\n Map> map = new HashMap<>();\n for (int i = 2; i <= n; i++) {\n List list = new ArrayList<>();\n int tmp = i;\n for (int j = i - 1; j > 1; j--) {\n if (tmp % j == 0) {\n if (map.containsKey(j)) {\n list.addAll(map.get(j));\n } else {\n list.add(j);\n }\n tmp /= j;\n }\n }\n if (tmp != 1)\n list.add(tmp);\n map.put(i, list);\n }\n return map;\n }\n\n static PrintWriter out;\n static Scanner sc;\n static boolean debugEnabled;\n static long start;\n static long end;\n\n static int[][] newIntArray(int h, int w, int value) {\n int[][] ret = new int[h][w];\n for (int i = 0; i < h; i++) {\n for (int j = 0; j < w; j++) {\n ret[i][j] = value;\n }\n }\n return ret;\n }\n\n static int nextInt() {\n return Integer.parseInt(sc.next());\n }\n\n static long nextLong() {\n return Long.parseLong(sc.next());\n }\n\n static String nextString() {\n return sc.next();\n }\n\n static int[] nextIntArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = nextInt();\n }\n return a;\n }\n\n static long[] nextLongArray(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++) {\n a[i] = nextLong();\n }\n return a;\n }\n\n static List nextIntList(int n) {\n List list = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n list.add(nextInt());\n }\n return list;\n }\n\n static List nextDoubleList(int n) {\n List list = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n list.add((double) nextInt());\n }\n return list;\n }\n\n static List nextLongList(int n) {\n List list = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n list.add(nextLong());\n }\n return list;\n }\n\n static char[][] nextCharArray(int h, int w) {\n char[][] c = new char[h][w];\n for (int i = 0; i < h; i++) {\n String str = nextString();\n for (int j = 0; j < w; j++) {\n c[i][j] = str.charAt(j);\n }\n }\n return c;\n }\n\n // 昇順\n static > List sort(List list) {\n return sortAsc(list);\n }\n\n // 昇順\n static > List sortAsc(List list) {\n Collections.sort(list);\n return list;\n }\n\n // 降順\n static > List sortDesc(List list) {\n Collections.sort(list, (e1, e2) -> e2.compareTo(e1));\n return list;\n }\n\n // greatest common divisor\n // 最大公約数\n static long gcd(long a, long b) {\n if (b == 0) {\n return a;\n }\n return gcd(b, a % b);\n }\n\n // least common multiple\n // 最小公倍数\n static long lcm(long a, long b) {\n if (a > b) {\n return (a / gcd(a, b)) * b;\n } else {\n return (b / gcd(a, b)) * a;\n }\n }\n\n // least common multiple\n // 最小公倍数\n // 素因数分解されたListを引数とした場合\n static List lcm(List a, List b) {\n List ret = new ArrayList<>(a);\n List tmp = new ArrayList<>(b);\n for (Integer i : a) {\n if (tmp.contains(i))\n tmp.remove(i);\n }\n ret.addAll(tmp);\n return ret;\n }\n\n // baseのn乗を計算を返す\n static int pow(int base, int n) {\n int ret = 1;\n for (int i = 0; i < n; i++) {\n ret *= base;\n }\n return ret;\n }\n\n // return n^k mod m\n static long powMod(long n, long k, long m) {\n if (k == 0) {\n return 1;\n } else if (k % 2 == 1) {\n return powMod(n, k - 1, m) * n % m;\n } else {\n long tmp = powMod(n, k / 2, m);\n return tmp * tmp % m;\n }\n }\n\n // intをlength桁のbit文字列に変換\n static String toBitString(int length, int n) {\n StringBuilder sb = new StringBuilder();\n for (int i = length - 1; i >= 0; i--) {\n if ((n >> i) % 2 == 1) {\n sb.append(\"1\");\n } else {\n sb.append(\"0\");\n }\n }\n return sb.toString();\n }\n\n static void setDebugEnabled() {\n String className = new Object() {\n }.getClass().getEnclosingClass().getSimpleName();\n\n if (!className.equals(\"Main\"))\n debugEnabled = true;\n }\n\n static void debug(String msg) {\n if (debugEnabled)\n System.err.println(msg);\n }\n\n static void debug(Supplier msg) {\n if (debugEnabled)\n System.err.println(msg.get());\n }\n\n static class UnionFind {\n int[] parent;\n\n UnionFind(int n) {\n parent = new int[n];\n init();\n }\n\n void init() {\n for (int i = 0; i < parent.length; i++) {\n parent[i] = i;\n }\n }\n\n int getRoot(int i) {\n if (parent[i] == i) {\n return i;\n } else {\n return parent[i] = getRoot(parent[i]);\n }\n }\n\n boolean isSame(int x, int y) {\n return getRoot(x) == getRoot(y);\n }\n\n void unit(int x, int y) {\n x = getRoot(x);\n y = getRoot(y);\n if (x != y) {\n parent[x] = y;\n }\n\n }\n }\n\n public static void main(String[] args) {\n preProcess();\n // System.exit(0)で終了した場合も、解答を出力するためにはshutdown hookの設定が必要\n // しかし、これを有効化すると100[msec]程度処理時間が長くなる\n // Runtime.getRuntime().addShutdownHook(new Thread(() -> postProcess()));\n solve();\n postProcess();\n }\n\n static void preProcess() {\n start = System.nanoTime();\n setDebugEnabled();\n out = new PrintWriter(System.out);\n sc = new Scanner(System.in);\n }\n\n static void postProcess() {\n out.flush();\n sc.close();\n end = System.nanoTime();\n debug(() -> \"elapsed time: \" + (end - start) / 1_000_000 + \"[msec]\");\n }\n\n}\n", "language": "Java", "metadata": {"date": 1579734140, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02900.html", "problem_id": "p02900", "resource_group": "high_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/Java/s371422851.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s371422851", "user_id": "u752146446"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.PrintWriter;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Scanner;\nimport java.util.Set;\nimport java.util.function.Supplier;\n\npublic class Main {\n\n static void solve() {\n long a = nextLong();\n long b = nextLong();\n\n long c = gcd(a, b);\n debug(\"gcd=\" + c);\n List primes = _primeFactorize(c);\n debug(() -> Arrays.toString(primes.toArray()));\n Set set = new HashSet<>(primes);\n out.println(set.size() + 1);\n }\n\n static final int MOD = 1_000_000_007;\n static long[] fac, finv, inv;\n\n // 階乗(n!)\n static long factorial(long n) {\n long ans = 1;\n for (long i = n; i > 0; i--) {\n ans = ans * i % MOD;\n }\n return ans;\n }\n\n // nCkの初期化\n static void comInit(int max) {\n fac = new long[max];\n finv = new long[max];\n inv = new long[max];\n fac[0] = fac[1] = 1;\n finv[0] = finv[1] = 1;\n inv[1] = 1;\n\n for (int i = 2; i < max; i++) {\n fac[i] = fac[i - 1] * i % MOD;\n inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;\n finv[i] = finv[i - 1] * inv[i] % MOD;\n }\n }\n\n // nCkの計算\n static long com(int n, int k) {\n if (n < k)\n return 0;\n if (n < 0 || k < 0)\n return 0;\n return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;\n }\n\n // 素因数分解\n static List primeFactorize(long n) {\n List list = new ArrayList<>();\n long tmp = n;\n for (int i = 2; i * i <= n; i++) {\n while (true) {\n if (tmp % i == 0) {\n list.add((long) i);\n tmp /= i;\n } else {\n break;\n }\n }\n }\n if (tmp != 1)\n list.add(tmp);\n return list;\n }\n\n static Map> primeFactors = new HashMap<>();\n\n // 素因数分解\n static List _primeFactorize(long n) {\n if (primeFactors.containsKey(n))\n return primeFactors.get(n);\n\n List list = new ArrayList<>();\n if (n % 2 == 0) {\n list.addAll(_primeFactorize(n / 2));\n list.add(2l);\n } else {\n boolean ok = true;\n for (int j = 3; j * j <= n; j += 2) {\n if (n % j == 0) {\n list.addAll(_primeFactorize(n / j));\n list.addAll(_primeFactorize(j));\n ok = false;\n break;\n }\n }\n if (ok) {\n if (n != 1)\n list.add(n);\n }\n }\n\n primeFactors.put(n, Collections.unmodifiableList(list));\n return list;\n }\n\n // 2〜nまでの数値を素因数分解したmapを返す.\n // map: 数値 -> (素因数)\n // ex)\n // 2 -> (2)\n // 4 -> (2,2)\n // 12 -> (2,2,3)\n @Deprecated // primeFactorizeを使うべき\n static Map> primeFactorizeTo(int n) {\n Map> map = new HashMap<>();\n for (int i = 2; i <= n; i++) {\n List list = new ArrayList<>();\n int tmp = i;\n for (int j = i - 1; j > 1; j--) {\n if (tmp % j == 0) {\n if (map.containsKey(j)) {\n list.addAll(map.get(j));\n } else {\n list.add(j);\n }\n tmp /= j;\n }\n }\n if (tmp != 1)\n list.add(tmp);\n map.put(i, list);\n }\n return map;\n }\n\n static PrintWriter out;\n static Scanner sc;\n static boolean debugEnabled;\n static long start;\n static long end;\n\n static int[][] newIntArray(int h, int w, int value) {\n int[][] ret = new int[h][w];\n for (int i = 0; i < h; i++) {\n for (int j = 0; j < w; j++) {\n ret[i][j] = value;\n }\n }\n return ret;\n }\n\n static int nextInt() {\n return Integer.parseInt(sc.next());\n }\n\n static long nextLong() {\n return Long.parseLong(sc.next());\n }\n\n static String nextString() {\n return sc.next();\n }\n\n static int[] nextIntArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = nextInt();\n }\n return a;\n }\n\n static long[] nextLongArray(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++) {\n a[i] = nextLong();\n }\n return a;\n }\n\n static List nextIntList(int n) {\n List list = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n list.add(nextInt());\n }\n return list;\n }\n\n static List nextDoubleList(int n) {\n List list = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n list.add((double) nextInt());\n }\n return list;\n }\n\n static List nextLongList(int n) {\n List list = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n list.add(nextLong());\n }\n return list;\n }\n\n static char[][] nextCharArray(int h, int w) {\n char[][] c = new char[h][w];\n for (int i = 0; i < h; i++) {\n String str = nextString();\n for (int j = 0; j < w; j++) {\n c[i][j] = str.charAt(j);\n }\n }\n return c;\n }\n\n // 昇順\n static > List sort(List list) {\n return sortAsc(list);\n }\n\n // 昇順\n static > List sortAsc(List list) {\n Collections.sort(list);\n return list;\n }\n\n // 降順\n static > List sortDesc(List list) {\n Collections.sort(list, (e1, e2) -> e2.compareTo(e1));\n return list;\n }\n\n // greatest common divisor\n // 最大公約数\n static long gcd(long a, long b) {\n if (b == 0) {\n return a;\n }\n return gcd(b, a % b);\n }\n\n // least common multiple\n // 最小公倍数\n static long lcm(long a, long b) {\n if (a > b) {\n return (a / gcd(a, b)) * b;\n } else {\n return (b / gcd(a, b)) * a;\n }\n }\n\n // least common multiple\n // 最小公倍数\n // 素因数分解されたListを引数とした場合\n static List lcm(List a, List b) {\n List ret = new ArrayList<>(a);\n List tmp = new ArrayList<>(b);\n for (Integer i : a) {\n if (tmp.contains(i))\n tmp.remove(i);\n }\n ret.addAll(tmp);\n return ret;\n }\n\n // baseのn乗を計算を返す\n static int pow(int base, int n) {\n int ret = 1;\n for (int i = 0; i < n; i++) {\n ret *= base;\n }\n return ret;\n }\n\n // return n^k mod m\n static long powMod(long n, long k, long m) {\n if (k == 0) {\n return 1;\n } else if (k % 2 == 1) {\n return powMod(n, k - 1, m) * n % m;\n } else {\n long tmp = powMod(n, k / 2, m);\n return tmp * tmp % m;\n }\n }\n\n // intをlength桁のbit文字列に変換\n static String toBitString(int length, int n) {\n StringBuilder sb = new StringBuilder();\n for (int i = length - 1; i >= 0; i--) {\n if ((n >> i) % 2 == 1) {\n sb.append(\"1\");\n } else {\n sb.append(\"0\");\n }\n }\n return sb.toString();\n }\n\n static void setDebugEnabled() {\n String className = new Object() {\n }.getClass().getEnclosingClass().getSimpleName();\n\n if (!className.equals(\"Main\"))\n debugEnabled = true;\n }\n\n static void debug(String msg) {\n if (debugEnabled)\n System.err.println(msg);\n }\n\n static void debug(Supplier msg) {\n if (debugEnabled)\n System.err.println(msg.get());\n }\n\n static class UnionFind {\n int[] parent;\n\n UnionFind(int n) {\n parent = new int[n];\n init();\n }\n\n void init() {\n for (int i = 0; i < parent.length; i++) {\n parent[i] = i;\n }\n }\n\n int getRoot(int i) {\n if (parent[i] == i) {\n return i;\n } else {\n return parent[i] = getRoot(parent[i]);\n }\n }\n\n boolean isSame(int x, int y) {\n return getRoot(x) == getRoot(y);\n }\n\n void unit(int x, int y) {\n x = getRoot(x);\n y = getRoot(y);\n if (x != y) {\n parent[x] = y;\n }\n\n }\n }\n\n public static void main(String[] args) {\n preProcess();\n // System.exit(0)で終了した場合も、解答を出力するためにはshutdown hookの設定が必要\n // しかし、これを有効化すると100[msec]程度処理時間が長くなる\n // Runtime.getRuntime().addShutdownHook(new Thread(() -> postProcess()));\n solve();\n postProcess();\n }\n\n static void preProcess() {\n start = System.nanoTime();\n setDebugEnabled();\n out = new PrintWriter(System.out);\n sc = new Scanner(System.in);\n }\n\n static void postProcess() {\n out.flush();\n sc.close();\n end = System.nanoTime();\n debug(() -> \"elapsed time: \" + (end - start) / 1_000_000 + \"[msec]\");\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": 9862, "cpu_time_ms": 2108, "memory_kb": 27092}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s283149148", "group_id": "codeNet:p02900", "input_text": "import java.util.Scanner;\nimport java.util.ArrayDeque;\nimport java.util.Deque;\n \nclass Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n long a = sc.nextLong();\n long b = sc.nextLong();\n int count = 0;\n long max = a;\n if(a < b)\n max = b;\n \n for(int i = 2; i*i <= max ; i++){\n if(a % i == 0 && b % i == 0)\n count += 1;\n while(a % i == 0){\n a /= i;\n }\n while(b % i == 0){\n b /= i;\n }\n }\n System.out.println(count+1);\n }\n}", "language": "Java", "metadata": {"date": 1569807364, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02900.html", "problem_id": "p02900", "resource_group": "high_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/Java/s283149148.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s283149148", "user_id": "u540144742"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner;\nimport java.util.ArrayDeque;\nimport java.util.Deque;\n \nclass Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n long a = sc.nextLong();\n long b = sc.nextLong();\n int count = 0;\n long max = a;\n if(a < b)\n max = b;\n \n for(int i = 2; i*i <= max ; i++){\n if(a % i == 0 && b % i == 0)\n count += 1;\n while(a % i == 0){\n a /= i;\n }\n while(b % i == 0){\n b /= i;\n }\n }\n System.out.println(count+1);\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": 634, "cpu_time_ms": 2108, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s383549605", "group_id": "codeNet:p02900", "input_text": "package antbook.p0;\n\nimport java.util.Scanner;\n\npublic class Main {\n\n long a;\n long b;\n\n Main(long a, long b) {\n this.a = a;\n this.b = b;\n }\n\n /**\n * \n * @return greeting message\n */\n public int solve() {\n\n // max integer requred\n int UPPER_BOUND = (int) (Math.sqrt(Math.max(a, b)));\n\n // prime sieve\n boolean[] isPrime = new boolean[UPPER_BOUND];\n\n // prime list\n int[] plist = new int[UPPER_BOUND];\n\n isPrime[0] = false;\n isPrime[1] = false;\n for (int i = 2; i < UPPER_BOUND; i++) {\n isPrime[i] = true;\n }\n\n int c = 0;\n for (int i = 2; i < UPPER_BOUND; i++) {\n if (isPrime[i]) {\n plist[c++] = i;\n for (int j = i * 2; j < UPPER_BOUND; j += i) {\n isPrime[j] = false;\n }\n }\n }\n\n int ans = 1;\n\n for (int i = 0; i < c; i++) {\n if (a % plist[i] == 0 && b % plist[i] == 0) {\n ans++;\n }\n }\n\n return ans;\n }\n\n public static void main(String[] args) {\n\n // input\n Scanner sc = new Scanner(System.in);\n long a = sc.nextLong();\n long b = sc.nextLong();\n sc.close();\n\n // solve\n int p = new Main(a, b).solve();\n\n // display\n System.out.println(p);\n }\n\n}\n", "language": "Java", "metadata": {"date": 1569725405, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02900.html", "problem_id": "p02900", "resource_group": "high_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/Java/s383549605.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s383549605", "user_id": "u577170763"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "package antbook.p0;\n\nimport java.util.Scanner;\n\npublic class Main {\n\n long a;\n long b;\n\n Main(long a, long b) {\n this.a = a;\n this.b = b;\n }\n\n /**\n * \n * @return greeting message\n */\n public int solve() {\n\n // max integer requred\n int UPPER_BOUND = (int) (Math.sqrt(Math.max(a, b)));\n\n // prime sieve\n boolean[] isPrime = new boolean[UPPER_BOUND];\n\n // prime list\n int[] plist = new int[UPPER_BOUND];\n\n isPrime[0] = false;\n isPrime[1] = false;\n for (int i = 2; i < UPPER_BOUND; i++) {\n isPrime[i] = true;\n }\n\n int c = 0;\n for (int i = 2; i < UPPER_BOUND; i++) {\n if (isPrime[i]) {\n plist[c++] = i;\n for (int j = i * 2; j < UPPER_BOUND; j += i) {\n isPrime[j] = false;\n }\n }\n }\n\n int ans = 1;\n\n for (int i = 0; i < c; i++) {\n if (a % plist[i] == 0 && b % plist[i] == 0) {\n ans++;\n }\n }\n\n return ans;\n }\n\n public static void main(String[] args) {\n\n // input\n Scanner sc = new Scanner(System.in);\n long a = sc.nextLong();\n long b = sc.nextLong();\n sc.close();\n\n // solve\n int p = new Main(a, b).solve();\n\n // display\n System.out.println(p);\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": 1412, "cpu_time_ms": 79, "memory_kb": 21972}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s867466790", "group_id": "codeNet:p02900", "input_text": "import java.io.*;\nimport java.util.*;\n\npublic class Main\n{\n PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));\n BufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer tok;\n\n public void go() throws IOException\n {\n boolean[] isPrime = new boolean[1001000];\n Arrays.fill(isPrime, true);\n isPrime[0] = false;\n isPrime[1] = false;\n for (int i = 2; i < isPrime.length; i++)\n {\n if (!isPrime[i])\n {\n continue;\n }\n for (int j = i*2; j < isPrime.length; j += i)\n {\n isPrime[j] = false;\n }\n }\n int p = 0;\n int[] primes = new int[100000];\n for (int i = 0; i < isPrime.length; i++)\n {\n if (isPrime[i])\n {\n primes[p] = i;\n p++;\n }\n }\n\n ntok();\n long a = lpar();\n long b = lpar();\n long gcd = gcd(a, b);\n // out.println(gcd);\n long count = 0;\n HashSet set = new HashSet<>();\n long[] freq = new long[100000];\n for (int i = 0; i < p; i++)\n {\n while (gcd % primes[i] == 0)\n {\n freq[i]++;\n count++;\n set.add((long)primes[i]);\n gcd /= primes[i];\n }\n }\n set.add(1L);\n set.add(gcd);\n long sum = count * (count + 1) / 2;\n for (int i = 0; i < freq.length; i++)\n {\n sum -= freq[i] * (freq[i]-1) / 2;\n }\n out.println(set.size());\n\n out.flush();\n in.close();\n }\n\n public long gcd(long a, long b)\n {\n if (b == 0)\n {\n return a;\n }\n return gcd(b, a%b);\n }\n\n public void ntok() throws IOException\n {\n tok = new StringTokenizer(in.readLine());\n }\n\n public int ipar()\n {\n return Integer.parseInt(tok.nextToken());\n }\n\n public int[] iapar(int n)\n {\n int[] arr = new int[n];\n for (int i = 0; i < n; i++)\n {\n arr[i] = ipar();\n }\n return arr;\n }\n\n public long lpar()\n {\n return Long.parseLong(tok.nextToken());\n }\n\n public long[] lapar(int n)\n {\n long[] arr = new long[n];\n for (int i = 0; i < n; i++)\n {\n arr[i] = lpar();\n }\n return arr;\n }\n\n public double dpar()\n {\n return Double.parseDouble(tok.nextToken());\n }\n\n public String spar()\n {\n return tok.nextToken();\n }\n\n public static void main(String[] args) throws IOException\n {\n new Main().go();\n }\n}\n", "language": "Java", "metadata": {"date": 1569720434, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02900.html", "problem_id": "p02900", "resource_group": "high_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/Java/s867466790.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s867466790", "user_id": "u169500433"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\n\npublic class Main\n{\n PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));\n BufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer tok;\n\n public void go() throws IOException\n {\n boolean[] isPrime = new boolean[1001000];\n Arrays.fill(isPrime, true);\n isPrime[0] = false;\n isPrime[1] = false;\n for (int i = 2; i < isPrime.length; i++)\n {\n if (!isPrime[i])\n {\n continue;\n }\n for (int j = i*2; j < isPrime.length; j += i)\n {\n isPrime[j] = false;\n }\n }\n int p = 0;\n int[] primes = new int[100000];\n for (int i = 0; i < isPrime.length; i++)\n {\n if (isPrime[i])\n {\n primes[p] = i;\n p++;\n }\n }\n\n ntok();\n long a = lpar();\n long b = lpar();\n long gcd = gcd(a, b);\n // out.println(gcd);\n long count = 0;\n HashSet set = new HashSet<>();\n long[] freq = new long[100000];\n for (int i = 0; i < p; i++)\n {\n while (gcd % primes[i] == 0)\n {\n freq[i]++;\n count++;\n set.add((long)primes[i]);\n gcd /= primes[i];\n }\n }\n set.add(1L);\n set.add(gcd);\n long sum = count * (count + 1) / 2;\n for (int i = 0; i < freq.length; i++)\n {\n sum -= freq[i] * (freq[i]-1) / 2;\n }\n out.println(set.size());\n\n out.flush();\n in.close();\n }\n\n public long gcd(long a, long b)\n {\n if (b == 0)\n {\n return a;\n }\n return gcd(b, a%b);\n }\n\n public void ntok() throws IOException\n {\n tok = new StringTokenizer(in.readLine());\n }\n\n public int ipar()\n {\n return Integer.parseInt(tok.nextToken());\n }\n\n public int[] iapar(int n)\n {\n int[] arr = new int[n];\n for (int i = 0; i < n; i++)\n {\n arr[i] = ipar();\n }\n return arr;\n }\n\n public long lpar()\n {\n return Long.parseLong(tok.nextToken());\n }\n\n public long[] lapar(int n)\n {\n long[] arr = new long[n];\n for (int i = 0; i < n; i++)\n {\n arr[i] = lpar();\n }\n return arr;\n }\n\n public double dpar()\n {\n return Double.parseDouble(tok.nextToken());\n }\n\n public String spar()\n {\n return tok.nextToken();\n }\n\n public static void main(String[] args) throws IOException\n {\n new Main().go();\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": 2762, "cpu_time_ms": 134, "memory_kb": 24532}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s291776169", "group_id": "codeNet:p02909", "input_text": "import java.util.*;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\t\n\t\tScanner sc=new Scanner(System.in);\n\t\tString s=sc.next();\n\t\t\n\t\tString s1=\"Sunny\";\n\t\tString s2=\"Cloudy\";\n\t\tString s3=\"Rainy\";\n\t\tif(s.equals(s1)){\n\t\t\tSystem.out.println(s2);\n\t\t}else if(s.equals(s2)){\n\t\t\tSystem.out.println(s3);\n\t\t}else\n\t\t\tSystem.out.println(s1);\n\t\t\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1569459370, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02909.html", "problem_id": "p02909", "resource_group": "high_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/Java/s291776169.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s291776169", "user_id": "u816631826"}, "prompt_components": {"gold_output": "Cloudy\n", "input_to_evaluate": "import java.util.*;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\t\n\t\tScanner sc=new Scanner(System.in);\n\t\tString s=sc.next();\n\t\t\n\t\tString s1=\"Sunny\";\n\t\tString s2=\"Cloudy\";\n\t\tString s3=\"Rainy\";\n\t\tif(s.equals(s1)){\n\t\t\tSystem.out.println(s2);\n\t\t}else if(s.equals(s2)){\n\t\t\tSystem.out.println(s3);\n\t\t}else\n\t\t\tSystem.out.println(s1);\n\t\t\n\t}\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": 393, "cpu_time_ms": 89, "memory_kb": 21716}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s427977473", "group_id": "codeNet:p02909", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args ) throws Exception {\n Scanner sc = new Scanner(System.in);\n String N = sc.next();\n if(N.equals(\"Sunny\")){\n \tSystem.out.println(\"Cloudy\");\n }else if(N.equals(\"Cloudy\")){\n \tSystem.out.println(\"Rainy\");\n }else{\n \tSystem.out.println(\"Sunny\");\n }\n }\n}", "language": "Java", "metadata": {"date": 1568595921, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02909.html", "problem_id": "p02909", "resource_group": "high_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/Java/s427977473.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s427977473", "user_id": "u143789605"}, "prompt_components": {"gold_output": "Cloudy\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args ) throws Exception {\n Scanner sc = new Scanner(System.in);\n String N = sc.next();\n if(N.equals(\"Sunny\")){\n \tSystem.out.println(\"Cloudy\");\n }else if(N.equals(\"Cloudy\")){\n \tSystem.out.println(\"Rainy\");\n }else{\n \tSystem.out.println(\"Sunny\");\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": 355, "cpu_time_ms": 113, "memory_kb": 22228}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s607258996", "group_id": "codeNet:p02911", "input_text": "import java.util.Scanner;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint participants = sc.nextInt(); //参加者数\n\t\tint point = sc.nextInt(); //ポイント\n\t\tint questions = sc.nextInt(); //問題数\n\t\tint winner[] = new int[questions]; //問題ごとに正解した人の番号\n\n\t\t//問題ごとに正解した参加者の番号を代入\n\t\tfor(int i : winner) {\n\t\t\twinner[i] = sc.nextInt();\n\t\t}\n\n\t\t//「要素番号=参加者番号」の配列に得点を入れる\n\t\tint result[] = new int[participants];\n\t\tfor(int i : result) {\n\t\t\tresult[i] = point;\n\t\t}\n\n\t\t//問題ごとに正解してない参加者番号の人のポイントから-1\n\t\tfor(int i : winner) {\n\t\t\tfor(int j : result) {\n\t\t\t\tif(winner[i] != j) {\n\t\t\t\t\tresult[j] -=1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor(int i : result) {\n\t\tSystem.out.println(result[i] > 0 ? \"Yes\" : \"No\");\n\t\t}\n\t}\n}\n", "language": "Java", "metadata": {"date": 1593118957, "filename_ext": "java", "original_language": "Java (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02911.html", "problem_id": "p02911", "resource_group": "high_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/Java/s607258996.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s607258996", "user_id": "u824555610"}, "prompt_components": {"gold_output": "No\nNo\nYes\nNo\nNo\nNo\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint participants = sc.nextInt(); //参加者数\n\t\tint point = sc.nextInt(); //ポイント\n\t\tint questions = sc.nextInt(); //問題数\n\t\tint winner[] = new int[questions]; //問題ごとに正解した人の番号\n\n\t\t//問題ごとに正解した参加者の番号を代入\n\t\tfor(int i : winner) {\n\t\t\twinner[i] = sc.nextInt();\n\t\t}\n\n\t\t//「要素番号=参加者番号」の配列に得点を入れる\n\t\tint result[] = new int[participants];\n\t\tfor(int i : result) {\n\t\t\tresult[i] = point;\n\t\t}\n\n\t\t//問題ごとに正解してない参加者番号の人のポイントから-1\n\t\tfor(int i : winner) {\n\t\t\tfor(int j : result) {\n\t\t\t\tif(winner[i] != j) {\n\t\t\t\t\tresult[j] -=1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor(int i : result) {\n\t\tSystem.out.println(result[i] > 0 ? \"Yes\" : \"No\");\n\t\t}\n\t}\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": 903, "cpu_time_ms": 364, "memory_kb": 49508}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s970326312", "group_id": "codeNet:p02915", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.util.StringTokenizer;\n\npublic class Main {\n public static void main(String[] args) {\n FastReader sc = new FastReader(System.in);\n System.out.println((int)Math.pow(sc.nextInt(), 3));\n }\n static class FastReader\n {\n BufferedReader br;\n StringTokenizer st;\n public FastReader(InputStream x) {\n br = new BufferedReader(new\n InputStreamReader(x));\n\n }\n\n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n }\n catch (IOException e)\n {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt()\n {\n return Integer.parseInt(next());\n }\n\n long nextLong()\n {\n return Long.parseLong(next());\n }\n\n double nextDouble()\n {\n return Double.parseDouble(next());\n }\n\n String nextLine()\n {\n String str = \"\";\n try\n {\n str = br.readLine();\n }\n catch (IOException e)\n {\n e.printStackTrace();\n }\n return str;\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1571391353, "filename_ext": "java", "original_language": "Java7 (OpenJDK 1.7.0)", "problem_description_relpath": "problem_descriptions/p02915.html", "problem_id": "p02915", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02915/input.txt", "sample_output_relpath": "derived/input_output/data/p02915/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02915/Java/s970326312.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s970326312", "user_id": "u126434371"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.util.StringTokenizer;\n\npublic class Main {\n public static void main(String[] args) {\n FastReader sc = new FastReader(System.in);\n System.out.println((int)Math.pow(sc.nextInt(), 3));\n }\n static class FastReader\n {\n BufferedReader br;\n StringTokenizer st;\n public FastReader(InputStream x) {\n br = new BufferedReader(new\n InputStreamReader(x));\n\n }\n\n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n }\n catch (IOException e)\n {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt()\n {\n return Integer.parseInt(next());\n }\n\n long nextLong()\n {\n return Long.parseLong(next());\n }\n\n double nextDouble()\n {\n return Double.parseDouble(next());\n }\n\n String nextLine()\n {\n String str = \"\";\n try\n {\n str = br.readLine();\n }\n catch (IOException e)\n {\n e.printStackTrace();\n }\n return str;\n }\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is going to set a 3-character password.\n\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\nConstraints\n\n1 \\leq N \\leq 9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of possible passwords.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nThere are eight possible passwords: 111, 112, 121, 122, 211, 212, 221, and 222.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nThere is only one possible password if you can only use one kind of character.", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02915", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is going to set a 3-character password.\n\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\nConstraints\n\n1 \\leq N \\leq 9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of possible passwords.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nThere are eight possible passwords: 111, 112, 121, 122, 211, 212, 221, and 222.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nThere is only one possible password if you can only use one kind of character.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1482, "cpu_time_ms": 77, "memory_kb": 20820}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s666101552", "group_id": "codeNet:p02916", "input_text": "\nimport java.util.Scanner;\n\npublic class Main {\n static final Scanner sc = new Scanner(System.in);\n static final int MOD = (int) 1E9 + 7;\n \n public static void main(String[] args) {\n int N = nint();\n int[] A = nints(N, 1, 0);\n int[] B = nints(N, 1, 0);\n int[] C = nints(N-1, 1, 0);\n int ans = 0;\n \n for (int i = 1; i <= N; i++) {\n ans += B[A[i]];\n if (i > 1 && A[i] == A[i-1] + 1) {\n ans += C[A[i-1]];\n }\n }\n System.out.println(ans);\n }\n\n private static long nlong() {\n return sc.nextLong();\n }\n\n private static int nint() {\n return sc.nextInt();\n }\n\n private static String nstr() {\n return sc.next();\n }\n\n private static char[] nchars() {\n return sc.next().toCharArray();\n }\n\n private static int[] nints(int n) {\n return nints(n, 0, 0);\n }\n\n private static int[] nints(int n, int padL, int padR) {\n int[] a = new int[padL + n + padR];\n for (int i = 0; i < n; i++)\n a[padL + i] = nint();\n return a;\n }\n\n private static char[][] nchars2(int h, int w) {\n return nchars2(h, w, 0);\n }\n\n private static char[][] nchars2(int h, int w, int pad) {\n char[][] a2 = new char[h + pad * 2][w + pad * 2];\n for (int i = 0; i < h; i++)\n System.arraycopy(nchars(), 0, a2[pad + i], pad, w);\n return a2;\n }\n}\n", "language": "Java", "metadata": {"date": 1567904807, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02916.html", "problem_id": "p02916", "resource_group": "high_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/Java/s666101552.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s666101552", "user_id": "u228127260"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "\nimport java.util.Scanner;\n\npublic class Main {\n static final Scanner sc = new Scanner(System.in);\n static final int MOD = (int) 1E9 + 7;\n \n public static void main(String[] args) {\n int N = nint();\n int[] A = nints(N, 1, 0);\n int[] B = nints(N, 1, 0);\n int[] C = nints(N-1, 1, 0);\n int ans = 0;\n \n for (int i = 1; i <= N; i++) {\n ans += B[A[i]];\n if (i > 1 && A[i] == A[i-1] + 1) {\n ans += C[A[i-1]];\n }\n }\n System.out.println(ans);\n }\n\n private static long nlong() {\n return sc.nextLong();\n }\n\n private static int nint() {\n return sc.nextInt();\n }\n\n private static String nstr() {\n return sc.next();\n }\n\n private static char[] nchars() {\n return sc.next().toCharArray();\n }\n\n private static int[] nints(int n) {\n return nints(n, 0, 0);\n }\n\n private static int[] nints(int n, int padL, int padR) {\n int[] a = new int[padL + n + padR];\n for (int i = 0; i < n; i++)\n a[padL + i] = nint();\n return a;\n }\n\n private static char[][] nchars2(int h, int w) {\n return nchars2(h, w, 0);\n }\n\n private static char[][] nchars2(int h, int w, int pad) {\n char[][] a2 = new char[h + pad * 2][w + pad * 2];\n for (int i = 0; i < h; i++)\n System.arraycopy(nchars(), 0, a2[pad + i], pad, w);\n return a2;\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": 1470, "cpu_time_ms": 106, "memory_kb": 22612}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s140890304", "group_id": "codeNet:p02917", "input_text": "import java.io.PrintWriter;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = Integer.parseInt(sc.next());\n int[] B = new int[N - 1];\n int A = 0;\n\n for (int i = 0; i < N - 1; i++) {\n B[i] = Integer.parseInt(sc.next());\n }\n\n A += B[0];\n for (int i = 1; i < N - 1; i++) {\n A += Math.min(B[i - 1], B[i]);\n }\n A += B[N - 2];\n\n PrintWriter out = new PrintWriter(System.out);\n out.println(A);\n\n sc.close();\n out.flush();\n }\n}", "language": "Java", "metadata": {"date": 1593479277, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02917.html", "problem_id": "p02917", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02917/input.txt", "sample_output_relpath": "derived/input_output/data/p02917/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02917/Java/s140890304.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s140890304", "user_id": "u751558844"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.io.PrintWriter;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = Integer.parseInt(sc.next());\n int[] B = new int[N - 1];\n int A = 0;\n\n for (int i = 0; i < N - 1; i++) {\n B[i] = Integer.parseInt(sc.next());\n }\n\n A += B[0];\n for (int i = 1; i < N - 1; i++) {\n A += Math.min(B[i - 1], B[i]);\n }\n A += B[N - 2];\n\n PrintWriter out = new PrintWriter(System.out);\n out.println(A);\n\n sc.close();\n out.flush();\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is an integer sequence A of length N whose values are unknown.\n\nGiven is an integer sequence B of length N-1 which is known to satisfy the following:\n\nB_i \\geq \\max(A_i, A_{i+1})\n\nFind the maximum possible sum of the elements of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n0 \\leq B_i \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nB_1 B_2 ... B_{N-1}\n\nOutput\n\nPrint the maximum possible sum of the elements of A.\n\nSample Input 1\n\n3\n2 5\n\nSample Output 1\n\n9\n\nA can be, for example, ( 2 , 1 , 5 ), ( -1 , -2 , -3 ), or ( 2 , 2 , 5 ). Among those candidates, A = ( 2 , 2 , 5 ) has the maximum possible sum.\n\nSample Input 2\n\n2\n3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n6\n0 153 10 10 23\n\nSample Output 3\n\n53", "sample_input": "3\n2 5\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02917", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is an integer sequence A of length N whose values are unknown.\n\nGiven is an integer sequence B of length N-1 which is known to satisfy the following:\n\nB_i \\geq \\max(A_i, A_{i+1})\n\nFind the maximum possible sum of the elements of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n0 \\leq B_i \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nB_1 B_2 ... B_{N-1}\n\nOutput\n\nPrint the maximum possible sum of the elements of A.\n\nSample Input 1\n\n3\n2 5\n\nSample Output 1\n\n9\n\nA can be, for example, ( 2 , 1 , 5 ), ( -1 , -2 , -3 ), or ( 2 , 2 , 5 ). Among those candidates, A = ( 2 , 2 , 5 ) has the maximum possible sum.\n\nSample Input 2\n\n2\n3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n6\n0 153 10 10 23\n\nSample Output 3\n\n53", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 631, "cpu_time_ms": 119, "memory_kb": 35696}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s683565503", "group_id": "codeNet:p02917", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = Integer.parseInt(sc.next());\n int[] aryb = new int[n - 1];\n int ans = 0;\n for (int i = 0; i < n - 1; i++) {\n int a = Integer.parseInt(sc.next());\n aryb[i] = a;\n }\n for (int i = n - 2; i >= 0; i--) {\n if (i == n - 2) {\n ans += aryb[i];\n }\n if (i == 0) {\n ans += aryb[i];\n } else {\n ans += Math.min(aryb[i], aryb[i - 1]);\n }\n }\n System.out.println(ans);\n }\n}", "language": "Java", "metadata": {"date": 1567907582, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02917.html", "problem_id": "p02917", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02917/input.txt", "sample_output_relpath": "derived/input_output/data/p02917/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02917/Java/s683565503.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s683565503", "user_id": "u522656211"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = Integer.parseInt(sc.next());\n int[] aryb = new int[n - 1];\n int ans = 0;\n for (int i = 0; i < n - 1; i++) {\n int a = Integer.parseInt(sc.next());\n aryb[i] = a;\n }\n for (int i = n - 2; i >= 0; i--) {\n if (i == n - 2) {\n ans += aryb[i];\n }\n if (i == 0) {\n ans += aryb[i];\n } else {\n ans += Math.min(aryb[i], aryb[i - 1]);\n }\n }\n System.out.println(ans);\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is an integer sequence A of length N whose values are unknown.\n\nGiven is an integer sequence B of length N-1 which is known to satisfy the following:\n\nB_i \\geq \\max(A_i, A_{i+1})\n\nFind the maximum possible sum of the elements of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n0 \\leq B_i \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nB_1 B_2 ... B_{N-1}\n\nOutput\n\nPrint the maximum possible sum of the elements of A.\n\nSample Input 1\n\n3\n2 5\n\nSample Output 1\n\n9\n\nA can be, for example, ( 2 , 1 , 5 ), ( -1 , -2 , -3 ), or ( 2 , 2 , 5 ). Among those candidates, A = ( 2 , 2 , 5 ) has the maximum possible sum.\n\nSample Input 2\n\n2\n3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n6\n0 153 10 10 23\n\nSample Output 3\n\n53", "sample_input": "3\n2 5\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02917", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is an integer sequence A of length N whose values are unknown.\n\nGiven is an integer sequence B of length N-1 which is known to satisfy the following:\n\nB_i \\geq \\max(A_i, A_{i+1})\n\nFind the maximum possible sum of the elements of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n0 \\leq B_i \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nB_1 B_2 ... B_{N-1}\n\nOutput\n\nPrint the maximum possible sum of the elements of A.\n\nSample Input 1\n\n3\n2 5\n\nSample Output 1\n\n9\n\nA can be, for example, ( 2 , 1 , 5 ), ( -1 , -2 , -3 ), or ( 2 , 2 , 5 ). Among those candidates, A = ( 2 , 2 , 5 ) has the maximum possible sum.\n\nSample Input 2\n\n2\n3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n6\n0 153 10 10 23\n\nSample Output 3\n\n53", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 684, "cpu_time_ms": 106, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s946013740", "group_id": "codeNet:p02919", "input_text": "import java.io.*;\nimport java.util.*;\n\npublic class Main implements Runnable {\n\tFastReader scn;\n\tPrintWriter out;\n\tString INPUT = \"\";\n\n\tvoid solve() {\n\t\tint n = scn.nextInt();\n\t\tint[] arr = new int[n + 2];\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\tarr[i] = scn.nextInt();\n\t\t}\n\t\tarr[n + 1] = (int) 1e6;\n\n\t\tn++;\n\t\tint[] st = new int[n + 1], left = new int[n + 1], right = new int[n + 1];\n\n\t\tint top = -1;\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\twhile (top != -1 && arr[st[top]] < arr[i]) {\n\t\t\t\ttop--;\n\t\t\t}\n\t\t\tleft[i] = top == -1 ? 0 : st[top];\n\t\t\tst[++top] = i;\n\t\t}\n\n\t\ttop = -1;\n\t\tfor (int i = n; i > 0; i--) {\n\t\t\twhile (top != -1 && arr[st[top]] < arr[i]) {\n\t\t\t\ttop--;\n\t\t\t}\n\t\t\tright[i] = top == -1 ? n + 1 : st[top];\n\t\t\tst[++top] = i;\n\t\t}\n\n\t\tseg = new int[4 * n];\n\t\tbuild(1, 1, n, arr);\n\n\t\tlong ans = 0;\n\t\tfor (int i = 1; i < n; i++) {\n\t\t\tif (arr[i] == n - 1) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tint lf = left[i], rt = right[i];\n\n\t\t\tlong sub = 0;\n\n\t\t\t// right part\n\t\t\tif (rt != n) {\n\t\t\t\tint x = i - lf, y;\n\n\t\t\t\tint rv = queryRight(1, 1, n, rt + 1, right[rt], arr[i]);\n\t\t\t\ty = Math.max(1, rv - rt);\n\n\t\t\t\tsub += x * 1L * y;\n\t\t\t}\n\n\t\t\t// left part\n\t\t\tif (lf != 0) {\n\t\t\t\tint x = rt - i, y;\n\n\t\t\t\tint rv = queryLeft(1, 1, n, left[lf], lf - 1, arr[i]);\n\t\t\t\ty = Math.max(1, lf - rv);\n\n\t\t\t\tsub += x * 1L * y;\n\t\t\t}\n\n\t\t\tans += sub * arr[i];\n\t\t}\n\n\t\tout.println(ans);\n\t}\n\n\tint[] seg;\n\n\tint queryLeft(int ind, int l, int r, int si, int li, int val) {\n\t\tif (l > li || r < si || l > r) {\n\t\t\treturn (int) 0;\n\t\t}\n\n\t\tif (l == r) {\n\t\t\tif (seg[ind] > val)\n\t\t\t\treturn l;\n\t\t\treturn 0;\n\t\t}\n\n\t\tint m = (l + r) >> 1;\n\t\tif (l >= si && r <= li) {\n\t\t\tif (seg[2 * ind + 1] > val) {\n\t\t\t\treturn queryLeft(2 * ind + 1, m + 1, r, si, li, val);\n\t\t\t} else {\n\t\t\t\treturn queryLeft(2 * ind, l, m, si, li, val);\t\t\t\t\n\t\t\t}\n\t\t}\n\n\t\tint a = queryLeft(2 * ind, l, m, si, li, val);\n\t\tint b = queryLeft(2 * ind + 1, m + 1, r, si, li, val);\n\n\t\treturn Math.max(a, b);\n\t}\n\n\tint queryRight(int ind, int l, int r, int si, int li, int val) {\n\t\tif (l > li || r < si || l > r) {\n\t\t\treturn (int) 1e6;\n\t\t}\n\n\t\tif (l == r) {\n\t\t\tif (seg[ind] > val)\n\t\t\t\treturn l;\n\t\t\treturn (int) 1e6;\n\t\t}\n\n\t\tint m = (l + r) >> 1;\n\t\tif (l >= si && r <= li) {\n\t\t\tif (seg[2 * ind] > val) {\n\t\t\t\treturn queryRight(2 * ind, l, m, si, li, val);\n\t\t\t} else {\n\t\t\t\treturn queryRight(2 * ind + 1, m + 1, r, si, li, val);\n\t\t\t}\n\t\t}\n\n\t\tint a = queryRight(2 * ind, l, m, si, li, val);\n\t\tint b = queryRight(2 * ind + 1, m + 1, r, si, li, val);\n\n\t\treturn Math.min(a, b);\n\t}\n\n\tvoid build(int ind, int l, int r, int[] arr) {\n\t\tif (l == r) {\n\t\t\tseg[ind] = arr[l];\n\t\t\treturn;\n\t\t}\n\t\tint m = (l + r) >> 1;\n\t\tbuild(2 * ind, l, m, arr);\n\t\tbuild(2 * ind + 1, m + 1, r, arr);\n\t\tseg[ind] = Math.max(seg[2 * ind], seg[2 * ind + 1]);\n\t}\n\n\tpublic void run() {\n\t\tlong time = System.currentTimeMillis();\n\t\tboolean oj = true;\n\t\tout = new PrintWriter(System.out);\n\t\tscn = new FastReader(oj);\n\t\tsolve();\n\t\tout.flush();\n\t\tif (!oj) {\n\t\t\tSystem.out.println(Arrays.deepToString(new Object[] { System.currentTimeMillis() - time + \" ms\" }));\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tnew Thread(null, new Main(), \"Main\", 1 << 26).start();\n\t}\n\n\tclass FastReader {\n\t\tInputStream is;\n\n\t\tpublic FastReader(boolean onlineJudge) {\n\t\t\tis = onlineJudge ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n\t\t}\n\n\t\tpublic FastReader() {\n\t\t\tis = System.in;\n\t\t}\n\n\t\tbyte[] inbuf = new byte[1024];\n\t\tpublic int lenbuf = 0, ptrbuf = 0;\n\n\t\tint readByte() {\n\t\t\tif (lenbuf == -1)\n\t\t\t\tthrow new InputMismatchException();\n\t\t\tif (ptrbuf >= lenbuf) {\n\t\t\t\tptrbuf = 0;\n\t\t\t\ttry {\n\t\t\t\t\tlenbuf = is.read(inbuf);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\t\t\t\tif (lenbuf <= 0)\n\t\t\t\t\treturn -1;\n\t\t\t}\n\t\t\treturn inbuf[ptrbuf++];\n\t\t}\n\n\t\tboolean isSpaceChar(int c) {\n\t\t\treturn !(c >= 33 && c <= 126);\n\t\t}\n\n\t\tint skip() {\n\t\t\tint b;\n\t\t\twhile ((b = readByte()) != -1 && isSpaceChar(b))\n\t\t\t\t;\n\t\t\treturn b;\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tchar nextChar() {\n\t\t\treturn (char) skip();\n\t\t}\n\n\t\tString next() {\n\t\t\tint b = skip();\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\twhile (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')\n\t\t\t\tsb.appendCodePoint(b);\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t\treturn sb.toString();\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tint b = skip();\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\twhile ((!isSpaceChar(b) || b == ' ')) { // when nextLine, (isSpaceChar(b) && b != ' ')\n\t\t\t\tsb.appendCodePoint(b);\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t\treturn sb.toString();\n\t\t}\n\n\t\tchar[] next(int n) {\n\t\t\tchar[] buf = new char[n];\n\t\t\tint b = skip(), p = 0;\n\t\t\twhile (p < n && !(isSpaceChar(b))) {\n\t\t\t\tbuf[p++] = (char) b;\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t\treturn n == p ? buf : Arrays.copyOf(buf, p);\n\t\t}\n\n\t\tint nextInt() {\n\t\t\tint num = 0, b;\n\t\t\tboolean minus = false;\n\t\t\twhile ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))\n\t\t\t\t;\n\t\t\tif (b == '-') {\n\t\t\t\tminus = true;\n\t\t\t\tb = readByte();\n\t\t\t}\n\n\t\t\twhile (true) {\n\t\t\t\tif (b >= '0' && b <= '9') {\n\t\t\t\t\tnum = num * 10 + (b - '0');\n\t\t\t\t} else {\n\t\t\t\t\treturn minus ? -num : num;\n\t\t\t\t}\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\tlong num = 0;\n\t\t\tint b;\n\t\t\tboolean minus = false;\n\t\t\twhile ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))\n\t\t\t\t;\n\t\t\tif (b == '-') {\n\t\t\t\tminus = true;\n\t\t\t\tb = readByte();\n\t\t\t}\n\n\t\t\twhile (true) {\n\t\t\t\tif (b >= '0' && b <= '9') {\n\t\t\t\t\tnum = num * 10 + (b - '0');\n\t\t\t\t} else {\n\t\t\t\t\treturn minus ? -num : num;\n\t\t\t\t}\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t}\n\n\t\tchar[][] nextMatrix(int n, int m) {\n\t\t\tchar[][] map = new char[n][];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\tmap[i] = next(m);\n\t\t\treturn map;\n\t\t}\n\n\t\tint[] nextIntArray(int n) {\n\t\t\tint[] a = new int[n];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\ta[i] = nextInt();\n\t\t\treturn a;\n\t\t}\n\n\t\tint[][] IndIntArray(int n) {\n\t\t\tint[][] a = new int[n][];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\ta[i] = new int[] { nextInt(), i };\n\t\t\treturn a;\n\t\t}\n\n\t\tlong[] nextLongArray(int n) {\n\t\t\tlong[] a = new long[n];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\ta[i] = nextLong();\n\t\t\treturn a;\n\t\t}\n\n\t\tint[][] next2DInt(int n, int m) {\n\t\t\tint[][] arr = new int[n][];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tarr[i] = nextIntArray(m);\n\t\t\t}\n\t\t\treturn arr;\n\t\t}\n\n\t\tlong[][] next2DLong(int n, int m) {\n\t\t\tlong[][] arr = new long[n][];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tarr[i] = nextLongArray(m);\n\t\t\t}\n\t\t\treturn arr;\n\t\t}\n\n\t\tint[] shuffle(int[] arr) {\n\t\t\tRandom r = new Random();\n\t\t\tfor (int i = 1, j; i < arr.length; i++) {\n\t\t\t\tj = r.nextInt(i);\n\t\t\t\tint c = arr[i];\n\t\t\t\tarr[i] = arr[j];\n\t\t\t\tarr[j] = c;\n\t\t\t}\n\t\t\treturn arr;\n\t\t}\n\n\t\tlong[] shuffle(long[] arr) {\n\t\t\tRandom r = new Random();\n\t\t\tfor (int i = 1, j; i < arr.length; i++) {\n\t\t\t\tj = r.nextInt(i);\n\t\t\t\tlong c = arr[i];\n\t\t\t\tarr[i] = arr[j];\n\t\t\t\tarr[j] = c;\n\t\t\t}\n\t\t\treturn arr;\n\t\t}\n\n\t\tint[] uniq(int[] arr) {\n\t\t\tarr = scn.shuffle(arr);\n\t\t\tArrays.sort(arr);\n\t\t\tint[] rv = new int[arr.length];\n\t\t\tint pos = 0;\n\t\t\trv[pos++] = arr[0];\n\t\t\tfor (int i = 1; i < arr.length; i++) {\n\t\t\t\tif (arr[i] != arr[i - 1]) {\n\t\t\t\t\trv[pos++] = arr[i];\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn Arrays.copyOf(rv, pos);\n\t\t}\n\n\t\tlong[] uniq(long[] arr) {\n\t\t\tarr = scn.shuffle(arr);\n\t\t\tArrays.sort(arr);\n\t\t\tlong[] rv = new long[arr.length];\n\t\t\tint pos = 0;\n\t\t\trv[pos++] = arr[0];\n\t\t\tfor (int i = 1; i < arr.length; i++) {\n\t\t\t\tif (arr[i] != arr[i - 1]) {\n\t\t\t\t\trv[pos++] = arr[i];\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn Arrays.copyOf(rv, pos);\n\t\t}\n\n\t\tint[] reverse(int[] arr) {\n\t\t\tint l = 0, r = arr.length - 1;\n\t\t\twhile (l < r) {\n\t\t\t\tarr[l] = arr[l] ^ arr[r];\n\t\t\t\tarr[r] = arr[l] ^ arr[r];\n\t\t\t\tarr[l] = arr[l] ^ arr[r];\n\t\t\t\tl++;\n\t\t\t\tr--;\n\t\t\t}\n\t\t\treturn arr;\n\t\t}\n\n\t\tlong[] reverse(long[] arr) {\n\t\t\tint l = 0, r = arr.length - 1;\n\t\t\twhile (l < r) {\n\t\t\t\tarr[l] = arr[l] ^ arr[r];\n\t\t\t\tarr[r] = arr[l] ^ arr[r];\n\t\t\t\tarr[l] = arr[l] ^ arr[r];\n\t\t\t\tl++;\n\t\t\t\tr--;\n\t\t\t}\n\t\t\treturn arr;\n\t\t}\n\n\t\tint[] compress(int[] arr) {\n\t\t\tint n = arr.length;\n\t\t\tint[] rv = Arrays.copyOf(arr, n);\n\t\t\trv = uniq(rv);\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tarr[i] = Arrays.binarySearch(rv, arr[i]);\n\t\t\t}\n\t\t\treturn arr;\n\t\t}\n\n\t\tlong[] compress(long[] arr) {\n\t\t\tint n = arr.length;\n\t\t\tlong[] rv = Arrays.copyOf(arr, n);\n\t\t\trv = uniq(rv);\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tarr[i] = Arrays.binarySearch(rv, arr[i]);\n\t\t\t}\n\t\t\treturn arr;\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1567906670, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02919.html", "problem_id": "p02919", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02919/input.txt", "sample_output_relpath": "derived/input_output/data/p02919/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02919/Java/s946013740.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s946013740", "user_id": "u228818634"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\n\npublic class Main implements Runnable {\n\tFastReader scn;\n\tPrintWriter out;\n\tString INPUT = \"\";\n\n\tvoid solve() {\n\t\tint n = scn.nextInt();\n\t\tint[] arr = new int[n + 2];\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\tarr[i] = scn.nextInt();\n\t\t}\n\t\tarr[n + 1] = (int) 1e6;\n\n\t\tn++;\n\t\tint[] st = new int[n + 1], left = new int[n + 1], right = new int[n + 1];\n\n\t\tint top = -1;\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\twhile (top != -1 && arr[st[top]] < arr[i]) {\n\t\t\t\ttop--;\n\t\t\t}\n\t\t\tleft[i] = top == -1 ? 0 : st[top];\n\t\t\tst[++top] = i;\n\t\t}\n\n\t\ttop = -1;\n\t\tfor (int i = n; i > 0; i--) {\n\t\t\twhile (top != -1 && arr[st[top]] < arr[i]) {\n\t\t\t\ttop--;\n\t\t\t}\n\t\t\tright[i] = top == -1 ? n + 1 : st[top];\n\t\t\tst[++top] = i;\n\t\t}\n\n\t\tseg = new int[4 * n];\n\t\tbuild(1, 1, n, arr);\n\n\t\tlong ans = 0;\n\t\tfor (int i = 1; i < n; i++) {\n\t\t\tif (arr[i] == n - 1) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tint lf = left[i], rt = right[i];\n\n\t\t\tlong sub = 0;\n\n\t\t\t// right part\n\t\t\tif (rt != n) {\n\t\t\t\tint x = i - lf, y;\n\n\t\t\t\tint rv = queryRight(1, 1, n, rt + 1, right[rt], arr[i]);\n\t\t\t\ty = Math.max(1, rv - rt);\n\n\t\t\t\tsub += x * 1L * y;\n\t\t\t}\n\n\t\t\t// left part\n\t\t\tif (lf != 0) {\n\t\t\t\tint x = rt - i, y;\n\n\t\t\t\tint rv = queryLeft(1, 1, n, left[lf], lf - 1, arr[i]);\n\t\t\t\ty = Math.max(1, lf - rv);\n\n\t\t\t\tsub += x * 1L * y;\n\t\t\t}\n\n\t\t\tans += sub * arr[i];\n\t\t}\n\n\t\tout.println(ans);\n\t}\n\n\tint[] seg;\n\n\tint queryLeft(int ind, int l, int r, int si, int li, int val) {\n\t\tif (l > li || r < si || l > r) {\n\t\t\treturn (int) 0;\n\t\t}\n\n\t\tif (l == r) {\n\t\t\tif (seg[ind] > val)\n\t\t\t\treturn l;\n\t\t\treturn 0;\n\t\t}\n\n\t\tint m = (l + r) >> 1;\n\t\tif (l >= si && r <= li) {\n\t\t\tif (seg[2 * ind + 1] > val) {\n\t\t\t\treturn queryLeft(2 * ind + 1, m + 1, r, si, li, val);\n\t\t\t} else {\n\t\t\t\treturn queryLeft(2 * ind, l, m, si, li, val);\t\t\t\t\n\t\t\t}\n\t\t}\n\n\t\tint a = queryLeft(2 * ind, l, m, si, li, val);\n\t\tint b = queryLeft(2 * ind + 1, m + 1, r, si, li, val);\n\n\t\treturn Math.max(a, b);\n\t}\n\n\tint queryRight(int ind, int l, int r, int si, int li, int val) {\n\t\tif (l > li || r < si || l > r) {\n\t\t\treturn (int) 1e6;\n\t\t}\n\n\t\tif (l == r) {\n\t\t\tif (seg[ind] > val)\n\t\t\t\treturn l;\n\t\t\treturn (int) 1e6;\n\t\t}\n\n\t\tint m = (l + r) >> 1;\n\t\tif (l >= si && r <= li) {\n\t\t\tif (seg[2 * ind] > val) {\n\t\t\t\treturn queryRight(2 * ind, l, m, si, li, val);\n\t\t\t} else {\n\t\t\t\treturn queryRight(2 * ind + 1, m + 1, r, si, li, val);\n\t\t\t}\n\t\t}\n\n\t\tint a = queryRight(2 * ind, l, m, si, li, val);\n\t\tint b = queryRight(2 * ind + 1, m + 1, r, si, li, val);\n\n\t\treturn Math.min(a, b);\n\t}\n\n\tvoid build(int ind, int l, int r, int[] arr) {\n\t\tif (l == r) {\n\t\t\tseg[ind] = arr[l];\n\t\t\treturn;\n\t\t}\n\t\tint m = (l + r) >> 1;\n\t\tbuild(2 * ind, l, m, arr);\n\t\tbuild(2 * ind + 1, m + 1, r, arr);\n\t\tseg[ind] = Math.max(seg[2 * ind], seg[2 * ind + 1]);\n\t}\n\n\tpublic void run() {\n\t\tlong time = System.currentTimeMillis();\n\t\tboolean oj = true;\n\t\tout = new PrintWriter(System.out);\n\t\tscn = new FastReader(oj);\n\t\tsolve();\n\t\tout.flush();\n\t\tif (!oj) {\n\t\t\tSystem.out.println(Arrays.deepToString(new Object[] { System.currentTimeMillis() - time + \" ms\" }));\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tnew Thread(null, new Main(), \"Main\", 1 << 26).start();\n\t}\n\n\tclass FastReader {\n\t\tInputStream is;\n\n\t\tpublic FastReader(boolean onlineJudge) {\n\t\t\tis = onlineJudge ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n\t\t}\n\n\t\tpublic FastReader() {\n\t\t\tis = System.in;\n\t\t}\n\n\t\tbyte[] inbuf = new byte[1024];\n\t\tpublic int lenbuf = 0, ptrbuf = 0;\n\n\t\tint readByte() {\n\t\t\tif (lenbuf == -1)\n\t\t\t\tthrow new InputMismatchException();\n\t\t\tif (ptrbuf >= lenbuf) {\n\t\t\t\tptrbuf = 0;\n\t\t\t\ttry {\n\t\t\t\t\tlenbuf = is.read(inbuf);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\t\t\t\tif (lenbuf <= 0)\n\t\t\t\t\treturn -1;\n\t\t\t}\n\t\t\treturn inbuf[ptrbuf++];\n\t\t}\n\n\t\tboolean isSpaceChar(int c) {\n\t\t\treturn !(c >= 33 && c <= 126);\n\t\t}\n\n\t\tint skip() {\n\t\t\tint b;\n\t\t\twhile ((b = readByte()) != -1 && isSpaceChar(b))\n\t\t\t\t;\n\t\t\treturn b;\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tchar nextChar() {\n\t\t\treturn (char) skip();\n\t\t}\n\n\t\tString next() {\n\t\t\tint b = skip();\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\twhile (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')\n\t\t\t\tsb.appendCodePoint(b);\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t\treturn sb.toString();\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tint b = skip();\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\twhile ((!isSpaceChar(b) || b == ' ')) { // when nextLine, (isSpaceChar(b) && b != ' ')\n\t\t\t\tsb.appendCodePoint(b);\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t\treturn sb.toString();\n\t\t}\n\n\t\tchar[] next(int n) {\n\t\t\tchar[] buf = new char[n];\n\t\t\tint b = skip(), p = 0;\n\t\t\twhile (p < n && !(isSpaceChar(b))) {\n\t\t\t\tbuf[p++] = (char) b;\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t\treturn n == p ? buf : Arrays.copyOf(buf, p);\n\t\t}\n\n\t\tint nextInt() {\n\t\t\tint num = 0, b;\n\t\t\tboolean minus = false;\n\t\t\twhile ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))\n\t\t\t\t;\n\t\t\tif (b == '-') {\n\t\t\t\tminus = true;\n\t\t\t\tb = readByte();\n\t\t\t}\n\n\t\t\twhile (true) {\n\t\t\t\tif (b >= '0' && b <= '9') {\n\t\t\t\t\tnum = num * 10 + (b - '0');\n\t\t\t\t} else {\n\t\t\t\t\treturn minus ? -num : num;\n\t\t\t\t}\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\tlong num = 0;\n\t\t\tint b;\n\t\t\tboolean minus = false;\n\t\t\twhile ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))\n\t\t\t\t;\n\t\t\tif (b == '-') {\n\t\t\t\tminus = true;\n\t\t\t\tb = readByte();\n\t\t\t}\n\n\t\t\twhile (true) {\n\t\t\t\tif (b >= '0' && b <= '9') {\n\t\t\t\t\tnum = num * 10 + (b - '0');\n\t\t\t\t} else {\n\t\t\t\t\treturn minus ? -num : num;\n\t\t\t\t}\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t}\n\n\t\tchar[][] nextMatrix(int n, int m) {\n\t\t\tchar[][] map = new char[n][];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\tmap[i] = next(m);\n\t\t\treturn map;\n\t\t}\n\n\t\tint[] nextIntArray(int n) {\n\t\t\tint[] a = new int[n];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\ta[i] = nextInt();\n\t\t\treturn a;\n\t\t}\n\n\t\tint[][] IndIntArray(int n) {\n\t\t\tint[][] a = new int[n][];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\ta[i] = new int[] { nextInt(), i };\n\t\t\treturn a;\n\t\t}\n\n\t\tlong[] nextLongArray(int n) {\n\t\t\tlong[] a = new long[n];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\ta[i] = nextLong();\n\t\t\treturn a;\n\t\t}\n\n\t\tint[][] next2DInt(int n, int m) {\n\t\t\tint[][] arr = new int[n][];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tarr[i] = nextIntArray(m);\n\t\t\t}\n\t\t\treturn arr;\n\t\t}\n\n\t\tlong[][] next2DLong(int n, int m) {\n\t\t\tlong[][] arr = new long[n][];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tarr[i] = nextLongArray(m);\n\t\t\t}\n\t\t\treturn arr;\n\t\t}\n\n\t\tint[] shuffle(int[] arr) {\n\t\t\tRandom r = new Random();\n\t\t\tfor (int i = 1, j; i < arr.length; i++) {\n\t\t\t\tj = r.nextInt(i);\n\t\t\t\tint c = arr[i];\n\t\t\t\tarr[i] = arr[j];\n\t\t\t\tarr[j] = c;\n\t\t\t}\n\t\t\treturn arr;\n\t\t}\n\n\t\tlong[] shuffle(long[] arr) {\n\t\t\tRandom r = new Random();\n\t\t\tfor (int i = 1, j; i < arr.length; i++) {\n\t\t\t\tj = r.nextInt(i);\n\t\t\t\tlong c = arr[i];\n\t\t\t\tarr[i] = arr[j];\n\t\t\t\tarr[j] = c;\n\t\t\t}\n\t\t\treturn arr;\n\t\t}\n\n\t\tint[] uniq(int[] arr) {\n\t\t\tarr = scn.shuffle(arr);\n\t\t\tArrays.sort(arr);\n\t\t\tint[] rv = new int[arr.length];\n\t\t\tint pos = 0;\n\t\t\trv[pos++] = arr[0];\n\t\t\tfor (int i = 1; i < arr.length; i++) {\n\t\t\t\tif (arr[i] != arr[i - 1]) {\n\t\t\t\t\trv[pos++] = arr[i];\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn Arrays.copyOf(rv, pos);\n\t\t}\n\n\t\tlong[] uniq(long[] arr) {\n\t\t\tarr = scn.shuffle(arr);\n\t\t\tArrays.sort(arr);\n\t\t\tlong[] rv = new long[arr.length];\n\t\t\tint pos = 0;\n\t\t\trv[pos++] = arr[0];\n\t\t\tfor (int i = 1; i < arr.length; i++) {\n\t\t\t\tif (arr[i] != arr[i - 1]) {\n\t\t\t\t\trv[pos++] = arr[i];\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn Arrays.copyOf(rv, pos);\n\t\t}\n\n\t\tint[] reverse(int[] arr) {\n\t\t\tint l = 0, r = arr.length - 1;\n\t\t\twhile (l < r) {\n\t\t\t\tarr[l] = arr[l] ^ arr[r];\n\t\t\t\tarr[r] = arr[l] ^ arr[r];\n\t\t\t\tarr[l] = arr[l] ^ arr[r];\n\t\t\t\tl++;\n\t\t\t\tr--;\n\t\t\t}\n\t\t\treturn arr;\n\t\t}\n\n\t\tlong[] reverse(long[] arr) {\n\t\t\tint l = 0, r = arr.length - 1;\n\t\t\twhile (l < r) {\n\t\t\t\tarr[l] = arr[l] ^ arr[r];\n\t\t\t\tarr[r] = arr[l] ^ arr[r];\n\t\t\t\tarr[l] = arr[l] ^ arr[r];\n\t\t\t\tl++;\n\t\t\t\tr--;\n\t\t\t}\n\t\t\treturn arr;\n\t\t}\n\n\t\tint[] compress(int[] arr) {\n\t\t\tint n = arr.length;\n\t\t\tint[] rv = Arrays.copyOf(arr, n);\n\t\t\trv = uniq(rv);\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tarr[i] = Arrays.binarySearch(rv, arr[i]);\n\t\t\t}\n\t\t\treturn arr;\n\t\t}\n\n\t\tlong[] compress(long[] arr) {\n\t\t\tint n = arr.length;\n\t\t\tlong[] rv = Arrays.copyOf(arr, n);\n\t\t\trv = uniq(rv);\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tarr[i] = Arrays.binarySearch(rv, arr[i]);\n\t\t\t}\n\t\t\treturn arr;\n\t\t}\n\t}\n}", "problem_context": "Score: 500 points\n\nProblem Statement\n\nGiven is a permutation P of \\{1, 2, \\ldots, N\\}.\n\nFor a pair (L, R) (1 \\le L \\lt R \\le N), let X_{L, R} be the second largest value among P_L, P_{L+1}, \\ldots, P_R.\n\nFind \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le P_i \\le N\n\nP_i \\neq P_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 \\ldots P_N\n\nOutput\n\nPrint \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n5\n\nX_{1, 2} = 2, X_{1, 3} = 2, and X_{2, 3} = 1, so the sum is 2 + 2 + 1 = 5.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n30\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n136", "sample_input": "3\n2 3 1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02919", "source_text": "Score: 500 points\n\nProblem Statement\n\nGiven is a permutation P of \\{1, 2, \\ldots, N\\}.\n\nFor a pair (L, R) (1 \\le L \\lt R \\le N), let X_{L, R} be the second largest value among P_L, P_{L+1}, \\ldots, P_R.\n\nFind \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le P_i \\le N\n\nP_i \\neq P_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 \\ldots P_N\n\nOutput\n\nPrint \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n5\n\nX_{1, 2} = 2, X_{1, 3} = 2, and X_{2, 3} = 1, so the sum is 2 + 2 + 1 = 5.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n30\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n136", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 8202, "cpu_time_ms": 180, "memory_kb": 28372}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s676815878", "group_id": "codeNet:p02921", "input_text": "import java.io.*;\nimport java.util.*;\n\nclass Main{\n final static long INF = Long.MAX_VALUE / 2;\n final static int MOD = 1_000_000_007;\n final static int SIZE = 1_000_000;\n long[] fac = new long[SIZE];\n long[] inv = new long[SIZE];\n long[] finv = new long[SIZE];\n FastScanner sc = new FastScanner();\n\n public static void main(String[] args) {\n new Main().solve();\n }\n\n void solve(){\n\n String s = sc.next();\n String t = sc.next();\n int c = 0;\n\n for(int i = 0; i < 3; i++){\n if(s.charAt(i) == t.charAt(i)) c++;\n }\n\n System.out.println(c);\n\n }\n\n long gcd(long a, long b){ // return aとbの最大公約数\n if(b == 0){\n return a;\n }\n return gcd(b, a % b);\n }\n\n long lcm(long a, long b){ // return aとbの最小公倍数\n return a * b / gcd(a, b);\n }\n\n long inv(long a){ // return aの逆元 (mod MOD)\n return pow(a, MOD - 2);\n }\n\n long pow(long a, long r){ // return a^r (mod MOD)\n long sum = 1;\n while(r > 0){\n if((r & 1) == 1){ // 2進数表記で末尾1の時\n sum *= a;\n sum %= MOD;\n }\n a *= a;\n a %= MOD;\n r >>= 1;\n }\n return sum;\n }\n\n long modFact(long n){ // retur n! (mod MOD)\n if(n == 0){\n return 1;\n }\n return n * modFact(n - 1) % MOD;\n }\n\n long fact(long n){ // return n!\n if(n == 0){\n return 1;\n }\n return n * fact(n - 1);\n }\n\n void initCOMB(){\n fac[0] = fac[1] = 1;\n inv[1] = 1;\n finv[0] = finv[1] = 1;\n for(int i = 2; i < SIZE; i++){\n fac[i] = fac[i - 1] * i % MOD;\n inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;\n finv[i] = finv[i - 1] * inv[i] % MOD;\n }\n }\n\n long modComb(int n, int r){ // return nCr (先にinitCOMB()必要)\n if(n < r || n < 0 || r < 0) return 0;\n return fac[n] * finv[r] % MOD * finv[n - r] % MOD;\n }\n\n long comb(long n, long r){ // return nCr\n long num = 1;\n for(long i = 1; i <= r; i++){\n num = num * (n - i + 1) / i;\n }\n return num;\n }\n\n boolean isPrime(long a){ // aの素数判定\n if(a <= 1) return false;\n for(int i = 2; i * i <= a; i++){\n if(a % i == 0) return false;\n }\n return true;\n }\n\n int lowerBound(long[] a, long v){ // return 配列a内のv以上の要素の内最低の要素のイテレータ\n int r = a.length;\n int l = -1;\n while(r - l > 1){\n int mid = (r + l) / 2;\n if(a[mid] >= v){\n r = mid;\n }else{\n l = mid;\n }\n }\n return r;\n }\n\n int upperBound(long[] a, long v){ // return 配列a内のvより大きい要素の内最低の要素のイテレータ\n int r = a.length;\n int l = -1;\n while(r - l > 1){\n int mid = (r + l) / 2;\n if(a[mid] > v){\n r = mid;\n }else{\n l = mid;\n }\n }\n return r;\n }\n\n String nextPermutation(String s){ // return sの次の順列\n ArrayList list = new ArrayList<>();\n for(int i = 0; i < s.length(); i++) list.add(s.charAt(i));\n\n int pivotPos = -1;\n char pivot = 0;\n for(int i = list.size() - 2; i >= 0; i--){\n if(list.get(i) < list.get(i+1)){\n \t\t\tpivotPos = i;\n \t\t\tpivot = list.get(i);\n \t\t\tbreak;\n \t\t}\n \t}\n\n if(pivotPos == -1 && pivot == 0) return null;\n\n int L = pivotPos + 1;\n int R = list.size() - 1;\n \tint minPos = -1;\n \tchar min = Character.MAX_VALUE;\n \tfor(int i = R; i >= L; i--){\n \t\tif(pivot < list.get(i)){\n \t\t\tif(list.get(i) < min){\n \t\t\t\tmin = list.get(i);\n \t\t\t\tminPos = i;\n \t\t\t}\n \t\t}\n \t}\n\n \tCollections.swap(list, pivotPos, minPos);\n \tCollections.sort(list.subList(L, R + 1));\n\n \tStringBuilder sb = new StringBuilder();\n \tfor(int i=0; i 0; i--){\n if(a[i - 1] < a[i]){\n int swapIndex = find(a[i - 1], a, i, a.length - 1);\n long temp = a[swapIndex];\n a[swapIndex] = a[i - 1];\n a[i - 1] = temp;\n Arrays.sort(a, i, a.length);\n return true;\n }\n }\n return false;\n }\n\n int find(long dest, long[] a, int s, int e){\n if(s == e){\n return s;\n }\n int m = (s + e + 1) / 2;\n return a[m] <= dest ? find(dest, a, s, m - 1) : find(dest, a, m, e);\n }\n\n void elimination(int[][] a, int[] b) {\n int n = a.length;\n double f;\n for(int k = 0; k < n - 1; k++){\n for(int i = k + 1; i < n; i++){\n f = - a[i][k] / a[k][k];\n for(int j = k + 1; j < n; j++){\n a[i][j] += f * a[k][j];\n }\n b[i] += f * b[k];\n }\n for(int i = n - 1; i >= 0; i--){\n for(int j = i + 1; j < n; j++){\n b[i] -= a[i][j] * b[j];\n }\n b[i] = b[i] / a[i][i];\n }\n }\n }\n\n\n\n class SegmentTree{\n\n //------------------------------------------------------------\n // 2 * n - 1 : 木全体のノード数\n // i + n - 1 : 配列のi番目が対応するノードの番号\n // 2 * i + 1, 2 * i + 2 : i番目のノードの子ノードの番号\n // (i - 1) / 2 : i番目のノードの親ノードの番号\n //\n // int n = sc.nextInt();\n // long[] a = new long[n];\n // for(int i = 0; i < n; i++) a[i] = sc.nextLong();\n // SegmentTree st = new SegmentTree(a);\n // int l = sc.nextInt() - 1;\n // int r = sc.nextInt() - 1;\n // System.out.println(st.query(l, r));\n //------------------------------------------------------------\n\n final static long INF = Long.MAX_VALUE / 2;\n\n // long e = INF; // 単位元\n long e = 0;\n long func(long a, long b){ // 処理\n // return Math.min(a, b);\n return a + b;\n }\n\n int n; // 配列の要素数を超える最小の2のべき乗\n long[] node;\n\n SegmentTree(long[] a){\n init(a);\n }\n\n void init(long[] a){ // 配列aで初期化\n n = 1;\n while(n < a.length){\n n *= 2;\n }\n node = new long[2 * n - 1];\n Arrays.fill(node, e);\n for(int i = 0; i < a.length; i++){\n node[i + n - 1] = a[i];\n }\n for(int i = n - 2; i >= 0; i--){\n node[i] = func(node[2 * i + 1], node[2 * i + 2]);\n }\n }\n\n void update(int p, long v){ // 配列のp番目をvに変更し、木全体を更新\n p = p + n - 1;\n node[p] = v;\n while(p > 0){\n p = (p - 1) / 2;\n node[p] = func(node[2 * p + 1], node[2 * p + 2]);\n }\n }\n\n long query(int a, int b){ // 区間[a, b)についてクエリを処理\n return query(a, b, 0, 0, n);\n }\n\n long query(int a, int b, int k, int l, int r){\n if(r <= a || b <= l) return e;\n if(a <= l && r <= b) return node[k];\n return func(query(a, b, 2 * k + 1, l, (l + r) / 2), query(a, b, 2 * k + 2, (l + r) / 2, r));\n }\n\n }\n\n\n\n}\n\n\n\nclass Pair implements Comparable{\n long a, b;\n public Pair(long i, long j){\n a = i;\n b = j;\n }\n\n @Override\n public int compareTo(Pair p){\n if(this.b < p.b) return -1;\n else if(this.b > p.b) return 1;\n else return 0;\n }\n}\n\n\n\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte(){\n if(ptr < buflen){\n return true;\n }else{\n ptr = 0;\n try{\n buflen = in.read(buffer);\n }catch(IOException e){\n e.printStackTrace();\n }\n if(buflen <= 0){\n return false;\n }\n }\n return true;\n }\n private int readByte(){\n if(hasNextByte()) return buffer[ptr++];\n else return -1;\n }\n private static boolean isPrintableChar(int c){\n return 33 <= c && c <= 126;\n }\n public boolean hasNext(){\n while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n return hasNextByte();\n }\n public String next(){\n if(!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while(isPrintableChar(b)){\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n public long nextLong(){\n if(!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if(b == '-'){\n minus = true;\n b = readByte();\n }\n if(b < '0' || '9' < b){\n throw new NumberFormatException();\n }\n while(true){\n if('0' <= b && b <= '9'){\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n public int nextInt(){\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n public double nextDouble(){\n return Double.parseDouble(next());\n }\n}\n", "language": "Java", "metadata": {"date": 1589924525, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02921.html", "problem_id": "p02921", "resource_group": "high_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/Java/s676815878.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s676815878", "user_id": "u521293705"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\n\nclass Main{\n final static long INF = Long.MAX_VALUE / 2;\n final static int MOD = 1_000_000_007;\n final static int SIZE = 1_000_000;\n long[] fac = new long[SIZE];\n long[] inv = new long[SIZE];\n long[] finv = new long[SIZE];\n FastScanner sc = new FastScanner();\n\n public static void main(String[] args) {\n new Main().solve();\n }\n\n void solve(){\n\n String s = sc.next();\n String t = sc.next();\n int c = 0;\n\n for(int i = 0; i < 3; i++){\n if(s.charAt(i) == t.charAt(i)) c++;\n }\n\n System.out.println(c);\n\n }\n\n long gcd(long a, long b){ // return aとbの最大公約数\n if(b == 0){\n return a;\n }\n return gcd(b, a % b);\n }\n\n long lcm(long a, long b){ // return aとbの最小公倍数\n return a * b / gcd(a, b);\n }\n\n long inv(long a){ // return aの逆元 (mod MOD)\n return pow(a, MOD - 2);\n }\n\n long pow(long a, long r){ // return a^r (mod MOD)\n long sum = 1;\n while(r > 0){\n if((r & 1) == 1){ // 2進数表記で末尾1の時\n sum *= a;\n sum %= MOD;\n }\n a *= a;\n a %= MOD;\n r >>= 1;\n }\n return sum;\n }\n\n long modFact(long n){ // retur n! (mod MOD)\n if(n == 0){\n return 1;\n }\n return n * modFact(n - 1) % MOD;\n }\n\n long fact(long n){ // return n!\n if(n == 0){\n return 1;\n }\n return n * fact(n - 1);\n }\n\n void initCOMB(){\n fac[0] = fac[1] = 1;\n inv[1] = 1;\n finv[0] = finv[1] = 1;\n for(int i = 2; i < SIZE; i++){\n fac[i] = fac[i - 1] * i % MOD;\n inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;\n finv[i] = finv[i - 1] * inv[i] % MOD;\n }\n }\n\n long modComb(int n, int r){ // return nCr (先にinitCOMB()必要)\n if(n < r || n < 0 || r < 0) return 0;\n return fac[n] * finv[r] % MOD * finv[n - r] % MOD;\n }\n\n long comb(long n, long r){ // return nCr\n long num = 1;\n for(long i = 1; i <= r; i++){\n num = num * (n - i + 1) / i;\n }\n return num;\n }\n\n boolean isPrime(long a){ // aの素数判定\n if(a <= 1) return false;\n for(int i = 2; i * i <= a; i++){\n if(a % i == 0) return false;\n }\n return true;\n }\n\n int lowerBound(long[] a, long v){ // return 配列a内のv以上の要素の内最低の要素のイテレータ\n int r = a.length;\n int l = -1;\n while(r - l > 1){\n int mid = (r + l) / 2;\n if(a[mid] >= v){\n r = mid;\n }else{\n l = mid;\n }\n }\n return r;\n }\n\n int upperBound(long[] a, long v){ // return 配列a内のvより大きい要素の内最低の要素のイテレータ\n int r = a.length;\n int l = -1;\n while(r - l > 1){\n int mid = (r + l) / 2;\n if(a[mid] > v){\n r = mid;\n }else{\n l = mid;\n }\n }\n return r;\n }\n\n String nextPermutation(String s){ // return sの次の順列\n ArrayList list = new ArrayList<>();\n for(int i = 0; i < s.length(); i++) list.add(s.charAt(i));\n\n int pivotPos = -1;\n char pivot = 0;\n for(int i = list.size() - 2; i >= 0; i--){\n if(list.get(i) < list.get(i+1)){\n \t\t\tpivotPos = i;\n \t\t\tpivot = list.get(i);\n \t\t\tbreak;\n \t\t}\n \t}\n\n if(pivotPos == -1 && pivot == 0) return null;\n\n int L = pivotPos + 1;\n int R = list.size() - 1;\n \tint minPos = -1;\n \tchar min = Character.MAX_VALUE;\n \tfor(int i = R; i >= L; i--){\n \t\tif(pivot < list.get(i)){\n \t\t\tif(list.get(i) < min){\n \t\t\t\tmin = list.get(i);\n \t\t\t\tminPos = i;\n \t\t\t}\n \t\t}\n \t}\n\n \tCollections.swap(list, pivotPos, minPos);\n \tCollections.sort(list.subList(L, R + 1));\n\n \tStringBuilder sb = new StringBuilder();\n \tfor(int i=0; i 0; i--){\n if(a[i - 1] < a[i]){\n int swapIndex = find(a[i - 1], a, i, a.length - 1);\n long temp = a[swapIndex];\n a[swapIndex] = a[i - 1];\n a[i - 1] = temp;\n Arrays.sort(a, i, a.length);\n return true;\n }\n }\n return false;\n }\n\n int find(long dest, long[] a, int s, int e){\n if(s == e){\n return s;\n }\n int m = (s + e + 1) / 2;\n return a[m] <= dest ? find(dest, a, s, m - 1) : find(dest, a, m, e);\n }\n\n void elimination(int[][] a, int[] b) {\n int n = a.length;\n double f;\n for(int k = 0; k < n - 1; k++){\n for(int i = k + 1; i < n; i++){\n f = - a[i][k] / a[k][k];\n for(int j = k + 1; j < n; j++){\n a[i][j] += f * a[k][j];\n }\n b[i] += f * b[k];\n }\n for(int i = n - 1; i >= 0; i--){\n for(int j = i + 1; j < n; j++){\n b[i] -= a[i][j] * b[j];\n }\n b[i] = b[i] / a[i][i];\n }\n }\n }\n\n\n\n class SegmentTree{\n\n //------------------------------------------------------------\n // 2 * n - 1 : 木全体のノード数\n // i + n - 1 : 配列のi番目が対応するノードの番号\n // 2 * i + 1, 2 * i + 2 : i番目のノードの子ノードの番号\n // (i - 1) / 2 : i番目のノードの親ノードの番号\n //\n // int n = sc.nextInt();\n // long[] a = new long[n];\n // for(int i = 0; i < n; i++) a[i] = sc.nextLong();\n // SegmentTree st = new SegmentTree(a);\n // int l = sc.nextInt() - 1;\n // int r = sc.nextInt() - 1;\n // System.out.println(st.query(l, r));\n //------------------------------------------------------------\n\n final static long INF = Long.MAX_VALUE / 2;\n\n // long e = INF; // 単位元\n long e = 0;\n long func(long a, long b){ // 処理\n // return Math.min(a, b);\n return a + b;\n }\n\n int n; // 配列の要素数を超える最小の2のべき乗\n long[] node;\n\n SegmentTree(long[] a){\n init(a);\n }\n\n void init(long[] a){ // 配列aで初期化\n n = 1;\n while(n < a.length){\n n *= 2;\n }\n node = new long[2 * n - 1];\n Arrays.fill(node, e);\n for(int i = 0; i < a.length; i++){\n node[i + n - 1] = a[i];\n }\n for(int i = n - 2; i >= 0; i--){\n node[i] = func(node[2 * i + 1], node[2 * i + 2]);\n }\n }\n\n void update(int p, long v){ // 配列のp番目をvに変更し、木全体を更新\n p = p + n - 1;\n node[p] = v;\n while(p > 0){\n p = (p - 1) / 2;\n node[p] = func(node[2 * p + 1], node[2 * p + 2]);\n }\n }\n\n long query(int a, int b){ // 区間[a, b)についてクエリを処理\n return query(a, b, 0, 0, n);\n }\n\n long query(int a, int b, int k, int l, int r){\n if(r <= a || b <= l) return e;\n if(a <= l && r <= b) return node[k];\n return func(query(a, b, 2 * k + 1, l, (l + r) / 2), query(a, b, 2 * k + 2, (l + r) / 2, r));\n }\n\n }\n\n\n\n}\n\n\n\nclass Pair implements Comparable{\n long a, b;\n public Pair(long i, long j){\n a = i;\n b = j;\n }\n\n @Override\n public int compareTo(Pair p){\n if(this.b < p.b) return -1;\n else if(this.b > p.b) return 1;\n else return 0;\n }\n}\n\n\n\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte(){\n if(ptr < buflen){\n return true;\n }else{\n ptr = 0;\n try{\n buflen = in.read(buffer);\n }catch(IOException e){\n e.printStackTrace();\n }\n if(buflen <= 0){\n return false;\n }\n }\n return true;\n }\n private int readByte(){\n if(hasNextByte()) return buffer[ptr++];\n else return -1;\n }\n private static boolean isPrintableChar(int c){\n return 33 <= c && c <= 126;\n }\n public boolean hasNext(){\n while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n return hasNextByte();\n }\n public String next(){\n if(!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while(isPrintableChar(b)){\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n public long nextLong(){\n if(!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if(b == '-'){\n minus = true;\n b = readByte();\n }\n if(b < '0' || '9' < b){\n throw new NumberFormatException();\n }\n while(true){\n if('0' <= b && b <= '9'){\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n public int nextInt(){\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n public double nextDouble(){\n return Double.parseDouble(next());\n }\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": 10089, "cpu_time_ms": 75, "memory_kb": 47828}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s951633778", "group_id": "codeNet:p02921", "input_text": "\n\nimport java.util.Scanner;\n\npublic class Main {\n\n\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int n = scanner.nextInt();\n int res = 0;\n for(int i = n ; i>0;i-- ){\n res+=i;\n }\n System.out.println(res);\n }\n \n}\n", "language": "Java", "metadata": {"date": 1589807334, "filename_ext": "java", "original_language": "Java7 (OpenJDK 1.7.0)", "problem_description_relpath": "problem_descriptions/p02921.html", "problem_id": "p02921", "resource_group": "high_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/Java/s951633778.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s951633778", "user_id": "u362532770"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\n\nimport java.util.Scanner;\n\npublic class Main {\n\n\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int n = scanner.nextInt();\n int res = 0;\n for(int i = n ; i>0;i-- ){\n res+=i;\n }\n System.out.println(res);\n }\n \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": 309, "cpu_time_ms": 121, "memory_kb": 22740}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s667018000", "group_id": "codeNet:p02922", "input_text": "import java.util.Scanner;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tdouble sockets = in.nextDouble();\n\t\tdouble total_req = in.nextDouble();\t\n\t\tdouble mid = total_req-sockets;\n\t\tif(total_req == 1.0) {\n\t\t\tSystem.out.println(0);\n\t\t\tSystem.exit(0);\n\t\t}\n\t\t//System.out.println(mid);\n\t\tdouble total = Math.ceil(mid/(sockets-1));\n\t\t//System.out.println(total);\n\t\tif(sockets>=total_req) {\n\t\t\tSystem.out.println(1);\n\t\t\tSystem.exit(0);\n\t\t}\n//\t\tif(total < 1.0 && total != 0) {\n//\t\t\ttotal = 1.0;\n//\t\t}\n\t\ttotal++;\n\t\tSystem.out.println((int)(total));\n\t\t\n\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1568716372, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02922.html", "problem_id": "p02922", "resource_group": "high_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/Java/s667018000.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s667018000", "user_id": "u018679195"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tdouble sockets = in.nextDouble();\n\t\tdouble total_req = in.nextDouble();\t\n\t\tdouble mid = total_req-sockets;\n\t\tif(total_req == 1.0) {\n\t\t\tSystem.out.println(0);\n\t\t\tSystem.exit(0);\n\t\t}\n\t\t//System.out.println(mid);\n\t\tdouble total = Math.ceil(mid/(sockets-1));\n\t\t//System.out.println(total);\n\t\tif(sockets>=total_req) {\n\t\t\tSystem.out.println(1);\n\t\t\tSystem.exit(0);\n\t\t}\n//\t\tif(total < 1.0 && total != 0) {\n//\t\t\ttotal = 1.0;\n//\t\t}\n\t\ttotal++;\n\t\tSystem.out.println((int)(total));\n\t\t\n\n\t}\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": 609, "cpu_time_ms": 110, "memory_kb": 25172}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s547153447", "group_id": "codeNet:p02923", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\tScanner scan = new Scanner(System.in);\n\t\tint masuNum = scan.nextInt();\n\t\tint[] h = new int[masuNum];\n\n\t\tfor(int i=0;i= masuNum-1-i) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tfor(int ii=0;ii= masuNum-1-i) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif(h[i+ii] >= h[i+ii+1]) {\n\t\t\t\t\tidouNum += 1;\n\t\t\t\t\tif(idouNum > kIdou) {\n\t\t\t\t\t\tkIdou = idouNum;\n\t\t\t\t\t}\n\t\t\t\t}else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(kIdou);\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1567368584, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02923.html", "problem_id": "p02923", "resource_group": "high_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/Java/s547153447.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s547153447", "user_id": "u265394171"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\tScanner scan = new Scanner(System.in);\n\t\tint masuNum = scan.nextInt();\n\t\tint[] h = new int[masuNum];\n\n\t\tfor(int i=0;i= masuNum-1-i) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tfor(int ii=0;ii= masuNum-1-i) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif(h[i+ii] >= h[i+ii+1]) {\n\t\t\t\t\tidouNum += 1;\n\t\t\t\t\tif(idouNum > kIdou) {\n\t\t\t\t\t\tkIdou = idouNum;\n\t\t\t\t\t}\n\t\t\t\t}else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(kIdou);\n\t}\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": 695, "cpu_time_ms": 465, "memory_kb": 50456}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s635128948", "group_id": "codeNet:p02923", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\tScanner scan = new Scanner(System.in);\n\t\tint masuNum = scan.nextInt();\n\t\tint[] h = new int[masuNum];\n\n\t\tfor(int i=0;i= h[i+ii+1]) {\n\t\t\t\t\tidouNum += 1;\n\t\t\t\t\tif(idouNum > kIdou) {\n\t\t\t\t\t\tkIdou = idouNum;\n\t\t\t\t\t}\n\t\t\t\t}else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(kIdou);\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1567367416, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02923.html", "problem_id": "p02923", "resource_group": "high_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/Java/s635128948.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s635128948", "user_id": "u265394171"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\tScanner scan = new Scanner(System.in);\n\t\tint masuNum = scan.nextInt();\n\t\tint[] h = new int[masuNum];\n\n\t\tfor(int i=0;i= h[i+ii+1]) {\n\t\t\t\t\tidouNum += 1;\n\t\t\t\t\tif(idouNum > kIdou) {\n\t\t\t\t\t\tkIdou = idouNum;\n\t\t\t\t\t}\n\t\t\t\t}else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(kIdou);\n\t}\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": 617, "cpu_time_ms": 2109, "memory_kb": 49996}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s930869324", "group_id": "codeNet:p02923", "input_text": "import java.io.*;\nimport java.util.*;\n\n@SuppressWarnings(\"unused\")\npublic class Main {\n FastScanner in = new FastScanner(System.in);\n PrintWriter out = new PrintWriter(System.out);\n final int MOD = (int)1e9+7;\n void printlnYN(boolean b){out.println((b ? \"Yes\" : \"No\"));}\n\n void solve() throws Exception{\n int N = in.nextInt();\n int[] H = in.nextIntArray(N);\n int sum = 0, max = 0, now = H[0];\n for(int i = 1; i < N; i++){\n if(H[i] <= now){\n sum++;\n now = H[i];\n max = Math.max(max, sum);\n }else{\n sum = 0;\n now = H[i];\n }\n }\n out.println(max);\n }\n\n\n public static void main(String[] args) throws Exception {\n new Main().m();\n }\n\n void m() throws Exception {\n solve();\n out.flush();\n }\n\n static class FastScanner {\n Reader input;\n\n FastScanner() {this(System.in);}\n FastScanner(InputStream stream) {this.input = new BufferedReader(new InputStreamReader(stream));}\n\n int nextInt() {return (int) nextLong();}\n\n long nextLong() {\n try {\n int sign = 1;\n int b = input.read();\n while ((b < '0' || '9' < b) && b != '-' && b != '+') {\n b = input.read();\n }\n if (b == '-') {\n sign = -1;\n b = input.read();\n } else if (b == '+') {\n b = input.read();\n }\n long ret = b - '0';\n while (true) {\n b = input.read();\n if (b < '0' || '9' < b) return ret * sign;\n ret *= 10;\n ret += b - '0';\n }\n } catch (IOException e) {\n e.printStackTrace();\n return -1;\n }\n }\n\n double nextDouble() {\n try {\n double sign = 1;\n int b = input.read();\n while ((b < '0' || '9' < b) && b != '-' && b != '+') {\n b = input.read();\n }\n if (b == '-') {\n sign = -1;\n b = input.read();\n } else if (b == '+') {\n b = input.read();\n }\n double ret = b - '0';\n while (true) {\n b = input.read();\n if (b < '0' || '9' < b) break;\n ret *= 10;\n ret += b - '0';\n }\n if (b != '.') return sign * ret;\n double div = 1;\n b = input.read();\n while ('0' <= b && b <= '9') {\n ret *= 10;\n ret += b - '0';\n div *= 10;\n b = input.read();\n }\n return sign * ret / div;\n } catch (IOException e) {\n e.printStackTrace();\n return Double.NaN;\n }\n }\n\n char nextChar() {\n try {\n int b = input.read();\n while (Character.isWhitespace(b)) {\n b = input.read();\n }\n return (char) b;\n } catch (IOException e) {\n e.printStackTrace();\n return 0;\n }\n }\n\n String nextStr() {\n try {\n StringBuilder sb = new StringBuilder();\n int b = input.read();\n while (Character.isWhitespace(b)) {\n b = input.read();\n }\n while (b != -1 && !Character.isWhitespace(b)) {\n sb.append((char) b);\n b = input.read();\n }\n return sb.toString();\n } catch (IOException e) {\n e.printStackTrace();\n return \"\";\n }\n }\n\n public int[] nextIntArray(int n) {\n int[] res = new int[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextInt();\n }\n return res;\n }\n\n public int[] nextIntArrayDec(int n) {\n int[] res = new int[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextInt() - 1;\n }\n return res;\n }\n\n public int[] nextIntArray1Index(int n) {\n int[] res = new int[n + 1];\n for (int i = 0; i < n; i++) {\n res[i + 1] = nextInt();\n }\n return res;\n }\n\n public long[] nextLongArray(int n) {\n long[] res = new long[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextLong();\n }\n return res;\n }\n\n public long[] nextLongArrayDec(int n) {\n long[] res = new long[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextLong() - 1;\n }\n return res;\n }\n\n public long[] nextLongArray1Index(int n) {\n long[] res = new long[n + 1];\n for (int i = 0; i < n; i++) {\n res[i + 1] = nextLong();\n }\n return res;\n }\n\n public double[] nextDoubleArray(int n) {\n double[] res = new double[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextDouble();\n }\n return res;\n }\n\n public Long[] nextWrapperLongArray(int n) {\n Long[] res = new Long[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextLong();\n }\n return res;\n }\n\n public Long[] nextWrapperLongArrayDec(int n) {\n Long[] res = new Long[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextLong() - 1;\n }\n return res;\n }\n\n public Long[] nextWrapperLongArray1Index(int n) {\n Long[] res = new Long[n + 1];\n for (int i = 0; i < n; i++) {\n res[i + 1] = nextLong();\n }\n return res;\n }\n }\n}", "language": "Java", "metadata": {"date": 1567365960, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02923.html", "problem_id": "p02923", "resource_group": "high_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/Java/s930869324.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s930869324", "user_id": "u234826697"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\n\n@SuppressWarnings(\"unused\")\npublic class Main {\n FastScanner in = new FastScanner(System.in);\n PrintWriter out = new PrintWriter(System.out);\n final int MOD = (int)1e9+7;\n void printlnYN(boolean b){out.println((b ? \"Yes\" : \"No\"));}\n\n void solve() throws Exception{\n int N = in.nextInt();\n int[] H = in.nextIntArray(N);\n int sum = 0, max = 0, now = H[0];\n for(int i = 1; i < N; i++){\n if(H[i] <= now){\n sum++;\n now = H[i];\n max = Math.max(max, sum);\n }else{\n sum = 0;\n now = H[i];\n }\n }\n out.println(max);\n }\n\n\n public static void main(String[] args) throws Exception {\n new Main().m();\n }\n\n void m() throws Exception {\n solve();\n out.flush();\n }\n\n static class FastScanner {\n Reader input;\n\n FastScanner() {this(System.in);}\n FastScanner(InputStream stream) {this.input = new BufferedReader(new InputStreamReader(stream));}\n\n int nextInt() {return (int) nextLong();}\n\n long nextLong() {\n try {\n int sign = 1;\n int b = input.read();\n while ((b < '0' || '9' < b) && b != '-' && b != '+') {\n b = input.read();\n }\n if (b == '-') {\n sign = -1;\n b = input.read();\n } else if (b == '+') {\n b = input.read();\n }\n long ret = b - '0';\n while (true) {\n b = input.read();\n if (b < '0' || '9' < b) return ret * sign;\n ret *= 10;\n ret += b - '0';\n }\n } catch (IOException e) {\n e.printStackTrace();\n return -1;\n }\n }\n\n double nextDouble() {\n try {\n double sign = 1;\n int b = input.read();\n while ((b < '0' || '9' < b) && b != '-' && b != '+') {\n b = input.read();\n }\n if (b == '-') {\n sign = -1;\n b = input.read();\n } else if (b == '+') {\n b = input.read();\n }\n double ret = b - '0';\n while (true) {\n b = input.read();\n if (b < '0' || '9' < b) break;\n ret *= 10;\n ret += b - '0';\n }\n if (b != '.') return sign * ret;\n double div = 1;\n b = input.read();\n while ('0' <= b && b <= '9') {\n ret *= 10;\n ret += b - '0';\n div *= 10;\n b = input.read();\n }\n return sign * ret / div;\n } catch (IOException e) {\n e.printStackTrace();\n return Double.NaN;\n }\n }\n\n char nextChar() {\n try {\n int b = input.read();\n while (Character.isWhitespace(b)) {\n b = input.read();\n }\n return (char) b;\n } catch (IOException e) {\n e.printStackTrace();\n return 0;\n }\n }\n\n String nextStr() {\n try {\n StringBuilder sb = new StringBuilder();\n int b = input.read();\n while (Character.isWhitespace(b)) {\n b = input.read();\n }\n while (b != -1 && !Character.isWhitespace(b)) {\n sb.append((char) b);\n b = input.read();\n }\n return sb.toString();\n } catch (IOException e) {\n e.printStackTrace();\n return \"\";\n }\n }\n\n public int[] nextIntArray(int n) {\n int[] res = new int[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextInt();\n }\n return res;\n }\n\n public int[] nextIntArrayDec(int n) {\n int[] res = new int[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextInt() - 1;\n }\n return res;\n }\n\n public int[] nextIntArray1Index(int n) {\n int[] res = new int[n + 1];\n for (int i = 0; i < n; i++) {\n res[i + 1] = nextInt();\n }\n return res;\n }\n\n public long[] nextLongArray(int n) {\n long[] res = new long[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextLong();\n }\n return res;\n }\n\n public long[] nextLongArrayDec(int n) {\n long[] res = new long[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextLong() - 1;\n }\n return res;\n }\n\n public long[] nextLongArray1Index(int n) {\n long[] res = new long[n + 1];\n for (int i = 0; i < n; i++) {\n res[i + 1] = nextLong();\n }\n return res;\n }\n\n public double[] nextDoubleArray(int n) {\n double[] res = new double[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextDouble();\n }\n return res;\n }\n\n public Long[] nextWrapperLongArray(int n) {\n Long[] res = new Long[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextLong();\n }\n return res;\n }\n\n public Long[] nextWrapperLongArrayDec(int n) {\n Long[] res = new Long[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextLong() - 1;\n }\n return res;\n }\n\n public Long[] nextWrapperLongArray1Index(int n) {\n Long[] res = new Long[n + 1];\n for (int i = 0; i < n; i++) {\n res[i + 1] = nextLong();\n }\n return res;\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": 6248, "cpu_time_ms": 133, "memory_kb": 24404}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s826059950", "group_id": "codeNet:p02923", "input_text": "import java.io.*;\nimport java.util.*;\n\nimport static java.lang.Math.*;\nimport static java.lang.String.format;\n\npublic class Main {\n public static void main(String[] args) {\n solve();\n }\n final static int INF = Integer.MAX_VALUE>>1;\n final static int MOD = 1_000_000_007;\n final static int[] dx4 = { 0, 1, 0, -1 };\n final static int[] dy4 = { 1, 0, -1, 0 };\n final static int[] dx8 = {0, 1, 1, 1, 0, -1, -1, -1};\n final static int[] dy8 = {1, 1, 0, -1, -1, -1, 0, 1};\n final static Runnable me=()->{};\n public static void solve(){\n //TODO:Solve problem like ***\n Scanner sc=new Scanner();\n int n = sc.nextInt();\n int[] h = new int[n];\n for (int i = 0; i < n; i++) {\n h[i] = sc.nextInt();\n }\n int max = 0;\n for (int i = n - 1, len = 0; i >0; i--) {\n if(h[i-1]>=h[i]){\n len++;\n max = max(max, len);\n }else{\n len=0;\n }\n }\n put(max);\n\n }\n private static Runnable func(Object... objects){\n try{\n assert false;\n return me;\n }catch(AssertionError e){\n return ()->{put(objects);};\n }\n }\n private static void print(Object... objects){\n if(objects.length==1){\n System.out.print(objects[0]);\n }else{\n System.out.print(Arrays.toString(objects));\n }\n }\n private static void put(Object... objects) {\n print(objects);\n put();\n }\n private static void put(){\n System.out.println();\n }\n\n\n private static void runWhenEA(Runnable runnable){\n try{\n assert false;\n }catch(AssertionError e){\n PrintStream ps=System.out;\n PrintStream pse=System.err;\n System.setOut(pse);\n runnable.run();\n System.setOut(ps);\n }\n }\n private static void putM(String name,char[][] mat){\n put(\"---------------------\"+name+\"-----------------\");\n for (int i = 0; i < mat.length; i++) {\n put(Arrays.toString(mat[i]));\n }\n }\n private static void putM(String name,int[][] mat){\n put(\"---------------------\"+name+\"-----------------\");\n for (int i = 0; i < mat.length; i++) {\n put(Arrays.toString(mat[i]));\n }\n }\n private static void putM(String name,long[][] mat){\n put(\"---------------------\"+name+\"-----------------\");\n for (int i = 0; i < mat.length; i++) {\n put(Arrays.toString(mat[i]));\n }\n }\n private static void putM(String name,boolean[][] mat){\n put(\"---------------------\"+name+\"-----------------\");\n for (int i = 0; i < mat.length; i++) {\n put(Arrays.toString(mat[i]));\n }\n }\n final static private class Scanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte())\n return buffer[ptr++];\n else\n return -1;\n }\n\n private boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr]))\n ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext())\n throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext())\n throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)\n throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n }\n final static private class FixedIntPair {\n final public int x, y;\n final static public FixedIntPair ZEROS=new FixedIntPair(0,0);\n FixedIntPair(int x, int y) {\n this.x = x;\n this.y = y;\n }\n public static double distance(FixedIntPair fip1,FixedIntPair fip2){\n double x = (double) fip1.x - fip2.x;\n double y = (double) fip1.y - fip2.y;\n return Math.sqrt(x*x+y*y);\n }\n\n @Override\n public int hashCode() {\n return x+y;\n }\n\n @Override\n public boolean equals(Object obj) {\n if(obj==null)return false;\n if(!(obj instanceof FixedIntPair)) return false;\n FixedIntPair pair=(FixedIntPair) obj;\n return this.x==pair.x&&this.y==pair.y;\n }\n\n @Override\n public String toString() {\n return format(FixedIntPair.class.getSimpleName()+\":(%d,%d)\", x, y);\n }\n }\n final static private class FixedLongPair {\n final public long x, y;\n final static public FixedLongPair ZEROS=new FixedLongPair(0,0);\n FixedLongPair(long x, long y) {\n this.x = x;\n this.y = y;\n }\n public static double distance(FixedLongPair flp1,FixedLongPair flp2){\n double x = (double) flp1.x - flp2.x;\n double y = (double) flp1.y - flp2.y;\n return Math.sqrt(x*x+y*y);\n }\n\n @Override\n public int hashCode() {\n return (int)x+(int)y;\n }\n\n @Override\n public boolean equals(Object obj) {\n if(obj==null)return false;\n if(!(obj instanceof FixedLongPair)) return false;\n FixedLongPair pair=(FixedLongPair)obj;\n return this.x==pair.x&&this.y==pair.y;\n }\n\n @Override\n public String toString() {\n return format(FixedLongPair.class.getSimpleName()+\":(%d,%d)\", x, y);\n }\n }\n final static private class Binary{\n public static String toZeroPadding(int i){\n return format(\"%\"+Integer.toBinaryString(-1).length()+\"s\",Integer.toBinaryString(i)).replace(' ','0');\n }\n public static String toZeroPadding(long i){\n return format(\"%\"+Long.toBinaryString(-1).length()+\"s\",Long.toBinaryString(i)).replace(' ','0');\n }\n }\n\n final static private class Util {\n static long gcd(long a,long b){\n a= abs(a);\n b= abs(b);\n if(a=0&&i=0&&j>1;\n final static int MOD = 1_000_000_007;\n final static int[] dx4 = { 0, 1, 0, -1 };\n final static int[] dy4 = { 1, 0, -1, 0 };\n final static int[] dx8 = {0, 1, 1, 1, 0, -1, -1, -1};\n final static int[] dy8 = {1, 1, 0, -1, -1, -1, 0, 1};\n final static Runnable me=()->{};\n public static void solve(){\n //TODO:Solve problem like ***\n Scanner sc=new Scanner();\n int n = sc.nextInt();\n int[] h = new int[n];\n for (int i = 0; i < n; i++) {\n h[i] = sc.nextInt();\n }\n int max = 0;\n for (int i = n - 1, len = 0; i >0; i--) {\n if(h[i-1]>=h[i]){\n len++;\n max = max(max, len);\n }else{\n len=0;\n }\n }\n put(max);\n\n }\n private static Runnable func(Object... objects){\n try{\n assert false;\n return me;\n }catch(AssertionError e){\n return ()->{put(objects);};\n }\n }\n private static void print(Object... objects){\n if(objects.length==1){\n System.out.print(objects[0]);\n }else{\n System.out.print(Arrays.toString(objects));\n }\n }\n private static void put(Object... objects) {\n print(objects);\n put();\n }\n private static void put(){\n System.out.println();\n }\n\n\n private static void runWhenEA(Runnable runnable){\n try{\n assert false;\n }catch(AssertionError e){\n PrintStream ps=System.out;\n PrintStream pse=System.err;\n System.setOut(pse);\n runnable.run();\n System.setOut(ps);\n }\n }\n private static void putM(String name,char[][] mat){\n put(\"---------------------\"+name+\"-----------------\");\n for (int i = 0; i < mat.length; i++) {\n put(Arrays.toString(mat[i]));\n }\n }\n private static void putM(String name,int[][] mat){\n put(\"---------------------\"+name+\"-----------------\");\n for (int i = 0; i < mat.length; i++) {\n put(Arrays.toString(mat[i]));\n }\n }\n private static void putM(String name,long[][] mat){\n put(\"---------------------\"+name+\"-----------------\");\n for (int i = 0; i < mat.length; i++) {\n put(Arrays.toString(mat[i]));\n }\n }\n private static void putM(String name,boolean[][] mat){\n put(\"---------------------\"+name+\"-----------------\");\n for (int i = 0; i < mat.length; i++) {\n put(Arrays.toString(mat[i]));\n }\n }\n final static private class Scanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte())\n return buffer[ptr++];\n else\n return -1;\n }\n\n private boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr]))\n ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext())\n throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext())\n throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)\n throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n }\n final static private class FixedIntPair {\n final public int x, y;\n final static public FixedIntPair ZEROS=new FixedIntPair(0,0);\n FixedIntPair(int x, int y) {\n this.x = x;\n this.y = y;\n }\n public static double distance(FixedIntPair fip1,FixedIntPair fip2){\n double x = (double) fip1.x - fip2.x;\n double y = (double) fip1.y - fip2.y;\n return Math.sqrt(x*x+y*y);\n }\n\n @Override\n public int hashCode() {\n return x+y;\n }\n\n @Override\n public boolean equals(Object obj) {\n if(obj==null)return false;\n if(!(obj instanceof FixedIntPair)) return false;\n FixedIntPair pair=(FixedIntPair) obj;\n return this.x==pair.x&&this.y==pair.y;\n }\n\n @Override\n public String toString() {\n return format(FixedIntPair.class.getSimpleName()+\":(%d,%d)\", x, y);\n }\n }\n final static private class FixedLongPair {\n final public long x, y;\n final static public FixedLongPair ZEROS=new FixedLongPair(0,0);\n FixedLongPair(long x, long y) {\n this.x = x;\n this.y = y;\n }\n public static double distance(FixedLongPair flp1,FixedLongPair flp2){\n double x = (double) flp1.x - flp2.x;\n double y = (double) flp1.y - flp2.y;\n return Math.sqrt(x*x+y*y);\n }\n\n @Override\n public int hashCode() {\n return (int)x+(int)y;\n }\n\n @Override\n public boolean equals(Object obj) {\n if(obj==null)return false;\n if(!(obj instanceof FixedLongPair)) return false;\n FixedLongPair pair=(FixedLongPair)obj;\n return this.x==pair.x&&this.y==pair.y;\n }\n\n @Override\n public String toString() {\n return format(FixedLongPair.class.getSimpleName()+\":(%d,%d)\", x, y);\n }\n }\n final static private class Binary{\n public static String toZeroPadding(int i){\n return format(\"%\"+Integer.toBinaryString(-1).length()+\"s\",Integer.toBinaryString(i)).replace(' ','0');\n }\n public static String toZeroPadding(long i){\n return format(\"%\"+Long.toBinaryString(-1).length()+\"s\",Long.toBinaryString(i)).replace(' ','0');\n }\n }\n\n final static private class Util {\n static long gcd(long a,long b){\n a= abs(a);\n b= abs(b);\n if(a=0&&i=0&&j map = new HashMap(n);\n\t/*for ( キーのデータ型 key : マップの名前.keySet() ) {\n\t\tデータのデータ型 data = マップの名前.get( key );\n\t\t\n\t\t// keyやdataを使った処理;\n\t}*/\n\t//int i = Integer.parseInt(s);\n\t//Queue qq=new ArrayDeque<>(); //add,poll,peek\n\t//Deque qq=new ArrayDeque<>();//push,pop,peek\n\t//ArrayList cc = new ArrayList<>(n);\n\t//Collections.sort(list);\n\t//Array.sort(list); cc.contains(tmp)\n\t//Arrays.asList(c).contains(\"a\")\n\t//list.set(1,\"walk\");//1 1 2 3 5\n\tstatic int K,N;\n\tstatic long mod =1000000007;\n\t//static \tArrayList cc = new ArrayList<>(100);\n//R 82 L 76\n\t\n\tstatic long D=0;\n\tpublic static void main(String[] args) {\n\t\tint N=sc.nextInt();\n\t\t\n\t\tp(N*(N-1)/2);\n\t\t\t\n\t\t\t//String S=sc.next();\n\t\t\t\n\t\t\t//int a[]=new int[N];\n\t\t\t//for(int i=0;i cc = new ArrayList<>(10001);\n\t\n\tstatic void p(String ans) {System.out.println(ans);};\n\tstatic void p(int ans) {System.out.println(ans);};\n\tstatic void p() {System.out.println();};\n\tstatic void p(long ans) {System.out.println(ans);};\n\tstatic void p(double ans) {System.out.println(ans);};\n\tpublic static int gcd(int a, int b) {\n return b == 0 ? a: gcd(b, a % b);\n\t}\n\tstatic String nextPermutation(String s) {\n\t\tArrayList list=new ArrayList<>();\n\t\tfor(int i=0;i=0;i--) {\n\t\t\tif(list.get(i)=L;i--) {\n\t\t\tif(pivot map = new HashMap(n);\n\t/*for ( キーのデータ型 key : マップの名前.keySet() ) {\n\t\tデータのデータ型 data = マップの名前.get( key );\n\t\t\n\t\t// keyやdataを使った処理;\n\t}*/\n\t//int i = Integer.parseInt(s);\n\t//Queue qq=new ArrayDeque<>(); //add,poll,peek\n\t//Deque qq=new ArrayDeque<>();//push,pop,peek\n\t//ArrayList cc = new ArrayList<>(n);\n\t//Collections.sort(list);\n\t//Array.sort(list); cc.contains(tmp)\n\t//Arrays.asList(c).contains(\"a\")\n\t//list.set(1,\"walk\");//1 1 2 3 5\n\tstatic int K,N;\n\tstatic long mod =1000000007;\n\t//static \tArrayList cc = new ArrayList<>(100);\n//R 82 L 76\n\t\n\tstatic long D=0;\n\tpublic static void main(String[] args) {\n\t\tint N=sc.nextInt();\n\t\t\n\t\tp(N*(N-1)/2);\n\t\t\t\n\t\t\t//String S=sc.next();\n\t\t\t\n\t\t\t//int a[]=new int[N];\n\t\t\t//for(int i=0;i cc = new ArrayList<>(10001);\n\t\n\tstatic void p(String ans) {System.out.println(ans);};\n\tstatic void p(int ans) {System.out.println(ans);};\n\tstatic void p() {System.out.println();};\n\tstatic void p(long ans) {System.out.println(ans);};\n\tstatic void p(double ans) {System.out.println(ans);};\n\tpublic static int gcd(int a, int b) {\n return b == 0 ? a: gcd(b, a % b);\n\t}\n\tstatic String nextPermutation(String s) {\n\t\tArrayList list=new ArrayList<>();\n\t\tfor(int i=0;i=0;i--) {\n\t\t\tif(list.get(i)=L;i--) {\n\t\t\tif(pivot[] graph;\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tIO io = new IO(System.in, System.out);\n\t\tint i, j, k;\n\t\n\t\tN = io.nextInt();\n\t\tgraph = new ArrayDeque[N];\n\t\tfor (i = 0; i < N; ++i) graph[i] = new ArrayDeque<>();\n\t\t\n\t\tfor (i = 0; i < N; ++i) for (j = 0; j < N - 1; ++j) {\n\t\t\tgraph[i].add(io.nextInt() - 1);\n\t\t}\n\t\t\n\t\tTimerTask tt = new TimerTask() {\n\t\t\tpublic void run() {\n\t\t\t\tSystem.out.println(N);\n\t\t\t\tSystem.exit(0);\n\t\t\t}\n\t\t};\n\t\tTimer t = new Timer();\n\t\tt.schedule(tt, 1800);\n\t\tnew Solver().solve(N, graph);\n\t}\n}\n\nclass Solver {\n\tvoid solve(int N, ArrayDeque[] graph) throws Exception {\n\t\tint i, j, k;\n\t\t\n\t\tint match = 0;\n\t\tHashSet exc = new HashSet<>(), participating = new HashSet<>();\n\t\tHashSet rem = new HashSet<>();\n\t\tfor (i = 0; i < N; ++i) participating.add(i);\n\t\t\n\t\tfor (i = 0; ; ++i) {\n\t\t\texc.clear();\n\t\t\tboolean ok = false;\n\t\t\trem.clear();\n\t\t\t\n\t\t\tfor (int itr : participating) if (!exc.contains(j = itr)) {\n\t\t\t\tint oth = graph[j].peekFirst();\n\t\t\t\tif (!exc.contains(oth) && graph[oth].peekFirst() == j) {\n\t\t\t\t\tok = true;\n\t\t\t\t\tgraph[j].pollFirst();\n\t\t\t\t\tgraph[oth].pollFirst();\n\t\t\t\t\t\n\t\t\t\t\tif (graph[j].isEmpty()) rem.add(j);\n\t\t\t\t\tif (graph[oth].isEmpty()) rem.add(oth);\n\t\t\t\t\t\n\t\t\t\t\texc.add(j); exc.add(oth);\n\t\t\t\t\t++match;\n\t\t\t\t\t\n\t\t\t\t\t//System.err.print(\"PPP: \" + j + \" \" + oth + \" \");\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tparticipating.removeAll(rem);\n\t\t\t\n\t\t\tif (!ok) {\n\t\t\t\tif (match == N * (N - 1) >> 1) {\n\t\t\t\t\tSystem.out.println(i);\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.println(-1);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tSystem.exit(0);\n\t\t\t}\n\t\t\t//System.err.println();\n\t\t}\n \t}\n}\n\n\n\n\nclass IO {\n static byte[] buf = new byte[2048];\n static int index, total;\n static InputStream in;\n static BufferedWriter bw;\n\n\n IO(InputStream is, OutputStream os) {\n try {\n in = is;\n bw = new BufferedWriter(new OutputStreamWriter(os));\n } catch (Exception e) {\n }\n }\n\n IO(String inputFile, String outputFile) {\n try {\n in = new FileInputStream(inputFile);\n bw = new BufferedWriter(new OutputStreamWriter(\n new FileOutputStream(outputFile)));\n } catch (Exception e) {\n }\n }\n\n int scan() throws Exception {\n if (index >= total) {\n index = 0;\n total = in.read(buf);\n if (total <= 0)\n return -1;\n }\n return buf[index++];\n }\n\n String next() throws Exception {\n int c;\n for (c = scan(); c <= 32; c = scan()) ;\n StringBuilder sb = new StringBuilder();\n for (; c > 32; c = scan())\n sb.append((char) c);\n return sb.toString();\n }\n\n int nextInt() throws Exception {\n int c, val = 0;\n for (c = scan(); c <= 32; c = scan()) ;\n boolean neg = c == '-';\n if (c == '-' || c == '+')\n c = scan();\n for (; c >= '0' && c <= '9'; c = scan())\n val = (val << 3) + (val << 1) + (c & 15);\n return neg ? -val : val;\n }\n long nextLong() throws Exception {\n int c;\n long val = 0;\n for (c = scan(); c <= 32; c = scan()) ;\n boolean neg = c == '-';\n if (c == '-' || c == '+')\n c = scan();\n for (; c >= '0' && c <= '9'; c = scan())\n val = (val << 3) + (val << 1) + (c & 15);\n return neg ? -val : val;\n }\n void print(Object a) throws Exception {\n bw.write(a.toString());\n }\n void println() throws Exception {\n bw.write(\"\\n\");\n }\n void println(Object a) throws Exception {\n print(a);\n println();\n }\n void flush() throws Exception {\n bw.flush();\n bw.close();\n }\n}", "language": "Java", "metadata": {"date": 1567369809, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02925.html", "problem_id": "p02925", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02925/input.txt", "sample_output_relpath": "derived/input_output/data/p02925/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02925/Java/s217591269.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s217591269", "user_id": "u481050822"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n\tstatic int N;\n\tstatic ArrayDeque[] graph;\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tIO io = new IO(System.in, System.out);\n\t\tint i, j, k;\n\t\n\t\tN = io.nextInt();\n\t\tgraph = new ArrayDeque[N];\n\t\tfor (i = 0; i < N; ++i) graph[i] = new ArrayDeque<>();\n\t\t\n\t\tfor (i = 0; i < N; ++i) for (j = 0; j < N - 1; ++j) {\n\t\t\tgraph[i].add(io.nextInt() - 1);\n\t\t}\n\t\t\n\t\tTimerTask tt = new TimerTask() {\n\t\t\tpublic void run() {\n\t\t\t\tSystem.out.println(N);\n\t\t\t\tSystem.exit(0);\n\t\t\t}\n\t\t};\n\t\tTimer t = new Timer();\n\t\tt.schedule(tt, 1800);\n\t\tnew Solver().solve(N, graph);\n\t}\n}\n\nclass Solver {\n\tvoid solve(int N, ArrayDeque[] graph) throws Exception {\n\t\tint i, j, k;\n\t\t\n\t\tint match = 0;\n\t\tHashSet exc = new HashSet<>(), participating = new HashSet<>();\n\t\tHashSet rem = new HashSet<>();\n\t\tfor (i = 0; i < N; ++i) participating.add(i);\n\t\t\n\t\tfor (i = 0; ; ++i) {\n\t\t\texc.clear();\n\t\t\tboolean ok = false;\n\t\t\trem.clear();\n\t\t\t\n\t\t\tfor (int itr : participating) if (!exc.contains(j = itr)) {\n\t\t\t\tint oth = graph[j].peekFirst();\n\t\t\t\tif (!exc.contains(oth) && graph[oth].peekFirst() == j) {\n\t\t\t\t\tok = true;\n\t\t\t\t\tgraph[j].pollFirst();\n\t\t\t\t\tgraph[oth].pollFirst();\n\t\t\t\t\t\n\t\t\t\t\tif (graph[j].isEmpty()) rem.add(j);\n\t\t\t\t\tif (graph[oth].isEmpty()) rem.add(oth);\n\t\t\t\t\t\n\t\t\t\t\texc.add(j); exc.add(oth);\n\t\t\t\t\t++match;\n\t\t\t\t\t\n\t\t\t\t\t//System.err.print(\"PPP: \" + j + \" \" + oth + \" \");\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tparticipating.removeAll(rem);\n\t\t\t\n\t\t\tif (!ok) {\n\t\t\t\tif (match == N * (N - 1) >> 1) {\n\t\t\t\t\tSystem.out.println(i);\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.println(-1);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tSystem.exit(0);\n\t\t\t}\n\t\t\t//System.err.println();\n\t\t}\n \t}\n}\n\n\n\n\nclass IO {\n static byte[] buf = new byte[2048];\n static int index, total;\n static InputStream in;\n static BufferedWriter bw;\n\n\n IO(InputStream is, OutputStream os) {\n try {\n in = is;\n bw = new BufferedWriter(new OutputStreamWriter(os));\n } catch (Exception e) {\n }\n }\n\n IO(String inputFile, String outputFile) {\n try {\n in = new FileInputStream(inputFile);\n bw = new BufferedWriter(new OutputStreamWriter(\n new FileOutputStream(outputFile)));\n } catch (Exception e) {\n }\n }\n\n int scan() throws Exception {\n if (index >= total) {\n index = 0;\n total = in.read(buf);\n if (total <= 0)\n return -1;\n }\n return buf[index++];\n }\n\n String next() throws Exception {\n int c;\n for (c = scan(); c <= 32; c = scan()) ;\n StringBuilder sb = new StringBuilder();\n for (; c > 32; c = scan())\n sb.append((char) c);\n return sb.toString();\n }\n\n int nextInt() throws Exception {\n int c, val = 0;\n for (c = scan(); c <= 32; c = scan()) ;\n boolean neg = c == '-';\n if (c == '-' || c == '+')\n c = scan();\n for (; c >= '0' && c <= '9'; c = scan())\n val = (val << 3) + (val << 1) + (c & 15);\n return neg ? -val : val;\n }\n long nextLong() throws Exception {\n int c;\n long val = 0;\n for (c = scan(); c <= 32; c = scan()) ;\n boolean neg = c == '-';\n if (c == '-' || c == '+')\n c = scan();\n for (; c >= '0' && c <= '9'; c = scan())\n val = (val << 3) + (val << 1) + (c & 15);\n return neg ? -val : val;\n }\n void print(Object a) throws Exception {\n bw.write(a.toString());\n }\n void println() throws Exception {\n bw.write(\"\\n\");\n }\n void println(Object a) throws Exception {\n print(a);\n println();\n }\n void flush() throws Exception {\n bw.flush();\n bw.close();\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nN players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\n\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.\n\nEach player plays at most one matches in a day.\n\nEach player i (1 \\leq i \\leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} in this order.\n\nConstraints\n\n3 \\leq N \\leq 1000\n\n1 \\leq A_{i, j} \\leq N\n\nA_{i, j} \\neq i\n\nA_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} \\ldots A_{1, N-1}\nA_{2, 1} A_{2, 2} \\ldots A_{2, N-1}\n:\nA_{N, 1} A_{N, 2} \\ldots A_{N, N-1}\n\nOutput\n\nIf it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print -1.\n\nSample Input 1\n\n3\n2 3\n1 3\n1 2\n\nSample Output 1\n\n3\n\nAll the conditions can be satisfied if the matches are scheduled for three days as follows:\n\nDay 1: Player 1 vs Player 2\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\nSample Input 2\n\n4\n2 3 4\n1 3 4\n4 1 2\n3 1 2\n\nSample Output 2\n\n4\n\nAll the conditions can be satisfied if the matches are scheduled for four days as follows:\n\nDay 1: Player 1 vs Player 2, Player 3 vs Player 4\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 1 vs Player 4, Player 2 vs Player 3\n\nDay 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\nSample Input 3\n\n3\n2 3\n3 1\n1 2\n\nSample Output 3\n\n-1\n\nAny scheduling of the matches violates some condition.", "sample_input": "3\n2 3\n1 3\n1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02925", "source_text": "Score : 500 points\n\nProblem Statement\n\nN players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\n\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.\n\nEach player plays at most one matches in a day.\n\nEach player i (1 \\leq i \\leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} in this order.\n\nConstraints\n\n3 \\leq N \\leq 1000\n\n1 \\leq A_{i, j} \\leq N\n\nA_{i, j} \\neq i\n\nA_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} \\ldots A_{1, N-1}\nA_{2, 1} A_{2, 2} \\ldots A_{2, N-1}\n:\nA_{N, 1} A_{N, 2} \\ldots A_{N, N-1}\n\nOutput\n\nIf it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print -1.\n\nSample Input 1\n\n3\n2 3\n1 3\n1 2\n\nSample Output 1\n\n3\n\nAll the conditions can be satisfied if the matches are scheduled for three days as follows:\n\nDay 1: Player 1 vs Player 2\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\nSample Input 2\n\n4\n2 3 4\n1 3 4\n4 1 2\n3 1 2\n\nSample Output 2\n\n4\n\nAll the conditions can be satisfied if the matches are scheduled for four days as follows:\n\nDay 1: Player 1 vs Player 2, Player 3 vs Player 4\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 1 vs Player 4, Player 2 vs Player 3\n\nDay 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\nSample Input 3\n\n3\n2 3\n3 1\n1 2\n\nSample Output 3\n\n-1\n\nAny scheduling of the matches violates some condition.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3792, "cpu_time_ms": 1949, "memory_kb": 295400}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s440833806", "group_id": "codeNet:p02925", "input_text": "import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.util.ArrayDeque;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.Queue;\n\npublic class Main {\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tList> list = new ArrayList<>(n);\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] sa = br.readLine().split(\" \");\n\t\t\tQueue que = new ArrayDeque<>();\n\t\t\tlist.add(que);\n\t\t\tfor (int j = 0; j < sa.length; j++) {\n\t\t\t\tque.add(Integer.parseInt(sa[j]) - 1);\n\t\t\t}\n\t\t}\n\t\tbr.close();\n\n\t\tint ans = 0;\n\t\twhile (true) {\n\t\t\tans++;\n\t\t\tboolean[] flg = new boolean[n];\n\t\t\tboolean flg2 = false;\n\t\t\tboolean[] flg3 = new boolean[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tif (flg[i]) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tQueue que = list.get(i);\n\t\t\t\tif (que.isEmpty()) {\n\t\t\t\t\tflg3[i] = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tint o = que.peek();\n\n\t\t\t\tif (flg[o]) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tQueue que2 = list.get(o);\n\t\t\t\tif (que2.isEmpty()) {\n\t\t\t\t\tflg3[o] = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tint o2 = que2.peek();\n\n\t\t\t\tif (o2 == i) {\n\t\t\t\t\tque.poll();\n\t\t\t\t\tque2.poll();\n\t\t\t\t\tflg[o] = true;\n\t\t\t\t\tflg[o2] = true;\n\t\t\t\t\tflg2 = true;\n\t\t\t\t\tif (que.isEmpty()) {\n\t\t\t\t\t\tflg3[i] = true;\n\t\t\t\t\t}\n\t\t\t\t\tif (que2.isEmpty()) {\n\t\t\t\t\t\tflg3[o] = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tboolean flg4 = true;\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tif (!flg3[i]) {\n\t\t\t\t\tflg4 = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (flg4) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (!flg2) {\n\t\t\t\tSystem.out.println(-1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1567368145, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02925.html", "problem_id": "p02925", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02925/input.txt", "sample_output_relpath": "derived/input_output/data/p02925/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02925/Java/s440833806.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s440833806", "user_id": "u522636435"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.util.ArrayDeque;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.Queue;\n\npublic class Main {\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tint n = Integer.parseInt(br.readLine());\n\t\tList> list = new ArrayList<>(n);\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] sa = br.readLine().split(\" \");\n\t\t\tQueue que = new ArrayDeque<>();\n\t\t\tlist.add(que);\n\t\t\tfor (int j = 0; j < sa.length; j++) {\n\t\t\t\tque.add(Integer.parseInt(sa[j]) - 1);\n\t\t\t}\n\t\t}\n\t\tbr.close();\n\n\t\tint ans = 0;\n\t\twhile (true) {\n\t\t\tans++;\n\t\t\tboolean[] flg = new boolean[n];\n\t\t\tboolean flg2 = false;\n\t\t\tboolean[] flg3 = new boolean[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tif (flg[i]) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tQueue que = list.get(i);\n\t\t\t\tif (que.isEmpty()) {\n\t\t\t\t\tflg3[i] = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tint o = que.peek();\n\n\t\t\t\tif (flg[o]) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tQueue que2 = list.get(o);\n\t\t\t\tif (que2.isEmpty()) {\n\t\t\t\t\tflg3[o] = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tint o2 = que2.peek();\n\n\t\t\t\tif (o2 == i) {\n\t\t\t\t\tque.poll();\n\t\t\t\t\tque2.poll();\n\t\t\t\t\tflg[o] = true;\n\t\t\t\t\tflg[o2] = true;\n\t\t\t\t\tflg2 = true;\n\t\t\t\t\tif (que.isEmpty()) {\n\t\t\t\t\t\tflg3[i] = true;\n\t\t\t\t\t}\n\t\t\t\t\tif (que2.isEmpty()) {\n\t\t\t\t\t\tflg3[o] = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tboolean flg4 = true;\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tif (!flg3[i]) {\n\t\t\t\t\tflg4 = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (flg4) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (!flg2) {\n\t\t\t\tSystem.out.println(-1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nN players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\n\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.\n\nEach player plays at most one matches in a day.\n\nEach player i (1 \\leq i \\leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} in this order.\n\nConstraints\n\n3 \\leq N \\leq 1000\n\n1 \\leq A_{i, j} \\leq N\n\nA_{i, j} \\neq i\n\nA_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} \\ldots A_{1, N-1}\nA_{2, 1} A_{2, 2} \\ldots A_{2, N-1}\n:\nA_{N, 1} A_{N, 2} \\ldots A_{N, N-1}\n\nOutput\n\nIf it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print -1.\n\nSample Input 1\n\n3\n2 3\n1 3\n1 2\n\nSample Output 1\n\n3\n\nAll the conditions can be satisfied if the matches are scheduled for three days as follows:\n\nDay 1: Player 1 vs Player 2\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\nSample Input 2\n\n4\n2 3 4\n1 3 4\n4 1 2\n3 1 2\n\nSample Output 2\n\n4\n\nAll the conditions can be satisfied if the matches are scheduled for four days as follows:\n\nDay 1: Player 1 vs Player 2, Player 3 vs Player 4\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 1 vs Player 4, Player 2 vs Player 3\n\nDay 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\nSample Input 3\n\n3\n2 3\n3 1\n1 2\n\nSample Output 3\n\n-1\n\nAny scheduling of the matches violates some condition.", "sample_input": "3\n2 3\n1 3\n1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02925", "source_text": "Score : 500 points\n\nProblem Statement\n\nN players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\n\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.\n\nEach player plays at most one matches in a day.\n\nEach player i (1 \\leq i \\leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} in this order.\n\nConstraints\n\n3 \\leq N \\leq 1000\n\n1 \\leq A_{i, j} \\leq N\n\nA_{i, j} \\neq i\n\nA_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} \\ldots A_{1, N-1}\nA_{2, 1} A_{2, 2} \\ldots A_{2, N-1}\n:\nA_{N, 1} A_{N, 2} \\ldots A_{N, N-1}\n\nOutput\n\nIf it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print -1.\n\nSample Input 1\n\n3\n2 3\n1 3\n1 2\n\nSample Output 1\n\n3\n\nAll the conditions can be satisfied if the matches are scheduled for three days as follows:\n\nDay 1: Player 1 vs Player 2\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\nSample Input 2\n\n4\n2 3 4\n1 3 4\n4 1 2\n3 1 2\n\nSample Output 2\n\n4\n\nAll the conditions can be satisfied if the matches are scheduled for four days as follows:\n\nDay 1: Player 1 vs Player 2, Player 3 vs Player 4\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 1 vs Player 4, Player 2 vs Player 3\n\nDay 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\nSample Input 3\n\n3\n2 3\n3 1\n1 2\n\nSample Output 3\n\n-1\n\nAny scheduling of the matches violates some condition.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2105, "memory_kb": 109508}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s851559020", "group_id": "codeNet:p02925", "input_text": "import java.io.*;\nimport java.util.*;\n\n\npublic class Main {\n\n\tprivate static Scanner sc;\n\tprivate static Printer pr;\n\n\tprivate static void solve() {\n\t\tint n = sc.nextInt();\n\n\t\tint[][] a = new int[n][];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextIntArray(n - 1);\n\t\t}\n\t\t\n\t\tList> q = new ArrayList<>(n);\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tq.add(new ArrayDeque<>());\n\t\t}\n\n\t\tfor (int j = 0; j < n - 1; j++) {\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tint aa = a[i][j] - 1;\n\t\t\t\tq.get(aa).add(i);\n\t\t\t}\n\t\t}\n\n\t\tint cnt = 0;\n\t\twhile (true) {\n\t\t\tSet del = new HashSet<>();\n\t\t\tboolean[] used = new boolean[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tQueue qq = q.get(i);\n\t\t\t\tif (used[i] || qq.isEmpty()) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tint b = qq.peek();\n\t\t\t\tQueue qq2 = q.get(b);\n\t\t\t\tif (used[b] || qq2.isEmpty()) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tint c = qq2.peek();\n\t\t\t\t\n\t\t\t\tif (c == i) {\n\t\t\t\t\tdel.add(i);\n\t\t\t\t\tdel.add(b);\n\t\t\t\t\tused[i] = true;\n\t\t\t\t\tused[c] = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (int e : del) {\n\t\t\t\tq.get(e).remove();\n\t\t\t}\n\t\t\tcnt++;\n\t\t\t\n\t\t\tboolean flag = true;\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tif (!q.get(i).isEmpty()) {\n\t\t\t\t\tflag = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (flag) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\tif (del.isEmpty()) {\n\t\t\t\tpr.println(-1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpr.println(cnt);\n\t}\n\n\t// ---------------------------------------------------\n\tpublic static void main(String[] args) {\n\t\tsc = new Scanner(System.in);\n\t\tpr = new Printer(System.out);\n\t\t\t\n\t\tsolve();\n\t\t\t\n\t\tpr.close();\n\t\tsc.close();\n\t}\n\n\tstatic class Scanner {\n\t\tBufferedReader br;\n\n\t\tScanner (InputStream in) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(in));\n\t\t}\n\n\t\tprivate boolean isPrintable(int ch) {\n\t\t\treturn ch >= '!' && ch <= '~';\n\t\t}\n\n\t\tprivate boolean isCRLF(int ch) {\n\t\t\treturn ch == '\\n' || ch == '\\r' || ch == -1;\n\t\t}\n\n\t\tprivate int nextPrintable() {\n\t\t\ttry {\n\t\t\t\tint ch;\n\t\t\t\twhile (!isPrintable(ch = br.read())) {\n\t\t\t\t\tif (ch == -1) {\n\t\t\t\t\t\tthrow new NoSuchElementException();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn ch;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tString next() {\n\t\t\ttry {\n\t\t\t\tint ch = nextPrintable();\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tdo {\n\t\t\t\t\tsb.appendCodePoint(ch);\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn sb.toString();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tint nextInt() {\n\t\t\ttry {\n\t\t\t\t// parseInt from Integer.parseInt()\n\t\t\t\tboolean negative = false;\n\t\t\t\tint res = 0;\n\t\t\t\tint limit = -Integer.MAX_VALUE;\n\t\t\t\tint radix = 10;\n\n\t\t\t\tint fc = nextPrintable();\n\t\t\t\tif (fc < '0') {\n\t\t\t\t\tif (fc == '-') {\n\t\t\t\t\t\tnegative = true;\n\t\t\t\t\t\tlimit = Integer.MIN_VALUE;\n\t\t\t\t\t} else if (fc != '+') {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tfc = br.read();\n\t\t\t\t}\n\t\t\t\tint multmin = limit / radix;\n\n\t\t\t\tint ch = fc;\n\t\t\t\tdo {\n\t\t\t\t\tint digit = ch - '0';\n\t\t\t\t\tif (digit < 0 || digit >= radix) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tif (res < multmin) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres *= radix;\n\t\t\t\t\tif (res < limit + digit) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres -= digit;\n\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn negative ? res : -res;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\ttry {\n\t\t\t\t// parseLong from Long.parseLong()\n\t\t\t\tboolean negative = false;\n\t\t\t\tlong res = 0;\n\t\t\t\tlong limit = -Long.MAX_VALUE;\n\t\t\t\tint radix = 10;\n\n\t\t\t\tint fc = nextPrintable();\n\t\t\t\tif (fc < '0') {\n\t\t\t\t\tif (fc == '-') {\n\t\t\t\t\t\tnegative = true;\n\t\t\t\t\t\tlimit = Long.MIN_VALUE;\n\t\t\t\t\t} else if (fc != '+') {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tfc = br.read();\n\t\t\t\t}\n\t\t\t\tlong multmin = limit / radix;\n\n\t\t\t\tint ch = fc;\n\t\t\t\tdo {\n\t\t\t\t\tint digit = ch - '0';\n\t\t\t\t\tif (digit < 0 || digit >= radix) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tif (res < multmin) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres *= radix;\n\t\t\t\t\tif (res < limit + digit) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres -= digit;\n\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn negative ? res : -res;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tfloat nextFloat() {\n\t\t\treturn Float.parseFloat(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\ttry {\n\t\t\t\tint ch;\n\t\t\t\twhile (isCRLF(ch = br.read())) {\n\t\t\t\t\tif (ch == -1) {\n\t\t\t\t\t\tthrow new NoSuchElementException();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tdo {\n\t\t\t\t\tsb.appendCodePoint(ch);\n\t\t\t\t} while (!isCRLF(ch = br.read()));\n\n\t\t\t\treturn sb.toString();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\t\t\n\t\tint[] nextIntArray(int n) {\n\t\t\tint[] ret = new int[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tret[i] = sc.nextInt();\n\t\t\t}\n\t\t\t\n\t\t\treturn ret;\n\t\t}\n\n\t\tint[][] nextIntArrays(int n, int m) {\n\t\t\tint[][] ret = new int[m][n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tfor (int j = 0; j < m; j++) {\n\t\t\t\t\tret[j][i] = sc.nextInt();\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn ret;\n\t\t}\n\n\t\tvoid close() {\n\t\t\ttry {\n\t\t\t\tbr.close();\n\t\t\t} catch (IOException e) {\n//\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic class Printer extends PrintWriter {\n\t\tPrinter(OutputStream out) {\n\t\t\tsuper(out);\n\t\t}\n\t\t\n\t\tvoid printInts(int... a) {\n\t\t\tStringBuilder sb = new StringBuilder(32);\n\t\t\tfor (int i = 0, size = a.length; i < size; i++) {\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tsb.append(' ');\n\t\t\t\t}\n\t\t\t\tsb.append(a[i]);\n\t\t\t}\n\n\t\t\tprintln(sb);\n\t\t}\n\t\t\n\t\tvoid printLongs(long... a) {\n\t\t\tStringBuilder sb = new StringBuilder(64);\n\t\t\tfor (int i = 0, size = a.length; i < size; i++) {\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tsb.append(' ');\n\t\t\t\t}\n\t\t\t\tsb.append(a[i]);\n\t\t\t}\n\n\t\t\tprintln(sb);\n\t\t}\n\t\t\n\t\tvoid printStrings(String... a) {\n\t\t\tStringBuilder sb = new StringBuilder(32);\n\t\t\tfor (int i = 0, size = a.length; i < size; i++) {\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tsb.append(' ');\n\t\t\t\t}\n\t\t\t\tsb.append(a[i]);\n\t\t\t}\n\n\t\t\tprintln(sb);\n\t\t}\n\t}\n}\n", "language": "Java", "metadata": {"date": 1567367518, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02925.html", "problem_id": "p02925", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02925/input.txt", "sample_output_relpath": "derived/input_output/data/p02925/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02925/Java/s851559020.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s851559020", "user_id": "u900015623"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\n\n\npublic class Main {\n\n\tprivate static Scanner sc;\n\tprivate static Printer pr;\n\n\tprivate static void solve() {\n\t\tint n = sc.nextInt();\n\n\t\tint[][] a = new int[n][];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextIntArray(n - 1);\n\t\t}\n\t\t\n\t\tList> q = new ArrayList<>(n);\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tq.add(new ArrayDeque<>());\n\t\t}\n\n\t\tfor (int j = 0; j < n - 1; j++) {\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tint aa = a[i][j] - 1;\n\t\t\t\tq.get(aa).add(i);\n\t\t\t}\n\t\t}\n\n\t\tint cnt = 0;\n\t\twhile (true) {\n\t\t\tSet del = new HashSet<>();\n\t\t\tboolean[] used = new boolean[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tQueue qq = q.get(i);\n\t\t\t\tif (used[i] || qq.isEmpty()) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tint b = qq.peek();\n\t\t\t\tQueue qq2 = q.get(b);\n\t\t\t\tif (used[b] || qq2.isEmpty()) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tint c = qq2.peek();\n\t\t\t\t\n\t\t\t\tif (c == i) {\n\t\t\t\t\tdel.add(i);\n\t\t\t\t\tdel.add(b);\n\t\t\t\t\tused[i] = true;\n\t\t\t\t\tused[c] = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (int e : del) {\n\t\t\t\tq.get(e).remove();\n\t\t\t}\n\t\t\tcnt++;\n\t\t\t\n\t\t\tboolean flag = true;\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tif (!q.get(i).isEmpty()) {\n\t\t\t\t\tflag = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (flag) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\tif (del.isEmpty()) {\n\t\t\t\tpr.println(-1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpr.println(cnt);\n\t}\n\n\t// ---------------------------------------------------\n\tpublic static void main(String[] args) {\n\t\tsc = new Scanner(System.in);\n\t\tpr = new Printer(System.out);\n\t\t\t\n\t\tsolve();\n\t\t\t\n\t\tpr.close();\n\t\tsc.close();\n\t}\n\n\tstatic class Scanner {\n\t\tBufferedReader br;\n\n\t\tScanner (InputStream in) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(in));\n\t\t}\n\n\t\tprivate boolean isPrintable(int ch) {\n\t\t\treturn ch >= '!' && ch <= '~';\n\t\t}\n\n\t\tprivate boolean isCRLF(int ch) {\n\t\t\treturn ch == '\\n' || ch == '\\r' || ch == -1;\n\t\t}\n\n\t\tprivate int nextPrintable() {\n\t\t\ttry {\n\t\t\t\tint ch;\n\t\t\t\twhile (!isPrintable(ch = br.read())) {\n\t\t\t\t\tif (ch == -1) {\n\t\t\t\t\t\tthrow new NoSuchElementException();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn ch;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tString next() {\n\t\t\ttry {\n\t\t\t\tint ch = nextPrintable();\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tdo {\n\t\t\t\t\tsb.appendCodePoint(ch);\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn sb.toString();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tint nextInt() {\n\t\t\ttry {\n\t\t\t\t// parseInt from Integer.parseInt()\n\t\t\t\tboolean negative = false;\n\t\t\t\tint res = 0;\n\t\t\t\tint limit = -Integer.MAX_VALUE;\n\t\t\t\tint radix = 10;\n\n\t\t\t\tint fc = nextPrintable();\n\t\t\t\tif (fc < '0') {\n\t\t\t\t\tif (fc == '-') {\n\t\t\t\t\t\tnegative = true;\n\t\t\t\t\t\tlimit = Integer.MIN_VALUE;\n\t\t\t\t\t} else if (fc != '+') {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tfc = br.read();\n\t\t\t\t}\n\t\t\t\tint multmin = limit / radix;\n\n\t\t\t\tint ch = fc;\n\t\t\t\tdo {\n\t\t\t\t\tint digit = ch - '0';\n\t\t\t\t\tif (digit < 0 || digit >= radix) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tif (res < multmin) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres *= radix;\n\t\t\t\t\tif (res < limit + digit) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres -= digit;\n\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn negative ? res : -res;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\ttry {\n\t\t\t\t// parseLong from Long.parseLong()\n\t\t\t\tboolean negative = false;\n\t\t\t\tlong res = 0;\n\t\t\t\tlong limit = -Long.MAX_VALUE;\n\t\t\t\tint radix = 10;\n\n\t\t\t\tint fc = nextPrintable();\n\t\t\t\tif (fc < '0') {\n\t\t\t\t\tif (fc == '-') {\n\t\t\t\t\t\tnegative = true;\n\t\t\t\t\t\tlimit = Long.MIN_VALUE;\n\t\t\t\t\t} else if (fc != '+') {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tfc = br.read();\n\t\t\t\t}\n\t\t\t\tlong multmin = limit / radix;\n\n\t\t\t\tint ch = fc;\n\t\t\t\tdo {\n\t\t\t\t\tint digit = ch - '0';\n\t\t\t\t\tif (digit < 0 || digit >= radix) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tif (res < multmin) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres *= radix;\n\t\t\t\t\tif (res < limit + digit) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres -= digit;\n\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn negative ? res : -res;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tfloat nextFloat() {\n\t\t\treturn Float.parseFloat(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\ttry {\n\t\t\t\tint ch;\n\t\t\t\twhile (isCRLF(ch = br.read())) {\n\t\t\t\t\tif (ch == -1) {\n\t\t\t\t\t\tthrow new NoSuchElementException();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tdo {\n\t\t\t\t\tsb.appendCodePoint(ch);\n\t\t\t\t} while (!isCRLF(ch = br.read()));\n\n\t\t\t\treturn sb.toString();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\t\t\n\t\tint[] nextIntArray(int n) {\n\t\t\tint[] ret = new int[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tret[i] = sc.nextInt();\n\t\t\t}\n\t\t\t\n\t\t\treturn ret;\n\t\t}\n\n\t\tint[][] nextIntArrays(int n, int m) {\n\t\t\tint[][] ret = new int[m][n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tfor (int j = 0; j < m; j++) {\n\t\t\t\t\tret[j][i] = sc.nextInt();\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn ret;\n\t\t}\n\n\t\tvoid close() {\n\t\t\ttry {\n\t\t\t\tbr.close();\n\t\t\t} catch (IOException e) {\n//\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic class Printer extends PrintWriter {\n\t\tPrinter(OutputStream out) {\n\t\t\tsuper(out);\n\t\t}\n\t\t\n\t\tvoid printInts(int... a) {\n\t\t\tStringBuilder sb = new StringBuilder(32);\n\t\t\tfor (int i = 0, size = a.length; i < size; i++) {\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tsb.append(' ');\n\t\t\t\t}\n\t\t\t\tsb.append(a[i]);\n\t\t\t}\n\n\t\t\tprintln(sb);\n\t\t}\n\t\t\n\t\tvoid printLongs(long... a) {\n\t\t\tStringBuilder sb = new StringBuilder(64);\n\t\t\tfor (int i = 0, size = a.length; i < size; i++) {\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tsb.append(' ');\n\t\t\t\t}\n\t\t\t\tsb.append(a[i]);\n\t\t\t}\n\n\t\t\tprintln(sb);\n\t\t}\n\t\t\n\t\tvoid printStrings(String... a) {\n\t\t\tStringBuilder sb = new StringBuilder(32);\n\t\t\tfor (int i = 0, size = a.length; i < size; i++) {\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tsb.append(' ');\n\t\t\t\t}\n\t\t\t\tsb.append(a[i]);\n\t\t\t}\n\n\t\t\tprintln(sb);\n\t\t}\n\t}\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nN players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\n\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.\n\nEach player plays at most one matches in a day.\n\nEach player i (1 \\leq i \\leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} in this order.\n\nConstraints\n\n3 \\leq N \\leq 1000\n\n1 \\leq A_{i, j} \\leq N\n\nA_{i, j} \\neq i\n\nA_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} \\ldots A_{1, N-1}\nA_{2, 1} A_{2, 2} \\ldots A_{2, N-1}\n:\nA_{N, 1} A_{N, 2} \\ldots A_{N, N-1}\n\nOutput\n\nIf it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print -1.\n\nSample Input 1\n\n3\n2 3\n1 3\n1 2\n\nSample Output 1\n\n3\n\nAll the conditions can be satisfied if the matches are scheduled for three days as follows:\n\nDay 1: Player 1 vs Player 2\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\nSample Input 2\n\n4\n2 3 4\n1 3 4\n4 1 2\n3 1 2\n\nSample Output 2\n\n4\n\nAll the conditions can be satisfied if the matches are scheduled for four days as follows:\n\nDay 1: Player 1 vs Player 2, Player 3 vs Player 4\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 1 vs Player 4, Player 2 vs Player 3\n\nDay 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\nSample Input 3\n\n3\n2 3\n3 1\n1 2\n\nSample Output 3\n\n-1\n\nAny scheduling of the matches violates some condition.", "sample_input": "3\n2 3\n1 3\n1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02925", "source_text": "Score : 500 points\n\nProblem Statement\n\nN players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\n\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.\n\nEach player plays at most one matches in a day.\n\nEach player i (1 \\leq i \\leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} in this order.\n\nConstraints\n\n3 \\leq N \\leq 1000\n\n1 \\leq A_{i, j} \\leq N\n\nA_{i, j} \\neq i\n\nA_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} \\ldots A_{1, N-1}\nA_{2, 1} A_{2, 2} \\ldots A_{2, N-1}\n:\nA_{N, 1} A_{N, 2} \\ldots A_{N, N-1}\n\nOutput\n\nIf it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print -1.\n\nSample Input 1\n\n3\n2 3\n1 3\n1 2\n\nSample Output 1\n\n3\n\nAll the conditions can be satisfied if the matches are scheduled for three days as follows:\n\nDay 1: Player 1 vs Player 2\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\nSample Input 2\n\n4\n2 3 4\n1 3 4\n4 1 2\n3 1 2\n\nSample Output 2\n\n4\n\nAll the conditions can be satisfied if the matches are scheduled for four days as follows:\n\nDay 1: Player 1 vs Player 2, Player 3 vs Player 4\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 1 vs Player 4, Player 2 vs Player 3\n\nDay 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\nSample Input 3\n\n3\n2 3\n3 1\n1 2\n\nSample Output 3\n\n-1\n\nAny scheduling of the matches violates some condition.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6006, "cpu_time_ms": 556, "memory_kb": 81728}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s582379227", "group_id": "codeNet:p02934", "input_text": "import java.util.*;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tdouble a = 0;\n\t\t\n\t\tfor(int i = 0; i < n; i++) a += 1.0 / sc.nextInt();\n\n\t\tSystem.out.println(1 / a);\n\t}\n}", "language": "Java", "metadata": {"date": 1597318856, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p02934.html", "problem_id": "p02934", "resource_group": "high_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/Java/s582379227.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s582379227", "user_id": "u078168851"}, "prompt_components": {"gold_output": "7.5\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tdouble a = 0;\n\t\t\n\t\tfor(int i = 0; i < n; i++) a += 1.0 / sc.nextInt();\n\n\t\tSystem.out.println(1 / a);\n\t}\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": 260, "cpu_time_ms": 122, "memory_kb": 35960}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s128525810", "group_id": "codeNet:p02934", "input_text": "import java.util.Scanner;\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n float sum = 0;\n for(int i = 0; i < n; i++){\n sum = sum + (1 / sc.nextFloat());\n }\n System.out.println(1 / sum);\n }\n}", "language": "Java", "metadata": {"date": 1566179337, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02934.html", "problem_id": "p02934", "resource_group": "high_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/Java/s128525810.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s128525810", "user_id": "u241752770"}, "prompt_components": {"gold_output": "7.5\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n float sum = 0;\n for(int i = 0; i < n; i++){\n sum = sum + (1 / sc.nextFloat());\n }\n System.out.println(1 / sum);\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": 323, "cpu_time_ms": 121, "memory_kb": 22612}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s517961677", "group_id": "codeNet:p02935", "input_text": "import java.util.Arrays;\nimport java.util.Scanner;\nimport java.util.TreeMap;\n\npublic class Main {\n\n\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n main3(sc);\n }\n\n public static void main3(Scanner sc) {\n\n \tint N = sc.nextInt();\n float[] all = new float[N];\n\n for (int i = 0; i < N; i++) {\n \tall[i] = sc.nextFloat();\n }\n\n Arrays.sort(all);\n\n float value = (all[0] + all[1])/2;\n\n for (int i = 2; i < N; i++) {\n \tvalue = (value + all[i])/2;\n }\n\n System.out.println(value);\n }\n\n}", "language": "Java", "metadata": {"date": 1566234844, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02935.html", "problem_id": "p02935", "resource_group": "high_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/Java/s517961677.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s517961677", "user_id": "u804922227"}, "prompt_components": {"gold_output": "3.5\n", "input_to_evaluate": "import java.util.Arrays;\nimport java.util.Scanner;\nimport java.util.TreeMap;\n\npublic class Main {\n\n\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n main3(sc);\n }\n\n public static void main3(Scanner sc) {\n\n \tint N = sc.nextInt();\n float[] all = new float[N];\n\n for (int i = 0; i < N; i++) {\n \tall[i] = sc.nextFloat();\n }\n\n Arrays.sort(all);\n\n float value = (all[0] + all[1])/2;\n\n for (int i = 2; i < N; i++) {\n \tvalue = (value + all[i])/2;\n }\n\n System.out.println(value);\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": 624, "cpu_time_ms": 116, "memory_kb": 23252}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s888024091", "group_id": "codeNet:p02946", "input_text": "import java.io.PrintWriter;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n PrintWriter out = new PrintWriter(System.out);\n int k = in.nextInt();\n int x = in.nextInt();\n final int MIN = -1000000;\n final int MAX = 1000000;\n int right = Math.min(x + k - 1, MAX);\n for (int i = Math.max(x - k + 1, MIN); i <= right; ++i)\n out.print(i + (i == right ? \"\\n\" : \" \"));\n out.close();\n }\n}\n", "language": "Java", "metadata": {"date": 1565485687, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02946.html", "problem_id": "p02946", "resource_group": "high_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/Java/s888024091.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s888024091", "user_id": "u158104782"}, "prompt_components": {"gold_output": "5 6 7 8 9\n", "input_to_evaluate": "import java.io.PrintWriter;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n PrintWriter out = new PrintWriter(System.out);\n int k = in.nextInt();\n int x = in.nextInt();\n final int MIN = -1000000;\n final int MAX = 1000000;\n int right = Math.min(x + k - 1, MAX);\n for (int i = Math.max(x - k + 1, MIN); i <= right; ++i)\n out.print(i + (i == right ? \"\\n\" : \" \"));\n out.close();\n }\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": 540, "cpu_time_ms": 119, "memory_kb": 21972}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s644307599", "group_id": "codeNet:p02947", "input_text": "import java.util.*;\n\nclass Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tsc.nextLine();\n\t\tHashMap hm = new HashMap<>();\n\t\tfor(int i = 0; i < n; i++){\n\t\tString s = sc.nextLine();\n\t\tchar[] chr = s.toCharArray();\n\t\tArrays.sort(chr);\n\t\tString str = String.valueOf(chr);\n\t\thm.put(str, 1 + hm.getOrDefault(str,0));\n\t\t}\n\t\tlong count = 0;\n\t\tfor(long cur : hm.values()){\n\t\t\tcount += (cur * (cur - 1)/2);\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n\t\t\n\t\t\n\t}", "language": "Java", "metadata": {"date": 1569687618, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02947.html", "problem_id": "p02947", "resource_group": "high_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/Java/s644307599.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s644307599", "user_id": "u250483945"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*;\n\nclass Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tsc.nextLine();\n\t\tHashMap hm = new HashMap<>();\n\t\tfor(int i = 0; i < n; i++){\n\t\tString s = sc.nextLine();\n\t\tchar[] chr = s.toCharArray();\n\t\tArrays.sort(chr);\n\t\tString str = String.valueOf(chr);\n\t\thm.put(str, 1 + hm.getOrDefault(str,0));\n\t\t}\n\t\tlong count = 0;\n\t\tfor(long cur : hm.values()){\n\t\t\tcount += (cur * (cur - 1)/2);\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n\t\t\n\t\t\n\t}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\n\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\n\nGiven are N strings s_1, s_2, \\ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\ns_i is a string of length 10.\n\nEach character in s_i is a lowercase English letter.\n\ns_1, s_2, \\ldots, s_N are all distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nSample Input 1\n\n3\nacornistnt\npeanutbomb\nconstraint\n\nSample Output 1\n\n1\n\ns_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.\n\nSample Input 2\n\n2\noneplustwo\nninemodsix\n\nSample Output 2\n\n0\n\nIf there is no pair i, j such that s_i is an anagram of s_j, print 0.\n\nSample Input 3\n\n5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa\n\nSample Output 3\n\n4\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "sample_input": "3\nacornistnt\npeanutbomb\nconstraint\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02947", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\n\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\n\nGiven are N strings s_1, s_2, \\ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\ns_i is a string of length 10.\n\nEach character in s_i is a lowercase English letter.\n\ns_1, s_2, \\ldots, s_N are all distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nSample Input 1\n\n3\nacornistnt\npeanutbomb\nconstraint\n\nSample Output 1\n\n1\n\ns_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.\n\nSample Input 2\n\n2\noneplustwo\nninemodsix\n\nSample Output 2\n\n0\n\nIf there is no pair i, j such that s_i is an anagram of s_j, print 0.\n\nSample Input 3\n\n5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa\n\nSample Output 3\n\n4\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 521, "cpu_time_ms": 512, "memory_kb": 106844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s266125929", "group_id": "codeNet:p02948", "input_text": "import java.util.*;\nimport java.io.*;\n\npublic class Main {\n public static void main(String[] args) {\n FastScanner scanner = new FastScanner();\n PrintWriter out = new PrintWriter(System.out, false);\n int n= scanner.nextInt(), m = scanner.nextInt();\n ArrayList[] list = new ArrayList[m+1];\n for(int i = 0; i <= m; i++) list[i] = new ArrayList<>();\n for(int i = 0; i < n; i++ ){\n int t = scanner.nextInt();\n if (t > m) {\n scanner.nextInt();\n continue;\n }\n list[t].add(scanner.nextInt());\n }\n PriorityQueue queue = new PriorityQueue<>(Collections.reverseOrder());\n long ans = 0;\n for(int i = 1; i <= m; i++) {\n for(int val: list[i]) {\n queue.offer(val);\n }\n ans += !queue.isEmpty() ? queue.poll() : 0;\n }\n out.println(ans);\n out.flush();\n }\n \n public static class FastScanner {\n BufferedReader br;\n StringTokenizer st;\n \n public FastScanner(Reader in) {\n br = new BufferedReader(in);\n }\n \n public FastScanner() {\n this(new InputStreamReader(System.in));\n }\n \n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n \n int nextInt() {\n return Integer.parseInt(next());\n }\n \n long nextLong() {\n return Long.parseLong(next());\n }\n \n double nextDouble() {\n return Double.parseDouble(next());\n }\n \n String readNextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1569070228, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02948.html", "problem_id": "p02948", "resource_group": "high_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/Java/s266125929.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s266125929", "user_id": "u227307124"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\n\npublic class Main {\n public static void main(String[] args) {\n FastScanner scanner = new FastScanner();\n PrintWriter out = new PrintWriter(System.out, false);\n int n= scanner.nextInt(), m = scanner.nextInt();\n ArrayList[] list = new ArrayList[m+1];\n for(int i = 0; i <= m; i++) list[i] = new ArrayList<>();\n for(int i = 0; i < n; i++ ){\n int t = scanner.nextInt();\n if (t > m) {\n scanner.nextInt();\n continue;\n }\n list[t].add(scanner.nextInt());\n }\n PriorityQueue queue = new PriorityQueue<>(Collections.reverseOrder());\n long ans = 0;\n for(int i = 1; i <= m; i++) {\n for(int val: list[i]) {\n queue.offer(val);\n }\n ans += !queue.isEmpty() ? queue.poll() : 0;\n }\n out.println(ans);\n out.flush();\n }\n \n public static class FastScanner {\n BufferedReader br;\n StringTokenizer st;\n \n public FastScanner(Reader in) {\n br = new BufferedReader(in);\n }\n \n public FastScanner() {\n this(new InputStreamReader(System.in));\n }\n \n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n \n int nextInt() {\n return Integer.parseInt(next());\n }\n \n long nextLong() {\n return Long.parseLong(next());\n }\n \n double nextDouble() {\n return Double.parseDouble(next());\n }\n \n String readNextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }\n }\n}\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": 2136, "cpu_time_ms": 337, "memory_kb": 55016}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s561537699", "group_id": "codeNet:p02951", "input_text": "import java.util.Scanner;\npublic class Main{\n \n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint a = sc.nextInt();\n \tint b = sc.nextInt();\n \tint c = sc.nextInt();\n \n int ans =b+c-a;\n if(ans>=0)\n System.out.println(ans);\n else\n System.out.println(0);\n\n\n\n\t\t\n\t\t\n\t}\n \n}\n", "language": "Java", "metadata": {"date": 1577741160, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02951.html", "problem_id": "p02951", "resource_group": "high_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/Java/s561537699.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s561537699", "user_id": "u745128557"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main{\n \n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint a = sc.nextInt();\n \tint b = sc.nextInt();\n \tint c = sc.nextInt();\n \n int ans =b+c-a;\n if(ans>=0)\n System.out.println(ans);\n else\n System.out.println(0);\n\n\n\n\t\t\n\t\t\n\t}\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": 350, "cpu_time_ms": 93, "memory_kb": 22740}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s681130577", "group_id": "codeNet:p02952", "input_text": "import java.util.*;\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int cnt = 0;\n\n for(int i = 1;i<=n;i++){\n if(String.valueOf(i).length()%2==1){\n cnt++;\n // System.out.println(i);\n }\n }\n System.out.println(cnt);\n\n\n }\n}\n", "language": "Java", "metadata": {"date": 1588426954, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02952.html", "problem_id": "p02952", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02952/input.txt", "sample_output_relpath": "derived/input_output/data/p02952/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02952/Java/s681130577.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s681130577", "user_id": "u241090452"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.util.*;\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int cnt = 0;\n\n for(int i = 1;i<=n;i++){\n if(String.valueOf(i).length()%2==1){\n cnt++;\n // System.out.println(i);\n }\n }\n System.out.println(cnt);\n\n\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of positive integers less than or equal to N that have an odd number of digits.\n\nSample Input 1\n\n11\n\nSample Output 1\n\n9\n\nAmong the positive integers less than or equal to 11, nine integers have an odd number of digits: 1, 2, \\ldots, 9.\n\nSample Input 2\n\n136\n\nSample Output 2\n\n46\n\nIn addition to 1, 2, \\ldots, 9, another 37 integers also have an odd number of digits: 100, 101, \\ldots, 136.\n\nSample Input 3\n\n100000\n\nSample Output 3\n\n90909", "sample_input": "11\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02952", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of positive integers less than or equal to N that have an odd number of digits.\n\nSample Input 1\n\n11\n\nSample Output 1\n\n9\n\nAmong the positive integers less than or equal to 11, nine integers have an odd number of digits: 1, 2, \\ldots, 9.\n\nSample Input 2\n\n136\n\nSample Output 2\n\n46\n\nIn addition to 1, 2, \\ldots, 9, another 37 integers also have an odd number of digits: 100, 101, \\ldots, 136.\n\nSample Input 3\n\n100000\n\nSample Output 3\n\n90909", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 394, "cpu_time_ms": 124, "memory_kb": 27732}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s116675203", "group_id": "codeNet:p02954", "input_text": "import java.io.*;\nimport java.math.BigDecimal;\nimport java.math.BigInteger;\nimport java.util.*;\n\npublic class Main {\n\tstatic final int INF = (int) (1e9 + 10);\n\tstatic final int MOD = (int) (1e9 + 7);\n\tstatic final int N = (int) (4e5 + 5);\n\t// static ArrayList[] graph;\n\t// static boolean visited[];\n\t// static long size[];\n\n\tpublic static void main(String[] args) throws NumberFormatException, IOException {\n\t\tFastReader sc = new FastReader();\n\t\tPrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t// Scanner scn = new Scanner(System.in);\n\t\t//\n\t\tString s = sc.next();\n\t\ts=s.toLowerCase();\n\t\tint r[] = new int[s.length()];\n\t\tint l[] = new int[s.length()];\n\t\tint c = 0;\n\t\tfor (int i = 0; i < s.length() - 1; i++) {\n\t\t\tif (s.charAt(i) == 'r')\n\t\t\t\tc++;\n\t\t\tif (s.charAt(i + 1) == 'l') {\n\t\t\t\tr[i] = c;\n\t\t\t\tc = 0;\n\t\t\t}\n\t\t}\n\t\tc = 0;\n\t\tfor (int i = s.length() - 1; i > 0; i--) {\n\t\t\tif (s.charAt(i) == 'l')\n\t\t\t\tc++;\n\t\t\tif (s.charAt(i - 1) == 'r') {\n\t\t\t\tl[i] = c;\n\t\t\t\tc = 0;\n\t\t\t}\n\t\t}\n//\t\tfor(int i=0;i l[i + 1]) {\n\t\t\t\t\t\tint diff = r[i] - l[i + 1];\n\t\t\t\t\t\tr[i] -= (diff / 2);\n\t\t\t\t\t\tl[i + 1] += diff / 2;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tint diff = l[i + 1] - r[i];\n\t\t\t\t\t\tr[i] += (diff / 2);\n\t\t\t\t\t\tl[i + 1] -= diff / 2;\n\t\t\t\t\t}\n\t\t\t\t\t//System.out.println(r[i]+\" \"+l[i+1]);\n\t\t\t\t\tif((r[i]==1 && l[i+1]==2) || (r[i]==2 && l[i+1]==1))\n\t\t\t\t\t\tsb.append(l[i + 1] + \" \" + r[i] + \" \");\n\t\t\t\t\telse\n\t\t\t\t\t\t\n\t\t\t\t\tsb.append(r[i] + \" \" + l[i + 1] + \" \");\n\t\t\t\t}\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tsb.append(\"0 \");\n\t\t\t}\n\t\t}\n\t\tif(s.charAt(s.length()-1)=='l' && s.charAt(s.length()-2)=='l')\n\t\t\tsb.append(\"0\");\n\t\tpr.println(sb);\n\t\t//\n\t\t// coded to perfection by Rohan Mukhija\n\t\tpr.flush();\n\t\tpr.close();\n\t}\n\n\t/*\n\t * Template From Here\n\t */\n\tpublic static class Pair implements Comparable {\n\t\tint u;\n\t\tint v;\n\n\t\tPair(int u, int v, int c) {\n\t\t\tthis.u = u;\n\t\t\tthis.v = v;\n\n\t\t}\n\n\t\tpublic int compareTo(Pair compareEdge) {\n\t\t\treturn Long.compare(this.v, compareEdge.v);\n\t\t}\n\t};\n\n\tprivate static boolean possible(long[] arr, int[] f, long mid, long k) {\n\t\tlong c = 0;\n\n\t\tfor (int i = 0; i < arr.length; i++) {\n\t\t\tif ((arr[i] * f[f.length - i - 1]) > mid) {\n\t\t\t\tc += (arr[i] - (mid / f[f.length - i - 1]));\n\t\t\t}\n\t\t}\n\t\t// System.out.println(mid+\" \"+c);\n\t\tif (c <= k)\n\t\t\treturn true;\n\t\treturn false;\n\t}\n\n\tstatic void sort(long[] a) {\n\t\tArrayList l = new ArrayList<>();\n\t\tfor (long i : a)\n\t\t\tl.add(i);\n\t\tCollections.sort(l);\n\t\tfor (int i = 0; i < a.length; i++)\n\t\t\ta[i] = l.get(i);\n\t}\n\n\tstatic void sort(int[] a) {\n\t\tArrayList l = new ArrayList<>();\n\t\tfor (int i : a)\n\t\t\tl.add(i);\n\t\tCollections.sort(l);\n\t\tfor (int i = 0; i < a.length; i++)\n\t\t\ta[i] = l.get(i);\n\t}\n\n\tpublic static int lowerBound(ArrayList array, int length, long value) {\n\t\tint low = 0;\n\t\tint high = length;\n\t\twhile (low < high) {\n\t\t\tfinal int mid = (low + high) / 2;\n\t\t\tif (value <= array.get(mid)) {\n\t\t\t\thigh = mid;\n\t\t\t} else {\n\t\t\t\tlow = mid + 1;\n\t\t\t}\n\t\t}\n\t\treturn low;\n\t}\n\n\tstatic class FastReader {\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\n\t\tpublic FastReader() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\n\t\tString next() {\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\t}\n\n\tstatic long gcd(long a, long b) {\n\t\tif (a == 0)\n\t\t\treturn b;\n\t\treturn gcd(b % a, a);\n\t}\n\n\tstatic long lcm(long a, long b) {\n\t\treturn (a * b) / gcd(a, b);\n\t}\n\n\tpublic static void sortbyColumn(int[][] att, int col) {\n\t\t// Using built-in sort function Arrays.sort\n\t\tArrays.sort(att, new Comparator() {\n\n\t\t\t@Override\n\t\t\t// Compare values according to columns\n\t\t\tpublic int compare(final int[] entry1, final int[] entry2) {\n\n\t\t\t\t// To sort in descending order revert\n\t\t\t\t// the '>' Operator\n\t\t\t\t// if (entry1[col] > entry2[col])\n\t\t\t\t// return 1;\n\t\t\t\t// else //(entry1[col] >= entry2[col])\n\t\t\t\t// return -1;\n\t\t\t\treturn new Integer(entry1[col]).compareTo(entry2[col]);\n\t\t\t\t// return entry1[col].\n\t\t\t}\n\t\t}); // End of function call sort().\n\t}\n\n\tstatic class pair {\n\t\tint V, I;\n\n\t\tpair(int v, int i) {\n\t\t\tV = v;\n\t\t\tI = i;\n\t\t}\n\t}\n\n\tpublic static int[] swap(int data[], int left, int right) {\n\t\tint temp = data[left];\n\t\tdata[left] = data[right];\n\t\tdata[right] = temp;\n\t\treturn data;\n\t}\n\n\tpublic static int[] reverse(int data[], int left, int right) {\n\t\twhile (left < right) {\n\t\t\tint temp = data[left];\n\t\t\tdata[left++] = data[right];\n\t\t\tdata[right--] = temp;\n\t\t}\n\t\treturn data;\n\t}\n\n\tpublic static boolean findNextPermutation(int data[]) {\n\t\tif (data.length <= 1)\n\t\t\treturn false;\n\n\t\tint last = data.length - 2;\n\t\twhile (last >= 0) {\n\t\t\tif (data[last] < data[last + 1]) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tlast--;\n\t\t}\n\t\tif (last < 0)\n\t\t\treturn false;\n\n\t\tint nextGreater = data.length - 1;\n\t\tfor (int i = data.length - 1; i > last; i--) {\n\t\t\tif (data[i] > data[last]) {\n\t\t\t\tnextGreater = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tdata = swap(data, nextGreater, last);\n\t\tdata = reverse(data, last + 1, data.length - 1);\n\t\treturn true;\n\t}\n\n\tstatic long ncr(long n, long r) {\n\t\tlong p = 1, k = 1;\n\t\tif (n - r < r) {\n\t\t\tr = n - r;\n\t\t}\n\n\t\tif (r != 0) {\n\t\t\twhile (r > 0) {\n\t\t\t\tp *= n;\n\t\t\t\tk *= r;\n\n\t\t\t\t// gcd of p, k\n\t\t\t\tlong m = __gcd(p, k);\n\n\t\t\t\tp /= m;\n\t\t\t\tk /= m;\n\n\t\t\t\tn--;\n\t\t\t\tr--;\n\t\t\t}\n\n\t\t} else {\n\t\t\tp = 1;\n\t\t}\n\n\t\t// if our approach is correct p = ans and k =1\n\t\treturn p;\n\t}\n\n\tstatic long __gcd(long n1, long n2) {\n\t\tlong gcd = 1;\n\n\t\tfor (int i = 1; i <= n1 && i <= n2; ++i) {\n\t\t\t// Checks if i is factor of both integers\n\t\t\tif (n1 % i == 0 && n2 % i == 0) {\n\t\t\t\tgcd = i;\n\t\t\t}\n\t\t}\n\t\treturn gcd;\n\t}\n\n\tstatic long power(long prev, int y, int p) {\n\t\tlong res = 1;\n\n\t\tprev = prev % p;\n\n\t\tif (prev == 0)\n\t\t\treturn 0;\n\t\twhile (y > 0) {\n\n\t\t\tif ((y & 1) == 1)\n\t\t\t\tres = (res * prev) % p;\n\n\t\t\ty = y >> 1;\n\t\t\tprev = (prev * prev) % p;\n\t\t}\n\t\treturn res;\n\t}\n\n\tstatic long modInverse(long fac2, int p) {\n\t\treturn power(fac2, p - 2, p);\n\t}\n\n\tstatic boolean isPrime(int n) {\n\t\t// Corner cases\n\t\tif (n <= 1)\n\t\t\treturn false;\n\t\tif (n <= 3)\n\t\t\treturn true;\n\n\t\t// This is checked so that we can skip\n\t\t// middle five numbers in below loop\n\t\tif (n % 2 == 0 || n % 3 == 0)\n\t\t\treturn false;\n\n\t\tfor (int i = 5; i * i <= n; i = i + 6)\n\t\t\tif (n % i == 0 || n % (i + 2) == 0)\n\t\t\t\treturn false;\n\n\t\treturn true;\n\t}\n\n\tpublic static BigInteger lcmm(String a, String b) {\n\t\tBigInteger s = new BigInteger(a);\n\t\tBigInteger s1 = new BigInteger(b);\n\t\tBigInteger mul = s.multiply(s1);\n\t\tBigInteger gcd = s.gcd(s1);\n\t\tBigInteger lcm = mul.divide(gcd);\n\t\treturn lcm;\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1590260454, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02954.html", "problem_id": "p02954", "resource_group": "high_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/Java/s116675203.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s116675203", "user_id": "u225470629"}, "prompt_components": {"gold_output": "0 1 2 1 1\n", "input_to_evaluate": "import java.io.*;\nimport java.math.BigDecimal;\nimport java.math.BigInteger;\nimport java.util.*;\n\npublic class Main {\n\tstatic final int INF = (int) (1e9 + 10);\n\tstatic final int MOD = (int) (1e9 + 7);\n\tstatic final int N = (int) (4e5 + 5);\n\t// static ArrayList[] graph;\n\t// static boolean visited[];\n\t// static long size[];\n\n\tpublic static void main(String[] args) throws NumberFormatException, IOException {\n\t\tFastReader sc = new FastReader();\n\t\tPrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t// Scanner scn = new Scanner(System.in);\n\t\t//\n\t\tString s = sc.next();\n\t\ts=s.toLowerCase();\n\t\tint r[] = new int[s.length()];\n\t\tint l[] = new int[s.length()];\n\t\tint c = 0;\n\t\tfor (int i = 0; i < s.length() - 1; i++) {\n\t\t\tif (s.charAt(i) == 'r')\n\t\t\t\tc++;\n\t\t\tif (s.charAt(i + 1) == 'l') {\n\t\t\t\tr[i] = c;\n\t\t\t\tc = 0;\n\t\t\t}\n\t\t}\n\t\tc = 0;\n\t\tfor (int i = s.length() - 1; i > 0; i--) {\n\t\t\tif (s.charAt(i) == 'l')\n\t\t\t\tc++;\n\t\t\tif (s.charAt(i - 1) == 'r') {\n\t\t\t\tl[i] = c;\n\t\t\t\tc = 0;\n\t\t\t}\n\t\t}\n//\t\tfor(int i=0;i l[i + 1]) {\n\t\t\t\t\t\tint diff = r[i] - l[i + 1];\n\t\t\t\t\t\tr[i] -= (diff / 2);\n\t\t\t\t\t\tl[i + 1] += diff / 2;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tint diff = l[i + 1] - r[i];\n\t\t\t\t\t\tr[i] += (diff / 2);\n\t\t\t\t\t\tl[i + 1] -= diff / 2;\n\t\t\t\t\t}\n\t\t\t\t\t//System.out.println(r[i]+\" \"+l[i+1]);\n\t\t\t\t\tif((r[i]==1 && l[i+1]==2) || (r[i]==2 && l[i+1]==1))\n\t\t\t\t\t\tsb.append(l[i + 1] + \" \" + r[i] + \" \");\n\t\t\t\t\telse\n\t\t\t\t\t\t\n\t\t\t\t\tsb.append(r[i] + \" \" + l[i + 1] + \" \");\n\t\t\t\t}\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tsb.append(\"0 \");\n\t\t\t}\n\t\t}\n\t\tif(s.charAt(s.length()-1)=='l' && s.charAt(s.length()-2)=='l')\n\t\t\tsb.append(\"0\");\n\t\tpr.println(sb);\n\t\t//\n\t\t// coded to perfection by Rohan Mukhija\n\t\tpr.flush();\n\t\tpr.close();\n\t}\n\n\t/*\n\t * Template From Here\n\t */\n\tpublic static class Pair implements Comparable {\n\t\tint u;\n\t\tint v;\n\n\t\tPair(int u, int v, int c) {\n\t\t\tthis.u = u;\n\t\t\tthis.v = v;\n\n\t\t}\n\n\t\tpublic int compareTo(Pair compareEdge) {\n\t\t\treturn Long.compare(this.v, compareEdge.v);\n\t\t}\n\t};\n\n\tprivate static boolean possible(long[] arr, int[] f, long mid, long k) {\n\t\tlong c = 0;\n\n\t\tfor (int i = 0; i < arr.length; i++) {\n\t\t\tif ((arr[i] * f[f.length - i - 1]) > mid) {\n\t\t\t\tc += (arr[i] - (mid / f[f.length - i - 1]));\n\t\t\t}\n\t\t}\n\t\t// System.out.println(mid+\" \"+c);\n\t\tif (c <= k)\n\t\t\treturn true;\n\t\treturn false;\n\t}\n\n\tstatic void sort(long[] a) {\n\t\tArrayList l = new ArrayList<>();\n\t\tfor (long i : a)\n\t\t\tl.add(i);\n\t\tCollections.sort(l);\n\t\tfor (int i = 0; i < a.length; i++)\n\t\t\ta[i] = l.get(i);\n\t}\n\n\tstatic void sort(int[] a) {\n\t\tArrayList l = new ArrayList<>();\n\t\tfor (int i : a)\n\t\t\tl.add(i);\n\t\tCollections.sort(l);\n\t\tfor (int i = 0; i < a.length; i++)\n\t\t\ta[i] = l.get(i);\n\t}\n\n\tpublic static int lowerBound(ArrayList array, int length, long value) {\n\t\tint low = 0;\n\t\tint high = length;\n\t\twhile (low < high) {\n\t\t\tfinal int mid = (low + high) / 2;\n\t\t\tif (value <= array.get(mid)) {\n\t\t\t\thigh = mid;\n\t\t\t} else {\n\t\t\t\tlow = mid + 1;\n\t\t\t}\n\t\t}\n\t\treturn low;\n\t}\n\n\tstatic class FastReader {\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\n\t\tpublic FastReader() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\n\t\tString next() {\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\t}\n\n\tstatic long gcd(long a, long b) {\n\t\tif (a == 0)\n\t\t\treturn b;\n\t\treturn gcd(b % a, a);\n\t}\n\n\tstatic long lcm(long a, long b) {\n\t\treturn (a * b) / gcd(a, b);\n\t}\n\n\tpublic static void sortbyColumn(int[][] att, int col) {\n\t\t// Using built-in sort function Arrays.sort\n\t\tArrays.sort(att, new Comparator() {\n\n\t\t\t@Override\n\t\t\t// Compare values according to columns\n\t\t\tpublic int compare(final int[] entry1, final int[] entry2) {\n\n\t\t\t\t// To sort in descending order revert\n\t\t\t\t// the '>' Operator\n\t\t\t\t// if (entry1[col] > entry2[col])\n\t\t\t\t// return 1;\n\t\t\t\t// else //(entry1[col] >= entry2[col])\n\t\t\t\t// return -1;\n\t\t\t\treturn new Integer(entry1[col]).compareTo(entry2[col]);\n\t\t\t\t// return entry1[col].\n\t\t\t}\n\t\t}); // End of function call sort().\n\t}\n\n\tstatic class pair {\n\t\tint V, I;\n\n\t\tpair(int v, int i) {\n\t\t\tV = v;\n\t\t\tI = i;\n\t\t}\n\t}\n\n\tpublic static int[] swap(int data[], int left, int right) {\n\t\tint temp = data[left];\n\t\tdata[left] = data[right];\n\t\tdata[right] = temp;\n\t\treturn data;\n\t}\n\n\tpublic static int[] reverse(int data[], int left, int right) {\n\t\twhile (left < right) {\n\t\t\tint temp = data[left];\n\t\t\tdata[left++] = data[right];\n\t\t\tdata[right--] = temp;\n\t\t}\n\t\treturn data;\n\t}\n\n\tpublic static boolean findNextPermutation(int data[]) {\n\t\tif (data.length <= 1)\n\t\t\treturn false;\n\n\t\tint last = data.length - 2;\n\t\twhile (last >= 0) {\n\t\t\tif (data[last] < data[last + 1]) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tlast--;\n\t\t}\n\t\tif (last < 0)\n\t\t\treturn false;\n\n\t\tint nextGreater = data.length - 1;\n\t\tfor (int i = data.length - 1; i > last; i--) {\n\t\t\tif (data[i] > data[last]) {\n\t\t\t\tnextGreater = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tdata = swap(data, nextGreater, last);\n\t\tdata = reverse(data, last + 1, data.length - 1);\n\t\treturn true;\n\t}\n\n\tstatic long ncr(long n, long r) {\n\t\tlong p = 1, k = 1;\n\t\tif (n - r < r) {\n\t\t\tr = n - r;\n\t\t}\n\n\t\tif (r != 0) {\n\t\t\twhile (r > 0) {\n\t\t\t\tp *= n;\n\t\t\t\tk *= r;\n\n\t\t\t\t// gcd of p, k\n\t\t\t\tlong m = __gcd(p, k);\n\n\t\t\t\tp /= m;\n\t\t\t\tk /= m;\n\n\t\t\t\tn--;\n\t\t\t\tr--;\n\t\t\t}\n\n\t\t} else {\n\t\t\tp = 1;\n\t\t}\n\n\t\t// if our approach is correct p = ans and k =1\n\t\treturn p;\n\t}\n\n\tstatic long __gcd(long n1, long n2) {\n\t\tlong gcd = 1;\n\n\t\tfor (int i = 1; i <= n1 && i <= n2; ++i) {\n\t\t\t// Checks if i is factor of both integers\n\t\t\tif (n1 % i == 0 && n2 % i == 0) {\n\t\t\t\tgcd = i;\n\t\t\t}\n\t\t}\n\t\treturn gcd;\n\t}\n\n\tstatic long power(long prev, int y, int p) {\n\t\tlong res = 1;\n\n\t\tprev = prev % p;\n\n\t\tif (prev == 0)\n\t\t\treturn 0;\n\t\twhile (y > 0) {\n\n\t\t\tif ((y & 1) == 1)\n\t\t\t\tres = (res * prev) % p;\n\n\t\t\ty = y >> 1;\n\t\t\tprev = (prev * prev) % p;\n\t\t}\n\t\treturn res;\n\t}\n\n\tstatic long modInverse(long fac2, int p) {\n\t\treturn power(fac2, p - 2, p);\n\t}\n\n\tstatic boolean isPrime(int n) {\n\t\t// Corner cases\n\t\tif (n <= 1)\n\t\t\treturn false;\n\t\tif (n <= 3)\n\t\t\treturn true;\n\n\t\t// This is checked so that we can skip\n\t\t// middle five numbers in below loop\n\t\tif (n % 2 == 0 || n % 3 == 0)\n\t\t\treturn false;\n\n\t\tfor (int i = 5; i * i <= n; i = i + 6)\n\t\t\tif (n % i == 0 || n % (i + 2) == 0)\n\t\t\t\treturn false;\n\n\t\treturn true;\n\t}\n\n\tpublic static BigInteger lcmm(String a, String b) {\n\t\tBigInteger s = new BigInteger(a);\n\t\tBigInteger s1 = new BigInteger(b);\n\t\tBigInteger mul = s.multiply(s1);\n\t\tBigInteger gcd = s.gcd(s1);\n\t\tBigInteger lcm = mul.divide(gcd);\n\t\treturn lcm;\n\t}\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": 7397, "cpu_time_ms": 162, "memory_kb": 33448}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s361094648", "group_id": "codeNet:p02954", "input_text": "import java.util.*;\npublic class Main{\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String S = sc.next();\n int n = S.length();\n char[] h = new char[n+1];\n int i,index=0,r=0,l=0;\n int[] ans = new int[n];\n for(i=0;il){\n if((r+l)%4==3){\n ans[index]=(l+r-1)/2;\n ans[index+1]=(l+r+1)/2;\n }else{\n ans[index]=(l+r+1)/2;\n ans[index+1]=(l+r-1)/2;\n }\n l=0;\n r=0;\n }else{\n if((r+l)%4==3){\n ans[index] = (l+r+1)/2;\n ans[index+1] = (l+r-1)/2;\n }else{\n ans[index] = (l+r-1)/2;\n ans[index+1] = (l+r+1)/2;\n }\n l=0;\n r=0;\n }\n }\n }\n for(i=0;il){\n if((r+l)%4==3){\n ans[index]=(l+r-1)/2;\n ans[index+1]=(l+r+1)/2;\n }else{\n ans[index]=(l+r+1)/2;\n ans[index+1]=(l+r-1)/2;\n }\n l=0;\n r=0;\n }else{\n if((r+l)%4==3){\n ans[index] = (l+r+1)/2;\n ans[index+1] = (l+r-1)/2;\n }else{\n ans[index] = (l+r-1)/2;\n ans[index+1] = (l+r+1)/2;\n }\n l=0;\n r=0;\n }\n }\n }\n for(i=0;i=2;x--){\n if(sum%x!=0) continue;\n System.arraycopy(a, 0, b, 0, n);\n for(int i=0;ix-b[r]){\n t-=x-b[r];\n b[l]-=x-b[r];\n r--;\n }\n else{\n t-=b[l];\n b[r]+=b[l];\n l++;\n }\n if(t<0) break;\n if(r<=l){\n System.out.println(x);\n return;\n }\n }\n if(x==max) x=(x/n)+1;\n }\n System.out.println(1);\n }\n static class FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte(){\n if(ptr Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n public double nextDouble() { return Double.parseDouble(next());}\n public void close(){\n try{in.close();}\n catch(IOException e){e.printStackTrace();}\n }\n }\n}", "language": "Java", "metadata": {"date": 1573153237, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02955.html", "problem_id": "p02955", "resource_group": "high_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/Java/s831844385.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s831844385", "user_id": "u541055501"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\n\nclass Main{\n public static void main(String[] args){\n FastScanner fsc=new FastScanner();\n int n=fsc.nextInt();\n long k=fsc.nextLong();\n long[] a=new long[n];\n long sum=0;\n for(int i=0;i=2;x--){\n if(sum%x!=0) continue;\n System.arraycopy(a, 0, b, 0, n);\n for(int i=0;ix-b[r]){\n t-=x-b[r];\n b[l]-=x-b[r];\n r--;\n }\n else{\n t-=b[l];\n b[r]+=b[l];\n l++;\n }\n if(t<0) break;\n if(r<=l){\n System.out.println(x);\n return;\n }\n }\n if(x==max) x=(x/n)+1;\n }\n System.out.println(1);\n }\n static class FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte(){\n if(ptr Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n public double nextDouble() { return Double.parseDouble(next());}\n public void close(){\n try{in.close();}\n catch(IOException e){e.printStackTrace();}\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": 3798, "cpu_time_ms": 212, "memory_kb": 24672}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s683998673", "group_id": "codeNet:p02957", "input_text": "import java.util.*;\npublic class Main {\n\tpublic static void main(String[] args){\n\t\t// 整数の入力\n\t\tScanner sc = new Scanner(System.in);\n\t\t// 整数の入力\n\t\tint a = sc.nextInt();\n\t\tint b = sc.nextInt();\n\t\t// 絶対値の差分を取る10\n\t\tint c = Math.abs(a - b);\n\n\t\t// 偶数の場合はNG\n\t\tif(c % 2 != 0) {\n\t\t\tSystem.out.println(\"IMPOSSIBLE\");\n\t\t}else {\n\t\t\tint k = (a + b) / 2;\n\t\t\tSystem.out.println(k);\n\t\t}\n\t}\n}\n", "language": "Java", "metadata": {"date": 1564889643, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02957.html", "problem_id": "p02957", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02957/input.txt", "sample_output_relpath": "derived/input_output/data/p02957/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02957/Java/s683998673.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s683998673", "user_id": "u936673091"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.util.*;\npublic class Main {\n\tpublic static void main(String[] args){\n\t\t// 整数の入力\n\t\tScanner sc = new Scanner(System.in);\n\t\t// 整数の入力\n\t\tint a = sc.nextInt();\n\t\tint b = sc.nextInt();\n\t\t// 絶対値の差分を取る10\n\t\tint c = Math.abs(a - b);\n\n\t\t// 偶数の場合はNG\n\t\tif(c % 2 != 0) {\n\t\t\tSystem.out.println(\"IMPOSSIBLE\");\n\t\t}else {\n\t\t\tint k = (a + b) / 2;\n\t\t\tSystem.out.println(k);\n\t\t}\n\t}\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nWe have two distinct integers A and B.\n\nPrint the integer K such that |A - K| = |B - K|.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A,\\ B \\leq 10^9\n\nA and B are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the integer K satisfying the condition.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nSample Input 1\n\n2 16\n\nSample Output 1\n\n9\n\n|2 - 9| = 7 and |16 - 9| = 7, so 9 satisfies the condition.\n\nSample Input 2\n\n0 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nNo integer satisfies the condition.\n\nSample Input 3\n\n998244353 99824435\n\nSample Output 3\n\n549034394", "sample_input": "2 16\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02957", "source_text": "Score: 100 points\n\nProblem Statement\n\nWe have two distinct integers A and B.\n\nPrint the integer K such that |A - K| = |B - K|.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A,\\ B \\leq 10^9\n\nA and B are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the integer K satisfying the condition.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nSample Input 1\n\n2 16\n\nSample Output 1\n\n9\n\n|2 - 9| = 7 and |16 - 9| = 7, so 9 satisfies the condition.\n\nSample Input 2\n\n0 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nNo integer satisfies the condition.\n\nSample Input 3\n\n998244353 99824435\n\nSample Output 3\n\n549034394", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 424, "cpu_time_ms": 95, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s706289687", "group_id": "codeNet:p02958", "input_text": "import java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\t Scanner scan = new Scanner(System.in);\n\t int r = scan.nextInt();\n\t ArrayList list = new ArrayList();\n\t for(int i=0;i sorted =(ArrayList) list.clone();\n\t Collections.sort(sorted);\n\t for(int i=0;i tmp =(ArrayList) list.clone();\n\t \t\t tmp.set(i, list.get(j));\n\t \t\t tmp.set(j, list.get(i));\n\t \t\t if(list.equals(tmp)) {\n\t \t\t\t System.out.println(\"YES\");\n\t \t\t\t return ;\n\t \t\t }\n\n\t \t }\n\n\t }\n\t\t System.out.println(\"NO\");\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1564278690, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02958.html", "problem_id": "p02958", "resource_group": "high_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/Java/s706289687.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s706289687", "user_id": "u914475937"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\t Scanner scan = new Scanner(System.in);\n\t int r = scan.nextInt();\n\t ArrayList list = new ArrayList();\n\t for(int i=0;i sorted =(ArrayList) list.clone();\n\t Collections.sort(sorted);\n\t for(int i=0;i tmp =(ArrayList) list.clone();\n\t \t\t tmp.set(i, list.get(j));\n\t \t\t tmp.set(j, list.get(i));\n\t \t\t if(list.equals(tmp)) {\n\t \t\t\t System.out.println(\"YES\");\n\t \t\t\t return ;\n\t \t\t }\n\n\t \t }\n\n\t }\n\t\t System.out.println(\"NO\");\n\t}\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": 937, "cpu_time_ms": 114, "memory_kb": 23892}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s379448485", "group_id": "codeNet:p02958", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scn = new Scanner(System.in);\n\n int N = scn.nextInt();\n\n int count = 0;\n for (int i = 1; i <= N; i++) {\n int p = scn.nextInt();\n if (p != i) {\n count++;\n }\n\n }\n if (count == 2 || count == 0) {\n System.out.println(\"YES\");\n } else {\n System.out.println(\"NO\");\n }\n }\n}", "language": "Java", "metadata": {"date": 1564276240, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02958.html", "problem_id": "p02958", "resource_group": "high_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/Java/s379448485.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s379448485", "user_id": "u647999897"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scn = new Scanner(System.in);\n\n int N = scn.nextInt();\n\n int count = 0;\n for (int i = 1; i <= N; i++) {\n int p = scn.nextInt();\n if (p != i) {\n count++;\n }\n\n }\n if (count == 2 || count == 0) {\n System.out.println(\"YES\");\n } else {\n System.out.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": 415, "cpu_time_ms": 106, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s056610854", "group_id": "codeNet:p02959", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] a = new int[n+1];\n int[] b = new int[n];\n for(int i = 0; i < n+1; i++){\n a[i] = sc.nextInt();\n }\n for(int i = 0; i < n; i++){\n b[i] = sc.nextInt();\n }\n long ans = 0;\n for(int i = 0; i < n; i++){\n if(a[i] <= b[i]){\n ans += a[i];\n b[i] -= a[i];\n a[i] = 0;\n ans += Math.min(a[i+1], b[i]);\n a[i+1] = Math.max(0,a[i+1]-b[i]);\n }else{\n ans += b[i];\n }\n }\n System.out.println(ans);\n }\n}", "language": "Java", "metadata": {"date": 1588296224, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02959.html", "problem_id": "p02959", "resource_group": "high_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/Java/s056610854.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s056610854", "user_id": "u578775554"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] a = new int[n+1];\n int[] b = new int[n];\n for(int i = 0; i < n+1; i++){\n a[i] = sc.nextInt();\n }\n for(int i = 0; i < n; i++){\n b[i] = sc.nextInt();\n }\n long ans = 0;\n for(int i = 0; i < n; i++){\n if(a[i] <= b[i]){\n ans += a[i];\n b[i] -= a[i];\n a[i] = 0;\n ans += Math.min(a[i+1], b[i]);\n a[i+1] = Math.max(0,a[i+1]-b[i]);\n }else{\n ans += b[i];\n }\n }\n System.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": 782, "cpu_time_ms": 610, "memory_kb": 67124}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s458983772", "group_id": "codeNet:p02959", "input_text": "public class Main {\n\tpublic static void main(String[] args) {\n\t\tjava.util.Scanner s = new java.util.Scanner(System.in);\n\t\tint a[] = new int[s.nextInt()+1];\n\t\tint b[] = new int[a.length-1];\n\t\tfor(int i=0;i=cap) {\n\t\t\ta[ind]-=cap;\n\t\t\treturn cap;\n\t\t}else {\n\t\t\tint res = 0;\n\t\t\tcap-=a[ind];\n\t\t\tres+=a[ind];\n\t\t\ta[ind]=0;\n\t\t\tif(a[ind+1]>=cap) {\n\t\t\t\ta[ind+1]-=cap;\n\t\t\t\treturn res + cap;\n\t\t\t}else {\n\t\t\t\tcap=0;\n\t\t\t\tres += a[ind+1];\n\t\t\t\ta[ind+1]=0;\n\t\t\t\treturn res;\n\t\t\t}\n\t\t}\n\t}\n}\n", "language": "Java", "metadata": {"date": 1564278587, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02959.html", "problem_id": "p02959", "resource_group": "high_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/Java/s458983772.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s458983772", "user_id": "u830501843"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "public class Main {\n\tpublic static void main(String[] args) {\n\t\tjava.util.Scanner s = new java.util.Scanner(System.in);\n\t\tint a[] = new int[s.nextInt()+1];\n\t\tint b[] = new int[a.length-1];\n\t\tfor(int i=0;i=cap) {\n\t\t\ta[ind]-=cap;\n\t\t\treturn cap;\n\t\t}else {\n\t\t\tint res = 0;\n\t\t\tcap-=a[ind];\n\t\t\tres+=a[ind];\n\t\t\ta[ind]=0;\n\t\t\tif(a[ind+1]>=cap) {\n\t\t\t\ta[ind+1]-=cap;\n\t\t\t\treturn res + cap;\n\t\t\t}else {\n\t\t\t\tcap=0;\n\t\t\t\tres += a[ind+1];\n\t\t\t\ta[ind+1]=0;\n\t\t\t\treturn res;\n\t\t\t}\n\t\t}\n\t}\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": 757, "cpu_time_ms": 604, "memory_kb": 65156}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s257335552", "group_id": "codeNet:p02960", "input_text": "import java.util.*;\npublic class Main {\n\tpublic static long mod;\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString S = sc.next();\n\t\tlong mod = (long)Math.pow(10, 9)+7; \n\t\tfinal int N = 13; \n\t\tlong r[] = new long[N];\n\t\t\n\t\tr[0]=1;//初期値で、0を13で割った余りは0\n\t\tint last = S.length()-1;\n\t\tlong mul = 1;//見てる桁数\n\t\tfor(int i=0;i<=last;i++) {\n\t\t\tlong nextr[] = new long[N];\n\t\t\tif(S.charAt(last-i)=='?') {\n\t\t\t\tfor(int j=0;j<=9;j++) {\n\t\t\t\t\tint tmp =(int)((j*mul)%N);\n\t\t\t\t\tfor(int k=0;k void printArrayT(T[] a) {\n\t// \tfor (int i = 0; i < a.length; i++) {\n\t// \t\tSystem.out.print(a[i] + \", \");\n\t// \t}\n\t// \tSystem.out.println();\n\t// }\n\n\t// public static class Triple implements Comparable {\n\t// \tpublic int A, B, C;\n\t// \tTriple(int A, int B, int C) {\n\t// \t\tthis.A = A;\n\t// \t\tthis.B = B;\n\t// \t\tthis.C = C;\n\t// \t}\n\n\t// \t@Override\n\t// \tpublic String toString() {\n\t// \t\treturn String.format(\"(%d, %d, %d)\", A, B, C);\n\t// \t}\n\n\t// \t@Override\n\t// \tpublic int compareTo(Triple o) {\n\t// \t\tint a = this.A - o.A;\n\t// \t\tif (a != 0) return a;\n\t// \t\tint b = this.B - o.B;\n\t// \t\tif (b != 0) return b;\n\t// \t\treturn this.C - o.C;\n\t// \t}\n\t// }\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint[] A = new int[N];\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\tint color = 0;\n\t\tTreeMap map = new TreeMap<>();\n\t\tfor (int i = N - 1; i >= 0; i--) {\n\t\t\tint value = A[i];\n\t\t\tMap.Entry entry = map.ceilingEntry(value + 1);\n\t\t\tif (entry != null) {\n\t\t\t\tif (entry.getValue() == 1) {\n\t\t\t\t\tmap.remove(entry.getKey());\n\t\t\t\t} else {\n\t\t\t\t\tmap.put(entry.getKey(), entry.getValue() - 1);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcolor++;\n\t\t\t}\n\t\t\tif (map.containsKey(value)) {\n\t\t\t\tmap.put(value, map.get(value) + 1);\n\t\t\t} else {\n\t\t\t\tmap.put(value, 1);\n\t\t\t}\n\t}\n\t\tSystem.out.println(color);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1565638251, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02973.html", "problem_id": "p02973", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02973/input.txt", "sample_output_relpath": "derived/input_output/data/p02973/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02973/Java/s219105200.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s219105200", "user_id": "u579651661"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\t// public static void printArray(int[] a) {\n\t// \tfor (int i = 0; i < a.length; i++) {\n\t// \t\tSystem.out.print(a[i] + \", \");\n\t// \t}\n\t// \tSystem.out.println();\n\t// }\n\n\t// public static void printArrayT(T[] a) {\n\t// \tfor (int i = 0; i < a.length; i++) {\n\t// \t\tSystem.out.print(a[i] + \", \");\n\t// \t}\n\t// \tSystem.out.println();\n\t// }\n\n\t// public static class Triple implements Comparable {\n\t// \tpublic int A, B, C;\n\t// \tTriple(int A, int B, int C) {\n\t// \t\tthis.A = A;\n\t// \t\tthis.B = B;\n\t// \t\tthis.C = C;\n\t// \t}\n\n\t// \t@Override\n\t// \tpublic String toString() {\n\t// \t\treturn String.format(\"(%d, %d, %d)\", A, B, C);\n\t// \t}\n\n\t// \t@Override\n\t// \tpublic int compareTo(Triple o) {\n\t// \t\tint a = this.A - o.A;\n\t// \t\tif (a != 0) return a;\n\t// \t\tint b = this.B - o.B;\n\t// \t\tif (b != 0) return b;\n\t// \t\treturn this.C - o.C;\n\t// \t}\n\t// }\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint[] A = new int[N];\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tA[i] = sc.nextInt();\n\t\t}\n\t\tint color = 0;\n\t\tTreeMap map = new TreeMap<>();\n\t\tfor (int i = N - 1; i >= 0; i--) {\n\t\t\tint value = A[i];\n\t\t\tMap.Entry entry = map.ceilingEntry(value + 1);\n\t\t\tif (entry != null) {\n\t\t\t\tif (entry.getValue() == 1) {\n\t\t\t\t\tmap.remove(entry.getKey());\n\t\t\t\t} else {\n\t\t\t\t\tmap.put(entry.getKey(), entry.getValue() - 1);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcolor++;\n\t\t\t}\n\t\t\tif (map.containsKey(value)) {\n\t\t\t\tmap.put(value, map.get(value) + 1);\n\t\t\t} else {\n\t\t\t\tmap.put(value, 1);\n\t\t\t}\n\t}\n\t\tSystem.out.println(color);\n\t}\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given a sequence with N integers: A = \\{ A_1, A_2, \\cdots, A_N \\}.\nFor each of these N integers, we will choose a color and paint the integer with that color. Here the following condition must be satisfied:\n\nIf A_i and A_j (i < j) are painted with the same color, A_i < A_j.\n\nFind the minimum number of colors required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint the minimum number of colors required to satisfy the condition.\n\nSample Input 1\n\n5\n2\n1\n4\n5\n3\n\nSample Output 1\n\n2\n\nWe can satisfy the condition with two colors by, for example, painting 2 and 3 red and painting 1, 4, and 5 blue.\n\nSample Input 2\n\n4\n0\n0\n0\n0\n\nSample Output 2\n\n4\n\nWe have to paint all the integers with distinct colors.", "sample_input": "5\n2\n1\n4\n5\n3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02973", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given a sequence with N integers: A = \\{ A_1, A_2, \\cdots, A_N \\}.\nFor each of these N integers, we will choose a color and paint the integer with that color. Here the following condition must be satisfied:\n\nIf A_i and A_j (i < j) are painted with the same color, A_i < A_j.\n\nFind the minimum number of colors required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint the minimum number of colors required to satisfy the condition.\n\nSample Input 1\n\n5\n2\n1\n4\n5\n3\n\nSample Output 1\n\n2\n\nWe can satisfy the condition with two colors by, for example, painting 2 and 3 red and painting 1, 4, and 5 blue.\n\nSample Input 2\n\n4\n0\n0\n0\n0\n\nSample Output 2\n\n4\n\nWe have to paint all the integers with distinct colors.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1596, "cpu_time_ms": 641, "memory_kb": 57464}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s708844853", "group_id": "codeNet:p02975", "input_text": "\nimport java.util.HashMap;\nimport java.util.Map;\n\npublic class Main {\n\n private static void solve() {\n int n = ni();\n int[] a = na(n);\n Map map = new HashMap<>();\n for (int v : a) {\n map.putIfAbsent(v, 0);\n\n map.put(v, map.get(v) + 1);\n }\n\n\n int c1 = a[0];\n int c2 = a[1];\n\n int[] b = new int[n];\n b[0] = c1;\n b[1] = c2;\n\n for (int v : new int[] {c1, c2}) {\n map.put(v, map.get(v) - 1);\n if (map.get(v) == 0) {\n map.remove(v);\n }\n }\n\n for (int i = 2; i < n; i++) {\n int x = b[i - 2];\n int y = b[i - 1];\n int z = x ^ y;\n\n if (!map.containsKey(z)) {\n System.out.println(\"No\");\n return;\n }\n map.put(z, map.get(z) - 1);\n if (map.get(z) == 0) {\n map.remove(z);\n }\n b[i] = z;\n }\n if ((a[0] ^ a[n - 2]) != a[n - 1]) {\n System.out.println(\"No\");\n return;\n }\n\n System.out.println(\"Yes\");\n }\n\n public static void main(String[] args) {\n new Thread(null, new Runnable() {\n @Override\n public void run() {\n long start = System.currentTimeMillis();\n String debug = args.length > 0 ? args[0] : null;\n if (debug != null) {\n try {\n is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));\n } catch (Exception e) {\n throw new RuntimeException(e);\n }\n }\n reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);\n solve();\n out.flush();\n tr((System.currentTimeMillis() - start) + \"ms\");\n }\n }, \"\", 64000000).start();\n }\n\n private static java.io.InputStream is = System.in;\n private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);\n private static java.util.StringTokenizer tokenizer = null;\n private static java.io.BufferedReader reader;\n\n public static String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new java.util.StringTokenizer(reader.readLine());\n } catch (Exception e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n private static double nd() {\n return Double.parseDouble(next());\n }\n\n private static long nl() {\n return Long.parseLong(next());\n }\n\n private static int[] na(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = ni();\n return a;\n }\n\n private static char[] ns() {\n return next().toCharArray();\n }\n\n private static long[] nal(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = nl();\n return a;\n }\n\n private static int[][] ntable(int n, int m) {\n int[][] table = new int[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n table[i][j] = ni();\n }\n }\n return table;\n }\n\n private static int[][] nlist(int n, int m) {\n int[][] table = new int[m][n];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n table[j][i] = ni();\n }\n }\n return table;\n }\n\n private static int ni() {\n return Integer.parseInt(next());\n }\n\n private static void tr(Object... o) {\n if (is != System.in)\n System.out.println(java.util.Arrays.deepToString(o));\n }\n}\n\n", "language": "Java", "metadata": {"date": 1563154681, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02975.html", "problem_id": "p02975", "resource_group": "high_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/Java/s708844853.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s708844853", "user_id": "u769201746"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "\nimport java.util.HashMap;\nimport java.util.Map;\n\npublic class Main {\n\n private static void solve() {\n int n = ni();\n int[] a = na(n);\n Map map = new HashMap<>();\n for (int v : a) {\n map.putIfAbsent(v, 0);\n\n map.put(v, map.get(v) + 1);\n }\n\n\n int c1 = a[0];\n int c2 = a[1];\n\n int[] b = new int[n];\n b[0] = c1;\n b[1] = c2;\n\n for (int v : new int[] {c1, c2}) {\n map.put(v, map.get(v) - 1);\n if (map.get(v) == 0) {\n map.remove(v);\n }\n }\n\n for (int i = 2; i < n; i++) {\n int x = b[i - 2];\n int y = b[i - 1];\n int z = x ^ y;\n\n if (!map.containsKey(z)) {\n System.out.println(\"No\");\n return;\n }\n map.put(z, map.get(z) - 1);\n if (map.get(z) == 0) {\n map.remove(z);\n }\n b[i] = z;\n }\n if ((a[0] ^ a[n - 2]) != a[n - 1]) {\n System.out.println(\"No\");\n return;\n }\n\n System.out.println(\"Yes\");\n }\n\n public static void main(String[] args) {\n new Thread(null, new Runnable() {\n @Override\n public void run() {\n long start = System.currentTimeMillis();\n String debug = args.length > 0 ? args[0] : null;\n if (debug != null) {\n try {\n is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));\n } catch (Exception e) {\n throw new RuntimeException(e);\n }\n }\n reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);\n solve();\n out.flush();\n tr((System.currentTimeMillis() - start) + \"ms\");\n }\n }, \"\", 64000000).start();\n }\n\n private static java.io.InputStream is = System.in;\n private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);\n private static java.util.StringTokenizer tokenizer = null;\n private static java.io.BufferedReader reader;\n\n public static String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new java.util.StringTokenizer(reader.readLine());\n } catch (Exception e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n private static double nd() {\n return Double.parseDouble(next());\n }\n\n private static long nl() {\n return Long.parseLong(next());\n }\n\n private static int[] na(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = ni();\n return a;\n }\n\n private static char[] ns() {\n return next().toCharArray();\n }\n\n private static long[] nal(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = nl();\n return a;\n }\n\n private static int[][] ntable(int n, int m) {\n int[][] table = new int[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n table[i][j] = ni();\n }\n }\n return table;\n }\n\n private static int[][] nlist(int n, int m) {\n int[][] table = new int[m][n];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n table[j][i] = ni();\n }\n }\n return table;\n }\n\n private static int ni() {\n return Integer.parseInt(next());\n }\n\n private static void tr(Object... o) {\n if (is != System.in)\n System.out.println(java.util.Arrays.deepToString(o));\n }\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has N hats. The i-th hat has an integer a_i written on it.\n\nThere are N camels standing in a circle.\nSnuke will put one of his hats on each of these camels.\n\nIf there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print Yes; otherwise, print No.\n\nThe bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself.\n\nWhat is XOR?\n\nThe bitwise XOR x_1 \\oplus x_2 \\oplus \\ldots \\oplus x_n of n non-negative integers x_1, x_2, \\ldots, x_n is defined as follows:\n\n- When x_1 \\oplus x_2 \\oplus \\ldots \\oplus x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3 \\oplus 5 = 6.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 10^{5}\n\n0 \\leq a_i \\leq 10^{9}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\nYes\n\nIf we put the hats with 1, 2, and 3 in this order, clockwise, the condition will be satisfied for every camel, so the answer is Yes.\n\nSample Input 2\n\n4\n1 2 4 8\n\nSample Output 2\n\nNo\n\nThere is no such way to distribute the hats; the answer is No.", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02975", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has N hats. The i-th hat has an integer a_i written on it.\n\nThere are N camels standing in a circle.\nSnuke will put one of his hats on each of these camels.\n\nIf there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print Yes; otherwise, print No.\n\nThe bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself.\n\nWhat is XOR?\n\nThe bitwise XOR x_1 \\oplus x_2 \\oplus \\ldots \\oplus x_n of n non-negative integers x_1, x_2, \\ldots, x_n is defined as follows:\n\n- When x_1 \\oplus x_2 \\oplus \\ldots \\oplus x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3 \\oplus 5 = 6.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 10^{5}\n\n0 \\leq a_i \\leq 10^{9}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\nYes\n\nIf we put the hats with 1, 2, and 3 in this order, clockwise, the condition will be satisfied for every camel, so the answer is Yes.\n\nSample Input 2\n\n4\n1 2 4 8\n\nSample Output 2\n\nNo\n\nThere is no such way to distribute the hats; the answer is No.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3302, "cpu_time_ms": 256, "memory_kb": 44568}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s144449877", "group_id": "codeNet:p02981", "input_text": "import java.util.ArrayDeque;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.Queue;\nimport java.util.Scanner;\n \n\n\npublic class Main {\n\tprivate static Scanner sc = new Scanner(System.in);\n\t//result = Math.pow(num1, num3)\n\t//StringBuffer str = new StringBuffer(hoge1);\n\t//String hoge2 = str.reverse().toString();\n\t//map.containsKey(A)\n\n\t//Map map = new HashMap(n);\n\t/*for ( キーのデータ型 key : マップの名前.keySet() ) {\n\t\tデータのデータ型 data = マップの名前.get( key );\n\t\t\n\t\t// keyやdataを使った処理;\n\t}*/\n\t//int i = Integer.parseInt(s);\n\t//Queue qq=new ArrayDeque<>(); //add,poll,peek\n\t//Deque qq=new ArrayDeque<>();//push,pop,peek\n\t//ArrayList cc = new ArrayList<>(n);\n\t//Collections.sort(list);\n\t//Array.sort(list); cc.contains(tmp)\n\t//Arrays.asList(c).contains(\"a\")\n\t//list.set(1,\"walk\");//1 1 2 3 5\n\t//static long mod =1000000007;\n\t//static \tArrayList cc = new ArrayList<>(100);\n\t\n\t\n\t\n\t\n\t//for(int i=0;i list=new ArrayList<>();\n\t\tfor(int i=0;i=0;i--) {\n\t\t\tif(list.get(i)=L;i--) {\n\t\t\tif(pivot map = new HashMap(n);\n\t/*for ( キーのデータ型 key : マップの名前.keySet() ) {\n\t\tデータのデータ型 data = マップの名前.get( key );\n\t\t\n\t\t// keyやdataを使った処理;\n\t}*/\n\t//int i = Integer.parseInt(s);\n\t//Queue qq=new ArrayDeque<>(); //add,poll,peek\n\t//Deque qq=new ArrayDeque<>();//push,pop,peek\n\t//ArrayList cc = new ArrayList<>(n);\n\t//Collections.sort(list);\n\t//Array.sort(list); cc.contains(tmp)\n\t//Arrays.asList(c).contains(\"a\")\n\t//list.set(1,\"walk\");//1 1 2 3 5\n\t//static long mod =1000000007;\n\t//static \tArrayList cc = new ArrayList<>(100);\n\t\n\t\n\t\n\t\n\t//for(int i=0;i list=new ArrayList<>();\n\t\tfor(int i=0;i=0;i--) {\n\t\t\tif(list.get(i)=L;i--) {\n\t\t\tif(pivot= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0) {\n return -1;\n }\n }\n return buf[curChar++];\n }\n\n public int nextInt() {\n int c = read();\n while (isSpaceChar(c)) {\n c = read();\n }\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n res *= 10;\n res += c - '0';\n c = read();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n\n public boolean isSpaceChar(int c) {\n if (filter != null) {\n return filter.isSpaceChar(c);\n }\n return isWhitespace(c);\n }\n\n public static boolean isWhitespace(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public int[] nextIntArray(int n) {\n int[] array = new int[n];\n for (int i = 0; i < n; ++i) array[i] = nextInt();\n return array;\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\n\n }\n\n static class OutputWriter {\n private final PrintWriter writer;\n\n public OutputWriter(OutputStream outputStream) {\n writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));\n }\n\n public OutputWriter(Writer writer) {\n this.writer = new PrintWriter(writer);\n }\n\n public void close() {\n writer.close();\n }\n\n public void println(int i) {\n writer.println(i);\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1561856863, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02988.html", "problem_id": "p02988", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02988/input.txt", "sample_output_relpath": "derived/input_output/data/p02988/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02988/Java/s946080798.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s946080798", "user_id": "u052212445"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.io.BufferedWriter;\nimport java.io.Writer;\nimport java.io.OutputStreamWriter;\nimport java.util.InputMismatchException;\nimport java.io.IOException;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n OutputWriter out = new OutputWriter(outputStream);\n BOrdinaryNumber solver = new BOrdinaryNumber();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class BOrdinaryNumber {\n public void solve(int testNumber, InputReader in, OutputWriter out) {\n int n = in.nextInt();\n int ar[] = in.nextIntArray(n);\n int cc = 0;\n for (int i = 1; i < n - 1; i++) {\n int a = ar[i - 1];\n int b = ar[i];\n int c = ar[i + 1];\n int arr[] = {a, b, c};\n Arrays.sort(arr);\n if (arr[1] == b)\n cc++;\n }\n out.println(cc);\n }\n\n }\n\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private InputReader.SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n\n public int read() {\n if (numChars == -1) {\n throw new InputMismatchException();\n }\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0) {\n return -1;\n }\n }\n return buf[curChar++];\n }\n\n public int nextInt() {\n int c = read();\n while (isSpaceChar(c)) {\n c = read();\n }\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n res *= 10;\n res += c - '0';\n c = read();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n\n public boolean isSpaceChar(int c) {\n if (filter != null) {\n return filter.isSpaceChar(c);\n }\n return isWhitespace(c);\n }\n\n public static boolean isWhitespace(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public int[] nextIntArray(int n) {\n int[] array = new int[n];\n for (int i = 0; i < n; ++i) array[i] = nextInt();\n return array;\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\n\n }\n\n static class OutputWriter {\n private final PrintWriter writer;\n\n public OutputWriter(OutputStream outputStream) {\n writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));\n }\n\n public OutputWriter(Writer writer) {\n this.writer = new PrintWriter(writer);\n }\n\n public void close() {\n writer.close();\n }\n\n public void println(int i) {\n writer.println(i);\n }\n\n }\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a permutation p = {p_1,\\ p_2,\\ ...,\\ p_n} of {1,\\ 2,\\ ...,\\ n}.\n\nPrint the number of elements p_i (1 < i < n) that satisfy the following condition:\n\np_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 20\n\np is a permutation of {1,\\ 2,\\ ...,\\ n}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\np_1 p_2 ... p_n\n\nOutput\n\nPrint the number of elements p_i (1 < i < n) that satisfy the condition.\n\nSample Input 1\n\n5\n1 3 5 4 2\n\nSample Output 1\n\n2\n\np_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5. Also, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 = 2. These two elements satisfy the condition.\n\nSample Input 2\n\n9\n9 6 3 2 5 8 7 4 1\n\nSample Output 2\n\n5", "sample_input": "5\n1 3 5 4 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02988", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a permutation p = {p_1,\\ p_2,\\ ...,\\ p_n} of {1,\\ 2,\\ ...,\\ n}.\n\nPrint the number of elements p_i (1 < i < n) that satisfy the following condition:\n\np_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 20\n\np is a permutation of {1,\\ 2,\\ ...,\\ n}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\np_1 p_2 ... p_n\n\nOutput\n\nPrint the number of elements p_i (1 < i < n) that satisfy the condition.\n\nSample Input 1\n\n5\n1 3 5 4 2\n\nSample Output 1\n\n2\n\np_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5. Also, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 = 2. These two elements satisfy the condition.\n\nSample Input 2\n\n9\n9 6 3 2 5 8 7 4 1\n\nSample Output 2\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3921, "cpu_time_ms": 75, "memory_kb": 23252}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s075943122", "group_id": "codeNet:p02989", "input_text": "import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n int n = in.nextInt();\n int d[] = new int[n];\n for (int i = 0; i < n; i++) {\n d[i] = in.nextInt();\n }\n\n Arrays.sort(d);\n System.out.println(d[n / 2] - d[n / 2 - 1]);\n }\n}\n", "language": "Java", "metadata": {"date": 1591755823, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02989.html", "problem_id": "p02989", "resource_group": "high_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/Java/s075943122.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s075943122", "user_id": "u649423108"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n int n = in.nextInt();\n int d[] = new int[n];\n for (int i = 0; i < n; i++) {\n d[i] = in.nextInt();\n }\n\n Arrays.sort(d);\n System.out.println(d[n / 2] - d[n / 2 - 1]);\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi made N problems for competitive programming.\nThe problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).\n\nHe is dividing the problems into two categories by choosing an integer K, as follows:\n\nA problem with difficulty K or higher will be for ARCs.\n\nA problem with difficulty lower than K will be for ABCs.\n\nHow many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?\n\nProblem Statement\n\n2 \\leq N \\leq 10^5\n\nN is an even number.\n\n1 \\leq d_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 1\n\n6\n9 1 4 4 6 7\n\nSample Output 1\n\n2\n\nIf we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.\nThus, the answer is 2.\n\nSample Input 2\n\n8\n9 1 14 5 5 4 4 14\n\nSample Output 2\n\n0\n\nThere may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 3\n\n14\n99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1\n\nSample Output 3\n\n42685", "sample_input": "6\n9 1 4 4 6 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02989", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi made N problems for competitive programming.\nThe problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).\n\nHe is dividing the problems into two categories by choosing an integer K, as follows:\n\nA problem with difficulty K or higher will be for ARCs.\n\nA problem with difficulty lower than K will be for ABCs.\n\nHow many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?\n\nProblem Statement\n\n2 \\leq N \\leq 10^5\n\nN is an even number.\n\n1 \\leq d_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 1\n\n6\n9 1 4 4 6 7\n\nSample Output 1\n\n2\n\nIf we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.\nThus, the answer is 2.\n\nSample Input 2\n\n8\n9 1 14 5 5 4 4 14\n\nSample Output 2\n\n0\n\nThere may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 3\n\n14\n99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1\n\nSample Output 3\n\n42685", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 389, "cpu_time_ms": 469, "memory_kb": 51436}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s391153698", "group_id": "codeNet:p02990", "input_text": "import java.util.*;\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint K = sc.nextInt();\n\t\tsc.close();\n\t\t\n\t\tif(N==K){\n\t\t\tSystem.out.println(1);\n\t\t\treturn;\n\t\t}\n\n\t\tfor(int i=1;i<=K;i++){\n\t\t\tlong tmp = comb(N-K+1,i)*comb(K-1,i-1);\n\t\t\ttmp %= (Math.pow(10, 9)+7);\n\t\t\tSystem.out.println(tmp);\n\t\t}\n\n\t}\n\n\t//combination\n\tstatic long comb(int n, int k){\n\t\tif(n> g = g(us, vs);\n \n int S = nint();\n int T = nint();\n \n int[][] cost = new int[3][N+1];\n for (int i = 0; i < 3; i++) {\n Arrays.fill(cost[i], INF);\n }\n \n Pair start = new Pair(0, S);\n cost[0][S] = 0;\n \n Deque d = new ArrayDeque<>();\n d.add(start);\n \n while (!d.isEmpty()) {\n Pair top = d.poll();\n Set nexts = g.get(top);\n if (nexts == null) continue;\n \n for (Pair n : nexts) {\n int newCost = cost[top.lev][top.num] + 1;\n if (newCost < cost[n.lev][n.num]) {\n cost[n.lev][n.num] = newCost;\n d.add(n);\n }\n }\n }\n \n System.out.println(cost[0][T] == INF ? -1 : cost[0][T] / 3);\n }\n public static class Pair {\n int lev;\n int num;\n public Pair(int lev, int num) {\n super();\n this.lev = lev;\n this.num = num;\n }\n \n @Override\n public boolean equals(Object obj) {\n Pair that = (Pair) obj;\n return that.num == this.num && that.lev == this.lev;\n }\n \n @Override\n public int hashCode() {\n final int prime = 31;\n int result = 1;\n result = prime * result + num;\n result = prime * result + lev;\n return result;\n }\n \n @Override\n public String toString() {\n return \"Pair[\" + num + \", \" + lev + \"]\";\n }\n }\n \n public static Map> g(Pair[] nodes1, Pair[] nodes2) {\n Map> graph = new HashMap<>();\n \n for (int i = 0; i < nodes1.length; i++) {\n Pair u = nodes1[i];\n Pair v = nodes2[i];\n \n Set uc = graph.get(u);\n if (uc == null) {\n uc = new HashSet<>();\n }\n uc.add(v);\n graph.put(u, uc);\n }\n return graph;\n }\n\n private static int nint() {\n return sc.nextInt();\n }\n\n private static int[] nints(int n) {\n return nints(n, 0, 0);\n }\n\n private static int[] nints(int n, int padL, int padR) {\n int[] a = new int[padL + n + padR];\n for (int i = 0; i < n; i++)\n a[padL + i] = nint();\n return a;\n }\n\n private static long nlong() {\n return sc.nextLong();\n }\n\n private static long[] nlongs(int n) {\n return nlongs(n, 0, 0);\n }\n\n private static long[] nlongs(int n, int padL, int padR) {\n long[] a = new long[padL + n + padR];\n for (int i = 0; i < n; i++)\n a[padL + i] = nlong();\n return a;\n }\n\n private static double ndouble() {\n return sc.nextDouble();\n }\n \n private static double[] ndoubles(int n) {\n return ndoubles(n, 0, 0);\n }\n \n private static double[] ndoubles(int n, int padL, int padR) {\n double[] d = new double[n + padL + padR];\n for (int i = 0; i < n; i++) {\n d[padL + i] = ndouble();\n }\n return d;\n }\n\n private static String nstr() {\n return sc.next();\n }\n\n private static char[] nchars() {\n return sc.next().toCharArray();\n }\n\n private static char[] nchars(int padL, int padR) {\n char[] temp = sc.next().toCharArray();\n char[] ret = new char[temp.length + padL + padR];\n System.arraycopy(temp, 0, ret, padL, temp.length);\n return ret;\n }\n \n private static char[][] nchars2(int h, int w) {\n return nchars2(h, w, 0, 0);\n }\n\n private static char[][] nchars2(int h, int w, int padLU, int padRD) {\n char[][] a2 = new char[h + padLU + padRD][w + padLU + padRD];\n for (int i = 0; i < h; i++)\n System.arraycopy(nchars(), 0, a2[padLU + i], padLU, w);\n return a2;\n }\n \n static long max(long... longs) {\n return Arrays.stream(longs).max().getAsLong();\n }\n \n static long min(long... longs) {\n return Arrays.stream(longs).min().getAsLong();\n }\n}\n", "language": "Java", "metadata": {"date": 1568486862, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02991.html", "problem_id": "p02991", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02991/input.txt", "sample_output_relpath": "derived/input_output/data/p02991/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02991/Java/s954201095.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s954201095", "user_id": "u228127260"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\nimport java.util.ArrayDeque;\nimport java.util.Arrays;\nimport java.util.Deque;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.Map;\nimport java.util.Scanner;\nimport java.util.Set;\n\npublic class Main {\n static final Scanner sc = new Scanner(System.in);\n static final int MOD = (int) 1E9 + 7;\n static final int INF = Integer.MAX_VALUE;\n \n public static void main(String[] args) {\n int N = nint();\n int M = nint();\n Pair[] us = new Pair[M*3];\n Pair[] vs = new Pair[M*3];\n for (int i = 0; i < M; i++) {\n int ui = nint();\n int vi = nint();\n for (int j = 0; j < 3; j++) {\n Pair u = new Pair(j, ui);\n Pair v = new Pair((j+1) % 3, vi);\n us[i*3 + j] = u;\n vs[i*3 + j] = v;\n }\n }\n \n Map> g = g(us, vs);\n \n int S = nint();\n int T = nint();\n \n int[][] cost = new int[3][N+1];\n for (int i = 0; i < 3; i++) {\n Arrays.fill(cost[i], INF);\n }\n \n Pair start = new Pair(0, S);\n cost[0][S] = 0;\n \n Deque d = new ArrayDeque<>();\n d.add(start);\n \n while (!d.isEmpty()) {\n Pair top = d.poll();\n Set nexts = g.get(top);\n if (nexts == null) continue;\n \n for (Pair n : nexts) {\n int newCost = cost[top.lev][top.num] + 1;\n if (newCost < cost[n.lev][n.num]) {\n cost[n.lev][n.num] = newCost;\n d.add(n);\n }\n }\n }\n \n System.out.println(cost[0][T] == INF ? -1 : cost[0][T] / 3);\n }\n public static class Pair {\n int lev;\n int num;\n public Pair(int lev, int num) {\n super();\n this.lev = lev;\n this.num = num;\n }\n \n @Override\n public boolean equals(Object obj) {\n Pair that = (Pair) obj;\n return that.num == this.num && that.lev == this.lev;\n }\n \n @Override\n public int hashCode() {\n final int prime = 31;\n int result = 1;\n result = prime * result + num;\n result = prime * result + lev;\n return result;\n }\n \n @Override\n public String toString() {\n return \"Pair[\" + num + \", \" + lev + \"]\";\n }\n }\n \n public static Map> g(Pair[] nodes1, Pair[] nodes2) {\n Map> graph = new HashMap<>();\n \n for (int i = 0; i < nodes1.length; i++) {\n Pair u = nodes1[i];\n Pair v = nodes2[i];\n \n Set uc = graph.get(u);\n if (uc == null) {\n uc = new HashSet<>();\n }\n uc.add(v);\n graph.put(u, uc);\n }\n return graph;\n }\n\n private static int nint() {\n return sc.nextInt();\n }\n\n private static int[] nints(int n) {\n return nints(n, 0, 0);\n }\n\n private static int[] nints(int n, int padL, int padR) {\n int[] a = new int[padL + n + padR];\n for (int i = 0; i < n; i++)\n a[padL + i] = nint();\n return a;\n }\n\n private static long nlong() {\n return sc.nextLong();\n }\n\n private static long[] nlongs(int n) {\n return nlongs(n, 0, 0);\n }\n\n private static long[] nlongs(int n, int padL, int padR) {\n long[] a = new long[padL + n + padR];\n for (int i = 0; i < n; i++)\n a[padL + i] = nlong();\n return a;\n }\n\n private static double ndouble() {\n return sc.nextDouble();\n }\n \n private static double[] ndoubles(int n) {\n return ndoubles(n, 0, 0);\n }\n \n private static double[] ndoubles(int n, int padL, int padR) {\n double[] d = new double[n + padL + padR];\n for (int i = 0; i < n; i++) {\n d[padL + i] = ndouble();\n }\n return d;\n }\n\n private static String nstr() {\n return sc.next();\n }\n\n private static char[] nchars() {\n return sc.next().toCharArray();\n }\n\n private static char[] nchars(int padL, int padR) {\n char[] temp = sc.next().toCharArray();\n char[] ret = new char[temp.length + padL + padR];\n System.arraycopy(temp, 0, ret, padL, temp.length);\n return ret;\n }\n \n private static char[][] nchars2(int h, int w) {\n return nchars2(h, w, 0, 0);\n }\n\n private static char[][] nchars2(int h, int w, int padLU, int padRD) {\n char[][] a2 = new char[h + padLU + padRD][w + padLU + padRD];\n for (int i = 0; i < h; i++)\n System.arraycopy(nchars(), 0, a2[padLU + i], padLU, w);\n return a2;\n }\n \n static long max(long... longs) {\n return Arrays.stream(longs).max().getAsLong();\n }\n \n static long min(long... longs) {\n return Arrays.stream(longs).min().getAsLong();\n }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nKen loves ken-ken-pa (Japanese version of hopscotch). Today, he will play it on a directed graph G.\nG consists of N vertices numbered 1 to N, and M edges. The i-th edge points from Vertex u_i to Vertex v_i.\n\nFirst, Ken stands on Vertex S. He wants to reach Vertex T by repeating ken-ken-pa. In one ken-ken-pa, he does the following exactly three times: follow an edge pointing from the vertex on which he is standing.\n\nDetermine if he can reach Vertex T by repeating ken-ken-pa. If the answer is yes, find the minimum number of ken-ken-pa needed to reach Vertex T. Note that visiting Vertex T in the middle of a ken-ken-pa does not count as reaching Vertex T by repeating ken-ken-pa.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n0 \\leq M \\leq \\min(10^5, N (N-1))\n\n1 \\leq u_i, v_i \\leq N(1 \\leq i \\leq M)\n\nu_i \\neq v_i (1 \\leq i \\leq M)\n\nIf i \\neq j, (u_i, v_i) \\neq (u_j, v_j).\n\n1 \\leq S, T \\leq N\n\nS \\neq T\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nu_1 v_1\n:\nu_M v_M\nS T\n\nOutput\n\nIf Ken cannot reach Vertex T from Vertex S by repeating ken-ken-pa, print -1.\nIf he can, print the minimum number of ken-ken-pa needed to reach vertex T.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 1\n1 3\n\nSample Output 1\n\n2\n\nKen can reach Vertex 3 from Vertex 1 in two ken-ken-pa, as follows: 1 \\rightarrow 2 \\rightarrow 3 \\rightarrow 4 in the first ken-ken-pa, then 4 \\rightarrow 1 \\rightarrow 2 \\rightarrow 3 in the second ken-ken-pa. This is the minimum number of ken-ken-pa needed.\n\nSample Input 2\n\n3 3\n1 2\n2 3\n3 1\n1 2\n\nSample Output 2\n\n-1\n\nAny number of ken-ken-pa will bring Ken back to Vertex 1, so he cannot reach Vertex 2, though he can pass through it in the middle of a ken-ken-pa.\n\nSample Input 3\n\n2 0\n1 2\n\nSample Output 3\n\n-1\n\nVertex S and Vertex T may be disconnected.\n\nSample Input 4\n\n6 8\n1 2\n2 3\n3 4\n4 5\n5 1\n1 4\n1 5\n4 6\n1 6\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 2\n2 3\n3 4\n4 1\n1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02991", "source_text": "Score : 500 points\n\nProblem Statement\n\nKen loves ken-ken-pa (Japanese version of hopscotch). Today, he will play it on a directed graph G.\nG consists of N vertices numbered 1 to N, and M edges. The i-th edge points from Vertex u_i to Vertex v_i.\n\nFirst, Ken stands on Vertex S. He wants to reach Vertex T by repeating ken-ken-pa. In one ken-ken-pa, he does the following exactly three times: follow an edge pointing from the vertex on which he is standing.\n\nDetermine if he can reach Vertex T by repeating ken-ken-pa. If the answer is yes, find the minimum number of ken-ken-pa needed to reach Vertex T. Note that visiting Vertex T in the middle of a ken-ken-pa does not count as reaching Vertex T by repeating ken-ken-pa.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n0 \\leq M \\leq \\min(10^5, N (N-1))\n\n1 \\leq u_i, v_i \\leq N(1 \\leq i \\leq M)\n\nu_i \\neq v_i (1 \\leq i \\leq M)\n\nIf i \\neq j, (u_i, v_i) \\neq (u_j, v_j).\n\n1 \\leq S, T \\leq N\n\nS \\neq T\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nu_1 v_1\n:\nu_M v_M\nS T\n\nOutput\n\nIf Ken cannot reach Vertex T from Vertex S by repeating ken-ken-pa, print -1.\nIf he can, print the minimum number of ken-ken-pa needed to reach vertex T.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 1\n1 3\n\nSample Output 1\n\n2\n\nKen can reach Vertex 3 from Vertex 1 in two ken-ken-pa, as follows: 1 \\rightarrow 2 \\rightarrow 3 \\rightarrow 4 in the first ken-ken-pa, then 4 \\rightarrow 1 \\rightarrow 2 \\rightarrow 3 in the second ken-ken-pa. This is the minimum number of ken-ken-pa needed.\n\nSample Input 2\n\n3 3\n1 2\n2 3\n3 1\n1 2\n\nSample Output 2\n\n-1\n\nAny number of ken-ken-pa will bring Ken back to Vertex 1, so he cannot reach Vertex 2, though he can pass through it in the middle of a ken-ken-pa.\n\nSample Input 3\n\n2 0\n1 2\n\nSample Output 3\n\n-1\n\nVertex S and Vertex T may be disconnected.\n\nSample Input 4\n\n6 8\n1 2\n2 3\n3 4\n4 5\n5 1\n1 4\n1 5\n4 6\n1 6\n\nSample Output 4\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5073, "cpu_time_ms": 1564, "memory_kb": 177764}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s757153322", "group_id": "codeNet:p02991", "input_text": "import java.util.*;\n\n\nclass Main{\n static int[][] dp;\n static int[][] map;\n static int n,m,T,S;\n public static void main(String argv[]) {\n Scanner sc = new Scanner(System.in);\n n = sc.nextInt();\n m = sc.nextInt();\n dp = new int[n+1][n+1];\n map = new int[n+1][3];\n for(int i=0;i 0) {\n //絶対値の小さい方に丸められる(正なら負の方向)\n return a/b;\n } else {\n //よくある切り上げのテクニックの切り捨て版\n return (a-b+1)/b;\n }\n }\n\n /*\n * n >= a/b なる最小の整数nを返す\n */\n public long ceil(long a, long b) {\n if (b < 0) {\n a *= -1;\n b *= -1;\n }\n\n if (a > 0) {\n //よくある切り上げのテクニック\n return (a+b-1)/b;\n } else {\n //絶対値の小さい方に丸められる(負なら正の方向)\n return a/b;\n }\n }\n\n public long lcm(long a, long b) {\n return a * b / gcd(a, b);\n }\n\n public long gcd(long a, long b) {\n long M = Math.max(a, b);\n long m = Math.min(a, b);\n\n if (m == 0) {\n return M;\n }\n\n return gcd(m, M%m);\n }\n\n public static class Mathf {\n\n public static int max(int[] a) {\n int M = a[0];\n for (int i = 1; i < a.length; i++) {\n M = Math.max(M, a[i]);\n }\n return M;\n }\n\n public static int min(int[] a) {\n int m = a[0];\n for (int i = 1; i < a.length; i++) {\n m = Math.min(m, a[i]);\n }\n return m;\n }\n\n public static long max(long[] a) {\n long M = a[0];\n for (int i = 1; i < a.length; i++) {\n M = Math.max(M, a[i]);\n }\n return M;\n }\n\n public static long min(long[] a) {\n long m = a[0];\n for (int i = 1; i < a.length; i++) {\n m = Math.min(m, a[i]);\n }\n return m;\n }\n\n }\n\n /*\n add()でインデックスを指定しない場合指定されたソート順に違わない位置に追加する\n (ただしソートされていることが前提となる)\n Comparatorが0を返したとき、それらの順序は保証しない\n (TreeSet, TreeMapと違い削除はしない)\n */\n static class TreeList extends ArrayList {\n\n Comparator comparator;\n\n TreeList(Comparator c) {\n super();\n comparator = c;\n }\n\n /*\n ソート済みのリストに要素を追加する\n */\n public boolean add(E e) {\n int lowIndex = 0;\n int highIndex = size() - 1;\n int index = 0;\n\n if (size() == 0) {\n super.add(e);\n return true;\n }\n\n if (comparator.compare(e, get(0)) < 0) {\n index = 0;\n } else if (comparator.compare(e, get(highIndex)) > 0) {\n index = highIndex + 1;\n } else {\n while (lowIndex <= highIndex) {\n\n if (highIndex == lowIndex + 1 || highIndex == lowIndex) {\n index = highIndex;\n break;\n }\n\n int midIndex = (lowIndex + highIndex) / 2;\n ;\n\n if (comparator.compare(e, get(midIndex)) > 0) {\n lowIndex = midIndex;\n } else {\n highIndex = midIndex;\n }\n\n }\n }\n\n super.add(index, e);\n return true;\n }\n\n }\n\n static class FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) return buffer[ptr++];\n else return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n private void skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n }\n\n public boolean hasNext() {\n skipUnprintable();\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n return (int) nextLong();\n }\n\n public int[] nextIntArray(int N, boolean oneBased) {\n if (oneBased) {\n int[] array = new int[N + 1];\n for (int i = 1; i <= N; i++) {\n array[i] = sc.nextInt();\n }\n return array;\n } else {\n int[] array = new int[N];\n for (int i = 0; i < N; i++) {\n array[i] = sc.nextInt();\n }\n return array;\n }\n }\n\n public long[] nextLongArray(int N, boolean oneBased) {\n if (oneBased) {\n long[] array = new long[N + 1];\n for (int i = 1; i <= N; i++) {\n array[i] = sc.nextLong();\n }\n return array;\n } else {\n long[] array = new long[N];\n for (int i = 0; i < N; i++) {\n array[i] = sc.nextLong();\n }\n return array;\n }\n }\n }\n\n}\n", "language": "Java", "metadata": {"date": 1561589507, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02995.html", "problem_id": "p02995", "resource_group": "high_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/Java/s791890232.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s791890232", "user_id": "u951672936"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "/**\n * Created at 00:43 on 2019-06-27\n */\n\nimport java.io.*;\nimport java.util.*;\n\npublic class Main implements Runnable {\n\n static FastScanner sc = new FastScanner();\n\n static int[] dx = {0, 1, 0, -1};\n static int[] dy = {-1, 0, 1, 0};\n\n static long MOD = (long) (1e9 + 7);\n\n public static void main(String[] args) {\n \n new Main().run();\n\n }\n\n public void run() {\n\n long A = sc.nextLong();\n long B = sc.nextLong();\n long C = sc.nextLong();\n long D = sc.nextLong();\n\n long ans = B - A + 1;\n ans -= count_nq_r(A, B, C, 0);\n ans -= count_nq_r(A, B, D, 0);\n ans += count_nq_r(A, B, lcm(C, D), 0);\n\n System.out.println(ans);\n\n }\n\n /*\n * 区間[a, b]の中でqで割ってr余るものの個数\n * r = 0 なら区間[a, b]の中でqの倍数であるものの個数\n * a <= b, 0 <= r < q\n */\n public long count_nq_r(long a, long b, long q, long r) {\n r %= q;\n return (floor(b-r,q)+1) - (floor(a-1-r, q)+1);\n }\n\n /*\n * n <= a/b なる最大の整数nを返す\n */\n public long floor(long a, long b) {\n if (b < 0) {\n a *= -1;\n b *= -1;\n }\n\n if (a > 0) {\n //絶対値の小さい方に丸められる(正なら負の方向)\n return a/b;\n } else {\n //よくある切り上げのテクニックの切り捨て版\n return (a-b+1)/b;\n }\n }\n\n /*\n * n >= a/b なる最小の整数nを返す\n */\n public long ceil(long a, long b) {\n if (b < 0) {\n a *= -1;\n b *= -1;\n }\n\n if (a > 0) {\n //よくある切り上げのテクニック\n return (a+b-1)/b;\n } else {\n //絶対値の小さい方に丸められる(負なら正の方向)\n return a/b;\n }\n }\n\n public long lcm(long a, long b) {\n return a * b / gcd(a, b);\n }\n\n public long gcd(long a, long b) {\n long M = Math.max(a, b);\n long m = Math.min(a, b);\n\n if (m == 0) {\n return M;\n }\n\n return gcd(m, M%m);\n }\n\n public static class Mathf {\n\n public static int max(int[] a) {\n int M = a[0];\n for (int i = 1; i < a.length; i++) {\n M = Math.max(M, a[i]);\n }\n return M;\n }\n\n public static int min(int[] a) {\n int m = a[0];\n for (int i = 1; i < a.length; i++) {\n m = Math.min(m, a[i]);\n }\n return m;\n }\n\n public static long max(long[] a) {\n long M = a[0];\n for (int i = 1; i < a.length; i++) {\n M = Math.max(M, a[i]);\n }\n return M;\n }\n\n public static long min(long[] a) {\n long m = a[0];\n for (int i = 1; i < a.length; i++) {\n m = Math.min(m, a[i]);\n }\n return m;\n }\n\n }\n\n /*\n add()でインデックスを指定しない場合指定されたソート順に違わない位置に追加する\n (ただしソートされていることが前提となる)\n Comparatorが0を返したとき、それらの順序は保証しない\n (TreeSet, TreeMapと違い削除はしない)\n */\n static class TreeList extends ArrayList {\n\n Comparator comparator;\n\n TreeList(Comparator c) {\n super();\n comparator = c;\n }\n\n /*\n ソート済みのリストに要素を追加する\n */\n public boolean add(E e) {\n int lowIndex = 0;\n int highIndex = size() - 1;\n int index = 0;\n\n if (size() == 0) {\n super.add(e);\n return true;\n }\n\n if (comparator.compare(e, get(0)) < 0) {\n index = 0;\n } else if (comparator.compare(e, get(highIndex)) > 0) {\n index = highIndex + 1;\n } else {\n while (lowIndex <= highIndex) {\n\n if (highIndex == lowIndex + 1 || highIndex == lowIndex) {\n index = highIndex;\n break;\n }\n\n int midIndex = (lowIndex + highIndex) / 2;\n ;\n\n if (comparator.compare(e, get(midIndex)) > 0) {\n lowIndex = midIndex;\n } else {\n highIndex = midIndex;\n }\n\n }\n }\n\n super.add(index, e);\n return true;\n }\n\n }\n\n static class FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) return buffer[ptr++];\n else return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n private void skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n }\n\n public boolean hasNext() {\n skipUnprintable();\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n return (int) nextLong();\n }\n\n public int[] nextIntArray(int N, boolean oneBased) {\n if (oneBased) {\n int[] array = new int[N + 1];\n for (int i = 1; i <= N; i++) {\n array[i] = sc.nextInt();\n }\n return array;\n } else {\n int[] array = new int[N];\n for (int i = 0; i < N; i++) {\n array[i] = sc.nextInt();\n }\n return array;\n }\n }\n\n public long[] nextLongArray(int N, boolean oneBased) {\n if (oneBased) {\n long[] array = new long[N + 1];\n for (int i = 1; i <= N; i++) {\n array[i] = sc.nextLong();\n }\n return array;\n } else {\n long[] array = new long[N];\n for (int i = 0; i < N; i++) {\n array[i] = sc.nextLong();\n }\n return array;\n }\n }\n }\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": 6703, "cpu_time_ms": 71, "memory_kb": 22484}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s599801002", "group_id": "codeNet:p02995", "input_text": "\n\nimport java.util.Scanner;\npublic class Main {\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tlong a = sc.nextLong();\n\t\tlong b = sc.nextLong();\n\t\tlong c = sc.nextLong();\n\t\tlong d = sc.nextLong();\n\t\tlong dif = b-a;\n\t\tlong ans = dif - dif/c - dif/d + dif/lcm(c,d);\n\t\tif(a%c == 0 || a%d == 0) {\n\t\t\tif(b%c == 0 || b%d == 0) {\n\t\t\t\tans --;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t\tsc.close();\n\t}\n\tprivate static long lcm(long m, long n) {\n\t return m * n / gcd(m, n);\n\t}\n\tprivate static long gcd(long m, long n) {\n\t if(m < n) return gcd(n, m);\n\t if(n == 0) return m;\n\t return gcd(n, m % n);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1561231615, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02995.html", "problem_id": "p02995", "resource_group": "high_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/Java/s599801002.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s599801002", "user_id": "u992134985"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\n\nimport java.util.Scanner;\npublic class Main {\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tlong a = sc.nextLong();\n\t\tlong b = sc.nextLong();\n\t\tlong c = sc.nextLong();\n\t\tlong d = sc.nextLong();\n\t\tlong dif = b-a;\n\t\tlong ans = dif - dif/c - dif/d + dif/lcm(c,d);\n\t\tif(a%c == 0 || a%d == 0) {\n\t\t\tif(b%c == 0 || b%d == 0) {\n\t\t\t\tans --;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t\tsc.close();\n\t}\n\tprivate static long lcm(long m, long n) {\n\t return m * n / gcd(m, n);\n\t}\n\tprivate static long gcd(long m, long n) {\n\t if(m < n) return gcd(n, m);\n\t if(n == 0) return m;\n\t return gcd(n, m % n);\n\t}\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": 652, "cpu_time_ms": 96, "memory_kb": 23764}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s632698523", "group_id": "codeNet:p02999", "input_text": "import java.util.*;\n\nclass Main {\n\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n\n int x = sc.nextInt();\n int a = sc.nextInt();\n if (x < a) System.out.println(\"0\");\n else System.out.println(\"10\");\n }\n\n}\n", "language": "Java", "metadata": {"date": 1560770408, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p02999.html", "problem_id": "p02999", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02999/input.txt", "sample_output_relpath": "derived/input_output/data/p02999/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02999/Java/s632698523.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s632698523", "user_id": "u533482278"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "import java.util.*;\n\nclass Main {\n\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n\n int x = sc.nextInt();\n int a = sc.nextInt();\n if (x < a) System.out.println(\"0\");\n else System.out.println(\"10\");\n }\n\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nX and A are integers between 0 and 9 (inclusive).\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nConstraints\n\n0 \\leq X, A \\leq 9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX A\n\nOutput\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\n3 is less than 5, so we should print 0.\n\nSample Input 2\n\n7 5\n\nSample Output 2\n\n10\n\n7 is not less than 5, so we should print 10.\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n10\n\n6 is not less than 6, so we should print 10.", "sample_input": "3 5\n"}, "reference_outputs": ["0\n"], "source_document_id": "p02999", "source_text": "Score : 100 points\n\nProblem Statement\n\nX and A are integers between 0 and 9 (inclusive).\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nConstraints\n\n0 \\leq X, A \\leq 9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX A\n\nOutput\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\n3 is less than 5, so we should print 0.\n\nSample Input 2\n\n7 5\n\nSample Output 2\n\n10\n\n7 is not less than 5, so we should print 10.\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n10\n\n6 is not less than 6, so we should print 10.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 254, "cpu_time_ms": 94, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s724554472", "group_id": "codeNet:p03000", "input_text": "import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n \t\n\t\tScanner sc = new Scanner(System.in);\n\t\t// 整数の入力\n\t\tint N = sc.nextInt();\n\t\tint X = sc.nextInt();\n\n\t\tint intArray[] = new int[N];\n\t\tfor (int i = 0; i < N;i ++ ){\n\t\t\tintArray[i] = sc.nextInt();\n\t\t}\n\n\t\tint sum = 0;\n\t\tint cnt = 0;\n\t\tif(sum < X){\n\t\t\tcnt ++;\n\t\t}else{\n\t\t\tSystem.out.println(cnt);\n\t \t\tsc.close();\n\t return ;\n\t\t}\n\n\t\tfor (int i = 0; i < N;i ++ ){\n\t\t\tsum = sum + intArray[i];\n\t\t\tif(sum <= X){\n\t\t\t\tcnt ++;\n\t\t\t}else{\n\t\t\t\tbreak ;\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(cnt);\n\n \t\tsc.close();\n return ;\n\n }\n \n}\n\n", "language": "Java", "metadata": {"date": 1560712403, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03000.html", "problem_id": "p03000", "resource_group": "high_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/Java/s724554472.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s724554472", "user_id": "u991076420"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n \t\n\t\tScanner sc = new Scanner(System.in);\n\t\t// 整数の入力\n\t\tint N = sc.nextInt();\n\t\tint X = sc.nextInt();\n\n\t\tint intArray[] = new int[N];\n\t\tfor (int i = 0; i < N;i ++ ){\n\t\t\tintArray[i] = sc.nextInt();\n\t\t}\n\n\t\tint sum = 0;\n\t\tint cnt = 0;\n\t\tif(sum < X){\n\t\t\tcnt ++;\n\t\t}else{\n\t\t\tSystem.out.println(cnt);\n\t \t\tsc.close();\n\t return ;\n\t\t}\n\n\t\tfor (int i = 0; i < N;i ++ ){\n\t\t\tsum = sum + intArray[i];\n\t\t\tif(sum <= X){\n\t\t\t\tcnt ++;\n\t\t\t}else{\n\t\t\t\tbreak ;\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(cnt);\n\n \t\tsc.close();\n return ;\n\n }\n \n}\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": 740, "cpu_time_ms": 108, "memory_kb": 23252}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s324405322", "group_id": "codeNet:p03001", "input_text": "import java.util.*;\npublic class Main{\n\tpublic static void main(String arg[]){\n\t\tScanner sc=new Scanner(System.in);\n\t\tint a=sc.nextInt();\n\t\tint b=sc.nextInt();\n\t\tint c=sc.nextInt();\n\t\tint d=sc.nextInt();\n\t\tdouble e=(double)(a*b)/2;\n\t\tif(a!=b){\n\t\t\tSystem.out.printf(\"%.6f \",e);\n\t\t System.out.println(\"0\");\n\t\t}\n\t\telse{\n\t\t\tSystem.out.printf(\"%.6f\",e);\n\t System.out.println(\"1\");\n\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1574999572, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03001.html", "problem_id": "p03001", "resource_group": "high_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/Java/s324405322.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s324405322", "user_id": "u379464460"}, "prompt_components": {"gold_output": "3.000000 0\n", "input_to_evaluate": "import java.util.*;\npublic class Main{\n\tpublic static void main(String arg[]){\n\t\tScanner sc=new Scanner(System.in);\n\t\tint a=sc.nextInt();\n\t\tint b=sc.nextInt();\n\t\tint c=sc.nextInt();\n\t\tint d=sc.nextInt();\n\t\tdouble e=(double)(a*b)/2;\n\t\tif(a!=b){\n\t\t\tSystem.out.printf(\"%.6f \",e);\n\t\t System.out.println(\"0\");\n\t\t}\n\t\telse{\n\t\t\tSystem.out.printf(\"%.6f\",e);\n\t System.out.println(\"1\");\n\t}\n\t}\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": 388, "cpu_time_ms": 146, "memory_kb": 24148}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s791735088", "group_id": "codeNet:p03001", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\t//Input\n\t\tScanner sc = new Scanner(System.in);\n\t\tint W = Integer.parseInt(sc.next());\n\t\tint H = Integer.parseInt(sc.next());\n\t\tint x = Integer.parseInt(sc.next());\n\t\tint y = Integer.parseInt(sc.next());\n\t\tsc.close();\n\n\t\t//logic\n\t\tdouble cx = W/2;\n\t\tdouble cy = H/2;\n\n\t\tint count = 1;\n\n\t\tif(cx - x == 0 || cy - y == 0) {\n\t\t\tcount = 0;\n\t\t}\n\n\t\tif(cx - x == 0 && cy - y == 0) {\n\t\t\tcount = 1;\n\t\t}\n\n\t\tdouble answer = (W * H) / 2;\n\n\t\tSystem.out.println(answer + \" \" + count);\n\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1560716858, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03001.html", "problem_id": "p03001", "resource_group": "high_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/Java/s791735088.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s791735088", "user_id": "u850997975"}, "prompt_components": {"gold_output": "3.000000 0\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\t//Input\n\t\tScanner sc = new Scanner(System.in);\n\t\tint W = Integer.parseInt(sc.next());\n\t\tint H = Integer.parseInt(sc.next());\n\t\tint x = Integer.parseInt(sc.next());\n\t\tint y = Integer.parseInt(sc.next());\n\t\tsc.close();\n\n\t\t//logic\n\t\tdouble cx = W/2;\n\t\tdouble cy = H/2;\n\n\t\tint count = 1;\n\n\t\tif(cx - x == 0 || cy - y == 0) {\n\t\t\tcount = 0;\n\t\t}\n\n\t\tif(cx - x == 0 && cy - y == 0) {\n\t\t\tcount = 1;\n\t\t}\n\n\t\tdouble answer = (W * H) / 2;\n\n\t\tSystem.out.println(answer + \" \" + count);\n\n\t}\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": 624, "cpu_time_ms": 94, "memory_kb": 23124}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s569912025", "group_id": "codeNet:p03001", "input_text": "import java.math.BigDecimal;\nimport java.util.Scanner;\n\npublic class Main {\n\n\n\tpublic static void main(String[] args) {\n\t\t(new Main()).execute();\n\t}\n\tpublic void execute() { ;\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\tScanner sc = new Scanner(System.in);\n\t\t// 整数の入力\n\t\tBigDecimal W = new BigDecimal(sc.next()) ;\n\t\tBigDecimal H = new BigDecimal(sc.next()) ;\n\t\tBigDecimal x = new BigDecimal(sc.next()) ;\n\t\tBigDecimal y = new BigDecimal(sc.next()) ;\n\n\t\tBigDecimal s = W.multiply(H).divide(new BigDecimal(\"2\"));\n\n\t\tSystem.out.print(s + \" \");\n\t\tBigDecimal wd = W.divide(new BigDecimal(\"2\")) ;\n\t\tBigDecimal hd = H.divide(new BigDecimal(\"2\")) ;\n\t\tif(\tx.equals(wd) &&y.equals(hd) ){\n\t\t\tSystem.out.println(1);\n\t\t}else {\n\t\t\tSystem.out.println(0);\n\t\t}\n\t}\n}\n", "language": "Java", "metadata": {"date": 1560715433, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03001.html", "problem_id": "p03001", "resource_group": "high_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/Java/s569912025.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s569912025", "user_id": "u998334406"}, "prompt_components": {"gold_output": "3.000000 0\n", "input_to_evaluate": "import java.math.BigDecimal;\nimport java.util.Scanner;\n\npublic class Main {\n\n\n\tpublic static void main(String[] args) {\n\t\t(new Main()).execute();\n\t}\n\tpublic void execute() { ;\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\tScanner sc = new Scanner(System.in);\n\t\t// 整数の入力\n\t\tBigDecimal W = new BigDecimal(sc.next()) ;\n\t\tBigDecimal H = new BigDecimal(sc.next()) ;\n\t\tBigDecimal x = new BigDecimal(sc.next()) ;\n\t\tBigDecimal y = new BigDecimal(sc.next()) ;\n\n\t\tBigDecimal s = W.multiply(H).divide(new BigDecimal(\"2\"));\n\n\t\tSystem.out.print(s + \" \");\n\t\tBigDecimal wd = W.divide(new BigDecimal(\"2\")) ;\n\t\tBigDecimal hd = H.divide(new BigDecimal(\"2\")) ;\n\t\tif(\tx.equals(wd) &&y.equals(hd) ){\n\t\t\tSystem.out.println(1);\n\t\t}else {\n\t\t\tSystem.out.println(0);\n\t\t}\n\t}\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": 771, "cpu_time_ms": 97, "memory_kb": 23764}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s076346369", "group_id": "codeNet:p03001", "input_text": "import java.util.*;\n\npublic class Main{\n\n public static void main(String args[]){\n\n // スキャナーの宣言\n Scanner sc = new Scanner(System.in);\n // 整数の入力\n\t\tint w = sc.nextInt();\n // スペース区切りの整数の入力\n int h = sc.nextInt();\n int x = sc.nextInt();\n int y = sc.nextInt();\n\n double ans;\n double a = 0.0, b = 0.0;\n int c = 0;\n\n if((x == 0 || x == w) && (y == 0 || y == h)){\n a = w * h / 2.0; b = w * h / 2.0;\n c = 1;\n }else if(x == 0 || x == w){\n a = Math.min(x * h, (w - x) * h); b = Math.min(w * y, w * (h - y)); //a0\n c = 0;\n }else if(y == 0 || y == h){\n a = Math.min(x * h, (w - x) * h); Math.min(w * y, w * (h - y)); //b0\n c = 0;\n }else{\n a = Math.min(x * h, (w - x) * h); b = Math.min(w * y, w * (h - y));\n if(a == b) c = 1;\n }\n ans = Math.max(a, b);\n\n // 出力\n System.out.println(String.format(\"%.9f\", ans) + \" \" + c);\n\n }\n\n}\n", "language": "Java", "metadata": {"date": 1560715015, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03001.html", "problem_id": "p03001", "resource_group": "high_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/Java/s076346369.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s076346369", "user_id": "u521293705"}, "prompt_components": {"gold_output": "3.000000 0\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main{\n\n public static void main(String args[]){\n\n // スキャナーの宣言\n Scanner sc = new Scanner(System.in);\n // 整数の入力\n\t\tint w = sc.nextInt();\n // スペース区切りの整数の入力\n int h = sc.nextInt();\n int x = sc.nextInt();\n int y = sc.nextInt();\n\n double ans;\n double a = 0.0, b = 0.0;\n int c = 0;\n\n if((x == 0 || x == w) && (y == 0 || y == h)){\n a = w * h / 2.0; b = w * h / 2.0;\n c = 1;\n }else if(x == 0 || x == w){\n a = Math.min(x * h, (w - x) * h); b = Math.min(w * y, w * (h - y)); //a0\n c = 0;\n }else if(y == 0 || y == h){\n a = Math.min(x * h, (w - x) * h); Math.min(w * y, w * (h - y)); //b0\n c = 0;\n }else{\n a = Math.min(x * h, (w - x) * h); b = Math.min(w * y, w * (h - y));\n if(a == b) c = 1;\n }\n ans = Math.max(a, b);\n\n // 出力\n System.out.println(String.format(\"%.9f\", ans) + \" \" + c);\n\n }\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": 1088, "cpu_time_ms": 99, "memory_kb": 20820}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s522820468", "group_id": "codeNet:p03003", "input_text": "import java.util.*;\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint numS = sc.nextInt();\n\t\tint numT = sc.nextInt();\n\t\tlong s[] = new long[numS];\n\t\tfor(int i = 0; i < numS; i ++) {\n\t\t\ts[i] = sc.nextLong();\n\t\t}\n\t\tlong t[] = new long[numT];\n\t\tfor(int i = 0; i < numT; i ++) {\n\t\t\tt[i] = sc.nextLong();\n\t\t}\n\t\tlong dp[][] = new long[numS + 1][numT + 1];\n\t\tlong dpSum[][] = new long[numS + 1][numT + 1];\n\t\tfor(int i = 0; i <= numS; i ++) {\n\t\t\tdp[i][0] = 0;\n\t\t\tdpSum[i][0] = 1;\n\t\t}\n\t\tfor(int i = 0; i <= numT; i ++) {\n\t\t\tdp[0][i] = 0;\n\t\t\tdpSum[0][i] = 1;\n\t\t}\n\t\tdp[0][0] = 1;\n\n\t\tfor(int i = 1; i <= numS; i ++) {\n\t\t\tfor(int j = 1; j <= numT; j ++) {\n\t\t\t\tdpSum[i][j] = mod(dpSum[i - 1][j] + dpSum[i][j - 1] - dpSum[i - 1][j - 1]);\n\t\t\t\tif(s[i - 1] != t[j - 1]) { dp[i][j] = 0; continue; }\n\t\t\t\tdp[i][j] = dpSum[i - 1][j - 1];\n\t\t\t\tdpSum[i][j] = mod(dpSum[i][j] + dp[i][j]);\n\t\t\t}\n\t\t}\n\n\t\tlong ans = 0;\n\t\tfor(int i = 0; i <= numS; i ++) {\n\t\t\tfor(int j = 0; j <= numT; j ++) {\n\t\t\t\tans = mod(ans + dp[i][j]);\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(mod(ans));\n\t}\n\n\tstatic long MOD = (long)Math.pow(10, 9) + 7;\n\tpublic static long mod(long i) {\n\t\treturn i % MOD + ((i % MOD) < 0 ? MOD : 0);\n\t}\n\t\n\tstatic long powerMod(long x, long y) {\n\t\tif (y == 0) {\n\t\t\treturn 1;\n\t\t} else if (y == 1) {\n\t\t\treturn x;\n\t\t} else if (y % 2 == 0) {\n\t\t\tlong tmp = powerMod(x, y / 2);\n\t\t\treturn mod(tmp * tmp);\n\t\t} else {\n\t\t\tlong tmp = powerMod(x, y / 2);\n\t\t\treturn mod(mod(tmp * tmp) * x);\n\t\t}\n\t}\n\t\n\tstatic long invMod(long x) {\n\t\treturn powerMod(x, MOD - 2);\n\t}\n\t\n\tstatic int MAX_FACT = 200_100;\n\tstatic long factMod[] = new long[MAX_FACT];\n\tstatic void prepareFact() {\n\t\tfactMod[0] = 1;\n\t\tfor(int i = 1; i < MAX_FACT; i ++) {\n\t\t\tfactMod[i] = mod(factMod[i - 1] * i);\n\t\t}\n\t}\n\t\n\tstatic long combiMod(int n, int r) {\n\t\tif(n < 0 || n < r) { return 0; }\n\t\tif(r == 0 || r == n) { return 1; }\n\t\treturn mod(mod(factMod[n] * invMod(factMod[r])) * invMod(factMod[n - r]));\n\t}\n}", "language": "Java", "metadata": {"date": 1560736526, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03003.html", "problem_id": "p03003", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03003/input.txt", "sample_output_relpath": "derived/input_output/data/p03003/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03003/Java/s522820468.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s522820468", "user_id": "u137087473"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*;\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint numS = sc.nextInt();\n\t\tint numT = sc.nextInt();\n\t\tlong s[] = new long[numS];\n\t\tfor(int i = 0; i < numS; i ++) {\n\t\t\ts[i] = sc.nextLong();\n\t\t}\n\t\tlong t[] = new long[numT];\n\t\tfor(int i = 0; i < numT; i ++) {\n\t\t\tt[i] = sc.nextLong();\n\t\t}\n\t\tlong dp[][] = new long[numS + 1][numT + 1];\n\t\tlong dpSum[][] = new long[numS + 1][numT + 1];\n\t\tfor(int i = 0; i <= numS; i ++) {\n\t\t\tdp[i][0] = 0;\n\t\t\tdpSum[i][0] = 1;\n\t\t}\n\t\tfor(int i = 0; i <= numT; i ++) {\n\t\t\tdp[0][i] = 0;\n\t\t\tdpSum[0][i] = 1;\n\t\t}\n\t\tdp[0][0] = 1;\n\n\t\tfor(int i = 1; i <= numS; i ++) {\n\t\t\tfor(int j = 1; j <= numT; j ++) {\n\t\t\t\tdpSum[i][j] = mod(dpSum[i - 1][j] + dpSum[i][j - 1] - dpSum[i - 1][j - 1]);\n\t\t\t\tif(s[i - 1] != t[j - 1]) { dp[i][j] = 0; continue; }\n\t\t\t\tdp[i][j] = dpSum[i - 1][j - 1];\n\t\t\t\tdpSum[i][j] = mod(dpSum[i][j] + dp[i][j]);\n\t\t\t}\n\t\t}\n\n\t\tlong ans = 0;\n\t\tfor(int i = 0; i <= numS; i ++) {\n\t\t\tfor(int j = 0; j <= numT; j ++) {\n\t\t\t\tans = mod(ans + dp[i][j]);\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(mod(ans));\n\t}\n\n\tstatic long MOD = (long)Math.pow(10, 9) + 7;\n\tpublic static long mod(long i) {\n\t\treturn i % MOD + ((i % MOD) < 0 ? MOD : 0);\n\t}\n\t\n\tstatic long powerMod(long x, long y) {\n\t\tif (y == 0) {\n\t\t\treturn 1;\n\t\t} else if (y == 1) {\n\t\t\treturn x;\n\t\t} else if (y % 2 == 0) {\n\t\t\tlong tmp = powerMod(x, y / 2);\n\t\t\treturn mod(tmp * tmp);\n\t\t} else {\n\t\t\tlong tmp = powerMod(x, y / 2);\n\t\t\treturn mod(mod(tmp * tmp) * x);\n\t\t}\n\t}\n\t\n\tstatic long invMod(long x) {\n\t\treturn powerMod(x, MOD - 2);\n\t}\n\t\n\tstatic int MAX_FACT = 200_100;\n\tstatic long factMod[] = new long[MAX_FACT];\n\tstatic void prepareFact() {\n\t\tfactMod[0] = 1;\n\t\tfor(int i = 1; i < MAX_FACT; i ++) {\n\t\t\tfactMod[i] = mod(factMod[i - 1] * i);\n\t\t}\n\t}\n\t\n\tstatic long combiMod(int n, int r) {\n\t\tif(n < 0 || n < r) { return 0; }\n\t\tif(r == 0 || r == n) { return 1; }\n\t\treturn mod(mod(factMod[n] * invMod(factMod[r])) * invMod(factMod[n - r]));\n\t}\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive).\n\nIn how many pairs of a subsequence of S and a subsequence of T do the two subsequences are the same in content?\n\nHere the subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order.\n\nFor both S and T, we distinguish two subsequences if the sets of the indices of the removed elements are different, even if the subsequences are the same in content.\n\nSince the answer can be tremendous, print the number modulo 10^9+7.\n\nConstraints\n\n1 \\leq N, M \\leq 2 \\times 10^3\n\nThe length of S is N.\n\nThe length of T is M.\n\n1 \\leq S_i, T_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS_1 S_2 ... S_{N-1} S_{N}\nT_1 T_2 ... T_{M-1} T_{M}\n\nOutput\n\nPrint the number of pairs of a subsequence of S and a subsequence of T such that the subsequences are the same in content, modulo 10^9+7.\n\nSample Input 1\n\n2 2\n1 3\n3 1\n\nSample Output 1\n\n3\n\nS has four subsequences: (), (1), (3), (1, 3).\n\nT has four subsequences: (), (3), (1), (3, 1).\n\nThere are 1 \\times 1 pair of subsequences in which the subsequences are both (), 1 \\times 1 pair of subsequences in which the subsequences are both (1), and 1 \\times 1 pair of subsequences in which the subsequences are both (3), for a total of three pairs.\n\nSample Input 2\n\n2 2\n1 1\n1 1\n\nSample Output 2\n\n6\n\nS has four subsequences: (), (1), (1), (1, 1).\n\nT has four subsequences: (), (1), (1), (1, 1).\n\nThere are 1 \\times 1 pair of subsequences in which the subsequences are both (), 2 \\times 2 pairs of subsequences in which the subsequences are both (1), and 1 \\times 1 pair of subsequences in which the subsequences are both (1,1), for a total of six pairs.\nNote again that we distinguish two subsequences if the sets of the indices of the removed elements are different, even if the subsequences are the same in content.\n\nSample Input 3\n\n4 4\n3 4 5 6\n3 4 5 6\n\nSample Output 3\n\n16\n\nSample Input 4\n\n10 9\n9 6 5 7 5 9 8 5 6 7\n8 6 8 5 5 7 9 9 7\n\nSample Output 4\n\n191\n\nSample Input 5\n\n20 20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n\nSample Output 5\n\n846527861\n\nBe sure to print the number modulo 10^9+7.", "sample_input": "2 2\n1 3\n3 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03003", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive).\n\nIn how many pairs of a subsequence of S and a subsequence of T do the two subsequences are the same in content?\n\nHere the subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order.\n\nFor both S and T, we distinguish two subsequences if the sets of the indices of the removed elements are different, even if the subsequences are the same in content.\n\nSince the answer can be tremendous, print the number modulo 10^9+7.\n\nConstraints\n\n1 \\leq N, M \\leq 2 \\times 10^3\n\nThe length of S is N.\n\nThe length of T is M.\n\n1 \\leq S_i, T_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS_1 S_2 ... S_{N-1} S_{N}\nT_1 T_2 ... T_{M-1} T_{M}\n\nOutput\n\nPrint the number of pairs of a subsequence of S and a subsequence of T such that the subsequences are the same in content, modulo 10^9+7.\n\nSample Input 1\n\n2 2\n1 3\n3 1\n\nSample Output 1\n\n3\n\nS has four subsequences: (), (1), (3), (1, 3).\n\nT has four subsequences: (), (3), (1), (3, 1).\n\nThere are 1 \\times 1 pair of subsequences in which the subsequences are both (), 1 \\times 1 pair of subsequences in which the subsequences are both (1), and 1 \\times 1 pair of subsequences in which the subsequences are both (3), for a total of three pairs.\n\nSample Input 2\n\n2 2\n1 1\n1 1\n\nSample Output 2\n\n6\n\nS has four subsequences: (), (1), (1), (1, 1).\n\nT has four subsequences: (), (1), (1), (1, 1).\n\nThere are 1 \\times 1 pair of subsequences in which the subsequences are both (), 2 \\times 2 pairs of subsequences in which the subsequences are both (1), and 1 \\times 1 pair of subsequences in which the subsequences are both (1,1), for a total of six pairs.\nNote again that we distinguish two subsequences if the sets of the indices of the removed elements are different, even if the subsequences are the same in content.\n\nSample Input 3\n\n4 4\n3 4 5 6\n3 4 5 6\n\nSample Output 3\n\n16\n\nSample Input 4\n\n10 9\n9 6 5 7 5 9 8 5 6 7\n8 6 8 5 5 7 9 9 7\n\nSample Output 4\n\n191\n\nSample Input 5\n\n20 20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n\nSample Output 5\n\n846527861\n\nBe sure to print the number modulo 10^9+7.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1978, "cpu_time_ms": 426, "memory_kb": 130584}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s360601531", "group_id": "codeNet:p03006", "input_text": "/*Author: Satyajeet Singh, Delhi Technological University*/\n import java.io.*;\n import java.util.*;\n import java.text.*; \n import java.lang.*;\n import java.math.*;\n\npublic class Main{\n/*********************************************Constants******************************************/\n static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out)); \n static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n static long mod=(long)1e9+7;\n static long mod1=998244353;\n static boolean sieve[];\n static ArrayList primes;\n static ArrayList factorial;\n static HashSet graph[];\n/****************************************Solutions Begins***************************************/\n public static void main (String[] args) throws Exception {\n String st[]=br.readLine().split(\" \");\n int n=Integer.parseInt(st[0]);\n Pair input[]=new Pair[n];\n HashMap map=new HashMap<>();\n\n for(int i=0;i();\n }\n }\n static void addEdge(int a,int b,int c){\n graph[a].add(new Pair(b,c));\n } \n/*********************************************PAIR********************************************************/\n static class PairComp implements Comparator{\n public int compare(Pair p1,Pair p2){\n if(p1.u!=p2.u){\n return p1.u-p2.u;\n }\n else{\n return p2.v-p1.v;\n }\n }\n }\n static class Pair implements Comparable {\n int u;\n int v;\n int index=-1;\n public Pair(int u, int v) {\n this.u = u;\n this.v = v;\n }\n \n public int hashCode() {\n int hu = (int) (u ^ (u >>> 32));\n int hv = (int) (v ^ (v >>> 32));\n return 31 * hu + hv;\n }\n \n public boolean equals(Object o) {\n Pair other = (Pair) o;\n return u == other.u && v == other.v;\n }\n \n public int compareTo(Pair other) {\n if(index!=other.index)\n return Long.compare(index, other.index);\n return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);\n }\n \n public String toString() {\n return \"[u=\" + u + \", v=\" + v + \"]\";\n }\n }\n/******************************************Long Pair*************************************************/\n static class PairCompL implements Comparator{\n public int compare(Pairl p1,Pairl p2){\n long aa=p2.u-p1.u;\n if(aa<0){\n return -1;\n }\n else if(aa>0){\n return 1;\n }\n else{\n return 0;\n }\n }\n }\n static class Pairl implements Comparable {\n long u;\n long v;\n int index=-1;\n public Pairl(long u, long v) {\n this.u = u;\n this.v = v;\n }\n \n public int hashCode() {\n int hu = (int) (u ^ (u >>> 32));\n int hv = (int) (v ^ (v >>> 32));\n return 31 * hu + hv;\n }\n \n public boolean equals(Object o) {\n Pair other = (Pair) o;\n return u == other.u && v == other.v;\n }\n \n public int compareTo(Pair other) {\n if(index!=other.index)\n return Long.compare(index, other.index);\n return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);\n }\n \n public String toString() {\n return \"[u=\" + u + \", v=\" + v + \"]\";\n }\n }\n/*****************************************DEBUG***********************************************************/\n public static void debug(Object... o) {\n System.out.println(Arrays.deepToString(o));\n }\n/************************************MODULAR EXPONENTIATION***********************************************/\n static long modulo(long a,long b,long c) {\n long x=1;\n long y=a;\n while(b > 0){\n if(b%2 == 1){\n x=(x*y)%c;\n }\n y = (y*y)%c; // squaring the base\n b /= 2;\n }\n return x%c;\n }\n/********************************************GCD**********************************************************/\n static long gcd(long x, long y)\n {\n if(x==0)\n return y;\n if(y==0)\n return x;\n long r=0, a, b;\n a = (x > y) ? x : y; // a is greater number\n b = (x < y) ? x : y; // b is smaller number\n r = b;\n while(a % b != 0)\n {\n r = a % b;\n a = b;\n b = r;\n }\n return r;\n }\n/******************************************SIEVE**********************************************************/\n static void sieveMake(int n){\n sieve=new boolean[n];\n Arrays.fill(sieve,true);\n sieve[0]=false;\n sieve[1]=false;\n for(int i=2;i*i();\n for(int i=0;i primes;\n static ArrayList factorial;\n static HashSet graph[];\n/****************************************Solutions Begins***************************************/\n public static void main (String[] args) throws Exception {\n String st[]=br.readLine().split(\" \");\n int n=Integer.parseInt(st[0]);\n Pair input[]=new Pair[n];\n HashMap map=new HashMap<>();\n\n for(int i=0;i();\n }\n }\n static void addEdge(int a,int b,int c){\n graph[a].add(new Pair(b,c));\n } \n/*********************************************PAIR********************************************************/\n static class PairComp implements Comparator{\n public int compare(Pair p1,Pair p2){\n if(p1.u!=p2.u){\n return p1.u-p2.u;\n }\n else{\n return p2.v-p1.v;\n }\n }\n }\n static class Pair implements Comparable {\n int u;\n int v;\n int index=-1;\n public Pair(int u, int v) {\n this.u = u;\n this.v = v;\n }\n \n public int hashCode() {\n int hu = (int) (u ^ (u >>> 32));\n int hv = (int) (v ^ (v >>> 32));\n return 31 * hu + hv;\n }\n \n public boolean equals(Object o) {\n Pair other = (Pair) o;\n return u == other.u && v == other.v;\n }\n \n public int compareTo(Pair other) {\n if(index!=other.index)\n return Long.compare(index, other.index);\n return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);\n }\n \n public String toString() {\n return \"[u=\" + u + \", v=\" + v + \"]\";\n }\n }\n/******************************************Long Pair*************************************************/\n static class PairCompL implements Comparator{\n public int compare(Pairl p1,Pairl p2){\n long aa=p2.u-p1.u;\n if(aa<0){\n return -1;\n }\n else if(aa>0){\n return 1;\n }\n else{\n return 0;\n }\n }\n }\n static class Pairl implements Comparable {\n long u;\n long v;\n int index=-1;\n public Pairl(long u, long v) {\n this.u = u;\n this.v = v;\n }\n \n public int hashCode() {\n int hu = (int) (u ^ (u >>> 32));\n int hv = (int) (v ^ (v >>> 32));\n return 31 * hu + hv;\n }\n \n public boolean equals(Object o) {\n Pair other = (Pair) o;\n return u == other.u && v == other.v;\n }\n \n public int compareTo(Pair other) {\n if(index!=other.index)\n return Long.compare(index, other.index);\n return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);\n }\n \n public String toString() {\n return \"[u=\" + u + \", v=\" + v + \"]\";\n }\n }\n/*****************************************DEBUG***********************************************************/\n public static void debug(Object... o) {\n System.out.println(Arrays.deepToString(o));\n }\n/************************************MODULAR EXPONENTIATION***********************************************/\n static long modulo(long a,long b,long c) {\n long x=1;\n long y=a;\n while(b > 0){\n if(b%2 == 1){\n x=(x*y)%c;\n }\n y = (y*y)%c; // squaring the base\n b /= 2;\n }\n return x%c;\n }\n/********************************************GCD**********************************************************/\n static long gcd(long x, long y)\n {\n if(x==0)\n return y;\n if(y==0)\n return x;\n long r=0, a, b;\n a = (x > y) ? x : y; // a is greater number\n b = (x < y) ? x : y; // b is smaller number\n r = b;\n while(a % b != 0)\n {\n r = a % b;\n a = b;\n b = r;\n }\n return r;\n }\n/******************************************SIEVE**********************************************************/\n static void sieveMake(int n){\n sieve=new boolean[n];\n Arrays.fill(sieve,true);\n sieve[0]=false;\n sieve[1]=false;\n for(int i=2;i*i();\n for(int i=0;i= 0; i--) {\n\t\t\tfor (int j = w - 1; j >= 0; j--) {\n\n\t\t\t\tif (s[i].substring(j, j + 1).equals(\"#\")) {\n\t\t\t\t\tr[i][j] = 0;\n\t\t\t\t\td[i][j] = 0;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (j == w - 1) {\n\t\t\t\t\tr[i][j] = 1;\n\t\t\t\t} else {\n\t\t\t\t\tr[i][j] = r[i][j + 1] + 1;\n\t\t\t\t}\n\n\t\t\t\tif (i == h - 1) {\n\t\t\t\t\td[i][j] = 1;\n\t\t\t\t} else {\n\t\t\t\t\td[i][j] = d[i + 1][j] + 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tint max = 0;\n\t\tfor (int i = 0; i < h; i++) {\n\t\t\tfor (int j = 0; j < w; j++) {\n\t\t\t\tmax = Math.max(max, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(max);\n\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1585624937, "filename_ext": "java", "original_language": "Java7 (OpenJDK 1.7.0)", "problem_description_relpath": "problem_descriptions/p03014.html", "problem_id": "p03014", "resource_group": "high_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/Java/s243385250.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s243385250", "user_id": "u162241493"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "\n\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint h = sc.nextInt();\n\t\tint w = sc.nextInt();\n\t\tString[] s = new String[h];\n\n\t\tfor (int i = 0; i < h; i++) {\n\t\t\ts[i] = sc.next();\n\t\t}\n\n\t\tint[][] l = new int[h][w];\n\t\tint[][] r = new int[h][w];\n\t\tint[][] u = new int[h][w];\n\t\tint[][] d = new int[h][w];\n\n\t\tfor (int i = 0; i < h; i++) {\n\t\t\tfor (int j = 0; j < w; j++) {\n\n\t\t\t\tif (s[i].substring(j, j + 1).equals(\"#\")) {\n\t\t\t\t\tl[i][j] = 0;\n\t\t\t\t\tu[i][j] = 0;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (i == 0) {\n\t\t\t\t\tu[i][j] = 1;\n\t\t\t\t} else {\n\t\t\t\t\tu[i][j] = u[i - 1][j] + 1;\n\t\t\t\t}\n\n\t\t\t\tif (j == 0) {\n\t\t\t\t\tl[i][j] = 1;\n\t\t\t\t} else {\n\t\t\t\t\tl[i][j] = l[i][j - 1] + 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (int i = h - 1; i >= 0; i--) {\n\t\t\tfor (int j = w - 1; j >= 0; j--) {\n\n\t\t\t\tif (s[i].substring(j, j + 1).equals(\"#\")) {\n\t\t\t\t\tr[i][j] = 0;\n\t\t\t\t\td[i][j] = 0;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (j == w - 1) {\n\t\t\t\t\tr[i][j] = 1;\n\t\t\t\t} else {\n\t\t\t\t\tr[i][j] = r[i][j + 1] + 1;\n\t\t\t\t}\n\n\t\t\t\tif (i == h - 1) {\n\t\t\t\t\td[i][j] = 1;\n\t\t\t\t} else {\n\t\t\t\t\td[i][j] = d[i + 1][j] + 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tint max = 0;\n\t\tfor (int i = 0; i < h; i++) {\n\t\t\tfor (int j = 0; j < w; j++) {\n\t\t\t\tmax = Math.max(max, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(max);\n\n\t}\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": 1309, "cpu_time_ms": 668, "memory_kb": 221844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s383997642", "group_id": "codeNet:p03014", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.InputMismatchException;\nimport java.io.IOException;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author KharYusuf\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n FastReader in = new FastReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n DLamp solver = new DLamp();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class DLamp {\n public void solve(int testNumber, FastReader s, PrintWriter w) {\n int n = s.nextInt(), m = s.nextInt(), max = 0, l[][] = new int[n][m], r[][] = new int[n][m], u[][] = new int[n][m], d[][] = new int[n][m];\n char c[][] = new char[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n if ((c[i][j] = s.nextChar()) == '.') {\n if (i == 0) u[i][j] = -1;\n else u[i][j] = u[i - 1][j];\n if (j == 0) l[i][j] = -1;\n else l[i][j] = l[i][j - 1];\n } else {\n u[i][j] = i;\n l[i][j] = j;\n }\n }\n }\n for (int i = n - 1; i >= 0; i--) {\n for (int j = m - 1; j >= 0; j--) {\n if (c[i][j] == '.') {\n if (i == n - 1) d[i][j] = n;\n else d[i][j] = d[i + 1][j];\n if (j == m - 1) r[i][j] = m;\n else r[i][j] = r[i][j + 1];\n max = Math.max(max, r[i][j] - l[i][j] + d[i][j] - u[i][j] - 3);\n } else {\n d[i][j] = i;\n r[i][j] = j;\n }\n }\n }\n w.println(max);\n }\n\n }\n\n static class FastReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private FastReader.SpaceCharFilter filter;\n\n public FastReader(InputStream stream) {\n this.stream = stream;\n }\n\n public int read() {\n\n if (numChars == -1)\n throw new InputMismatchException();\n\n if (curChar >= numChars) {\n\n curChar = 0;\n\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n\n if (numChars <= 0)\n return -1;\n }\n\n return buf[curChar++];\n }\n\n public int nextInt() {\n\n int c = read();\n\n while (isSpaceChar(c))\n c = read();\n\n int sgn = 1;\n\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n\n int res = 0;\n\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n\n res *= 10;\n res += c - '0';\n c = read();\n }\n while (!isSpaceChar(c));\n\n return res * sgn;\n }\n\n public char nextChar() {\n\n int c = read();\n\n while (isSpaceChar(c))\n c = read();\n\n return (char) c;\n }\n\n public boolean isSpaceChar(int c) {\n\n if (filter != null)\n return filter.isSpaceChar(c);\n\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1560203519, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03014.html", "problem_id": "p03014", "resource_group": "high_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/Java/s383997642.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s383997642", "user_id": "u537747009"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.InputMismatchException;\nimport java.io.IOException;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author KharYusuf\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n FastReader in = new FastReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n DLamp solver = new DLamp();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class DLamp {\n public void solve(int testNumber, FastReader s, PrintWriter w) {\n int n = s.nextInt(), m = s.nextInt(), max = 0, l[][] = new int[n][m], r[][] = new int[n][m], u[][] = new int[n][m], d[][] = new int[n][m];\n char c[][] = new char[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n if ((c[i][j] = s.nextChar()) == '.') {\n if (i == 0) u[i][j] = -1;\n else u[i][j] = u[i - 1][j];\n if (j == 0) l[i][j] = -1;\n else l[i][j] = l[i][j - 1];\n } else {\n u[i][j] = i;\n l[i][j] = j;\n }\n }\n }\n for (int i = n - 1; i >= 0; i--) {\n for (int j = m - 1; j >= 0; j--) {\n if (c[i][j] == '.') {\n if (i == n - 1) d[i][j] = n;\n else d[i][j] = d[i + 1][j];\n if (j == m - 1) r[i][j] = m;\n else r[i][j] = r[i][j + 1];\n max = Math.max(max, r[i][j] - l[i][j] + d[i][j] - u[i][j] - 3);\n } else {\n d[i][j] = i;\n r[i][j] = j;\n }\n }\n }\n w.println(max);\n }\n\n }\n\n static class FastReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private FastReader.SpaceCharFilter filter;\n\n public FastReader(InputStream stream) {\n this.stream = stream;\n }\n\n public int read() {\n\n if (numChars == -1)\n throw new InputMismatchException();\n\n if (curChar >= numChars) {\n\n curChar = 0;\n\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n\n if (numChars <= 0)\n return -1;\n }\n\n return buf[curChar++];\n }\n\n public int nextInt() {\n\n int c = read();\n\n while (isSpaceChar(c))\n c = read();\n\n int sgn = 1;\n\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n\n int res = 0;\n\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n\n res *= 10;\n res += c - '0';\n c = read();\n }\n while (!isSpaceChar(c));\n\n return res * sgn;\n }\n\n public char nextChar() {\n\n int c = read();\n\n while (isSpaceChar(c))\n c = read();\n\n return (char) c;\n }\n\n public boolean isSpaceChar(int c) {\n\n if (filter != null)\n return filter.isSpaceChar(c);\n\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\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": 3987, "cpu_time_ms": 301, "memory_kb": 133348}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s525943420", "group_id": "codeNet:p03017", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String args[]) {\n\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int A = sc.nextInt();\n int B = sc.nextInt();\n int C = sc.nextInt();\n int D = sc.nextInt();\n String S = sc.next();\n\n if (S.contains(\"##\")) {\n System.out.print(\"No\");\n return;\n } else {\n if (C < D) {\n System.out.print(\"Yes\");\n return;\n } else {\n if (S.contains(\"...\")) {\n System.out.print(\"Yes\");\n } else {\n System.out.print(\"No\");\n }\n }\n }\n }\n}", "language": "Java", "metadata": {"date": 1559533076, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03017.html", "problem_id": "p03017", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03017/input.txt", "sample_output_relpath": "derived/input_output/data/p03017/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03017/Java/s525943420.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s525943420", "user_id": "u127030911"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String args[]) {\n\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int A = sc.nextInt();\n int B = sc.nextInt();\n int C = sc.nextInt();\n int D = sc.nextInt();\n String S = sc.next();\n\n if (S.contains(\"##\")) {\n System.out.print(\"No\");\n return;\n } else {\n if (C < D) {\n System.out.print(\"Yes\");\n return;\n } else {\n if (S.contains(\"...\")) {\n System.out.print(\"Yes\");\n } else {\n System.out.print(\"No\");\n }\n }\n }\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N squares arranged in a row, numbered 1, 2, ..., N from left to right.\nYou are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.\n\nIn the beginning, Snuke stands on Square A, and Fnuke stands on Square B.\n\nYou can repeat the following operation any number of times:\n\nChoose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.\n\nYou want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.\n\nDetermine whether this is possible.\n\nConstraints\n\n4 \\leq N \\leq 200\\ 000\n\nS is a string of length N consisting of . and #.\n\n1 \\leq A, B, C, D \\leq N\n\nSquare A, B, C and D do not contain a rock.\n\nA, B, C and D are all different.\n\nA < B\n\nA < C\n\nB < D\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\nS\n\nOutput\n\nPrint Yes if the objective is achievable, and No if it is not.\n\nSample Input 1\n\n7 1 3 6 7\n.#..#..\n\nSample Output 1\n\nYes\n\nThe objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)\n\nA#B.#..\n\nA#.B#..\n\n.#AB#..\n\n.#A.#B.\n\n.#.A#B.\n\n.#.A#.B\n\n.#..#AB\n\nSample Input 2\n\n7 1 3 7 6\n.#..#..\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n15 1 3 15 13\n...#.#...#.#...\n\nSample Output 3\n\nYes", "sample_input": "7 1 3 6 7\n.#..#..\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03017", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N squares arranged in a row, numbered 1, 2, ..., N from left to right.\nYou are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.\n\nIn the beginning, Snuke stands on Square A, and Fnuke stands on Square B.\n\nYou can repeat the following operation any number of times:\n\nChoose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.\n\nYou want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.\n\nDetermine whether this is possible.\n\nConstraints\n\n4 \\leq N \\leq 200\\ 000\n\nS is a string of length N consisting of . and #.\n\n1 \\leq A, B, C, D \\leq N\n\nSquare A, B, C and D do not contain a rock.\n\nA, B, C and D are all different.\n\nA < B\n\nA < C\n\nB < D\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\nS\n\nOutput\n\nPrint Yes if the objective is achievable, and No if it is not.\n\nSample Input 1\n\n7 1 3 6 7\n.#..#..\n\nSample Output 1\n\nYes\n\nThe objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)\n\nA#B.#..\n\nA#.B#..\n\n.#AB#..\n\n.#A.#B.\n\n.#.A#B.\n\n.#.A#.B\n\n.#..#AB\n\nSample Input 2\n\n7 1 3 7 6\n.#..#..\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n15 1 3 15 13\n...#.#...#.#...\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 733, "cpu_time_ms": 171, "memory_kb": 26452}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s098482306", "group_id": "codeNet:p03023", "input_text": "import java.util.Scanner;\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner stdIn=new Scanner(System.in);\n\t\tint N=stdIn.nextInt();\n\t\tSystem.out.println(180*(N-2));\n\t}\n}", "language": "Java", "metadata": {"date": 1559437457, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03023.html", "problem_id": "p03023", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03023/input.txt", "sample_output_relpath": "derived/input_output/data/p03023/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03023/Java/s098482306.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s098482306", "user_id": "u253726906"}, "prompt_components": {"gold_output": "180\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner stdIn=new Scanner(System.in);\n\t\tint N=stdIn.nextInt();\n\t\tSystem.out.println(180*(N-2));\n\t}\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides.\n\nPrint the answer in degrees, but do not print units.\n\nConstraints\n\n3 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint an integer representing the sum of the interior angles of a regular polygon with N sides.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n180\n\nThe sum of the interior angles of a regular triangle is 180 degrees.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n17640", "sample_input": "3\n"}, "reference_outputs": ["180\n"], "source_document_id": "p03023", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides.\n\nPrint the answer in degrees, but do not print units.\n\nConstraints\n\n3 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint an integer representing the sum of the interior angles of a regular polygon with N sides.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n180\n\nThe sum of the interior angles of a regular triangle is 180 degrees.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n17640", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 116, "memory_kb": 22612}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s322772322", "group_id": "codeNet:p03025", "input_text": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.NoSuchElementException;\n\npublic class Main {\n private static FastScanner sc = new FastScanner();\n private static long mod = 1000000007;\n\n public static void main(String[] args) {\n \tint N = sc.nextInt();\n \tint A = sc.nextInt();\n \tint B = sc.nextInt();\n \tint C = sc.nextInt();\n \tlong[] frac = new long[200000];\n \tfrac[0] = 1;\n \tfor(int i=1; i<200000; i++) {\n \t\tfrac[i] = frac[i-1] * i % mod;\n \t}\n \tlong ans = 0;\n \tlong ApBdiv = power(A+B, mod-2);\n \tfor(int i=0; i<=N-1; i++) {\n \t\tlong c = frac[N-1+i] * power(frac[N-1], mod-2) % mod * power(frac[i], mod-2) % mod;\n \t\tlong pra = c * power(A * ApBdiv % mod, N) % mod * power(B * ApBdiv % mod, i) % mod;\n \t\tlong prb = c * power(B * ApBdiv % mod, N) % mod * power(A * ApBdiv % mod, i) % mod;\n \t\tlong pr = (pra + prb) % mod;\n \t\tans = (ans + (pr * (N + i) % mod)) % mod;\n \t}\n \tans = ans * 100 % mod * ApBdiv % mod;\n \tSystem.out.println(ans);\n }\n\n static long power(long m , long n){\n \tif(n == 0) {\n \t\treturn 1;\n \t}else if(n == 1){\n return m;\n }else if(n % 2 == 0){\n long s = power(m, n/2);\n return ( (s % mod) * (s % mod) ) % mod;\n }else{\n return ( (m % mod) * (power(m, n-1) % mod) ) % mod;\n }\n }\n\n static class FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte() {\n if(ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch(IOException e) {\n e.printStackTrace();\n }\n if(buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}\n private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}\n private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}\n public boolean hasNext() { skipUnprintable(); return hasNextByte();}\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while(isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n public long nextLong() {\n return Long.parseLong(next());\n }\n public int nextInt(){\n return Integer.parseInt(next());\n }\n public double nextDouble(){\n return Double.parseDouble(next());\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1559439368, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03025.html", "problem_id": "p03025", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03025/input.txt", "sample_output_relpath": "derived/input_output/data/p03025/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03025/Java/s322772322.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s322772322", "user_id": "u914173586"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.NoSuchElementException;\n\npublic class Main {\n private static FastScanner sc = new FastScanner();\n private static long mod = 1000000007;\n\n public static void main(String[] args) {\n \tint N = sc.nextInt();\n \tint A = sc.nextInt();\n \tint B = sc.nextInt();\n \tint C = sc.nextInt();\n \tlong[] frac = new long[200000];\n \tfrac[0] = 1;\n \tfor(int i=1; i<200000; i++) {\n \t\tfrac[i] = frac[i-1] * i % mod;\n \t}\n \tlong ans = 0;\n \tlong ApBdiv = power(A+B, mod-2);\n \tfor(int i=0; i<=N-1; i++) {\n \t\tlong c = frac[N-1+i] * power(frac[N-1], mod-2) % mod * power(frac[i], mod-2) % mod;\n \t\tlong pra = c * power(A * ApBdiv % mod, N) % mod * power(B * ApBdiv % mod, i) % mod;\n \t\tlong prb = c * power(B * ApBdiv % mod, N) % mod * power(A * ApBdiv % mod, i) % mod;\n \t\tlong pr = (pra + prb) % mod;\n \t\tans = (ans + (pr * (N + i) % mod)) % mod;\n \t}\n \tans = ans * 100 % mod * ApBdiv % mod;\n \tSystem.out.println(ans);\n }\n\n static long power(long m , long n){\n \tif(n == 0) {\n \t\treturn 1;\n \t}else if(n == 1){\n return m;\n }else if(n % 2 == 0){\n long s = power(m, n/2);\n return ( (s % mod) * (s % mod) ) % mod;\n }else{\n return ( (m % mod) * (power(m, n-1) % mod) ) % mod;\n }\n }\n\n static class FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte() {\n if(ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch(IOException e) {\n e.printStackTrace();\n }\n if(buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}\n private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}\n private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}\n public boolean hasNext() { skipUnprintable(); return hasNextByte();}\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while(isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n public long nextLong() {\n return Long.parseLong(next());\n }\n public int nextInt(){\n return Integer.parseInt(next());\n }\n public double nextDouble(){\n return Double.parseDouble(next());\n }\n }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi and Aoki will play a game. They will repeatedly play it until one of them have N wins in total.\n\nWhen they play the game once, Takahashi wins with probability A %, Aoki wins with probability B %, and the game ends in a draw (that is, nobody wins) with probability C %.\nFind the expected number of games that will be played, and print it as follows.\n\nWe can represent the expected value as P/Q with coprime integers P and Q.\nPrint the integer R between 0 and 10^9+6 (inclusive) such that R \\times Q \\equiv P\\pmod {10^9+7}.\n(Such an integer R always uniquely exists under the constraints of this problem.)\n\nConstraints\n\n1 \\leq N \\leq 100000\n\n0 \\leq A,B,C \\leq 100\n\n1 \\leq A+B\n\nA+B+C=100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\n\nOutput\n\nPrint the expected number of games that will be played, in the manner specified in the statement.\n\nSample Input 1\n\n1 25 25 50\n\nSample Output 1\n\n2\n\nSince N=1, they will repeat the game until one of them wins.\nThe expected number of games played is 2.\n\nSample Input 2\n\n4 50 50 0\n\nSample Output 2\n\n312500008\n\nC may be 0.\n\nSample Input 3\n\n1 100 0 0\n\nSample Output 3\n\n1\n\nB may also be 0.\n\nSample Input 4\n\n100000 31 41 28\n\nSample Output 4\n\n104136146", "sample_input": "1 25 25 50\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03025", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi and Aoki will play a game. They will repeatedly play it until one of them have N wins in total.\n\nWhen they play the game once, Takahashi wins with probability A %, Aoki wins with probability B %, and the game ends in a draw (that is, nobody wins) with probability C %.\nFind the expected number of games that will be played, and print it as follows.\n\nWe can represent the expected value as P/Q with coprime integers P and Q.\nPrint the integer R between 0 and 10^9+6 (inclusive) such that R \\times Q \\equiv P\\pmod {10^9+7}.\n(Such an integer R always uniquely exists under the constraints of this problem.)\n\nConstraints\n\n1 \\leq N \\leq 100000\n\n0 \\leq A,B,C \\leq 100\n\n1 \\leq A+B\n\nA+B+C=100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\n\nOutput\n\nPrint the expected number of games that will be played, in the manner specified in the statement.\n\nSample Input 1\n\n1 25 25 50\n\nSample Output 1\n\n2\n\nSince N=1, they will repeat the game until one of them wins.\nThe expected number of games played is 2.\n\nSample Input 2\n\n4 50 50 0\n\nSample Output 2\n\n312500008\n\nC may be 0.\n\nSample Input 3\n\n1 100 0 0\n\nSample Output 3\n\n1\n\nB may also be 0.\n\nSample Input 4\n\n100000 31 41 28\n\nSample Output 4\n\n104136146", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2987, "cpu_time_ms": 788, "memory_kb": 29500}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s351441099", "group_id": "codeNet:p03029", "input_text": "\n\nimport java.text.DecimalFormat;\nimport java.util.function.BiFunction;\nimport java.util.function.Function;\nimport java.util.stream.LongStream;\nimport java.util.stream.IntStream;\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n FastScanner sc = new FastScanner();\n PrintWriter out = new PrintWriter(System.out);\n\n int a = sc.nextInt();\n int p = sc.nextInt();\n out.println((a * 3 + p) / 2);\n\n out.flush();\n }\n\n}\n\n// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4\nclass FastScanner {\n\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) {\n return buffer[ptr++];\n } else {\n return -1;\n }\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) {\n ptr++;\n }\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {\n throw new NumberFormatException();\n }\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n}\n", "language": "Java", "metadata": {"date": 1588286455, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03029.html", "problem_id": "p03029", "resource_group": "high_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/Java/s351441099.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s351441099", "user_id": "u871244227"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "\n\nimport java.text.DecimalFormat;\nimport java.util.function.BiFunction;\nimport java.util.function.Function;\nimport java.util.stream.LongStream;\nimport java.util.stream.IntStream;\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n FastScanner sc = new FastScanner();\n PrintWriter out = new PrintWriter(System.out);\n\n int a = sc.nextInt();\n int p = sc.nextInt();\n out.println((a * 3 + p) / 2);\n\n out.flush();\n }\n\n}\n\n// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4\nclass FastScanner {\n\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) {\n return buffer[ptr++];\n } else {\n return -1;\n }\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) {\n ptr++;\n }\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {\n throw new NumberFormatException();\n }\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\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": 2882, "cpu_time_ms": 72, "memory_kb": 22740}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s172408817", "group_id": "codeNet:p03030", "input_text": "import java.util.Scanner;\nimport java.util.TreeMap;\nimport java.util.Iterator;\n\npublic class Main {\n \tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n TreeMap> restaurants = new TreeMap<>();\n\n int N = sc.nextInt();\n for (int i = 0; i < N; i++) {\n String city = sc.next();\n TreeMap restaurantsInCity = restaurants.get(city);\n if (restaurantsInCity == null) {\n restaurantsInCity = new TreeMap<>();\n }\n\n restaurantsInCity.put(sc.nextInt(), i);\n }\n\n Iterator itr = restaurants.keySet().iterator();\n while (itr.hasNext()) {\n TreeMap resutaurantsInCity = restaurants.get(itr.next());\n Iterator index = resutaurantsInCity.values().iterator();\n while (index.hasNext()) {\n System.out.println(index.next());\n }\n }\n }\n}", "language": "Java", "metadata": {"date": 1560304185, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03030.html", "problem_id": "p03030", "resource_group": "high_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/Java/s172408817.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s172408817", "user_id": "u108980211"}, "prompt_components": {"gold_output": "3\n4\n6\n1\n5\n2\n", "input_to_evaluate": "import java.util.Scanner;\nimport java.util.TreeMap;\nimport java.util.Iterator;\n\npublic class Main {\n \tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n TreeMap> restaurants = new TreeMap<>();\n\n int N = sc.nextInt();\n for (int i = 0; i < N; i++) {\n String city = sc.next();\n TreeMap restaurantsInCity = restaurants.get(city);\n if (restaurantsInCity == null) {\n restaurantsInCity = new TreeMap<>();\n }\n\n restaurantsInCity.put(sc.nextInt(), i);\n }\n\n Iterator itr = restaurants.keySet().iterator();\n while (itr.hasNext()) {\n TreeMap resutaurantsInCity = restaurants.get(itr.next());\n Iterator index = resutaurantsInCity.values().iterator();\n while (index.hasNext()) {\n System.out.println(index.next());\n }\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": 1009, "cpu_time_ms": 104, "memory_kb": 23124}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s590421585", "group_id": "codeNet:p03031", "input_text": "import java.util.HashSet;\nimport java.util.LinkedHashMap;\nimport java.util.Map;\nimport java.util.Scanner;\nimport java.util.Set;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner stdIn = new Scanner(System.in);\n\n\t\tint numberOfSwitch = stdIn.nextInt();\n\t\tint numberOfLights = stdIn.nextInt();\n\n\t\tstdIn.nextLine();//改行のため\n\n\t\tMap switchMap = new LinkedHashMap<>();\n\t\t// set input\n\t\tfor (int i = 1; i <= numberOfLights; i++) {\n\t\t\tswitchMap.put(i, new LightSwitch(i, stdIn.nextLine()));\n\t\t}\n\t\tfor (int i = 1; i <= numberOfLights; i++) {\n\t\t\tswitchMap.get(i).setMod(stdIn.nextInt());\n\t\t}\n\n\t\t// execute\n\t\tint allSize = (int) Math.pow(2, numberOfSwitch);\n\t\tint cnt = 0;\n\n\t\tfor (int i = 0; i < allSize; i++) {\n\n\t\t\tString boolStr = String.format(\"%\" + numberOfSwitch + \"s\", Integer.toBinaryString(i)).replaceAll(\" \", \"0\");\n\n\t\t\tif (canAllLightUp(switchMap, boolStr)) {\n\t\t\t\tcnt++;\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(cnt);\n\n\t\tstdIn.close();\n\t}\n\n\tprivate static boolean canAllLightUp(Map switchMap, String boolStr) {\n\t\tfor (LightSwitch swt : switchMap.values()) {\n\t\t\tif (!swt.canLightsUp(boolStr)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n}\n\nclass LightSwitch {\n\tprivate int switchId;\n\tprivate Set useSwitchSet = new HashSet<>();\n\tprivate int mod;\n\n\tpublic LightSwitch(int switchId, String useSwitchStr) {\n\t\tthis.switchId = switchId;\n\n\t\tString[] strArray = useSwitchStr.split(\" \");\n\n\t\tfor (int i = 1; i < strArray.length; i++) {\n\t\t\tuseSwitchSet.add(Integer.parseInt(strArray[i]));\n\t\t}\n\t}\n\n\tpublic boolean canLightsUp(String switchArrayStr) {\n\t\tint cnt = 0;\n\n\t\tfor (Integer switchId : useSwitchSet) {\n\t\t\tif (switchArrayStr.charAt(switchId - 1) == '1') {\n\t\t\t\tcnt++;\n\t\t\t}\n\t\t}\n\n\t\treturn cnt % 2 == mod;\n\n\t}\n\n\tpublic int getMod() {\n\t\treturn mod;\n\t}\n\n\tpublic void setMod(int mod) {\n\t\tthis.mod = mod;\n\t}\n\n\tpublic int getSwitchId() {\n\t\treturn switchId;\n\t}\n\n}", "language": "Java", "metadata": {"date": 1588466108, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03031.html", "problem_id": "p03031", "resource_group": "high_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/Java/s590421585.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s590421585", "user_id": "u123743472"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.HashSet;\nimport java.util.LinkedHashMap;\nimport java.util.Map;\nimport java.util.Scanner;\nimport java.util.Set;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner stdIn = new Scanner(System.in);\n\n\t\tint numberOfSwitch = stdIn.nextInt();\n\t\tint numberOfLights = stdIn.nextInt();\n\n\t\tstdIn.nextLine();//改行のため\n\n\t\tMap switchMap = new LinkedHashMap<>();\n\t\t// set input\n\t\tfor (int i = 1; i <= numberOfLights; i++) {\n\t\t\tswitchMap.put(i, new LightSwitch(i, stdIn.nextLine()));\n\t\t}\n\t\tfor (int i = 1; i <= numberOfLights; i++) {\n\t\t\tswitchMap.get(i).setMod(stdIn.nextInt());\n\t\t}\n\n\t\t// execute\n\t\tint allSize = (int) Math.pow(2, numberOfSwitch);\n\t\tint cnt = 0;\n\n\t\tfor (int i = 0; i < allSize; i++) {\n\n\t\t\tString boolStr = String.format(\"%\" + numberOfSwitch + \"s\", Integer.toBinaryString(i)).replaceAll(\" \", \"0\");\n\n\t\t\tif (canAllLightUp(switchMap, boolStr)) {\n\t\t\t\tcnt++;\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(cnt);\n\n\t\tstdIn.close();\n\t}\n\n\tprivate static boolean canAllLightUp(Map switchMap, String boolStr) {\n\t\tfor (LightSwitch swt : switchMap.values()) {\n\t\t\tif (!swt.canLightsUp(boolStr)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n}\n\nclass LightSwitch {\n\tprivate int switchId;\n\tprivate Set useSwitchSet = new HashSet<>();\n\tprivate int mod;\n\n\tpublic LightSwitch(int switchId, String useSwitchStr) {\n\t\tthis.switchId = switchId;\n\n\t\tString[] strArray = useSwitchStr.split(\" \");\n\n\t\tfor (int i = 1; i < strArray.length; i++) {\n\t\t\tuseSwitchSet.add(Integer.parseInt(strArray[i]));\n\t\t}\n\t}\n\n\tpublic boolean canLightsUp(String switchArrayStr) {\n\t\tint cnt = 0;\n\n\t\tfor (Integer switchId : useSwitchSet) {\n\t\t\tif (switchArrayStr.charAt(switchId - 1) == '1') {\n\t\t\t\tcnt++;\n\t\t\t}\n\t\t}\n\n\t\treturn cnt % 2 == mod;\n\n\t}\n\n\tpublic int getMod() {\n\t\treturn mod;\n\t}\n\n\tpublic void setMod(int mod) {\n\t\tthis.mod = mod;\n\t}\n\n\tpublic int getSwitchId() {\n\t\treturn switchId;\n\t}\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": 1923, "cpu_time_ms": 183, "memory_kb": 27732}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s492017711", "group_id": "codeNet:p03032", "input_text": "import java.util.*;\nimport java.io.*;\n \npublic class Main {\n static boolean[][] used;\n static int[] ans;\n public static void main(String[] args) throws Exception {\n long max = 100000 * 20000000000L;\n FastScanner sc = new FastScanner(System.in);\n PrintWriter out = new PrintWriter(System.out);\n int n = sc.nextInt();\n int k = sc.nextInt();\n long[] a = sc.nextLongArray(n);\n long ans = 0;\n for(int i = 0; i <= k; i++){\n for(int j = 0; j <= k-i; j++){\n if(i+j > n) continue;\n long now = 0;\n int d = k-i-j;\n ArrayList li = new ArrayList<>();\n for(int l = 1; l <= i; l++){\n now += a[l-1];\n li.add(a[l-1]);\n }\n for(int r = 1; r <= j; r++){\n now += a[n-r];\n li.add(a[n-r]);\n }\n Collections.sort(li);\n for(int v = 0; v < d; v++){\n if(v >= li.size()) break;\n if(li.get(v) >= 0) break;\n now -= li.get(v);\n }\n ans = Math.max(ans,now);\n }\n }\n System.out.println(ans);\n }\n}\n\nclass FastScanner {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n public FastScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n tokenizer = null;\n }\n\n public String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken(\"\\n\");\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n\n public int[] nextIntArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = nextInt();\n return a;\n }\n\n public long[] nextLongArray(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = nextLong();\n return a;\n } \n}\n\n\n", "language": "Java", "metadata": {"date": 1589144857, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03032.html", "problem_id": "p03032", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03032/input.txt", "sample_output_relpath": "derived/input_output/data/p03032/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03032/Java/s492017711.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s492017711", "user_id": "u578775554"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\n \npublic class Main {\n static boolean[][] used;\n static int[] ans;\n public static void main(String[] args) throws Exception {\n long max = 100000 * 20000000000L;\n FastScanner sc = new FastScanner(System.in);\n PrintWriter out = new PrintWriter(System.out);\n int n = sc.nextInt();\n int k = sc.nextInt();\n long[] a = sc.nextLongArray(n);\n long ans = 0;\n for(int i = 0; i <= k; i++){\n for(int j = 0; j <= k-i; j++){\n if(i+j > n) continue;\n long now = 0;\n int d = k-i-j;\n ArrayList li = new ArrayList<>();\n for(int l = 1; l <= i; l++){\n now += a[l-1];\n li.add(a[l-1]);\n }\n for(int r = 1; r <= j; r++){\n now += a[n-r];\n li.add(a[n-r]);\n }\n Collections.sort(li);\n for(int v = 0; v < d; v++){\n if(v >= li.size()) break;\n if(li.get(v) >= 0) break;\n now -= li.get(v);\n }\n ans = Math.max(ans,now);\n }\n }\n System.out.println(ans);\n }\n}\n\nclass FastScanner {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n public FastScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n tokenizer = null;\n }\n\n public String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken(\"\\n\");\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n\n public int[] nextIntArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = nextInt();\n return a;\n }\n\n public long[] nextLongArray(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = nextLong();\n return a;\n } \n}\n\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYour friend gave you a dequeue D as a birthday present.\n\nD is a horizontal cylinder that contains a row of N jewels.\n\nThe values of the jewels are V_1, V_2, ..., V_N from left to right. There may be jewels with negative values.\n\nIn the beginning, you have no jewel in your hands.\n\nYou can perform at most K operations on D, chosen from the following, at most K times (possibly zero):\n\nOperation A: Take out the leftmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation B: Take out the rightmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation C: Choose a jewel in your hands and insert it to the left end of D. You cannot do this operation when you have no jewel in your hand.\n\nOperation D: Choose a jewel in your hands and insert it to the right end of D. You cannot do this operation when you have no jewel in your hand.\n\nFind the maximum possible sum of the values of jewels in your hands after the operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 50\n\n1 \\leq K \\leq 100\n\n-10^7 \\leq V_i \\leq 10^7\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nV_1 V_2 ... V_N\n\nOutput\n\nPrint the maximum possible sum of the values of jewels in your hands after the operations.\n\nSample Input 1\n\n6 4\n-10 8 2 1 2 6\n\nSample Output 1\n\n14\n\nAfter the following sequence of operations, you have two jewels of values 8 and 6 in your hands for a total of 14, which is the maximum result.\n\nDo operation A. You take out the jewel of value -10 from the left end of D.\n\nDo operation B. You take out the jewel of value 6 from the right end of D.\n\nDo operation A. You take out the jewel of value 8 from the left end of D.\n\nDo operation D. You insert the jewel of value -10 to the right end of D.\n\nSample Input 2\n\n6 4\n-6 -100 50 -2 -5 -3\n\nSample Output 2\n\n44\n\nSample Input 3\n\n6 3\n-6 -100 50 -2 -5 -3\n\nSample Output 3\n\n0\n\nIt is optimal to do no operation.", "sample_input": "6 4\n-10 8 2 1 2 6\n"}, "reference_outputs": ["14\n"], "source_document_id": "p03032", "source_text": "Score : 400 points\n\nProblem Statement\n\nYour friend gave you a dequeue D as a birthday present.\n\nD is a horizontal cylinder that contains a row of N jewels.\n\nThe values of the jewels are V_1, V_2, ..., V_N from left to right. There may be jewels with negative values.\n\nIn the beginning, you have no jewel in your hands.\n\nYou can perform at most K operations on D, chosen from the following, at most K times (possibly zero):\n\nOperation A: Take out the leftmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation B: Take out the rightmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation C: Choose a jewel in your hands and insert it to the left end of D. You cannot do this operation when you have no jewel in your hand.\n\nOperation D: Choose a jewel in your hands and insert it to the right end of D. You cannot do this operation when you have no jewel in your hand.\n\nFind the maximum possible sum of the values of jewels in your hands after the operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 50\n\n1 \\leq K \\leq 100\n\n-10^7 \\leq V_i \\leq 10^7\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nV_1 V_2 ... V_N\n\nOutput\n\nPrint the maximum possible sum of the values of jewels in your hands after the operations.\n\nSample Input 1\n\n6 4\n-10 8 2 1 2 6\n\nSample Output 1\n\n14\n\nAfter the following sequence of operations, you have two jewels of values 8 and 6 in your hands for a total of 14, which is the maximum result.\n\nDo operation A. You take out the jewel of value -10 from the left end of D.\n\nDo operation B. You take out the jewel of value 6 from the right end of D.\n\nDo operation A. You take out the jewel of value 8 from the left end of D.\n\nDo operation D. You insert the jewel of value -10 to the right end of D.\n\nSample Input 2\n\n6 4\n-6 -100 50 -2 -5 -3\n\nSample Output 2\n\n44\n\nSample Input 3\n\n6 3\n-6 -100 50 -2 -5 -3\n\nSample Output 3\n\n0\n\nIt is optimal to do no operation.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2736, "cpu_time_ms": 122, "memory_kb": 22740}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s693728928", "group_id": "codeNet:p03033", "input_text": "import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Scanner;\n\n/**\n * Roadwork\n */\npublic class Main {\n\n public static void main(String[] args) throws Exception {\n try (Scanner sc = new Scanner(System.in)) {\n int N = sc.nextInt();\n int Q = sc.nextInt();\n\n int[][] W = new int[N][3];\n for (int i = 0; i < N; i++) {\n W[i][0] = sc.nextInt();\n W[i][1] = sc.nextInt();\n W[i][2] = sc.nextInt();\n }\n\n Arrays.sort(W, (o1, o2) -> Integer.compare(o1[2], o2[2]));\n\n List D = new ArrayList();\n Map index = new HashMap<>();\n for (int i = 0; i < Q; i++) {\n int d = sc.nextInt();\n D.add(d);\n index.put(d, i);\n }\n\n int[] A = new int[Q];\n Arrays.fill(A, -1);\n\n for (int i = 0; i < N; i++) {\n int s = W[i][0];\n int t = W[i][1];\n int x = W[i][2];\n\n int pos1 = Collections.binarySearch(D, s - x);\n if (pos1 < 0) {\n pos1 = -(pos1 + 1);\n }\n\n int pos2 = Collections.binarySearch(D, t - x);\n if (pos2 < 0) {\n pos2 = -(pos2 + 1);\n }\n\n //System.out.println(s + \" \" + t + \" \" + x + \" \" + pos1 + \" \" + pos2 + \" \" + D);\n\n if (pos1 == pos2) {\n continue;\n }\n\n for (int p = pos1; p < pos2; p++) {\n int q = D.remove(pos1);\n A[index.get(q)] = x;\n }\n }\n\n StringBuilder ans = new StringBuilder();\n for (int a : A) {\n ans.append(a).append(\"\\n\");\n }\n\n System.out.print(ans.toString());\n }\n }\n\n}\n", "language": "Java", "metadata": {"date": 1578534797, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03033.html", "problem_id": "p03033", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03033/input.txt", "sample_output_relpath": "derived/input_output/data/p03033/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03033/Java/s693728928.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s693728928", "user_id": "u146364934"}, "prompt_components": {"gold_output": "2\n2\n10\n-1\n13\n-1\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Scanner;\n\n/**\n * Roadwork\n */\npublic class Main {\n\n public static void main(String[] args) throws Exception {\n try (Scanner sc = new Scanner(System.in)) {\n int N = sc.nextInt();\n int Q = sc.nextInt();\n\n int[][] W = new int[N][3];\n for (int i = 0; i < N; i++) {\n W[i][0] = sc.nextInt();\n W[i][1] = sc.nextInt();\n W[i][2] = sc.nextInt();\n }\n\n Arrays.sort(W, (o1, o2) -> Integer.compare(o1[2], o2[2]));\n\n List D = new ArrayList();\n Map index = new HashMap<>();\n for (int i = 0; i < Q; i++) {\n int d = sc.nextInt();\n D.add(d);\n index.put(d, i);\n }\n\n int[] A = new int[Q];\n Arrays.fill(A, -1);\n\n for (int i = 0; i < N; i++) {\n int s = W[i][0];\n int t = W[i][1];\n int x = W[i][2];\n\n int pos1 = Collections.binarySearch(D, s - x);\n if (pos1 < 0) {\n pos1 = -(pos1 + 1);\n }\n\n int pos2 = Collections.binarySearch(D, t - x);\n if (pos2 < 0) {\n pos2 = -(pos2 + 1);\n }\n\n //System.out.println(s + \" \" + t + \" \" + x + \" \" + pos1 + \" \" + pos2 + \" \" + D);\n\n if (pos1 == pos2) {\n continue;\n }\n\n for (int p = pos1; p < pos2; p++) {\n int q = D.remove(pos1);\n A[index.get(q)] = x;\n }\n }\n\n StringBuilder ans = new StringBuilder();\n for (int a : A) {\n ans.append(a).append(\"\\n\");\n }\n\n System.out.print(ans.toString());\n }\n }\n\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere is an infinitely long street that runs west to east, which we consider as a number line.\n\nThere are N roadworks scheduled on this street.\nThe i-th roadwork blocks the point at coordinate X_i from time S_i - 0.5 to time T_i - 0.5.\n\nQ people are standing at coordinate 0. The i-th person will start the coordinate 0 at time D_i, continue to walk with speed 1 in the positive direction and stop walking when reaching a blocked point.\n\nFind the distance each of the Q people will walk.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, Q \\leq 2 \\times 10^5\n\n0 \\leq S_i < T_i \\leq 10^9\n\n1 \\leq X_i \\leq 10^9\n\n0 \\leq D_1 < D_2 < ... < D_Q \\leq 10^9\n\nIf i \\neq j and X_i = X_j, the intervals [S_i, T_i) and [S_j, T_j) do not overlap.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS_1 T_1 X_1\n:\nS_N T_N X_N\nD_1\n:\nD_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the distance the i-th person will walk or -1 if that person walks forever.\n\nSample Input 1\n\n4 6\n1 3 2\n7 13 10\n18 20 13\n3 4 2\n0\n1\n2\n3\n5\n8\n\nSample Output 1\n\n2\n2\n10\n-1\n13\n-1\n\nThe first person starts coordinate 0 at time 0 and stops walking at coordinate 2 when reaching a point blocked by the first roadwork at time 2.\n\nThe second person starts coordinate 0 at time 1 and reaches coordinate 2 at time 3. The first roadwork has ended, but the fourth roadwork has begun, so this person also stops walking at coordinate 2.\n\nThe fourth and sixth persons encounter no roadworks while walking, so they walk forever. The output for these cases is -1.", "sample_input": "4 6\n1 3 2\n7 13 10\n18 20 13\n3 4 2\n0\n1\n2\n3\n5\n8\n"}, "reference_outputs": ["2\n2\n10\n-1\n13\n-1\n"], "source_document_id": "p03033", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere is an infinitely long street that runs west to east, which we consider as a number line.\n\nThere are N roadworks scheduled on this street.\nThe i-th roadwork blocks the point at coordinate X_i from time S_i - 0.5 to time T_i - 0.5.\n\nQ people are standing at coordinate 0. The i-th person will start the coordinate 0 at time D_i, continue to walk with speed 1 in the positive direction and stop walking when reaching a blocked point.\n\nFind the distance each of the Q people will walk.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, Q \\leq 2 \\times 10^5\n\n0 \\leq S_i < T_i \\leq 10^9\n\n1 \\leq X_i \\leq 10^9\n\n0 \\leq D_1 < D_2 < ... < D_Q \\leq 10^9\n\nIf i \\neq j and X_i = X_j, the intervals [S_i, T_i) and [S_j, T_j) do not overlap.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS_1 T_1 X_1\n:\nS_N T_N X_N\nD_1\n:\nD_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the distance the i-th person will walk or -1 if that person walks forever.\n\nSample Input 1\n\n4 6\n1 3 2\n7 13 10\n18 20 13\n3 4 2\n0\n1\n2\n3\n5\n8\n\nSample Output 1\n\n2\n2\n10\n-1\n13\n-1\n\nThe first person starts coordinate 0 at time 0 and stops walking at coordinate 2 when reaching a point blocked by the first roadwork at time 2.\n\nThe second person starts coordinate 0 at time 1 and reaches coordinate 2 at time 3. The first roadwork has ended, but the fourth roadwork has begun, so this person also stops walking at coordinate 2.\n\nThe fourth and sixth persons encounter no roadworks while walking, so they walk forever. The output for these cases is -1.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2039, "cpu_time_ms": 2109, "memory_kb": 185320}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s115871000", "group_id": "codeNet:p03035", "input_text": "import java.util.*;\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\t// 整数の入力\n\t\tint a = sc.nextInt();\n\t\t// スペース区切りの整数の入力\n\t\tint b = sc.nextInt();\n\t\t// 出力\n\t\t\n\t\tif(b%2==0) {\n\t\t\tif ( a>=0 && a<6 ) {\n\t\t\t\tSystem.out.println(0);\n\t\t\t} else if ( a>=6 && a<12 ){\n\t\t\t\tSystem.out.println(b/2);\n\t\t\t} else if ( a>=13 && a<= 100){\n\t\t\t\tSystem.out.println(b);\n\t\t\t} else {\n\t\t\t}\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1558834608, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03035.html", "problem_id": "p03035", "resource_group": "high_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/Java/s115871000.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s115871000", "user_id": "u622095001"}, "prompt_components": {"gold_output": "100\n", "input_to_evaluate": "import java.util.*;\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\t// 整数の入力\n\t\tint a = sc.nextInt();\n\t\t// スペース区切りの整数の入力\n\t\tint b = sc.nextInt();\n\t\t// 出力\n\t\t\n\t\tif(b%2==0) {\n\t\t\tif ( a>=0 && a<6 ) {\n\t\t\t\tSystem.out.println(0);\n\t\t\t} else if ( a>=6 && a<12 ){\n\t\t\t\tSystem.out.println(b/2);\n\t\t\t} else if ( a>=13 && a<= 100){\n\t\t\t\tSystem.out.println(b);\n\t\t\t} else {\n\t\t\t}\n\t\t}\n\t}\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": 462, "cpu_time_ms": 94, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s978213176", "group_id": "codeNet:p03035", "input_text": "import java.util.*;\n\nclass Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int nennrei = sc.nextInt();\n int b = sc.nextInt();\n\n if(nennrei > 12){\n System.out.println(b);\n }else if(nennrei < 6){\n System.out.println(0);\n }else{\n System.out.println(b/2);\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1558832627, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03035.html", "problem_id": "p03035", "resource_group": "high_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/Java/s978213176.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s978213176", "user_id": "u346749506"}, "prompt_components": {"gold_output": "100\n", "input_to_evaluate": "import java.util.*;\n\nclass Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int nennrei = sc.nextInt();\n int b = sc.nextInt();\n\n if(nennrei > 12){\n System.out.println(b);\n }else if(nennrei < 6){\n System.out.println(0);\n }else{\n System.out.println(b/2);\n }\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "sample_input": "30 100\n"}, "reference_outputs": ["100\n"], "source_document_id": "p03035", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 382, "cpu_time_ms": 118, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s791823414", "group_id": "codeNet:p03036", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String args[]) {\n\n Scanner sc = new Scanner(System.in);\n int r = sc.nextInt();\n int d = sc.nextInt();\n int x2000 = sc.nextInt();\n\n int x2001 = r*x2000 - d;\n int x2002 = r*x2001 - d;\n int x2003 = r*x2002 - d;\n int x2004 = r*x2003 - d;\n int x2005 = r*x2004 - d;\n int x2006 = r*x2005 - d;\n int x2007 = r*x2006 - d;\n int x2008 = r*x2007 - d;\n int x2009 = r*x2008 - d;\n int x2010 = r*x2009 - d;\n System.out.println(x2001);\n System.out.println(x2002);\n System.out.println(x2003);\n System.out.println(x2004);\n System.out.println(x2005);\n System.out.println(x2006);\n System.out.println(x2007);\n System.out.println(x2008);\n System.out.println(x2009);\n System.out.println(x2010);\n }\n}\n\n\n\n", "language": "Java", "metadata": {"date": 1559874891, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03036.html", "problem_id": "p03036", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03036/input.txt", "sample_output_relpath": "derived/input_output/data/p03036/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03036/Java/s791823414.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s791823414", "user_id": "u127030911"}, "prompt_components": {"gold_output": "30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String args[]) {\n\n Scanner sc = new Scanner(System.in);\n int r = sc.nextInt();\n int d = sc.nextInt();\n int x2000 = sc.nextInt();\n\n int x2001 = r*x2000 - d;\n int x2002 = r*x2001 - d;\n int x2003 = r*x2002 - d;\n int x2004 = r*x2003 - d;\n int x2005 = r*x2004 - d;\n int x2006 = r*x2005 - d;\n int x2007 = r*x2006 - d;\n int x2008 = r*x2007 - d;\n int x2009 = r*x2008 - d;\n int x2010 = r*x2009 - d;\n System.out.println(x2001);\n System.out.println(x2002);\n System.out.println(x2003);\n System.out.println(x2004);\n System.out.println(x2005);\n System.out.println(x2006);\n System.out.println(x2007);\n System.out.println(x2008);\n System.out.println(x2009);\n System.out.println(x2010);\n }\n}\n\n\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThe development of algae in a pond is as follows.\n\nLet the total weight of the algae at the beginning of the year i be x_i gram. For i≥2000, the following formula holds:\n\nx_{i+1} = rx_i - D\n\nYou are given r, D and x_{2000}. Calculate x_{2001}, ..., x_{2010} and print them in order.\n\nConstraints\n\n2 ≤ r ≤ 5\n\n1 ≤ D ≤ 100\n\nD < x_{2000} ≤ 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr D x_{2000}\n\nOutput\n\nPrint 10 lines. The i-th line (1 ≤ i ≤ 10) should contain x_{2000+i} as an integer.\n\nSample Input 1\n\n2 10 20\n\nSample Output 1\n\n30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n\nFor example, x_{2001} = rx_{2000} - D = 2 \\times 20 - 10 = 30 and x_{2002} = rx_{2001} - D = 2 \\times 30 - 10 = 50.\n\nSample Input 2\n\n4 40 60\n\nSample Output 2\n\n200\n760\n3000\n11960\n47800\n191160\n764600\n3058360\n12233400\n48933560", "sample_input": "2 10 20\n"}, "reference_outputs": ["30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n"], "source_document_id": "p03036", "source_text": "Score : 200 points\n\nProblem Statement\n\nThe development of algae in a pond is as follows.\n\nLet the total weight of the algae at the beginning of the year i be x_i gram. For i≥2000, the following formula holds:\n\nx_{i+1} = rx_i - D\n\nYou are given r, D and x_{2000}. Calculate x_{2001}, ..., x_{2010} and print them in order.\n\nConstraints\n\n2 ≤ r ≤ 5\n\n1 ≤ D ≤ 100\n\nD < x_{2000} ≤ 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr D x_{2000}\n\nOutput\n\nPrint 10 lines. The i-th line (1 ≤ i ≤ 10) should contain x_{2000+i} as an integer.\n\nSample Input 1\n\n2 10 20\n\nSample Output 1\n\n30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n\nFor example, x_{2001} = rx_{2000} - D = 2 \\times 20 - 10 = 30 and x_{2002} = rx_{2001} - D = 2 \\times 30 - 10 = 50.\n\nSample Input 2\n\n4 40 60\n\nSample Output 2\n\n200\n760\n3000\n11960\n47800\n191160\n764600\n3058360\n12233400\n48933560", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 918, "cpu_time_ms": 95, "memory_kb": 21972}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s565542224", "group_id": "codeNet:p03038", "input_text": "import java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\nimport java.util.PriorityQueue;\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n \n Scanner sc = new Scanner(System.in);\n \n int n = Integer.parseInt(sc.next());\n int m = Integer.parseInt(sc.next());\n \n PriorityQueue a = new PriorityQueue<>();\n for(int i = 0; i < n; i++){\n a.offer(Integer.parseInt(sc.next()));\n }\n \n List list = new ArrayList<>();\n for(int i = 0; i < m; i++){\n list.add(new BC(Integer.parseInt(sc.next()), Integer.parseInt(sc.next())));\n }\n Collections.sort(list);\n \n int count = 0;\n int b, c;\n for(int i = 0; i < m; i++){\n b = list.get(i).b;\n c = list.get(i).c;\n for(int j = 0; j < b; j++){\n if(a.peek() >= c){\n break;\n }\n a.poll();\n a.offer(c);\n count++;\n if(count >= n){\n break;\n }\n }\n if(c <= a.peek() || count >= n){\n break;\n }\n }\n \n long ans = 0;\n for(int i = 0; i < n; i++){\n ans += a.poll();\n }\n System.out.println(ans);\n }\n}\n\nclass BC implements Comparable{\n int b;\n int c;\n \n BC(int b, int c){\n this.b = b;\n this.c = c;\n }\n\n @Override\n public int compareTo(BC bc) {\n \n if(this.c > bc.c){\n return -1;\n }else if(this.c < bc.c){\n return 1;\n }else{\n return 0;\n }\n }\n}", "language": "Java", "metadata": {"date": 1567223875, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03038.html", "problem_id": "p03038", "resource_group": "high_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/Java/s565542224.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s565542224", "user_id": "u175752990"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\nimport java.util.PriorityQueue;\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n \n Scanner sc = new Scanner(System.in);\n \n int n = Integer.parseInt(sc.next());\n int m = Integer.parseInt(sc.next());\n \n PriorityQueue a = new PriorityQueue<>();\n for(int i = 0; i < n; i++){\n a.offer(Integer.parseInt(sc.next()));\n }\n \n List list = new ArrayList<>();\n for(int i = 0; i < m; i++){\n list.add(new BC(Integer.parseInt(sc.next()), Integer.parseInt(sc.next())));\n }\n Collections.sort(list);\n \n int count = 0;\n int b, c;\n for(int i = 0; i < m; i++){\n b = list.get(i).b;\n c = list.get(i).c;\n for(int j = 0; j < b; j++){\n if(a.peek() >= c){\n break;\n }\n a.poll();\n a.offer(c);\n count++;\n if(count >= n){\n break;\n }\n }\n if(c <= a.peek() || count >= n){\n break;\n }\n }\n \n long ans = 0;\n for(int i = 0; i < n; i++){\n ans += a.poll();\n }\n System.out.println(ans);\n }\n}\n\nclass BC implements Comparable{\n int b;\n int c;\n \n BC(int b, int c){\n this.b = b;\n this.c = c;\n }\n\n @Override\n public int compareTo(BC bc) {\n \n if(this.c > bc.c){\n return -1;\n }else if(this.c < bc.c){\n return 1;\n }else{\n return 0;\n }\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have N cards. On the i-th card, an integer A_i is written.\n\nFor each j = 1, 2, ..., M in this order, you will perform the following operation once:\n\nOperation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.\n\nFind the maximum possible sum of the integers written on the N cards after the M operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i, C_i \\leq 10^9\n\n1 \\leq B_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\nB_1 C_1\nB_2 C_2\n\\vdots\nB_M C_M\n\nOutput\n\nPrint the maximum possible sum of the integers written on the N cards after the M operations.\n\nSample Input 1\n\n3 2\n5 1 4\n2 3\n1 5\n\nSample Output 1\n\n14\n\nBy replacing the integer on the second card with 5, the sum of the integers written on the three cards becomes 5 + 5 + 4 = 14, which is the maximum result.\n\nSample Input 2\n\n10 3\n1 8 5 7 100 4 52 33 13 5\n3 10\n4 30\n1 4\n\nSample Output 2\n\n338\n\nSample Input 3\n\n3 2\n100 100 100\n3 99\n3 99\n\nSample Output 3\n\n300\n\nSample Input 4\n\n11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000000\n\nSample Output 4\n\n10000000001\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "3 2\n5 1 4\n2 3\n1 5\n"}, "reference_outputs": ["14\n"], "source_document_id": "p03038", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have N cards. On the i-th card, an integer A_i is written.\n\nFor each j = 1, 2, ..., M in this order, you will perform the following operation once:\n\nOperation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.\n\nFind the maximum possible sum of the integers written on the N cards after the M operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i, C_i \\leq 10^9\n\n1 \\leq B_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\nB_1 C_1\nB_2 C_2\n\\vdots\nB_M C_M\n\nOutput\n\nPrint the maximum possible sum of the integers written on the N cards after the M operations.\n\nSample Input 1\n\n3 2\n5 1 4\n2 3\n1 5\n\nSample Output 1\n\n14\n\nBy replacing the integer on the second card with 5, the sum of the integers written on the three cards becomes 5 + 5 + 4 = 14, which is the maximum result.\n\nSample Input 2\n\n10 3\n1 8 5 7 100 4 52 33 13 5\n3 10\n4 30\n1 4\n\nSample Output 2\n\n338\n\nSample Input 3\n\n3 2\n100 100 100\n3 99\n3 99\n\nSample Output 3\n\n300\n\nSample Input 4\n\n11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000000\n\nSample Output 4\n\n10000000001\n\nThe output may not fit into a 32-bit integer type.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1766, "cpu_time_ms": 787, "memory_kb": 68440}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s953004065", "group_id": "codeNet:p03038", "input_text": "import java.util.*;\nclass Main {\n public static void main(String[] args) {\n\tScanner sc = new Scanner(System.in);\n\tint n = Integer.parseInt(sc.next());\n\tint m = Integer.parseInt(sc.next());\n\tlong[] a = new long[n];\n\tlong[] sum = new long[n+1];\n\n\tfor(int i = 0; i0; j--) {\n\t\tif(a[j-1]>c) continue;\n\t\t//System.out.println(\"sumn: \" + sum[n] + \" sumb \" + sum[j] + \" cb \" + (c*j) + \" max? \" + (sum[n]-sum[j]+c*j));\n\t\tmax = Math.max(max, sum[n]-sum[j]+c*j);\n\n\t\tfor(int k = 0; k0; j--) {\n\t\tif(a[j-1]>c) continue;\n\t\t//System.out.println(\"sumn: \" + sum[n] + \" sumb \" + sum[j] + \" cb \" + (c*j) + \" max? \" + (sum[n]-sum[j]+c*j));\n\t\tmax = Math.max(max, sum[n]-sum[j]+c*j);\n\n\t\tfor(int k = 0; k12 || k==0) && t<=112){\n\t\t\tSystem.out.println(\"MMYY\");\n\t\t}else if(k<=12 && k!=0 && (t>112 || t==100)){\n\t\t\tSystem.out.println(\"YYMM\");\n\t\t}else if(k<=12 && t<=112 && k!=0 && t!=0){\n\t\t\tSystem.out.println(\"AMBIGUOUS\");\n\t\t}else{\n\t\t\tSystem.out.println(\"NA\");\n\t\t}\n\n\n\n\t}\n}\n", "language": "Java", "metadata": {"date": 1564874690, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03042.html", "problem_id": "p03042", "resource_group": "high_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/Java/s835711255.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s835711255", "user_id": "u251779460"}, "prompt_components": {"gold_output": "YYMM\n", "input_to_evaluate": "import java.util.*;\n\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n int s=sc.nextInt();\n\t\ts+=10000;\n\t\tint k=s%100; //下2桁\n\t\tint t=s/100; //上2桁\n\n\t\tif((k>12 || k==0) && t<=112){\n\t\t\tSystem.out.println(\"MMYY\");\n\t\t}else if(k<=12 && k!=0 && (t>112 || t==100)){\n\t\t\tSystem.out.println(\"YYMM\");\n\t\t}else if(k<=12 && t<=112 && k!=0 && t!=0){\n\t\t\tSystem.out.println(\"AMBIGUOUS\");\n\t\t}else{\n\t\t\tSystem.out.println(\"NA\");\n\t\t}\n\n\n\n\t}\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have a digit sequence S of length 4. You are wondering which of the following formats S is in:\n\nYYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order\n\nMMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order\n\nIf S is valid in only YYMM format, print YYMM; if S is valid in only MMYY format, print MMYY; if S is valid in both formats, print AMBIGUOUS; if S is valid in neither format, print NA.\n\nConstraints\n\nS is a digit sequence of length 4.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the specified string: YYMM, MMYY, AMBIGUOUS or NA.\n\nSample Input 1\n\n1905\n\nSample Output 1\n\nYYMM\n\nMay XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.\n\nSample Input 2\n\n0112\n\nSample Output 2\n\nAMBIGUOUS\n\nBoth December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.\n\nSample Input 3\n\n1700\n\nSample Output 3\n\nNA\n\nNeither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.", "sample_input": "1905\n"}, "reference_outputs": ["YYMM\n"], "source_document_id": "p03042", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have a digit sequence S of length 4. You are wondering which of the following formats S is in:\n\nYYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order\n\nMMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order\n\nIf S is valid in only YYMM format, print YYMM; if S is valid in only MMYY format, print MMYY; if S is valid in both formats, print AMBIGUOUS; if S is valid in neither format, print NA.\n\nConstraints\n\nS is a digit sequence of length 4.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the specified string: YYMM, MMYY, AMBIGUOUS or NA.\n\nSample Input 1\n\n1905\n\nSample Output 1\n\nYYMM\n\nMay XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.\n\nSample Input 2\n\n0112\n\nSample Output 2\n\nAMBIGUOUS\n\nBoth December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.\n\nSample Input 3\n\n1700\n\nSample Output 3\n\nNA\n\nNeither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 488, "cpu_time_ms": 105, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s314841827", "group_id": "codeNet:p03043", "input_text": "import java.math.BigDecimal;\nimport java.util.Scanner;\n\npublic class Main {\n\n private static Scanner sc = new Scanner(System.in);\n\n public static void main(String[] args) {\n\n int n = sc.nextInt();\n int k = sc.nextInt();\n\n BigDecimal ans = new BigDecimal(0);\n\n BigDecimal nbd = new BigDecimal(n);\n BigDecimal add;\n for (int i=1; i <= n; i++) {\n add = new BigDecimal(\"0.5\").pow(countPowOf2(k, i)).divide(nbd, 12, BigDecimal.ROUND_HALF_UP);\n\n ans = ans.add(add);\n }\n\n System.out.println(ans.toString());\n }\n\n private static int countPowOf2(int target, int orig) {\n int pow = 0;\n while (orig < target) {\n orig *= 2;\n pow++;\n }\n return pow;\n }\n\n}\n", "language": "Java", "metadata": {"date": 1558315325, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03043.html", "problem_id": "p03043", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03043/input.txt", "sample_output_relpath": "derived/input_output/data/p03043/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03043/Java/s314841827.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s314841827", "user_id": "u546047488"}, "prompt_components": {"gold_output": "0.145833333333\n", "input_to_evaluate": "import java.math.BigDecimal;\nimport java.util.Scanner;\n\npublic class Main {\n\n private static Scanner sc = new Scanner(System.in);\n\n public static void main(String[] args) {\n\n int n = sc.nextInt();\n int k = sc.nextInt();\n\n BigDecimal ans = new BigDecimal(0);\n\n BigDecimal nbd = new BigDecimal(n);\n BigDecimal add;\n for (int i=1; i <= n; i++) {\n add = new BigDecimal(\"0.5\").pow(countPowOf2(k, i)).divide(nbd, 12, BigDecimal.ROUND_HALF_UP);\n\n ans = ans.add(add);\n }\n\n System.out.println(ans.toString());\n }\n\n private static int countPowOf2(int target, int orig) {\n int pow = 0;\n while (orig < target) {\n orig *= 2;\n pow++;\n }\n return pow;\n }\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has a fair N-sided die that shows the integers from 1 to N with equal probability and a fair coin. He will play the following game with them:\n\nThrow the die. The current score is the result of the die.\n\nAs long as the score is between 1 and K-1 (inclusive), keep flipping the coin. The score is doubled each time the coin lands heads up, and the score becomes 0 if the coin lands tails up.\n\nThe game ends when the score becomes 0 or becomes K or above. Snuke wins if the score is K or above, and loses if the score is 0.\n\nYou are given N and K. Find the probability that Snuke wins the game.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ K ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the probability that Snuke wins the game. The output is considered correct when the absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n3 10\n\nSample Output 1\n\n0.145833333333\n\nIf the die shows 1, Snuke needs to get four consecutive heads from four coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^4 = \\frac{1}{48}.\n\nIf the die shows 2, Snuke needs to get three consecutive heads from three coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^3 = \\frac{1}{24}.\n\nIf the die shows 3, Snuke needs to get two consecutive heads from two coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^2 = \\frac{1}{12}.\n\nThus, the probability that Snuke wins is \\frac{1}{48} + \\frac{1}{24} + \\frac{1}{12} = \\frac{7}{48} \\simeq 0.1458333333.\n\nSample Input 2\n\n100000 5\n\nSample Output 2\n\n0.999973749998", "sample_input": "3 10\n"}, "reference_outputs": ["0.145833333333\n"], "source_document_id": "p03043", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has a fair N-sided die that shows the integers from 1 to N with equal probability and a fair coin. He will play the following game with them:\n\nThrow the die. The current score is the result of the die.\n\nAs long as the score is between 1 and K-1 (inclusive), keep flipping the coin. The score is doubled each time the coin lands heads up, and the score becomes 0 if the coin lands tails up.\n\nThe game ends when the score becomes 0 or becomes K or above. Snuke wins if the score is K or above, and loses if the score is 0.\n\nYou are given N and K. Find the probability that Snuke wins the game.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ K ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the probability that Snuke wins the game. The output is considered correct when the absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n3 10\n\nSample Output 1\n\n0.145833333333\n\nIf the die shows 1, Snuke needs to get four consecutive heads from four coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^4 = \\frac{1}{48}.\n\nIf the die shows 2, Snuke needs to get three consecutive heads from three coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^3 = \\frac{1}{24}.\n\nIf the die shows 3, Snuke needs to get two consecutive heads from two coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^2 = \\frac{1}{12}.\n\nThus, the probability that Snuke wins is \\frac{1}{48} + \\frac{1}{24} + \\frac{1}{12} = \\frac{7}{48} \\simeq 0.1458333333.\n\nSample Input 2\n\n100000 5\n\nSample Output 2\n\n0.999973749998", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 785, "cpu_time_ms": 172, "memory_kb": 39508}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s842136626", "group_id": "codeNet:p03044", "input_text": "import java.util.ArrayDeque;\nimport java.util.ArrayList;\nimport java.util.Deque;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Scanner;\n\npublic class Main {\n public static void debug(String str) {\n boolean debug = false;\n if (debug == false) {\n return;\n }\n System.out.println(str);\n }\n\n public static class Edge {\n int u;\n int v;\n int w;\n\n public Edge(int u, int v, int w) {\n this.u = u;\n this.v = v;\n this.w = w;\n\n }\n }\n\n public static void main(String[] args) {\n\n int N;\n HashMap> set;\n\n try (Scanner sc = new Scanner(System.in)) {\n N = sc.nextInt();\n set = new HashMap<>();\n for (int i = 0; i < N - 1; i++) {\n int u = sc.nextInt();\n int v = sc.nextInt();\n int w = sc.nextInt();\n Edge e = new Edge(u, v, w);\n setSet(set,e,u);\n setSet(set,e,v);\n }\n }\n int[] distans = new int[N];\n HashSet visited = new HashSet<>();\n Deque queue = new ArrayDeque<>();\n queue.push(1);\n distans[0] = 0;\n Integer target;\n while((target = queue.pollFirst()) != null){\n List list = set.get(target);\n for(Edge e : list){\n if(visited.contains(e)){\n continue;\n }else{\n if(e.u != target && e.v == target){\n queue.addLast(e.u);\n distans[e.u -1] = distans[target-1] + e.w;\n debug(e.u+\":\" + distans[e.u -1] );\n }else if(e.v != target && e.u == target){\n queue.addLast(e.v);\n distans[e.v -1] = distans[target-1] + e.w;\n debug(e.v+\":\"+distans[e.v -1]);\n }\n visited.add(e);\n }\n }\n }\n for(int i : distans){\n System.out.println(i%2);\n }\n }\n\n private static void setSet(HashMap> set,Edge e, int i){\n List list = set.get(i);\n if(list == null){\n list = new ArrayList<>();\n }\n list.add(e);\n set.put(i, list);\n }\n\n}\n", "language": "Java", "metadata": {"date": 1562388316, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03044.html", "problem_id": "p03044", "resource_group": "high_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/Java/s842136626.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s842136626", "user_id": "u499889187"}, "prompt_components": {"gold_output": "0\n0\n1\n", "input_to_evaluate": "import java.util.ArrayDeque;\nimport java.util.ArrayList;\nimport java.util.Deque;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Scanner;\n\npublic class Main {\n public static void debug(String str) {\n boolean debug = false;\n if (debug == false) {\n return;\n }\n System.out.println(str);\n }\n\n public static class Edge {\n int u;\n int v;\n int w;\n\n public Edge(int u, int v, int w) {\n this.u = u;\n this.v = v;\n this.w = w;\n\n }\n }\n\n public static void main(String[] args) {\n\n int N;\n HashMap> set;\n\n try (Scanner sc = new Scanner(System.in)) {\n N = sc.nextInt();\n set = new HashMap<>();\n for (int i = 0; i < N - 1; i++) {\n int u = sc.nextInt();\n int v = sc.nextInt();\n int w = sc.nextInt();\n Edge e = new Edge(u, v, w);\n setSet(set,e,u);\n setSet(set,e,v);\n }\n }\n int[] distans = new int[N];\n HashSet visited = new HashSet<>();\n Deque queue = new ArrayDeque<>();\n queue.push(1);\n distans[0] = 0;\n Integer target;\n while((target = queue.pollFirst()) != null){\n List list = set.get(target);\n for(Edge e : list){\n if(visited.contains(e)){\n continue;\n }else{\n if(e.u != target && e.v == target){\n queue.addLast(e.u);\n distans[e.u -1] = distans[target-1] + e.w;\n debug(e.u+\":\" + distans[e.u -1] );\n }else if(e.v != target && e.u == target){\n queue.addLast(e.v);\n distans[e.v -1] = distans[target-1] + e.w;\n debug(e.v+\":\"+distans[e.v -1]);\n }\n visited.add(e);\n }\n }\n }\n for(int i : distans){\n System.out.println(i%2);\n }\n }\n\n private static void setSet(HashMap> set,Edge e, int i){\n List list = set.get(i);\n if(list == null){\n list = new ArrayList<>();\n }\n list.add(e);\n set.put(i, list);\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": 2424, "cpu_time_ms": 1396, "memory_kb": 108712}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s384620338", "group_id": "codeNet:p03045", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.StringTokenizer;\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author Jaynil\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n E1Or2 solver = new E1Or2();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class E1Or2 {\n public void solve(int testNumber, InputReader in, PrintWriter out) {\n int n = in.nextInt();\n int m = in.nextInt();\n DSet d = new DSet(n);\n for (int i = 0; i < m; i++) {\n d.union(in.nextInt(), in.nextInt());\n int temp = in.nextInt();\n }\n out.println(d.getClusters());\n }\n\n }\n\n static class DSet {\n int parent[];\n int rank[];\n int size;\n\n DSet(int n) {\n parent = new int[n + 1];\n rank = new int[n + 1];\n size = n;\n for (int i = 0; i <= n; i++) {\n this.parent[i] = i;\n }\n }\n\n public int find(int i) {\n if (parent[i] == i) return i;\n else {\n int result = find(parent[i]);\n parent[i] = result;\n return result;\n }\n }\n\n public int getClusters() {\n return size;\n }\n\n public void union(int i, int j) {\n int ipar = this.find(i);\n int jpar = this.find(j);\n if (ipar == jpar) {\n return;\n }\n int irank = this.rank[ipar];\n int jrank = this.rank[jpar];\n if (irank < jrank) {\n this.parent[ipar] = jpar;\n } else if (jrank < irank) {\n this.parent[jpar] = ipar;\n } else {\n this.parent[ipar] = jpar;\n this.rank[jpar]++;\n }\n size--;\n }\n\n }\n\n static class InputReader {\n public BufferedReader reader;\n public StringTokenizer tokenizer;\n\n public InputReader(InputStream stream) {\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\n tokenizer = null;\n }\n\n public String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1574143509, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03045.html", "problem_id": "p03045", "resource_group": "high_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/Java/s384620338.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s384620338", "user_id": "u264547643"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.StringTokenizer;\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author Jaynil\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n E1Or2 solver = new E1Or2();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class E1Or2 {\n public void solve(int testNumber, InputReader in, PrintWriter out) {\n int n = in.nextInt();\n int m = in.nextInt();\n DSet d = new DSet(n);\n for (int i = 0; i < m; i++) {\n d.union(in.nextInt(), in.nextInt());\n int temp = in.nextInt();\n }\n out.println(d.getClusters());\n }\n\n }\n\n static class DSet {\n int parent[];\n int rank[];\n int size;\n\n DSet(int n) {\n parent = new int[n + 1];\n rank = new int[n + 1];\n size = n;\n for (int i = 0; i <= n; i++) {\n this.parent[i] = i;\n }\n }\n\n public int find(int i) {\n if (parent[i] == i) return i;\n else {\n int result = find(parent[i]);\n parent[i] = result;\n return result;\n }\n }\n\n public int getClusters() {\n return size;\n }\n\n public void union(int i, int j) {\n int ipar = this.find(i);\n int jpar = this.find(j);\n if (ipar == jpar) {\n return;\n }\n int irank = this.rank[ipar];\n int jrank = this.rank[jpar];\n if (irank < jrank) {\n this.parent[ipar] = jpar;\n } else if (jrank < irank) {\n this.parent[jpar] = ipar;\n } else {\n this.parent[ipar] = jpar;\n this.rank[jpar]++;\n }\n size--;\n }\n\n }\n\n static class InputReader {\n public BufferedReader reader;\n public StringTokenizer tokenizer;\n\n public InputReader(InputStream stream) {\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\n tokenizer = null;\n }\n\n public String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n }\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": 3077, "cpu_time_ms": 226, "memory_kb": 46652}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s818949924", "group_id": "codeNet:p03049", "input_text": "import java.util.*;\nimport java.io.*;\nimport java.text.*;\npublic class Main{\n //SOLUTION BEGIN\n //This code is not meant for understanding, proceed with caution\n void pre() throws Exception{}\n void solve(int TC) throws Exception{\n int n = ni(), ans = 0;\n int[] cnt = new int[4];\n for(int i = 0; i< n; i++){\n String s= n();\n for(int j = 0; j< s.length()-1; j++)if(s.charAt(j)=='A' && s.charAt(j+1)=='B')ans++;\n int ty = 0;\n if(s.charAt(0)=='B')ty+=1;\n if(s.charAt(s.length()-1)=='A')ty+=2;\n cnt[ty]++;\n }\n if(cnt[2]+cnt[3]>0){\n if(cnt[2]>0)ans+=cnt[3]+Math.min(cnt[1], cnt[2]);\n else ans+= cnt[3]-1+(cnt[1]>0?1:0);\n }\n pn(ans);\n }\n class Pair{\n int ty;\n String s;\n public Pair(String S){\n s = S;\n if(s.charAt(0)=='B')ty+=1;\n if(s.charAt(s.length()-1)=='A')ty+=2;\n \n }\n }\n //SOLUTION END\n void hold(boolean b)throws Exception{if(!b)throw new Exception(\"Hold right there, Sparky!\");}\n long mod = (long)998244353, IINF = (long)1e18;\n final int INF = (int)1e9, MX = (int)1e5+1;\n DecimalFormat df = new DecimalFormat(\"0.00000000000\");\n double PI = 3.1415926535897932384626433832792884197169399375105820974944, eps = 1e-8;\n static boolean multipleTC = false, memory = false;\n FastReader in;PrintWriter out;\n void run() throws Exception{\n in = new FastReader();\n out = new PrintWriter(System.out);\n int T = (multipleTC)?ni():1;\n pre();for(int t = 1; t<= T; t++)solve(t);\n out.flush();\n out.close();\n }\n public static void main(String[] args) throws Exception{\n if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, \"1\", 1 << 28).start();\n else new Main().run();\n }\n long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}\n int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}\n int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}\n void p(Object o){out.print(o);}\n void pn(Object o){out.println(o);}\n void pni(Object o){out.println(o);out.flush();}\n String n()throws Exception{return in.next();}\n String nln()throws Exception{return in.nextLine();}\n int ni()throws Exception{return Integer.parseInt(in.next());}\n long nl()throws Exception{return Long.parseLong(in.next());}\n double nd()throws Exception{return Double.parseDouble(in.next());}\n\n class FastReader{\n BufferedReader br;\n StringTokenizer st;\n public FastReader(){\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n\n public FastReader(String s) throws Exception{\n br = new BufferedReader(new FileReader(s));\n }\n\n String next() throws Exception{\n while (st == null || !st.hasMoreElements()){\n try{\n st = new StringTokenizer(br.readLine());\n }catch (IOException e){\n throw new Exception(e.toString());\n }\n }\n return st.nextToken();\n }\n\n String nextLine() throws Exception{\n String str = \"\";\n try{ \n str = br.readLine();\n }catch (IOException e){\n throw new Exception(e.toString());\n } \n return str;\n }\n }\n}", "language": "Java", "metadata": {"date": 1557650484, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03049.html", "problem_id": "p03049", "resource_group": "high_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/Java/s818949924.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s818949924", "user_id": "u136104392"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\nimport java.text.*;\npublic class Main{\n //SOLUTION BEGIN\n //This code is not meant for understanding, proceed with caution\n void pre() throws Exception{}\n void solve(int TC) throws Exception{\n int n = ni(), ans = 0;\n int[] cnt = new int[4];\n for(int i = 0; i< n; i++){\n String s= n();\n for(int j = 0; j< s.length()-1; j++)if(s.charAt(j)=='A' && s.charAt(j+1)=='B')ans++;\n int ty = 0;\n if(s.charAt(0)=='B')ty+=1;\n if(s.charAt(s.length()-1)=='A')ty+=2;\n cnt[ty]++;\n }\n if(cnt[2]+cnt[3]>0){\n if(cnt[2]>0)ans+=cnt[3]+Math.min(cnt[1], cnt[2]);\n else ans+= cnt[3]-1+(cnt[1]>0?1:0);\n }\n pn(ans);\n }\n class Pair{\n int ty;\n String s;\n public Pair(String S){\n s = S;\n if(s.charAt(0)=='B')ty+=1;\n if(s.charAt(s.length()-1)=='A')ty+=2;\n \n }\n }\n //SOLUTION END\n void hold(boolean b)throws Exception{if(!b)throw new Exception(\"Hold right there, Sparky!\");}\n long mod = (long)998244353, IINF = (long)1e18;\n final int INF = (int)1e9, MX = (int)1e5+1;\n DecimalFormat df = new DecimalFormat(\"0.00000000000\");\n double PI = 3.1415926535897932384626433832792884197169399375105820974944, eps = 1e-8;\n static boolean multipleTC = false, memory = false;\n FastReader in;PrintWriter out;\n void run() throws Exception{\n in = new FastReader();\n out = new PrintWriter(System.out);\n int T = (multipleTC)?ni():1;\n pre();for(int t = 1; t<= T; t++)solve(t);\n out.flush();\n out.close();\n }\n public static void main(String[] args) throws Exception{\n if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, \"1\", 1 << 28).start();\n else new Main().run();\n }\n long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}\n int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}\n int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}\n void p(Object o){out.print(o);}\n void pn(Object o){out.println(o);}\n void pni(Object o){out.println(o);out.flush();}\n String n()throws Exception{return in.next();}\n String nln()throws Exception{return in.nextLine();}\n int ni()throws Exception{return Integer.parseInt(in.next());}\n long nl()throws Exception{return Long.parseLong(in.next());}\n double nd()throws Exception{return Double.parseDouble(in.next());}\n\n class FastReader{\n BufferedReader br;\n StringTokenizer st;\n public FastReader(){\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n\n public FastReader(String s) throws Exception{\n br = new BufferedReader(new FileReader(s));\n }\n\n String next() throws Exception{\n while (st == null || !st.hasMoreElements()){\n try{\n st = new StringTokenizer(br.readLine());\n }catch (IOException e){\n throw new Exception(e.toString());\n }\n }\n return st.nextToken();\n }\n\n String nextLine() throws Exception{\n String str = \"\";\n try{ \n str = br.readLine();\n }catch (IOException e){\n throw new Exception(e.toString());\n } \n return str;\n }\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has N strings. The i-th string is s_i.\n\nLet us concatenate these strings into one string after arranging them in some order.\nFind the maximum possible number of occurrences of AB in the resulting string.\n\nConstraints\n\n1 \\leq N \\leq 10^{4}\n\n2 \\leq |s_i| \\leq 10\n\ns_i consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\n\\vdots\ns_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\nABCA\nXBAZ\nBAD\n\nSample Output 1\n\n2\n\nFor example, if we concatenate ABCA, BAD and XBAZ in this order, the resulting string ABCABADXBAZ has two occurrences of AB.\n\nSample Input 2\n\n9\nBEWPVCRWH\nZZNQYIJX\nBAVREA\nPA\nHJMYITEOX\nBCJHMRMNK\nBP\nQVFABZ\nPRGKSPUNA\n\nSample Output 2\n\n4\n\nSample Input 3\n\n7\nRABYBBE\nJOZ\nBMHQUVA\nBPA\nISU\nMCMABAOBHZ\nSZMEHMA\n\nSample Output 3\n\n4", "sample_input": "3\nABCA\nXBAZ\nBAD\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03049", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has N strings. The i-th string is s_i.\n\nLet us concatenate these strings into one string after arranging them in some order.\nFind the maximum possible number of occurrences of AB in the resulting string.\n\nConstraints\n\n1 \\leq N \\leq 10^{4}\n\n2 \\leq |s_i| \\leq 10\n\ns_i consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\n\\vdots\ns_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\nABCA\nXBAZ\nBAD\n\nSample Output 1\n\n2\n\nFor example, if we concatenate ABCA, BAD and XBAZ in this order, the resulting string ABCABADXBAZ has two occurrences of AB.\n\nSample Input 2\n\n9\nBEWPVCRWH\nZZNQYIJX\nBAVREA\nPA\nHJMYITEOX\nBCJHMRMNK\nBP\nQVFABZ\nPRGKSPUNA\n\nSample Output 2\n\n4\n\nSample Input 3\n\n7\nRABYBBE\nJOZ\nBMHQUVA\nBPA\nISU\nMCMABAOBHZ\nSZMEHMA\n\nSample Output 3\n\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3492, "cpu_time_ms": 143, "memory_kb": 26068}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s636467931", "group_id": "codeNet:p03049", "input_text": "\nimport java.util.*;\n\npublic class Main {\n\n void run() {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int ans = 0;\n LinkedList as = new LinkedList<>(), bs = new LinkedList<>();\n HashSet ain = new HashSet<>();\n\n for (int i = 0; i < n; i++) {\n String s = sc.next();\n for (int j = s.length() - 2; j > 0; j--) {\n if (s.charAt(j - 1) == 'A' && s.charAt(j) == 'B') ans++;\n }\n if (s.charAt(0) == 'B') {\n if (s.charAt(s.length() - 1) == 'A') bs.addFirst(i);\n else bs.addLast(i);\n }\n if (s.charAt(s.length() - 1) == 'A') {\n if (s.charAt(0) == 'B') {\n as.addLast(i);\n } else {\n as.addFirst(i);\n }\n ain.add(i);\n }\n }\n// debug(ans, as, bs);\n\n boolean[] used = new boolean[n];\n if (!as.isEmpty()) {\n int i = as.removeFirst();\n while (!bs.isEmpty()) {\n if (ain.contains(i)) {\n // nothing\n } else {\n used[i] = true;\n while (!as.isEmpty() && used[i]) i = as.removeFirst();\n if (used[i]) break;\n }\n used[i] = true;\n while (!bs.isEmpty()) {\n int j = bs.remove();\n if (used[j]) continue;\n// debug(i, j);\n i = j;\n ans++;\n break;\n }\n }\n }\n System.out.println(ans);\n }\n\n void debug(Object...os) {\n System.err.println(Arrays.deepToString(os));\n }\n\n public static void main(String[] args) {\n new Main().run();\n }\n}\n", "language": "Java", "metadata": {"date": 1557628107, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03049.html", "problem_id": "p03049", "resource_group": "high_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/Java/s636467931.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s636467931", "user_id": "u726872801"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\nimport java.util.*;\n\npublic class Main {\n\n void run() {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int ans = 0;\n LinkedList as = new LinkedList<>(), bs = new LinkedList<>();\n HashSet ain = new HashSet<>();\n\n for (int i = 0; i < n; i++) {\n String s = sc.next();\n for (int j = s.length() - 2; j > 0; j--) {\n if (s.charAt(j - 1) == 'A' && s.charAt(j) == 'B') ans++;\n }\n if (s.charAt(0) == 'B') {\n if (s.charAt(s.length() - 1) == 'A') bs.addFirst(i);\n else bs.addLast(i);\n }\n if (s.charAt(s.length() - 1) == 'A') {\n if (s.charAt(0) == 'B') {\n as.addLast(i);\n } else {\n as.addFirst(i);\n }\n ain.add(i);\n }\n }\n// debug(ans, as, bs);\n\n boolean[] used = new boolean[n];\n if (!as.isEmpty()) {\n int i = as.removeFirst();\n while (!bs.isEmpty()) {\n if (ain.contains(i)) {\n // nothing\n } else {\n used[i] = true;\n while (!as.isEmpty() && used[i]) i = as.removeFirst();\n if (used[i]) break;\n }\n used[i] = true;\n while (!bs.isEmpty()) {\n int j = bs.remove();\n if (used[j]) continue;\n// debug(i, j);\n i = j;\n ans++;\n break;\n }\n }\n }\n System.out.println(ans);\n }\n\n void debug(Object...os) {\n System.err.println(Arrays.deepToString(os));\n }\n\n public static void main(String[] args) {\n new Main().run();\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has N strings. The i-th string is s_i.\n\nLet us concatenate these strings into one string after arranging them in some order.\nFind the maximum possible number of occurrences of AB in the resulting string.\n\nConstraints\n\n1 \\leq N \\leq 10^{4}\n\n2 \\leq |s_i| \\leq 10\n\ns_i consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\n\\vdots\ns_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\nABCA\nXBAZ\nBAD\n\nSample Output 1\n\n2\n\nFor example, if we concatenate ABCA, BAD and XBAZ in this order, the resulting string ABCABADXBAZ has two occurrences of AB.\n\nSample Input 2\n\n9\nBEWPVCRWH\nZZNQYIJX\nBAVREA\nPA\nHJMYITEOX\nBCJHMRMNK\nBP\nQVFABZ\nPRGKSPUNA\n\nSample Output 2\n\n4\n\nSample Input 3\n\n7\nRABYBBE\nJOZ\nBMHQUVA\nBPA\nISU\nMCMABAOBHZ\nSZMEHMA\n\nSample Output 3\n\n4", "sample_input": "3\nABCA\nXBAZ\nBAD\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03049", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has N strings. The i-th string is s_i.\n\nLet us concatenate these strings into one string after arranging them in some order.\nFind the maximum possible number of occurrences of AB in the resulting string.\n\nConstraints\n\n1 \\leq N \\leq 10^{4}\n\n2 \\leq |s_i| \\leq 10\n\ns_i consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\n\\vdots\ns_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\nABCA\nXBAZ\nBAD\n\nSample Output 1\n\n2\n\nFor example, if we concatenate ABCA, BAD and XBAZ in this order, the resulting string ABCABADXBAZ has two occurrences of AB.\n\nSample Input 2\n\n9\nBEWPVCRWH\nZZNQYIJX\nBAVREA\nPA\nHJMYITEOX\nBCJHMRMNK\nBP\nQVFABZ\nPRGKSPUNA\n\nSample Output 2\n\n4\n\nSample Input 3\n\n7\nRABYBBE\nJOZ\nBMHQUVA\nBPA\nISU\nMCMABAOBHZ\nSZMEHMA\n\nSample Output 3\n\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1871, "cpu_time_ms": 188, "memory_kb": 33440}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s922657264", "group_id": "codeNet:p03051", "input_text": "import java.util.*;\nimport java.lang.*;\n\nimport java.util.*;\nimport java.io.*;\n\nclass Mod{\n static final long MOD = 1000_000_007;\n static final long[] fact = makeFactorialArray(1000000);\n static final long[] factInv = makeInversedArray(fact);\n\n public static long add(long a, long b){\n long tmp = (a+b)%MOD;\n return tmp>=0 ? tmp : tmp+MOD;\n }\n public static long sub(long a, long b){\n return add(a,-b);\n }\n public static long mult(long a, long b){\n long tmp = (a*b)%MOD;\n return tmp>=0 ? tmp : tmp+MOD;\n }\n public static long power(long a, long x){ //calculate a^x\n if(x<0)return 0;\n if(x==0)return 1;\n if(x%2==0) {\n long half = power(a,x/2);\n return mult(half,half);\n }\n return (a*power(a,x-1)) % MOD;\n }\n public static long inverse(long a){\n return power(a,MOD-2);\n }\n public static long div(long a, long b){\n return mult(a, inverse(b));\n }\n public static long[] makeFactorialArray(int size){\n long[] array = new long[size];\n array[0]=1;\n for(int i=1;i extends HashMap{\n long def;\n public Counter(long d){\n super();def=d;\n }\n public Long get(Object elm){\n return getOrDefault(elm,def);\n }\n public void add(T elm, long amount){\n if(!this.containsKey(elm)) put(elm, Mod.add(def,amount));\n else replace(elm, Mod.add(get(elm),amount));\n }\n public void addOne(T elm){\n add(elm, 1L);\n }\n\n}\npublic class Main {\n static int countAB(String s){\n return (s.length() - s.replaceAll(\"AB\", \"\").length()) / 2;\n }\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n\n int N = sc.nextInt();\n long[] A = new long[N];\n for(int n=0; n counter0 = new Counter<>(1);\n Counter counterX = new Counter<>(0);\n for(int n=1; n=0 ? tmp : tmp+MOD;\n }\n public static long sub(long a, long b){\n return add(a,-b);\n }\n public static long mult(long a, long b){\n long tmp = (a*b)%MOD;\n return tmp>=0 ? tmp : tmp+MOD;\n }\n public static long power(long a, long x){ //calculate a^x\n if(x<0)return 0;\n if(x==0)return 1;\n if(x%2==0) {\n long half = power(a,x/2);\n return mult(half,half);\n }\n return (a*power(a,x-1)) % MOD;\n }\n public static long inverse(long a){\n return power(a,MOD-2);\n }\n public static long div(long a, long b){\n return mult(a, inverse(b));\n }\n public static long[] makeFactorialArray(int size){\n long[] array = new long[size];\n array[0]=1;\n for(int i=1;i extends HashMap{\n long def;\n public Counter(long d){\n super();def=d;\n }\n public Long get(Object elm){\n return getOrDefault(elm,def);\n }\n public void add(T elm, long amount){\n if(!this.containsKey(elm)) put(elm, Mod.add(def,amount));\n else replace(elm, Mod.add(get(elm),amount));\n }\n public void addOne(T elm){\n add(elm, 1L);\n }\n\n}\npublic class Main {\n static int countAB(String s){\n return (s.length() - s.replaceAll(\"AB\", \"\").length()) / 2;\n }\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n\n int N = sc.nextInt();\n long[] A = new long[N];\n for(int n=0; n counter0 = new Counter<>(1);\n Counter counterX = new Counter<>(0);\n for(int n=1; n W || y <= 0 || y > H){\n\t\t\t\t\tSystem.out.println(\"NO\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif(A.charAt(j) == a.charAt(i)){\n\t\t\t\t\tif(x + dxa[i] >= 1 && x + dxa[i] <= W && y + dya[i] >= 0 && y + dya[i] <= H){\n\t\t\t\t\t\tx += dxa[i];\n\t\t\t\t\t\ty += dya[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(\"YES\");\n\t}\n\t\n\t/* end solve */\n\t\n\t/* main */\n\tpublic static void main(String[] args) throws Exception {\n\t\tnew Main().m();\n\t}\n\t\n\tvoid m() throws Exception {\n\t\tlong S = System.currentTimeMillis();\n\t\tsc = (isDebug) ? new FastScanner(new FileInputStream(fileName)) : new FastScanner(System.in);\n\t\tout = new PrintWriter(System.out);\n\t\tsolve();\n\t\tout.flush();\n\t\tlong G = System.currentTimeMillis();\n\t\tif(isDebug){\n\t\t\tSystem.out.println(\"---Debug---\");\n\t\t\tSystem.out.printf(\"%8d ms\", (G-S));\n\t\t}\n\t}\n\t/* end main */\n}\n/* end Main */\n\nclass FastScanner {\n private InputStream in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n public FastScanner(InputStream in) {\n\t\tthis.in = in;\n\t}\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n }else{\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n private int readByte() {\n \tif (hasNextByte()) return buffer[ptr++];\n \telse return -1;\n }\n private static boolean isPrintableChar(int c){\n \treturn 33 <= c && c <= 126;\n }\n public boolean hasNext() {\n \twhile(hasNextByte() && !isPrintableChar(buffer[ptr]))\n \t\tptr++; return hasNextByte();\n }\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while(isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n public String nextLine() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while(b != 10) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while(true){\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n public double nextDouble() {\n \treturn Double.parseDouble(next());\n }\n}", "language": "Java", "metadata": {"date": 1557027145, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03054.html", "problem_id": "p03054", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03054/input.txt", "sample_output_relpath": "derived/input_output/data/p03054/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03054/Java/s252818434.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s252818434", "user_id": "u234826697"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\nimport java.util.Map.Entry;\nimport java.util.stream.Collectors;\n\n@SuppressWarnings(\"unused\")\npublic class Main {\n\t\n\t//final boolean isDebug = true;\n\tfinal boolean isDebug = false;\n\tString fileName = \"input.txt\";\n\tFastScanner sc;\n\tPrintWriter out;\n\tfinal int MOD = (int)1e9+7;\n\tfinal int INF = Integer.MAX_VALUE / 2;\n\t\n\tvoid solve() throws Exception{\n\t\tint H = sc.nextInt();\n\t\tint W = sc.nextInt();\n\t\tint N = sc.nextInt();\n\t\tint sx = sc.nextInt(), sy = sc.nextInt();\n\t\tString T = sc.next();\n\t\tString A = sc.next();\n\t\tString t = \"LRUD\";\n\t\tString a = \"RLDU\";\n\t\tint[] dyt = {0, 0, -1, 1};\n\t\tint[] dya = {0, 0, 1, -1};\n\t\tint[] dxt = {-1, 1, 0, 0};\n\t\tint[] dxa = {1, -1, 0, 0};\n\t\t\n\t\tfor(int i = 0; i < 4; i++){\n\t\t\tint x = sx, y = sy;\n\t\t\tfor(int j = 0; j < N; j++){\n\t\t\t\tif(T.charAt(j) == t.charAt(i)){\n\t\t\t\t\tx += dxt[i];\n\t\t\t\t\ty += dyt[i];\n\t\t\t\t}\n\t\t\t\tif(x <= 0 || x > W || y <= 0 || y > H){\n\t\t\t\t\tSystem.out.println(\"NO\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif(A.charAt(j) == a.charAt(i)){\n\t\t\t\t\tif(x + dxa[i] >= 1 && x + dxa[i] <= W && y + dya[i] >= 0 && y + dya[i] <= H){\n\t\t\t\t\t\tx += dxa[i];\n\t\t\t\t\t\ty += dya[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(\"YES\");\n\t}\n\t\n\t/* end solve */\n\t\n\t/* main */\n\tpublic static void main(String[] args) throws Exception {\n\t\tnew Main().m();\n\t}\n\t\n\tvoid m() throws Exception {\n\t\tlong S = System.currentTimeMillis();\n\t\tsc = (isDebug) ? new FastScanner(new FileInputStream(fileName)) : new FastScanner(System.in);\n\t\tout = new PrintWriter(System.out);\n\t\tsolve();\n\t\tout.flush();\n\t\tlong G = System.currentTimeMillis();\n\t\tif(isDebug){\n\t\t\tSystem.out.println(\"---Debug---\");\n\t\t\tSystem.out.printf(\"%8d ms\", (G-S));\n\t\t}\n\t}\n\t/* end main */\n}\n/* end Main */\n\nclass FastScanner {\n private InputStream in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n public FastScanner(InputStream in) {\n\t\tthis.in = in;\n\t}\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n }else{\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n private int readByte() {\n \tif (hasNextByte()) return buffer[ptr++];\n \telse return -1;\n }\n private static boolean isPrintableChar(int c){\n \treturn 33 <= c && c <= 126;\n }\n public boolean hasNext() {\n \twhile(hasNextByte() && !isPrintableChar(buffer[ptr]))\n \t\tptr++; return hasNextByte();\n }\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while(isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n public String nextLine() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while(b != 10) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while(true){\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n public double nextDouble() {\n \treturn Double.parseDouble(next());\n }\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left.\nOn this grid, there is a piece, which is initially placed at square (s_r,s_c).\n\nTakahashi and Aoki will play a game, where each player has a string of length N.\nTakahashi's string is S, and Aoki's string is T. S and T both consist of four kinds of letters: L, R, U and D.\n\nThe game consists of N steps. The i-th step proceeds as follows:\n\nFirst, Takahashi performs a move. He either moves the piece in the direction of S_i, or does not move the piece.\n\nSecond, Aoki performs a move. He either moves the piece in the direction of T_i, or does not move the piece.\n\nHere, to move the piece in the direction of L, R, U and D, is to move the piece from square (r,c) to square (r,c-1), (r,c+1), (r-1,c) and (r+1,c), respectively. If the destination square does not exist, the piece is removed from the grid, and the game ends, even if less than N steps are done.\n\nTakahashi wants to remove the piece from the grid in one of the N steps.\nAoki, on the other hand, wants to finish the N steps with the piece remaining on the grid.\nDetermine if the piece will remain on the grid at the end of the game when both players play optimally.\n\nConstraints\n\n2 \\leq H,W \\leq 2 \\times 10^5\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq s_r \\leq H\n\n1 \\leq s_c \\leq W\n\n|S|=|T|=N\n\nS and T consists of the four kinds of letters L, R, U and D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W N\ns_r s_c\nS\nT\n\nOutput\n\nIf the piece will remain on the grid at the end of the game, print YES; otherwise, print NO.\n\nSample Input 1\n\n2 3 3\n2 2\nRRL\nLUD\n\nSample Output 1\n\nYES\n\nHere is one possible progress of the game:\n\nTakahashi moves the piece right. The piece is now at (2,3).\n\nAoki moves the piece left. The piece is now at (2,2).\n\nTakahashi does not move the piece. The piece remains at (2,2).\n\nAoki moves the piece up. The piece is now at (1,2).\n\nTakahashi moves the piece left. The piece is now at (1,1).\n\nAoki does not move the piece. The piece remains at (1,1).\n\nSample Input 2\n\n4 3 5\n2 2\nUDRRR\nLLDUD\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n5 6 11\n2 1\nRLDRRUDDLRL\nURRDRLLDLRD\n\nSample Output 3\n\nNO", "sample_input": "2 3 3\n2 2\nRRL\nLUD\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03054", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left.\nOn this grid, there is a piece, which is initially placed at square (s_r,s_c).\n\nTakahashi and Aoki will play a game, where each player has a string of length N.\nTakahashi's string is S, and Aoki's string is T. S and T both consist of four kinds of letters: L, R, U and D.\n\nThe game consists of N steps. The i-th step proceeds as follows:\n\nFirst, Takahashi performs a move. He either moves the piece in the direction of S_i, or does not move the piece.\n\nSecond, Aoki performs a move. He either moves the piece in the direction of T_i, or does not move the piece.\n\nHere, to move the piece in the direction of L, R, U and D, is to move the piece from square (r,c) to square (r,c-1), (r,c+1), (r-1,c) and (r+1,c), respectively. If the destination square does not exist, the piece is removed from the grid, and the game ends, even if less than N steps are done.\n\nTakahashi wants to remove the piece from the grid in one of the N steps.\nAoki, on the other hand, wants to finish the N steps with the piece remaining on the grid.\nDetermine if the piece will remain on the grid at the end of the game when both players play optimally.\n\nConstraints\n\n2 \\leq H,W \\leq 2 \\times 10^5\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq s_r \\leq H\n\n1 \\leq s_c \\leq W\n\n|S|=|T|=N\n\nS and T consists of the four kinds of letters L, R, U and D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W N\ns_r s_c\nS\nT\n\nOutput\n\nIf the piece will remain on the grid at the end of the game, print YES; otherwise, print NO.\n\nSample Input 1\n\n2 3 3\n2 2\nRRL\nLUD\n\nSample Output 1\n\nYES\n\nHere is one possible progress of the game:\n\nTakahashi moves the piece right. The piece is now at (2,3).\n\nAoki moves the piece left. The piece is now at (2,2).\n\nTakahashi does not move the piece. The piece remains at (2,2).\n\nAoki moves the piece up. The piece is now at (1,2).\n\nTakahashi moves the piece left. The piece is now at (1,1).\n\nAoki does not move the piece. The piece remains at (1,1).\n\nSample Input 2\n\n4 3 5\n2 2\nUDRRR\nLLDUD\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n5 6 11\n2 1\nRLDRRUDDLRL\nURRDRLLDLRD\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": 4172, "cpu_time_ms": 141, "memory_kb": 26324}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s906707936", "group_id": "codeNet:p03059", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t\n\t\ttry(Scanner sc = new Scanner(System.in)){\n\t\t\n\t\t\tint a = sc.nextInt();\n\t\t\tint b = sc.nextInt();\n\t\t\tint t = sc.nextInt();\n\t\t\t\n\t\t\tSystem.out.println(t / a * b);\n\t\t}\n\n\t}\n}\n", "language": "Java", "metadata": {"date": 1556413411, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03059.html", "problem_id": "p03059", "resource_group": "high_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/Java/s906707936.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s906707936", "user_id": "u650081733"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t\n\t\ttry(Scanner sc = new Scanner(System.in)){\n\t\t\n\t\t\tint a = sc.nextInt();\n\t\t\tint b = sc.nextInt();\n\t\t\tint t = sc.nextInt();\n\t\t\t\n\t\t\tSystem.out.println(t / a * b);\n\t\t}\n\n\t}\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": 263, "cpu_time_ms": 100, "memory_kb": 21204}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s556204533", "group_id": "codeNet:p03060", "input_text": "import java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n List valueList = new ArrayList<>();\n for (int i=0; i costList = new ArrayList<>();\n for (int i=0; i 0){\n totalBenefit += benefit;\n }\n }\n\n System.out.println(totalBenefit);\n }\n}", "language": "Java", "metadata": {"date": 1560527319, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03060.html", "problem_id": "p03060", "resource_group": "high_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/Java/s556204533.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s556204533", "user_id": "u853192329"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n List valueList = new ArrayList<>();\n for (int i=0; i costList = new ArrayList<>();\n for (int i=0; i 0){\n totalBenefit += benefit;\n }\n }\n\n System.out.println(totalBenefit);\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": 706, "cpu_time_ms": 108, "memory_kb": 22996}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s905488179", "group_id": "codeNet:p03060", "input_text": "import java.util.*;\n\nclass Main{\n public static void main(String[] args){\n\n Scanner sc = new Scanner(System.in);\n\n int N = sc.nextInt();\n int[] v;\n int[] c;\n\n v = new int[49];\n c = new int[49];\n N -=1;\n for(int i=0;i<=N;i++){\n v[i] = sc.nextInt();\n }\n for(int j=0;j<=N;j++){\n c[j] = sc.nextInt();\n }\n\n int X = v[0]+v[N];\n int Y = c[0]+c[N];\n\n int xy = X -Y;\n \n if(xy>0){\n System.out.println(xy);\n }else{\n System.out.println(0);\n }\n\n\n }\n}", "language": "Java", "metadata": {"date": 1556417493, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03060.html", "problem_id": "p03060", "resource_group": "high_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/Java/s905488179.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s905488179", "user_id": "u151015483"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*;\n\nclass Main{\n public static void main(String[] args){\n\n Scanner sc = new Scanner(System.in);\n\n int N = sc.nextInt();\n int[] v;\n int[] c;\n\n v = new int[49];\n c = new int[49];\n N -=1;\n for(int i=0;i<=N;i++){\n v[i] = sc.nextInt();\n }\n for(int j=0;j<=N;j++){\n c[j] = sc.nextInt();\n }\n\n int X = v[0]+v[N];\n int Y = c[0]+c[N];\n\n int xy = X -Y;\n \n if(xy>0){\n System.out.println(xy);\n }else{\n System.out.println(0);\n }\n\n\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N gems. The value of the i-th gem is V_i.\n\nYou will choose some of these gems, possibly all or none, and get them.\n\nHowever, you need to pay a cost of C_i to get the i-th gem.\n\nLet X be the sum of the values of the gems obtained, and Y be the sum of the costs paid.\n\nFind the maximum possible value of X-Y.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq C_i, V_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nV_1 V_2 ... V_N\nC_1 C_2 ... C_N\n\nOutput\n\nPrint the maximum possible value of X-Y.\n\nSample Input 1\n\n3\n10 2 5\n6 3 4\n\nSample Output 1\n\n5\n\nIf we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10.\nWe have X-Y = 5 here, which is the maximum possible value.\n\nSample Input 2\n\n4\n13 21 6 19\n11 30 6 15\n\nSample Output 2\n\n6\n\nSample Input 3\n\n1\n1\n50\n\nSample Output 3\n\n0", "sample_input": "3\n10 2 5\n6 3 4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03060", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N gems. The value of the i-th gem is V_i.\n\nYou will choose some of these gems, possibly all or none, and get them.\n\nHowever, you need to pay a cost of C_i to get the i-th gem.\n\nLet X be the sum of the values of the gems obtained, and Y be the sum of the costs paid.\n\nFind the maximum possible value of X-Y.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq C_i, V_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nV_1 V_2 ... V_N\nC_1 C_2 ... C_N\n\nOutput\n\nPrint the maximum possible value of X-Y.\n\nSample Input 1\n\n3\n10 2 5\n6 3 4\n\nSample Output 1\n\n5\n\nIf we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10.\nWe have X-Y = 5 here, which is the maximum possible value.\n\nSample Input 2\n\n4\n13 21 6 19\n11 30 6 15\n\nSample Output 2\n\n6\n\nSample Input 3\n\n1\n1\n50\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 613, "cpu_time_ms": 96, "memory_kb": 23764}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s898764399", "group_id": "codeNet:p03060", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\t\tpublic static void main(String[] args) {\n\t\t\tString strV, strC;\n\t\t\tint N, result = 0;\n\t\t\tint[] V = new int[20];\n\t\t\tint[] C = new int[20];\n\n\t\t\tScanner scN = new Scanner(System.in);\n\t\t\tN = Integer.parseInt(scN.nextLine());\n\t\t\tstrV = scN.nextLine();\n\t\t\tstrC = scN.nextLine();\n\n\t\t\tSystem.out.println(strC);\n\n\t\t\tfor (int i = 0; i < N; i++) {\n\t\t\t\tV[i] = Integer.parseInt(strV.split(\" \")[i]);\n\t\t\t\tC[i] = Integer.parseInt(strC.split(\" \")[i]);\n\t\t\t}\n\n\t\t\tfor (int i = 0; i < N; i++) {\n\t\t\t\tif (V[i] - C[i] > 0) {\n\t\t\t\t\tresult += V[i] - C[i];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tSystem.out.print(result);\n\n\t\t\tscN.close();\n\t\t}\n}", "language": "Java", "metadata": {"date": 1556416575, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03060.html", "problem_id": "p03060", "resource_group": "high_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/Java/s898764399.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s898764399", "user_id": "u518703962"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\t\tpublic static void main(String[] args) {\n\t\t\tString strV, strC;\n\t\t\tint N, result = 0;\n\t\t\tint[] V = new int[20];\n\t\t\tint[] C = new int[20];\n\n\t\t\tScanner scN = new Scanner(System.in);\n\t\t\tN = Integer.parseInt(scN.nextLine());\n\t\t\tstrV = scN.nextLine();\n\t\t\tstrC = scN.nextLine();\n\n\t\t\tSystem.out.println(strC);\n\n\t\t\tfor (int i = 0; i < N; i++) {\n\t\t\t\tV[i] = Integer.parseInt(strV.split(\" \")[i]);\n\t\t\t\tC[i] = Integer.parseInt(strC.split(\" \")[i]);\n\t\t\t}\n\n\t\t\tfor (int i = 0; i < N; i++) {\n\t\t\t\tif (V[i] - C[i] > 0) {\n\t\t\t\t\tresult += V[i] - C[i];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tSystem.out.print(result);\n\n\t\t\tscN.close();\n\t\t}\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": 640, "cpu_time_ms": 102, "memory_kb": 23380}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s666214737", "group_id": "codeNet:p03067", "input_text": "import java.io.IOException;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) throws IOException {\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n int c = sc.nextInt();\n\n if((a < c && c < b)||(b < c && c < a)) System.out.println(\"Yes\");\n else System.out.println(\"No\");\n\n }\n\n\n}\n", "language": "Java", "metadata": {"date": 1556150649, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03067.html", "problem_id": "p03067", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03067/input.txt", "sample_output_relpath": "derived/input_output/data/p03067/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03067/Java/s666214737.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s666214737", "user_id": "u310094554"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.IOException;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) throws IOException {\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n int c = sc.nextInt();\n\n if((a < c && c < b)||(b < c && c < a)) System.out.println(\"Yes\");\n else System.out.println(\"No\");\n\n }\n\n\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively.\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nConstraints\n\n0\\leq A,B,C\\leq 100\n\nA, B and C are distinct integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nSample Input 1\n\n3 8 5\n\nSample Output 1\n\nYes\n\nWe pass the coordinate 5 on the straight way from the house at coordinate 3 to the house at coordinate 8.\n\nSample Input 2\n\n7 3 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n10 2 4\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n31 41 59\n\nSample Output 4\n\nNo", "sample_input": "3 8 5\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03067", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively.\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nConstraints\n\n0\\leq A,B,C\\leq 100\n\nA, B and C are distinct integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nSample Input 1\n\n3 8 5\n\nSample Output 1\n\nYes\n\nWe pass the coordinate 5 on the straight way from the house at coordinate 3 to the house at coordinate 8.\n\nSample Input 2\n\n7 3 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n10 2 4\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n31 41 59\n\nSample Output 4\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 95, "memory_kb": 21588}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s867984435", "group_id": "codeNet:p03067", "input_text": "\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n // int times = Integer.parseInt(sc.nextLine());\n // int bit = 0;\n\n int x1 = Integer.parseInt(sc.nextLine());\n String s = sc.nextLine();\n\n int t1 = s.indexOf(\"#\");\n\n int cnt = 0;\n\n while (true) {\n if (t1 < 0)\n break;\n if (t1 + 1 >= x1)\n break;\n if (s.charAt(t1 + 1) == '.') {\n cnt++;\n }\n if (t1 + 1 >= x1) {\n break;\n } else {\n t1 = s.indexOf(\"#\", t1 + 1);\n }\n if (t1 >= x1 - 1) {\n break;\n } else if (t1 < 0) {\n break;\n }\n\n }\n\n System.out.println(cnt);\n sc.close();\n }\n}\n", "language": "Java", "metadata": {"date": 1555813610, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03067.html", "problem_id": "p03067", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03067/input.txt", "sample_output_relpath": "derived/input_output/data/p03067/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03067/Java/s867984435.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s867984435", "user_id": "u744470124"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n // int times = Integer.parseInt(sc.nextLine());\n // int bit = 0;\n\n int x1 = Integer.parseInt(sc.nextLine());\n String s = sc.nextLine();\n\n int t1 = s.indexOf(\"#\");\n\n int cnt = 0;\n\n while (true) {\n if (t1 < 0)\n break;\n if (t1 + 1 >= x1)\n break;\n if (s.charAt(t1 + 1) == '.') {\n cnt++;\n }\n if (t1 + 1 >= x1) {\n break;\n } else {\n t1 = s.indexOf(\"#\", t1 + 1);\n }\n if (t1 >= x1 - 1) {\n break;\n } else if (t1 < 0) {\n break;\n }\n\n }\n\n System.out.println(cnt);\n sc.close();\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively.\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nConstraints\n\n0\\leq A,B,C\\leq 100\n\nA, B and C are distinct integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nSample Input 1\n\n3 8 5\n\nSample Output 1\n\nYes\n\nWe pass the coordinate 5 on the straight way from the house at coordinate 3 to the house at coordinate 8.\n\nSample Input 2\n\n7 3 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n10 2 4\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n31 41 59\n\nSample Output 4\n\nNo", "sample_input": "3 8 5\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03067", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively.\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nConstraints\n\n0\\leq A,B,C\\leq 100\n\nA, B and C are distinct integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nSample Input 1\n\n3 8 5\n\nSample Output 1\n\nYes\n\nWe pass the coordinate 5 on the straight way from the house at coordinate 3 to the house at coordinate 8.\n\nSample Input 2\n\n7 3 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n10 2 4\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n31 41 59\n\nSample Output 4\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 897, "cpu_time_ms": 93, "memory_kb": 22868}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s316951836", "group_id": "codeNet:p03071", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int num1 = sc.nextInt();\n int num2 = sc.nextInt();\n int sum = 0;\n for(int i = 0; i < 2; i++){\n if(num1 < num2){\n sum += num2;\n num2--;\n } else {\n sum += num1;\n num1--;\n }\n }\n System.out.println(sum);\n }\n }", "language": "Java", "metadata": {"date": 1588169469, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03071.html", "problem_id": "p03071", "resource_group": "high_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/Java/s316951836.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s316951836", "user_id": "u073606136"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int num1 = sc.nextInt();\n int num2 = sc.nextInt();\n int sum = 0;\n for(int i = 0; i < 2; i++){\n if(num1 < num2){\n sum += num2;\n num2--;\n } else {\n sum += num1;\n num1--;\n }\n }\n System.out.println(sum);\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": 484, "cpu_time_ms": 93, "memory_kb": 21332}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s615864432", "group_id": "codeNet:p03072", "input_text": "import java.util.*;\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] h = new int[n];\n int max = 0;\n int count = 0;\n for(int i = 0;iA[i]){\n \t\t\t\tcheck = false;\n\n \t\t\t}\n\n \t\t\t}\n \t\tif(check = true ){\n \t\t\tans ++;\n \t\t}\n\n \t}\n \tSystem.out.println(ans);\n\n}\n\n}\n", "language": "Java", "metadata": {"date": 1559120103, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03072.html", "problem_id": "p03072", "resource_group": "high_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/Java/s981074953.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s981074953", "user_id": "u223718904"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner;\n\nclass Main {\n public static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n \tint N = sc.nextInt();\n \tint A[] = new int[N];\n \tint ans=0;\n \tboolean check = false;\n \tfor(int i =0;iA[i]){\n \t\t\t\tcheck = false;\n\n \t\t\t}\n\n \t\t\t}\n \t\tif(check = true ){\n \t\t\tans ++;\n \t\t}\n\n \t}\n \tSystem.out.println(ans);\n\n}\n\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "sample_input": "4\n6 5 6 8\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03072", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 546, "cpu_time_ms": 101, "memory_kb": 23764}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s095225342", "group_id": "codeNet:p03072", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tint [] h = new int[n];\n\t\tfor(int i = 0;i < n;i++){\n\t\t\th[i] = sc.nextInt();\n\t\t}\n\t\tint cnt = 1;\n\t\tint max = h[0];\n\t\tfor(int i = 0;i < n-1;i++){\n\t\t\tif(max < h[i+1]){\n\t\t\t\tcnt++;\n\t\t\t\tmax = h[i+1];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(cnt);\n\t}\n}", "language": "Java", "metadata": {"date": 1555191086, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03072.html", "problem_id": "p03072", "resource_group": "high_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/Java/s095225342.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s095225342", "user_id": "u247337392"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tint [] h = new int[n];\n\t\tfor(int i = 0;i < n;i++){\n\t\t\th[i] = sc.nextInt();\n\t\t}\n\t\tint cnt = 1;\n\t\tint max = h[0];\n\t\tfor(int i = 0;i < n-1;i++){\n\t\t\tif(max < h[i+1]){\n\t\t\t\tcnt++;\n\t\t\t\tmax = h[i+1];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(cnt);\n\t}\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": 388, "cpu_time_ms": 96, "memory_kb": 21972}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s401279551", "group_id": "codeNet:p03072", "input_text": "import java.util.Scanner;\n\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n=Integer.parseInt(sc.next());\n\t\tint h[]=new int[100];\n\t\tint sum=0;\n\t\tint j;\n\n\t\tfor(int i=0;i0;j--){\n\t\t\t\tif(i!=0&&h[i]0;j--){\n\t\t\t\tif(i!=0&&h[i]>i) == 0) {\n ans1++;\n }\n } else {\n if ((1 & l>>i) == 1) {\n ans1++;\n }\n }\n\n if (i%2 == 0) {\n if ((1 & l>>i) == 0) {\n ans2++;\n }\n } else {\n if ((1 & l>>i) == 1) {\n ans2++;\n }\n }\n\n }\n System.out.println(Math.min(ans1, ans2));\n }\n}", "language": "Java", "metadata": {"date": 1564519440, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03073.html", "problem_id": "p03073", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03073/input.txt", "sample_output_relpath": "derived/input_output/data/p03073/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03073/Java/s801158792.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s801158792", "user_id": "u087831989"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*;\n \nclass Main {\n \n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String s = sc.nextLine();\n long l = Long.parseLong(s, 2);\n \n long ans1 = 0;\n long ans2 = 0;\n for(long i = 0; i < s.length(); i++) {\n if (i%2 == 1) {\n if ((1 & l>>i) == 0) {\n ans1++;\n }\n } else {\n if ((1 & l>>i) == 1) {\n ans1++;\n }\n }\n\n if (i%2 == 0) {\n if ((1 & l>>i) == 0) {\n ans2++;\n }\n } else {\n if ((1 & l>>i) == 1) {\n ans2++;\n }\n }\n\n }\n System.out.println(Math.min(ans1, ans2));\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nN tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.\n\nThe i-th tile from the left is painted black if the i-th character of S is 0, and painted white if that character is 1.\n\nYou want to repaint some of the tiles black or white, so that any two adjacent tiles have different colors.\n\nAt least how many tiles need to be repainted to satisfy the condition?\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of tiles that need to be repainted to satisfy the condition.\n\nSample Input 1\n\n000\n\nSample Output 1\n\n1\n\nThe condition can be satisfied by repainting the middle tile white.\n\nSample Input 2\n\n10010010\n\nSample Output 2\n\n3\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "sample_input": "000\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03073", "source_text": "Score : 300 points\n\nProblem Statement\n\nN tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.\n\nThe i-th tile from the left is painted black if the i-th character of S is 0, and painted white if that character is 1.\n\nYou want to repaint some of the tiles black or white, so that any two adjacent tiles have different colors.\n\nAt least how many tiles need to be repainted to satisfy the condition?\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of tiles that need to be repainted to satisfy the condition.\n\nSample Input 1\n\n000\n\nSample Output 1\n\n1\n\nThe condition can be satisfied by repainting the middle tile white.\n\nSample Input 2\n\n10010010\n\nSample Output 2\n\n3\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 657, "cpu_time_ms": 167, "memory_kb": 26060}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s936803961", "group_id": "codeNet:p03074", "input_text": "import java.util.Scanner;\nimport java.util.List;\nimport java.util.ArrayList;\n\npublic class Main{\n public static void main(String args[]){\n \n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int k = sc.nextInt();\n String s = sc.next();\n List kList = new ArrayList<>();\n List oneList = new ArrayList<>();\n \n boolean f = true;\n int z = 0;\n int one = 0;\n boolean firstoneFlag = false;\n for(int i = 0; i < n; i++){\n z++;\n char c = s.charAt(i);\n if(i == 0 && c == '1'){\n firstoneFlag = true;\n }\n if(c == '1'){\n if(f){\n one++;\n }else{\n f = true;\n kList.add(z);\n if(firstoneFlag){\n firstoneFlag = false;\n }else{\n oneList.add(one);\n }\n one = 1;\n }\n }else{\n f = false;\n }\n }\n \n if(f){\n oneList.add(one);\n }else{\n kList.add(z);\n oneList.add(0);\n }\n \n long max = 0;\n int index = -1;\n for(int i = k - 1; i < kList.size(); i++){\n long tmp = 0;\n if(index == -1){\n tmp = kList.get(i) + oneList.get(i);\n }else{\n tmp = kList.get(i) + oneList.get(i) - kList.get(index);\n }\n if(max < tmp){\n max = tmp;\n }\n index++;\n }\n \n if(max == 0){\n max = n;\n }\n \n System.out.println(max);\n \n \n \n }\n}\n", "language": "Java", "metadata": {"date": 1555187961, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03074.html", "problem_id": "p03074", "resource_group": "high_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/Java/s936803961.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s936803961", "user_id": "u183787127"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.Scanner;\nimport java.util.List;\nimport java.util.ArrayList;\n\npublic class Main{\n public static void main(String args[]){\n \n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int k = sc.nextInt();\n String s = sc.next();\n List kList = new ArrayList<>();\n List oneList = new ArrayList<>();\n \n boolean f = true;\n int z = 0;\n int one = 0;\n boolean firstoneFlag = false;\n for(int i = 0; i < n; i++){\n z++;\n char c = s.charAt(i);\n if(i == 0 && c == '1'){\n firstoneFlag = true;\n }\n if(c == '1'){\n if(f){\n one++;\n }else{\n f = true;\n kList.add(z);\n if(firstoneFlag){\n firstoneFlag = false;\n }else{\n oneList.add(one);\n }\n one = 1;\n }\n }else{\n f = false;\n }\n }\n \n if(f){\n oneList.add(one);\n }else{\n kList.add(z);\n oneList.add(0);\n }\n \n long max = 0;\n int index = -1;\n for(int i = k - 1; i < kList.size(); i++){\n long tmp = 0;\n if(index == -1){\n tmp = kList.get(i) + oneList.get(i);\n }else{\n tmp = kList.get(i) + oneList.get(i) - kList.get(index);\n }\n if(max < tmp){\n max = tmp;\n }\n index++;\n }\n \n if(max == 0){\n max = n;\n }\n \n System.out.println(max);\n \n \n \n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nN people are arranged in a row from left to right.\n\nYou are given a string S of length N consisting of 0 and 1, and a positive integer K.\n\nThe i-th person from the left is standing on feet if the i-th character of S is 0, and standing on hands if that character is 1.\n\nYou will give the following direction at most K times (possibly zero):\n\nDirection: Choose integers l and r satisfying 1 \\leq l \\leq r \\leq N, and flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1, ..., r, the i-th person from the left now stands on hands if he/she was standing on feet, and stands on feet if he/she was standing on hands.\n\nFind the maximum possible number of consecutive people standing on hands after at most K directions.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^5.\n\nK is an integer satisfying 1 \\leq K \\leq 10^5.\n\nThe length of the string S is N.\n\nEach character of the string S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the maximum possible number of consecutive people standing on hands after at most K directions.\n\nSample Input 1\n\n5 1\n00010\n\nSample Output 1\n\n4\n\nWe can have four consecutive people standing on hands, which is the maximum result, by giving the following direction:\n\nGive the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\nSample Input 2\n\n14 2\n11101010110011\n\nSample Output 2\n\n8\n\nSample Input 3\n\n1 1\n1\n\nSample Output 3\n\n1\n\nNo directions are necessary.", "sample_input": "5 1\n00010\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03074", "source_text": "Score : 400 points\n\nProblem Statement\n\nN people are arranged in a row from left to right.\n\nYou are given a string S of length N consisting of 0 and 1, and a positive integer K.\n\nThe i-th person from the left is standing on feet if the i-th character of S is 0, and standing on hands if that character is 1.\n\nYou will give the following direction at most K times (possibly zero):\n\nDirection: Choose integers l and r satisfying 1 \\leq l \\leq r \\leq N, and flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1, ..., r, the i-th person from the left now stands on hands if he/she was standing on feet, and stands on feet if he/she was standing on hands.\n\nFind the maximum possible number of consecutive people standing on hands after at most K directions.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^5.\n\nK is an integer satisfying 1 \\leq K \\leq 10^5.\n\nThe length of the string S is N.\n\nEach character of the string S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the maximum possible number of consecutive people standing on hands after at most K directions.\n\nSample Input 1\n\n5 1\n00010\n\nSample Output 1\n\n4\n\nWe can have four consecutive people standing on hands, which is the maximum result, by giving the following direction:\n\nGive the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\nSample Input 2\n\n14 2\n11101010110011\n\nSample Output 2\n\n8\n\nSample Input 3\n\n1 1\n1\n\nSample Output 3\n\n1\n\nNo directions are necessary.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1817, "cpu_time_ms": 178, "memory_kb": 30668}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s912845429", "group_id": "codeNet:p03074", "input_text": "import java.util.*;\nimport java.lang.*;\nimport java.math.*;\nimport java.io.*;\n\n/* abhi2601 */\n\npublic class Main implements Runnable{\n\n final static long mod = (long)1e9 + 7;\n\n class Pair{\n int l,r;\n Pair(int l,int r){\n this.l=l;\n this.r=r;\n }\n }\n class Comp implements Comparator{\n public int compare(Pair p1, Pair p2){\n if(p1.lp2.l) return 1;\n else{\n if(p1.rp2.r) return 1;\n else return 0;\n }\n }\n }\n public void run(){\n InputReader sc = new InputReader(System.in);\n PrintWriter w = new PrintWriter(System.out);\n int n=sc.nextInt();\n int k=sc.nextInt();\n String s=sc.next();\n StringBuilder sb=new StringBuilder();\n for(int i=0;iq=new LinkedList<>();\n Queueq1=new LinkedList<>();\n int c=0,t=0,ans=0,p=-1;\n for(int i=0;ik){\n p=q.poll();\n t--;\n }\n ans=Math.max(ans,i-p-1);\n }\n }\n else{\n if(c!=0){\n t++;\n q.add(i-1);\n c=0;\n }\n if(i==n-1){\n if(t>k){\n p=q.poll();\n t--;\n }\n ans=Math.max(ans,i-p);\n }\n }\n }\n int c1=0,t1=0,ans1=0,p1=-1;\n for(int i=0;ik1){\n p1=q1.poll();\n t1--;\n }\n ans1=Math.max(ans1,i-p1-1);\n }\n }\n else{\n if(c1!=0){\n t1++;\n q1.add(i-1);\n c1=0;\n }\n if(i==n-1){\n if(t1>k1){\n p1=q1.poll();\n t1--;\n }\n ans1=Math.max(ans1,i-p1);\n }\n }\n }\n w.println(Math.max(ans,ans1));\n w.close();\n }\n //static PrintWriter w;\n /*File in=new File(\"input.txt\");\n File out=new File(\"output.txt\");\n Scanner sc= null;\n try {\n sc = new Scanner(in);\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n }\n try {\n w=new PrintWriter(out);\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n }*/\n static class InputReader {\n\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private SpaceCharFilter filter;\n\n public InputReader(InputStream stream)\n {\n this.stream = stream;\n }\n\n public int read()\n {\n if (numChars==-1)\n throw new InputMismatchException();\n\n if (curChar >= numChars)\n {\n curChar = 0;\n try\n {\n numChars = stream.read(buf);\n }\n catch (IOException e)\n {\n throw new InputMismatchException();\n }\n\n if(numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }\n\n public String nextLine()\n {\n BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n String str = \"\";\n try\n {\n str = br.readLine();\n }\n catch (IOException e)\n {\n e.printStackTrace();\n }\n return str;\n }\n public int nextInt()\n {\n int c = read();\n\n while(isSpaceChar(c))\n c = read();\n\n int sgn = 1;\n\n if (c == '-')\n {\n sgn = -1;\n c = read();\n }\n\n int res = 0;\n do\n {\n if(c<'0'||c>'9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = read();\n }\n while (!isSpaceChar(c));\n\n return res * sgn;\n }\n\n public long nextLong()\n {\n int c = read();\n while (isSpaceChar(c))\n c = read();\n int sgn = 1;\n if (c == '-')\n {\n sgn = -1;\n c = read();\n }\n long res = 0;\n\n do\n {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = read();\n }\n while (!isSpaceChar(c));\n return res * sgn;\n }\n\n public double nextDouble()\n {\n int c = read();\n while (isSpaceChar(c))\n c = read();\n int sgn = 1;\n if (c == '-')\n {\n sgn = -1;\n c = read();\n }\n double res = 0;\n while (!isSpaceChar(c) && c != '.')\n {\n if (c == 'e' || c == 'E')\n return res * Math.pow(10, nextInt());\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = read();\n }\n if (c == '.')\n {\n c = read();\n double m = 1;\n while (!isSpaceChar(c))\n {\n if (c == 'e' || c == 'E')\n return res * Math.pow(10, nextInt());\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n m /= 10;\n res += (c - '0') * m;\n c = read();\n }\n }\n return res * sgn;\n }\n\n public String readString()\n {\n int c = read();\n while (isSpaceChar(c))\n c = read();\n StringBuilder res = new StringBuilder();\n do\n {\n res.appendCodePoint(c);\n c = read();\n }\n while (!isSpaceChar(c));\n\n return res.toString();\n }\n\n public boolean isSpaceChar(int c)\n {\n if (filter != null)\n return filter.isSpaceChar(c);\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public String next()\n {\n return readString();\n }\n\n public interface SpaceCharFilter\n {\n public boolean isSpaceChar(int ch);\n }\n }\n\n public static void main(String args[]) throws Exception\n {\n new Thread(null, new Main(),\"q1\",1<<26).start();\n }\n}", "language": "Java", "metadata": {"date": 1555187261, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03074.html", "problem_id": "p03074", "resource_group": "high_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/Java/s912845429.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s912845429", "user_id": "u076285441"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*;\nimport java.lang.*;\nimport java.math.*;\nimport java.io.*;\n\n/* abhi2601 */\n\npublic class Main implements Runnable{\n\n final static long mod = (long)1e9 + 7;\n\n class Pair{\n int l,r;\n Pair(int l,int r){\n this.l=l;\n this.r=r;\n }\n }\n class Comp implements Comparator{\n public int compare(Pair p1, Pair p2){\n if(p1.lp2.l) return 1;\n else{\n if(p1.rp2.r) return 1;\n else return 0;\n }\n }\n }\n public void run(){\n InputReader sc = new InputReader(System.in);\n PrintWriter w = new PrintWriter(System.out);\n int n=sc.nextInt();\n int k=sc.nextInt();\n String s=sc.next();\n StringBuilder sb=new StringBuilder();\n for(int i=0;iq=new LinkedList<>();\n Queueq1=new LinkedList<>();\n int c=0,t=0,ans=0,p=-1;\n for(int i=0;ik){\n p=q.poll();\n t--;\n }\n ans=Math.max(ans,i-p-1);\n }\n }\n else{\n if(c!=0){\n t++;\n q.add(i-1);\n c=0;\n }\n if(i==n-1){\n if(t>k){\n p=q.poll();\n t--;\n }\n ans=Math.max(ans,i-p);\n }\n }\n }\n int c1=0,t1=0,ans1=0,p1=-1;\n for(int i=0;ik1){\n p1=q1.poll();\n t1--;\n }\n ans1=Math.max(ans1,i-p1-1);\n }\n }\n else{\n if(c1!=0){\n t1++;\n q1.add(i-1);\n c1=0;\n }\n if(i==n-1){\n if(t1>k1){\n p1=q1.poll();\n t1--;\n }\n ans1=Math.max(ans1,i-p1);\n }\n }\n }\n w.println(Math.max(ans,ans1));\n w.close();\n }\n //static PrintWriter w;\n /*File in=new File(\"input.txt\");\n File out=new File(\"output.txt\");\n Scanner sc= null;\n try {\n sc = new Scanner(in);\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n }\n try {\n w=new PrintWriter(out);\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n }*/\n static class InputReader {\n\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private SpaceCharFilter filter;\n\n public InputReader(InputStream stream)\n {\n this.stream = stream;\n }\n\n public int read()\n {\n if (numChars==-1)\n throw new InputMismatchException();\n\n if (curChar >= numChars)\n {\n curChar = 0;\n try\n {\n numChars = stream.read(buf);\n }\n catch (IOException e)\n {\n throw new InputMismatchException();\n }\n\n if(numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }\n\n public String nextLine()\n {\n BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n String str = \"\";\n try\n {\n str = br.readLine();\n }\n catch (IOException e)\n {\n e.printStackTrace();\n }\n return str;\n }\n public int nextInt()\n {\n int c = read();\n\n while(isSpaceChar(c))\n c = read();\n\n int sgn = 1;\n\n if (c == '-')\n {\n sgn = -1;\n c = read();\n }\n\n int res = 0;\n do\n {\n if(c<'0'||c>'9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = read();\n }\n while (!isSpaceChar(c));\n\n return res * sgn;\n }\n\n public long nextLong()\n {\n int c = read();\n while (isSpaceChar(c))\n c = read();\n int sgn = 1;\n if (c == '-')\n {\n sgn = -1;\n c = read();\n }\n long res = 0;\n\n do\n {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = read();\n }\n while (!isSpaceChar(c));\n return res * sgn;\n }\n\n public double nextDouble()\n {\n int c = read();\n while (isSpaceChar(c))\n c = read();\n int sgn = 1;\n if (c == '-')\n {\n sgn = -1;\n c = read();\n }\n double res = 0;\n while (!isSpaceChar(c) && c != '.')\n {\n if (c == 'e' || c == 'E')\n return res * Math.pow(10, nextInt());\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = read();\n }\n if (c == '.')\n {\n c = read();\n double m = 1;\n while (!isSpaceChar(c))\n {\n if (c == 'e' || c == 'E')\n return res * Math.pow(10, nextInt());\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n m /= 10;\n res += (c - '0') * m;\n c = read();\n }\n }\n return res * sgn;\n }\n\n public String readString()\n {\n int c = read();\n while (isSpaceChar(c))\n c = read();\n StringBuilder res = new StringBuilder();\n do\n {\n res.appendCodePoint(c);\n c = read();\n }\n while (!isSpaceChar(c));\n\n return res.toString();\n }\n\n public boolean isSpaceChar(int c)\n {\n if (filter != null)\n return filter.isSpaceChar(c);\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public String next()\n {\n return readString();\n }\n\n public interface SpaceCharFilter\n {\n public boolean isSpaceChar(int ch);\n }\n }\n\n public static void main(String args[]) throws Exception\n {\n new Thread(null, new Main(),\"q1\",1<<26).start();\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": 7633, "cpu_time_ms": 131, "memory_kb": 32260}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s262027244", "group_id": "codeNet:p03076", "input_text": "import java.util.*;\n\npublic class Main{\n\n\tpublic static void main(String[] args){\n\n\t\tScanner sc =new Scanner(System.in);\n\t\tint[] dish = new int[5];\n\t\tfor(int i=0;i<5;i++){\n\t\t\tdish[i] = sc.nextInt();\n\t\t}\n\n\t\tint[] point = new int[5];\n\t\tint[] ones_place=new int[5];\n\t\tfor(int i=0;i<5;i++){\n\t\t\tif(dish[i] >=100){\n\t\t\t\tones_place[i] = dish[i]/100;\n\t\t\t\tif(ones_place[i] == 0)\n\t\t\t\t\tones_place[i] = 10;\n\n\t\t\t\t\tpoint[i] = dish[i]+10-ones_place[i];\n\t\t\t\t\n\t\t\t}else if(dish[i]>=10){\n\t\t\t\t\tones_place[i]=dish[i]/10;\n\t\t\t\t\tif(ones_place[i] == 0)\n\t\t\t\t\tones_place[i] = 10;\n\n\t\t\t\t\tpoint[i] = dish[i]+10-ones_place[i];\n\t\t\t\t}else{\n\t\t\t\t\tones_place[i]=dish[i];\n\t\t\t\t\tif(ones_place[i] == 0)\n\t\t\t\t\tones_place[i] = 10;\n\n\t\t\t\t\tpoint[i] = dish[i]+10-ones_place[i];\n\t\t\t\t}\n\t\t}\n\n\t\tArrays.sort(ones_place);\n\t\tint time=0;\n\n\t\tfor(int i=0;i=100){\n\t\t\t\tones_place[i] = dish[i]/100;\n\t\t\t\tif(ones_place[i] == 0)\n\t\t\t\t\tones_place[i] = 10;\n\n\t\t\t\t\tpoint[i] = dish[i]+10-ones_place[i];\n\t\t\t\t\n\t\t\t}else if(dish[i]>=10){\n\t\t\t\t\tones_place[i]=dish[i]/10;\n\t\t\t\t\tif(ones_place[i] == 0)\n\t\t\t\t\tones_place[i] = 10;\n\n\t\t\t\t\tpoint[i] = dish[i]+10-ones_place[i];\n\t\t\t\t}else{\n\t\t\t\t\tones_place[i]=dish[i];\n\t\t\t\t\tif(ones_place[i] == 0)\n\t\t\t\t\tones_place[i] = 10;\n\n\t\t\t\t\tpoint[i] = dish[i]+10-ones_place[i];\n\t\t\t\t}\n\t\t}\n\n\t\tArrays.sort(ones_place);\n\t\tint time=0;\n\n\t\tfor(int i=0;i= 0) {\n long mid = (l + r) / 2;\n if (check(mid)) {\n bord = mid;\n l = mid + 1;\n } else {\n r = mid - 1;\n }\n }\n ArrayList ans = new ArrayList<>();\n for (int i = 0; i < x; i++) {\n for (int j = 0; j < y; j++) {\n for (int t = 0; t < z; t++) {\n if (a[i] + b[j] + c[t] >= bord) {\n ans.add(a[i] + b[j] + c[t]);\n } else {\n break;\n }\n }\n }\n }\n Collections.sort(ans, Collections.reverseOrder());\n for (int i = 0; i < k; i++) {\n out.println(ans.get(i));\n }\n }\n\n static boolean check(long mid) {\n int nb = 0;\n for (int i = 0; i < x; i++) {\n for (int j = 0; j < y; j++) {\n if (a[i] + b[j] >= mid) {\n nb += z;\n if (nb >= k) return true;\n } else {\n for (int l = 0; l < z; l++) {\n if (a[i] + b[j] + c[l] >= mid) {\n nb++;\n } else {\n break;\n }\n if (nb >= k) return true;\n }\n }\n }\n }\n return false;\n }\n\n }\n\n static class inputClass {\n BufferedReader br;\n StringTokenizer st;\n\n public inputClass(InputStream in) {\n\n br = new BufferedReader(new InputStreamReader(in));\n }\n\n public String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1557342801, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03078.html", "problem_id": "p03078", "resource_group": "high_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/Java/s125599293.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s125599293", "user_id": "u789370084"}, "prompt_components": {"gold_output": "19\n17\n15\n14\n13\n12\n10\n8\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayList;\nimport java.util.StringTokenizer;\nimport java.io.BufferedReader;\nimport java.util.Collections;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author Washoum\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n inputClass in = new inputClass(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n DCake123 solver = new DCake123();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class DCake123 {\n static int x;\n static int y;\n static int z;\n static int k;\n static Long[] a;\n static Long[] b;\n static Long[] c;\n\n public void solve(int testNumber, inputClass sc, PrintWriter out) {\n x = sc.nextInt();\n y = sc.nextInt();\n z = sc.nextInt();\n k = sc.nextInt();\n a = new Long[x];\n b = new Long[y];\n c = new Long[z];\n for (int i = 0; i < x; i++) {\n a[i] = sc.nextLong();\n }\n for (int i = 0; i < y; i++) {\n b[i] = sc.nextLong();\n }\n for (int i = 0; i < z; i++) {\n c[i] = sc.nextLong();\n }\n Arrays.sort(a, Collections.reverseOrder());\n Arrays.sort(b, Collections.reverseOrder());\n Arrays.sort(c, Collections.reverseOrder());\n long bord = 0;\n long l = 1;\n long r = (long) 1e11;\n while (r - l >= 0) {\n long mid = (l + r) / 2;\n if (check(mid)) {\n bord = mid;\n l = mid + 1;\n } else {\n r = mid - 1;\n }\n }\n ArrayList ans = new ArrayList<>();\n for (int i = 0; i < x; i++) {\n for (int j = 0; j < y; j++) {\n for (int t = 0; t < z; t++) {\n if (a[i] + b[j] + c[t] >= bord) {\n ans.add(a[i] + b[j] + c[t]);\n } else {\n break;\n }\n }\n }\n }\n Collections.sort(ans, Collections.reverseOrder());\n for (int i = 0; i < k; i++) {\n out.println(ans.get(i));\n }\n }\n\n static boolean check(long mid) {\n int nb = 0;\n for (int i = 0; i < x; i++) {\n for (int j = 0; j < y; j++) {\n if (a[i] + b[j] >= mid) {\n nb += z;\n if (nb >= k) return true;\n } else {\n for (int l = 0; l < z; l++) {\n if (a[i] + b[j] + c[l] >= mid) {\n nb++;\n } else {\n break;\n }\n if (nb >= k) return true;\n }\n }\n }\n }\n return false;\n }\n\n }\n\n static class inputClass {\n BufferedReader br;\n StringTokenizer st;\n\n public inputClass(InputStream in) {\n\n br = new BufferedReader(new InputStreamReader(in));\n }\n\n public String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\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": 4185, "cpu_time_ms": 2113, "memory_kb": 489836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s710820781", "group_id": "codeNet:p03079", "input_text": "import java.util.*;\n\nclass Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n\n int a = sc.nextInt();\n int b = sc.nextInt();\n int c = sc.nextInt();\n\n if(a == b && a == c && c ==a){\n System.out.println(\"Yes\");\n }\n else{\n System.out.println(\"No\");\n } \n }\n}", "language": "Java", "metadata": {"date": 1553976999, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03079.html", "problem_id": "p03079", "resource_group": "high_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/Java/s710820781.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s710820781", "user_id": "u575858003"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*;\n\nclass Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n\n int a = sc.nextInt();\n int b = sc.nextInt();\n int c = sc.nextInt();\n\n if(a == b && a == c && c ==a){\n System.out.println(\"Yes\");\n }\n else{\n System.out.println(\"No\");\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": 379, "cpu_time_ms": 97, "memory_kb": 23124}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s752461293", "group_id": "codeNet:p03086", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n //int N = sc.nextInt();\n //int[] count = new int[N];\n String str = sc.next();\n int max = 0;\n int count = 0;\n \n for(int i=0; i < str.length(); i++){\n if(str.charAt(i) == 'A' || str.charAt(i) == 'C' || str.charAt(i) == 'G' || str.charAt(i) == 'T'){\n count++;\n }else{\n count = 0;\n }\n if(max < count){\n max = count;\n }\n }\n //if(str[0].equals(\"H\"));\n System.out.println(max);\n }\n}", "language": "Java", "metadata": {"date": 1591689333, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03086.html", "problem_id": "p03086", "resource_group": "high_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/Java/s752461293.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s752461293", "user_id": "u224941344"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n //int N = sc.nextInt();\n //int[] count = new int[N];\n String str = sc.next();\n int max = 0;\n int count = 0;\n \n for(int i=0; i < str.length(); i++){\n if(str.charAt(i) == 'A' || str.charAt(i) == 'C' || str.charAt(i) == 'G' || str.charAt(i) == 'T'){\n count++;\n }else{\n count = 0;\n }\n if(max < count){\n max = count;\n }\n }\n //if(str[0].equals(\"H\"));\n System.out.println(max);\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.\n\nHere, a ACGT string is a string that contains no characters other than A, C, G and T.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\nS is a string of length between 1 and 10 (inclusive).\n\nEach character in S is an uppercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest ACGT string that is a substring of S.\n\nSample Input 1\n\nATCODER\n\nSample Output 1\n\n3\n\nAmong the ACGT strings that are substrings of ATCODER, the longest one is ATC.\n\nSample Input 2\n\nHATAGAYA\n\nSample Output 2\n\n5\n\nAmong the ACGT strings that are substrings of HATAGAYA, the longest one is ATAGA.\n\nSample Input 3\n\nSHINJUKU\n\nSample Output 3\n\n0\n\nAmong the ACGT strings that are substrings of SHINJUKU, the longest one is (the empty string).", "sample_input": "ATCODER\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03086", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.\n\nHere, a ACGT string is a string that contains no characters other than A, C, G and T.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\nS is a string of length between 1 and 10 (inclusive).\n\nEach character in S is an uppercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest ACGT string that is a substring of S.\n\nSample Input 1\n\nATCODER\n\nSample Output 1\n\n3\n\nAmong the ACGT strings that are substrings of ATCODER, the longest one is ATC.\n\nSample Input 2\n\nHATAGAYA\n\nSample Output 2\n\n5\n\nAmong the ACGT strings that are substrings of HATAGAYA, the longest one is ATAGA.\n\nSample Input 3\n\nSHINJUKU\n\nSample Output 3\n\n0\n\nAmong the ACGT strings that are substrings of SHINJUKU, the longest one is (the empty string).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 599, "cpu_time_ms": 91, "memory_kb": 23636}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s407338870", "group_id": "codeNet:p03086", "input_text": "import java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String s = sc.next();\n\n int max = 0;\n int tmp = 0;\n for (int i = 0; i < s.length(); ++i) {\n char ch = s.charAt(i);\n if (ch == 'A' || ch == 'C' || ch == 'G' || ch == 'T') ++tmp;\n else tmp = 0;\n if (tmp > max) max = tmp;\n }\n\n System.out.println(max);\n }\n}", "language": "Java", "metadata": {"date": 1590957973, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03086.html", "problem_id": "p03086", "resource_group": "high_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/Java/s407338870.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s407338870", "user_id": "u333573372"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String s = sc.next();\n\n int max = 0;\n int tmp = 0;\n for (int i = 0; i < s.length(); ++i) {\n char ch = s.charAt(i);\n if (ch == 'A' || ch == 'C' || ch == 'G' || ch == 'T') ++tmp;\n else tmp = 0;\n if (tmp > max) max = tmp;\n }\n\n System.out.println(max);\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.\n\nHere, a ACGT string is a string that contains no characters other than A, C, G and T.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\nS is a string of length between 1 and 10 (inclusive).\n\nEach character in S is an uppercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest ACGT string that is a substring of S.\n\nSample Input 1\n\nATCODER\n\nSample Output 1\n\n3\n\nAmong the ACGT strings that are substrings of ATCODER, the longest one is ATC.\n\nSample Input 2\n\nHATAGAYA\n\nSample Output 2\n\n5\n\nAmong the ACGT strings that are substrings of HATAGAYA, the longest one is ATAGA.\n\nSample Input 3\n\nSHINJUKU\n\nSample Output 3\n\n0\n\nAmong the ACGT strings that are substrings of SHINJUKU, the longest one is (the empty string).", "sample_input": "ATCODER\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03086", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.\n\nHere, a ACGT string is a string that contains no characters other than A, C, G and T.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\nS is a string of length between 1 and 10 (inclusive).\n\nEach character in S is an uppercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest ACGT string that is a substring of S.\n\nSample Input 1\n\nATCODER\n\nSample Output 1\n\n3\n\nAmong the ACGT strings that are substrings of ATCODER, the longest one is ATC.\n\nSample Input 2\n\nHATAGAYA\n\nSample Output 2\n\n5\n\nAmong the ACGT strings that are substrings of HATAGAYA, the longest one is ATAGA.\n\nSample Input 3\n\nSHINJUKU\n\nSample Output 3\n\n0\n\nAmong the ACGT strings that are substrings of SHINJUKU, the longest one is (the empty string).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 475, "cpu_time_ms": 96, "memory_kb": 22996}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s043285952", "group_id": "codeNet:p03086", "input_text": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.NoSuchElementException;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tFastScanner sc = new FastScanner();\n\t\tString S = sc.next();\n\t\tList list = new ArrayList();\n\t\tlist.add(0);\n\t\tfor (int i = 0; i < S.length(); i++) {\n\t\t\tchar t = S.charAt(i);\n\t\t\tif (t != 'A' && t !='C' && t != 'G' && t != 'T') {\n\t\t\t\tlist.add(i+1);\n\t\t\t}\n\t\t}\n\t\tlist.add(S.length()+1);\n\t\tint ans = 0;\n\t\tfor (int i = 0; i < list.size() -1; i++) {\n\t\t\tint t = list.get(i+1) - list.get(i) - 1;\n\t\t\tif (t > ans) {\n\t\t\t\tans = t;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n}\n\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte())\n return buffer[ptr++];\n else\n return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr]))\n ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext())\n throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext())\n throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)\n throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n}", "language": "Java", "metadata": {"date": 1561307147, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03086.html", "problem_id": "p03086", "resource_group": "high_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/Java/s043285952.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s043285952", "user_id": "u893188242"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.NoSuchElementException;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tFastScanner sc = new FastScanner();\n\t\tString S = sc.next();\n\t\tList list = new ArrayList();\n\t\tlist.add(0);\n\t\tfor (int i = 0; i < S.length(); i++) {\n\t\t\tchar t = S.charAt(i);\n\t\t\tif (t != 'A' && t !='C' && t != 'G' && t != 'T') {\n\t\t\t\tlist.add(i+1);\n\t\t\t}\n\t\t}\n\t\tlist.add(S.length()+1);\n\t\tint ans = 0;\n\t\tfor (int i = 0; i < list.size() -1; i++) {\n\t\t\tint t = list.get(i+1) - list.get(i) - 1;\n\t\t\tif (t > ans) {\n\t\t\t\tans = t;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n}\n\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte())\n return buffer[ptr++];\n else\n return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr]))\n ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext())\n throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext())\n throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)\n throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\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": 2932, "cpu_time_ms": 69, "memory_kb": 21332}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s151450965", "group_id": "codeNet:p03086", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.io.PrintStream;\nimport java.io.IOException;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.io.Closeable;\nimport java.util.Comparator;\nimport java.util.NoSuchElementException;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author HBonsai\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n FastScanner in = new FastScanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n BATCoder solver = new BATCoder();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class BATCoder {\n public void solve(int testNumber, FastScanner in, PrintWriter out) {\n String s = in.next();\n List cands = new ArrayList<>();\n cands.add(\"\");\n for (int i = 0; i < s.length(); i++) {\n for (int j = i + 1; j <= s.length(); j++) {\n String part = s.substring(i, j);\n if (part.matches(\"[ACGT]+\")) {\n System.err.println(part);\n cands.add(part);\n }\n }\n }\n cands.sort(Comparator.comparing(String::length).reversed());\n out.println(cands.get(0).length());\n }\n\n }\n\n static class FastScanner implements Closeable {\n private final InputStream in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n public FastScanner(InputStream in) {\n this.in = in;\n }\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) return buffer[ptr++];\n else return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public void close() {\n try {\n in.close();\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1553458444, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03086.html", "problem_id": "p03086", "resource_group": "high_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/Java/s151450965.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s151450965", "user_id": "u752146501"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.io.PrintStream;\nimport java.io.IOException;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.io.Closeable;\nimport java.util.Comparator;\nimport java.util.NoSuchElementException;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author HBonsai\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n FastScanner in = new FastScanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n BATCoder solver = new BATCoder();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class BATCoder {\n public void solve(int testNumber, FastScanner in, PrintWriter out) {\n String s = in.next();\n List cands = new ArrayList<>();\n cands.add(\"\");\n for (int i = 0; i < s.length(); i++) {\n for (int j = i + 1; j <= s.length(); j++) {\n String part = s.substring(i, j);\n if (part.matches(\"[ACGT]+\")) {\n System.err.println(part);\n cands.add(part);\n }\n }\n }\n cands.sort(Comparator.comparing(String::length).reversed());\n out.println(cands.get(0).length());\n }\n\n }\n\n static class FastScanner implements Closeable {\n private final InputStream in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n public FastScanner(InputStream in) {\n this.in = in;\n }\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) return buffer[ptr++];\n else return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public void close() {\n try {\n in.close();\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n\n }\n}\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": 3192, "cpu_time_ms": 187, "memory_kb": 28884}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s181677054", "group_id": "codeNet:p03087", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tchar[] s = sc.next().toCharArray();\n\t\tint[] a = new int[n];\n\t\tfor (int i = 1; i < n; i++) {\n\t\t\tif(s[i-1]=='A'&&s[i]=='C') a[i] += 1;\n\t\t\ta[i] += a[i-1];\n\t\t}\n\t\tint l = 0, r = 0; String[] lr = new String[2];\n\t\tsc.nextLine();\n\t\tfor (int i = 0; i < q; i++) {\n\t\t\tlr = sc.nextLine().split(\" \");\n\t\t\tl = Integer.parseInt(lr[0])-1;\n\t\t\tr = Integer.parseInt(lr[1])-1;\n\t\t\tif(l == 0) {\n\t\t\t\tSystem.out.println(a[r]);\n\t\t\t}else {\n\t\t\t\tn = (s[l]=='C'&&s[l-1]=='A')?1:0;\n\t\t\t\tSystem.out.println(a[r]-a[l-1]-n);\n\t\t\t}\n\t\t}\n\t\tsc.close();\n\t}\n}", "language": "Java", "metadata": {"date": 1581208935, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03087.html", "problem_id": "p03087", "resource_group": "high_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/Java/s181677054.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s181677054", "user_id": "u324881146"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tchar[] s = sc.next().toCharArray();\n\t\tint[] a = new int[n];\n\t\tfor (int i = 1; i < n; i++) {\n\t\t\tif(s[i-1]=='A'&&s[i]=='C') a[i] += 1;\n\t\t\ta[i] += a[i-1];\n\t\t}\n\t\tint l = 0, r = 0; String[] lr = new String[2];\n\t\tsc.nextLine();\n\t\tfor (int i = 0; i < q; i++) {\n\t\t\tlr = sc.nextLine().split(\" \");\n\t\t\tl = Integer.parseInt(lr[0])-1;\n\t\t\tr = Integer.parseInt(lr[1])-1;\n\t\t\tif(l == 0) {\n\t\t\t\tSystem.out.println(a[r]);\n\t\t\t}else {\n\t\t\t\tn = (s[l]=='C'&&s[l-1]=='A')?1:0;\n\t\t\t\tSystem.out.println(a[r]-a[l-1]-n);\n\t\t\t}\n\t\t}\n\t\tsc.close();\n\t}\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, C, G and T. Answer the following Q queries:\n\nQuery i (1 \\leq i \\leq Q): You will be given integers l_i and r_i (1 \\leq l_i < r_i \\leq N). Consider the substring of S starting at index l_i and ending at index r_i (both inclusive). In this string, how many times does AC occurs as a substring?\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\nS is a string of length N.\n\nEach character in S is A, C, G or T.\n\n1 \\leq l_i < r_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the answer to the i-th query.\n\nSample Input 1\n\n8 3\nACACTACG\n3 7\n2 3\n1 8\n\nSample Output 1\n\n2\n0\n3\n\nQuery 1: the substring of S starting at index 3 and ending at index 7 is ACTAC. In this string, AC occurs twice as a substring.\n\nQuery 2: the substring of S starting at index 2 and ending at index 3 is CA. In this string, AC occurs zero times as a substring.\n\nQuery 3: the substring of S starting at index 1 and ending at index 8 is ACACTACG. In this string, AC occurs three times as a substring.", "sample_input": "8 3\nACACTACG\n3 7\n2 3\n1 8\n"}, "reference_outputs": ["2\n0\n3\n"], "source_document_id": "p03087", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, C, G and T. Answer the following Q queries:\n\nQuery i (1 \\leq i \\leq Q): You will be given integers l_i and r_i (1 \\leq l_i < r_i \\leq N). Consider the substring of S starting at index l_i and ending at index r_i (both inclusive). In this string, how many times does AC occurs as a substring?\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\nS is a string of length N.\n\nEach character in S is A, C, G or T.\n\n1 \\leq l_i < r_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the answer to the i-th query.\n\nSample Input 1\n\n8 3\nACACTACG\n3 7\n2 3\n1 8\n\nSample Output 1\n\n2\n0\n3\n\nQuery 1: the substring of S starting at index 3 and ending at index 7 is ACTAC. In this string, AC occurs twice as a substring.\n\nQuery 2: the substring of S starting at index 2 and ending at index 3 is CA. In this string, AC occurs zero times as a substring.\n\nQuery 3: the substring of S starting at index 1 and ending at index 8 is ACACTACG. In this string, AC occurs three times as a substring.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 696, "cpu_time_ms": 2110, "memory_kb": 357068}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s808299251", "group_id": "codeNet:p03087", "input_text": "\nimport java.util.ArrayList;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tsc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tString s = sc.next();\n\t\tAC2 ac = new AC2(s);\n\t\t\n\t\tfor (int i = 0; i < q; i++) {\n\t\t\tint l = sc.nextInt();\n\t\t\tint r = sc.nextInt();\n\t\t\tint ans = ac.getAC(l, r);\n\t\t\tSystem.out.println(ans);\n\t\t}\n\t\t\n\t}\n\t\n}\n\nclass AC2 {\n\tString s;\n\tArrayList acList = new ArrayList<>();\n\tAC2(String s) {\n\t\tthis.s = s;\n\t\tboolean a = false;\n\t\tfor (int i = 0; i < s.length(); i++) {\n\t\t\tchar ch = s.charAt(i);\n\t\t\tif (a) {\n\t\t\t\tif (ch == 'C') {\n\t\t\t\t\tacList.add(i);\n\t\t\t\t\ta = false;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\ta = (ch == 'A') ? true : false;\n\t\t}\n\t}\n\tint getAC(int l, int r) {\n\t\tint ac = 0;\n\t\tfor (int acIndex : acList) {\n\t\t\tif (acIndex > r - 1) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (acIndex >= l) {\n\t\t\t\tac++;\n\t\t\t}\n\t\t}\n\t\treturn ac;\n\t}\n}\n", "language": "Java", "metadata": {"date": 1557676259, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03087.html", "problem_id": "p03087", "resource_group": "high_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/Java/s808299251.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s808299251", "user_id": "u978153700"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "\nimport java.util.ArrayList;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tsc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tString s = sc.next();\n\t\tAC2 ac = new AC2(s);\n\t\t\n\t\tfor (int i = 0; i < q; i++) {\n\t\t\tint l = sc.nextInt();\n\t\t\tint r = sc.nextInt();\n\t\t\tint ans = ac.getAC(l, r);\n\t\t\tSystem.out.println(ans);\n\t\t}\n\t\t\n\t}\n\t\n}\n\nclass AC2 {\n\tString s;\n\tArrayList acList = new ArrayList<>();\n\tAC2(String s) {\n\t\tthis.s = s;\n\t\tboolean a = false;\n\t\tfor (int i = 0; i < s.length(); i++) {\n\t\t\tchar ch = s.charAt(i);\n\t\t\tif (a) {\n\t\t\t\tif (ch == 'C') {\n\t\t\t\t\tacList.add(i);\n\t\t\t\t\ta = false;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\ta = (ch == 'A') ? true : false;\n\t\t}\n\t}\n\tint getAC(int l, int r) {\n\t\tint ac = 0;\n\t\tfor (int acIndex : acList) {\n\t\t\tif (acIndex > r - 1) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (acIndex >= l) {\n\t\t\t\tac++;\n\t\t\t}\n\t\t}\n\t\treturn ac;\n\t}\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": 902, "cpu_time_ms": 2109, "memory_kb": 62748}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s214842262", "group_id": "codeNet:p03087", "input_text": "import java.util.*;\n\npublic class Main{\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int length = sc.nextInt();\n int n = sc.nextInt();\n sc.nextLine();\n String q = sc.nextLine();\n char[] qc = q.toCharArray();\n int data[] = new int[length+1];\n for(int i = 2;i<=length;i++){\n if(qc[i-2] == 'A' && qc[i-1] == 'C'){\n data[i] = data[i-1] + 1;\n }else{\n data[i] = data[i-1];\n }\n }\n int tmp = 0;\n for(int i = 0;i 0 ? counts [l - 1] : 0));\n\t\t}\n\t}\n\n\t// 0〜i番目の部分文字列がACの場合の数\n\tprivate static int[] countAC(String str) {\n\t\tint[] counts = new int[str.length() - 1];\n\t\tchar[] chars = str.toCharArray();\n\t\tint len = chars.length;\n\t\tint count = 0;\n\t\tfor (int i = 0; i < len - 1; i++) {\n\t\t\tif (chars[i] == 'A' && chars[i + 1] == 'C') {\n\t\t\t\tcount++;\n\t\t\t}\n\t\t\tcounts[i] = count;\n\t\t}\n\t\treturn counts;\n\t}\n}\n", "language": "Java", "metadata": {"date": 1554371781, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03087.html", "problem_id": "p03087", "resource_group": "high_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/Java/s492732176.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s492732176", "user_id": "u858185571"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\ttry (Scanner sc = new Scanner(br)) {\n\t\t\tint len = sc.nextInt();\n\t\t\tint numOfQuestion = sc.nextInt();\n\t\t\tString str = sc.next();\n\t\t\tquestion(str, numOfQuestion, sc);\n\t\t}\n\t}\n\n\tprivate static void question(String str, int numOfQuestion, Scanner sc) {\n\t\tint[] counts = countAC(str);\n\t\tfor (int i = 1; i <= numOfQuestion; i++) {\n\t\t\tint l = sc.nextInt() - 1;\n\t\t\tint r = sc.nextInt() - 1;\n\t\t\tSystem.out.println(counts[r - 1] - (l > 0 ? counts [l - 1] : 0));\n\t\t}\n\t}\n\n\t// 0〜i番目の部分文字列がACの場合の数\n\tprivate static int[] countAC(String str) {\n\t\tint[] counts = new int[str.length() - 1];\n\t\tchar[] chars = str.toCharArray();\n\t\tint len = chars.length;\n\t\tint count = 0;\n\t\tfor (int i = 0; i < len - 1; i++) {\n\t\t\tif (chars[i] == 'A' && chars[i + 1] == 'C') {\n\t\t\t\tcount++;\n\t\t\t}\n\t\t\tcounts[i] = count;\n\t\t}\n\t\treturn counts;\n\t}\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": 1066, "cpu_time_ms": 1390, "memory_kb": 66596}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s573060563", "group_id": "codeNet:p03089", "input_text": "import java.io.ByteArrayInputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.InputMismatchException;\n\npublic class Main {\n\tstatic InputStream is;\n\tstatic PrintWriter out;\n\tstatic String INPUT = \"\";\n\t\n\tstatic void solve()\n\t{\n\t\t// 123\n\t\t// 122\n\t\t// 112\n\t\t// 113\n\t\t// 121\n\t\t// 111\n\t\t\n\t\tint n = ni();\n\t\tint[] b = na(n);\n\t\tfor(int i = 0;i < n;i++){\n\t\t\tif(b[i] > i+1){\n\t\t\t\tout.println(-1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tint[] c = new int[n];\n\t\tfor(int i = 0;i < n;i++){\n\t\t\tc[i] = b[i]-1;\n\t\t\tfor(int j = 0;j < i;j++){\n\t\t\t\tif(c[j] >= c[i]){\n\t\t\t\t\tc[j]++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ttr(c);\n\t\tfor(int i = 0;i < n;i++){\n\t\t\tfor(int j = 0;j < n;j++){\n\t\t\t\tif(c[j] == i){\n\t\t\t\t\tint small = 1;\n\t\t\t\t\tfor(int k = 0;k < j;k++){\n\t\t\t\t\t\tif(c[k] < c[j])small++;\n\t\t\t\t\t}\n\t\t\t\t\tout.println(small);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args) throws Exception\n\t{\n\t\tlong S = System.currentTimeMillis();\n\t\tis = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n\t\tout = new PrintWriter(System.out);\n\t\t\n\t\tsolve();\n\t\tout.flush();\n\t\tlong G = System.currentTimeMillis();\n\t\ttr(G-S+\"ms\");\n\t}\n\t\n\tprivate static boolean eof()\n\t{\n\t\tif(lenbuf == -1)return true;\n\t\tint lptr = ptrbuf;\n\t\twhile(lptr < lenbuf)if(!isSpaceChar(inbuf[lptr++]))return false;\n\t\t\n\t\ttry {\n\t\t\tis.mark(1000);\n\t\t\twhile(true){\n\t\t\t\tint b = is.read();\n\t\t\t\tif(b == -1){\n\t\t\t\t\tis.reset();\n\t\t\t\t\treturn true;\n\t\t\t\t}else if(!isSpaceChar(b)){\n\t\t\t\t\tis.reset();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (IOException e) {\n\t\t\treturn true;\n\t\t}\n\t}\n\t\n\tprivate static byte[] inbuf = new byte[1024];\n\tstatic int lenbuf = 0, ptrbuf = 0;\n\t\n\tprivate static int readByte()\n\t{\n\t\tif(lenbuf == -1)throw new InputMismatchException();\n\t\tif(ptrbuf >= lenbuf){\n\t\t\tptrbuf = 0;\n\t\t\ttry { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }\n\t\t\tif(lenbuf <= 0)return -1;\n\t\t}\n\t\treturn inbuf[ptrbuf++];\n\t}\n\t\n\tprivate static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }\n//\tprivate static boolean isSpaceChar(int c) { return !(c >= 32 && c <= 126); }\n\tprivate static int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }\n\t\n\tprivate static double nd() { return Double.parseDouble(ns()); }\n\tprivate static char nc() { return (char)skip(); }\n\t\n\tprivate static String ns()\n\t{\n\t\tint b = skip();\n\t\tStringBuilder sb = new StringBuilder();\n\t\twhile(!(isSpaceChar(b))){\n\t\t\tsb.appendCodePoint(b);\n\t\t\tb = readByte();\n\t\t}\n\t\treturn sb.toString();\n\t}\n\t\n\tprivate static char[] ns(int n)\n\t{\n\t\tchar[] buf = new char[n];\n\t\tint b = skip(), p = 0;\n\t\twhile(p < n && !(isSpaceChar(b))){\n\t\t\tbuf[p++] = (char)b;\n\t\t\tb = readByte();\n\t\t}\n\t\treturn n == p ? buf : Arrays.copyOf(buf, p);\n\t}\n\t\n\tprivate static char[][] nm(int n, int m)\n\t{\n\t\tchar[][] map = new char[n][];\n\t\tfor(int i = 0;i < n;i++)map[i] = ns(m);\n\t\treturn map;\n\t}\n\t\n\tprivate static int[] na(int n)\n\t{\n\t\tint[] a = new int[n];\n\t\tfor(int i = 0;i < n;i++)a[i] = ni();\n\t\treturn a;\n\t}\n\t\n\tprivate static int ni()\n\t{\n\t\tint num = 0, b;\n\t\tboolean minus = false;\n\t\twhile((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n\t\tif(b == '-'){\n\t\t\tminus = true;\n\t\t\tb = readByte();\n\t\t}\n\t\t\n\t\twhile(true){\n\t\t\tif(b >= '0' && b <= '9'){\n\t\t\t\tnum = num * 10 + (b - '0');\n\t\t\t}else{\n\t\t\t\treturn minus ? -num : num;\n\t\t\t}\n\t\t\tb = readByte();\n\t\t}\n\t}\n\t\n\tprivate static long nl()\n\t{\n\t\tlong num = 0;\n\t\tint b;\n\t\tboolean minus = false;\n\t\twhile((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n\t\tif(b == '-'){\n\t\t\tminus = true;\n\t\t\tb = readByte();\n\t\t}\n\t\t\n\t\twhile(true){\n\t\t\tif(b >= '0' && b <= '9'){\n\t\t\t\tnum = num * 10 + (b - '0');\n\t\t\t}else{\n\t\t\t\treturn minus ? -num : num;\n\t\t\t}\n\t\t\tb = readByte();\n\t\t}\n\t}\n\t\n\tprivate static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }\n}\n", "language": "Java", "metadata": {"date": 1553375417, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03089.html", "problem_id": "p03089", "resource_group": "high_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/Java/s573060563.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s573060563", "user_id": "u119714109"}, "prompt_components": {"gold_output": "1\n1\n2\n", "input_to_evaluate": "import java.io.ByteArrayInputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.InputMismatchException;\n\npublic class Main {\n\tstatic InputStream is;\n\tstatic PrintWriter out;\n\tstatic String INPUT = \"\";\n\t\n\tstatic void solve()\n\t{\n\t\t// 123\n\t\t// 122\n\t\t// 112\n\t\t// 113\n\t\t// 121\n\t\t// 111\n\t\t\n\t\tint n = ni();\n\t\tint[] b = na(n);\n\t\tfor(int i = 0;i < n;i++){\n\t\t\tif(b[i] > i+1){\n\t\t\t\tout.println(-1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tint[] c = new int[n];\n\t\tfor(int i = 0;i < n;i++){\n\t\t\tc[i] = b[i]-1;\n\t\t\tfor(int j = 0;j < i;j++){\n\t\t\t\tif(c[j] >= c[i]){\n\t\t\t\t\tc[j]++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ttr(c);\n\t\tfor(int i = 0;i < n;i++){\n\t\t\tfor(int j = 0;j < n;j++){\n\t\t\t\tif(c[j] == i){\n\t\t\t\t\tint small = 1;\n\t\t\t\t\tfor(int k = 0;k < j;k++){\n\t\t\t\t\t\tif(c[k] < c[j])small++;\n\t\t\t\t\t}\n\t\t\t\t\tout.println(small);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args) throws Exception\n\t{\n\t\tlong S = System.currentTimeMillis();\n\t\tis = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n\t\tout = new PrintWriter(System.out);\n\t\t\n\t\tsolve();\n\t\tout.flush();\n\t\tlong G = System.currentTimeMillis();\n\t\ttr(G-S+\"ms\");\n\t}\n\t\n\tprivate static boolean eof()\n\t{\n\t\tif(lenbuf == -1)return true;\n\t\tint lptr = ptrbuf;\n\t\twhile(lptr < lenbuf)if(!isSpaceChar(inbuf[lptr++]))return false;\n\t\t\n\t\ttry {\n\t\t\tis.mark(1000);\n\t\t\twhile(true){\n\t\t\t\tint b = is.read();\n\t\t\t\tif(b == -1){\n\t\t\t\t\tis.reset();\n\t\t\t\t\treturn true;\n\t\t\t\t}else if(!isSpaceChar(b)){\n\t\t\t\t\tis.reset();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (IOException e) {\n\t\t\treturn true;\n\t\t}\n\t}\n\t\n\tprivate static byte[] inbuf = new byte[1024];\n\tstatic int lenbuf = 0, ptrbuf = 0;\n\t\n\tprivate static int readByte()\n\t{\n\t\tif(lenbuf == -1)throw new InputMismatchException();\n\t\tif(ptrbuf >= lenbuf){\n\t\t\tptrbuf = 0;\n\t\t\ttry { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }\n\t\t\tif(lenbuf <= 0)return -1;\n\t\t}\n\t\treturn inbuf[ptrbuf++];\n\t}\n\t\n\tprivate static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }\n//\tprivate static boolean isSpaceChar(int c) { return !(c >= 32 && c <= 126); }\n\tprivate static int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }\n\t\n\tprivate static double nd() { return Double.parseDouble(ns()); }\n\tprivate static char nc() { return (char)skip(); }\n\t\n\tprivate static String ns()\n\t{\n\t\tint b = skip();\n\t\tStringBuilder sb = new StringBuilder();\n\t\twhile(!(isSpaceChar(b))){\n\t\t\tsb.appendCodePoint(b);\n\t\t\tb = readByte();\n\t\t}\n\t\treturn sb.toString();\n\t}\n\t\n\tprivate static char[] ns(int n)\n\t{\n\t\tchar[] buf = new char[n];\n\t\tint b = skip(), p = 0;\n\t\twhile(p < n && !(isSpaceChar(b))){\n\t\t\tbuf[p++] = (char)b;\n\t\t\tb = readByte();\n\t\t}\n\t\treturn n == p ? buf : Arrays.copyOf(buf, p);\n\t}\n\t\n\tprivate static char[][] nm(int n, int m)\n\t{\n\t\tchar[][] map = new char[n][];\n\t\tfor(int i = 0;i < n;i++)map[i] = ns(m);\n\t\treturn map;\n\t}\n\t\n\tprivate static int[] na(int n)\n\t{\n\t\tint[] a = new int[n];\n\t\tfor(int i = 0;i < n;i++)a[i] = ni();\n\t\treturn a;\n\t}\n\t\n\tprivate static int ni()\n\t{\n\t\tint num = 0, b;\n\t\tboolean minus = false;\n\t\twhile((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n\t\tif(b == '-'){\n\t\t\tminus = true;\n\t\t\tb = readByte();\n\t\t}\n\t\t\n\t\twhile(true){\n\t\t\tif(b >= '0' && b <= '9'){\n\t\t\t\tnum = num * 10 + (b - '0');\n\t\t\t}else{\n\t\t\t\treturn minus ? -num : num;\n\t\t\t}\n\t\t\tb = readByte();\n\t\t}\n\t}\n\t\n\tprivate static long nl()\n\t{\n\t\tlong num = 0;\n\t\tint b;\n\t\tboolean minus = false;\n\t\twhile((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n\t\tif(b == '-'){\n\t\t\tminus = true;\n\t\t\tb = readByte();\n\t\t}\n\t\t\n\t\twhile(true){\n\t\t\tif(b >= '0' && b <= '9'){\n\t\t\t\tnum = num * 10 + (b - '0');\n\t\t\t}else{\n\t\t\t\treturn minus ? -num : num;\n\t\t\t}\n\t\t\tb = readByte();\n\t\t}\n\t}\n\t\n\tprivate static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }\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": 3828, "cpu_time_ms": 135, "memory_kb": 21972}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s837099230", "group_id": "codeNet:p03090", "input_text": "\n\nimport java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\n\t\tint matrix[][] = new int[n + 1][n + 1];\n\n\t\tfor(int i = 0; i <= n; i++){\n\t\t\tArrays.fill(matrix[i], 1);\n\t\t}\n\n\t\tfor(int i = 0; i < (n + 1) / 2; i++){\n\t\t\tif(n % 2 == 1){\n\t\t\t\tmatrix[i + 1][n - i - 1] = 0;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tmatrix[i + 1][n - i] = 0;\n\t\t\t}\n\t\t}\n\n\t\tfor(int i = 1; i <= n; i++){\n\t\t\tfor(int j = i + 1; j <= n; j++){\n\t\t\t\tif(matrix[i][j] != 0){\n\t\t\t\t\tSystem.out.println(i+\" \"+j);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n", "language": "Java", "metadata": {"date": 1593963718, "filename_ext": "java", "original_language": "Java (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03090.html", "problem_id": "p03090", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03090/input.txt", "sample_output_relpath": "derived/input_output/data/p03090/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03090/Java/s837099230.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s837099230", "user_id": "u918391323"}, "prompt_components": {"gold_output": "2\n1 3\n2 3\n", "input_to_evaluate": "\n\nimport java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\n\t\tint matrix[][] = new int[n + 1][n + 1];\n\n\t\tfor(int i = 0; i <= n; i++){\n\t\t\tArrays.fill(matrix[i], 1);\n\t\t}\n\n\t\tfor(int i = 0; i < (n + 1) / 2; i++){\n\t\t\tif(n % 2 == 1){\n\t\t\t\tmatrix[i + 1][n - i - 1] = 0;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tmatrix[i + 1][n - i] = 0;\n\t\t\t}\n\t\t}\n\n\t\tfor(int i = 1; i <= n; i++){\n\t\t\tfor(int j = i + 1; j <= n; j++){\n\t\t\t\tif(matrix[i][j] != 0){\n\t\t\t\t\tSystem.out.println(i+\" \"+j);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nYou are given an integer N.\nBuild an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions:\n\nThe graph is simple and connected.\n\nThere exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S.\n\nIt can be proved that at least one such graph exists under the constraints of this problem.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIn the first line, print the number of edges, M, in the graph you made. In the i-th of the following M lines, print two integers a_i and b_i, representing the endpoints of the i-th edge.\n\nThe output will be judged correct if the graph satisfies the conditions.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n2\n1 3\n2 3\n\nFor every vertex, the sum of the indices of the vertices adjacent to that vertex is 3.", "sample_input": "3\n"}, "reference_outputs": ["2\n1 3\n2 3\n"], "source_document_id": "p03090", "source_text": "Score : 700 points\n\nProblem Statement\n\nYou are given an integer N.\nBuild an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions:\n\nThe graph is simple and connected.\n\nThere exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S.\n\nIt can be proved that at least one such graph exists under the constraints of this problem.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIn the first line, print the number of edges, M, in the graph you made. In the i-th of the following M lines, print two integers a_i and b_i, representing the endpoints of the i-th edge.\n\nThe output will be judged correct if the graph satisfies the conditions.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n2\n1 3\n2 3\n\nFor every vertex, the sum of the indices of the vertices adjacent to that vertex 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": 623, "cpu_time_ms": 161, "memory_kb": 29152}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s009650887", "group_id": "codeNet:p03101", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint H = sc.nextInt();\n\t\tint W = sc.nextInt();\n\t\tint h = sc.nextInt();\n\t\tint w = sc.nextInt();\n\n\t\tSystem.out.println((H-h) * (W - w));\n\t\tsc.close();\n\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1573805702, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03101.html", "problem_id": "p03101", "resource_group": "high_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/Java/s009650887.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s009650887", "user_id": "u325942975"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint H = sc.nextInt();\n\t\tint W = sc.nextInt();\n\t\tint h = sc.nextInt();\n\t\tint w = sc.nextInt();\n\n\t\tSystem.out.println((H-h) * (W - w));\n\t\tsc.close();\n\n\t}\n\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are H rows and W columns of white square cells.\n\nYou will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.\n\nHow many white cells will remain?\n\nIt can be proved that this count does not depend on what rows and columns are chosen.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 20\n\n1 \\leq h \\leq H\n\n1 \\leq w \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nh w\n\nOutput\n\nPrint the number of white cells that will remain.\n\nSample Input 1\n\n3 2\n2 1\n\nSample Output 1\n\n1\n\nThere are 3 rows and 2 columns of cells. When two rows and one column are chosen and painted in black, there is always one white cell that remains.\n\nSample Input 2\n\n5 5\n2 3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n2 4\n2 4\n\nSample Output 3\n\n0", "sample_input": "3 2\n2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03101", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are H rows and W columns of white square cells.\n\nYou will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.\n\nHow many white cells will remain?\n\nIt can be proved that this count does not depend on what rows and columns are chosen.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 20\n\n1 \\leq h \\leq H\n\n1 \\leq w \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nh w\n\nOutput\n\nPrint the number of white cells that will remain.\n\nSample Input 1\n\n3 2\n2 1\n\nSample Output 1\n\n1\n\nThere are 3 rows and 2 columns of cells. When two rows and one column are chosen and painted in black, there is always one white cell that remains.\n\nSample Input 2\n\n5 5\n2 3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n2 4\n2 4\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 287, "cpu_time_ms": 95, "memory_kb": 23636}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s072295828", "group_id": "codeNet:p03101", "input_text": "package min;\n\nimport java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sca=new Scanner(System.in);\n\t\tint a=sca.nextInt();\n\t\tint b=sca.nextInt();\n\t\tint y=sca.nextInt();\n\t\tint x=sca.nextInt();\n\t\tint v=a*b-y*b-(a-y)*x;\n\t\tSystem.out.print(v);\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1559300885, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03101.html", "problem_id": "p03101", "resource_group": "high_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/Java/s072295828.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s072295828", "user_id": "u286256224"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "package min;\n\nimport java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sca=new Scanner(System.in);\n\t\tint a=sca.nextInt();\n\t\tint b=sca.nextInt();\n\t\tint y=sca.nextInt();\n\t\tint x=sca.nextInt();\n\t\tint v=a*b-y*b-(a-y)*x;\n\t\tSystem.out.print(v);\n\t}\n\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are H rows and W columns of white square cells.\n\nYou will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.\n\nHow many white cells will remain?\n\nIt can be proved that this count does not depend on what rows and columns are chosen.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 20\n\n1 \\leq h \\leq H\n\n1 \\leq w \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nh w\n\nOutput\n\nPrint the number of white cells that will remain.\n\nSample Input 1\n\n3 2\n2 1\n\nSample Output 1\n\n1\n\nThere are 3 rows and 2 columns of cells. When two rows and one column are chosen and painted in black, there is always one white cell that remains.\n\nSample Input 2\n\n5 5\n2 3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n2 4\n2 4\n\nSample Output 3\n\n0", "sample_input": "3 2\n2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03101", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are H rows and W columns of white square cells.\n\nYou will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.\n\nHow many white cells will remain?\n\nIt can be proved that this count does not depend on what rows and columns are chosen.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 20\n\n1 \\leq h \\leq H\n\n1 \\leq w \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nh w\n\nOutput\n\nPrint the number of white cells that will remain.\n\nSample Input 1\n\n3 2\n2 1\n\nSample Output 1\n\n1\n\nThere are 3 rows and 2 columns of cells. When two rows and one column are chosen and painted in black, there is always one white cell that remains.\n\nSample Input 2\n\n5 5\n2 3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n2 4\n2 4\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 280, "cpu_time_ms": 82, "memory_kb": 21332}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s089051218", "group_id": "codeNet:p03108", "input_text": "import java.util.*;\n\npublic class Main\n{\n public static void main(String[] args)\n {\n Scanner in = new Scanner(System.in);\n int n = in.nextInt();\n int m = in.nextInt();\n int[] l = new int[m];\n int[] r = new int[m];\n for (int i = m-1; i >= 0; i--)\n {\n l[i] = in.nextInt();\n r[i] = in.nextInt();\n }\n \n int[] size = new int[n];\n Arrays.fill(size, 1);\n long[] ans = new long[m];\n DSU d = new DSU(n);\n for (int i = 0; i < m; i++)\n \tif (d.find(l[i]) != d.find(r[i]))\n {\n int a = size[d.find(l[i])];\n int b = size[d.find(r[i])];\n ans[m-1-i] = a*b;\n d.union(l[i], r[i]);\n size[d.find(l[i])] = a+b;\n }\n for (int i = 1; i < m; i++)\n {\n ans[i] += ans[i-1];\n System.out.println(ans[i]);\n }\n \n in.close();\n }\n \n public static class DSU\n {\n int[] set;\n \n DSU(int n)\n {\n Arrays.fill(set = new int[n], -1);\n }\n \n int find(int i)\n {\n return set[i] < 0 ? i : (set[i] = find(set[i]));\n }\n \n boolean union(int a, int b)\n {\n if ((a = find(a)) == (b = find(b))) return false;\n if (set[a] == set[b]) set[a]--;\n if (set[a] <= set[b]) set[b] = a; else set[a] = b;\n return true;\n }\n }\n}", "language": "Java", "metadata": {"date": 1551779637, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03108.html", "problem_id": "p03108", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03108/input.txt", "sample_output_relpath": "derived/input_output/data/p03108/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03108/Java/s089051218.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s089051218", "user_id": "u068098242"}, "prompt_components": {"gold_output": "0\n0\n4\n5\n6\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main\n{\n public static void main(String[] args)\n {\n Scanner in = new Scanner(System.in);\n int n = in.nextInt();\n int m = in.nextInt();\n int[] l = new int[m];\n int[] r = new int[m];\n for (int i = m-1; i >= 0; i--)\n {\n l[i] = in.nextInt();\n r[i] = in.nextInt();\n }\n \n int[] size = new int[n];\n Arrays.fill(size, 1);\n long[] ans = new long[m];\n DSU d = new DSU(n);\n for (int i = 0; i < m; i++)\n \tif (d.find(l[i]) != d.find(r[i]))\n {\n int a = size[d.find(l[i])];\n int b = size[d.find(r[i])];\n ans[m-1-i] = a*b;\n d.union(l[i], r[i]);\n size[d.find(l[i])] = a+b;\n }\n for (int i = 1; i < m; i++)\n {\n ans[i] += ans[i-1];\n System.out.println(ans[i]);\n }\n \n in.close();\n }\n \n public static class DSU\n {\n int[] set;\n \n DSU(int n)\n {\n Arrays.fill(set = new int[n], -1);\n }\n \n int find(int i)\n {\n return set[i] < 0 ? i : (set[i] = find(set[i]));\n }\n \n boolean union(int a, int b)\n {\n if ((a = find(a)) == (b = find(b))) return false;\n if (set[a] == set[b]) set[a]--;\n if (set[a] <= set[b]) set[b] = a; else set[a] = b;\n return true;\n }\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N islands and M bridges.\n\nThe i-th bridge connects the A_i-th and B_i-th islands bidirectionally.\n\nInitially, we can travel between any two islands using some of these bridges.\n\nHowever, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to the M-th bridge.\n\nLet the inconvenience be the number of pairs of islands (a, b) (a < b) such that we are no longer able to travel between the a-th and b-th islands using some of the bridges remaining.\n\nFor each i (1 \\leq i \\leq M), find the inconvenience just after the i-th bridge collapses.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i < B_i \\leq N\n\nAll pairs (A_i, B_i) are distinct.\n\nThe inconvenience is initially 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_M B_M\n\nOutput\n\nIn the order i = 1, 2, ..., M, print the inconvenience just after the i-th bridge collapses.\nNote that the answer may not fit into a 32-bit integer type.\n\nSample Input 1\n\n4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n\nSample Output 1\n\n0\n0\n4\n5\n6\n\nFor example, when the first to third bridges have collapsed, the inconvenience is 4 since we can no longer travel between the pairs (1, 2), (1, 3), (2, 4) and (3, 4).\n\nSample Input 2\n\n6 5\n2 3\n1 2\n5 6\n3 4\n4 5\n\nSample Output 2\n\n8\n9\n12\n14\n15\n\nSample Input 3\n\n2 1\n1 2\n\nSample Output 3\n\n1", "sample_input": "4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n"}, "reference_outputs": ["0\n0\n4\n5\n6\n"], "source_document_id": "p03108", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N islands and M bridges.\n\nThe i-th bridge connects the A_i-th and B_i-th islands bidirectionally.\n\nInitially, we can travel between any two islands using some of these bridges.\n\nHowever, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to the M-th bridge.\n\nLet the inconvenience be the number of pairs of islands (a, b) (a < b) such that we are no longer able to travel between the a-th and b-th islands using some of the bridges remaining.\n\nFor each i (1 \\leq i \\leq M), find the inconvenience just after the i-th bridge collapses.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i < B_i \\leq N\n\nAll pairs (A_i, B_i) are distinct.\n\nThe inconvenience is initially 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_M B_M\n\nOutput\n\nIn the order i = 1, 2, ..., M, print the inconvenience just after the i-th bridge collapses.\nNote that the answer may not fit into a 32-bit integer type.\n\nSample Input 1\n\n4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n\nSample Output 1\n\n0\n0\n4\n5\n6\n\nFor example, when the first to third bridges have collapsed, the inconvenience is 4 since we can no longer travel between the pairs (1, 2), (1, 3), (2, 4) and (3, 4).\n\nSample Input 2\n\n6 5\n2 3\n1 2\n5 6\n3 4\n4 5\n\nSample Output 2\n\n8\n9\n12\n14\n15\n\nSample Input 3\n\n2 1\n1 2\n\nSample Output 3\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1366, "cpu_time_ms": 562, "memory_kb": 65956}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s398126297", "group_id": "codeNet:p03109", "input_text": "import java.time.LocalDate;\nimport java.time.format.DateTimeFormatter;\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String S = sc.next();\n DateTimeFormatter sdf = DateTimeFormatter.ofPattern(\"yyyy/MM/dd\");\n LocalDate reiwa = LocalDate.of(2019, 5, 1);\n\n LocalDate d = LocalDate.parse(S, sdf);\n if (d.isBefore(reiwa)) {\n System.out.println(\"Heisei\");\n } else {\n System.out.println(\"TBD\");\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1555150900, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03109.html", "problem_id": "p03109", "resource_group": "high_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/Java/s398126297.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s398126297", "user_id": "u291133005"}, "prompt_components": {"gold_output": "Heisei\n", "input_to_evaluate": "import java.time.LocalDate;\nimport java.time.format.DateTimeFormatter;\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String S = sc.next();\n DateTimeFormatter sdf = DateTimeFormatter.ofPattern(\"yyyy/MM/dd\");\n LocalDate reiwa = LocalDate.of(2019, 5, 1);\n\n LocalDate d = LocalDate.parse(S, sdf);\n if (d.isBefore(reiwa)) {\n System.out.println(\"Heisei\");\n } else {\n System.out.println(\"TBD\");\n }\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": 515, "cpu_time_ms": 198, "memory_kb": 27220}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s849750229", "group_id": "codeNet:p03111", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.io.Closeable;\nimport java.io.IOException;\nimport java.util.NoSuchElementException;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author HBonsai\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n FastScanner in = new FastScanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n CSyntheticKadomatsu solver = new CSyntheticKadomatsu();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class CSyntheticKadomatsu {\n int N = 0;\n int A = 0;\n int B = 0;\n int C = 0;\n int[] l = null;\n final int INF = 1 << 29;\n\n public void solve(int testNumber, FastScanner in, PrintWriter out) {\n N = in.nextInt();\n A = in.nextInt();\n B = in.nextInt();\n C = in.nextInt();\n l = in.nextIntArray(N);\n int ans = dfs(0, 0, 0, 0);\n out.println(ans);\n }\n\n int dfs(int i, int a, int b, int c) {\n if (i == N) {\n if (a > 0 && b > 0 && c > 0) {\n // 最初の1本に対して合成魔法のコストを払う必要はないのでここで引いておく(※)\n return Math.abs(a - A) + Math.abs(b - B) + Math.abs(c - C) - 30;\n // 無に対して延長魔法は使えないのでa,b,cどれにも+l[i]しなかったパターンにはINFを入れる\n } else {\n return INF;\n }\n }\n int ret0 = dfs(i + 1, a, b, c);\n // ※ここでは最初の1本に対しても合成魔法のコストを払っている\n int ret1 = dfs(i + 1, a + l[i], b, c) + 10;\n int ret2 = dfs(i + 1, a, b + l[i], c) + 10;\n int ret3 = dfs(i + 1, a, b, c + l[i]) + 10;\n return Math.min(ret0, Math.min(ret1, Math.min(ret2, ret3)));\n }\n\n }\n\n static class FastScanner implements Closeable {\n private final InputStream in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n public FastScanner(InputStream in) {\n this.in = in;\n }\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) return buffer[ptr++];\n else return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n return hasNextByte();\n }\n\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n\n public int[] nextIntArray(final int n) {\n final int[] res = new int[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextInt();\n }\n return res;\n }\n\n public void close() {\n try {\n in.close();\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1551080835, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03111.html", "problem_id": "p03111", "resource_group": "high_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/Java/s849750229.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s849750229", "user_id": "u752146501"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.io.Closeable;\nimport java.io.IOException;\nimport java.util.NoSuchElementException;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author HBonsai\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n FastScanner in = new FastScanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n CSyntheticKadomatsu solver = new CSyntheticKadomatsu();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class CSyntheticKadomatsu {\n int N = 0;\n int A = 0;\n int B = 0;\n int C = 0;\n int[] l = null;\n final int INF = 1 << 29;\n\n public void solve(int testNumber, FastScanner in, PrintWriter out) {\n N = in.nextInt();\n A = in.nextInt();\n B = in.nextInt();\n C = in.nextInt();\n l = in.nextIntArray(N);\n int ans = dfs(0, 0, 0, 0);\n out.println(ans);\n }\n\n int dfs(int i, int a, int b, int c) {\n if (i == N) {\n if (a > 0 && b > 0 && c > 0) {\n // 最初の1本に対して合成魔法のコストを払う必要はないのでここで引いておく(※)\n return Math.abs(a - A) + Math.abs(b - B) + Math.abs(c - C) - 30;\n // 無に対して延長魔法は使えないのでa,b,cどれにも+l[i]しなかったパターンにはINFを入れる\n } else {\n return INF;\n }\n }\n int ret0 = dfs(i + 1, a, b, c);\n // ※ここでは最初の1本に対しても合成魔法のコストを払っている\n int ret1 = dfs(i + 1, a + l[i], b, c) + 10;\n int ret2 = dfs(i + 1, a, b + l[i], c) + 10;\n int ret3 = dfs(i + 1, a, b, c + l[i]) + 10;\n return Math.min(ret0, Math.min(ret1, Math.min(ret2, ret3)));\n }\n\n }\n\n static class FastScanner implements Closeable {\n private final InputStream in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n public FastScanner(InputStream in) {\n this.in = in;\n }\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) return buffer[ptr++];\n else return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n return hasNextByte();\n }\n\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n\n public int[] nextIntArray(final int n) {\n final int[] res = new int[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextInt();\n }\n return res;\n }\n\n public void close() {\n try {\n in.close();\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n\n }\n}\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": 4708, "cpu_time_ms": 93, "memory_kb": 22996}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s442210330", "group_id": "codeNet:p03112", "input_text": "import java.io.*;\nimport java.util.*;\nimport java.lang.*;\npublic class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\tMyScanner sc = new MyScanner();\n\t\tint a=sc.nextInt();\n\t\tint b=sc.nextInt();\n\t\tint q=sc.nextInt();\n\t\tlong s[]=new long[a];\n\t\tlong t[]=new long[b];\n\t\tlong ans[]=new long[q];\n\t\tfor (int i = 0; i < a; i++) {\n\t\t\ts[i]=sc.nextLong();\n\t\t}\n\t\tfor (int i = 0; i < b; i++) {\n\t\t\tt[i]=sc.nextLong();\n\t\t}\n\t\t\n\t\tlong x[]=new long[q];\n\t\tfor (int i = 0; i < q; i++) {\n\t\t\tx[i]=sc.nextLong();\n\t\t}\n\t\t\n\t\t\n\t\tint sn[]=new int[q];\n\t\tint tn[]=new int[q];\n\t\tfor (int i = 0; i < q; i++) {\n\t\t\tsn[i]=nib(s,x[i],0,a-1);\n\t\t\ttn[i]=nib(t,s[sn[i]],0,b-1);\n\t\t\tans[i]=Math.abs(s[sn[i]]-t[tn[i]])+Math.min(Math.abs(s[sn[i]]-x[i]),Math.abs(t[tn[i]]-x[i]));\n\t\t\t\n\t\t\ttn[i]=nib(t,x[i],0,b-1);\n\t\t\tsn[i]=nib(s,t[tn[i]],0,a-1);\n\t\t\t\n\t\t\tans[i]=Math.min(ans[i],ans[i]=Math.abs(s[sn[i]]-t[tn[i]])+Math.min(Math.abs(s[sn[i]]-x[i]),Math.abs(t[tn[i]]-x[i])));\n\t\t\t\n\t\t}\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\tfor (int i = 0; i < q; i++) {\n\t\t\tSystem.out.println(ans[i]);\n\t\t}\n\t\t\n\t\t\n\t}\n\tstatic int nib(long[] a,long x,int l,int r) {\n\t\tint an=0;\n\t\t\n\t\t\n\t\tif(l==r) {\n\t\t\tan=l;\n\t\t}else if(x que = new PriorityQueue<>((k, l) -> l.y - k.y);\n\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n b[i] = sc.nextInt();\n que.add(new Point(i, a[i] + b[i]));\n }\n\n boolean t = true;\n\n long ts = 0;\n long as = 0;\n\n while (!que.isEmpty()) {\n if (t) {\n ts += a[que.poll().x];\n } else {\n as += b[que.poll().x];\n }\n t = !t;\n }\n\n System.out.println(ts - as);\n }\n}", "language": "Java", "metadata": {"date": 1592140926, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03141.html", "problem_id": "p03141", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03141/input.txt", "sample_output_relpath": "derived/input_output/data/p03141/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03141/Java/s259012748.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s259012748", "user_id": "u711620077"}, "prompt_components": {"gold_output": "20\n", "input_to_evaluate": "import java.awt.*;\nimport java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n // write your code here\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n\n int[] a = new int[n];\n int[] b = new int[n];\n\n PriorityQueue que = new PriorityQueue<>((k, l) -> l.y - k.y);\n\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n b[i] = sc.nextInt();\n que.add(new Point(i, a[i] + b[i]));\n }\n\n boolean t = true;\n\n long ts = 0;\n long as = 0;\n\n while (!que.isEmpty()) {\n if (t) {\n ts += a[que.poll().x];\n } else {\n as += b[que.poll().x];\n }\n t = !t;\n }\n\n System.out.println(ts - as);\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N dishes of cuisine placed in front of Takahashi and Aoki.\nFor convenience, we call these dishes Dish 1, Dish 2, ..., Dish N.\n\nWhen Takahashi eats Dish i, he earns A_i points of happiness; when Aoki eats Dish i, she earns B_i points of happiness.\n\nStarting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat.\nHere, both of them choose dishes so that the following value is maximized: \"the sum of the happiness he/she will earn in the end\" minus \"the sum of the happiness the other person will earn in the end\".\n\nFind the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nSample Input 1\n\n3\n10 10\n20 20\n30 30\n\nSample Output 1\n\n20\n\nIn this sample, both of them earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since Takahashi and Aoki have the same \"taste\", each time they will choose the dish with which they can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (30 + 10) - 20 = 20.\n\nSample Input 2\n\n3\n20 10\n20 20\n20 30\n\nSample Output 2\n\n20\n\nIn this sample, Takahashi earns 20 points of happiness by eating any one of the dishes 1, 2 and 3, but Aoki earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since only Aoki has likes and dislikes, each time they will choose the dish with which Aoki can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (20 + 20) - 20 = 20.\n\nSample Input 3\n\n6\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n\nSample Output 3\n\n-2999999997\n\nNote that the answer may not fit into a 32-bit integer.", "sample_input": "3\n10 10\n20 20\n30 30\n"}, "reference_outputs": ["20\n"], "source_document_id": "p03141", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N dishes of cuisine placed in front of Takahashi and Aoki.\nFor convenience, we call these dishes Dish 1, Dish 2, ..., Dish N.\n\nWhen Takahashi eats Dish i, he earns A_i points of happiness; when Aoki eats Dish i, she earns B_i points of happiness.\n\nStarting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat.\nHere, both of them choose dishes so that the following value is maximized: \"the sum of the happiness he/she will earn in the end\" minus \"the sum of the happiness the other person will earn in the end\".\n\nFind the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nSample Input 1\n\n3\n10 10\n20 20\n30 30\n\nSample Output 1\n\n20\n\nIn this sample, both of them earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since Takahashi and Aoki have the same \"taste\", each time they will choose the dish with which they can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (30 + 10) - 20 = 20.\n\nSample Input 2\n\n3\n20 10\n20 20\n20 30\n\nSample Output 2\n\n20\n\nIn this sample, Takahashi earns 20 points of happiness by eating any one of the dishes 1, 2 and 3, but Aoki earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since only Aoki has likes and dislikes, each time they will choose the dish with which Aoki can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (20 + 20) - 20 = 20.\n\nSample Input 3\n\n6\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n\nSample Output 3\n\n-2999999997\n\nNote that the answer may not fit into a 32-bit integer.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 829, "cpu_time_ms": 763, "memory_kb": 88940}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s506383808", "group_id": "codeNet:p03141", "input_text": "import java.util.Comparator;\nimport java.util.HashMap;\nimport java.util.LinkedList;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Scanner;\nimport java.util.stream.Collectors;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tfinal int N = sc.nextInt();\n\t\tsc.nextLine();\n\t\tfinal Map A = new HashMap<>();\n\t\tfinal Map B = new HashMap<>();\n\t\tfinal boolean[] selected = new boolean[N];\n\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tfinal String line = sc.nextLine();\n\t\t\tfinal String[] split = line.split(\" \");\n\t\t\tfinal long prefA = Long.parseLong(split[0]);\n\t\t\tfinal long prefB = Long.parseLong(split[1]);\n\n\t\t\tA.put(i, prefA);\n\t\t\tB.put(i, prefB);\n\t\t\tselected[i] = false;\n\t\t}\n\n\t\tList> sortedA = A.entrySet().stream()\n\t\t\t\t.sorted(Map.Entry.comparingByValue(new ValueComparator()))\n\t\t\t\t.collect(Collectors.toCollection(LinkedList::new));\n\t\t\n\t\tList> sortedB = B.entrySet().stream()\n\t\t\t\t.sorted(Map.Entry.comparingByValue(new ValueComparator()))\n\t\t\t\t.collect(Collectors.toCollection(LinkedList::new));\n\n\t\tlong takahashi = 0;\n\t\tlong aoki = 0;\n\n\t\tint numTrials = 0;\n\t\twhile (numTrials < N) {\n\t\t\tboolean t = (numTrials % 2) == 0;\n\t\t\t\n\t\t\tMap.Entry maxT = getHighest(N, sortedA, selected);\n\t\t\tMap.Entry nextT = getSecondHighest(N, sortedA, selected);\n\t\t\tlong prefMaxT = maxT.getValue();\n\t\t\tlong prefNextT = (nextT == null) ? 0 : nextT.getValue();\n\t\t\tlong expT = prefMaxT - prefNextT;\n\t\t\t\n\t\t\tMap.Entry maxA = getHighest(N, sortedB, selected);\n\t\t\tMap.Entry nextA = getSecondHighest(N, sortedB, selected);\n\t\t\tlong prefMaxA = maxA.getValue();\n\t\t\tlong prefNextA = (nextA == null) ? 0 : nextA.getValue();\n\t\t\tlong expA = prefMaxA - prefNextA;\n\n\t\t\tif (t) {\n\t\t\t\tif (expT > expA) {\n\t\t\t\t\ttakahashi += prefMaxT;\n\t\t\t\t\tselected[maxT.getKey()] = true;\n\t\t\t\t} else {\n\t\t\t\t\tfinal int key = maxA.getKey();\n\t\t\t\t\ttakahashi += A.get(key);\n\t\t\t\t\tselected[key] = true;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (expA > expT) {\n\t\t\t\t\taoki += prefMaxA;\n\t\t\t\t\tselected[maxA.getKey()] = true;\n\t\t\t\t} else {\n\t\t\t\t\tfinal int key = maxT.getKey();\n\t\t\t\t\taoki += B.get(key);\n\t\t\t\t\tselected[key] = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnumTrials++;\n\t\t}\n\n\t\tSystem.out.println(takahashi - aoki);\n\t}\n\t\n\tprivate static Map.Entry getHighest(int N, List> prefs, boolean[] selected) {\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tfinal Map.Entry e = prefs.get(i);\n\t\t\tfinal boolean sel = selected[e.getKey()];\n\t\t\t\n\t\t\tif (!sel) {\n\t\t\t\treturn e;\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn null;\n\t}\n\t\n\tprivate static Map.Entry getSecondHighest(int N, List> prefs, boolean[] selected) {\n\t\tboolean firstFound = false;\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tfinal Map.Entry e = prefs.get(i);\n\t\t\tfinal boolean sel = selected[e.getKey()];\n\t\t\t\n\t\t\tif (!sel) {\n\t\t\t\tif (firstFound) {\n\t\t\t\t\treturn e;\n\t\t\t\t} else {\n\t\t\t\t\tfirstFound = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn null;\n\t}\n\t\n}\n\nclass ValueComparator implements Comparator {\n\n\t@Override\n\tpublic int compare(Long o1, Long o2) {\n\t\treturn Long.compare(o2, o1);\n\t}\n\n}", "language": "Java", "metadata": {"date": 1548646431, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03141.html", "problem_id": "p03141", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03141/input.txt", "sample_output_relpath": "derived/input_output/data/p03141/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03141/Java/s506383808.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s506383808", "user_id": "u257782712"}, "prompt_components": {"gold_output": "20\n", "input_to_evaluate": "import java.util.Comparator;\nimport java.util.HashMap;\nimport java.util.LinkedList;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Scanner;\nimport java.util.stream.Collectors;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tfinal int N = sc.nextInt();\n\t\tsc.nextLine();\n\t\tfinal Map A = new HashMap<>();\n\t\tfinal Map B = new HashMap<>();\n\t\tfinal boolean[] selected = new boolean[N];\n\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tfinal String line = sc.nextLine();\n\t\t\tfinal String[] split = line.split(\" \");\n\t\t\tfinal long prefA = Long.parseLong(split[0]);\n\t\t\tfinal long prefB = Long.parseLong(split[1]);\n\n\t\t\tA.put(i, prefA);\n\t\t\tB.put(i, prefB);\n\t\t\tselected[i] = false;\n\t\t}\n\n\t\tList> sortedA = A.entrySet().stream()\n\t\t\t\t.sorted(Map.Entry.comparingByValue(new ValueComparator()))\n\t\t\t\t.collect(Collectors.toCollection(LinkedList::new));\n\t\t\n\t\tList> sortedB = B.entrySet().stream()\n\t\t\t\t.sorted(Map.Entry.comparingByValue(new ValueComparator()))\n\t\t\t\t.collect(Collectors.toCollection(LinkedList::new));\n\n\t\tlong takahashi = 0;\n\t\tlong aoki = 0;\n\n\t\tint numTrials = 0;\n\t\twhile (numTrials < N) {\n\t\t\tboolean t = (numTrials % 2) == 0;\n\t\t\t\n\t\t\tMap.Entry maxT = getHighest(N, sortedA, selected);\n\t\t\tMap.Entry nextT = getSecondHighest(N, sortedA, selected);\n\t\t\tlong prefMaxT = maxT.getValue();\n\t\t\tlong prefNextT = (nextT == null) ? 0 : nextT.getValue();\n\t\t\tlong expT = prefMaxT - prefNextT;\n\t\t\t\n\t\t\tMap.Entry maxA = getHighest(N, sortedB, selected);\n\t\t\tMap.Entry nextA = getSecondHighest(N, sortedB, selected);\n\t\t\tlong prefMaxA = maxA.getValue();\n\t\t\tlong prefNextA = (nextA == null) ? 0 : nextA.getValue();\n\t\t\tlong expA = prefMaxA - prefNextA;\n\n\t\t\tif (t) {\n\t\t\t\tif (expT > expA) {\n\t\t\t\t\ttakahashi += prefMaxT;\n\t\t\t\t\tselected[maxT.getKey()] = true;\n\t\t\t\t} else {\n\t\t\t\t\tfinal int key = maxA.getKey();\n\t\t\t\t\ttakahashi += A.get(key);\n\t\t\t\t\tselected[key] = true;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (expA > expT) {\n\t\t\t\t\taoki += prefMaxA;\n\t\t\t\t\tselected[maxA.getKey()] = true;\n\t\t\t\t} else {\n\t\t\t\t\tfinal int key = maxT.getKey();\n\t\t\t\t\taoki += B.get(key);\n\t\t\t\t\tselected[key] = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnumTrials++;\n\t\t}\n\n\t\tSystem.out.println(takahashi - aoki);\n\t}\n\t\n\tprivate static Map.Entry getHighest(int N, List> prefs, boolean[] selected) {\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tfinal Map.Entry e = prefs.get(i);\n\t\t\tfinal boolean sel = selected[e.getKey()];\n\t\t\t\n\t\t\tif (!sel) {\n\t\t\t\treturn e;\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn null;\n\t}\n\t\n\tprivate static Map.Entry getSecondHighest(int N, List> prefs, boolean[] selected) {\n\t\tboolean firstFound = false;\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tfinal Map.Entry e = prefs.get(i);\n\t\t\tfinal boolean sel = selected[e.getKey()];\n\t\t\t\n\t\t\tif (!sel) {\n\t\t\t\tif (firstFound) {\n\t\t\t\t\treturn e;\n\t\t\t\t} else {\n\t\t\t\t\tfirstFound = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn null;\n\t}\n\t\n}\n\nclass ValueComparator implements Comparator {\n\n\t@Override\n\tpublic int compare(Long o1, Long o2) {\n\t\treturn Long.compare(o2, o1);\n\t}\n\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N dishes of cuisine placed in front of Takahashi and Aoki.\nFor convenience, we call these dishes Dish 1, Dish 2, ..., Dish N.\n\nWhen Takahashi eats Dish i, he earns A_i points of happiness; when Aoki eats Dish i, she earns B_i points of happiness.\n\nStarting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat.\nHere, both of them choose dishes so that the following value is maximized: \"the sum of the happiness he/she will earn in the end\" minus \"the sum of the happiness the other person will earn in the end\".\n\nFind the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nSample Input 1\n\n3\n10 10\n20 20\n30 30\n\nSample Output 1\n\n20\n\nIn this sample, both of them earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since Takahashi and Aoki have the same \"taste\", each time they will choose the dish with which they can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (30 + 10) - 20 = 20.\n\nSample Input 2\n\n3\n20 10\n20 20\n20 30\n\nSample Output 2\n\n20\n\nIn this sample, Takahashi earns 20 points of happiness by eating any one of the dishes 1, 2 and 3, but Aoki earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since only Aoki has likes and dislikes, each time they will choose the dish with which Aoki can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (20 + 20) - 20 = 20.\n\nSample Input 3\n\n6\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n\nSample Output 3\n\n-2999999997\n\nNote that the answer may not fit into a 32-bit integer.", "sample_input": "3\n10 10\n20 20\n30 30\n"}, "reference_outputs": ["20\n"], "source_document_id": "p03141", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N dishes of cuisine placed in front of Takahashi and Aoki.\nFor convenience, we call these dishes Dish 1, Dish 2, ..., Dish N.\n\nWhen Takahashi eats Dish i, he earns A_i points of happiness; when Aoki eats Dish i, she earns B_i points of happiness.\n\nStarting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat.\nHere, both of them choose dishes so that the following value is maximized: \"the sum of the happiness he/she will earn in the end\" minus \"the sum of the happiness the other person will earn in the end\".\n\nFind the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nSample Input 1\n\n3\n10 10\n20 20\n30 30\n\nSample Output 1\n\n20\n\nIn this sample, both of them earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since Takahashi and Aoki have the same \"taste\", each time they will choose the dish with which they can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (30 + 10) - 20 = 20.\n\nSample Input 2\n\n3\n20 10\n20 20\n20 30\n\nSample Output 2\n\n20\n\nIn this sample, Takahashi earns 20 points of happiness by eating any one of the dishes 1, 2 and 3, but Aoki earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since only Aoki has likes and dislikes, each time they will choose the dish with which Aoki can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (20 + 20) - 20 = 20.\n\nSample Input 3\n\n6\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n\nSample Output 3\n\n-2999999997\n\nNote that the answer may not fit into a 32-bit integer.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3181, "cpu_time_ms": 2109, "memory_kb": 159140}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s457089083", "group_id": "codeNet:p03141", "input_text": "import java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String args[]) {\n try (Scanner in = new Scanner(System.in)) {\n int N = in.nextInt();\n long[] A = new long[N];\n long[] B = new long[N];\n ArrayList As = new ArrayList<>();\n for (int i = 0; i < N; i++) {\n A[i] = in.nextInt();\n B[i] = in.nextInt();\n As.add(new A(A[i], B[i], i));\n }\n Collections.sort(As, new Comparator() {\n @Override\n public int compare(A o1, A o2) {\n if (o1.a - o1.b < o2.a - o2.b) {\n return -1;\n }\n if (o1.a - o1.b > o2.a - o2.b) {\n return 1;\n }\n if (o1.a < o2.a) {\n return 1;\n }\n if (o1.a > o2.a) {\n return -1;\n }\n if (o1.b < o2.b) {\n return -1;\n }\n if (o1.b > o2.b) {\n return 1;\n }\n return 0;\n }\n });\n\n long sum = 0;\n for (int i = 0; i < N; i++) {\n if (i % 2 == 0) {\n sum += As.get(i).a;\n } else {\n sum -= As.get(i).b;\n }\n// Utils.debug(i, sum, As.get(i).a, As.get(i).b, As.get(i).i);\n }\n\n System.out.println(sum);\n }\n }\n}\n\nclass A {\n long a;\n long b;\n int i;\n\n public A(long a, long b, int i) {\n super();\n this.a = a;\n this.b = b;\n this.i = i;\n }\n}", "language": "Java", "metadata": {"date": 1548644039, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03141.html", "problem_id": "p03141", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03141/input.txt", "sample_output_relpath": "derived/input_output/data/p03141/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03141/Java/s457089083.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s457089083", "user_id": "u552502395"}, "prompt_components": {"gold_output": "20\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String args[]) {\n try (Scanner in = new Scanner(System.in)) {\n int N = in.nextInt();\n long[] A = new long[N];\n long[] B = new long[N];\n ArrayList As = new ArrayList<>();\n for (int i = 0; i < N; i++) {\n A[i] = in.nextInt();\n B[i] = in.nextInt();\n As.add(new A(A[i], B[i], i));\n }\n Collections.sort(As, new Comparator() {\n @Override\n public int compare(A o1, A o2) {\n if (o1.a - o1.b < o2.a - o2.b) {\n return -1;\n }\n if (o1.a - o1.b > o2.a - o2.b) {\n return 1;\n }\n if (o1.a < o2.a) {\n return 1;\n }\n if (o1.a > o2.a) {\n return -1;\n }\n if (o1.b < o2.b) {\n return -1;\n }\n if (o1.b > o2.b) {\n return 1;\n }\n return 0;\n }\n });\n\n long sum = 0;\n for (int i = 0; i < N; i++) {\n if (i % 2 == 0) {\n sum += As.get(i).a;\n } else {\n sum -= As.get(i).b;\n }\n// Utils.debug(i, sum, As.get(i).a, As.get(i).b, As.get(i).i);\n }\n\n System.out.println(sum);\n }\n }\n}\n\nclass A {\n long a;\n long b;\n int i;\n\n public A(long a, long b, int i) {\n super();\n this.a = a;\n this.b = b;\n this.i = i;\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N dishes of cuisine placed in front of Takahashi and Aoki.\nFor convenience, we call these dishes Dish 1, Dish 2, ..., Dish N.\n\nWhen Takahashi eats Dish i, he earns A_i points of happiness; when Aoki eats Dish i, she earns B_i points of happiness.\n\nStarting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat.\nHere, both of them choose dishes so that the following value is maximized: \"the sum of the happiness he/she will earn in the end\" minus \"the sum of the happiness the other person will earn in the end\".\n\nFind the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nSample Input 1\n\n3\n10 10\n20 20\n30 30\n\nSample Output 1\n\n20\n\nIn this sample, both of them earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since Takahashi and Aoki have the same \"taste\", each time they will choose the dish with which they can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (30 + 10) - 20 = 20.\n\nSample Input 2\n\n3\n20 10\n20 20\n20 30\n\nSample Output 2\n\n20\n\nIn this sample, Takahashi earns 20 points of happiness by eating any one of the dishes 1, 2 and 3, but Aoki earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since only Aoki has likes and dislikes, each time they will choose the dish with which Aoki can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (20 + 20) - 20 = 20.\n\nSample Input 3\n\n6\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n\nSample Output 3\n\n-2999999997\n\nNote that the answer may not fit into a 32-bit integer.", "sample_input": "3\n10 10\n20 20\n30 30\n"}, "reference_outputs": ["20\n"], "source_document_id": "p03141", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N dishes of cuisine placed in front of Takahashi and Aoki.\nFor convenience, we call these dishes Dish 1, Dish 2, ..., Dish N.\n\nWhen Takahashi eats Dish i, he earns A_i points of happiness; when Aoki eats Dish i, she earns B_i points of happiness.\n\nStarting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat.\nHere, both of them choose dishes so that the following value is maximized: \"the sum of the happiness he/she will earn in the end\" minus \"the sum of the happiness the other person will earn in the end\".\n\nFind the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nSample Input 1\n\n3\n10 10\n20 20\n30 30\n\nSample Output 1\n\n20\n\nIn this sample, both of them earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since Takahashi and Aoki have the same \"taste\", each time they will choose the dish with which they can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (30 + 10) - 20 = 20.\n\nSample Input 2\n\n3\n20 10\n20 20\n20 30\n\nSample Output 2\n\n20\n\nIn this sample, Takahashi earns 20 points of happiness by eating any one of the dishes 1, 2 and 3, but Aoki earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since only Aoki has likes and dislikes, each time they will choose the dish with which Aoki can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (20 + 20) - 20 = 20.\n\nSample Input 3\n\n6\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n\nSample Output 3\n\n-2999999997\n\nNote that the answer may not fit into a 32-bit integer.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1900, "cpu_time_ms": 708, "memory_kb": 95640}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s258749325", "group_id": "codeNet:p03141", "input_text": "import java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = in.nextInt();\n\t\tArrayList aa = new ArrayList<>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tint a = in.nextInt();\n\t\t\tint b = in.nextInt();\n\n\t\t\tU u = new U();\n\t\t\tu.d = a - b;\n\t\t\tu.t = a + b;\n u.a = a;\n\n\t\t\taa.add(u);\n\t\t}\n\t\tCollections.sort(aa, (u1, u2) -> u1.d - u2.d);\n\t\tlong r = 0;\n\t\tfor (int i = 0; i < aa.size(); i = i + 2) {\n\t\t\tr += aa.get(i).a;\n\t\t}\n\n\t\tin.close();\n\t\tSystem.out.println(r);\n\t}\n\n}\n\nclass U {\n\tint d;\n\tlong t;\n\tint a;\n}", "language": "Java", "metadata": {"date": 1548643770, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03141.html", "problem_id": "p03141", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03141/input.txt", "sample_output_relpath": "derived/input_output/data/p03141/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03141/Java/s258749325.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s258749325", "user_id": "u059223549"}, "prompt_components": {"gold_output": "20\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = in.nextInt();\n\t\tArrayList aa = new ArrayList<>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tint a = in.nextInt();\n\t\t\tint b = in.nextInt();\n\n\t\t\tU u = new U();\n\t\t\tu.d = a - b;\n\t\t\tu.t = a + b;\n u.a = a;\n\n\t\t\taa.add(u);\n\t\t}\n\t\tCollections.sort(aa, (u1, u2) -> u1.d - u2.d);\n\t\tlong r = 0;\n\t\tfor (int i = 0; i < aa.size(); i = i + 2) {\n\t\t\tr += aa.get(i).a;\n\t\t}\n\n\t\tin.close();\n\t\tSystem.out.println(r);\n\t}\n\n}\n\nclass U {\n\tint d;\n\tlong t;\n\tint a;\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N dishes of cuisine placed in front of Takahashi and Aoki.\nFor convenience, we call these dishes Dish 1, Dish 2, ..., Dish N.\n\nWhen Takahashi eats Dish i, he earns A_i points of happiness; when Aoki eats Dish i, she earns B_i points of happiness.\n\nStarting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat.\nHere, both of them choose dishes so that the following value is maximized: \"the sum of the happiness he/she will earn in the end\" minus \"the sum of the happiness the other person will earn in the end\".\n\nFind the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nSample Input 1\n\n3\n10 10\n20 20\n30 30\n\nSample Output 1\n\n20\n\nIn this sample, both of them earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since Takahashi and Aoki have the same \"taste\", each time they will choose the dish with which they can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (30 + 10) - 20 = 20.\n\nSample Input 2\n\n3\n20 10\n20 20\n20 30\n\nSample Output 2\n\n20\n\nIn this sample, Takahashi earns 20 points of happiness by eating any one of the dishes 1, 2 and 3, but Aoki earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since only Aoki has likes and dislikes, each time they will choose the dish with which Aoki can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (20 + 20) - 20 = 20.\n\nSample Input 3\n\n6\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n\nSample Output 3\n\n-2999999997\n\nNote that the answer may not fit into a 32-bit integer.", "sample_input": "3\n10 10\n20 20\n30 30\n"}, "reference_outputs": ["20\n"], "source_document_id": "p03141", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N dishes of cuisine placed in front of Takahashi and Aoki.\nFor convenience, we call these dishes Dish 1, Dish 2, ..., Dish N.\n\nWhen Takahashi eats Dish i, he earns A_i points of happiness; when Aoki eats Dish i, she earns B_i points of happiness.\n\nStarting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat.\nHere, both of them choose dishes so that the following value is maximized: \"the sum of the happiness he/she will earn in the end\" minus \"the sum of the happiness the other person will earn in the end\".\n\nFind the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the value: \"the sum of the happiness Takahashi earns in the end\" minus \"the sum of the happiness Aoki earns in the end\".\n\nSample Input 1\n\n3\n10 10\n20 20\n30 30\n\nSample Output 1\n\n20\n\nIn this sample, both of them earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since Takahashi and Aoki have the same \"taste\", each time they will choose the dish with which they can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (30 + 10) - 20 = 20.\n\nSample Input 2\n\n3\n20 10\n20 20\n20 30\n\nSample Output 2\n\n20\n\nIn this sample, Takahashi earns 20 points of happiness by eating any one of the dishes 1, 2 and 3, but Aoki earns 10 points of happiness by eating Dish 1, 20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since only Aoki has likes and dislikes, each time they will choose the dish with which Aoki can earn the greatest happiness. Thus, first Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally Takahashi will choose Dish 1, so the answer is (20 + 20) - 20 = 20.\n\nSample Input 3\n\n6\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n\nSample Output 3\n\n-2999999997\n\nNote that the answer may not fit into a 32-bit integer.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 766, "memory_kb": 68020}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s520412079", "group_id": "codeNet:p03142", "input_text": "import java.util.*;\nimport java.util.stream.*;\n\nclass Main{\n\tstatic Scanner s=new Scanner(System.in);\n\n\tstatic class D{\n\t\tpublic D(int a,int b){\n\t\t\tthis.a=a;\n\t\t\tthis.b=b;\n\t\t}\n\t\tint a,b;\n\t}\n\tpublic static void main(String[] $){\n\t\tint n=s.nextInt(),m=s.nextInt();\n\t\tArrayList>to=new ArrayList<>(n);\n\t\tArrayList>from=new ArrayList<>(n);\n\t\tfor(int i=0;i());\n\t\t\tfrom.add(new HashSet<>());\n\t\t}\n\t\t\n\t\tfor(int e=n+m-1;e>0;--e) {\n\t\t\tint f=s.nextInt()-1;\n\t\t\tint t=s.nextInt()-1;\n\t\t\tto.get(f).add(t);\n\t\t\tfrom.get(t).add(f);\n\t\t}\n\t\t\n\t\tint root=IntStream.range(0,n).filter(i->from.get(i).isEmpty()).findAny().getAsInt();\n\t\tSystem.err.println(root);\n\t\t\n\t\tint[]parent=new int[n];\n\t\t\n\t\tArrayDequeq=new ArrayDeque<>();\n\t\tfor(int i:to.get(root)) {\n\t\t\tq.add((long)root*n+i);\n\t\t}\n\t\twhile(!q.isEmpty()) {\n\t\t\tfor(int _q=q.size();_q>0;--_q) {\n\t\t\t\tlong p=q.poll();\n\t\t\t\tint pf=(int)p/n;\n\t\t\t\tint pt=(int)p%n;\n\t\t\t\tto.get(pf).remove(pt);\n\t\t\t\tfrom.get(pt).remove(pf);\n\t\t\t\tif(from.get(pt).isEmpty())\n\t\t\t\t\tparent[pt]=pf+1;\n\t\t\t\t\n\t\t\t\tfor(int i:to.get(pt)) {\n\t\t\t\t\tq.add((long)pt*n+i);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tArrays.stream(parent).forEach(System.out::println);\n\t}\n}", "language": "Java", "metadata": {"date": 1548643087, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03142.html", "problem_id": "p03142", "resource_group": "high_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/Java/s520412079.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s520412079", "user_id": "u059234158"}, "prompt_components": {"gold_output": "0\n1\n2\n", "input_to_evaluate": "import java.util.*;\nimport java.util.stream.*;\n\nclass Main{\n\tstatic Scanner s=new Scanner(System.in);\n\n\tstatic class D{\n\t\tpublic D(int a,int b){\n\t\t\tthis.a=a;\n\t\t\tthis.b=b;\n\t\t}\n\t\tint a,b;\n\t}\n\tpublic static void main(String[] $){\n\t\tint n=s.nextInt(),m=s.nextInt();\n\t\tArrayList>to=new ArrayList<>(n);\n\t\tArrayList>from=new ArrayList<>(n);\n\t\tfor(int i=0;i());\n\t\t\tfrom.add(new HashSet<>());\n\t\t}\n\t\t\n\t\tfor(int e=n+m-1;e>0;--e) {\n\t\t\tint f=s.nextInt()-1;\n\t\t\tint t=s.nextInt()-1;\n\t\t\tto.get(f).add(t);\n\t\t\tfrom.get(t).add(f);\n\t\t}\n\t\t\n\t\tint root=IntStream.range(0,n).filter(i->from.get(i).isEmpty()).findAny().getAsInt();\n\t\tSystem.err.println(root);\n\t\t\n\t\tint[]parent=new int[n];\n\t\t\n\t\tArrayDequeq=new ArrayDeque<>();\n\t\tfor(int i:to.get(root)) {\n\t\t\tq.add((long)root*n+i);\n\t\t}\n\t\twhile(!q.isEmpty()) {\n\t\t\tfor(int _q=q.size();_q>0;--_q) {\n\t\t\t\tlong p=q.poll();\n\t\t\t\tint pf=(int)p/n;\n\t\t\t\tint pt=(int)p%n;\n\t\t\t\tto.get(pf).remove(pt);\n\t\t\t\tfrom.get(pt).remove(pf);\n\t\t\t\tif(from.get(pt).isEmpty())\n\t\t\t\t\tparent[pt]=pf+1;\n\t\t\t\t\n\t\t\t\tfor(int i:to.get(pt)) {\n\t\t\t\t\tq.add((long)pt*n+i);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tArrays.stream(parent).forEach(System.out::println);\n\t}\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": 1187, "cpu_time_ms": 2107, "memory_kb": 327236}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s232818340", "group_id": "codeNet:p03145", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tSystem.out.println(sc.nextInt() * sc.nextInt() / 2 + 0 * sc.nextInt());\n\t}\n}\n", "language": "Java", "metadata": {"date": 1575514609, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03145.html", "problem_id": "p03145", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03145/input.txt", "sample_output_relpath": "derived/input_output/data/p03145/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03145/Java/s232818340.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s232818340", "user_id": "u518703962"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tSystem.out.println(sc.nextInt() * sc.nextInt() / 2 + 0 * sc.nextInt());\n\t}\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a right triangle ABC with ∠ABC=90°.\n\nGiven the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.\n\nIt is guaranteed that the area of the triangle ABC is an integer.\n\nConstraints\n\n1 \\leq |AB|,|BC|,|CA| \\leq 100\n\nAll values in input are integers.\n\nThe area of the triangle ABC is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n|AB| |BC| |CA|\n\nOutput\n\nPrint the area of the triangle ABC.\n\nSample Input 1\n\n3 4 5\n\nSample Output 1\n\n6\n\nThis triangle has an area of 6.\n\nSample Input 2\n\n5 12 13\n\nSample Output 2\n\n30\n\nThis triangle has an area of 30.\n\nSample Input 3\n\n45 28 53\n\nSample Output 3\n\n630\n\nThis triangle has an area of 630.", "sample_input": "3 4 5\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03145", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a right triangle ABC with ∠ABC=90°.\n\nGiven the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.\n\nIt is guaranteed that the area of the triangle ABC is an integer.\n\nConstraints\n\n1 \\leq |AB|,|BC|,|CA| \\leq 100\n\nAll values in input are integers.\n\nThe area of the triangle ABC is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n|AB| |BC| |CA|\n\nOutput\n\nPrint the area of the triangle ABC.\n\nSample Input 1\n\n3 4 5\n\nSample Output 1\n\n6\n\nThis triangle has an area of 6.\n\nSample Input 2\n\n5 12 13\n\nSample Output 2\n\n30\n\nThis triangle has an area of 30.\n\nSample Input 3\n\n45 28 53\n\nSample Output 3\n\n630\n\nThis triangle has an area of 630.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 207, "cpu_time_ms": 98, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s526170613", "group_id": "codeNet:p03145", "input_text": "import java.util.*;\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\n\t\t// 出力\n\t\tSystem.out.println(sc.nextInt() * sc.nextInt() / 2);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1566785188, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03145.html", "problem_id": "p03145", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03145/input.txt", "sample_output_relpath": "derived/input_output/data/p03145/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03145/Java/s526170613.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s526170613", "user_id": "u711620077"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.util.*;\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\n\t\t// 出力\n\t\tSystem.out.println(sc.nextInt() * sc.nextInt() / 2);\n\t}\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a right triangle ABC with ∠ABC=90°.\n\nGiven the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.\n\nIt is guaranteed that the area of the triangle ABC is an integer.\n\nConstraints\n\n1 \\leq |AB|,|BC|,|CA| \\leq 100\n\nAll values in input are integers.\n\nThe area of the triangle ABC is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n|AB| |BC| |CA|\n\nOutput\n\nPrint the area of the triangle ABC.\n\nSample Input 1\n\n3 4 5\n\nSample Output 1\n\n6\n\nThis triangle has an area of 6.\n\nSample Input 2\n\n5 12 13\n\nSample Output 2\n\n30\n\nThis triangle has an area of 30.\n\nSample Input 3\n\n45 28 53\n\nSample Output 3\n\n630\n\nThis triangle has an area of 630.", "sample_input": "3 4 5\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03145", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a right triangle ABC with ∠ABC=90°.\n\nGiven the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.\n\nIt is guaranteed that the area of the triangle ABC is an integer.\n\nConstraints\n\n1 \\leq |AB|,|BC|,|CA| \\leq 100\n\nAll values in input are integers.\n\nThe area of the triangle ABC is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n|AB| |BC| |CA|\n\nOutput\n\nPrint the area of the triangle ABC.\n\nSample Input 1\n\n3 4 5\n\nSample Output 1\n\n6\n\nThis triangle has an area of 6.\n\nSample Input 2\n\n5 12 13\n\nSample Output 2\n\n30\n\nThis triangle has an area of 30.\n\nSample Input 3\n\n45 28 53\n\nSample Output 3\n\n630\n\nThis triangle has an area of 630.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 94, "memory_kb": 21972}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s963175741", "group_id": "codeNet:p03145", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.math.BigDecimal;\nimport java.text.DecimalFormat;\nimport java.util.AbstractMap;\nimport java.util.ArrayDeque;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Comparator;\nimport java.util.Deque;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Objects;\nimport java.util.PriorityQueue;\nimport java.util.Queue;\nimport java.util.Set;\nimport java.util.Stack;\nimport java.util.TreeMap;\nimport java.util.TreeSet;\n\nimport static java.util.Comparator.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n MyInput in = new MyInput(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n\n Solver solver = new Solver(in, out);\n solver.solve();\n\n out.close();\n }\n\n // ======================================================================\n\n static class Solver {\n \tMyInput in;\n \tPrintWriter out;\n public Solver(MyInput in, PrintWriter out) {\n \tthis.in = in;\n \tthis.out = out;\n }\n \n // -----------------------------------------\n //\n\t\tpublic void solve() {\n\t\t\tint AB = ni();\n\t\t\tint BC = ni();\n\t\t\tint CA = ni();\n\t\t\tprn(AB * BC / 2);\n }\n \n // -----------------------------------------\n void prn(String s) {\n \tout.println(s);\n }\n void prn(int i) {\n \tout.println(i);\n }\n void prn(long i) {\n \tout.println(i);\n }\n void prr(String s) {\n \tout.print(s);\n }\n int ni() {\n \treturn in.nextInt();\n }\n long nl() {\n \treturn in.nextLong();\n }\n double nd() {\n \treturn in.nextDouble();\n }\n String ns() {\n \treturn in.nextString();\n }\n int[] ndi(int n) {\n \tint[] ans = new int[n];\n \tfor(int i=0; i < n; i++) {\n \t\tans[i] = ni();\n \t}\n \treturn ans;\n }\n long[] ndl(int n) {\n \tlong[] ans = new long[n];\n \tfor(int i=0; i < n; i++) {\n \t\tans[i] = nl();\n \t}\n \treturn ans;\n }\n double[] ndd(int n) {\n \tdouble[] ans = new double[n];\n \tfor(int i=0; i < n; i++) {\n \t\tans[i] = nd();\n \t}\n \treturn ans;\n }\n String[] nds(int n) {\n \tString[] ans = new String[n];\n \tfor(int i=0; i < n; i++) {\n \t\tans[i] = ns();\n \t}\n \treturn ans;\n }\n int[][] nddi(int n, int m) {\n \tint[][] ans = new int[n][m];\n \tfor(int i=0; i < n; i++) {\n \tfor(int j=0; j < m; j++) {\n \t\tans[i][j] = ni();\n \t}\n \t}\n \treturn ans;\n }\n long[][] nddl(int n, int m) {\n \tlong[][] ans = new long[n][m];\n \tfor(int i=0; i < n; i++) {\n \tfor(int j=0; j < m; j++) {\n \t\tans[i][j] = nl();\n \t}\n \t}\n \treturn ans;\n }\n }\n\n static class PP{\n \tpublic int key, val;\n \tpublic PP(int key, int val) {\n \t\tthis.key = key;\n \t\tthis.val = val;\n \t}\n\t\tpublic int getKey() {\n\t\t\treturn key;\n\t\t}\n\t\tpublic void setKey(int key) {\n\t\t\tthis.key = key;\n\t\t}\n\t\tpublic int getVal() {\n\t\t\treturn val;\n\t\t}\n\t\tpublic void setVal(int val) {\n\t\t\tthis.val = val;\n\t\t}\n }\n static class PPL {\n \tpublic long key, val;\n \tpublic PPL(long key, long val) {\n \t\tthis.key = key;\n \t\tthis.val = val;\n \t}\n\t\tpublic long getKey() {\n\t\t\treturn key;\n\t\t}\n\t\tpublic void setKey(long key) {\n\t\t\tthis.key = key;\n\t\t}\n\t\tpublic long getVal() {\n\t\t\treturn val;\n\t\t}\n\t\tpublic void setVal(long val) {\n\t\t\tthis.val = val;\n\t\t}\n }\n static class PPDL {\n \tpublic long key;\n \tpublic long[] val;\n \tpublic PPDL(long key, long[] val) {\n \t\tthis.key = key;\n \t\tthis.val = val;\n \t}\n\t\tpublic long getKey() {\n\t\t\treturn key;\n\t\t}\n\t\tpublic void setKey(long key) {\n\t\t\tthis.key = key;\n\t\t}\n\t\tpublic long[] getVal() {\n\t\t\treturn val;\n\t\t}\n\t\tpublic void setVal(long[] val) {\n\t\t\tthis.val = val;\n\t\t}\n\t\tpublic void dump(PrintWriter out) {\n\t\t\tout.print(\"key = \" + key + \" val \");\n\t\t\tfor(int i=0; i < val.length; i++) {\n\t\t\t\tout.print(\"[\" + val[i] + \"] \");\n\t\t\t}\n\t\t\tout.println(\"\");\n\t\t}\n }\n // HashMap のキーに使う\n static final class PPKEY{\n \tprivate final int key, val;\n \tpublic PPKEY(int key, int val) {\n \t\tthis.key = key;\n \t\tthis.val = val;\n \t}\n\t\tpublic int getKey() {\n\t\t\treturn key;\n\t\t}\n\t\tpublic int getVal() {\n\t\t\treturn val;\n\t\t}\n\t @Override\n\t public boolean equals(Object obj) {\n\t if (obj instanceof PPKEY) {\n\t \tPPKEY dest = (PPKEY) obj;\n\t return this.key == dest.key && this.val == dest.val;\n\t } else {\n\t return false;\n\t }\n\t }\n\t @Override\n\t public int hashCode() {\n\t return Objects.hash(key, val);\n\t }\n }\n // HashMap のキーに使う\n static final class PPLKEY{\n \tprivate final long key, val;\n \tpublic PPLKEY(long key, long val) {\n \t\tthis.key = key;\n \t\tthis.val = val;\n \t}\n\t\tpublic long getKey() {\n\t\t\treturn key;\n\t\t}\n\t\tpublic long getVal() {\n\t\t\treturn val;\n\t\t}\n\t @Override\n\t public boolean equals(Object obj) {\n\t if (obj instanceof PPKEY) {\n\t \tPPKEY dest = (PPKEY) obj;\n\t return this.key == dest.key && this.val == dest.val;\n\t } else {\n\t return false;\n\t }\n\t }\n\t @Override\n\t public int hashCode() {\n\t return Objects.hash(key, val);\n\t }\n }\n // グラフのリンクリスト\n static class Graph {\n private Map> data = new HashMap>();\n void add(int key, int value) {\n \tList list = data.get(key);\n \tif(list == null) {\n \t\tlist = new ArrayList();\n \t\tdata.put(key, list);\n \t}\n \tlist.add(value);\n }\n List get(int key) {\n \treturn data.get(key);\n }\n Set keySet() {\n \treturn data.keySet();\n }\n boolean contains(int key, int value) {\n \tList list = data.get(key);\n \tif(list == null)\treturn false;\n \telse \t\t\t\treturn list.contains(value);\n }\n void dump(PrintWriter out) {\n \tfor(int key : data.keySet()) {\n \t\tout.print(key + \" : \");\n \t\tfor(int val : data.get(key)) {\n \t\t\tout.print(val + \" \");\n \t\t}\n \t\tout.println(\"\");\n \t}\n }\n }\n // 重さを持ったグラフのリンクリスト\n static class GraphWith {\n private Map> data = new HashMap>();\n void add(int key, PP p) {\n \tList list = data.get(key);\n \tif(list == null) {\n \t\tlist = new ArrayList();\n \t\tdata.put(key, list);\n \t}\n \tlist.add(p);\n }\n List get(int key) {\n \treturn data.get(key);\n }\n // グラフの存在チェック(重さは関係しない)\n boolean contains(int key, int value) {\n \tList list = data.get(key);\n \tif(list == null)\treturn false;\n \tboolean ans = false;\n \tfor(PP p : list) {\n \t\tif(p.getKey() == value) {\n \t\t\tans = true;\n \t\t\tbreak;\n \t\t}\n \t}\n \treturn ans;\n }\n }\n // グラフのリンクリスト(Long)\n static class GraphLong {\n private Map> G = new HashMap>();\n void add(long key, long value) {\n \tList list = G.get(key);\n \tif(list == null) {\n \t\tlist = new ArrayList();\n \t\tG.put(key, list);\n \t}\n \tlist.add(value);\n }\n List get(long key) {\n \treturn G.get(key);\n }\n }\n // 重さを持ったグラフのリンクリスト(Long)\n static class GraphLongWith {\n private Map> G = new HashMap>();\n void add(long key, PPL p) {\n \tList list = G.get(key);\n \tif(list == null) {\n \t\tlist = new ArrayList();\n \t\tG.put(key, list);\n \t}\n \tlist.add(p);\n }\n List get(long key) {\n \treturn G.get(key);\n }\n }\n\n // ======================================================================\n static class Pair extends AbstractMap.SimpleEntry {\n /** serialVersionUID. */\n private static final long serialVersionUID = 6411527075103472113L;\n\n public Pair(final K key, final V value) {\n super(key, value);\n }\n }\n static class MyInput {\n private final BufferedReader in;\n private static int pos;\n private static int readLen;\n private static final char[] buffer = new char[1024 * 8];\n private static char[] str = new char[500 * 8 * 2];\n private static boolean[] isDigit = new boolean[256];\n private static boolean[] isSpace = new boolean[256];\n private static boolean[] isLineSep = new boolean[256];\n\n static {\n for (int i = 0; i < 10; i++) {\n isDigit['0' + i] = true;\n }\n isDigit['-'] = true;\n isSpace[' '] = isSpace['\\r'] = isSpace['\\n'] = isSpace['\\t'] = true;\n isLineSep['\\r'] = isLineSep['\\n'] = true;\n }\n\n public MyInput(InputStream is) {\n in = new BufferedReader(new InputStreamReader(is));\n }\n\n public int read() {\n if (pos >= readLen) {\n pos = 0;\n try {\n readLen = in.read(buffer);\n } catch (IOException e) {\n throw new RuntimeException();\n }\n if (readLen <= 0) {\n throw new MyInput.EndOfFileRuntimeException();\n }\n }\n return buffer[pos++];\n }\n\n public int nextInt() {\n int len = 0;\n str[len++] = nextChar();\n len = reads(len, isSpace);\n int i = 0;\n int ret = 0;\n if (str[0] == '-') {\n i = 1;\n }\n for (; i < len; i++) ret = ret * 10 + str[i] - '0';\n if (str[0] == '-') {\n ret = -ret;\n }\n return ret;\n }\n\n public long nextLong() {\n int len = 0;\n str[len++] = nextChar();\n len = reads(len, isSpace);\n int i = 0;\n long ret = 0L;\n if (str[0] == '-') {\n i = 1;\n }\n for (; i < len; i++) ret = ret * 10 + str[i] - '0';\n if (str[0] == '-') {\n ret = -ret;\n }\n return ret;\n }\n\n public double nextDouble() {\n int len = 0;\n str[len++] = nextChar();\n len = reads(len, isSpace);\n int i = 0;\n double ret = 0;\n if (str[0] == '-') {\n i = 1;\n }\n int cnt = 0;\n for (; i < len; i++) {\n \tif(str[i] == '.') {\n \t\tcnt = 10;\n \t\tcontinue;\n \t}\n \tif(cnt == 0) {\n \t\tret = ret * 10 + str[i] - '0';\n \t} else {\n \t\tret = ret + ((double)(str[i] - '0') / cnt);\n \t\tcnt *= 10;\n \t}\n }\n if (str[0] == '-') {\n ret = -ret;\n }\n return ret;\n }\n\n public String nextString() {\n \tString ret = new String(nextDChar()).trim();\n return ret;\n }\n\n public char[] nextDChar() {\n int len = 0;\n len = reads(len, isSpace);\n char[] ret = new char[len + 1];\n for (int i=0; i < len; i++)\t\tret[i] = str[i];\n ret[len] = 0x00;\n return ret;\n }\n\n public char nextChar() {\n while (true) {\n final int c = read();\n if (!isSpace[c]) {\n return (char) c;\n }\n }\n }\n\n int reads(int len, boolean[] accept) {\n try {\n while (true) {\n final int c = read();\n if (accept[c]) {\n break;\n }\n if (str.length == len) {\n char[] rep = new char[str.length * 3 / 2];\n System.arraycopy(str, 0, rep, 0, str.length);\n str = rep;\n }\n str[len++] = (char) c;\n }\n } catch (MyInput.EndOfFileRuntimeException e) {\n }\n return len;\n }\n\n static class EndOfFileRuntimeException extends RuntimeException {\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1562392335, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03145.html", "problem_id": "p03145", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03145/input.txt", "sample_output_relpath": "derived/input_output/data/p03145/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03145/Java/s963175741.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s963175741", "user_id": "u181039779"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.math.BigDecimal;\nimport java.text.DecimalFormat;\nimport java.util.AbstractMap;\nimport java.util.ArrayDeque;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Comparator;\nimport java.util.Deque;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Objects;\nimport java.util.PriorityQueue;\nimport java.util.Queue;\nimport java.util.Set;\nimport java.util.Stack;\nimport java.util.TreeMap;\nimport java.util.TreeSet;\n\nimport static java.util.Comparator.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n MyInput in = new MyInput(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n\n Solver solver = new Solver(in, out);\n solver.solve();\n\n out.close();\n }\n\n // ======================================================================\n\n static class Solver {\n \tMyInput in;\n \tPrintWriter out;\n public Solver(MyInput in, PrintWriter out) {\n \tthis.in = in;\n \tthis.out = out;\n }\n \n // -----------------------------------------\n //\n\t\tpublic void solve() {\n\t\t\tint AB = ni();\n\t\t\tint BC = ni();\n\t\t\tint CA = ni();\n\t\t\tprn(AB * BC / 2);\n }\n \n // -----------------------------------------\n void prn(String s) {\n \tout.println(s);\n }\n void prn(int i) {\n \tout.println(i);\n }\n void prn(long i) {\n \tout.println(i);\n }\n void prr(String s) {\n \tout.print(s);\n }\n int ni() {\n \treturn in.nextInt();\n }\n long nl() {\n \treturn in.nextLong();\n }\n double nd() {\n \treturn in.nextDouble();\n }\n String ns() {\n \treturn in.nextString();\n }\n int[] ndi(int n) {\n \tint[] ans = new int[n];\n \tfor(int i=0; i < n; i++) {\n \t\tans[i] = ni();\n \t}\n \treturn ans;\n }\n long[] ndl(int n) {\n \tlong[] ans = new long[n];\n \tfor(int i=0; i < n; i++) {\n \t\tans[i] = nl();\n \t}\n \treturn ans;\n }\n double[] ndd(int n) {\n \tdouble[] ans = new double[n];\n \tfor(int i=0; i < n; i++) {\n \t\tans[i] = nd();\n \t}\n \treturn ans;\n }\n String[] nds(int n) {\n \tString[] ans = new String[n];\n \tfor(int i=0; i < n; i++) {\n \t\tans[i] = ns();\n \t}\n \treturn ans;\n }\n int[][] nddi(int n, int m) {\n \tint[][] ans = new int[n][m];\n \tfor(int i=0; i < n; i++) {\n \tfor(int j=0; j < m; j++) {\n \t\tans[i][j] = ni();\n \t}\n \t}\n \treturn ans;\n }\n long[][] nddl(int n, int m) {\n \tlong[][] ans = new long[n][m];\n \tfor(int i=0; i < n; i++) {\n \tfor(int j=0; j < m; j++) {\n \t\tans[i][j] = nl();\n \t}\n \t}\n \treturn ans;\n }\n }\n\n static class PP{\n \tpublic int key, val;\n \tpublic PP(int key, int val) {\n \t\tthis.key = key;\n \t\tthis.val = val;\n \t}\n\t\tpublic int getKey() {\n\t\t\treturn key;\n\t\t}\n\t\tpublic void setKey(int key) {\n\t\t\tthis.key = key;\n\t\t}\n\t\tpublic int getVal() {\n\t\t\treturn val;\n\t\t}\n\t\tpublic void setVal(int val) {\n\t\t\tthis.val = val;\n\t\t}\n }\n static class PPL {\n \tpublic long key, val;\n \tpublic PPL(long key, long val) {\n \t\tthis.key = key;\n \t\tthis.val = val;\n \t}\n\t\tpublic long getKey() {\n\t\t\treturn key;\n\t\t}\n\t\tpublic void setKey(long key) {\n\t\t\tthis.key = key;\n\t\t}\n\t\tpublic long getVal() {\n\t\t\treturn val;\n\t\t}\n\t\tpublic void setVal(long val) {\n\t\t\tthis.val = val;\n\t\t}\n }\n static class PPDL {\n \tpublic long key;\n \tpublic long[] val;\n \tpublic PPDL(long key, long[] val) {\n \t\tthis.key = key;\n \t\tthis.val = val;\n \t}\n\t\tpublic long getKey() {\n\t\t\treturn key;\n\t\t}\n\t\tpublic void setKey(long key) {\n\t\t\tthis.key = key;\n\t\t}\n\t\tpublic long[] getVal() {\n\t\t\treturn val;\n\t\t}\n\t\tpublic void setVal(long[] val) {\n\t\t\tthis.val = val;\n\t\t}\n\t\tpublic void dump(PrintWriter out) {\n\t\t\tout.print(\"key = \" + key + \" val \");\n\t\t\tfor(int i=0; i < val.length; i++) {\n\t\t\t\tout.print(\"[\" + val[i] + \"] \");\n\t\t\t}\n\t\t\tout.println(\"\");\n\t\t}\n }\n // HashMap のキーに使う\n static final class PPKEY{\n \tprivate final int key, val;\n \tpublic PPKEY(int key, int val) {\n \t\tthis.key = key;\n \t\tthis.val = val;\n \t}\n\t\tpublic int getKey() {\n\t\t\treturn key;\n\t\t}\n\t\tpublic int getVal() {\n\t\t\treturn val;\n\t\t}\n\t @Override\n\t public boolean equals(Object obj) {\n\t if (obj instanceof PPKEY) {\n\t \tPPKEY dest = (PPKEY) obj;\n\t return this.key == dest.key && this.val == dest.val;\n\t } else {\n\t return false;\n\t }\n\t }\n\t @Override\n\t public int hashCode() {\n\t return Objects.hash(key, val);\n\t }\n }\n // HashMap のキーに使う\n static final class PPLKEY{\n \tprivate final long key, val;\n \tpublic PPLKEY(long key, long val) {\n \t\tthis.key = key;\n \t\tthis.val = val;\n \t}\n\t\tpublic long getKey() {\n\t\t\treturn key;\n\t\t}\n\t\tpublic long getVal() {\n\t\t\treturn val;\n\t\t}\n\t @Override\n\t public boolean equals(Object obj) {\n\t if (obj instanceof PPKEY) {\n\t \tPPKEY dest = (PPKEY) obj;\n\t return this.key == dest.key && this.val == dest.val;\n\t } else {\n\t return false;\n\t }\n\t }\n\t @Override\n\t public int hashCode() {\n\t return Objects.hash(key, val);\n\t }\n }\n // グラフのリンクリスト\n static class Graph {\n private Map> data = new HashMap>();\n void add(int key, int value) {\n \tList list = data.get(key);\n \tif(list == null) {\n \t\tlist = new ArrayList();\n \t\tdata.put(key, list);\n \t}\n \tlist.add(value);\n }\n List get(int key) {\n \treturn data.get(key);\n }\n Set keySet() {\n \treturn data.keySet();\n }\n boolean contains(int key, int value) {\n \tList list = data.get(key);\n \tif(list == null)\treturn false;\n \telse \t\t\t\treturn list.contains(value);\n }\n void dump(PrintWriter out) {\n \tfor(int key : data.keySet()) {\n \t\tout.print(key + \" : \");\n \t\tfor(int val : data.get(key)) {\n \t\t\tout.print(val + \" \");\n \t\t}\n \t\tout.println(\"\");\n \t}\n }\n }\n // 重さを持ったグラフのリンクリスト\n static class GraphWith {\n private Map> data = new HashMap>();\n void add(int key, PP p) {\n \tList list = data.get(key);\n \tif(list == null) {\n \t\tlist = new ArrayList();\n \t\tdata.put(key, list);\n \t}\n \tlist.add(p);\n }\n List get(int key) {\n \treturn data.get(key);\n }\n // グラフの存在チェック(重さは関係しない)\n boolean contains(int key, int value) {\n \tList list = data.get(key);\n \tif(list == null)\treturn false;\n \tboolean ans = false;\n \tfor(PP p : list) {\n \t\tif(p.getKey() == value) {\n \t\t\tans = true;\n \t\t\tbreak;\n \t\t}\n \t}\n \treturn ans;\n }\n }\n // グラフのリンクリスト(Long)\n static class GraphLong {\n private Map> G = new HashMap>();\n void add(long key, long value) {\n \tList list = G.get(key);\n \tif(list == null) {\n \t\tlist = new ArrayList();\n \t\tG.put(key, list);\n \t}\n \tlist.add(value);\n }\n List get(long key) {\n \treturn G.get(key);\n }\n }\n // 重さを持ったグラフのリンクリスト(Long)\n static class GraphLongWith {\n private Map> G = new HashMap>();\n void add(long key, PPL p) {\n \tList list = G.get(key);\n \tif(list == null) {\n \t\tlist = new ArrayList();\n \t\tG.put(key, list);\n \t}\n \tlist.add(p);\n }\n List get(long key) {\n \treturn G.get(key);\n }\n }\n\n // ======================================================================\n static class Pair extends AbstractMap.SimpleEntry {\n /** serialVersionUID. */\n private static final long serialVersionUID = 6411527075103472113L;\n\n public Pair(final K key, final V value) {\n super(key, value);\n }\n }\n static class MyInput {\n private final BufferedReader in;\n private static int pos;\n private static int readLen;\n private static final char[] buffer = new char[1024 * 8];\n private static char[] str = new char[500 * 8 * 2];\n private static boolean[] isDigit = new boolean[256];\n private static boolean[] isSpace = new boolean[256];\n private static boolean[] isLineSep = new boolean[256];\n\n static {\n for (int i = 0; i < 10; i++) {\n isDigit['0' + i] = true;\n }\n isDigit['-'] = true;\n isSpace[' '] = isSpace['\\r'] = isSpace['\\n'] = isSpace['\\t'] = true;\n isLineSep['\\r'] = isLineSep['\\n'] = true;\n }\n\n public MyInput(InputStream is) {\n in = new BufferedReader(new InputStreamReader(is));\n }\n\n public int read() {\n if (pos >= readLen) {\n pos = 0;\n try {\n readLen = in.read(buffer);\n } catch (IOException e) {\n throw new RuntimeException();\n }\n if (readLen <= 0) {\n throw new MyInput.EndOfFileRuntimeException();\n }\n }\n return buffer[pos++];\n }\n\n public int nextInt() {\n int len = 0;\n str[len++] = nextChar();\n len = reads(len, isSpace);\n int i = 0;\n int ret = 0;\n if (str[0] == '-') {\n i = 1;\n }\n for (; i < len; i++) ret = ret * 10 + str[i] - '0';\n if (str[0] == '-') {\n ret = -ret;\n }\n return ret;\n }\n\n public long nextLong() {\n int len = 0;\n str[len++] = nextChar();\n len = reads(len, isSpace);\n int i = 0;\n long ret = 0L;\n if (str[0] == '-') {\n i = 1;\n }\n for (; i < len; i++) ret = ret * 10 + str[i] - '0';\n if (str[0] == '-') {\n ret = -ret;\n }\n return ret;\n }\n\n public double nextDouble() {\n int len = 0;\n str[len++] = nextChar();\n len = reads(len, isSpace);\n int i = 0;\n double ret = 0;\n if (str[0] == '-') {\n i = 1;\n }\n int cnt = 0;\n for (; i < len; i++) {\n \tif(str[i] == '.') {\n \t\tcnt = 10;\n \t\tcontinue;\n \t}\n \tif(cnt == 0) {\n \t\tret = ret * 10 + str[i] - '0';\n \t} else {\n \t\tret = ret + ((double)(str[i] - '0') / cnt);\n \t\tcnt *= 10;\n \t}\n }\n if (str[0] == '-') {\n ret = -ret;\n }\n return ret;\n }\n\n public String nextString() {\n \tString ret = new String(nextDChar()).trim();\n return ret;\n }\n\n public char[] nextDChar() {\n int len = 0;\n len = reads(len, isSpace);\n char[] ret = new char[len + 1];\n for (int i=0; i < len; i++)\t\tret[i] = str[i];\n ret[len] = 0x00;\n return ret;\n }\n\n public char nextChar() {\n while (true) {\n final int c = read();\n if (!isSpace[c]) {\n return (char) c;\n }\n }\n }\n\n int reads(int len, boolean[] accept) {\n try {\n while (true) {\n final int c = read();\n if (accept[c]) {\n break;\n }\n if (str.length == len) {\n char[] rep = new char[str.length * 3 / 2];\n System.arraycopy(str, 0, rep, 0, str.length);\n str = rep;\n }\n str[len++] = (char) c;\n }\n } catch (MyInput.EndOfFileRuntimeException e) {\n }\n return len;\n }\n\n static class EndOfFileRuntimeException extends RuntimeException {\n }\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a right triangle ABC with ∠ABC=90°.\n\nGiven the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.\n\nIt is guaranteed that the area of the triangle ABC is an integer.\n\nConstraints\n\n1 \\leq |AB|,|BC|,|CA| \\leq 100\n\nAll values in input are integers.\n\nThe area of the triangle ABC is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n|AB| |BC| |CA|\n\nOutput\n\nPrint the area of the triangle ABC.\n\nSample Input 1\n\n3 4 5\n\nSample Output 1\n\n6\n\nThis triangle has an area of 6.\n\nSample Input 2\n\n5 12 13\n\nSample Output 2\n\n30\n\nThis triangle has an area of 30.\n\nSample Input 3\n\n45 28 53\n\nSample Output 3\n\n630\n\nThis triangle has an area of 630.", "sample_input": "3 4 5\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03145", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a right triangle ABC with ∠ABC=90°.\n\nGiven the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.\n\nIt is guaranteed that the area of the triangle ABC is an integer.\n\nConstraints\n\n1 \\leq |AB|,|BC|,|CA| \\leq 100\n\nAll values in input are integers.\n\nThe area of the triangle ABC is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n|AB| |BC| |CA|\n\nOutput\n\nPrint the area of the triangle ABC.\n\nSample Input 1\n\n3 4 5\n\nSample Output 1\n\n6\n\nThis triangle has an area of 6.\n\nSample Input 2\n\n5 12 13\n\nSample Output 2\n\n30\n\nThis triangle has an area of 30.\n\nSample Input 3\n\n45 28 53\n\nSample Output 3\n\n630\n\nThis triangle has an area of 630.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 13045, "cpu_time_ms": 73, "memory_kb": 21460}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s875018451", "group_id": "codeNet:p03146", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int s = sc.nextInt();\n int pre = s;\n boolean con = true;\n int ans = 1;\n boolean[] c = new boolean[1000000];\n while(con){\n ans++;\n int b;\n if(pre %2 == 0){\n b = pre /2;\n }else{\n b = 3 * pre +1;\n }\n if(c[b]) break;\n else {\n c[b] = true;\n pre = b;\n }\n }\n\n System.out.println(ans);\n sc.close();\n }\n\n}\n", "language": "Java", "metadata": {"date": 1548036646, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03146.html", "problem_id": "p03146", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03146/input.txt", "sample_output_relpath": "derived/input_output/data/p03146/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03146/Java/s875018451.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s875018451", "user_id": "u660444966"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int s = sc.nextInt();\n int pre = s;\n boolean con = true;\n int ans = 1;\n boolean[] c = new boolean[1000000];\n while(con){\n ans++;\n int b;\n if(pre %2 == 0){\n b = pre /2;\n }else{\n b = 3 * pre +1;\n }\n if(c[b]) break;\n else {\n c[b] = true;\n pre = b;\n }\n }\n\n System.out.println(ans);\n sc.close();\n }\n\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "sample_input": "8\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03146", "source_text": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 650, "cpu_time_ms": 108, "memory_kb": 25812}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s714298813", "group_id": "codeNet:p03146", "input_text": "import java.util.HashSet;\nimport java.util.Scanner;\nimport java.util.Set;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint s = sc.nextInt();\n\t\tSet sSet = new HashSet();\n\n\t\twhile(!sSet.contains(s)) {\n\t\t\tsSet.add(s);\n\n\t\t\tif(s % 2 == 0) {\n\t\t\t\ts = s/2;\n\t\t\t} else {\n\t\t\t\ts = 3*s + 1;\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(sSet.size() + 1);\n\n\t}\n\n}\n\n", "language": "Java", "metadata": {"date": 1548036417, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03146.html", "problem_id": "p03146", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03146/input.txt", "sample_output_relpath": "derived/input_output/data/p03146/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03146/Java/s714298813.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s714298813", "user_id": "u243925177"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.HashSet;\nimport java.util.Scanner;\nimport java.util.Set;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint s = sc.nextInt();\n\t\tSet sSet = new HashSet();\n\n\t\twhile(!sSet.contains(s)) {\n\t\t\tsSet.add(s);\n\n\t\t\tif(s % 2 == 0) {\n\t\t\t\ts = s/2;\n\t\t\t} else {\n\t\t\t\ts = 3*s + 1;\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(sSet.size() + 1);\n\n\t}\n\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "sample_input": "8\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03146", "source_text": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 415, "cpu_time_ms": 103, "memory_kb": 23252}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s931248020", "group_id": "codeNet:p03148", "input_text": "\nimport java.util.*;\n\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tMain main = new Main();\n\t\tmain.run();\n\t}\n\n\tclass P{\n\t\tint d;\n\t\tint k;\n\t\tP(int d, int k){\n\t\t\tthis.d=d;\n\t\t\tthis.k=k;\n\t\t}\n\t}\n\n\tpublic void run() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n=sc.nextInt();\n\t\tint k=sc.nextInt();\n\n\t\tArrayList> ll = new ArrayList<>();\n\t\tfor(int i=0; i());\n\t\t}\n\t\tfor(int i=0; i l : ll) {\n\t\t\tCollections.sort(l);\n\t\t}\n\n\t\tArrayList

pl = new ArrayList

();\n\t\tfor(ArrayList l : ll) {\n\t\t\tfor(int i=0; iInteger.compare(p1.d, p2.d));\n\n\t\tint choose = 0;\n\t\tlong sum = 0;\n\t\tlong max = 0;\n\t\tint kind = 0;\n\t\tPriorityQueue pq = new PriorityQueue<>();\n\t\tfor(int i=pl.size()-1; i>=0; i--) {\n\t\t\tint d = pl.get(i).d;\n\t\t\tsum += d;\n\t\t\tkind += pl.get(i).k;\n\t\t\tchoose++;\n\t\t\tif( pl.get(i).k==0) {\n\t\t\t\tpq.add(d);\n\t\t\t}\n\t\t\tif(choose > k) {\n\t\t\t\tchoose--;\n\t\t\t\tif(pq.isEmpty()) break;\n\t\t\t\tsum -= pq.poll();\n\t\t\t}\n\t\t\tif(choose == k) {\n\t\t\t\tmax = Math.max(max, sum + (long)kind*kind);\n\t\t\t}\n\n\t\t}\n\t\tSystem.out.println(max);\n\t\tsc.close();\n\t}\n\n\n}\n", "language": "Java", "metadata": {"date": 1589714443, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03148.html", "problem_id": "p03148", "resource_group": "high_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/Java/s931248020.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s931248020", "user_id": "u235169423"}, "prompt_components": {"gold_output": "26\n", "input_to_evaluate": "\nimport java.util.*;\n\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tMain main = new Main();\n\t\tmain.run();\n\t}\n\n\tclass P{\n\t\tint d;\n\t\tint k;\n\t\tP(int d, int k){\n\t\t\tthis.d=d;\n\t\t\tthis.k=k;\n\t\t}\n\t}\n\n\tpublic void run() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n=sc.nextInt();\n\t\tint k=sc.nextInt();\n\n\t\tArrayList> ll = new ArrayList<>();\n\t\tfor(int i=0; i());\n\t\t}\n\t\tfor(int i=0; i l : ll) {\n\t\t\tCollections.sort(l);\n\t\t}\n\n\t\tArrayList

pl = new ArrayList

();\n\t\tfor(ArrayList l : ll) {\n\t\t\tfor(int i=0; iInteger.compare(p1.d, p2.d));\n\n\t\tint choose = 0;\n\t\tlong sum = 0;\n\t\tlong max = 0;\n\t\tint kind = 0;\n\t\tPriorityQueue pq = new PriorityQueue<>();\n\t\tfor(int i=pl.size()-1; i>=0; i--) {\n\t\t\tint d = pl.get(i).d;\n\t\t\tsum += d;\n\t\t\tkind += pl.get(i).k;\n\t\t\tchoose++;\n\t\t\tif( pl.get(i).k==0) {\n\t\t\t\tpq.add(d);\n\t\t\t}\n\t\t\tif(choose > k) {\n\t\t\t\tchoose--;\n\t\t\t\tif(pq.isEmpty()) break;\n\t\t\t\tsum -= pq.poll();\n\t\t\t}\n\t\t\tif(choose == k) {\n\t\t\t\tmax = Math.max(max, sum + (long)kind*kind);\n\t\t\t}\n\n\t\t}\n\t\tSystem.out.println(max);\n\t\tsc.close();\n\t}\n\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": 1364, "cpu_time_ms": 934, "memory_kb": 102720}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s058419270", "group_id": "codeNet:p03148", "input_text": "import java.util.*;\nimport java.io.*;\n\nimport static java.lang.Math.*;\nimport static java.util.Arrays.*;\nimport static java.util.Collections.*;\n \npublic class Main{\n static final long mod=1000000007;\n// static int dx[]={-1,0,1,0};\n// static int dy[]={0,-1,0,1};\n\n public static void main(String[] args) throws Exception, IOException{ \n Reader sc = new Reader(System.in);\n PrintWriter out=new PrintWriter(System.out);\n // int n=sc.nextInt();\n // char c[][] = new char[h][w];\n // char c[]=sc.nextString().toCharArray();\n // int d[]=new int[n];\n // for(int i=0; i=0 && ++v<=k) {\n \tif(u[p[c].id]!=0)continue;\n \twhile(u[p[z].id]==0)z++;\n \tu[p[z].id]--;\n \tu[p[c].id]++;\n \ts += -p[z].d + p[c].d + 2*v-1;\n \tans = max(ans,s);\n }\n\t \n out.println(ans);\n out.flush();\n }\n \n static boolean validpos(int x,int y,int r, int c){\n return x{\n int id, d;\n P(int id, int d) {\n this.id=id;\n this.d=d;\n }\n public int compareTo(P p){\n return d-p.d; //des\n }\n}\n\nclass Reader\n{ \n private BufferedReader x;\n private StringTokenizer st;\n \n public Reader(InputStream in)\n {\n x = new BufferedReader(new InputStreamReader(in));\n st = null;\n }\n public String nextString() throws IOException\n {\n while( st==null || !st.hasMoreTokens() )\n st = new StringTokenizer(x.readLine());\n return st.nextToken();\n }\n public int nextInt() throws IOException\n {\n return Integer.parseInt(nextString());\n }\n public int[] nextIntArray(int size) throws IOException{\n \tint r[] = new int[size];\n \tfor (int i = 0; i < size; i++) {\n\t\t\tr[i] = this.nextInt(); \n\t\t}\n \treturn r;\n }\n public long nextLong() throws IOException\n {\n return Long.parseLong(nextString());\n }\n public double nextDouble() throws IOException\n {\n return Double.parseDouble(nextString());\n }\n}\n", "language": "Java", "metadata": {"date": 1548463730, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03148.html", "problem_id": "p03148", "resource_group": "high_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/Java/s058419270.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s058419270", "user_id": "u238640707"}, "prompt_components": {"gold_output": "26\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\n\nimport static java.lang.Math.*;\nimport static java.util.Arrays.*;\nimport static java.util.Collections.*;\n \npublic class Main{\n static final long mod=1000000007;\n// static int dx[]={-1,0,1,0};\n// static int dy[]={0,-1,0,1};\n\n public static void main(String[] args) throws Exception, IOException{ \n Reader sc = new Reader(System.in);\n PrintWriter out=new PrintWriter(System.out);\n // int n=sc.nextInt();\n // char c[][] = new char[h][w];\n // char c[]=sc.nextString().toCharArray();\n // int d[]=new int[n];\n // for(int i=0; i=0 && ++v<=k) {\n \tif(u[p[c].id]!=0)continue;\n \twhile(u[p[z].id]==0)z++;\n \tu[p[z].id]--;\n \tu[p[c].id]++;\n \ts += -p[z].d + p[c].d + 2*v-1;\n \tans = max(ans,s);\n }\n\t \n out.println(ans);\n out.flush();\n }\n \n static boolean validpos(int x,int y,int r, int c){\n return x{\n int id, d;\n P(int id, int d) {\n this.id=id;\n this.d=d;\n }\n public int compareTo(P p){\n return d-p.d; //des\n }\n}\n\nclass Reader\n{ \n private BufferedReader x;\n private StringTokenizer st;\n \n public Reader(InputStream in)\n {\n x = new BufferedReader(new InputStreamReader(in));\n st = null;\n }\n public String nextString() throws IOException\n {\n while( st==null || !st.hasMoreTokens() )\n st = new StringTokenizer(x.readLine());\n return st.nextToken();\n }\n public int nextInt() throws IOException\n {\n return Integer.parseInt(nextString());\n }\n public int[] nextIntArray(int size) throws IOException{\n \tint r[] = new int[size];\n \tfor (int i = 0; i < size; i++) {\n\t\t\tr[i] = this.nextInt(); \n\t\t}\n \treturn r;\n }\n public long nextLong() throws IOException\n {\n return Long.parseLong(nextString());\n }\n public double nextDouble() throws IOException\n {\n return Double.parseDouble(nextString());\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": 2762, "cpu_time_ms": 317, "memory_kb": 44552}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s272661795", "group_id": "codeNet:p03149", "input_text": "import java.util.*;\nimport java.io.*;\nimport java.math.*;\npublic class Main\n{\n static class Reader \n { \n private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;} \n public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];} \n public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;} \n public String s(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isSpaceChar(c));return res.toString();} \n public long l(){int c = read();while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }long res = 0; do{ if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read();}while(!isSpaceChar(c));return res * sgn;} \n public int i(){int c = read() ;while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }int res = 0;do{if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read() ;}while(!isSpaceChar(c));return res * sgn;} \n public double d() throws IOException {return Double.parseDouble(s()) ;}\n public boolean isSpaceChar(int c) { return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1; } \n public boolean isEndOfLine(int c) { return c == '\\n' || c == '\\r' || c == -1; } \n public int[] arr(int n){int[] ret = new int[n];for (int i = 0; i < n; i++) {ret[i] = i();}return ret;}\n }\n \n \n\n // |----| /\\ | | ----- |\n // | / / \\ | | | |\n // |--/ /----\\ |----| | |\n // | \\ / \\ | | | |\n // | \\ / \\ | | ----- -------\n \n \n public static void main(String[] args)throws IOException\n {\n PrintWriter out= new PrintWriter(System.out);\n Reader sc=new Reader();\n int arr[]=sc.arr(4);\n Arrays.sort(arr);\n if(arr[0]==1&&arr[1]==4&&arr[2]==7&&arr[3]==9)\n out.println(\"YES\");\n else\n out.println(\"NO\");\n out.flush();\n }\n}", "language": "Java", "metadata": {"date": 1547409712, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03149.html", "problem_id": "p03149", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03149/input.txt", "sample_output_relpath": "derived/input_output/data/p03149/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03149/Java/s272661795.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s272661795", "user_id": "u516540919"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\nimport java.math.*;\npublic class Main\n{\n static class Reader \n { \n private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;} \n public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];} \n public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;} \n public String s(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isSpaceChar(c));return res.toString();} \n public long l(){int c = read();while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }long res = 0; do{ if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read();}while(!isSpaceChar(c));return res * sgn;} \n public int i(){int c = read() ;while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }int res = 0;do{if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read() ;}while(!isSpaceChar(c));return res * sgn;} \n public double d() throws IOException {return Double.parseDouble(s()) ;}\n public boolean isSpaceChar(int c) { return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1; } \n public boolean isEndOfLine(int c) { return c == '\\n' || c == '\\r' || c == -1; } \n public int[] arr(int n){int[] ret = new int[n];for (int i = 0; i < n; i++) {ret[i] = i();}return ret;}\n }\n \n \n\n // |----| /\\ | | ----- |\n // | / / \\ | | | |\n // |--/ /----\\ |----| | |\n // | \\ / \\ | | | |\n // | \\ / \\ | | ----- -------\n \n \n public static void main(String[] args)throws IOException\n {\n PrintWriter out= new PrintWriter(System.out);\n Reader sc=new Reader();\n int arr[]=sc.arr(4);\n Arrays.sort(arr);\n if(arr[0]==1&&arr[1]==4&&arr[2]==7&&arr[3]==9)\n out.println(\"YES\");\n else\n out.println(\"NO\");\n out.flush();\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits \"1974\".\n\nConstraints\n\n0 \\leq N_1, N_2, N_3, N_4 \\leq 9\n\nN_1, N_2, N_3 and N_4 are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN_1 N_2 N_3 N_4\n\nOutput\n\nIf N_1, N_2, N_3 and N_4 can be arranged into the sequence of digits \"1974\", print YES; if they cannot, print NO.\n\nSample Input 1\n\n1 7 9 4\n\nSample Output 1\n\nYES\n\nWe can get 1974 by swapping N_2 and N_3.\n\nSample Input 2\n\n1 9 7 4\n\nSample Output 2\n\nYES\n\nWe already have 1974 before doing anything.\n\nSample Input 3\n\n1 2 9 1\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n4 9 0 8\n\nSample Output 4\n\nNO", "sample_input": "1 7 9 4\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03149", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits \"1974\".\n\nConstraints\n\n0 \\leq N_1, N_2, N_3, N_4 \\leq 9\n\nN_1, N_2, N_3 and N_4 are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN_1 N_2 N_3 N_4\n\nOutput\n\nIf N_1, N_2, N_3 and N_4 can be arranged into the sequence of digits \"1974\", print YES; if they cannot, print NO.\n\nSample Input 1\n\n1 7 9 4\n\nSample Output 1\n\nYES\n\nWe can get 1974 by swapping N_2 and N_3.\n\nSample Input 2\n\n1 9 7 4\n\nSample Output 2\n\nYES\n\nWe already have 1974 before doing anything.\n\nSample Input 3\n\n1 2 9 1\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n4 9 0 8\n\nSample Output 4\n\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2593, "cpu_time_ms": 139, "memory_kb": 20948}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s470849699", "group_id": "codeNet:p03153", "input_text": "\nimport java.util.Arrays;\n\nclass DisjointSet {\n public int[] upper;\n \n public DisjointSet(int n)\n {\n upper = new int[n];\n Arrays.fill(upper, -1);\n }\n \n public DisjointSet(DisjointSet ds)\n {\n this.upper = Arrays.copyOf(ds.upper, ds.upper.length);\n } \n \n public int root(int x)\n {\n return upper[x] < 0 ? x : (upper[x] = root(upper[x]));\n }\n \n public boolean equiv(int x, int y)\n {\n return root(x) == root(y);\n }\n \n public boolean union(int x, int y)\n {\n x = root(x);\n y = root(y);\n if(x != y) {\n if(upper[y] < upper[x]) {\n int d = x; x = y; y = d;\n }\n upper[x] += upper[y];\n upper[y] = x;\n }\n return x == y;\n }\n \n public int count()\n {\n int ct = 0;\n for(int u : upper){\n if(u < 0)ct++;\n }\n return ct;\n }\n}\n\nclass SegmentTreeRMQPos {\n public int M, H, N;\n public long[] st;\n public int[] pos;\n\n public SegmentTreeRMQPos(long[] a)\n {\n N = a.length;\n M = Integer.highestOneBit(Math.max(N-1, 1))<<2;\n H = M>>>1;\n st = new long[M];\n pos = new int[M];\n for(int i = 0;i < N;i++){\n st[H+i] = a[i];\n pos[H+i] = i;\n }\n Arrays.fill(st, H+N, M, Long.MAX_VALUE);\n for(int i = H-1;i >= 1;i--)propagate(i);\n }\n \n public void update(int pos, int x)\n {\n st[H+pos] = x;\n for(int i = (H+pos)>>>1;i >= 1;i >>>= 1)propagate(i);\n }\n \n private void propagate(int i)\n {\n if(st[2*i] <= st[2*i+1]){\n st[i] = st[2*i];\n pos[i] = pos[2*i];\n }else{\n st[i] = st[2*i+1];\n pos[i] = pos[2*i+1];\n }\n }\n \n public int minpos;\n public long minval;\n \n public long min(int l, int r){ \n minpos = -1;\n minval = Long.MAX_VALUE;\n min(l, r, 0, H, 1);\n return minval;\n }\n \n private void min(int l, int r, int cl, int cr, int cur)\n {\n if(l <= cl && cr <= r){\n if(st[cur] < minval){\n minval = st[cur];\n minpos = pos[cur];\n }\n }else{\n int mid = cl+cr>>>1;\n if(cl < r && l < mid)min(l, r, cl, mid, 2*cur);\n if(mid < r && l < cr)min(l, r, mid, cr, 2*cur+1);\n }\n }\n}\n\n\npublic class Main {\n private static void solve() {\n int n = ni();\n long d = ni();\n long[] a = nal(n);\n \n long[] left = new long[n];\n long[] right = new long[n];\n for (int i = 0; i < n; i ++) {\n left[i] = -i * d + a[i];\n right[i] = i * d + a[i];\n }\n \n long[][] table = new long[n][3];\n for (int i = 0; i < n; i ++) {\n table[i][0] = i;\n table[i][1] = a[i];\n }\n Arrays.sort(table, (o1, o2) -> Long.compare(o2[1], o1[1]));\n int[] idx = Arrays.stream(table).mapToInt(v -> (int)v[0]).toArray();\n \n SegmentTreeRMQPos stL = new SegmentTreeRMQPos(left);\n SegmentTreeRMQPos stR = new SegmentTreeRMQPos(right);\n \n int[] from = new int[n * 3];\n int[] to = new int[n * 3];\n long[] w = new long[n * 3];\n int ptr = 0;\n for (int i : idx) {\n stL.min(0, i);\n stR.min(i + 1, n);\n \n if (stL.minpos >= 0) {\n from[ptr] = i;\n to[ptr] = stL.minpos;\n w[ptr] = i * d + a[i] + stL.minval;\n ptr ++;\n }\n if (stR.minpos >= 0) {\n from[ptr] = i;\n to[ptr] = stR.minpos;\n w[ptr] = -i * d + a[i] + stR.minval;\n ptr ++;\n }\n }\n long ret = kruskal(from, to, w, ptr, n);\n System.out.println(ret);\n }\n \n public static long kruskal(int[] one, int[] other, long[] w, int m, int n)\n {\n DisjointSet ds = new DisjointSet(n);\n int p = m;\n long[] ord = new long[p];\n for(int i = 0;i < p;i++)ord[i] = (long)w[i]<<32 | i;\n Arrays.sort(ord);\n \n long d = 0;\n for(int i = 0;i < m;i++){\n int cur = (int)ord[i];\n if(!ds.equiv(one[cur], other[cur])){\n ds.union(one[cur], other[cur]);\n d += w[cur];\n }\n }\n \n return d;\n }\n\n public static void main(String[] args) {\n new Thread(null, new Runnable() {\n @Override\n public void run() {\n long start = System.currentTimeMillis();\n String debug = args.length > 0 ? args[0] : null;\n if (debug != null) {\n try {\n is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));\n } catch (Exception e) {\n throw new RuntimeException(e);\n }\n }\n reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);\n solve();\n out.flush();\n tr((System.currentTimeMillis() - start) + \"ms\");\n }\n }, \"\", 64000000).start();\n }\n\n private static java.io.InputStream is = System.in;\n private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);\n private static java.util.StringTokenizer tokenizer = null;\n private static java.io.BufferedReader reader;\n\n public static String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new java.util.StringTokenizer(reader.readLine());\n } catch (Exception e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n private static double nd() {\n return Double.parseDouble(next());\n }\n\n private static long nl() {\n return Long.parseLong(next());\n }\n\n private static int[] na(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = ni();\n return a;\n }\n\n private static char[] ns() {\n return next().toCharArray();\n }\n\n private static long[] nal(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = nl();\n return a;\n }\n\n private static int[][] ntable(int n, int m) {\n int[][] table = new int[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n table[i][j] = ni();\n }\n }\n return table;\n }\n\n private static int[][] nlist(int n, int m) {\n int[][] table = new int[m][n];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n table[j][i] = ni();\n }\n }\n return table;\n }\n\n private static int ni() {\n return Integer.parseInt(next());\n }\n\n private static void tr(Object... o) {\n if (is != System.in)\n System.out.println(java.util.Arrays.deepToString(o));\n }\n}\n", "language": "Java", "metadata": {"date": 1548257606, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03153.html", "problem_id": "p03153", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03153/input.txt", "sample_output_relpath": "derived/input_output/data/p03153/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03153/Java/s470849699.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s470849699", "user_id": "u769201746"}, "prompt_components": {"gold_output": "106\n", "input_to_evaluate": "\nimport java.util.Arrays;\n\nclass DisjointSet {\n public int[] upper;\n \n public DisjointSet(int n)\n {\n upper = new int[n];\n Arrays.fill(upper, -1);\n }\n \n public DisjointSet(DisjointSet ds)\n {\n this.upper = Arrays.copyOf(ds.upper, ds.upper.length);\n } \n \n public int root(int x)\n {\n return upper[x] < 0 ? x : (upper[x] = root(upper[x]));\n }\n \n public boolean equiv(int x, int y)\n {\n return root(x) == root(y);\n }\n \n public boolean union(int x, int y)\n {\n x = root(x);\n y = root(y);\n if(x != y) {\n if(upper[y] < upper[x]) {\n int d = x; x = y; y = d;\n }\n upper[x] += upper[y];\n upper[y] = x;\n }\n return x == y;\n }\n \n public int count()\n {\n int ct = 0;\n for(int u : upper){\n if(u < 0)ct++;\n }\n return ct;\n }\n}\n\nclass SegmentTreeRMQPos {\n public int M, H, N;\n public long[] st;\n public int[] pos;\n\n public SegmentTreeRMQPos(long[] a)\n {\n N = a.length;\n M = Integer.highestOneBit(Math.max(N-1, 1))<<2;\n H = M>>>1;\n st = new long[M];\n pos = new int[M];\n for(int i = 0;i < N;i++){\n st[H+i] = a[i];\n pos[H+i] = i;\n }\n Arrays.fill(st, H+N, M, Long.MAX_VALUE);\n for(int i = H-1;i >= 1;i--)propagate(i);\n }\n \n public void update(int pos, int x)\n {\n st[H+pos] = x;\n for(int i = (H+pos)>>>1;i >= 1;i >>>= 1)propagate(i);\n }\n \n private void propagate(int i)\n {\n if(st[2*i] <= st[2*i+1]){\n st[i] = st[2*i];\n pos[i] = pos[2*i];\n }else{\n st[i] = st[2*i+1];\n pos[i] = pos[2*i+1];\n }\n }\n \n public int minpos;\n public long minval;\n \n public long min(int l, int r){ \n minpos = -1;\n minval = Long.MAX_VALUE;\n min(l, r, 0, H, 1);\n return minval;\n }\n \n private void min(int l, int r, int cl, int cr, int cur)\n {\n if(l <= cl && cr <= r){\n if(st[cur] < minval){\n minval = st[cur];\n minpos = pos[cur];\n }\n }else{\n int mid = cl+cr>>>1;\n if(cl < r && l < mid)min(l, r, cl, mid, 2*cur);\n if(mid < r && l < cr)min(l, r, mid, cr, 2*cur+1);\n }\n }\n}\n\n\npublic class Main {\n private static void solve() {\n int n = ni();\n long d = ni();\n long[] a = nal(n);\n \n long[] left = new long[n];\n long[] right = new long[n];\n for (int i = 0; i < n; i ++) {\n left[i] = -i * d + a[i];\n right[i] = i * d + a[i];\n }\n \n long[][] table = new long[n][3];\n for (int i = 0; i < n; i ++) {\n table[i][0] = i;\n table[i][1] = a[i];\n }\n Arrays.sort(table, (o1, o2) -> Long.compare(o2[1], o1[1]));\n int[] idx = Arrays.stream(table).mapToInt(v -> (int)v[0]).toArray();\n \n SegmentTreeRMQPos stL = new SegmentTreeRMQPos(left);\n SegmentTreeRMQPos stR = new SegmentTreeRMQPos(right);\n \n int[] from = new int[n * 3];\n int[] to = new int[n * 3];\n long[] w = new long[n * 3];\n int ptr = 0;\n for (int i : idx) {\n stL.min(0, i);\n stR.min(i + 1, n);\n \n if (stL.minpos >= 0) {\n from[ptr] = i;\n to[ptr] = stL.minpos;\n w[ptr] = i * d + a[i] + stL.minval;\n ptr ++;\n }\n if (stR.minpos >= 0) {\n from[ptr] = i;\n to[ptr] = stR.minpos;\n w[ptr] = -i * d + a[i] + stR.minval;\n ptr ++;\n }\n }\n long ret = kruskal(from, to, w, ptr, n);\n System.out.println(ret);\n }\n \n public static long kruskal(int[] one, int[] other, long[] w, int m, int n)\n {\n DisjointSet ds = new DisjointSet(n);\n int p = m;\n long[] ord = new long[p];\n for(int i = 0;i < p;i++)ord[i] = (long)w[i]<<32 | i;\n Arrays.sort(ord);\n \n long d = 0;\n for(int i = 0;i < m;i++){\n int cur = (int)ord[i];\n if(!ds.equiv(one[cur], other[cur])){\n ds.union(one[cur], other[cur]);\n d += w[cur];\n }\n }\n \n return d;\n }\n\n public static void main(String[] args) {\n new Thread(null, new Runnable() {\n @Override\n public void run() {\n long start = System.currentTimeMillis();\n String debug = args.length > 0 ? args[0] : null;\n if (debug != null) {\n try {\n is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));\n } catch (Exception e) {\n throw new RuntimeException(e);\n }\n }\n reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);\n solve();\n out.flush();\n tr((System.currentTimeMillis() - start) + \"ms\");\n }\n }, \"\", 64000000).start();\n }\n\n private static java.io.InputStream is = System.in;\n private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);\n private static java.util.StringTokenizer tokenizer = null;\n private static java.io.BufferedReader reader;\n\n public static String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new java.util.StringTokenizer(reader.readLine());\n } catch (Exception e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n private static double nd() {\n return Double.parseDouble(next());\n }\n\n private static long nl() {\n return Long.parseLong(next());\n }\n\n private static int[] na(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = ni();\n return a;\n }\n\n private static char[] ns() {\n return next().toCharArray();\n }\n\n private static long[] nal(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = nl();\n return a;\n }\n\n private static int[][] ntable(int n, int m) {\n int[][] table = new int[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n table[i][j] = ni();\n }\n }\n return table;\n }\n\n private static int[][] nlist(int n, int m) {\n int[][] table = new int[m][n];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n table[j][i] = ni();\n }\n }\n return table;\n }\n\n private static int ni() {\n return Integer.parseInt(next());\n }\n\n private static void tr(Object... o) {\n if (is != System.in)\n System.out.println(java.util.Arrays.deepToString(o));\n }\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are N cities in Republic of AtCoder. The size of the i-th city is A_{i}.\nTakahashi would like to build N-1 bidirectional roads connecting two cities so that any city can be reached from any other city by using these roads.\n\nAssume that the cost of building a road connecting the i-th city and the j-th city is |i-j| \\times D + A_{i} + A_{j}.\nFor Takahashi, find the minimum possible total cost to achieve the objective.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq D \\leq 10^9\n\n1 \\leq A_{i} \\leq 10^9\n\nA_{i} and D are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible total cost.\n\nSample Input 1\n\n3 1\n1 100 1\n\nSample Output 1\n\n106\n\nThis cost can be achieved by, for example, building roads connecting City 1, 2 and City 1, 3.\n\nSample Input 2\n\n3 1000\n1 100 1\n\nSample Output 2\n\n2202\n\nSample Input 3\n\n6 14\n25 171 7 1 17 162\n\nSample Output 3\n\n497\n\nSample Input 4\n\n12 5\n43 94 27 3 69 99 56 25 8 15 46 8\n\nSample Output 4\n\n658", "sample_input": "3 1\n1 100 1\n"}, "reference_outputs": ["106\n"], "source_document_id": "p03153", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are N cities in Republic of AtCoder. The size of the i-th city is A_{i}.\nTakahashi would like to build N-1 bidirectional roads connecting two cities so that any city can be reached from any other city by using these roads.\n\nAssume that the cost of building a road connecting the i-th city and the j-th city is |i-j| \\times D + A_{i} + A_{j}.\nFor Takahashi, find the minimum possible total cost to achieve the objective.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq D \\leq 10^9\n\n1 \\leq A_{i} \\leq 10^9\n\nA_{i} and D are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible total cost.\n\nSample Input 1\n\n3 1\n1 100 1\n\nSample Output 1\n\n106\n\nThis cost can be achieved by, for example, building roads connecting City 1, 2 and City 1, 3.\n\nSample Input 2\n\n3 1000\n1 100 1\n\nSample Output 2\n\n2202\n\nSample Input 3\n\n6 14\n25 171 7 1 17 162\n\nSample Output 3\n\n497\n\nSample Input 4\n\n12 5\n43 94 27 3 69 99 56 25 8 15 46 8\n\nSample Output 4\n\n658", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6338, "cpu_time_ms": 1013, "memory_kb": 97332}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s222674205", "group_id": "codeNet:p03157", "input_text": "import java.util.Scanner;\n\npublic class Main \n{\n\tstatic boolean[][] grid;\n\tstatic int h,w;\n\tstatic boolean[][] visited;\n\tstatic long[][] islandbw = new long[160000][2];\n\tstatic int curisland = 0;\n\t\n\tstatic void findIsland(int x, int y, boolean state, int island)\n\t{\n\t\tif(x<0||y<0||x>=w||y>=h)return;\n\t\tif(visited[x][y])return;\n\t\tif(grid[x][y] == state)\n\t\t{\n\t\t\tvisited[x][y] = true;\n//\t\t\tSystem.out.println(x + \" \" + y + \": island \" + island);\n\t\t\tif(grid[x][y])\n\t\t\t\tislandbw[island][0]++;\n\t\t\telse islandbw[island][1]++;\n\t\t\t\n\t\t\t//expand\n\t\t\tfindIsland(x-1,y,!state,island);\n\t\t\tfindIsland(x+1,y,!state,island);\n\t\t\tfindIsland(x,y-1,!state,island);\n\t\t\tfindIsland(x,y+1,!state,island);\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) \n\t{\n\t\tScanner sc = new Scanner(System.in);\n\t\th = sc.nextInt();\n\t\tw = sc.nextInt();\n\t\tgrid = new boolean[w][h];\n\t\tvisited = new boolean[w][h];\n\t\t\n\t\tfor(int y = 0; y < h; y++)\n\t\t{\n\t\t\tString s = sc.next();\n\t\t\tfor(int x = 0; x < w; x++)\n\t\t\t{\n\t\t\t\tgrid[x][y] = s.charAt(x)=='#';\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int y = 0; y < h; y++)\n\t\t{\n\t\t\tfor(int x = 0; x < w; x++)\n\t\t\t{\n\t\t\t\tif(!visited[x][y])\n\t\t\t\t{\n\t\t\t\t\tfindIsland(x,y,grid[x][y],curisland);\n\t\t\t\t\tcurisland++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tlong an = 0;\n\t\tfor(int i = 0; i < curisland; i++)\n\t\t{\n\t\t\tan += (islandbw[i][0] * islandbw[i][1]);\n\t\t}\n\t\t\n\t\tSystem.out.println(an);\n\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1586954508, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03157.html", "problem_id": "p03157", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03157/input.txt", "sample_output_relpath": "derived/input_output/data/p03157/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03157/Java/s222674205.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s222674205", "user_id": "u245815044"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main \n{\n\tstatic boolean[][] grid;\n\tstatic int h,w;\n\tstatic boolean[][] visited;\n\tstatic long[][] islandbw = new long[160000][2];\n\tstatic int curisland = 0;\n\t\n\tstatic void findIsland(int x, int y, boolean state, int island)\n\t{\n\t\tif(x<0||y<0||x>=w||y>=h)return;\n\t\tif(visited[x][y])return;\n\t\tif(grid[x][y] == state)\n\t\t{\n\t\t\tvisited[x][y] = true;\n//\t\t\tSystem.out.println(x + \" \" + y + \": island \" + island);\n\t\t\tif(grid[x][y])\n\t\t\t\tislandbw[island][0]++;\n\t\t\telse islandbw[island][1]++;\n\t\t\t\n\t\t\t//expand\n\t\t\tfindIsland(x-1,y,!state,island);\n\t\t\tfindIsland(x+1,y,!state,island);\n\t\t\tfindIsland(x,y-1,!state,island);\n\t\t\tfindIsland(x,y+1,!state,island);\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) \n\t{\n\t\tScanner sc = new Scanner(System.in);\n\t\th = sc.nextInt();\n\t\tw = sc.nextInt();\n\t\tgrid = new boolean[w][h];\n\t\tvisited = new boolean[w][h];\n\t\t\n\t\tfor(int y = 0; y < h; y++)\n\t\t{\n\t\t\tString s = sc.next();\n\t\t\tfor(int x = 0; x < w; x++)\n\t\t\t{\n\t\t\t\tgrid[x][y] = s.charAt(x)=='#';\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int y = 0; y < h; y++)\n\t\t{\n\t\t\tfor(int x = 0; x < w; x++)\n\t\t\t{\n\t\t\t\tif(!visited[x][y])\n\t\t\t\t{\n\t\t\t\t\tfindIsland(x,y,grid[x][y],curisland);\n\t\t\t\t\tcurisland++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tlong an = 0;\n\t\tfor(int i = 0; i < curisland; i++)\n\t\t{\n\t\t\tan += (islandbw[i][0] * islandbw[i][1]);\n\t\t}\n\t\t\n\t\tSystem.out.println(an);\n\n\t}\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a grid with H rows and W columns, where each square is painted black or white.\n\nYou are given H strings S_1, S_2, ..., S_H, each of length W.\nIf the square at the i-th row from the top and the j-th column from the left is painted black, the j-th character in the string S_i is #; if that square is painted white, the j-th character in the string S_i is ..\n\nFind the number of pairs of a black square c_1 and a white square c_2 that satisfy the following condition:\n\nThere is a path from the square c_1 to the square c_2 where we repeatedly move to a vertically or horizontally adjacent square through an alternating sequence of black and white squares: black, white, black, white...\n\nConstraints\n\n1 \\leq H, W \\leq 400\n\n|S_i| = W (1 \\leq i \\leq H)\n\nFor each i (1 \\leq i \\leq H), the string S_i consists of characters # and ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_1\nS_2\n:\nS_H\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 3\n.#.\n..#\n#..\n\nSample Output 1\n\n10\n\nSome of the pairs satisfying the condition are ((1, 2), (3, 3)) and ((3, 1), (3, 2)), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.\n\nSample Input 2\n\n2 4\n....\n....\n\nSample Output 2\n\n0\n\nSample Input 3\n\n4 3\n###\n###\n...\n###\n\nSample Output 3\n\n6", "sample_input": "3 3\n.#.\n..#\n#..\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03157", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a grid with H rows and W columns, where each square is painted black or white.\n\nYou are given H strings S_1, S_2, ..., S_H, each of length W.\nIf the square at the i-th row from the top and the j-th column from the left is painted black, the j-th character in the string S_i is #; if that square is painted white, the j-th character in the string S_i is ..\n\nFind the number of pairs of a black square c_1 and a white square c_2 that satisfy the following condition:\n\nThere is a path from the square c_1 to the square c_2 where we repeatedly move to a vertically or horizontally adjacent square through an alternating sequence of black and white squares: black, white, black, white...\n\nConstraints\n\n1 \\leq H, W \\leq 400\n\n|S_i| = W (1 \\leq i \\leq H)\n\nFor each i (1 \\leq i \\leq H), the string S_i consists of characters # and ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_1\nS_2\n:\nS_H\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 3\n.#.\n..#\n#..\n\nSample Output 1\n\n10\n\nSome of the pairs satisfying the condition are ((1, 2), (3, 3)) and ((3, 1), (3, 2)), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.\n\nSample Input 2\n\n2 4\n....\n....\n\nSample Output 2\n\n0\n\nSample Input 3\n\n4 3\n###\n###\n...\n###\n\nSample Output 3\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1328, "cpu_time_ms": 192, "memory_kb": 45860}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s543163628", "group_id": "codeNet:p03157", "input_text": "import java.util.*;\nimport java.awt.*;\nimport java.awt.geom.*;\nimport static java.lang.System.*;\nimport static java.lang.Math.*;\npublic class Main {\n public static void main(String[] $) {\n Scanner sc = new Scanner(in);\n int h=sc.nextInt();\n int w=sc.nextInt();\n char[][] f=new char[h][w];\n for (int i = 0; i < h; i++) {\n String t=sc.next();\n for (int j = 0; j < w; j++) {\n f[i][j]=t.charAt(j);\n }\n }\n long ans=0;\n int[] dx={-1,0,1,0};\n int[] dy={0,-1,0,1};\n int[][] node=new int[h][w];\n for (int i = 0; i < h; i++) {\n for (int j = 0; j < w; j++) {\n if(node[i][j]==0) {\n Queue q = new ArrayDeque<>();\n if(f[i][j]=='#'){\n q.add(new Point(i, j));\n node[i][j]++;\n }\n long tempW = 0, tempB = 0;\n while (!q.isEmpty()) {\n Point p = q.poll();\n if (f[p.x][p.y] == '.') tempW++;\n else tempB++;\n for (int k = 0; k < 4; k++) {\n int x = p.x + dx[k];\n int y = p.y + dy[k];\n if (0 <= x && x < h && 0 <= y && y < w) {\n if (node[x][y] == 0 && f[p.x][p.y] != f[x][y]) {\n q.add(new Point(x, y));\n node[x][y]++;\n }\n }\n }\n }\n ans += tempB * tempW;\n }\n }\n }\n out.println(ans);\n }\n}\n", "language": "Java", "metadata": {"date": 1547859665, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03157.html", "problem_id": "p03157", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03157/input.txt", "sample_output_relpath": "derived/input_output/data/p03157/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03157/Java/s543163628.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s543163628", "user_id": "u832039789"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.util.*;\nimport java.awt.*;\nimport java.awt.geom.*;\nimport static java.lang.System.*;\nimport static java.lang.Math.*;\npublic class Main {\n public static void main(String[] $) {\n Scanner sc = new Scanner(in);\n int h=sc.nextInt();\n int w=sc.nextInt();\n char[][] f=new char[h][w];\n for (int i = 0; i < h; i++) {\n String t=sc.next();\n for (int j = 0; j < w; j++) {\n f[i][j]=t.charAt(j);\n }\n }\n long ans=0;\n int[] dx={-1,0,1,0};\n int[] dy={0,-1,0,1};\n int[][] node=new int[h][w];\n for (int i = 0; i < h; i++) {\n for (int j = 0; j < w; j++) {\n if(node[i][j]==0) {\n Queue q = new ArrayDeque<>();\n if(f[i][j]=='#'){\n q.add(new Point(i, j));\n node[i][j]++;\n }\n long tempW = 0, tempB = 0;\n while (!q.isEmpty()) {\n Point p = q.poll();\n if (f[p.x][p.y] == '.') tempW++;\n else tempB++;\n for (int k = 0; k < 4; k++) {\n int x = p.x + dx[k];\n int y = p.y + dy[k];\n if (0 <= x && x < h && 0 <= y && y < w) {\n if (node[x][y] == 0 && f[p.x][p.y] != f[x][y]) {\n q.add(new Point(x, y));\n node[x][y]++;\n }\n }\n }\n }\n ans += tempB * tempW;\n }\n }\n }\n out.println(ans);\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a grid with H rows and W columns, where each square is painted black or white.\n\nYou are given H strings S_1, S_2, ..., S_H, each of length W.\nIf the square at the i-th row from the top and the j-th column from the left is painted black, the j-th character in the string S_i is #; if that square is painted white, the j-th character in the string S_i is ..\n\nFind the number of pairs of a black square c_1 and a white square c_2 that satisfy the following condition:\n\nThere is a path from the square c_1 to the square c_2 where we repeatedly move to a vertically or horizontally adjacent square through an alternating sequence of black and white squares: black, white, black, white...\n\nConstraints\n\n1 \\leq H, W \\leq 400\n\n|S_i| = W (1 \\leq i \\leq H)\n\nFor each i (1 \\leq i \\leq H), the string S_i consists of characters # and ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_1\nS_2\n:\nS_H\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 3\n.#.\n..#\n#..\n\nSample Output 1\n\n10\n\nSome of the pairs satisfying the condition are ((1, 2), (3, 3)) and ((3, 1), (3, 2)), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.\n\nSample Input 2\n\n2 4\n....\n....\n\nSample Output 2\n\n0\n\nSample Input 3\n\n4 3\n###\n###\n...\n###\n\nSample Output 3\n\n6", "sample_input": "3 3\n.#.\n..#\n#..\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03157", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a grid with H rows and W columns, where each square is painted black or white.\n\nYou are given H strings S_1, S_2, ..., S_H, each of length W.\nIf the square at the i-th row from the top and the j-th column from the left is painted black, the j-th character in the string S_i is #; if that square is painted white, the j-th character in the string S_i is ..\n\nFind the number of pairs of a black square c_1 and a white square c_2 that satisfy the following condition:\n\nThere is a path from the square c_1 to the square c_2 where we repeatedly move to a vertically or horizontally adjacent square through an alternating sequence of black and white squares: black, white, black, white...\n\nConstraints\n\n1 \\leq H, W \\leq 400\n\n|S_i| = W (1 \\leq i \\leq H)\n\nFor each i (1 \\leq i \\leq H), the string S_i consists of characters # and ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_1\nS_2\n:\nS_H\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 3\n.#.\n..#\n#..\n\nSample Output 1\n\n10\n\nSome of the pairs satisfying the condition are ((1, 2), (3, 3)) and ((3, 1), (3, 2)), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.\n\nSample Input 2\n\n2 4\n....\n....\n\nSample Output 2\n\n0\n\nSample Input 3\n\n4 3\n###\n###\n...\n###\n\nSample Output 3\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1798, "cpu_time_ms": 229, "memory_kb": 46640}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s780546116", "group_id": "codeNet:p03162", "input_text": "import java.util.*;\n\npublic class Main\n{\n static int n;\n static int[][] abc;\n static Integer[][] memo;\n public static void main(String[] args)\n {\n\tScanner in = new Scanner(System.in);\n n = in.nextInt();\n abc = new int[3][n];\n for (int i = 0; i < n; i++)\n for (int j = 0; j < 3; j++)\n abc[j][i] = in.nextInt();\n \n memo = new Integer[3][n];\n System.out.println(go());\n in.close();\n }\n \n public static int go()\n {\n int ans = 0;\n for (int i = 0; i < 3; i++)\n ans = Math.max(ans, abc[i][0]+dp(i, 1));\n return ans;\n }\n \n public static int dp(int bad, int at)\n {\n\tif (at == n)\n return 0;\n if (memo[bad][at] != null)\n return memo[bad][at];\n \n int ans = 0;\n int to1 = 3-at;\n int to2 = 0;\n if (to1 == 3)\n {\n to1 = 1;\n to2 = 2;\n }\n ans = Math.max(ans, abc[to1][at]+dp(to1, at+1));\n ans = Math.max(ans, abc[to2][at]+dp(to2, at+1));\n return memo[bad][at] = ans;\n }\n}", "language": "Java", "metadata": {"date": 1551782318, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03162.html", "problem_id": "p03162", "resource_group": "high_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/Java/s780546116.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s780546116", "user_id": "u068098242"}, "prompt_components": {"gold_output": "210\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main\n{\n static int n;\n static int[][] abc;\n static Integer[][] memo;\n public static void main(String[] args)\n {\n\tScanner in = new Scanner(System.in);\n n = in.nextInt();\n abc = new int[3][n];\n for (int i = 0; i < n; i++)\n for (int j = 0; j < 3; j++)\n abc[j][i] = in.nextInt();\n \n memo = new Integer[3][n];\n System.out.println(go());\n in.close();\n }\n \n public static int go()\n {\n int ans = 0;\n for (int i = 0; i < 3; i++)\n ans = Math.max(ans, abc[i][0]+dp(i, 1));\n return ans;\n }\n \n public static int dp(int bad, int at)\n {\n\tif (at == n)\n return 0;\n if (memo[bad][at] != null)\n return memo[bad][at];\n \n int ans = 0;\n int to1 = 3-at;\n int to2 = 0;\n if (to1 == 3)\n {\n to1 = 1;\n to2 = 2;\n }\n ans = Math.max(ans, abc[to1][at]+dp(to1, at+1));\n ans = Math.max(ans, abc[to2][at]+dp(to2, at+1));\n return memo[bad][at] = ans;\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": 967, "cpu_time_ms": 596, "memory_kb": 93976}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s451455341", "group_id": "codeNet:p03164", "input_text": "import java.io.*;\nimport java.util.*;\n\npublic class Main{\n\n \n public static void main(String[] args){\n\t\tnew Main().run();\n }\n\n void run(){\n Scanner sc=new Scanner(System.in);\n int N=sc.nextInt();\n long W=sc.nextLong();\n long[] w=new long[N];\n int[] v=new int[N];\n for(int i=0;i=0;--j){\n \t dp[j+v[i]]=Math.min(dp[j+v[i]],dp[j]+w[i]);\n }\n }\n long ans=0;\n for(int i=0;i=0;--j){\n \t dp[j+v[i]]=Math.min(dp[j+v[i]],dp[j]+w[i]);\n }\n }\n long ans=0;\n for(int i=0;i= '0' && c <= '9');\n\n\t\t\tif (neg)\n\t\t\t\treturn -ret;\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic long nextLong() throws IOException {\n\t\t\tlong ret = 0;\n\t\t\tbyte c = read();\n\t\t\twhile (c <= ' ')\n\t\t\t\tc = read();\n\t\t\tboolean neg = (c == '-');\n\t\t\tif (neg)\n\t\t\t\tc = read();\n\t\t\tdo {\n\t\t\t\tret = ret * 10 + c - '0';\n\t\t\t} while ((c = read()) >= '0' && c <= '9');\n\t\t\tif (neg)\n\t\t\t\treturn -ret;\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic double nextDouble() throws IOException {\n\t\t\tdouble ret = 0, div = 1;\n\t\t\tbyte c = read();\n\t\t\twhile (c <= ' ')\n\t\t\t\tc = read();\n\t\t\tboolean neg = (c == '-');\n\t\t\tif (neg)\n\t\t\t\tc = read();\n\n\t\t\tdo {\n\t\t\t\tret = ret * 10 + c - '0';\n\t\t\t} while ((c = read()) >= '0' && c <= '9');\n\n\t\t\tif (c == '.') {\n\t\t\t\twhile ((c = read()) >= '0' && c <= '9') {\n\t\t\t\t\tret += (c - '0') / (div *= 10);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (neg)\n\t\t\t\treturn -ret;\n\t\t\treturn ret;\n\t\t}\n\n\t\tprivate void fillBuffer() throws IOException {\n\t\t\tbytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);\n\t\t\tif (bytesRead == -1)\n\t\t\t\tbuffer[0] = -1;\n\t\t}\n\n\t\tprivate byte read() throws IOException {\n\t\t\tif (bufferPointer == bytesRead)\n\t\t\t\tfillBuffer();\n\t\t\treturn buffer[bufferPointer++];\n\t\t}\n\n\t\tpublic void close() throws IOException {\n\t\t\tif (din == null)\n\t\t\t\treturn;\n\t\t\tdin.close();\n\t\t}\n\t}\n\t\n\tstatic ArrayList[] adj;\n\t\n\tpublic static void main(String[] args) throws Exception {\n\t\tReader in = new Reader();\n\t\tint N = in.nextInt();\n\t\tint M = in.nextInt();\n\t\tadj = new ArrayList[N];\n\t\tfor(int i = 0; i < N; ++i) {\n\t\t\tadj[i] = new ArrayList();\n\t\t}\n\t\tfor(int i = 0; i < M; ++i) {\n\t\t\tint x = in.nextInt() - 1;\n\t\t\tint y = in.nextInt() - 1;\n\t\t\tadj[x].add(y);\n\t\t}\n\t\tint[] dp = new int[N];\n\t\tboolean[] vis = new boolean[N];\n\t\tfor(int i = 0; i < N; ++i) {\n\t\t\tif(vis[i]) continue;\n\t\t\tLinkedList q = new LinkedList();\n\t\t\tq.add(i);\n\t\t\tvis[i] = true;\n\t\t\twhile(!q.isEmpty()) {\n\t\t\t\tint cur = q.poll();\n\t\t\t\tfor(Integer j : adj[cur]) {\n\t\t\t\t\tif(dp[cur] + 1 > dp[j]) {\n\t\t\t\t\t\tq.add(j);\n\t\t\t\t\t\tdp[j] = dp[cur] + 1;\n\t\t\t\t\t\tvis[j] = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tint mx = 0;\n\t\tfor(int i = 0; i < N; ++i) {\n\t\t\tmx = Math.max(mx, dp[i]);\n\t\t}\n\t\tSystem.out.println(mx);\n\t\tin.close();\n\t}\n}", "language": "Java", "metadata": {"date": 1598308384, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p03166.html", "problem_id": "p03166", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03166/input.txt", "sample_output_relpath": "derived/input_output/data/p03166/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03166/Java/s668102789.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s668102789", "user_id": "u816600238"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\n\npublic class Main {\n\tfinal static int MOD = 1000000007;\n\tfinal static int intMax = 1000000000;\n\tfinal static int intMin = -1000000000;\n\tfinal static int[] dx = { 0, 0, -1, 1 };\n\tfinal static int[] dy = { -1, 1, 0, 0 };\n\n\tstatic int T;\n\n\tstatic class Reader {\n\t\tfinal private int BUFFER_SIZE = 1 << 16;\n\t\tprivate DataInputStream din;\n\t\tprivate byte[] buffer;\n\t\tprivate int bufferPointer, bytesRead;\n\n\t\tpublic Reader() {\n\t\t\tdin = new DataInputStream(System.in);\n\t\t\tbuffer = new byte[BUFFER_SIZE];\n\t\t\tbufferPointer = bytesRead = 0;\n\t\t}\n\n\t\tpublic Reader(String file_name) throws IOException {\n\t\t\tdin = new DataInputStream(new FileInputStream(file_name));\n\t\t\tbuffer = new byte[BUFFER_SIZE];\n\t\t\tbufferPointer = bytesRead = 0;\n\t\t}\n\n\t\tpublic String readLine() throws IOException {\n\t\t\tbyte[] buf = new byte[360]; // line length\n\t\t\tint cnt = 0, c;\n\t\t\twhile ((c = read()) != -1) {\n\t\t\t\tif (c == '\\n')\n\t\t\t\t\tbreak;\n\t\t\t\tbuf[cnt++] = (byte) c;\n\t\t\t}\n\t\t\treturn new String(buf, 0, cnt);\n\t\t}\n\n\t\tpublic int nextInt() throws IOException {\n\t\t\tint ret = 0;\n\t\t\tbyte c = read();\n\t\t\twhile (c <= ' ')\n\t\t\t\tc = read();\n\t\t\tboolean neg = (c == '-');\n\t\t\tif (neg)\n\t\t\t\tc = read();\n\t\t\tdo {\n\t\t\t\tret = ret * 10 + c - '0';\n\t\t\t} while ((c = read()) >= '0' && c <= '9');\n\n\t\t\tif (neg)\n\t\t\t\treturn -ret;\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic long nextLong() throws IOException {\n\t\t\tlong ret = 0;\n\t\t\tbyte c = read();\n\t\t\twhile (c <= ' ')\n\t\t\t\tc = read();\n\t\t\tboolean neg = (c == '-');\n\t\t\tif (neg)\n\t\t\t\tc = read();\n\t\t\tdo {\n\t\t\t\tret = ret * 10 + c - '0';\n\t\t\t} while ((c = read()) >= '0' && c <= '9');\n\t\t\tif (neg)\n\t\t\t\treturn -ret;\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic double nextDouble() throws IOException {\n\t\t\tdouble ret = 0, div = 1;\n\t\t\tbyte c = read();\n\t\t\twhile (c <= ' ')\n\t\t\t\tc = read();\n\t\t\tboolean neg = (c == '-');\n\t\t\tif (neg)\n\t\t\t\tc = read();\n\n\t\t\tdo {\n\t\t\t\tret = ret * 10 + c - '0';\n\t\t\t} while ((c = read()) >= '0' && c <= '9');\n\n\t\t\tif (c == '.') {\n\t\t\t\twhile ((c = read()) >= '0' && c <= '9') {\n\t\t\t\t\tret += (c - '0') / (div *= 10);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (neg)\n\t\t\t\treturn -ret;\n\t\t\treturn ret;\n\t\t}\n\n\t\tprivate void fillBuffer() throws IOException {\n\t\t\tbytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);\n\t\t\tif (bytesRead == -1)\n\t\t\t\tbuffer[0] = -1;\n\t\t}\n\n\t\tprivate byte read() throws IOException {\n\t\t\tif (bufferPointer == bytesRead)\n\t\t\t\tfillBuffer();\n\t\t\treturn buffer[bufferPointer++];\n\t\t}\n\n\t\tpublic void close() throws IOException {\n\t\t\tif (din == null)\n\t\t\t\treturn;\n\t\t\tdin.close();\n\t\t}\n\t}\n\t\n\tstatic ArrayList[] adj;\n\t\n\tpublic static void main(String[] args) throws Exception {\n\t\tReader in = new Reader();\n\t\tint N = in.nextInt();\n\t\tint M = in.nextInt();\n\t\tadj = new ArrayList[N];\n\t\tfor(int i = 0; i < N; ++i) {\n\t\t\tadj[i] = new ArrayList();\n\t\t}\n\t\tfor(int i = 0; i < M; ++i) {\n\t\t\tint x = in.nextInt() - 1;\n\t\t\tint y = in.nextInt() - 1;\n\t\t\tadj[x].add(y);\n\t\t}\n\t\tint[] dp = new int[N];\n\t\tboolean[] vis = new boolean[N];\n\t\tfor(int i = 0; i < N; ++i) {\n\t\t\tif(vis[i]) continue;\n\t\t\tLinkedList q = new LinkedList();\n\t\t\tq.add(i);\n\t\t\tvis[i] = true;\n\t\t\twhile(!q.isEmpty()) {\n\t\t\t\tint cur = q.poll();\n\t\t\t\tfor(Integer j : adj[cur]) {\n\t\t\t\t\tif(dp[cur] + 1 > dp[j]) {\n\t\t\t\t\t\tq.add(j);\n\t\t\t\t\t\tdp[j] = dp[cur] + 1;\n\t\t\t\t\t\tvis[j] = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tint mx = 0;\n\t\tfor(int i = 0; i < N; ++i) {\n\t\t\tmx = Math.max(mx, dp[i]);\n\t\t}\n\t\tSystem.out.println(mx);\n\t\tin.close();\n\t}\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a directed graph G with N vertices and M edges.\nThe vertices are numbered 1, 2, \\ldots, N, and for each i (1 \\leq i \\leq M), the i-th directed edge goes from Vertex x_i to y_i.\nG does not contain directed cycles.\n\nFind the length of the longest directed path in G.\nHere, the length of a directed path is the number of edges in it.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nAll pairs (x_i, y_i) are distinct.\n\nG does not contain directed cycles.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the length of the longest directed path in G.\n\nSample Input 1\n\n4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n\nSample Output 1\n\n3\n\nThe red directed path in the following figure is the longest:\n\nSample Input 2\n\n6 3\n2 3\n4 5\n5 6\n\nSample Output 2\n\n2\n\nThe red directed path in the following figure is the longest:\n\nSample Input 3\n\n5 8\n5 3\n2 3\n2 4\n5 2\n5 1\n1 4\n4 3\n1 3\n\nSample Output 3\n\n3\n\nThe red directed path in the following figure is one of the longest:", "sample_input": "4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03166", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a directed graph G with N vertices and M edges.\nThe vertices are numbered 1, 2, \\ldots, N, and for each i (1 \\leq i \\leq M), the i-th directed edge goes from Vertex x_i to y_i.\nG does not contain directed cycles.\n\nFind the length of the longest directed path in G.\nHere, the length of a directed path is the number of edges in it.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nAll pairs (x_i, y_i) are distinct.\n\nG does not contain directed cycles.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the length of the longest directed path in G.\n\nSample Input 1\n\n4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n\nSample Output 1\n\n3\n\nThe red directed path in the following figure is the longest:\n\nSample Input 2\n\n6 3\n2 3\n4 5\n5 6\n\nSample Output 2\n\n2\n\nThe red directed path in the following figure is the longest:\n\nSample Input 3\n\n5 8\n5 3\n2 3\n2 4\n5 2\n5 1\n1 4\n4 3\n1 3\n\nSample Output 3\n\n3\n\nThe red directed path in the following figure is one of the longest:", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3367, "cpu_time_ms": 2207, "memory_kb": 65340}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s294720315", "group_id": "codeNet:p03166", "input_text": "\n// Problem : G - Longest Path\n// Contest : Educational DP Contest\n// URL : https://atcoder.jp/contests/dp/tasks/dp_g\n// Memory Limit : 1024 MB\n// Time Limit : 2000 ms\n// Powered by CP Editor (https://github.com/cpeditor/cpeditor)\n\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n\t\n\tpublic static void main(String[] args) throws Exception {\n\t\tFastReader scan = new FastReader();\n\t\tPrintWriter out = new PrintWriter(System.out);\n\t\t//PrintWriter out = new PrintWriter(\"file.out\");\n\t\tTask solver = new Task();\n\t\t//int t = scan.nextInt();\n\t\tint t = 1;\n\t\tfor(int i = 1; i <= t; i++) solver.solve(i, scan, out);\n\t\tout.close();\n\t}\n\n\tstatic class Task {\n\t\tstatic final int inf = Integer.MAX_VALUE;\n\t\tpublic void solve(int testNumber, FastReader sc, PrintWriter pw) {\n\t\t\tint n = sc.nextInt();\n\t\t\tArrayList[] adjl1 = new ArrayList[n];\n\t\t\tArrayList[] adjl2 = new ArrayList[n];\n\t\t\tint m = sc.nextInt();\n\t\t\tfor(int i=0;i();\n\t\t\t\tadjl2[i] = new ArrayList();\n\t\t\t}\n\t\t\tfor(int i = 0;i < m;i++){\n\t\t\t\tint a = sc.nextInt()-1;\n\t\t\t\tint b = sc.nextInt()-1;\n\t\t\t\tadjl1[a].add(b);\n\t\t\t\tadjl2[b].add(a);\n\t\t\t}\n\t\t\tQueue q = new LinkedList();\n\t\t\tint[] freq = new int[n];\n\t\t\tfor(int i = 0;i < n; i++){\n\t\t\t\tif(adjl1[i].size() == 0){\n\t\t\t\t\tq.add(i);\n\t\t\t\t\tfreq[i]++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tint bfs[] = new int[n];\n\t\t\twhile(!q.isEmpty()){\n\t\t\t\tint t = q.poll();\n\t\t\t\tfreq[t]--;\n\t\t\t\tif(freq[t]>0){\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tfor(int x : adjl2[t]){\n\t\t\t\t\tif(bfs[x] 0) {\n\t\t\tif ((b & 1) == 1)\n\t\t\t\tres = res * a % m;\n\t\t\ta = a * a % m;\n\t\t\tb >>= 1;\n\t\t}\n\t\treturn res;\n\t}\n\tstatic class tup implements Comparable{\n\t\tint a, b;\n\t\ttup(int a,int b){\n\t\t\tthis.a=a;\n\t\t\tthis.b=b;\n\t\t}\n\t\t@Override\n\t\tpublic int compareTo(tup o){\n\t\t\treturn Integer.compare(o.b,b);\n\t\t}\n\t}\n\tstatic void shuffle(int[] a) {\n\t\tRandom get = new Random();\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tint r = get.nextInt(a.length);\n\t\t\tint temp = a[i];\n\t\t\ta[i] = a[r];\n\t\t\ta[r] = temp;\n\t\t}\n\t}\n\n\tstatic void shuffle(long[] a) {\n\t\tRandom get = new Random();\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tint r = get.nextInt(a.length);\n\t\t\tlong temp = a[i];\n\t\t\ta[i] = a[r];\n\t\t\ta[r] = temp;\n\t\t}\n\t}\n\n\tstatic class FastReader {\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\n\t\tpublic FastReader() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\n\t\tpublic FastReader(String s) throws FileNotFoundException {\n\t\t\tbr = new BufferedReader(new FileReader(new File(s)));\n\t\t}\n\n\t\tString next() {\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\t}\n\n}", "language": "Java", "metadata": {"date": 1586408605, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03166.html", "problem_id": "p03166", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03166/input.txt", "sample_output_relpath": "derived/input_output/data/p03166/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03166/Java/s294720315.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s294720315", "user_id": "u882458885"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "\n// Problem : G - Longest Path\n// Contest : Educational DP Contest\n// URL : https://atcoder.jp/contests/dp/tasks/dp_g\n// Memory Limit : 1024 MB\n// Time Limit : 2000 ms\n// Powered by CP Editor (https://github.com/cpeditor/cpeditor)\n\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n\t\n\tpublic static void main(String[] args) throws Exception {\n\t\tFastReader scan = new FastReader();\n\t\tPrintWriter out = new PrintWriter(System.out);\n\t\t//PrintWriter out = new PrintWriter(\"file.out\");\n\t\tTask solver = new Task();\n\t\t//int t = scan.nextInt();\n\t\tint t = 1;\n\t\tfor(int i = 1; i <= t; i++) solver.solve(i, scan, out);\n\t\tout.close();\n\t}\n\n\tstatic class Task {\n\t\tstatic final int inf = Integer.MAX_VALUE;\n\t\tpublic void solve(int testNumber, FastReader sc, PrintWriter pw) {\n\t\t\tint n = sc.nextInt();\n\t\t\tArrayList[] adjl1 = new ArrayList[n];\n\t\t\tArrayList[] adjl2 = new ArrayList[n];\n\t\t\tint m = sc.nextInt();\n\t\t\tfor(int i=0;i();\n\t\t\t\tadjl2[i] = new ArrayList();\n\t\t\t}\n\t\t\tfor(int i = 0;i < m;i++){\n\t\t\t\tint a = sc.nextInt()-1;\n\t\t\t\tint b = sc.nextInt()-1;\n\t\t\t\tadjl1[a].add(b);\n\t\t\t\tadjl2[b].add(a);\n\t\t\t}\n\t\t\tQueue q = new LinkedList();\n\t\t\tint[] freq = new int[n];\n\t\t\tfor(int i = 0;i < n; i++){\n\t\t\t\tif(adjl1[i].size() == 0){\n\t\t\t\t\tq.add(i);\n\t\t\t\t\tfreq[i]++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tint bfs[] = new int[n];\n\t\t\twhile(!q.isEmpty()){\n\t\t\t\tint t = q.poll();\n\t\t\t\tfreq[t]--;\n\t\t\t\tif(freq[t]>0){\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tfor(int x : adjl2[t]){\n\t\t\t\t\tif(bfs[x] 0) {\n\t\t\tif ((b & 1) == 1)\n\t\t\t\tres = res * a % m;\n\t\t\ta = a * a % m;\n\t\t\tb >>= 1;\n\t\t}\n\t\treturn res;\n\t}\n\tstatic class tup implements Comparable{\n\t\tint a, b;\n\t\ttup(int a,int b){\n\t\t\tthis.a=a;\n\t\t\tthis.b=b;\n\t\t}\n\t\t@Override\n\t\tpublic int compareTo(tup o){\n\t\t\treturn Integer.compare(o.b,b);\n\t\t}\n\t}\n\tstatic void shuffle(int[] a) {\n\t\tRandom get = new Random();\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tint r = get.nextInt(a.length);\n\t\t\tint temp = a[i];\n\t\t\ta[i] = a[r];\n\t\t\ta[r] = temp;\n\t\t}\n\t}\n\n\tstatic void shuffle(long[] a) {\n\t\tRandom get = new Random();\n\t\tfor (int i = 0; i < a.length; i++) {\n\t\t\tint r = get.nextInt(a.length);\n\t\t\tlong temp = a[i];\n\t\t\ta[i] = a[r];\n\t\t\ta[r] = temp;\n\t\t}\n\t}\n\n\tstatic class FastReader {\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\n\t\tpublic FastReader() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\n\t\tpublic FastReader(String s) throws FileNotFoundException {\n\t\t\tbr = new BufferedReader(new FileReader(new File(s)));\n\t\t}\n\n\t\tString next() {\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\t}\n\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a directed graph G with N vertices and M edges.\nThe vertices are numbered 1, 2, \\ldots, N, and for each i (1 \\leq i \\leq M), the i-th directed edge goes from Vertex x_i to y_i.\nG does not contain directed cycles.\n\nFind the length of the longest directed path in G.\nHere, the length of a directed path is the number of edges in it.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nAll pairs (x_i, y_i) are distinct.\n\nG does not contain directed cycles.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the length of the longest directed path in G.\n\nSample Input 1\n\n4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n\nSample Output 1\n\n3\n\nThe red directed path in the following figure is the longest:\n\nSample Input 2\n\n6 3\n2 3\n4 5\n5 6\n\nSample Output 2\n\n2\n\nThe red directed path in the following figure is the longest:\n\nSample Input 3\n\n5 8\n5 3\n2 3\n2 4\n5 2\n5 1\n1 4\n4 3\n1 3\n\nSample Output 3\n\n3\n\nThe red directed path in the following figure is one of the longest:", "sample_input": "4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03166", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a directed graph G with N vertices and M edges.\nThe vertices are numbered 1, 2, \\ldots, N, and for each i (1 \\leq i \\leq M), the i-th directed edge goes from Vertex x_i to y_i.\nG does not contain directed cycles.\n\nFind the length of the longest directed path in G.\nHere, the length of a directed path is the number of edges in it.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nAll pairs (x_i, y_i) are distinct.\n\nG does not contain directed cycles.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the length of the longest directed path in G.\n\nSample Input 1\n\n4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n\nSample Output 1\n\n3\n\nThe red directed path in the following figure is the longest:\n\nSample Input 2\n\n6 3\n2 3\n4 5\n5 6\n\nSample Output 2\n\n2\n\nThe red directed path in the following figure is the longest:\n\nSample Input 3\n\n5 8\n5 3\n2 3\n2 4\n5 2\n5 1\n1 4\n4 3\n1 3\n\nSample Output 3\n\n3\n\nThe red directed path in the following figure is one of the longest:", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3300, "cpu_time_ms": 2110, "memory_kb": 352436}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s776954836", "group_id": "codeNet:p03167", "input_text": "/*\n * To change this license header, choose License Headers in Project Properties.\n * To change this template file, choose Tools | Templates\n * and open the template in the editor.\n */\nimport java.util.*;\n/**\n *\n * @author arvin\n */\npublic class Main {\n \n static char a[][];\n static long dp[][];\n static int m,n;\n \n static long rec(int x,int y)\n {\n if(x==n-1 && y==m-1)\n return 1l;\n if(x>=n || y>=m || a[x][y]=='#')\n return 0l;\n long ab,ch;\n if(dp[x+1][y]==0)\n ch=rec(x+1,y);\n else\n ch=dp[x+1][y];\n if(dp[x][y+1]==0)\n ab=rec(x,y+1);\n else\n ab=dp[x][y+1];\n dp[x][y]=(ch+ab)%1000000007l;\n return dp[x][y];\n }\n \n public static void main(String args[])\n {\n Scanner sc=new Scanner(System.in);\n n=sc.nextInt();\n m=sc.nextInt();\n a=new char[n+1][m+1];\n dp=new long[n+1][m+1];\n sc.nextLine();\n for(int i=0;i=n || y>=m || a[x][y]=='#')\n return 0l;\n long ab,ch;\n if(dp[x+1][y]==0)\n ch=rec(x+1,y);\n else\n ch=dp[x+1][y];\n if(dp[x][y+1]==0)\n ab=rec(x,y+1);\n else\n ab=dp[x][y+1];\n dp[x][y]=(ch+ab)%1000000007l;\n return dp[x][y];\n }\n \n public static void main(String args[])\n {\n Scanner sc=new Scanner(System.in);\n n=sc.nextInt();\n m=sc.nextInt();\n a=new char[n+1][m+1];\n dp=new long[n+1][m+1];\n sc.nextLine();\n for(int i=0;i primes;\n static ArrayList factorial;\n static HashSet graph[];\n/****************************************Solutions Begins*****************************************/\n static int n,m,input[][];\n static long dp[][];\n static boolean safe(int i,int j){\n if(i>=0&&j>=0&&i();\n }\n }\n static void addEdge(int a,int b){\n graph[a].add(b);\n } \n\n/*********************************************PAIR********************************************************/\n static class PairComp implements Comparator{\n public int compare(Pair p1,Pair p2){\n if(p1.u>p2.u){\n return 1;\n }\n else if(p1.u {\n int u;\n int v;\n int index=-1;\n public Pair(int u, int v) {\n this.u = u;\n this.v = v;\n }\n \n public int hashCode() {\n int hu = (int) (u ^ (u >>> 32));\n int hv = (int) (v ^ (v >>> 32));\n return 31 * hu + hv;\n }\n \n public boolean equals(Object o) {\n Pair other = (Pair) o;\n return u == other.u && v == other.v;\n }\n \n public int compareTo(Pair other) {\n if(index!=other.index)\n return Long.compare(index, other.index);\n return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);\n }\n \n public String toString() {\n return \"[u=\" + u + \", v=\" + v + \"]\";\n }\n }\n\n static class PairCompL implements Comparator{\n public int compare(Pairl p1,Pairl p2){\n if(p1.u>p2.u){\n return 1;\n }\n else if(p1.u {\n long u;\n long v;\n int index=-1;\n public Pairl(long u, long v) {\n this.u = u;\n this.v = v;\n }\n \n public int hashCode() {\n int hu = (int) (u ^ (u >>> 32));\n int hv = (int) (v ^ (v >>> 32));\n return 31 * hu + hv;\n }\n \n public boolean equals(Object o) {\n Pair other = (Pair) o;\n return u == other.u && v == other.v;\n }\n \n public int compareTo(Pair other) {\n if(index!=other.index)\n return Long.compare(index, other.index);\n return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);\n }\n \n public String toString() {\n return \"[u=\" + u + \", v=\" + v + \"]\";\n }\n }\n/*****************************************DEBUG***********************************************************/\n public static void debug(Object... o) {\n System.out.println(Arrays.deepToString(o));\n }\n/************************************MODULAR EXPONENTIATION***********************************************/\n static long modulo(long a,long b,long c) {\n long x=1;\n long y=a;\n while(b > 0){\n if(b%2 == 1){\n x=(x*y)%c;\n }\n y = (y*y)%c; // squaring the base\n b /= 2;\n }\n return x%c;\n }\n/********************************************GCD**********************************************************/\n static long gcd(long x, long y)\n {\n if(x==0)\n return y;\n if(y==0)\n return x;\n long r=0, a, b;\n a = (x > y) ? x : y; // a is greater number\n b = (x < y) ? x : y; // b is smaller number\n r = b;\n while(a % b != 0)\n {\n r = a % b;\n a = b;\n b = r;\n }\n return r;\n }\n/******************************************SIEVE**********************************************************/\n static void sieveMake(int n){\n sieve=new boolean[n];\n Arrays.fill(sieve,true);\n sieve[0]=false;\n sieve[1]=false;\n for(int i=2;i*i();\n for(int i=0;i primes;\n static ArrayList factorial;\n static HashSet graph[];\n/****************************************Solutions Begins*****************************************/\n static int n,m,input[][];\n static long dp[][];\n static boolean safe(int i,int j){\n if(i>=0&&j>=0&&i();\n }\n }\n static void addEdge(int a,int b){\n graph[a].add(b);\n } \n\n/*********************************************PAIR********************************************************/\n static class PairComp implements Comparator{\n public int compare(Pair p1,Pair p2){\n if(p1.u>p2.u){\n return 1;\n }\n else if(p1.u {\n int u;\n int v;\n int index=-1;\n public Pair(int u, int v) {\n this.u = u;\n this.v = v;\n }\n \n public int hashCode() {\n int hu = (int) (u ^ (u >>> 32));\n int hv = (int) (v ^ (v >>> 32));\n return 31 * hu + hv;\n }\n \n public boolean equals(Object o) {\n Pair other = (Pair) o;\n return u == other.u && v == other.v;\n }\n \n public int compareTo(Pair other) {\n if(index!=other.index)\n return Long.compare(index, other.index);\n return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);\n }\n \n public String toString() {\n return \"[u=\" + u + \", v=\" + v + \"]\";\n }\n }\n\n static class PairCompL implements Comparator{\n public int compare(Pairl p1,Pairl p2){\n if(p1.u>p2.u){\n return 1;\n }\n else if(p1.u {\n long u;\n long v;\n int index=-1;\n public Pairl(long u, long v) {\n this.u = u;\n this.v = v;\n }\n \n public int hashCode() {\n int hu = (int) (u ^ (u >>> 32));\n int hv = (int) (v ^ (v >>> 32));\n return 31 * hu + hv;\n }\n \n public boolean equals(Object o) {\n Pair other = (Pair) o;\n return u == other.u && v == other.v;\n }\n \n public int compareTo(Pair other) {\n if(index!=other.index)\n return Long.compare(index, other.index);\n return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);\n }\n \n public String toString() {\n return \"[u=\" + u + \", v=\" + v + \"]\";\n }\n }\n/*****************************************DEBUG***********************************************************/\n public static void debug(Object... o) {\n System.out.println(Arrays.deepToString(o));\n }\n/************************************MODULAR EXPONENTIATION***********************************************/\n static long modulo(long a,long b,long c) {\n long x=1;\n long y=a;\n while(b > 0){\n if(b%2 == 1){\n x=(x*y)%c;\n }\n y = (y*y)%c; // squaring the base\n b /= 2;\n }\n return x%c;\n }\n/********************************************GCD**********************************************************/\n static long gcd(long x, long y)\n {\n if(x==0)\n return y;\n if(y==0)\n return x;\n long r=0, a, b;\n a = (x > y) ? x : y; // a is greater number\n b = (x < y) ? x : y; // b is smaller number\n r = b;\n while(a % b != 0)\n {\n r = a % b;\n a = b;\n b = r;\n }\n return r;\n }\n/******************************************SIEVE**********************************************************/\n static void sieveMake(int n){\n sieve=new boolean[n];\n Arrays.fill(sieve,true);\n sieve[0]=false;\n sieve[1]=false;\n for(int i=2;i*i();\n for(int i=0;i= '!' && ch <= '~';\n\t\t}\n\n\t\tprivate boolean isCRLF(int ch) {\n\t\t\treturn ch == '\\n' || ch == '\\r' || ch == -1;\n\t\t}\n\n\t\tprivate int nextPrintable() {\n\t\t\ttry {\n\t\t\t\tint ch;\n\t\t\t\twhile (!isPrintable(ch = br.read())) {\n\t\t\t\t\tif (ch == -1) {\n\t\t\t\t\t\tthrow new NoSuchElementException();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn ch;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tString next() {\n\t\t\ttry {\n\t\t\t\tint ch = nextPrintable();\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tdo {\n\t\t\t\t\tsb.appendCodePoint(ch);\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn sb.toString();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tint nextInt() {\n\t\t\ttry {\n\t\t\t\t// parseInt from Integer.parseInt()\n\t\t\t\tboolean negative = false;\n\t\t\t\tint res = 0;\n\t\t\t\tint limit = -Integer.MAX_VALUE;\n\t\t\t\tint radix = 10;\n\n\t\t\t\tint fc = nextPrintable();\n\t\t\t\tif (fc < '0') {\n\t\t\t\t\tif (fc == '-') {\n\t\t\t\t\t\tnegative = true;\n\t\t\t\t\t\tlimit = Integer.MIN_VALUE;\n\t\t\t\t\t} else if (fc != '+') {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tfc = br.read();\n\t\t\t\t}\n\t\t\t\tint multmin = limit / radix;\n\n\t\t\t\tint ch = fc;\n\t\t\t\tdo {\n\t\t\t\t\tint digit = ch - '0';\n\t\t\t\t\tif (digit < 0 || digit >= radix) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tif (res < multmin) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres *= radix;\n\t\t\t\t\tif (res < limit + digit) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres -= digit;\n\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn negative ? res : -res;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\ttry {\n\t\t\t\t// parseLong from Long.parseLong()\n\t\t\t\tboolean negative = false;\n\t\t\t\tlong res = 0;\n\t\t\t\tlong limit = -Long.MAX_VALUE;\n\t\t\t\tint radix = 10;\n\n\t\t\t\tint fc = nextPrintable();\n\t\t\t\tif (fc < '0') {\n\t\t\t\t\tif (fc == '-') {\n\t\t\t\t\t\tnegative = true;\n\t\t\t\t\t\tlimit = Long.MIN_VALUE;\n\t\t\t\t\t} else if (fc != '+') {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tfc = br.read();\n\t\t\t\t}\n\t\t\t\tlong multmin = limit / radix;\n\n\t\t\t\tint ch = fc;\n\t\t\t\tdo {\n\t\t\t\t\tint digit = ch - '0';\n\t\t\t\t\tif (digit < 0 || digit >= radix) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tif (res < multmin) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres *= radix;\n\t\t\t\t\tif (res < limit + digit) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres -= digit;\n\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn negative ? res : -res;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tfloat nextFloat() {\n\t\t\treturn Float.parseFloat(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\ttry {\n\t\t\t\tint ch;\n\t\t\t\twhile (isCRLF(ch = br.read())) {\n\t\t\t\t\tif (ch == -1) {\n\t\t\t\t\t\tthrow new NoSuchElementException();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tdo {\n\t\t\t\t\tsb.appendCodePoint(ch);\n\t\t\t\t} while (!isCRLF(ch = br.read()));\n\n\t\t\t\treturn sb.toString();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tvoid close() {\n\t\t\ttry {\n\t\t\t\tbr.close();\n\t\t\t} catch (IOException e) {\n//\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic class Printer extends PrintWriter {\n\t\tPrinter(OutputStream out) {\n\t\t\tsuper(out);\n\t\t}\n\t}\n}\n", "language": "Java", "metadata": {"date": 1548990135, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03173.html", "problem_id": "p03173", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03173/input.txt", "sample_output_relpath": "derived/input_output/data/p03173/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03173/Java/s319716782.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s319716782", "user_id": "u900015623"}, "prompt_components": {"gold_output": "190\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\n\n\npublic class Main {\n\n\tprivate static Scanner sc;\n\tprivate static Printer pr;\n\n\tprivate static void solve() {\n\t\tint n = sc.nextInt();\n\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\tlong[] cumsum = new long[n + 1];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tcumsum[i + 1] = cumsum[i] + a[i];\n\t\t}\n\n\t\tfinal long INF = Long.MAX_VALUE / 2;\n\t\tlong[][] dp = new long[n][n];\n\t\tfor (int d = 1; d < n; d++) {\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tfor (int j = i + d; j < n; j++) {\n\t\t\t\t\tdp[i][j] = INF;\n\t\t\t\t\tfor (int k = i; k < j; k++) {\n\t\t\t\t\t\tdp[i][j] = Math.min(dp[i][j], dp[i][k] + dp[k + 1][j] + cumsum[k + 1] - cumsum[i] + cumsum[j + 1] - cumsum[k + 1]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpr.println(dp[0][n - 1]);\n\t}\n\n // ---------------------------------------------------\n\tpublic static void main(String[] args) {\n\t\tsc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));\n\t\tpr = new Printer(System.out);\n\n\t\tsolve();\n\n//\t\tpr.close();\n\t\tpr.flush();\n//\t\tsc.close();\n\t}\n\n\tstatic String INPUT = null;\n\n\tstatic class Scanner {\n\t\tBufferedReader br;\n\n\t\tScanner (InputStream in) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(in));\n\t\t}\n\n\t\tprivate boolean isPrintable(int ch) {\n\t\t\treturn ch >= '!' && ch <= '~';\n\t\t}\n\n\t\tprivate boolean isCRLF(int ch) {\n\t\t\treturn ch == '\\n' || ch == '\\r' || ch == -1;\n\t\t}\n\n\t\tprivate int nextPrintable() {\n\t\t\ttry {\n\t\t\t\tint ch;\n\t\t\t\twhile (!isPrintable(ch = br.read())) {\n\t\t\t\t\tif (ch == -1) {\n\t\t\t\t\t\tthrow new NoSuchElementException();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn ch;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tString next() {\n\t\t\ttry {\n\t\t\t\tint ch = nextPrintable();\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tdo {\n\t\t\t\t\tsb.appendCodePoint(ch);\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn sb.toString();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tint nextInt() {\n\t\t\ttry {\n\t\t\t\t// parseInt from Integer.parseInt()\n\t\t\t\tboolean negative = false;\n\t\t\t\tint res = 0;\n\t\t\t\tint limit = -Integer.MAX_VALUE;\n\t\t\t\tint radix = 10;\n\n\t\t\t\tint fc = nextPrintable();\n\t\t\t\tif (fc < '0') {\n\t\t\t\t\tif (fc == '-') {\n\t\t\t\t\t\tnegative = true;\n\t\t\t\t\t\tlimit = Integer.MIN_VALUE;\n\t\t\t\t\t} else if (fc != '+') {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tfc = br.read();\n\t\t\t\t}\n\t\t\t\tint multmin = limit / radix;\n\n\t\t\t\tint ch = fc;\n\t\t\t\tdo {\n\t\t\t\t\tint digit = ch - '0';\n\t\t\t\t\tif (digit < 0 || digit >= radix) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tif (res < multmin) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres *= radix;\n\t\t\t\t\tif (res < limit + digit) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres -= digit;\n\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn negative ? res : -res;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\ttry {\n\t\t\t\t// parseLong from Long.parseLong()\n\t\t\t\tboolean negative = false;\n\t\t\t\tlong res = 0;\n\t\t\t\tlong limit = -Long.MAX_VALUE;\n\t\t\t\tint radix = 10;\n\n\t\t\t\tint fc = nextPrintable();\n\t\t\t\tif (fc < '0') {\n\t\t\t\t\tif (fc == '-') {\n\t\t\t\t\t\tnegative = true;\n\t\t\t\t\t\tlimit = Long.MIN_VALUE;\n\t\t\t\t\t} else if (fc != '+') {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tfc = br.read();\n\t\t\t\t}\n\t\t\t\tlong multmin = limit / radix;\n\n\t\t\t\tint ch = fc;\n\t\t\t\tdo {\n\t\t\t\t\tint digit = ch - '0';\n\t\t\t\t\tif (digit < 0 || digit >= radix) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tif (res < multmin) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres *= radix;\n\t\t\t\t\tif (res < limit + digit) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres -= digit;\n\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn negative ? res : -res;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tfloat nextFloat() {\n\t\t\treturn Float.parseFloat(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\ttry {\n\t\t\t\tint ch;\n\t\t\t\twhile (isCRLF(ch = br.read())) {\n\t\t\t\t\tif (ch == -1) {\n\t\t\t\t\t\tthrow new NoSuchElementException();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tdo {\n\t\t\t\t\tsb.appendCodePoint(ch);\n\t\t\t\t} while (!isCRLF(ch = br.read()));\n\n\t\t\t\treturn sb.toString();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tvoid close() {\n\t\t\ttry {\n\t\t\t\tbr.close();\n\t\t\t} catch (IOException e) {\n//\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic class Printer extends PrintWriter {\n\t\tPrinter(OutputStream out) {\n\t\t\tsuper(out);\n\t\t}\n\t}\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N slimes lining up in a row.\nInitially, the i-th slime from the left has a size of a_i.\n\nTaro is trying to combine all the slimes into a larger slime.\nHe will perform the following operation repeatedly until there is only one slime:\n\nChoose two adjacent slimes, and combine them into a new slime. The new slime has a size of x + y, where x and y are the sizes of the slimes before combining them. Here, a cost of x + y is incurred. The positional relationship of the slimes does not change while combining slimes.\n\nFind the minimum possible total cost incurred.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 400\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the minimum possible total cost incurred.\n\nSample Input 1\n\n4\n10 20 30 40\n\nSample Output 1\n\n190\n\nTaro should do as follows (slimes being combined are shown in bold):\n\n(10, 20, 30, 40) → (30, 30, 40)\n\n(30, 30, 40) → (60, 40)\n\n(60, 40) → (100)\n\nSample Input 2\n\n5\n10 10 10 10 10\n\nSample Output 2\n\n120\n\nTaro should do, for example, as follows:\n\n(10, 10, 10, 10, 10) → (20, 10, 10, 10)\n\n(20, 10, 10, 10) → (20, 20, 10)\n\n(20, 20, 10) → (20, 30)\n\n(20, 30) → (50)\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n5000000000\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 4\n\n6\n7 6 8 6 1 1\n\nSample Output 4\n\n68\n\nTaro should do, for example, as follows:\n\n(7, 6, 8, 6, 1, 1) → (7, 6, 8, 6, 2)\n\n(7, 6, 8, 6, 2) → (7, 6, 8, 8)\n\n(7, 6, 8, 8) → (13, 8, 8)\n\n(13, 8, 8) → (13, 16)\n\n(13, 16) → (29)", "sample_input": "4\n10 20 30 40\n"}, "reference_outputs": ["190\n"], "source_document_id": "p03173", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N slimes lining up in a row.\nInitially, the i-th slime from the left has a size of a_i.\n\nTaro is trying to combine all the slimes into a larger slime.\nHe will perform the following operation repeatedly until there is only one slime:\n\nChoose two adjacent slimes, and combine them into a new slime. The new slime has a size of x + y, where x and y are the sizes of the slimes before combining them. Here, a cost of x + y is incurred. The positional relationship of the slimes does not change while combining slimes.\n\nFind the minimum possible total cost incurred.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 400\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the minimum possible total cost incurred.\n\nSample Input 1\n\n4\n10 20 30 40\n\nSample Output 1\n\n190\n\nTaro should do as follows (slimes being combined are shown in bold):\n\n(10, 20, 30, 40) → (30, 30, 40)\n\n(30, 30, 40) → (60, 40)\n\n(60, 40) → (100)\n\nSample Input 2\n\n5\n10 10 10 10 10\n\nSample Output 2\n\n120\n\nTaro should do, for example, as follows:\n\n(10, 10, 10, 10, 10) → (20, 10, 10, 10)\n\n(20, 10, 10, 10) → (20, 20, 10)\n\n(20, 20, 10) → (20, 30)\n\n(20, 30) → (50)\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n5000000000\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 4\n\n6\n7 6 8 6 1 1\n\nSample Output 4\n\n68\n\nTaro should do, for example, as follows:\n\n(7, 6, 8, 6, 1, 1) → (7, 6, 8, 6, 2)\n\n(7, 6, 8, 6, 2) → (7, 6, 8, 8)\n\n(7, 6, 8, 8) → (13, 8, 8)\n\n(13, 8, 8) → (13, 16)\n\n(13, 16) → (29)", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4540, "cpu_time_ms": 2108, "memory_kb": 24020}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s604214787", "group_id": "codeNet:p03174", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.util.stream.IntStream;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.BufferedOutputStream;\nimport java.io.UncheckedIOException;\nimport java.util.stream.Stream;\nimport java.nio.charset.Charset;\nimport java.util.StringTokenizer;\nimport java.io.Writer;\nimport java.io.OutputStreamWriter;\nimport java.io.BufferedReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author mikit\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n LightScanner in = new LightScanner(inputStream);\n LightWriter out = new LightWriter(outputStream);\n OMatching solver = new OMatching();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class OMatching {\n private static final int MOD = (int) 1e9 + 7;\n\n public void solve(int testNumber, LightScanner in, LightWriter out) {\n int n = in.ints(), all = 1 << n;\n int[][] a = in.ints(n, n);\n\n long[] dp = new long[all];\n dp[0] = 1;\n for (int j = 0; j < all - 1; j++) {\n int i = Integer.bitCount(j);\n for (int k = 0; k < n; k++) {\n int b = 1 << k;\n if (a[i][k] == 0 || (b & j) != 0) continue;\n dp[b | j] += dp[j];\n if (dp[b | j] >= MOD) dp[b | j] -= MOD;\n }\n }\n out.ans(dp[all - 1]).ln();\n }\n\n }\n\n static class LightScanner implements AutoCloseable {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n\n public LightScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n }\n\n public String string() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new UncheckedIOException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int ints() {\n return Integer.parseInt(string());\n }\n\n public int[] ints(int length) {\n return IntStream.range(0, length).map(x -> ints()).toArray();\n }\n\n public int[][] ints(int height, int width) {\n return IntStream.range(0, height).mapToObj(x -> ints(width)).toArray(int[][]::new);\n }\n\n public void close() {\n try {\n this.reader.close();\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n }\n\n }\n\n static class LightWriter implements AutoCloseable {\n private final Writer out;\n private boolean autoflush = false;\n private boolean breaked = true;\n\n public LightWriter(Writer out) {\n this.out = out;\n }\n\n public LightWriter(OutputStream out) {\n this(new OutputStreamWriter(new BufferedOutputStream(out), Charset.defaultCharset()));\n }\n\n public LightWriter print(char c) {\n try {\n out.write(c);\n breaked = false;\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n return this;\n }\n\n public LightWriter print(String s) {\n try {\n out.write(s, 0, s.length());\n breaked = false;\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n return this;\n }\n\n public LightWriter ans(String s) {\n if (!breaked) {\n print(' ');\n }\n return print(s);\n }\n\n public LightWriter ans(long l) {\n return ans(Long.toString(l));\n }\n\n public LightWriter ln() {\n print(System.lineSeparator());\n breaked = true;\n if (autoflush) {\n try {\n out.flush();\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n }\n return this;\n }\n\n public void close() {\n try {\n out.close();\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1596061000, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p03174.html", "problem_id": "p03174", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03174/input.txt", "sample_output_relpath": "derived/input_output/data/p03174/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03174/Java/s604214787.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s604214787", "user_id": "u183509493"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.util.stream.IntStream;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.BufferedOutputStream;\nimport java.io.UncheckedIOException;\nimport java.util.stream.Stream;\nimport java.nio.charset.Charset;\nimport java.util.StringTokenizer;\nimport java.io.Writer;\nimport java.io.OutputStreamWriter;\nimport java.io.BufferedReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author mikit\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n LightScanner in = new LightScanner(inputStream);\n LightWriter out = new LightWriter(outputStream);\n OMatching solver = new OMatching();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class OMatching {\n private static final int MOD = (int) 1e9 + 7;\n\n public void solve(int testNumber, LightScanner in, LightWriter out) {\n int n = in.ints(), all = 1 << n;\n int[][] a = in.ints(n, n);\n\n long[] dp = new long[all];\n dp[0] = 1;\n for (int j = 0; j < all - 1; j++) {\n int i = Integer.bitCount(j);\n for (int k = 0; k < n; k++) {\n int b = 1 << k;\n if (a[i][k] == 0 || (b & j) != 0) continue;\n dp[b | j] += dp[j];\n if (dp[b | j] >= MOD) dp[b | j] -= MOD;\n }\n }\n out.ans(dp[all - 1]).ln();\n }\n\n }\n\n static class LightScanner implements AutoCloseable {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n\n public LightScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n }\n\n public String string() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new UncheckedIOException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int ints() {\n return Integer.parseInt(string());\n }\n\n public int[] ints(int length) {\n return IntStream.range(0, length).map(x -> ints()).toArray();\n }\n\n public int[][] ints(int height, int width) {\n return IntStream.range(0, height).mapToObj(x -> ints(width)).toArray(int[][]::new);\n }\n\n public void close() {\n try {\n this.reader.close();\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n }\n\n }\n\n static class LightWriter implements AutoCloseable {\n private final Writer out;\n private boolean autoflush = false;\n private boolean breaked = true;\n\n public LightWriter(Writer out) {\n this.out = out;\n }\n\n public LightWriter(OutputStream out) {\n this(new OutputStreamWriter(new BufferedOutputStream(out), Charset.defaultCharset()));\n }\n\n public LightWriter print(char c) {\n try {\n out.write(c);\n breaked = false;\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n return this;\n }\n\n public LightWriter print(String s) {\n try {\n out.write(s, 0, s.length());\n breaked = false;\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n return this;\n }\n\n public LightWriter ans(String s) {\n if (!breaked) {\n print(' ');\n }\n return print(s);\n }\n\n public LightWriter ans(long l) {\n return ans(Long.toString(l));\n }\n\n public LightWriter ln() {\n print(System.lineSeparator());\n breaked = true;\n if (autoflush) {\n try {\n out.flush();\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n }\n return this;\n }\n\n public void close() {\n try {\n out.close();\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n }\n\n }\n}\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N men and N women, both numbered 1, 2, \\ldots, N.\n\nFor each i, j (1 \\leq i, j \\leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}.\nIf a_{i, j} = 1, Man i and Woman j are compatible; if a_{i, j} = 0, they are not.\n\nTaro is trying to make N pairs, each consisting of a man and a woman who are compatible.\nHere, each man and each woman must belong to exactly one pair.\n\nFind the number of ways in which Taro can make N pairs, modulo 10^9 + 7.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 21\n\na_{i, j} is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_{1, 1} \\ldots a_{1, N}\n:\na_{N, 1} \\ldots a_{N, N}\n\nOutput\n\nPrint the number of ways in which Taro can make N pairs, modulo 10^9 + 7.\n\nSample Input 1\n\n3\n0 1 1\n1 0 1\n1 1 1\n\nSample Output 1\n\n3\n\nThere are three ways to make pairs, as follows ((i, j) denotes a pair of Man i and Woman j):\n\n(1, 2), (2, 1), (3, 3)\n\n(1, 2), (2, 3), (3, 1)\n\n(1, 3), (2, 1), (3, 2)\n\nSample Input 2\n\n4\n0 1 0 0\n0 0 0 1\n1 0 0 0\n0 0 1 0\n\nSample Output 2\n\n1\n\nThere is one way to make pairs, as follows:\n\n(1, 2), (2, 4), (3, 1), (4, 3)\n\nSample Input 3\n\n1\n0\n\nSample Output 3\n\n0\n\nSample Input 4\n\n21\n0 0 0 0 0 0 0 1 1 0 1 1 1 1 0 0 0 1 0 0 1\n1 1 1 0 0 1 0 0 0 1 0 0 0 0 1 1 1 0 1 1 0\n0 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 0 0 0 1 1\n0 1 1 0 1 1 0 1 0 1 0 0 1 0 0 0 0 0 1 1 0\n1 1 0 0 1 0 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0\n0 1 1 0 1 1 1 0 1 1 1 0 0 0 1 1 1 1 0 0 1\n0 1 0 0 0 1 0 1 0 0 0 1 1 1 0 0 1 1 0 1 0\n0 0 0 0 1 1 0 0 1 1 0 0 0 0 0 1 1 1 1 1 1\n0 0 1 0 0 1 0 0 1 0 1 1 0 0 1 0 1 0 1 1 1\n0 0 0 0 1 1 0 0 1 1 1 0 0 0 0 1 1 0 0 0 1\n0 1 1 0 1 1 0 0 1 1 0 0 0 1 1 1 1 0 1 1 0\n0 0 1 0 0 1 1 1 1 0 1 1 0 1 1 1 0 0 0 0 1\n0 1 1 0 0 1 1 1 1 0 0 0 1 0 1 1 0 1 0 1 1\n1 1 1 1 1 0 0 0 0 1 0 0 1 1 0 1 1 1 0 0 1\n0 0 0 1 1 0 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1\n1 0 1 1 0 1 0 1 0 0 1 0 0 1 1 0 1 0 1 1 0\n0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 1\n0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 0 1 1 0 1\n0 0 0 0 1 1 1 0 1 0 1 1 1 0 1 1 0 0 1 1 0\n1 1 0 1 1 0 0 1 1 0 1 1 0 1 1 1 1 1 0 1 0\n1 0 0 1 1 0 1 1 1 1 1 0 1 0 1 1 0 0 0 0 0\n\nSample Output 4\n\n102515160\n\nBe sure to print the number modulo 10^9 + 7.", "sample_input": "3\n0 1 1\n1 0 1\n1 1 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03174", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N men and N women, both numbered 1, 2, \\ldots, N.\n\nFor each i, j (1 \\leq i, j \\leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}.\nIf a_{i, j} = 1, Man i and Woman j are compatible; if a_{i, j} = 0, they are not.\n\nTaro is trying to make N pairs, each consisting of a man and a woman who are compatible.\nHere, each man and each woman must belong to exactly one pair.\n\nFind the number of ways in which Taro can make N pairs, modulo 10^9 + 7.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 21\n\na_{i, j} is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_{1, 1} \\ldots a_{1, N}\n:\na_{N, 1} \\ldots a_{N, N}\n\nOutput\n\nPrint the number of ways in which Taro can make N pairs, modulo 10^9 + 7.\n\nSample Input 1\n\n3\n0 1 1\n1 0 1\n1 1 1\n\nSample Output 1\n\n3\n\nThere are three ways to make pairs, as follows ((i, j) denotes a pair of Man i and Woman j):\n\n(1, 2), (2, 1), (3, 3)\n\n(1, 2), (2, 3), (3, 1)\n\n(1, 3), (2, 1), (3, 2)\n\nSample Input 2\n\n4\n0 1 0 0\n0 0 0 1\n1 0 0 0\n0 0 1 0\n\nSample Output 2\n\n1\n\nThere is one way to make pairs, as follows:\n\n(1, 2), (2, 4), (3, 1), (4, 3)\n\nSample Input 3\n\n1\n0\n\nSample Output 3\n\n0\n\nSample Input 4\n\n21\n0 0 0 0 0 0 0 1 1 0 1 1 1 1 0 0 0 1 0 0 1\n1 1 1 0 0 1 0 0 0 1 0 0 0 0 1 1 1 0 1 1 0\n0 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 0 0 0 1 1\n0 1 1 0 1 1 0 1 0 1 0 0 1 0 0 0 0 0 1 1 0\n1 1 0 0 1 0 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0\n0 1 1 0 1 1 1 0 1 1 1 0 0 0 1 1 1 1 0 0 1\n0 1 0 0 0 1 0 1 0 0 0 1 1 1 0 0 1 1 0 1 0\n0 0 0 0 1 1 0 0 1 1 0 0 0 0 0 1 1 1 1 1 1\n0 0 1 0 0 1 0 0 1 0 1 1 0 0 1 0 1 0 1 1 1\n0 0 0 0 1 1 0 0 1 1 1 0 0 0 0 1 1 0 0 0 1\n0 1 1 0 1 1 0 0 1 1 0 0 0 1 1 1 1 0 1 1 0\n0 0 1 0 0 1 1 1 1 0 1 1 0 1 1 1 0 0 0 0 1\n0 1 1 0 0 1 1 1 1 0 0 0 1 0 1 1 0 1 0 1 1\n1 1 1 1 1 0 0 0 0 1 0 0 1 1 0 1 1 1 0 0 1\n0 0 0 1 1 0 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1\n1 0 1 1 0 1 0 1 0 0 1 0 0 1 1 0 1 0 1 1 0\n0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 1\n0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 0 1 1 0 1\n0 0 0 0 1 1 1 0 1 0 1 1 1 0 1 1 0 0 1 1 0\n1 1 0 1 1 0 0 1 1 0 1 1 0 1 1 1 1 1 0 1 0\n1 0 0 1 1 0 1 1 1 1 1 0 1 0 1 1 0 0 0 0 0\n\nSample Output 4\n\n102515160\n\nBe sure to print the number modulo 10^9 + 7.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4709, "cpu_time_ms": 383, "memory_kb": 51848}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s733508192", "group_id": "codeNet:p03176", "input_text": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.NoSuchElementException;\nimport java.util.stream.IntStream;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tnew Main();\n\t}\n\n\tpublic Main() {\n\t\tFastScanner sc = new FastScanner();\n\t\tint N = sc.nextInt(), h[] = sc.nextInt(N), a[] = sc.nextInt(N);\n\t\tLazySegmentTree segment = new LazySegmentTree(IntStream.range(0, N).mapToObj(i -> new Long(0)).toArray(Long[]::new), new Maximum(), new Maximum(), new Maximum());\n\t\tfor (int i = 0;i < N;++ i) segment.update(a[i] + segment.get(0, h[i]), h[i] - 1);\n\t\tSystem.out.println(segment.get(0, N));\n\t}\n\n\tpublic class Maximum> implements Monoid, Commutative, LazySegmentInterface{\n\n\t\t@Override\n\t\tpublic T operate(T left, T right) {\n\t\t\tif (left == null) return right;\n\t\t\telse if (right == null) return left;\n\t\t\treturn left.compareTo(right) > 0 ? left : right;\n\t\t}\n\n\t\t@Override\n\t\tpublic T unit() {\n\t\t\treturn null;\n\t\t}\n\n\t\t@Override\n\t\tpublic T function(T element, T reaction, int N) {\n\t\t\treturn operate(element, reaction);\n\t\t}\n\n\t}\n\n\tpublic interface Commutative {\n\t}\n\n\tpublic interface Monoid extends Associative, Unit {\n\t}\n\n\tpublic interface Unit {\n\t\tpublic T unit();\n\t}\n\n\tpublic interface Associative {\n\t\tpublic T operate(T left, T right);\n\t}\n\n\tpublic interface LazySegmentInterface {\n\t\tpublic T function(T element, E reaction, int N);\n\t}\n\n\tpublic class LazySegmentTree {\n\t\tprivate Associative semigroup;\n\t\tprivate Associative lazygroup;\n\t\tprivate LazySegmentInterface operate;\n\t\tprivate T dat[];\n\t\tprivate E lazy[];\n\t\tprivate int size;\n\n\t\tpublic LazySegmentTree(T[] dat, Associative semigroup, Associative lazygroup, LazySegmentInterface operate) {\n\t\t\tthis.semigroup = semigroup;\n\t\t\tthis.lazygroup = lazygroup;\n\t\t\tthis.operate = operate;\n\t\t\tbuild(dat);\n\t\t}\n\n\t\t@SuppressWarnings(\"unchecked\")\n\t\tprivate void build(T dat[]) {\n\t\t\tsize = dat.length;\n\t\t\tthis.dat = (T[]) new Object[Math.max(2, Integer.highestOneBit(dat.length - 1) << 2)]; // 要素数を超える最小の2冪*2\n\t\t\tthis.lazy = (E[]) new Object[this.dat.length]; // その遅延評価に使う関数\n\t\t\tSystem.arraycopy(dat, 0, this.dat, this.dat.length >> 1, dat.length); // 最下段を埋める\n\t\t\tfor (int i = this.dat.length / 2 - 1;i > 0; -- i) this.dat[i] = operate(this.dat[i << 1], this.dat[i * 2 + 1]); // 最下段以外すべて、下から埋める\n\t\t}\n\t\t\n\t\tpublic void debug() {\n\t\t\tSystem.out.print(\"data : \");\n\t\t\tfor (T i : dat) System.out.print(i + \" \");\n\t\t\tSystem.out.println();\n\t\t\tSystem.out.print(\"lazy : \");\n\t\t\tfor (E i : lazy) System.out.print(i + \" \");\n\t\t\tSystem.out.println();\n\t\t}\n\n\t\tprivate void lazy(int n, int length) {\n\t\t\tlazy[n << 1] = lazygroup.operate(lazy[n], lazy[n << 1]);\n\t\t\tlazy[n * 2 + 1] = lazygroup.operate(lazy[n], lazy[n * 2 + 1]);\n\t\t\tgetLazy(n, length);\n\t\t}\n\n\t\tprivate T operate(T left, T right) {\n\t\t\tif (right == null) return left; // 右がnullの可能性の方がはるかに高いので\n\t\t\telse if (left == null) return right;\n\t\t\telse return semigroup.operate(left, right);\n\t\t}\n\n\t\tprivate void lazyUpdate(E lazy, int index, int length) {\n\t\t\tthis.lazy[index] = lazyoperate(this.lazy[index], lazy);\n\t\t\tdat[index] = operate.function(dat[index], this.lazy[index], length);\n\t\t}\n\n\t\tprivate E lazyoperate(E left, E right) {\n\t\t\tif (right == null) return left; // 右がnullの可能性の方がはるかに高いので\n\t\t\telse if (left == null) return right;\n\t\t\telse return lazygroup.operate(left, right);\n\t\t}\n\n\t\tprivate T getLazy(int index, int length) {\n\t\t\tdat[index] = operate.function(dat[index], lazy[index], length);\n\t\t\tlazy[index] = null;\n\t\t\treturn dat[index];\n\t\t}\n\n\t\tpublic void update(E dat, int index) {\n\t\t\tupdate(dat, index, index + 1);\n\t\t}\n\n\t\tpublic void update(E dat, int left, int right) {\n\t\t\tif (left >= right || right > size) throw new IllegalArgumentException(\"[\" + left + \", \" + right + \") is undefined.\");\n\t\t\tint mid = left ^ right, m = 1, l, r, length = this.dat.length >> 1;\n\t\t\tfor (;(mid & length) == 0;m <<= 1, length >>= 1) {\n\t\t\t\tif ((left & length) != 0) {\n\t\t\t\t\tleft &= ~length;\n\t\t\t\t\tright &= ~length;\n\t\t\t\t\t++ m;\n\t\t\t\t}\n\t\t\t\tlazy(m, length); // 境界を見つけるまで遅延評価\n\t\t\t}\n\t\t\tl = m;\n\t\t\tint lengthL = length;\n\t\t\twhile(left != 0) { // 左側評価開始\n\t\t\t\tlazy(l, lengthL);\n\t\t\t\tlengthL >>= 1;\n\t\t\t\tl <<= 1;\n\t\t\t\tif ((left & lengthL) == 0) { // 1個右は含まれる区間なので\n\t\t\t\t\tlazyUpdate(dat, l + 1, lengthL);\n\t\t\t\t} else {\n\t\t\t\t\tleft &= ~lengthL;\n\t\t\t\t\t++ l;\n\t\t\t\t}\n\t\t\t}\n\t\t\tlazyUpdate(dat, l, lengthL);\n\t\t\tr = m + 1;\n\t\t\tint lengthR = length;\n\t\t\tright &= ~lengthR;\n\t\t\twhile(right != 0) { // 右側評価開始\n\t\t\t\tlazy(r, lengthR);\n\t\t\t\tlengthR >>= 1;\n\t\t\t\tr <<= 1;\n\t\t\t\tif ((right & lengthR) != 0) { // 1個左は含まれる区間なので\n\t\t\t\t\tright &= ~lengthR;\n\t\t\t\t\tlazyUpdate(dat, r, lengthR);\n\t\t\t\t\t++ r;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// これで全ての遅延評価が終わったので、次は戻していく操作\n\t\t\twhile(l > m) {\n\t\t\t\tl >>= 1;\n\t\t\t\tlengthL <<= 1;\n\t\t\t\tthis.dat[l] = operate(this.dat[l << 1], this.dat[l * 2 + 1]);\n\t\t\t}\n\t\t\twhile(r > m + 1) {\n\t\t\t\tr >>= 1;\n\t\t\t\tlengthR <<= 1;\n\t\t\t\tlazy(r, lengthR);\n\t\t\t\tthis.dat[r] = operate(this.dat[r << 1], this.dat[r * 2 + 1]);\n\t\t\t}\n\t\t\twhile(m > 1) {\n\t\t\t\tm >>= 1;\n\t\t\t\tlength <<= 1;\n\t\t\t\tlazy(m, length);\n\t\t\t\tthis.dat[m] = operate(this.dat[m << 1], this.dat[m * 2 + 1]);\n\t\t\t}\n\t\t}\n\n\t\tpublic T get(int index) {\n\t\t\treturn get(index, index + 1);\n\t\t}\n\n\t\tpublic T get(int left, int right) {\n\t\t\tif (left >= right || right > size) throw new IllegalArgumentException(\"[\" + left + \", \" + right + \") is undefined.\");\n\t\t\tint mid = left ^ right, i = 1, j, length = this.dat.length >> 1;\n\t\t\tT ret = null;\n\t\t\tfor (;(mid & length) == 0;i <<= 1, length >>= 1) { // 境界を見つけるまで遅延評価\n\t\t\t\tif ((left & length) != 0) {\n\t\t\t\t\tleft &= ~length;\n\t\t\t\t\tright &= ~length;\n\t\t\t\t\t++ i;\n\t\t\t\t}\n\t\t\t\tlazy(i, length);\n\t\t\t}\n\t\t\tj = i + 1;\n\t\t\tint lengthL = length;\n\t\t\twhile(left != 0) { // 左側評価開始\n\t\t\t\tlazy(i, lengthL);\n\t\t\t\tlengthL >>= 1;\n\t\t\t\ti <<= 1;\n\t\t\t\tif ((left & lengthL) == 0) { // 1個右は含まれる区間なので\n\t\t\t\t\tret = operate(getLazy(i + 1, lengthL), ret);\n\t\t\t\t} else {\n\t\t\t\t\tleft &= ~lengthL;\n\t\t\t\t\t++ i;\n\t\t\t\t}\n\t\t\t}\n\t\t\tret = operate(getLazy(i, lengthL), ret);\n\t\t\tint lengthR = length;\n\t\t\tright &= ~lengthR;\n\t\t\twhile(right != 0) { // 右側評価開始\n\t\t\t\tlazy(j, lengthR);\n\t\t\t\tlengthR >>= 1;\n\t\t\t\tj <<= 1;\n\t\t\t\tif ((right & lengthR) != 0) { // 1個左は含まれる区間なので\n\t\t\t\t\tright &= ~lengthR;\n\t\t\t\t\tret = operate(ret, getLazy(j++, lengthR));\n\t\t\t\t\t++ j;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\t}\n\n\n\n\tpublic class FastScanner {\n\t\tprivate final InputStream in = System.in;\n\t\tprivate final byte[] buffer = new byte[1024];\n\t\tprivate int ptr = 0;\n\t\tprivate int buflen = 0;\n\n\t\tprivate boolean hasNextByte() {\n\t\t\tif (ptr < buflen) {\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\tptr = 0;\n\t\t\t\ttry {\n\t\t\t\t\tbuflen = in.read(buffer);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t\tif (buflen <= 0) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tprivate int readByte() {\n\t\t\tif (hasNextByte()) return buffer[ptr++];\n\t\t\telse return -1;\n\t\t}\n\n\t\tprivate boolean isPrintableChar(int c) {\n\t\t\treturn 33 <= c && c <= 126;\n\t\t}\n\n\t\tpublic boolean hasNext() {\n\t\t\twhile (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n\t\t\treturn hasNextByte();\n\t\t}\n\n\t\tpublic String next() {\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tint b = readByte();\n\t\t\twhile (isPrintableChar(b)) {\n\t\t\t\tsb.appendCodePoint(b);\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t\treturn sb.toString();\n\t\t}\n\n\t\tpublic long nextLong() {\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tlong n = 0;\n\t\t\tboolean minus = false;\n\t\t\tint b = readByte();\n\t\t\tif (b == '-') {\n\t\t\t\tminus = true;\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t\tif (b < '0' || '9' < b) throw new NumberFormatException();\n\t\t\twhile (true) {\n\t\t\t\tif ('0' <= b && b <= '9') {\n\t\t\t\t\tn *= 10;\n\t\t\t\t\tn += b - '0';\n\t\t\t\t} else if (b == -1 || !isPrintableChar(b)) return minus ? -n : n;\n\t\t\t\telse throw new NumberFormatException();\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\tlong nl = nextLong();\n\t\t\tif (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n\t\t\treturn (int) nl;\n\t\t}\n\n\t\tpublic double nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tpublic int[] nextInt(int width) {\n\t\t\tint[] ret = new int[width];\n\t\t\tfor (int i = 0;i < width;++ i) ret[i] = nextInt();\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic long[] nextLong(int width) {\n\t\t\tlong[] ret = new long[width];\n\t\t\tfor (int i = 0;i < width;++ i) ret[i] = nextLong();\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic int[][] nextInt(int width, int height) {\n\t\t\tint[][] ret = new int[height][width];\n\t\t\tfor (int i = 0, j;i < height;++ i) for (j = 0;j < width;++ j) ret[j][i] = nextInt();\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic long[][] nextLong(int width, int height) {\n\t\t\tlong[][] ret = new long[height][width];\n\t\t\tfor (int i = 0, j;i < height;++ i) for (j = 0;j < width;++ j) ret[j][i] = nextLong();\n\t\t\treturn ret;\n\t\t}\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1551143784, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03176.html", "problem_id": "p03176", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03176/input.txt", "sample_output_relpath": "derived/input_output/data/p03176/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03176/Java/s733508192.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s733508192", "user_id": "u550314572"}, "prompt_components": {"gold_output": "60\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.NoSuchElementException;\nimport java.util.stream.IntStream;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tnew Main();\n\t}\n\n\tpublic Main() {\n\t\tFastScanner sc = new FastScanner();\n\t\tint N = sc.nextInt(), h[] = sc.nextInt(N), a[] = sc.nextInt(N);\n\t\tLazySegmentTree segment = new LazySegmentTree(IntStream.range(0, N).mapToObj(i -> new Long(0)).toArray(Long[]::new), new Maximum(), new Maximum(), new Maximum());\n\t\tfor (int i = 0;i < N;++ i) segment.update(a[i] + segment.get(0, h[i]), h[i] - 1);\n\t\tSystem.out.println(segment.get(0, N));\n\t}\n\n\tpublic class Maximum> implements Monoid, Commutative, LazySegmentInterface{\n\n\t\t@Override\n\t\tpublic T operate(T left, T right) {\n\t\t\tif (left == null) return right;\n\t\t\telse if (right == null) return left;\n\t\t\treturn left.compareTo(right) > 0 ? left : right;\n\t\t}\n\n\t\t@Override\n\t\tpublic T unit() {\n\t\t\treturn null;\n\t\t}\n\n\t\t@Override\n\t\tpublic T function(T element, T reaction, int N) {\n\t\t\treturn operate(element, reaction);\n\t\t}\n\n\t}\n\n\tpublic interface Commutative {\n\t}\n\n\tpublic interface Monoid extends Associative, Unit {\n\t}\n\n\tpublic interface Unit {\n\t\tpublic T unit();\n\t}\n\n\tpublic interface Associative {\n\t\tpublic T operate(T left, T right);\n\t}\n\n\tpublic interface LazySegmentInterface {\n\t\tpublic T function(T element, E reaction, int N);\n\t}\n\n\tpublic class LazySegmentTree {\n\t\tprivate Associative semigroup;\n\t\tprivate Associative lazygroup;\n\t\tprivate LazySegmentInterface operate;\n\t\tprivate T dat[];\n\t\tprivate E lazy[];\n\t\tprivate int size;\n\n\t\tpublic LazySegmentTree(T[] dat, Associative semigroup, Associative lazygroup, LazySegmentInterface operate) {\n\t\t\tthis.semigroup = semigroup;\n\t\t\tthis.lazygroup = lazygroup;\n\t\t\tthis.operate = operate;\n\t\t\tbuild(dat);\n\t\t}\n\n\t\t@SuppressWarnings(\"unchecked\")\n\t\tprivate void build(T dat[]) {\n\t\t\tsize = dat.length;\n\t\t\tthis.dat = (T[]) new Object[Math.max(2, Integer.highestOneBit(dat.length - 1) << 2)]; // 要素数を超える最小の2冪*2\n\t\t\tthis.lazy = (E[]) new Object[this.dat.length]; // その遅延評価に使う関数\n\t\t\tSystem.arraycopy(dat, 0, this.dat, this.dat.length >> 1, dat.length); // 最下段を埋める\n\t\t\tfor (int i = this.dat.length / 2 - 1;i > 0; -- i) this.dat[i] = operate(this.dat[i << 1], this.dat[i * 2 + 1]); // 最下段以外すべて、下から埋める\n\t\t}\n\t\t\n\t\tpublic void debug() {\n\t\t\tSystem.out.print(\"data : \");\n\t\t\tfor (T i : dat) System.out.print(i + \" \");\n\t\t\tSystem.out.println();\n\t\t\tSystem.out.print(\"lazy : \");\n\t\t\tfor (E i : lazy) System.out.print(i + \" \");\n\t\t\tSystem.out.println();\n\t\t}\n\n\t\tprivate void lazy(int n, int length) {\n\t\t\tlazy[n << 1] = lazygroup.operate(lazy[n], lazy[n << 1]);\n\t\t\tlazy[n * 2 + 1] = lazygroup.operate(lazy[n], lazy[n * 2 + 1]);\n\t\t\tgetLazy(n, length);\n\t\t}\n\n\t\tprivate T operate(T left, T right) {\n\t\t\tif (right == null) return left; // 右がnullの可能性の方がはるかに高いので\n\t\t\telse if (left == null) return right;\n\t\t\telse return semigroup.operate(left, right);\n\t\t}\n\n\t\tprivate void lazyUpdate(E lazy, int index, int length) {\n\t\t\tthis.lazy[index] = lazyoperate(this.lazy[index], lazy);\n\t\t\tdat[index] = operate.function(dat[index], this.lazy[index], length);\n\t\t}\n\n\t\tprivate E lazyoperate(E left, E right) {\n\t\t\tif (right == null) return left; // 右がnullの可能性の方がはるかに高いので\n\t\t\telse if (left == null) return right;\n\t\t\telse return lazygroup.operate(left, right);\n\t\t}\n\n\t\tprivate T getLazy(int index, int length) {\n\t\t\tdat[index] = operate.function(dat[index], lazy[index], length);\n\t\t\tlazy[index] = null;\n\t\t\treturn dat[index];\n\t\t}\n\n\t\tpublic void update(E dat, int index) {\n\t\t\tupdate(dat, index, index + 1);\n\t\t}\n\n\t\tpublic void update(E dat, int left, int right) {\n\t\t\tif (left >= right || right > size) throw new IllegalArgumentException(\"[\" + left + \", \" + right + \") is undefined.\");\n\t\t\tint mid = left ^ right, m = 1, l, r, length = this.dat.length >> 1;\n\t\t\tfor (;(mid & length) == 0;m <<= 1, length >>= 1) {\n\t\t\t\tif ((left & length) != 0) {\n\t\t\t\t\tleft &= ~length;\n\t\t\t\t\tright &= ~length;\n\t\t\t\t\t++ m;\n\t\t\t\t}\n\t\t\t\tlazy(m, length); // 境界を見つけるまで遅延評価\n\t\t\t}\n\t\t\tl = m;\n\t\t\tint lengthL = length;\n\t\t\twhile(left != 0) { // 左側評価開始\n\t\t\t\tlazy(l, lengthL);\n\t\t\t\tlengthL >>= 1;\n\t\t\t\tl <<= 1;\n\t\t\t\tif ((left & lengthL) == 0) { // 1個右は含まれる区間なので\n\t\t\t\t\tlazyUpdate(dat, l + 1, lengthL);\n\t\t\t\t} else {\n\t\t\t\t\tleft &= ~lengthL;\n\t\t\t\t\t++ l;\n\t\t\t\t}\n\t\t\t}\n\t\t\tlazyUpdate(dat, l, lengthL);\n\t\t\tr = m + 1;\n\t\t\tint lengthR = length;\n\t\t\tright &= ~lengthR;\n\t\t\twhile(right != 0) { // 右側評価開始\n\t\t\t\tlazy(r, lengthR);\n\t\t\t\tlengthR >>= 1;\n\t\t\t\tr <<= 1;\n\t\t\t\tif ((right & lengthR) != 0) { // 1個左は含まれる区間なので\n\t\t\t\t\tright &= ~lengthR;\n\t\t\t\t\tlazyUpdate(dat, r, lengthR);\n\t\t\t\t\t++ r;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// これで全ての遅延評価が終わったので、次は戻していく操作\n\t\t\twhile(l > m) {\n\t\t\t\tl >>= 1;\n\t\t\t\tlengthL <<= 1;\n\t\t\t\tthis.dat[l] = operate(this.dat[l << 1], this.dat[l * 2 + 1]);\n\t\t\t}\n\t\t\twhile(r > m + 1) {\n\t\t\t\tr >>= 1;\n\t\t\t\tlengthR <<= 1;\n\t\t\t\tlazy(r, lengthR);\n\t\t\t\tthis.dat[r] = operate(this.dat[r << 1], this.dat[r * 2 + 1]);\n\t\t\t}\n\t\t\twhile(m > 1) {\n\t\t\t\tm >>= 1;\n\t\t\t\tlength <<= 1;\n\t\t\t\tlazy(m, length);\n\t\t\t\tthis.dat[m] = operate(this.dat[m << 1], this.dat[m * 2 + 1]);\n\t\t\t}\n\t\t}\n\n\t\tpublic T get(int index) {\n\t\t\treturn get(index, index + 1);\n\t\t}\n\n\t\tpublic T get(int left, int right) {\n\t\t\tif (left >= right || right > size) throw new IllegalArgumentException(\"[\" + left + \", \" + right + \") is undefined.\");\n\t\t\tint mid = left ^ right, i = 1, j, length = this.dat.length >> 1;\n\t\t\tT ret = null;\n\t\t\tfor (;(mid & length) == 0;i <<= 1, length >>= 1) { // 境界を見つけるまで遅延評価\n\t\t\t\tif ((left & length) != 0) {\n\t\t\t\t\tleft &= ~length;\n\t\t\t\t\tright &= ~length;\n\t\t\t\t\t++ i;\n\t\t\t\t}\n\t\t\t\tlazy(i, length);\n\t\t\t}\n\t\t\tj = i + 1;\n\t\t\tint lengthL = length;\n\t\t\twhile(left != 0) { // 左側評価開始\n\t\t\t\tlazy(i, lengthL);\n\t\t\t\tlengthL >>= 1;\n\t\t\t\ti <<= 1;\n\t\t\t\tif ((left & lengthL) == 0) { // 1個右は含まれる区間なので\n\t\t\t\t\tret = operate(getLazy(i + 1, lengthL), ret);\n\t\t\t\t} else {\n\t\t\t\t\tleft &= ~lengthL;\n\t\t\t\t\t++ i;\n\t\t\t\t}\n\t\t\t}\n\t\t\tret = operate(getLazy(i, lengthL), ret);\n\t\t\tint lengthR = length;\n\t\t\tright &= ~lengthR;\n\t\t\twhile(right != 0) { // 右側評価開始\n\t\t\t\tlazy(j, lengthR);\n\t\t\t\tlengthR >>= 1;\n\t\t\t\tj <<= 1;\n\t\t\t\tif ((right & lengthR) != 0) { // 1個左は含まれる区間なので\n\t\t\t\t\tright &= ~lengthR;\n\t\t\t\t\tret = operate(ret, getLazy(j++, lengthR));\n\t\t\t\t\t++ j;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\t}\n\n\n\n\tpublic class FastScanner {\n\t\tprivate final InputStream in = System.in;\n\t\tprivate final byte[] buffer = new byte[1024];\n\t\tprivate int ptr = 0;\n\t\tprivate int buflen = 0;\n\n\t\tprivate boolean hasNextByte() {\n\t\t\tif (ptr < buflen) {\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\tptr = 0;\n\t\t\t\ttry {\n\t\t\t\t\tbuflen = in.read(buffer);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t\tif (buflen <= 0) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tprivate int readByte() {\n\t\t\tif (hasNextByte()) return buffer[ptr++];\n\t\t\telse return -1;\n\t\t}\n\n\t\tprivate boolean isPrintableChar(int c) {\n\t\t\treturn 33 <= c && c <= 126;\n\t\t}\n\n\t\tpublic boolean hasNext() {\n\t\t\twhile (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n\t\t\treturn hasNextByte();\n\t\t}\n\n\t\tpublic String next() {\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tint b = readByte();\n\t\t\twhile (isPrintableChar(b)) {\n\t\t\t\tsb.appendCodePoint(b);\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t\treturn sb.toString();\n\t\t}\n\n\t\tpublic long nextLong() {\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tlong n = 0;\n\t\t\tboolean minus = false;\n\t\t\tint b = readByte();\n\t\t\tif (b == '-') {\n\t\t\t\tminus = true;\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t\tif (b < '0' || '9' < b) throw new NumberFormatException();\n\t\t\twhile (true) {\n\t\t\t\tif ('0' <= b && b <= '9') {\n\t\t\t\t\tn *= 10;\n\t\t\t\t\tn += b - '0';\n\t\t\t\t} else if (b == -1 || !isPrintableChar(b)) return minus ? -n : n;\n\t\t\t\telse throw new NumberFormatException();\n\t\t\t\tb = readByte();\n\t\t\t}\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\tlong nl = nextLong();\n\t\t\tif (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n\t\t\treturn (int) nl;\n\t\t}\n\n\t\tpublic double nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tpublic int[] nextInt(int width) {\n\t\t\tint[] ret = new int[width];\n\t\t\tfor (int i = 0;i < width;++ i) ret[i] = nextInt();\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic long[] nextLong(int width) {\n\t\t\tlong[] ret = new long[width];\n\t\t\tfor (int i = 0;i < width;++ i) ret[i] = nextLong();\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic int[][] nextInt(int width, int height) {\n\t\t\tint[][] ret = new int[height][width];\n\t\t\tfor (int i = 0, j;i < height;++ i) for (j = 0;j < width;++ j) ret[j][i] = nextInt();\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic long[][] nextLong(int width, int height) {\n\t\t\tlong[][] ret = new long[height][width];\n\t\t\tfor (int i = 0, j;i < height;++ i) for (j = 0;j < width;++ j) ret[j][i] = nextLong();\n\t\t\treturn ret;\n\t\t}\n\t}\n\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N flowers arranged in a row.\nFor each i (1 \\leq i \\leq N), the height and the beauty of the i-th flower from the left is h_i and a_i, respectively.\nHere, h_1, h_2, \\ldots, h_N are all distinct.\n\nTaro is pulling out some flowers so that the following condition is met:\n\nThe heights of the remaining flowers are monotonically increasing from left to right.\n\nFind the maximum possible sum of the beauties of the remaining flowers.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 × 10^5\n\n1 \\leq h_i \\leq N\n\nh_1, h_2, \\ldots, h_N are all distinct.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 \\ldots h_N\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the maximum possible sum of the beauties of the remaining flowers.\n\nSample Input 1\n\n4\n3 1 4 2\n10 20 30 40\n\nSample Output 1\n\n60\n\nWe should keep the second and fourth flowers from the left.\nThen, the heights would be 1, 2 from left to right, which is monotonically increasing, and the sum of the beauties would be 20 + 40 = 60.\n\nSample Input 2\n\n1\n1\n10\n\nSample Output 2\n\n10\n\nThe condition is met already at the beginning.\n\nSample Input 3\n\n5\n1 2 3 4 5\n1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 3\n\n5000000000\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 4\n\n9\n4 2 5 8 3 6 1 7 9\n6 8 8 4 6 3 5 7 5\n\nSample Output 4\n\n31\n\nWe should keep the second, third, sixth, eighth and ninth flowers from the left.", "sample_input": "4\n3 1 4 2\n10 20 30 40\n"}, "reference_outputs": ["60\n"], "source_document_id": "p03176", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N flowers arranged in a row.\nFor each i (1 \\leq i \\leq N), the height and the beauty of the i-th flower from the left is h_i and a_i, respectively.\nHere, h_1, h_2, \\ldots, h_N are all distinct.\n\nTaro is pulling out some flowers so that the following condition is met:\n\nThe heights of the remaining flowers are monotonically increasing from left to right.\n\nFind the maximum possible sum of the beauties of the remaining flowers.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 × 10^5\n\n1 \\leq h_i \\leq N\n\nh_1, h_2, \\ldots, h_N are all distinct.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 \\ldots h_N\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the maximum possible sum of the beauties of the remaining flowers.\n\nSample Input 1\n\n4\n3 1 4 2\n10 20 30 40\n\nSample Output 1\n\n60\n\nWe should keep the second and fourth flowers from the left.\nThen, the heights would be 1, 2 from left to right, which is monotonically increasing, and the sum of the beauties would be 20 + 40 = 60.\n\nSample Input 2\n\n1\n1\n10\n\nSample Output 2\n\n10\n\nThe condition is met already at the beginning.\n\nSample Input 3\n\n5\n1 2 3 4 5\n1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 3\n\n5000000000\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 4\n\n9\n4 2 5 8 3 6 1 7 9\n6 8 8 4 6 3 5 7 5\n\nSample Output 4\n\n31\n\nWe should keep the second, third, sixth, eighth and ninth flowers from the left.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 9088, "cpu_time_ms": 691, "memory_kb": 57132}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s828744161", "group_id": "codeNet:p03184", "input_text": "import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n\n long M = 1_000_000_007L;\n int H = scanner.nextInt();\n int W = scanner.nextInt();\n int N = scanner.nextInt() + 1;\n Wall[] w = new Wall[N + 1];\n w[0] = new Wall(1, 1);\n for (int i = 1; i <= N - 1; i++) {\n w[i] = new Wall(scanner.nextInt(), scanner.nextInt());\n }\n w[N] = new Wall(H, W);\n\n Arrays.sort(w, (w1, w2) -> {\n if (w1.r <= w2.r && w1.c <= w2.c) return -1;\n if (w1.r >= w2.r && w1.c >= w2.c) return 1;\n return 0;\n });\n\n long[] fact = new long[H + W + 1];\n long[] factinv = new long[H + W + 1];\n fact[0] = 1;\n for (int i = 0; i < H + W; i++) fact[i + 1] = fact[i] * (i + 1) % M;\n factinv[0] = 1;\n for (int i = 1; i <= H + W; i++) factinv[i] = factinv[i - 1] * inverse(i, M) % M;\n\n long[][] dp = new long[N + 1][N + 1];\n dp[0][0] = 1;\n for (int i = 1; i <= N; i++) {\n for (int j = 1; j <= i; j++) {\n for (int k = j - 1; k < i; k++) {\n int dr = w[i].r - w[k].r;\n int dc = w[i].c - w[k].c;\n dp[i][j] += dp[k][j - 1] * comb(fact, factinv, dr + dc, dr, M) % M;\n if (dp[i][j] >= M) dp[i][j] -= M;\n }\n }\n }\n\n long res = 0;\n for (int i = 0; i <= N; i++) {\n res += dp[N][i] * (i % 2 == 0 ? -1 : 1);\n if (res >= M) res -= M;\n if (res < 0) res += M;\n }\n System.out.println(res);\n }\n\n private static long comb(long[] fact, long[] factinv, int n, int k, long M) {\n if (k < 0) return 0;\n if (n < k) return 0;\n long res = fact[n] * factinv[n - k] % M;\n res *= factinv[k];\n res %= M;\n return res;\n }\n\n public static long inverse(long a, long mod) {\n return modpow(a, mod - 2, mod);\n }\n\n public static long modpow(long a, long n, long mod) {\n long res = 1;\n while (n > 0) {\n if (n % 2 == 1) res = (res * a) % mod;\n a = (a * a) % mod;\n n >>= 1;\n }\n return res % mod;\n }\n\n private static class Wall {\n public final int r;\n public final int c;\n\n private Wall(int r, int c) {\n this.r = r;\n this.c = c;\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1555213254, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03184.html", "problem_id": "p03184", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03184/input.txt", "sample_output_relpath": "derived/input_output/data/p03184/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03184/Java/s828744161.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s828744161", "user_id": "u189832798"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n\n long M = 1_000_000_007L;\n int H = scanner.nextInt();\n int W = scanner.nextInt();\n int N = scanner.nextInt() + 1;\n Wall[] w = new Wall[N + 1];\n w[0] = new Wall(1, 1);\n for (int i = 1; i <= N - 1; i++) {\n w[i] = new Wall(scanner.nextInt(), scanner.nextInt());\n }\n w[N] = new Wall(H, W);\n\n Arrays.sort(w, (w1, w2) -> {\n if (w1.r <= w2.r && w1.c <= w2.c) return -1;\n if (w1.r >= w2.r && w1.c >= w2.c) return 1;\n return 0;\n });\n\n long[] fact = new long[H + W + 1];\n long[] factinv = new long[H + W + 1];\n fact[0] = 1;\n for (int i = 0; i < H + W; i++) fact[i + 1] = fact[i] * (i + 1) % M;\n factinv[0] = 1;\n for (int i = 1; i <= H + W; i++) factinv[i] = factinv[i - 1] * inverse(i, M) % M;\n\n long[][] dp = new long[N + 1][N + 1];\n dp[0][0] = 1;\n for (int i = 1; i <= N; i++) {\n for (int j = 1; j <= i; j++) {\n for (int k = j - 1; k < i; k++) {\n int dr = w[i].r - w[k].r;\n int dc = w[i].c - w[k].c;\n dp[i][j] += dp[k][j - 1] * comb(fact, factinv, dr + dc, dr, M) % M;\n if (dp[i][j] >= M) dp[i][j] -= M;\n }\n }\n }\n\n long res = 0;\n for (int i = 0; i <= N; i++) {\n res += dp[N][i] * (i % 2 == 0 ? -1 : 1);\n if (res >= M) res -= M;\n if (res < 0) res += M;\n }\n System.out.println(res);\n }\n\n private static long comb(long[] fact, long[] factinv, int n, int k, long M) {\n if (k < 0) return 0;\n if (n < k) return 0;\n long res = fact[n] * factinv[n - k] % M;\n res *= factinv[k];\n res %= M;\n return res;\n }\n\n public static long inverse(long a, long mod) {\n return modpow(a, mod - 2, mod);\n }\n\n public static long modpow(long a, long n, long mod) {\n long res = 1;\n while (n > 0) {\n if (n % 2 == 1) res = (res * a) % mod;\n a = (a * a) % mod;\n n >>= 1;\n }\n return res % mod;\n }\n\n private static class Wall {\n public final int r;\n public final int c;\n\n private Wall(int r, int c) {\n this.r = r;\n this.c = c;\n }\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a grid with H horizontal rows and W vertical columns.\nLet (i, j) denote the square at the i-th row from the top and the j-th column from the left.\n\nIn the grid, N Squares (r_1, c_1), (r_2, c_2), \\ldots, (r_N, c_N) are wall squares, and the others are all empty squares.\nIt is guaranteed that Squares (1, 1) and (H, W) are empty squares.\n\nTaro will start from Square (1, 1) and reach (H, W) by repeatedly moving right or down to an adjacent empty square.\n\nFind the number of Taro's paths from Square (1, 1) to (H, W), modulo 10^9 + 7.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq H, W \\leq 10^5\n\n1 \\leq N \\leq 3000\n\n1 \\leq r_i \\leq H\n\n1 \\leq c_i \\leq W\n\nSquares (r_i, c_i) are all distinct.\n\nSquares (1, 1) and (H, W) are empty squares.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W N\nr_1 c_1\nr_2 c_2\n:\nr_N c_N\n\nOutput\n\nPrint the number of Taro's paths from Square (1, 1) to (H, W), modulo 10^9 + 7.\n\nSample Input 1\n\n3 4 2\n2 2\n1 4\n\nSample Output 1\n\n3\n\nThere are three paths as follows:\n\nSample Input 2\n\n5 2 2\n2 1\n4 2\n\nSample Output 2\n\n0\n\nThere may be no paths.\n\nSample Input 3\n\n5 5 4\n3 1\n3 5\n1 3\n5 3\n\nSample Output 3\n\n24\n\nSample Input 4\n\n100000 100000 1\n50000 50000\n\nSample Output 4\n\n123445622\n\nBe sure to print the count modulo 10^9 + 7.", "sample_input": "3 4 2\n2 2\n1 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03184", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a grid with H horizontal rows and W vertical columns.\nLet (i, j) denote the square at the i-th row from the top and the j-th column from the left.\n\nIn the grid, N Squares (r_1, c_1), (r_2, c_2), \\ldots, (r_N, c_N) are wall squares, and the others are all empty squares.\nIt is guaranteed that Squares (1, 1) and (H, W) are empty squares.\n\nTaro will start from Square (1, 1) and reach (H, W) by repeatedly moving right or down to an adjacent empty square.\n\nFind the number of Taro's paths from Square (1, 1) to (H, W), modulo 10^9 + 7.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq H, W \\leq 10^5\n\n1 \\leq N \\leq 3000\n\n1 \\leq r_i \\leq H\n\n1 \\leq c_i \\leq W\n\nSquares (r_i, c_i) are all distinct.\n\nSquares (1, 1) and (H, W) are empty squares.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W N\nr_1 c_1\nr_2 c_2\n:\nr_N c_N\n\nOutput\n\nPrint the number of Taro's paths from Square (1, 1) to (H, W), modulo 10^9 + 7.\n\nSample Input 1\n\n3 4 2\n2 2\n1 4\n\nSample Output 1\n\n3\n\nThere are three paths as follows:\n\nSample Input 2\n\n5 2 2\n2 1\n4 2\n\nSample Output 2\n\n0\n\nThere may be no paths.\n\nSample Input 3\n\n5 5 4\n3 1\n3 5\n1 3\n5 3\n\nSample Output 3\n\n24\n\nSample Input 4\n\n100000 100000 1\n50000 50000\n\nSample Output 4\n\n123445622\n\nBe sure to print the count modulo 10^9 + 7.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2205, "cpu_time_ms": 2110, "memory_kb": 122448}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s174595759", "group_id": "codeNet:p03186", "input_text": "import java.util.*;\nimport java.lang.*;\nimport java.math.*;\n\npublic class Main {\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n \n int a = sc.nextInt(); // bad\n int b = sc.nextInt(); //good\n int c = sc.nextInt(); //good\n if (a + b >= c) {\n System.out.println(b + c); // all ok\n } else {\n System.out.println(b + (b + a) + 1);\n }\n\n\n sc.close();\n }\n}\n\n", "language": "Java", "metadata": {"date": 1546135450, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03186.html", "problem_id": "p03186", "resource_group": "high_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/Java/s174595759.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s174595759", "user_id": "u902576227"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*;\nimport java.lang.*;\nimport java.math.*;\n\npublic class Main {\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n \n int a = sc.nextInt(); // bad\n int b = sc.nextInt(); //good\n int c = sc.nextInt(); //good\n if (a + b >= c) {\n System.out.println(b + c); // all ok\n } else {\n System.out.println(b + (b + a) + 1);\n }\n\n\n sc.close();\n }\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison.\n\nEating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death.\nAs he wants to live, he cannot eat one in such a situation.\nEating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches.\n\nFind the maximum number of tasty cookies that Takahashi can eat.\n\nConstraints\n\n0 \\leq A,B,C \\leq 10^9\n\nA,B and C are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the maximum number of tasty cookies that Takahashi can eat.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n5\n\nWe can eat all tasty cookies, in the following order:\n\nA tasty cookie containing poison\n\nAn untasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nA tasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nAn untasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nSample Input 2\n\n5 2 9\n\nSample Output 2\n\n10\n\nSample Input 3\n\n8 8 1\n\nSample Output 3\n\n9", "sample_input": "3 1 4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03186", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison.\n\nEating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death.\nAs he wants to live, he cannot eat one in such a situation.\nEating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches.\n\nFind the maximum number of tasty cookies that Takahashi can eat.\n\nConstraints\n\n0 \\leq A,B,C \\leq 10^9\n\nA,B and C are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the maximum number of tasty cookies that Takahashi can eat.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n5\n\nWe can eat all tasty cookies, in the following order:\n\nA tasty cookie containing poison\n\nAn untasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nA tasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nAn untasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nSample Input 2\n\n5 2 9\n\nSample Output 2\n\n10\n\nSample Input 3\n\n8 8 1\n\nSample Output 3\n\n9", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 472, "cpu_time_ms": 106, "memory_kb": 22996}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s035193676", "group_id": "codeNet:p03188", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.BufferedWriter;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.UncheckedIOException;\nimport java.nio.charset.Charset;\nimport java.util.StringTokenizer;\nimport java.io.Writer;\nimport java.io.OutputStreamWriter;\nimport java.io.BufferedReader;\nimport java.util.regex.Pattern;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author mikit\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n LightScanner in = new LightScanner(inputStream);\n LightWriter out = new LightWriter(outputStream);\n CColoringTorus solver = new CColoringTorus();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class CColoringTorus {\n public void solve(int testNumber, LightScanner in, LightWriter out) {\n Debug.enable(\"src\");\n int k = in.ints();\n int m = (k + 1) / 2;\n int n = m * 2;\n out.ans(n).ln();\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < n; j++) {\n int v = (i + j) % m + 1;\n if (i % 2 == 1 && v + m <= k) {\n v += m;\n }\n out.ans(v);\n }\n out.ln();\n }\n }\n\n }\n\n static class LightScanner {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n\n public LightScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n }\n\n public String string() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new UncheckedIOException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int ints() {\n return Integer.parseInt(string());\n }\n\n }\n\n static class Debug {\n private static final String DEBUG_CALL_PATTERN = \"^.+\\\\.debug\\\\((.+)\\\\);.*$\";\n private static Pattern debugRegex;\n private static boolean enabled = false;\n private static String src;\n\n public static void enable(String s) {\n enabled = true;\n src = s;\n if (debugRegex == null) {\n debugRegex = Pattern.compile(DEBUG_CALL_PATTERN);\n }\n }\n\n }\n\n static class LightWriter implements AutoCloseable {\n private final Writer out;\n private boolean autoflush = false;\n private boolean breaked = true;\n\n public LightWriter(Writer out) {\n this.out = out;\n }\n\n public LightWriter(OutputStream out) {\n this(new BufferedWriter(new OutputStreamWriter(out, Charset.defaultCharset())));\n }\n\n public LightWriter print(char c) {\n try {\n out.write(c);\n breaked = false;\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n return this;\n }\n\n public LightWriter print(String s) {\n try {\n out.write(s, 0, s.length());\n breaked = false;\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n return this;\n }\n\n public LightWriter ans(String s) {\n if (!breaked) {\n print(' ');\n }\n return print(s);\n }\n\n public LightWriter ans(int i) {\n return ans(Integer.toString(i));\n }\n\n public LightWriter ln() {\n print(System.lineSeparator());\n breaked = true;\n if (autoflush) {\n try {\n out.flush();\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n }\n return this;\n }\n\n public void close() {\n try {\n out.close();\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1550136396, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03188.html", "problem_id": "p03188", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03188/input.txt", "sample_output_relpath": "derived/input_output/data/p03188/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03188/Java/s035193676.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s035193676", "user_id": "u183509493"}, "prompt_components": {"gold_output": "3\n1 1 1\n1 1 1\n2 2 2\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.BufferedWriter;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.UncheckedIOException;\nimport java.nio.charset.Charset;\nimport java.util.StringTokenizer;\nimport java.io.Writer;\nimport java.io.OutputStreamWriter;\nimport java.io.BufferedReader;\nimport java.util.regex.Pattern;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author mikit\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n LightScanner in = new LightScanner(inputStream);\n LightWriter out = new LightWriter(outputStream);\n CColoringTorus solver = new CColoringTorus();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class CColoringTorus {\n public void solve(int testNumber, LightScanner in, LightWriter out) {\n Debug.enable(\"src\");\n int k = in.ints();\n int m = (k + 1) / 2;\n int n = m * 2;\n out.ans(n).ln();\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < n; j++) {\n int v = (i + j) % m + 1;\n if (i % 2 == 1 && v + m <= k) {\n v += m;\n }\n out.ans(v);\n }\n out.ln();\n }\n }\n\n }\n\n static class LightScanner {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n\n public LightScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n }\n\n public String string() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new UncheckedIOException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int ints() {\n return Integer.parseInt(string());\n }\n\n }\n\n static class Debug {\n private static final String DEBUG_CALL_PATTERN = \"^.+\\\\.debug\\\\((.+)\\\\);.*$\";\n private static Pattern debugRegex;\n private static boolean enabled = false;\n private static String src;\n\n public static void enable(String s) {\n enabled = true;\n src = s;\n if (debugRegex == null) {\n debugRegex = Pattern.compile(DEBUG_CALL_PATTERN);\n }\n }\n\n }\n\n static class LightWriter implements AutoCloseable {\n private final Writer out;\n private boolean autoflush = false;\n private boolean breaked = true;\n\n public LightWriter(Writer out) {\n this.out = out;\n }\n\n public LightWriter(OutputStream out) {\n this(new BufferedWriter(new OutputStreamWriter(out, Charset.defaultCharset())));\n }\n\n public LightWriter print(char c) {\n try {\n out.write(c);\n breaked = false;\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n return this;\n }\n\n public LightWriter print(String s) {\n try {\n out.write(s, 0, s.length());\n breaked = false;\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n return this;\n }\n\n public LightWriter ans(String s) {\n if (!breaked) {\n print(' ');\n }\n return print(s);\n }\n\n public LightWriter ans(int i) {\n return ans(Integer.toString(i));\n }\n\n public LightWriter ln() {\n print(System.lineSeparator());\n breaked = true;\n if (autoflush) {\n try {\n out.flush();\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n }\n return this;\n }\n\n public void close() {\n try {\n out.close();\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n }\n\n }\n}\n\n", "problem_context": "Score : 1000 points\n\nProblem Statement\n\nFor an n \\times n grid, let (r, c) denote the square at the (r+1)-th row from the top and the (c+1)-th column from the left.\nA good coloring of this grid using K colors is a coloring that satisfies the following:\n\nEach square is painted in one of the K colors.\n\nEach of the K colors is used for some squares.\n\nLet us number the K colors 1, 2, ..., K. For any colors i and j (1 \\leq i \\leq K, 1 \\leq j \\leq K), every square in Color i has the same number of adjacent squares in Color j. Here, the squares adjacent to square (r, c) are ((r-1)\\; mod\\; n, c), ((r+1)\\; mod\\; n, c), (r, (c-1)\\; mod\\; n) and (r, (c+1)\\; mod\\; n) (if the same square appears multiple times among these four, the square is counted that number of times).\n\nGiven K, choose n between 1 and 500 (inclusive) freely and construct a good coloring of an n \\times n grid using K colors.\nIt can be proved that this is always possible under the constraints of this problem,\n\nConstraints\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nOutput should be in the following format:\n\nn\nc_{0,0} c_{0,1} ... c_{0,n-1}\nc_{1,0} c_{1,1} ... c_{1,n-1}\n:\nc_{n-1,0} c_{n-1,1} ... c_{n-1,n-1}\n\nn should represent the size of the grid, and 1 \\leq n \\leq 500 must hold.\nc_{r,c} should be an integer such that 1 \\leq c_{r,c} \\leq K and represent the color for the square (r, c).\n\nSample Input 1\n\n2\n\nSample Output 1\n\n3\n1 1 1\n1 1 1\n2 2 2\n\nEvery square in Color 1 has three adjacent squares in Color 1 and one adjacent square in Color 2.\n\nEvery square in Color 2 has two adjacent squares in Color 1 and two adjacent squares in Color 2.\n\nOutput such as the following will be judged incorrect:\n\n2\n1 2\n2 2\n\n3\n1 1 1\n1 1 1\n1 1 1\n\nSample Input 2\n\n9\n\nSample Output 2\n\n3\n1 2 3\n4 5 6\n7 8 9", "sample_input": "2\n"}, "reference_outputs": ["3\n1 1 1\n1 1 1\n2 2 2\n"], "source_document_id": "p03188", "source_text": "Score : 1000 points\n\nProblem Statement\n\nFor an n \\times n grid, let (r, c) denote the square at the (r+1)-th row from the top and the (c+1)-th column from the left.\nA good coloring of this grid using K colors is a coloring that satisfies the following:\n\nEach square is painted in one of the K colors.\n\nEach of the K colors is used for some squares.\n\nLet us number the K colors 1, 2, ..., K. For any colors i and j (1 \\leq i \\leq K, 1 \\leq j \\leq K), every square in Color i has the same number of adjacent squares in Color j. Here, the squares adjacent to square (r, c) are ((r-1)\\; mod\\; n, c), ((r+1)\\; mod\\; n, c), (r, (c-1)\\; mod\\; n) and (r, (c+1)\\; mod\\; n) (if the same square appears multiple times among these four, the square is counted that number of times).\n\nGiven K, choose n between 1 and 500 (inclusive) freely and construct a good coloring of an n \\times n grid using K colors.\nIt can be proved that this is always possible under the constraints of this problem,\n\nConstraints\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nOutput should be in the following format:\n\nn\nc_{0,0} c_{0,1} ... c_{0,n-1}\nc_{1,0} c_{1,1} ... c_{1,n-1}\n:\nc_{n-1,0} c_{n-1,1} ... c_{n-1,n-1}\n\nn should represent the size of the grid, and 1 \\leq n \\leq 500 must hold.\nc_{r,c} should be an integer such that 1 \\leq c_{r,c} \\leq K and represent the color for the square (r, c).\n\nSample Input 1\n\n2\n\nSample Output 1\n\n3\n1 1 1\n1 1 1\n2 2 2\n\nEvery square in Color 1 has three adjacent squares in Color 1 and one adjacent square in Color 2.\n\nEvery square in Color 2 has two adjacent squares in Color 1 and two adjacent squares in Color 2.\n\nOutput such as the following will be judged incorrect:\n\n2\n1 2\n2 2\n\n3\n1 1 1\n1 1 1\n1 1 1\n\nSample Input 2\n\n9\n\nSample Output 2\n\n3\n1 2 3\n4 5 6\n7 8 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": 4504, "cpu_time_ms": 238, "memory_kb": 45700}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s227206793", "group_id": "codeNet:p03196", "input_text": "\nimport java.text.DecimalFormat;\nimport java.util.stream.LongStream;\nimport java.util.stream.IntStream;\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n FastScanner sc = new FastScanner();\n PrintWriter out = new PrintWriter(System.out);\n\n AtCoder problem = new AtCoder(sc);\n problem.solve(sc, out);\n\n out.flush();\n }\n\n}\n\nclass AtCoder {\n\n long N, P;\n\n AtCoder(FastScanner sc) {\n N = sc.nextLong();\n P = sc.nextLong();\n }\n\n void solve(FastScanner sc, PrintWriter out) {\n if (P == 1) {\n out.println(1);\n return;\n }\n List ls = primeFactorization(P);\n long ans = 1;\n for (int i = 1; i < ls.size(); i += 2) {\n if (ls.get(i) >= N) ans *= ls.get(i - 1) * (ls.get(i) / N);\n }\n out.println(ans);\n }\n\n List primeFactorization(long n) {\n List ls = new ArrayList<>();\n for (long i = 2; i * i <= n; i++) {\n if (n % i != 0) continue;\n long ex = 0;\n while (n % i == 0) {\n ex++;\n n /= i;\n }\n ls.add(i);\n ls.add(ex);\n }\n if (n != 1) {\n ls.add(n);\n ls.add(1L);\n }\n return ls;\n }\n}\n\nclass FastScanner {\n\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) {\n return buffer[ptr++];\n } else {\n return -1;\n }\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) {\n ptr++;\n }\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {\n throw new NumberFormatException();\n }\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n\n public int[] arrayInt(int N) {\n int[] array = new int[N];\n for (int i = 0; i < N; i++) {\n array[i] = nextInt();\n }\n return array;\n }\n\n public long[] arrayLong(int N) {\n long[] array = new long[N];\n for (int i = 0; i < N; i++) {\n array[i] = nextLong();\n }\n return array;\n }\n\n public double[] arrayDouble(int N) {\n double[] array = new double[N];\n for (int i = 0; i < N; i++) {\n array[i] = nextDouble();\n }\n return array;\n }\n\n public String[] arrayString(int N) {\n String[] array = new String[N];\n for (int i = 0; i < N; i++) {\n array[i] = next();\n }\n return array;\n }\n\n public int randomInt() {\n Random r = new Random();\n int value = r.nextInt((int) 1e6);\n System.out.println(value);\n return value;\n }\n\n public int[] randomInt(int N) {\n int[] array = new int[N];\n Random r = new Random();\n for (int i = 0; i < N; i++) {\n array[i] = r.nextInt((int) 1e6);\n }\n System.out.println(Arrays.toString(array));\n return array;\n }\n\n}\n\nclass My {\n\n static void ans(boolean b) {\n System.out.println(b ? \"Yes\" : \"No\");\n }\n\n static void ANS(boolean b) {\n System.out.println(b ? \"YES\" : \"NO\");\n }\n\n static String sort(String s) {\n char[] ch = s.toCharArray();\n Arrays.sort(ch);\n return String.valueOf(ch);\n }\n\n static String reverse(String s) {\n return new StringBuilder(s).reverse().toString();\n }\n\n static int[] reverse(int[] array) {\n for (int i = 0; i < array.length / 2; i++) {\n int temp = array[i];\n array[i] = array[array.length - 1 - i];\n array[array.length - 1 - i] = temp;\n }\n return array;\n }\n\n static long[] reverse(long[] array) {\n for (int i = 0; i < array.length / 2; i++) {\n long temp = array[i];\n array[i] = array[array.length - 1 - i];\n array[array.length - 1 - i] = temp;\n }\n return array;\n }\n\n static double[] reverse(double[] array) {\n for (int i = 0; i < array.length / 2; i++) {\n double temp = array[i];\n array[i] = array[array.length - 1 - i];\n array[array.length - 1 - i] = temp;\n }\n return array;\n }\n\n static String[] reverse(String[] array) {\n for (int i = 0; i < array.length / 2; i++) {\n String temp = array[i];\n array[i] = array[array.length - 1 - i];\n array[array.length - 1 - i] = temp;\n }\n return array;\n }\n\n static char[] reverse(char[] array) {\n for (int i = 0; i < array.length / 2; i++) {\n char temp = array[i];\n array[i] = array[array.length - 1 - i];\n array[array.length - 1 - i] = temp;\n }\n return array;\n }\n\n static long min(long... numbers) {\n Arrays.sort(numbers);\n return numbers[0];\n }\n\n static int min(int... numbers) {\n Arrays.sort(numbers);\n return numbers[0];\n }\n\n static double min(double... numbers) {\n Arrays.sort(numbers);\n return numbers[0];\n }\n\n static long max(long... numbers) {\n Arrays.sort(numbers);\n return numbers[numbers.length - 1];\n }\n\n static int max(int... numbers) {\n Arrays.sort(numbers);\n return numbers[numbers.length - 1];\n }\n\n static double max(double... numbers) {\n Arrays.sort(numbers);\n return numbers[numbers.length - 1];\n }\n\n static int sum(long number) {\n int sum = 0;\n while (number > 0) {\n sum += number % 10;\n number /= 10;\n }\n return sum;\n }\n\n}\n", "language": "Java", "metadata": {"date": 1598223308, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p03196.html", "problem_id": "p03196", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03196/input.txt", "sample_output_relpath": "derived/input_output/data/p03196/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03196/Java/s227206793.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s227206793", "user_id": "u871244227"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\nimport java.text.DecimalFormat;\nimport java.util.stream.LongStream;\nimport java.util.stream.IntStream;\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n FastScanner sc = new FastScanner();\n PrintWriter out = new PrintWriter(System.out);\n\n AtCoder problem = new AtCoder(sc);\n problem.solve(sc, out);\n\n out.flush();\n }\n\n}\n\nclass AtCoder {\n\n long N, P;\n\n AtCoder(FastScanner sc) {\n N = sc.nextLong();\n P = sc.nextLong();\n }\n\n void solve(FastScanner sc, PrintWriter out) {\n if (P == 1) {\n out.println(1);\n return;\n }\n List ls = primeFactorization(P);\n long ans = 1;\n for (int i = 1; i < ls.size(); i += 2) {\n if (ls.get(i) >= N) ans *= ls.get(i - 1) * (ls.get(i) / N);\n }\n out.println(ans);\n }\n\n List primeFactorization(long n) {\n List ls = new ArrayList<>();\n for (long i = 2; i * i <= n; i++) {\n if (n % i != 0) continue;\n long ex = 0;\n while (n % i == 0) {\n ex++;\n n /= i;\n }\n ls.add(i);\n ls.add(ex);\n }\n if (n != 1) {\n ls.add(n);\n ls.add(1L);\n }\n return ls;\n }\n}\n\nclass FastScanner {\n\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) {\n return buffer[ptr++];\n } else {\n return -1;\n }\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) {\n ptr++;\n }\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {\n throw new NumberFormatException();\n }\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n\n public int[] arrayInt(int N) {\n int[] array = new int[N];\n for (int i = 0; i < N; i++) {\n array[i] = nextInt();\n }\n return array;\n }\n\n public long[] arrayLong(int N) {\n long[] array = new long[N];\n for (int i = 0; i < N; i++) {\n array[i] = nextLong();\n }\n return array;\n }\n\n public double[] arrayDouble(int N) {\n double[] array = new double[N];\n for (int i = 0; i < N; i++) {\n array[i] = nextDouble();\n }\n return array;\n }\n\n public String[] arrayString(int N) {\n String[] array = new String[N];\n for (int i = 0; i < N; i++) {\n array[i] = next();\n }\n return array;\n }\n\n public int randomInt() {\n Random r = new Random();\n int value = r.nextInt((int) 1e6);\n System.out.println(value);\n return value;\n }\n\n public int[] randomInt(int N) {\n int[] array = new int[N];\n Random r = new Random();\n for (int i = 0; i < N; i++) {\n array[i] = r.nextInt((int) 1e6);\n }\n System.out.println(Arrays.toString(array));\n return array;\n }\n\n}\n\nclass My {\n\n static void ans(boolean b) {\n System.out.println(b ? \"Yes\" : \"No\");\n }\n\n static void ANS(boolean b) {\n System.out.println(b ? \"YES\" : \"NO\");\n }\n\n static String sort(String s) {\n char[] ch = s.toCharArray();\n Arrays.sort(ch);\n return String.valueOf(ch);\n }\n\n static String reverse(String s) {\n return new StringBuilder(s).reverse().toString();\n }\n\n static int[] reverse(int[] array) {\n for (int i = 0; i < array.length / 2; i++) {\n int temp = array[i];\n array[i] = array[array.length - 1 - i];\n array[array.length - 1 - i] = temp;\n }\n return array;\n }\n\n static long[] reverse(long[] array) {\n for (int i = 0; i < array.length / 2; i++) {\n long temp = array[i];\n array[i] = array[array.length - 1 - i];\n array[array.length - 1 - i] = temp;\n }\n return array;\n }\n\n static double[] reverse(double[] array) {\n for (int i = 0; i < array.length / 2; i++) {\n double temp = array[i];\n array[i] = array[array.length - 1 - i];\n array[array.length - 1 - i] = temp;\n }\n return array;\n }\n\n static String[] reverse(String[] array) {\n for (int i = 0; i < array.length / 2; i++) {\n String temp = array[i];\n array[i] = array[array.length - 1 - i];\n array[array.length - 1 - i] = temp;\n }\n return array;\n }\n\n static char[] reverse(char[] array) {\n for (int i = 0; i < array.length / 2; i++) {\n char temp = array[i];\n array[i] = array[array.length - 1 - i];\n array[array.length - 1 - i] = temp;\n }\n return array;\n }\n\n static long min(long... numbers) {\n Arrays.sort(numbers);\n return numbers[0];\n }\n\n static int min(int... numbers) {\n Arrays.sort(numbers);\n return numbers[0];\n }\n\n static double min(double... numbers) {\n Arrays.sort(numbers);\n return numbers[0];\n }\n\n static long max(long... numbers) {\n Arrays.sort(numbers);\n return numbers[numbers.length - 1];\n }\n\n static int max(int... numbers) {\n Arrays.sort(numbers);\n return numbers[numbers.length - 1];\n }\n\n static double max(double... numbers) {\n Arrays.sort(numbers);\n return numbers[numbers.length - 1];\n }\n\n static int sum(long number) {\n int sum = 0;\n while (number > 0) {\n sum += number % 10;\n number /= 10;\n }\n return sum;\n }\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N integers a_1, a_2, ..., a_N not less than 1.\nThe values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \\times a_2 \\times ... \\times a_N = P.\n\nFind the maximum possible greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\n1 \\leq N \\leq 10^{12}\n\n1 \\leq P \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 24\n\nSample Output 1\n\n2\n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.\n\nSample Input 2\n\n5 1\n\nSample Output 2\n\n1\n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.\n\nSample Input 3\n\n1 111\n\nSample Output 3\n\n111\n\nSample Input 4\n\n4 972439611840\n\nSample Output 4\n\n206", "sample_input": "3 24\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03196", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N integers a_1, a_2, ..., a_N not less than 1.\nThe values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \\times a_2 \\times ... \\times a_N = P.\n\nFind the maximum possible greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\n1 \\leq N \\leq 10^{12}\n\n1 \\leq P \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 24\n\nSample Output 1\n\n2\n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.\n\nSample Input 2\n\n5 1\n\nSample Output 2\n\n1\n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.\n\nSample Input 3\n\n1 111\n\nSample Output 3\n\n111\n\nSample Input 4\n\n4 972439611840\n\nSample Output 4\n\n206", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7489, "cpu_time_ms": 93, "memory_kb": 32580}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s732901418", "group_id": "codeNet:p03196", "input_text": "import java.util.HashMap;\nimport java.util.Map;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tlong n = sc.nextLong();\n\t\tlong p = sc.nextLong();\n\t\tif(n==1) {\n\t\t\tSystem.out.println(p);\n\t\t\treturn;\n\t\t}\n\t\tMap sosuMap = new HashMap();\n\t\tfor(long i =2;i <= Math.sqrt(p);) {\n\t\t\tif(p % i == 0) {\n\t\t\t\tlong sosuCount = 0;\n\t\t\t\twhile(p % i == 0) {\n\t\t\t\t\tsosuCount++;\n\t\t\t\t\tp /= i;\n\t\t\t\t}\n\t\t\t\tsosuMap.put((long) i, sosuCount);\n\t\t\t}\n\t\t\tif(i ==2) {\n\t\t\t\ti++;\n\t\t\t}else {\n\t\t\t\ti+=2;\n\t\t\t}\n\t\t}\n\n\t\tlong answer = 1;\n\t\tfor(Map.Entry entry:sosuMap.entrySet()) {\n\t\t\tif(entry.getValue() >= n) {\n\t\t\t\tanswer *=Math.pow((double)entry.getKey(),(double)(entry.getValue() / n));\n\n\t\t\t}\n\n\t\t}\n\n\t\tSystem.out.println(answer);\n\t}\n\n}", "language": "Java", "metadata": {"date": 1590894974, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03196.html", "problem_id": "p03196", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03196/input.txt", "sample_output_relpath": "derived/input_output/data/p03196/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03196/Java/s732901418.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s732901418", "user_id": "u268132693"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.HashMap;\nimport java.util.Map;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tlong n = sc.nextLong();\n\t\tlong p = sc.nextLong();\n\t\tif(n==1) {\n\t\t\tSystem.out.println(p);\n\t\t\treturn;\n\t\t}\n\t\tMap sosuMap = new HashMap();\n\t\tfor(long i =2;i <= Math.sqrt(p);) {\n\t\t\tif(p % i == 0) {\n\t\t\t\tlong sosuCount = 0;\n\t\t\t\twhile(p % i == 0) {\n\t\t\t\t\tsosuCount++;\n\t\t\t\t\tp /= i;\n\t\t\t\t}\n\t\t\t\tsosuMap.put((long) i, sosuCount);\n\t\t\t}\n\t\t\tif(i ==2) {\n\t\t\t\ti++;\n\t\t\t}else {\n\t\t\t\ti+=2;\n\t\t\t}\n\t\t}\n\n\t\tlong answer = 1;\n\t\tfor(Map.Entry entry:sosuMap.entrySet()) {\n\t\t\tif(entry.getValue() >= n) {\n\t\t\t\tanswer *=Math.pow((double)entry.getKey(),(double)(entry.getValue() / n));\n\n\t\t\t}\n\n\t\t}\n\n\t\tSystem.out.println(answer);\n\t}\n\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N integers a_1, a_2, ..., a_N not less than 1.\nThe values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \\times a_2 \\times ... \\times a_N = P.\n\nFind the maximum possible greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\n1 \\leq N \\leq 10^{12}\n\n1 \\leq P \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 24\n\nSample Output 1\n\n2\n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.\n\nSample Input 2\n\n5 1\n\nSample Output 2\n\n1\n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.\n\nSample Input 3\n\n1 111\n\nSample Output 3\n\n111\n\nSample Input 4\n\n4 972439611840\n\nSample Output 4\n\n206", "sample_input": "3 24\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03196", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N integers a_1, a_2, ..., a_N not less than 1.\nThe values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \\times a_2 \\times ... \\times a_N = P.\n\nFind the maximum possible greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\n1 \\leq N \\leq 10^{12}\n\n1 \\leq P \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 24\n\nSample Output 1\n\n2\n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.\n\nSample Input 2\n\n5 1\n\nSample Output 2\n\n1\n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.\n\nSample Input 3\n\n1 111\n\nSample Output 3\n\n111\n\nSample Input 4\n\n4 972439611840\n\nSample Output 4\n\n206", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 808, "cpu_time_ms": 104, "memory_kb": 23252}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s924338078", "group_id": "codeNet:p03199", "input_text": "import java.io.ByteArrayInputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.HashMap;\nimport java.util.InputMismatchException;\nimport java.util.Map;\n\npublic class Main {\n\tstatic InputStream is;\n\tstatic PrintWriter out;\n\tstatic String INPUT = \"\";\n\t\n\t// 1000\n\t// 1???\n\t// ?1?1\n\t// 0??1\n\t\n\t\n\tstatic void solve()\n\t{\n\t\tint n = ni(), m = ni();\n\t\tint[][] co = new int[m][];\n\t\tfor(int i = 0;i < m;i++){\n\t\t\tco[i] = na(3);\n\t\t}\n\t\tMap map = new HashMap<>();\n\t\tfor(int[] c : co){\n\t\t\tmap.put((long)c[0]<<32|c[1], c[2]);\n\t\t}\n\t\tint[] udiag = new int[n-1];\n\t\tint[] ddiag = new int[n-1];\n\t\tint[] diag = new int[n];\n\t\tArrays.fill(diag, -1);\n\t\tArrays.fill(udiag, -1);\n\t\tArrays.fill(ddiag, -1);\n\t\t\n\t\tint mod = 998244353;\n\t\tint free = 0;\n\t\tfor(int i = 1;i <= n;i++){\n\t\t\tif(!map.containsKey((long)i<<32|i)){\n\t\t\t}else{\n\t\t\t\tdiag[i-1] = map.get((long)i<<32|i);\n\t\t\t}\n\t\t}\n\t\tint np = 0;\n\t\tfor(int i = 0;i < m;i++){\n\t\t\tint[] c = co[i];\n\t\t\tif(c[1] == c[0] + 1){\n\t\t\t\tudiag[c[0]-1] = c[2];\n\t\t\t\tcontinue;\n\t\t\t}else if(c[1] == c[0] - 1){\n\t\t\t\tddiag[c[1]-1] = c[2];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif(c[1] == c[0])continue;\n\t\t\tlong inv = (long)c[1]<<32|c[0];\n\t\t\tif(map.containsKey(inv)){\n\t\t\t\tnp += 1;\n\t\t\t\tint u = map.get(inv);\n\t\t\t\tif(u+c[2] == 1){\n\t\t\t\t\tif(Math.abs(c[0]-c[1]) > 2){\n\t\t\t\t\t\tout.println(0);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif(Math.abs(c[0]-c[1]) == 2){\n\t\t\t\t\t\tint r = (c[0]+c[1])/2;\n\t\t\t\t\t\tif(!map.containsKey((long)r<<32|r)){\n\t\t\t\t\t\t\tdiag[r-1] = 1;\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tint q = map.get((long)r<<32|r);\n\t\t\t\t\t\t\tif(q == 0){\n\t\t\t\t\t\t\t\tout.println(0);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\tnp += 2;\n\t\t\t}\n\t\t}\n\t\tfree += (long)(n-1)*(n-2)/2-np/2;\n\t\t\n//\t\ttr(free);\n//\t\ttr(udiag);\n//\t\ttr(diag);\n//\t\ttr(ddiag);\n\t\t\n\t\tlong[] dp = new long[2];\n\t\tif(diag[0] == 0){\n\t\t\tdp[0] = 1;\n\t\t}else if(diag[0] == 1){\n\t\t\tdp[1] = 1;\n\t\t}else{\n\t\t\tdp[0] = dp[1] = 1;\n\t\t}\n\t\t\n\t\tfor(int i = 1;i < n;i++){\n\t\t\t{\n\t\t\t\tint fi = (udiag[i-1] >= 0 ? 1 : 0) + (ddiag[i-1] >= 0 ? 1 : 0);\n\t\t\t\tint fs = udiag[i-1] ^ ddiag[i-1];\n\t\t\t\tlong[] ndp = new long[2];\n\t\t\t\tif(fi == 2){\n\t\t\t\t\tfor(int j = 0;j < 2;j++){\n\t\t\t\t\t\tndp[j^fs] += dp[j];\n\t\t\t\t\t}\n\t\t\t\t}else if(fi == 1){\n\t\t\t\t\tndp[0] = (dp[0] + dp[1]) % mod;\n\t\t\t\t\tndp[1] = (dp[0] + dp[1]) % mod;\n\t\t\t\t}else{\n\t\t\t\t\tndp[0] = (dp[0] + dp[1])*2L % mod;\n\t\t\t\t\tndp[1] = (dp[0] + dp[1])*2L % mod;\n\t\t\t\t}\n\t\t\t\tdp = ndp;\n\t\t\t}\n\t\t\tlong[] ndp = new long[2];\n\t\t\tif(diag[i] == 0){\n\t\t\t\tndp[0] = dp[0];\n\t\t\t}else if(diag[i] == 1){\n\t\t\t\tndp[1] = dp[1];\n\t\t\t}else{\n\t\t\t\tndp[0] = dp[0];\n\t\t\t\tndp[1] = dp[1];\n\t\t\t}\n\t\t\tdp = ndp;\n\t\t}\n\t\t\n\t\tout.println((dp[0]+dp[1])%mod * pow(2, free, mod) % mod);\n\t}\n\t// ??1\n\t// ??1\n\t// 010\n\t\n\tpublic static long pow(long a, long n, long mod) {\n\t\t//\t\ta %= mod;\n\t\tlong ret = 1;\n\t\tint x = 63 - Long.numberOfLeadingZeros(n);\n\t\tfor (; x >= 0; x--) {\n\t\t\tret = ret * ret % mod;\n\t\t\tif (n << 63 - x < 0)\n\t\t\t\tret = ret * a % mod;\n\t\t}\n\t\treturn ret;\n\t}\n\n\t\n\tpublic static void main(String[] args) throws Exception\n\t{\n\t\tlong S = System.currentTimeMillis();\n\t\tis = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n\t\tout = new PrintWriter(System.out);\n\t\t\n\t\tsolve();\n\t\tout.flush();\n\t\tlong G = System.currentTimeMillis();\n\t\ttr(G-S+\"ms\");\n\t}\n\t\n\tprivate static boolean eof()\n\t{\n\t\tif(lenbuf == -1)return true;\n\t\tint lptr = ptrbuf;\n\t\twhile(lptr < lenbuf)if(!isSpaceChar(inbuf[lptr++]))return false;\n\t\t\n\t\ttry {\n\t\t\tis.mark(1000);\n\t\t\twhile(true){\n\t\t\t\tint b = is.read();\n\t\t\t\tif(b == -1){\n\t\t\t\t\tis.reset();\n\t\t\t\t\treturn true;\n\t\t\t\t}else if(!isSpaceChar(b)){\n\t\t\t\t\tis.reset();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (IOException e) {\n\t\t\treturn true;\n\t\t}\n\t}\n\t\n\tprivate static byte[] inbuf = new byte[1024];\n\tstatic int lenbuf = 0, ptrbuf = 0;\n\t\n\tprivate static int readByte()\n\t{\n\t\tif(lenbuf == -1)throw new InputMismatchException();\n\t\tif(ptrbuf >= lenbuf){\n\t\t\tptrbuf = 0;\n\t\t\ttry { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }\n\t\t\tif(lenbuf <= 0)return -1;\n\t\t}\n\t\treturn inbuf[ptrbuf++];\n\t}\n\t\n\tprivate static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }\n//\tprivate static boolean isSpaceChar(int c) { return !(c >= 32 && c <= 126); }\n\tprivate static int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }\n\t\n\tprivate static double nd() { return Double.parseDouble(ns()); }\n\tprivate static char nc() { return (char)skip(); }\n\t\n\tprivate static String ns()\n\t{\n\t\tint b = skip();\n\t\tStringBuilder sb = new StringBuilder();\n\t\twhile(!(isSpaceChar(b))){\n\t\t\tsb.appendCodePoint(b);\n\t\t\tb = readByte();\n\t\t}\n\t\treturn sb.toString();\n\t}\n\t\n\tprivate static char[] ns(int n)\n\t{\n\t\tchar[] buf = new char[n];\n\t\tint b = skip(), p = 0;\n\t\twhile(p < n && !(isSpaceChar(b))){\n\t\t\tbuf[p++] = (char)b;\n\t\t\tb = readByte();\n\t\t}\n\t\treturn n == p ? buf : Arrays.copyOf(buf, p);\n\t}\n\t\n\tprivate static char[][] nm(int n, int m)\n\t{\n\t\tchar[][] map = new char[n][];\n\t\tfor(int i = 0;i < n;i++)map[i] = ns(m);\n\t\treturn map;\n\t}\n\t\n\tprivate static int[] na(int n)\n\t{\n\t\tint[] a = new int[n];\n\t\tfor(int i = 0;i < n;i++)a[i] = ni();\n\t\treturn a;\n\t}\n\t\n\tprivate static int ni()\n\t{\n\t\tint num = 0, b;\n\t\tboolean minus = false;\n\t\twhile((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n\t\tif(b == '-'){\n\t\t\tminus = true;\n\t\t\tb = readByte();\n\t\t}\n\t\t\n\t\twhile(true){\n\t\t\tif(b >= '0' && b <= '9'){\n\t\t\t\tnum = num * 10 + (b - '0');\n\t\t\t}else{\n\t\t\t\treturn minus ? -num : num;\n\t\t\t}\n\t\t\tb = readByte();\n\t\t}\n\t}\n\t\n\tprivate static long nl()\n\t{\n\t\tlong num = 0;\n\t\tint b;\n\t\tboolean minus = false;\n\t\twhile((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n\t\tif(b == '-'){\n\t\t\tminus = true;\n\t\t\tb = readByte();\n\t\t}\n\t\t\n\t\twhile(true){\n\t\t\tif(b >= '0' && b <= '9'){\n\t\t\t\tnum = num * 10 + (b - '0');\n\t\t\t}else{\n\t\t\t\treturn minus ? -num : num;\n\t\t\t}\n\t\t\tb = readByte();\n\t\t}\n\t}\n\t\n\tprivate static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }\n}\n", "language": "Java", "metadata": {"date": 1545537546, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03199.html", "problem_id": "p03199", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03199/input.txt", "sample_output_relpath": "derived/input_output/data/p03199/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03199/Java/s924338078.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s924338078", "user_id": "u119714109"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.io.ByteArrayInputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.HashMap;\nimport java.util.InputMismatchException;\nimport java.util.Map;\n\npublic class Main {\n\tstatic InputStream is;\n\tstatic PrintWriter out;\n\tstatic String INPUT = \"\";\n\t\n\t// 1000\n\t// 1???\n\t// ?1?1\n\t// 0??1\n\t\n\t\n\tstatic void solve()\n\t{\n\t\tint n = ni(), m = ni();\n\t\tint[][] co = new int[m][];\n\t\tfor(int i = 0;i < m;i++){\n\t\t\tco[i] = na(3);\n\t\t}\n\t\tMap map = new HashMap<>();\n\t\tfor(int[] c : co){\n\t\t\tmap.put((long)c[0]<<32|c[1], c[2]);\n\t\t}\n\t\tint[] udiag = new int[n-1];\n\t\tint[] ddiag = new int[n-1];\n\t\tint[] diag = new int[n];\n\t\tArrays.fill(diag, -1);\n\t\tArrays.fill(udiag, -1);\n\t\tArrays.fill(ddiag, -1);\n\t\t\n\t\tint mod = 998244353;\n\t\tint free = 0;\n\t\tfor(int i = 1;i <= n;i++){\n\t\t\tif(!map.containsKey((long)i<<32|i)){\n\t\t\t}else{\n\t\t\t\tdiag[i-1] = map.get((long)i<<32|i);\n\t\t\t}\n\t\t}\n\t\tint np = 0;\n\t\tfor(int i = 0;i < m;i++){\n\t\t\tint[] c = co[i];\n\t\t\tif(c[1] == c[0] + 1){\n\t\t\t\tudiag[c[0]-1] = c[2];\n\t\t\t\tcontinue;\n\t\t\t}else if(c[1] == c[0] - 1){\n\t\t\t\tddiag[c[1]-1] = c[2];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif(c[1] == c[0])continue;\n\t\t\tlong inv = (long)c[1]<<32|c[0];\n\t\t\tif(map.containsKey(inv)){\n\t\t\t\tnp += 1;\n\t\t\t\tint u = map.get(inv);\n\t\t\t\tif(u+c[2] == 1){\n\t\t\t\t\tif(Math.abs(c[0]-c[1]) > 2){\n\t\t\t\t\t\tout.println(0);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif(Math.abs(c[0]-c[1]) == 2){\n\t\t\t\t\t\tint r = (c[0]+c[1])/2;\n\t\t\t\t\t\tif(!map.containsKey((long)r<<32|r)){\n\t\t\t\t\t\t\tdiag[r-1] = 1;\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tint q = map.get((long)r<<32|r);\n\t\t\t\t\t\t\tif(q == 0){\n\t\t\t\t\t\t\t\tout.println(0);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\tnp += 2;\n\t\t\t}\n\t\t}\n\t\tfree += (long)(n-1)*(n-2)/2-np/2;\n\t\t\n//\t\ttr(free);\n//\t\ttr(udiag);\n//\t\ttr(diag);\n//\t\ttr(ddiag);\n\t\t\n\t\tlong[] dp = new long[2];\n\t\tif(diag[0] == 0){\n\t\t\tdp[0] = 1;\n\t\t}else if(diag[0] == 1){\n\t\t\tdp[1] = 1;\n\t\t}else{\n\t\t\tdp[0] = dp[1] = 1;\n\t\t}\n\t\t\n\t\tfor(int i = 1;i < n;i++){\n\t\t\t{\n\t\t\t\tint fi = (udiag[i-1] >= 0 ? 1 : 0) + (ddiag[i-1] >= 0 ? 1 : 0);\n\t\t\t\tint fs = udiag[i-1] ^ ddiag[i-1];\n\t\t\t\tlong[] ndp = new long[2];\n\t\t\t\tif(fi == 2){\n\t\t\t\t\tfor(int j = 0;j < 2;j++){\n\t\t\t\t\t\tndp[j^fs] += dp[j];\n\t\t\t\t\t}\n\t\t\t\t}else if(fi == 1){\n\t\t\t\t\tndp[0] = (dp[0] + dp[1]) % mod;\n\t\t\t\t\tndp[1] = (dp[0] + dp[1]) % mod;\n\t\t\t\t}else{\n\t\t\t\t\tndp[0] = (dp[0] + dp[1])*2L % mod;\n\t\t\t\t\tndp[1] = (dp[0] + dp[1])*2L % mod;\n\t\t\t\t}\n\t\t\t\tdp = ndp;\n\t\t\t}\n\t\t\tlong[] ndp = new long[2];\n\t\t\tif(diag[i] == 0){\n\t\t\t\tndp[0] = dp[0];\n\t\t\t}else if(diag[i] == 1){\n\t\t\t\tndp[1] = dp[1];\n\t\t\t}else{\n\t\t\t\tndp[0] = dp[0];\n\t\t\t\tndp[1] = dp[1];\n\t\t\t}\n\t\t\tdp = ndp;\n\t\t}\n\t\t\n\t\tout.println((dp[0]+dp[1])%mod * pow(2, free, mod) % mod);\n\t}\n\t// ??1\n\t// ??1\n\t// 010\n\t\n\tpublic static long pow(long a, long n, long mod) {\n\t\t//\t\ta %= mod;\n\t\tlong ret = 1;\n\t\tint x = 63 - Long.numberOfLeadingZeros(n);\n\t\tfor (; x >= 0; x--) {\n\t\t\tret = ret * ret % mod;\n\t\t\tif (n << 63 - x < 0)\n\t\t\t\tret = ret * a % mod;\n\t\t}\n\t\treturn ret;\n\t}\n\n\t\n\tpublic static void main(String[] args) throws Exception\n\t{\n\t\tlong S = System.currentTimeMillis();\n\t\tis = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n\t\tout = new PrintWriter(System.out);\n\t\t\n\t\tsolve();\n\t\tout.flush();\n\t\tlong G = System.currentTimeMillis();\n\t\ttr(G-S+\"ms\");\n\t}\n\t\n\tprivate static boolean eof()\n\t{\n\t\tif(lenbuf == -1)return true;\n\t\tint lptr = ptrbuf;\n\t\twhile(lptr < lenbuf)if(!isSpaceChar(inbuf[lptr++]))return false;\n\t\t\n\t\ttry {\n\t\t\tis.mark(1000);\n\t\t\twhile(true){\n\t\t\t\tint b = is.read();\n\t\t\t\tif(b == -1){\n\t\t\t\t\tis.reset();\n\t\t\t\t\treturn true;\n\t\t\t\t}else if(!isSpaceChar(b)){\n\t\t\t\t\tis.reset();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (IOException e) {\n\t\t\treturn true;\n\t\t}\n\t}\n\t\n\tprivate static byte[] inbuf = new byte[1024];\n\tstatic int lenbuf = 0, ptrbuf = 0;\n\t\n\tprivate static int readByte()\n\t{\n\t\tif(lenbuf == -1)throw new InputMismatchException();\n\t\tif(ptrbuf >= lenbuf){\n\t\t\tptrbuf = 0;\n\t\t\ttry { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }\n\t\t\tif(lenbuf <= 0)return -1;\n\t\t}\n\t\treturn inbuf[ptrbuf++];\n\t}\n\t\n\tprivate static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }\n//\tprivate static boolean isSpaceChar(int c) { return !(c >= 32 && c <= 126); }\n\tprivate static int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }\n\t\n\tprivate static double nd() { return Double.parseDouble(ns()); }\n\tprivate static char nc() { return (char)skip(); }\n\t\n\tprivate static String ns()\n\t{\n\t\tint b = skip();\n\t\tStringBuilder sb = new StringBuilder();\n\t\twhile(!(isSpaceChar(b))){\n\t\t\tsb.appendCodePoint(b);\n\t\t\tb = readByte();\n\t\t}\n\t\treturn sb.toString();\n\t}\n\t\n\tprivate static char[] ns(int n)\n\t{\n\t\tchar[] buf = new char[n];\n\t\tint b = skip(), p = 0;\n\t\twhile(p < n && !(isSpaceChar(b))){\n\t\t\tbuf[p++] = (char)b;\n\t\t\tb = readByte();\n\t\t}\n\t\treturn n == p ? buf : Arrays.copyOf(buf, p);\n\t}\n\t\n\tprivate static char[][] nm(int n, int m)\n\t{\n\t\tchar[][] map = new char[n][];\n\t\tfor(int i = 0;i < n;i++)map[i] = ns(m);\n\t\treturn map;\n\t}\n\t\n\tprivate static int[] na(int n)\n\t{\n\t\tint[] a = new int[n];\n\t\tfor(int i = 0;i < n;i++)a[i] = ni();\n\t\treturn a;\n\t}\n\t\n\tprivate static int ni()\n\t{\n\t\tint num = 0, b;\n\t\tboolean minus = false;\n\t\twhile((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n\t\tif(b == '-'){\n\t\t\tminus = true;\n\t\t\tb = readByte();\n\t\t}\n\t\t\n\t\twhile(true){\n\t\t\tif(b >= '0' && b <= '9'){\n\t\t\t\tnum = num * 10 + (b - '0');\n\t\t\t}else{\n\t\t\t\treturn minus ? -num : num;\n\t\t\t}\n\t\t\tb = readByte();\n\t\t}\n\t}\n\t\n\tprivate static long nl()\n\t{\n\t\tlong num = 0;\n\t\tint b;\n\t\tboolean minus = false;\n\t\twhile((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n\t\tif(b == '-'){\n\t\t\tminus = true;\n\t\t\tb = readByte();\n\t\t}\n\t\t\n\t\twhile(true){\n\t\t\tif(b >= '0' && b <= '9'){\n\t\t\t\tnum = num * 10 + (b - '0');\n\t\t\t}else{\n\t\t\t\treturn minus ? -num : num;\n\t\t\t}\n\t\t\tb = readByte();\n\t\t}\n\t}\n\t\n\tprivate static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }\n}\n", "problem_context": "Score : 900 points\n\nProblem Statement\n\nTakahashi has an N \\times N grid. The square at the i-th row and the j-th column of the grid is denoted by (i,j).\nParticularly, the top-left square of the grid is (1,1), and the bottom-right square is (N,N).\n\nAn integer, 0 or 1, is written on M of the squares in the Takahashi's grid.\nThree integers a_i,b_i and c_i describe the i-th of those squares with integers written on them: the integer c_i is written on the square (a_i,b_i).\n\nTakahashi decides to write an integer, 0 or 1, on each of the remaining squares so that the condition below is satisfied.\nFind the number of such ways to write integers, modulo 998244353.\n\nFor all 1\\leq i < j\\leq N, there are even number of 1s in the square region whose top-left square is (i,i) and whose bottom-right square is (j,j).\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n0 \\leq M \\leq min(5 \\times 10^4,N^2)\n\n1 \\leq a_i,b_i \\leq N(1\\leq i\\leq M)\n\n0 \\leq c_i \\leq 1(1\\leq i\\leq M)\n\nIf i \\neq j, then (a_i,b_i) \\neq (a_j,b_j).\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 c_1\n:\na_M b_M c_M\n\nOutput\n\nPrint the number of possible ways to write integers, modulo 998244353.\n\nSample Input 1\n\n3 3\n1 1 1\n3 1 0\n2 3 1\n\nSample Output 1\n\n8\n\nFor example, the following ways to write integers satisfy the condition:\n\n101 111\n011 111\n000 011\n\nSample Input 2\n\n4 5\n1 3 1\n2 4 0\n2 3 1\n4 2 1\n4 4 1\n\nSample Output 2\n\n32\n\nSample Input 3\n\n3 5\n1 3 1\n3 3 0\n3 1 0\n2 3 1\n3 2 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n4 8\n1 1 1\n1 2 0\n3 2 1\n1 4 0\n2 1 1\n1 3 0\n3 4 1\n4 4 1\n\nSample Output 4\n\n4\n\nSample Input 5\n\n100000 0\n\nSample Output 5\n\n342016343", "sample_input": "3 3\n1 1 1\n3 1 0\n2 3 1\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03199", "source_text": "Score : 900 points\n\nProblem Statement\n\nTakahashi has an N \\times N grid. The square at the i-th row and the j-th column of the grid is denoted by (i,j).\nParticularly, the top-left square of the grid is (1,1), and the bottom-right square is (N,N).\n\nAn integer, 0 or 1, is written on M of the squares in the Takahashi's grid.\nThree integers a_i,b_i and c_i describe the i-th of those squares with integers written on them: the integer c_i is written on the square (a_i,b_i).\n\nTakahashi decides to write an integer, 0 or 1, on each of the remaining squares so that the condition below is satisfied.\nFind the number of such ways to write integers, modulo 998244353.\n\nFor all 1\\leq i < j\\leq N, there are even number of 1s in the square region whose top-left square is (i,i) and whose bottom-right square is (j,j).\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n0 \\leq M \\leq min(5 \\times 10^4,N^2)\n\n1 \\leq a_i,b_i \\leq N(1\\leq i\\leq M)\n\n0 \\leq c_i \\leq 1(1\\leq i\\leq M)\n\nIf i \\neq j, then (a_i,b_i) \\neq (a_j,b_j).\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 c_1\n:\na_M b_M c_M\n\nOutput\n\nPrint the number of possible ways to write integers, modulo 998244353.\n\nSample Input 1\n\n3 3\n1 1 1\n3 1 0\n2 3 1\n\nSample Output 1\n\n8\n\nFor example, the following ways to write integers satisfy the condition:\n\n101 111\n011 111\n000 011\n\nSample Input 2\n\n4 5\n1 3 1\n2 4 0\n2 3 1\n4 2 1\n4 4 1\n\nSample Output 2\n\n32\n\nSample Input 3\n\n3 5\n1 3 1\n3 3 0\n3 1 0\n2 3 1\n3 2 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n4 8\n1 1 1\n1 2 0\n3 2 1\n1 4 0\n2 1 1\n1 3 0\n3 4 1\n4 4 1\n\nSample Output 4\n\n4\n\nSample Input 5\n\n100000 0\n\nSample Output 5\n\n342016343", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5879, "cpu_time_ms": 320, "memory_kb": 50744}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s352972912", "group_id": "codeNet:p03200", "input_text": "\nimport java.text.DecimalFormat;\nimport java.util.stream.LongStream;\nimport java.util.stream.IntStream;\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n FastScanner sc = new FastScanner();\n PrintWriter out = new PrintWriter(System.out);\n\n AtCoder problem = new AtCoder(sc);\n problem.solve(out);\n\n out.flush();\n }\n\n}\n\nclass AtCoder {\n\n char[] S;\n\n AtCoder(FastScanner sc) {\n S = sc.next().toCharArray();\n }\n\n void solve(PrintWriter out) {\n int cnt = 0;\n long ans = 0;\n for (int i = 0; i < S.length; i++) {\n if (S[i] == 'W') {\n ans += i - cnt;\n cnt++;\n }\n }\n out.println(ans);\n }\n\n}\n\nclass FastScanner {\n\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) {\n return buffer[ptr++];\n } else {\n return -1;\n }\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) {\n ptr++;\n }\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {\n throw new NumberFormatException();\n }\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n\n public int[] arrayInt(int N) {\n int[] array = new int[N];\n for (int i = 0; i < N; i++) {\n array[i] = nextInt();\n }\n return array;\n }\n\n public long[] arrayLong(int N) {\n long[] array = new long[N];\n for (int i = 0; i < N; i++) {\n array[i] = nextLong();\n }\n return array;\n }\n\n public double[] arrayDouble(int N) {\n double[] array = new double[N];\n for (int i = 0; i < N; i++) {\n array[i] = nextDouble();\n }\n return array;\n }\n\n public String[] arrayString(int N) {\n String[] array = new String[N];\n for (int i = 0; i < N; i++) {\n array[i] = next();\n }\n return array;\n }\n}\n\nclass My {\n\n static void ans(boolean b) {\n System.out.println(b ? \"Yes\" : \"No\");\n }\n\n static void ANS(boolean b) {\n System.out.println(b ? \"YES\" : \"NO\");\n }\n\n static String sort(String s) {\n char[] ch = s.toCharArray();\n Arrays.sort(ch);\n return String.valueOf(ch);\n }\n\n static String reverse(String s) {\n return new StringBuilder(s).reverse().toString();\n }\n\n static int[] reverse(int[] array) {\n for (int i = 0; i < array.length / 2; i++) {\n int temp = array[i];\n array[i] = array[array.length - 1 - i];\n array[array.length - 1 - i] = temp;\n }\n return array;\n }\n\n static long[] reverse(long[] array) {\n for (int i = 0; i < array.length / 2; i++) {\n long temp = array[i];\n array[i] = array[array.length - 1 - i];\n array[array.length - 1 - i] = temp;\n }\n return array;\n }\n\n static double[] reverse(double[] array) {\n for (int i = 0; i < array.length / 2; i++) {\n double temp = array[i];\n array[i] = array[array.length - 1 - i];\n array[array.length - 1 - i] = temp;\n }\n return array;\n }\n\n static String[] reverse(String[] array) {\n for (int i = 0; i < array.length / 2; i++) {\n String temp = array[i];\n array[i] = array[array.length - 1 - i];\n array[array.length - 1 - i] = temp;\n }\n return array;\n }\n\n static char[] reverse(char[] array) {\n for (int i = 0; i < array.length / 2; i++) {\n char temp = array[i];\n array[i] = array[array.length - 1 - i];\n array[array.length - 1 - i] = temp;\n }\n return array;\n }\n\n static long min(long... numbers) {\n Arrays.sort(numbers);\n return numbers[0];\n }\n\n static int min(int... numbers) {\n Arrays.sort(numbers);\n return numbers[0];\n }\n\n static double min(double... numbers) {\n Arrays.sort(numbers);\n return numbers[0];\n }\n\n static long max(long... numbers) {\n Arrays.sort(numbers);\n return numbers[numbers.length - 1];\n }\n\n static int max(int... numbers) {\n Arrays.sort(numbers);\n return numbers[numbers.length - 1];\n }\n\n static double max(double... numbers) {\n Arrays.sort(numbers);\n return numbers[numbers.length - 1];\n }\n\n static int sum(long number) {\n int sum = 0;\n while (number > 0) {\n sum += number % 10;\n number /= 10;\n }\n return sum;\n }\n\n}\n", "language": "Java", "metadata": {"date": 1592615997, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p03200.html", "problem_id": "p03200", "resource_group": "high_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/Java/s352972912.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s352972912", "user_id": "u871244227"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\nimport java.text.DecimalFormat;\nimport java.util.stream.LongStream;\nimport java.util.stream.IntStream;\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n FastScanner sc = new FastScanner();\n PrintWriter out = new PrintWriter(System.out);\n\n AtCoder problem = new AtCoder(sc);\n problem.solve(out);\n\n out.flush();\n }\n\n}\n\nclass AtCoder {\n\n char[] S;\n\n AtCoder(FastScanner sc) {\n S = sc.next().toCharArray();\n }\n\n void solve(PrintWriter out) {\n int cnt = 0;\n long ans = 0;\n for (int i = 0; i < S.length; i++) {\n if (S[i] == 'W') {\n ans += i - cnt;\n cnt++;\n }\n }\n out.println(ans);\n }\n\n}\n\nclass FastScanner {\n\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) {\n return buffer[ptr++];\n } else {\n return -1;\n }\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) {\n ptr++;\n }\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {\n throw new NumberFormatException();\n }\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n\n public int[] arrayInt(int N) {\n int[] array = new int[N];\n for (int i = 0; i < N; i++) {\n array[i] = nextInt();\n }\n return array;\n }\n\n public long[] arrayLong(int N) {\n long[] array = new long[N];\n for (int i = 0; i < N; i++) {\n array[i] = nextLong();\n }\n return array;\n }\n\n public double[] arrayDouble(int N) {\n double[] array = new double[N];\n for (int i = 0; i < N; i++) {\n array[i] = nextDouble();\n }\n return array;\n }\n\n public String[] arrayString(int N) {\n String[] array = new String[N];\n for (int i = 0; i < N; i++) {\n array[i] = next();\n }\n return array;\n }\n}\n\nclass My {\n\n static void ans(boolean b) {\n System.out.println(b ? \"Yes\" : \"No\");\n }\n\n static void ANS(boolean b) {\n System.out.println(b ? \"YES\" : \"NO\");\n }\n\n static String sort(String s) {\n char[] ch = s.toCharArray();\n Arrays.sort(ch);\n return String.valueOf(ch);\n }\n\n static String reverse(String s) {\n return new StringBuilder(s).reverse().toString();\n }\n\n static int[] reverse(int[] array) {\n for (int i = 0; i < array.length / 2; i++) {\n int temp = array[i];\n array[i] = array[array.length - 1 - i];\n array[array.length - 1 - i] = temp;\n }\n return array;\n }\n\n static long[] reverse(long[] array) {\n for (int i = 0; i < array.length / 2; i++) {\n long temp = array[i];\n array[i] = array[array.length - 1 - i];\n array[array.length - 1 - i] = temp;\n }\n return array;\n }\n\n static double[] reverse(double[] array) {\n for (int i = 0; i < array.length / 2; i++) {\n double temp = array[i];\n array[i] = array[array.length - 1 - i];\n array[array.length - 1 - i] = temp;\n }\n return array;\n }\n\n static String[] reverse(String[] array) {\n for (int i = 0; i < array.length / 2; i++) {\n String temp = array[i];\n array[i] = array[array.length - 1 - i];\n array[array.length - 1 - i] = temp;\n }\n return array;\n }\n\n static char[] reverse(char[] array) {\n for (int i = 0; i < array.length / 2; i++) {\n char temp = array[i];\n array[i] = array[array.length - 1 - i];\n array[array.length - 1 - i] = temp;\n }\n return array;\n }\n\n static long min(long... numbers) {\n Arrays.sort(numbers);\n return numbers[0];\n }\n\n static int min(int... numbers) {\n Arrays.sort(numbers);\n return numbers[0];\n }\n\n static double min(double... numbers) {\n Arrays.sort(numbers);\n return numbers[0];\n }\n\n static long max(long... numbers) {\n Arrays.sort(numbers);\n return numbers[numbers.length - 1];\n }\n\n static int max(int... numbers) {\n Arrays.sort(numbers);\n return numbers[numbers.length - 1];\n }\n\n static double max(double... numbers) {\n Arrays.sort(numbers);\n return numbers[numbers.length - 1];\n }\n\n static int sum(long number) {\n int sum = 0;\n while (number > 0) {\n sum += number % 10;\n number /= 10;\n }\n return sum;\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": 6475, "cpu_time_ms": 130, "memory_kb": 34668}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s093165869", "group_id": "codeNet:p03200", "input_text": "import static java.lang.System.*;\nimport java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(in);\n\n String s = sc.next();\n\t\t\n\t\tlong ans = 0;\n\t\tlong bc = 0;\n\t\tfor(char c: s.toCharArray()) {\n\t\t\tif(c == 'B') bc++;\n\t\t\telse ans += bc;\n\t\t}\n \n out.println(ans);\n }\n}\n", "language": "Java", "metadata": {"date": 1553574292, "filename_ext": "java", "original_language": "Java7 (OpenJDK 1.7.0)", "problem_description_relpath": "problem_descriptions/p03200.html", "problem_id": "p03200", "resource_group": "high_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/Java/s093165869.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s093165869", "user_id": "u012670428"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import static java.lang.System.*;\nimport java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(in);\n\n String s = sc.next();\n\t\t\n\t\tlong ans = 0;\n\t\tlong bc = 0;\n\t\tfor(char c: s.toCharArray()) {\n\t\t\tif(c == 'B') bc++;\n\t\t\telse ans += bc;\n\t\t}\n \n out.println(ans);\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": 344, "cpu_time_ms": 198, "memory_kb": 25868}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s957639098", "group_id": "codeNet:p03207", "input_text": "import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint a[] = new int[n];\n\t\tfor (int i = 0; i <= n - 1; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\tArrays.sort(a);\n\n\t\ta[n-1] = a[n-1]/2;\n\t\tint sum=0;\n\t\tfor (int i = 0; i <= n - 1; i++) {\n\t\t\tsum+=a[i];\n\t\t}\n\t\tSystem.out.println(sum);\n\t}\n}", "language": "Java", "metadata": {"date": 1562173661, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03207.html", "problem_id": "p03207", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03207/input.txt", "sample_output_relpath": "derived/input_output/data/p03207/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03207/Java/s957639098.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s957639098", "user_id": "u533017901"}, "prompt_components": {"gold_output": "15950\n", "input_to_evaluate": "import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint a[] = new int[n];\n\t\tfor (int i = 0; i <= n - 1; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t}\n\t\tArrays.sort(a);\n\n\t\ta[n-1] = a[n-1]/2;\n\t\tint sum=0;\n\t\tfor (int i = 0; i <= n - 1; i++) {\n\t\t\tsum+=a[i];\n\t\t}\n\t\tSystem.out.println(sum);\n\t}\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn some other world, today is the day before Christmas Eve.\n\nMr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \\leq i \\leq N) is p_i yen (the currency of Japan).\n\nHe has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?\n\nConstraints\n\n2 \\leq N \\leq 10\n\n100 \\leq p_i \\leq 10000\n\np_i is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1\np_2\n:\np_N\n\nOutput\n\nPrint the total amount Mr. Takaha will pay.\n\nSample Input 1\n\n3\n4980\n7980\n6980\n\nSample Output 1\n\n15950\n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 = 15950 yen.\n\nNote that outputs such as 15950.0 will be judged as Wrong Answer.\n\nSample Input 2\n\n4\n4320\n4320\n4320\n4320\n\nSample Output 2\n\n15120\n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320 + 4320 + 4320 = 15120 yen.", "sample_input": "3\n4980\n7980\n6980\n"}, "reference_outputs": ["15950\n"], "source_document_id": "p03207", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn some other world, today is the day before Christmas Eve.\n\nMr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \\leq i \\leq N) is p_i yen (the currency of Japan).\n\nHe has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?\n\nConstraints\n\n2 \\leq N \\leq 10\n\n100 \\leq p_i \\leq 10000\n\np_i is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1\np_2\n:\np_N\n\nOutput\n\nPrint the total amount Mr. Takaha will pay.\n\nSample Input 1\n\n3\n4980\n7980\n6980\n\nSample Output 1\n\n15950\n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 = 15950 yen.\n\nNote that outputs such as 15950.0 will be judged as Wrong Answer.\n\nSample Input 2\n\n4\n4320\n4320\n4320\n4320\n\nSample Output 2\n\n15120\n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320 + 4320 + 4320 = 15120 yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 95, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s998186954", "group_id": "codeNet:p03209", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n public static int heightOfBurger(int level) {\n if (level == 0) {\n return 1;\n } else {\n return heightOfBurger(level - 1) * 2 + 3;\n }\n }\n\n public static int numberOfPatty(int level) {\n if (level == 0) {\n return 1;\n } else {\n return numberOfPatty(level - 1) * 2 + 1;\n }\n }\n\n public static int answer(int level, int layer) {\n if (layer == 1) {\n return 0;\n } else if (layer < heightOfBurger(level - 1) + 1) {\n return answer(level - 1, layer - 1);\n } else if (layer == heightOfBurger(level - 1) + 2) {\n return numberOfPatty(level - 1) + 1;\n } else if (layer < heightOfBurger(level - 1) * 2 + 2) {\n return numberOfPatty(level - 1) + 1 + answer(level - 1, layer - heightOfBurger(level - 1) - 2);\n } else {\n return numberOfPatty(level);\n }\n }\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int level = sc.nextInt();\n int layer = sc.nextInt();\n System.out.println(answer(level, layer));\n }\n}\n", "language": "Java", "metadata": {"date": 1544997366, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03209.html", "problem_id": "p03209", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03209/input.txt", "sample_output_relpath": "derived/input_output/data/p03209/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03209/Java/s998186954.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s998186954", "user_id": "u003018968"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n public static int heightOfBurger(int level) {\n if (level == 0) {\n return 1;\n } else {\n return heightOfBurger(level - 1) * 2 + 3;\n }\n }\n\n public static int numberOfPatty(int level) {\n if (level == 0) {\n return 1;\n } else {\n return numberOfPatty(level - 1) * 2 + 1;\n }\n }\n\n public static int answer(int level, int layer) {\n if (layer == 1) {\n return 0;\n } else if (layer < heightOfBurger(level - 1) + 1) {\n return answer(level - 1, layer - 1);\n } else if (layer == heightOfBurger(level - 1) + 2) {\n return numberOfPatty(level - 1) + 1;\n } else if (layer < heightOfBurger(level - 1) * 2 + 2) {\n return numberOfPatty(level - 1) + 1 + answer(level - 1, layer - heightOfBurger(level - 1) - 2);\n } else {\n return numberOfPatty(level);\n }\n }\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int level = sc.nextInt();\n int layer = sc.nextInt();\n System.out.println(answer(level, layer));\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nIn some other world, today is Christmas.\n\nMr. Takaha decides to make a multi-dimensional burger in his party. A level-L burger (L is an integer greater than or equal to 0) is the following thing:\n\nA level-0 burger is a patty.\n\nA level-L burger (L \\geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.\n\nFor example, a level-1 burger and a level-2 burger look like BPPPB and BBPPPBPBPPPBB (rotated 90 degrees), where B and P stands for a bun and a patty.\n\nThe burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq X \\leq ( the total number of layers in a level-N burger )\n\nN and X are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\n\nOutput\n\nPrint the number of patties in the bottom-most X layers from the bottom of a level-N burger.\n\nSample Input 1\n\n2 7\n\nSample Output 1\n\n4\n\nThere are 4 patties in the bottom-most 7 layers of a level-2 burger (BBPPPBPBPPPBB).\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\n0\n\nThe bottom-most layer of a level-1 burger is a bun.\n\nSample Input 3\n\n50 4321098765432109\n\nSample Output 3\n\n2160549382716056\n\nA level-50 burger is rather thick, to the extent that the number of its layers does not fit into a 32-bit integer.", "sample_input": "2 7\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03209", "source_text": "Score : 400 points\n\nProblem Statement\n\nIn some other world, today is Christmas.\n\nMr. Takaha decides to make a multi-dimensional burger in his party. A level-L burger (L is an integer greater than or equal to 0) is the following thing:\n\nA level-0 burger is a patty.\n\nA level-L burger (L \\geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.\n\nFor example, a level-1 burger and a level-2 burger look like BPPPB and BBPPPBPBPPPBB (rotated 90 degrees), where B and P stands for a bun and a patty.\n\nThe burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq X \\leq ( the total number of layers in a level-N burger )\n\nN and X are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\n\nOutput\n\nPrint the number of patties in the bottom-most X layers from the bottom of a level-N burger.\n\nSample Input 1\n\n2 7\n\nSample Output 1\n\n4\n\nThere are 4 patties in the bottom-most 7 layers of a level-2 burger (BBPPPBPBPPPBB).\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\n0\n\nThe bottom-most layer of a level-1 burger is a bun.\n\nSample Input 3\n\n50 4321098765432109\n\nSample Output 3\n\n2160549382716056\n\nA level-50 burger is rather thick, to the extent that the number of its layers does not fit into a 32-bit integer.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1067, "cpu_time_ms": 118, "memory_kb": 22100}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s533125648", "group_id": "codeNet:p03211", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString s = sc.next();\n\t\tchar[] c = s.toCharArray();\n\t\tint ans = 753;\n\t\tfor (int i = 0; i < c.length - 2; i++) {\n\t\t\tint x = (c[i] - '0') * 100 + (c[i + 1] - '0') * 10 + (c[i + 2] - '0');\n\t\t\tans = Math.min(ans, Math.abs(753 - x));\n\t\t}\n\t\tSystem.out.println(ans);\n\t\tsc.close();\n\t}\n}", "language": "Java", "metadata": {"date": 1571601792, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03211.html", "problem_id": "p03211", "resource_group": "high_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/Java/s533125648.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s533125648", "user_id": "u849975039"}, "prompt_components": {"gold_output": "34\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString s = sc.next();\n\t\tchar[] c = s.toCharArray();\n\t\tint ans = 753;\n\t\tfor (int i = 0; i < c.length - 2; i++) {\n\t\t\tint x = (c[i] - '0') * 100 + (c[i + 1] - '0') * 10 + (c[i + 2] - '0');\n\t\t\tans = Math.min(ans, Math.abs(753 - x));\n\t\t}\n\t\tSystem.out.println(ans);\n\t\tsc.close();\n\t}\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": 426, "cpu_time_ms": 92, "memory_kb": 21588}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s233360055", "group_id": "codeNet:p03212", "input_text": "import java.util.*;\nimport java.awt.*;\nimport static java.lang.System.*;\nimport static java.lang.Math.*;\npublic class Main {\n public static void main(String[]$){\n Scanner sc = new Scanner(in);\n int n=sc.nextInt();\n long k=0;\n if(n<357){\n out.println(0);\n }else{\n int order=2;\n for (int i = 357; i <= n; i++) {\n if(9990){\n int l=t%10;\n if(l==3)++n3;\n if(l==5)++n5;\n if(l==7)++n7;\n t/=10;\n ++c;\n }\n if(n3+n5+n7==c&&n3>0&&n5>0&&n7>0){\n ++k;\n }\n }\n out.println(k);\n }\n }\n static long power(long x,int n){\n long mod=1000000007;\n long ans=1;\n while (n>0) {\n if((n&1)==1){\n ans=(ans*x)%mod;\n }\n x=(x*x)%mod;\n n>>=1;\n }\n return ans;\n }\n //最大公約数\n static int gcd (int a, int b) {\n int temp;\n while((temp = a%b)!=0) {\n a = b;\n b = temp;\n }\n return b;\n }\n//※最小公倍数はa*b/gcd(a,b)である\n}\n", "language": "Java", "metadata": {"date": 1543806986, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03212.html", "problem_id": "p03212", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03212/input.txt", "sample_output_relpath": "derived/input_output/data/p03212/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03212/Java/s233360055.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s233360055", "user_id": "u881037761"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*;\nimport java.awt.*;\nimport static java.lang.System.*;\nimport static java.lang.Math.*;\npublic class Main {\n public static void main(String[]$){\n Scanner sc = new Scanner(in);\n int n=sc.nextInt();\n long k=0;\n if(n<357){\n out.println(0);\n }else{\n int order=2;\n for (int i = 357; i <= n; i++) {\n if(9990){\n int l=t%10;\n if(l==3)++n3;\n if(l==5)++n5;\n if(l==7)++n7;\n t/=10;\n ++c;\n }\n if(n3+n5+n7==c&&n3>0&&n5>0&&n7>0){\n ++k;\n }\n }\n out.println(k);\n }\n }\n static long power(long x,int n){\n long mod=1000000007;\n long ans=1;\n while (n>0) {\n if((n&1)==1){\n ans=(ans*x)%mod;\n }\n x=(x*x)%mod;\n n>>=1;\n }\n return ans;\n }\n //最大公約数\n static int gcd (int a, int b) {\n int temp;\n while((temp = a%b)!=0) {\n a = b;\n b = temp;\n }\n return b;\n }\n//※最小公倍数はa*b/gcd(a,b)である\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally \"Seven-Five-Three numbers\") are there?\n\nHere, a Shichi-Go-San number is a positive integer that satisfies the following condition:\n\nWhen the number is written in base ten, each of the digits 7, 5 and 3 appears at least once, and the other digits never appear.\n\nConstraints\n\n1 \\leq N < 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the Shichi-Go-San numbers between 1 and N (inclusive).\n\nSample Input 1\n\n575\n\nSample Output 1\n\n4\n\nThere are four Shichi-Go-San numbers not greater than 575: 357, 375, 537 and 573.\n\nSample Input 2\n\n3600\n\nSample Output 2\n\n13\n\nThere are 13 Shichi-Go-San numbers not greater than 3600: the above four numbers, 735, 753, 3357, 3375, 3537, 3557, 3573, 3575 and 3577.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n26484", "sample_input": "575\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03212", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally \"Seven-Five-Three numbers\") are there?\n\nHere, a Shichi-Go-San number is a positive integer that satisfies the following condition:\n\nWhen the number is written in base ten, each of the digits 7, 5 and 3 appears at least once, and the other digits never appear.\n\nConstraints\n\n1 \\leq N < 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the Shichi-Go-San numbers between 1 and N (inclusive).\n\nSample Input 1\n\n575\n\nSample Output 1\n\n4\n\nThere are four Shichi-Go-San numbers not greater than 575: 357, 375, 537 and 573.\n\nSample Input 2\n\n3600\n\nSample Output 2\n\n13\n\nThere are 13 Shichi-Go-San numbers not greater than 3600: the above four numbers, 735, 753, 3357, 3375, 3537, 3557, 3573, 3575 and 3577.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n26484", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2029, "cpu_time_ms": 2108, "memory_kb": 25556}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s764789177", "group_id": "codeNet:p03217", "input_text": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.InputMismatchException;\nimport java.util.Map;\nimport java.util.NoSuchElementException;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tIO io = new IO();\n\t\tint n = io.nextInt();\n\t\tint d = io.nextInt();\n\t\tHashMap hm = new HashMap<>();\n\t\tfor(int i=0;i hm, long a) {\n\t\tint big = 0;\n\t\tfor(int c : hm.values()) {\n\t\t\twhile(big * big < c) {\n\t\t\t\tbig++;\n\t\t\t}\n\t\t}\n\t\tLOOP: for(int x=0;x hs = new HashSet<>();\n\t\t\tfor(Map.Entry e: hm.entrySet()) {\n\t\t\t\tint p = e.getKey();\n\t\t\t\tint x2 = p / 1000;\n\t\t\t\tint y2 = p % 1000;\n\t\t\t\tint x3 = (x2 - x + d) % d;\n\t\t\t\t//int y3 = (y2 - y + d) % d;\n\n\t\t\t\tint count = e.getValue();\n\t\t\t\tlong shorter = (int) Math.sqrt(count);\n\t\t\t\tlong longer = shorter;\n\t\t\t\tif (shorter * longer < count) {\n\t\t\t\t\tlonger++;\n\t\t\t\t\tif (shorter * longer < count) {\n\t\t\t\t\t\tshorter++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tlong x4l = x3 + d * (longer - 1);\n\t\t\t\tlong x4s = x3 + d * (shorter - 1);\n\t\t\t\tif (x4s > a) {\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\t}else if(x4l > a) {\n\t\t\t\t\tif (longer == big) {\n\t\t\t\t\t\ths.add(y2);\n\t\t\t\t\t}\n\t\t\t\t}else{\n\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (hs.size() <= 1) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tArrayList al = new ArrayList<>(hs);\n\t\t\tal.sort(null);\n\t\t\tint max = al.get(0) - al.get(al.size()-1) + d;\n\t\t\tfor(int i=0;i Integer.MAX_VALUE) {\n\t\t\tthrow new NumberFormatException();\n\t\t}\n\t\treturn (int) nl;\n\t}\n\tpublic char nextChar() {\n\t\tif (!hasNext()) {\n\t\t\tthrow new NoSuchElementException();\n\t\t}\n\t\treturn (char) readByte();\n\t}\n\tpublic double nextDouble() { return Double.parseDouble(next());}\n\tpublic int[] nextIntArray(int n) { int[] a = new int[n]; for(int i=0;i hm = new HashMap<>();\n\t\tfor(int i=0;i hm, long a) {\n\t\tint big = 0;\n\t\tfor(int c : hm.values()) {\n\t\t\twhile(big * big < c) {\n\t\t\t\tbig++;\n\t\t\t}\n\t\t}\n\t\tLOOP: for(int x=0;x hs = new HashSet<>();\n\t\t\tfor(Map.Entry e: hm.entrySet()) {\n\t\t\t\tint p = e.getKey();\n\t\t\t\tint x2 = p / 1000;\n\t\t\t\tint y2 = p % 1000;\n\t\t\t\tint x3 = (x2 - x + d) % d;\n\t\t\t\t//int y3 = (y2 - y + d) % d;\n\n\t\t\t\tint count = e.getValue();\n\t\t\t\tlong shorter = (int) Math.sqrt(count);\n\t\t\t\tlong longer = shorter;\n\t\t\t\tif (shorter * longer < count) {\n\t\t\t\t\tlonger++;\n\t\t\t\t\tif (shorter * longer < count) {\n\t\t\t\t\t\tshorter++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tlong x4l = x3 + d * (longer - 1);\n\t\t\t\tlong x4s = x3 + d * (shorter - 1);\n\t\t\t\tif (x4s > a) {\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\t}else if(x4l > a) {\n\t\t\t\t\tif (longer == big) {\n\t\t\t\t\t\ths.add(y2);\n\t\t\t\t\t}\n\t\t\t\t}else{\n\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (hs.size() <= 1) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tArrayList al = new ArrayList<>(hs);\n\t\t\tal.sort(null);\n\t\t\tint max = al.get(0) - al.get(al.size()-1) + d;\n\t\t\tfor(int i=0;i Integer.MAX_VALUE) {\n\t\t\tthrow new NumberFormatException();\n\t\t}\n\t\treturn (int) nl;\n\t}\n\tpublic char nextChar() {\n\t\tif (!hasNext()) {\n\t\t\tthrow new NoSuchElementException();\n\t\t}\n\t\treturn (char) readByte();\n\t}\n\tpublic double nextDouble() { return Double.parseDouble(next());}\n\tpublic int[] nextIntArray(int n) { int[] a = new int[n]; for(int i=0;i> dic = new HashMap<>();\n\t\tList toi = new ArrayList<>();\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tint x = sc.nextInt();\n\t\t\tlong y = sc.nextLong();\n\t\t\ttoi.add(new Pair(x, y));\n\t\t\tList list = dic.getOrDefault(x, new ArrayList<>());\n\t\t\tlist.add(y);\n\t\t\tdic.put(x, list);\n\t\t}\n\n\t\tMap sortDic = new HashMap<>();\n\t\tdic.entrySet().stream().forEach(e -> {\n\t\t\tLong[] tmp = e.getValue().toArray(new Long[e.getValue().size()]);\n\t\t\tArrays.sort(tmp);\n\t\t\tsortDic.put(e.getKey(), tmp);\n\t\t});\n\n\t\tfor (int i = 0; i < toi.size(); i++) {\n\t\t\tPair mon = toi.get(i);\n\t\t\tString x = String.valueOf(mon.x);\n\t\t\tString paddingleft = x.format(\"%6s\", x).replace(\" \", \"0\");\n\t\t\tString index = String.valueOf(Arrays.binarySearch(sortDic.get(mon.x), mon.y) + 1);\n\t\t\tString paddingRight = index.format(\"%6s\", index).replace(\" \", \"0\");\n\t\t\tout.println(paddingleft + paddingRight);\n\t\t}\n\n\t}\n\n\tstatic class Pair {\n\t\tpublic int x;\n\t\tpublic long y;\n\n\t\tpublic Pair(int x, long y) {\n\t\t\tthis.x = x;\n\t\t\tthis.y = y;\n\t\t}\n\t}\n\n\tstatic class FastReader {\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\n\t\tpublic FastReader() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\n\t\tString next() {\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\t}\n}\n", "language": "Java", "metadata": {"date": 1559690727, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03221.html", "problem_id": "p03221", "resource_group": "high_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/Java/s247213148.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s247213148", "user_id": "u626217867"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.PrintWriter;\nimport java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tFastReader sc = new FastReader();\n\t\tPrintWriter out = new PrintWriter(System.out);\n\t\tint n = sc.nextInt();\n\t\tint m = sc.nextInt();\n\n\t\tMap> dic = new HashMap<>();\n\t\tList toi = new ArrayList<>();\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tint x = sc.nextInt();\n\t\t\tlong y = sc.nextLong();\n\t\t\ttoi.add(new Pair(x, y));\n\t\t\tList list = dic.getOrDefault(x, new ArrayList<>());\n\t\t\tlist.add(y);\n\t\t\tdic.put(x, list);\n\t\t}\n\n\t\tMap sortDic = new HashMap<>();\n\t\tdic.entrySet().stream().forEach(e -> {\n\t\t\tLong[] tmp = e.getValue().toArray(new Long[e.getValue().size()]);\n\t\t\tArrays.sort(tmp);\n\t\t\tsortDic.put(e.getKey(), tmp);\n\t\t});\n\n\t\tfor (int i = 0; i < toi.size(); i++) {\n\t\t\tPair mon = toi.get(i);\n\t\t\tString x = String.valueOf(mon.x);\n\t\t\tString paddingleft = x.format(\"%6s\", x).replace(\" \", \"0\");\n\t\t\tString index = String.valueOf(Arrays.binarySearch(sortDic.get(mon.x), mon.y) + 1);\n\t\t\tString paddingRight = index.format(\"%6s\", index).replace(\" \", \"0\");\n\t\t\tout.println(paddingleft + paddingRight);\n\t\t}\n\n\t}\n\n\tstatic class Pair {\n\t\tpublic int x;\n\t\tpublic long y;\n\n\t\tpublic Pair(int x, long y) {\n\t\t\tthis.x = x;\n\t\t\tthis.y = y;\n\t\t}\n\t}\n\n\tstatic class FastReader {\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\n\t\tpublic FastReader() {\n\t\t\tbr = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\n\t\tString next() {\n\t\t\twhile (st == null || !st.hasMoreElements()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\tString str = \"\";\n\t\t\ttry {\n\t\t\t\tstr = br.readLine();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn str;\n\t\t}\n\t}\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": 2089, "cpu_time_ms": 1589, "memory_kb": 181900}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s125773881", "group_id": "codeNet:p03221", "input_text": "\n\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.util.Arrays;\n\npublic class Main {\n\tprivate static boolean ispf = false;\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(\n\t\t\t\tnew InputStreamReader(Main.class.getResourceAsStream(\"/data.txt\")));\n\t\t//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString[] systemInLine = br.readLine().split(\" \");\n\t\tint provinceCount = Integer.parseInt(systemInLine[0]);\n\t\tint cityCount = Integer.parseInt(systemInLine[1]);\n\t\tpf(\"辖区总数:\" + provinceCount + \" 城市总数:\" + cityCount);\n\n\t\t\n\t\t/**\n\t\t * 所有的城市\n\t\t */\n\t\t\n\t\t//城市数组,0:省份,1:年份,2:输入顺序号,4:年份序号\n\t\tint[][] proviceCityArray = new int[cityCount][4];\n\n\t\tfor (int i = 0; i < cityCount; i++) {\n\t\t\tsystemInLine = br.readLine().split(\" \");\n\t\t\tint provinceIndex = Integer.parseInt(systemInLine[0]);\n\t\t\tint cityCreateYear = Integer.parseInt(systemInLine[1]);\n\t\t\tproviceCityArray[i][0]= provinceIndex;\n\t\t\tproviceCityArray[i][1]= cityCreateYear;\n\t\t\tproviceCityArray[i][2]= i+1;\n\t\t}\n\t\tbr.close();\n\t\t\n\t\t\n\t\t\n\t\t/**\n\t\t * 这次排序后辖区和年份已经排序了\n\t\t */\n\t\n\t\tArrays.sort(proviceCityArray,(o1, o2) -> (o1[0] == o2[0]) ? (o1[1] - o2[1]) : (o1[0] - o2[0]));\n\t\t\n\t\tfor (int i = 0; i < proviceCityArray.length; i++) {\n\t\t\tif(i==0) {\n\t\t\t\tproviceCityArray[i][3] = 1;\n\t\t\t}else {\n\t\t\t\tif((proviceCityArray[i][0] == proviceCityArray[i - 1][0])) {//于上一次比较\n\t\t\t\t\tproviceCityArray[i][3] = proviceCityArray[i - 1][3] + 1;\n\t\t\t\t}else {\n\t\t\t\t\tproviceCityArray[i][3] = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * 再次排序拍会回来\n\t\t */\n\t\t Arrays.sort(proviceCityArray, (o1, o2) -> o1[2] - o2[2]);\n\t\t\n\t\tfor (int i = 0; i < proviceCityArray.length; i++) {\n\t\t\tSystem.out.println(String.format(\"%06d\", proviceCityArray[i][0])+String.format(\"%06d\", proviceCityArray[i][3]));\n\t\t}\n\t\t\n\t}\n\n\tpublic static void pf(String s) {\n\t\tif (ispf) {\n\t\t\tSystem.out.println(s);\n\t\t}\n\t}\n}\n", "language": "Java", "metadata": {"date": 1543875918, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03221.html", "problem_id": "p03221", "resource_group": "high_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/Java/s125773881.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s125773881", "user_id": "u726792545"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "\n\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.util.Arrays;\n\npublic class Main {\n\tprivate static boolean ispf = false;\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(\n\t\t\t\tnew InputStreamReader(Main.class.getResourceAsStream(\"/data.txt\")));\n\t\t//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString[] systemInLine = br.readLine().split(\" \");\n\t\tint provinceCount = Integer.parseInt(systemInLine[0]);\n\t\tint cityCount = Integer.parseInt(systemInLine[1]);\n\t\tpf(\"辖区总数:\" + provinceCount + \" 城市总数:\" + cityCount);\n\n\t\t\n\t\t/**\n\t\t * 所有的城市\n\t\t */\n\t\t\n\t\t//城市数组,0:省份,1:年份,2:输入顺序号,4:年份序号\n\t\tint[][] proviceCityArray = new int[cityCount][4];\n\n\t\tfor (int i = 0; i < cityCount; i++) {\n\t\t\tsystemInLine = br.readLine().split(\" \");\n\t\t\tint provinceIndex = Integer.parseInt(systemInLine[0]);\n\t\t\tint cityCreateYear = Integer.parseInt(systemInLine[1]);\n\t\t\tproviceCityArray[i][0]= provinceIndex;\n\t\t\tproviceCityArray[i][1]= cityCreateYear;\n\t\t\tproviceCityArray[i][2]= i+1;\n\t\t}\n\t\tbr.close();\n\t\t\n\t\t\n\t\t\n\t\t/**\n\t\t * 这次排序后辖区和年份已经排序了\n\t\t */\n\t\n\t\tArrays.sort(proviceCityArray,(o1, o2) -> (o1[0] == o2[0]) ? (o1[1] - o2[1]) : (o1[0] - o2[0]));\n\t\t\n\t\tfor (int i = 0; i < proviceCityArray.length; i++) {\n\t\t\tif(i==0) {\n\t\t\t\tproviceCityArray[i][3] = 1;\n\t\t\t}else {\n\t\t\t\tif((proviceCityArray[i][0] == proviceCityArray[i - 1][0])) {//于上一次比较\n\t\t\t\t\tproviceCityArray[i][3] = proviceCityArray[i - 1][3] + 1;\n\t\t\t\t}else {\n\t\t\t\t\tproviceCityArray[i][3] = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * 再次排序拍会回来\n\t\t */\n\t\t Arrays.sort(proviceCityArray, (o1, o2) -> o1[2] - o2[2]);\n\t\t\n\t\tfor (int i = 0; i < proviceCityArray.length; i++) {\n\t\t\tSystem.out.println(String.format(\"%06d\", proviceCityArray[i][0])+String.format(\"%06d\", proviceCityArray[i][3]));\n\t\t}\n\t\t\n\t}\n\n\tpublic static void pf(String s) {\n\t\tif (ispf) {\n\t\t\tSystem.out.println(s);\n\t\t}\n\t}\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": 2017, "cpu_time_ms": 82, "memory_kb": 23124}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s463216854", "group_id": "codeNet:p03221", "input_text": "import java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Scanner;\nimport java.util.TreeMap;\n\npublic class Main {\n\t@SuppressWarnings(\"resource\")\n\tpublic static void main(String args[]) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tint m=scanner.nextInt();\n\t\tint p[]=new int[m];\n\t\tint y[]=new int[m];\n\t\tMap>map=new TreeMap<>();\n\t\tfor(int i=0;ilist=new ArrayList<>();\n\t\t\t\tlist.add(y[i]);\n\t\t\t\tmap.put(p[i], list);\n\t\t\t}\n\t\t}\n\t\t/*for(List list:map.values()) {\n\t\t\tCollections.sort(list);\n\t\t}*/\n\t\tfor(int i=0;i list, int val) {\n\t\treturn ~Collections.binarySearch(list, val, (x, y) -> x.compareTo(y) >= 0 ? 1 : -1) - 1;\n\t}\n}\n\nclass IComparator implements Comparator {\n\t@Override\n\tpublic int compare(Integer o1, Integer o2) {\n\t\tif (o1 > o2) {\n\t\t\treturn 1;\n\t\t} else if (o1 < o2) {\n\t\t\treturn -1;\n\t\t} else {\n\t\t\treturn 0;\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1541398246, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03221.html", "problem_id": "p03221", "resource_group": "high_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/Java/s463216854.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s463216854", "user_id": "u367107084"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Scanner;\nimport java.util.TreeMap;\n\npublic class Main {\n\t@SuppressWarnings(\"resource\")\n\tpublic static void main(String args[]) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tint m=scanner.nextInt();\n\t\tint p[]=new int[m];\n\t\tint y[]=new int[m];\n\t\tMap>map=new TreeMap<>();\n\t\tfor(int i=0;ilist=new ArrayList<>();\n\t\t\t\tlist.add(y[i]);\n\t\t\t\tmap.put(p[i], list);\n\t\t\t}\n\t\t}\n\t\t/*for(List list:map.values()) {\n\t\t\tCollections.sort(list);\n\t\t}*/\n\t\tfor(int i=0;i list, int val) {\n\t\treturn ~Collections.binarySearch(list, val, (x, y) -> x.compareTo(y) >= 0 ? 1 : -1) - 1;\n\t}\n}\n\nclass IComparator implements Comparator {\n\t@Override\n\tpublic int compare(Integer o1, Integer o2) {\n\t\tif (o1 > o2) {\n\t\t\treturn 1;\n\t\t} else if (o1 < o2) {\n\t\t\treturn -1;\n\t\t} else {\n\t\t\treturn 0;\n\t\t}\n\t}\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": 1399, "cpu_time_ms": 2111, "memory_kb": 149664}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s717500631", "group_id": "codeNet:p03221", "input_text": "import java.util.*;\nimport java.awt.*;\nimport static java.lang.System.*;\nimport static java.lang.Math.*;\n//Loopで使う文字列の長さは固定!\n//intで大丈夫?オーバーフローしない?\n//Loop回数は本当に10⁹以内になってる?Loopは回る??\npublic class Main {\n public static void main(String[]$){\n Scanner sc = new Scanner(in);\n int n=sc.nextInt();\n int m=sc.nextInt();\n int[] p=new int[m];\n int[] y=new int[m];\n HashMap map=new HashMap<>();\n HashMap YtoM=new HashMap<>();\n TreeMap tm=new TreeMap<>();\n for (int i = 0; i < m; i++) {\n p[i]=sc.nextInt();\n y[i]=sc.nextInt();\n tm.put(y[i],p[i]);\n map.put(p[i],1);\n YtoM.put(y[i],i);\n }\n String[] ans=new String[m];\n for(int k:tm.keySet()){\n String left=\"\";\n String right=\"\";\n left=Integer.toString(tm.get(k));\n int length=left.length();\n for (int i = 0; i <6-length; i++) {\n left=\"0\"+left;\n }\n right=Integer.toString(map.get(tm.get(k)));\n length=right.length();\n for (int i = 0; i <6-length; i++) {\n right=\"0\"+right;\n }\n map.put(tm.get(k),map.get(tm.get(k))+1);\n ans[YtoM.get(k)]=left+right;\n }\n for (int i = 0; i < m; i++) {\n out.println(ans[i]);\n }\n }\n}", "language": "Java", "metadata": {"date": 1541385687, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03221.html", "problem_id": "p03221", "resource_group": "high_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/Java/s717500631.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s717500631", "user_id": "u881037761"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "import java.util.*;\nimport java.awt.*;\nimport static java.lang.System.*;\nimport static java.lang.Math.*;\n//Loopで使う文字列の長さは固定!\n//intで大丈夫?オーバーフローしない?\n//Loop回数は本当に10⁹以内になってる?Loopは回る??\npublic class Main {\n public static void main(String[]$){\n Scanner sc = new Scanner(in);\n int n=sc.nextInt();\n int m=sc.nextInt();\n int[] p=new int[m];\n int[] y=new int[m];\n HashMap map=new HashMap<>();\n HashMap YtoM=new HashMap<>();\n TreeMap tm=new TreeMap<>();\n for (int i = 0; i < m; i++) {\n p[i]=sc.nextInt();\n y[i]=sc.nextInt();\n tm.put(y[i],p[i]);\n map.put(p[i],1);\n YtoM.put(y[i],i);\n }\n String[] ans=new String[m];\n for(int k:tm.keySet()){\n String left=\"\";\n String right=\"\";\n left=Integer.toString(tm.get(k));\n int length=left.length();\n for (int i = 0; i <6-length; i++) {\n left=\"0\"+left;\n }\n right=Integer.toString(map.get(tm.get(k)));\n length=right.length();\n for (int i = 0; i <6-length; i++) {\n right=\"0\"+right;\n }\n map.put(tm.get(k),map.get(tm.get(k))+1);\n ans[YtoM.get(k)]=left+right;\n }\n for (int i = 0; i < m; i++) {\n out.println(ans[i]);\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": 1530, "cpu_time_ms": 1568, "memory_kb": 126276}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s935855162", "group_id": "codeNet:p03232", "input_text": "/*\n......................................................................................................................................\n..................................... ________ ____ __________________________________________ .....................................\n..................................... / _____/| | \\ \\__ ___/\\_ _____/\\______ \\.....................................\n...................................../ \\ ___| | / | \\| | | __)_ | _/.....................................\n.....................................\\ \\_\\ \\ | / | \\ | | \\ | | \\.....................................\n..................................... \\______ /______/\\____|__ /____| /_______ / |____|_ /.....................................\n..................................... \\/ \\/ \\/ \\/ .....................................\n......................................................................................................................................\n.............................................................,;'';:...................................................................\n........................................................+@@@@@@@@@@@@@@'..............................................................\n.....................................................#@@@##############@@@:...........................................................\n...................................................@@@####################@@,.........................................................\n.................................................@@#########################@@........................................................\n...............................................:@############################@@.......................................................\n..............................................@@######@@@#';;'#@@@############@@:.....................................................\n.............................................@#####@@,````````````,@@###########@:....................................................\n............................................@####@;``````````````````+@##########@....................................................\n...........................................@###@:``````````````````````#@########@@...................................................\n..........................................@####``````````````````````````@########@@..................................................\n.........................................###@.````````````````````````````@########@+.................................................\n.........................................@#@```````````````````````````````#########@.................................................\n........................................@#@`````````````````````````````````########@@................................................\n.......................................,@@```````````````````````````````````@#######@:...............................................\n.......................................@@`````````````````````````````````````@#######@...............................................\n.......................................@:````````````````````#@@'``````````````@######@+..............................................\n......................................#@```````````````````@@@@@@@#````````````########@..............................................\n......................................@```````````````````@@@@@@@@@@````````````@######@+.............................................\n......................................@``````````````````@@@@@@@+ +```````````+#######@.............................................\n.....................................;:``````````````````@@@@@@@ @````````````@######@'............................................\n.....................................@``````````````````:@@@@@@@ @````````````@#######@............................................\n.....................................@```,@@@#``````````;@@@@@@@ @````````````:#######@:...........................................\n.....................................@``@@@@@@@@````````.@@@@@@@# ,#`````````````@#######@...........................................\n.....................................@`@@@@@@@+'@````````@@@@@@@@@@@``````````````@#######@...........................................\n.....................................@,@@@@@@ ,```:+:``:@@@@@@@@@.``````````````@########@..........................................\n.....................................#@@@@@@@ ;@@#;,,,@``:@@@@@@@````````````````#########@..........................................\n.....................................+@@@@@@@@',,,,,,,,;,```.'+;``````````````````'########@;.........................................\n.....................................'@@@@',,,,,,,,,,,,,@`````````````````````````:#########@.........................................\n....................................:@#,,,,,:;;;;;:,,,,,@`````````````````````````.#########@.........................................\n.................................:@#@@@@#++';;;;;;;;;;;;@``````````````````````````##########+........................................\n...............................#@#+;;;;;;;;;;;;;;;;;;;;':``````````````````````````##########@........................................\n....................................,@#@@@@@#+'';;;;;+@#```````````````````````````##########@........................................\n.....................................@``````````.,,,.``````````````````````````````############.......................................\n.....................................@`````````````````````````````````````````````#######+'+#@.......................................\n.....................................@`````````````````````````````````````````````##########'@.......................................\n.....................................#`````````````````````````````````````````````############@#.....................................\n.....................................:.````````````````````````````````````````````##############@,...................................\n......................................+```````````````````````````````````````````.###############@#..................................\n......................................@```````````````````````````````````````````.################@@.................................\n......................................@```````````````````````````````````````````.###+##############@................................\n......................................@```````````````````````````````````````````.###+###############@...............................\n......................................',``````````````````````````````````````````.####'##############@@..............................\n.......................................@```````````````````````````````````````````#####+##############@:.............................\n.......................................@```````````````````````````````````````````#####'###############@.............................\n.......................................@```````````````````````````````````````````######'################............................\n.......................................#,``````````````````````````````````````````#######'##############@............................\n........................................@``````````````````````````````````````````@######++##############+...........................\n........................................@``````````````````````````````````````````@#######'##############@...........................\n........................................@``````````````````````````````````````````@########'#############@...........................\n.......................................@#'`````````````````````````````````````````@#########'##############..........................\n.......................................@#@`````````````````````````````````````````+#########+'############@..........................\n......................................@##@`````````````````````````````````````````.##########+'###########@..........................\n......................................@##@:`````````````````````````````````````````###########+'###########..........................\n.....................................:@###@`````````````````````````````````````````@###########+'+#########,.........................\n.....................................@####@`````````````````````````````````````````@#############''########..........................\n.....................................@####@.````````````````````````````````````````;##############+'######@..........................\n.....................................@#####@`````````````````````````````````````````################@@@###+..........................\n.....................................@#####@`````````````````````````````````````````@###############@..;;............................\n....................................,@#####@.````````````````````````````````````````+################'...............................\n....................................:#######@`````````````````````````````````````````################@...............................\n....................................:#######@`````````````````````````````````````````@###############@...............................\n....................................,@#######,````````````````````````````````````````:###############@...............................\n.....................................@######@@`````````````````````````````````````````@##############@...............................\n.....................................@######@@`````````````````````````````````````````+##############@...............................\n.....................................@#####@,;;`````````````````````````````````````````@#############@...............................\n.....................................@####@@..@`````````````````````````````````````````+#############@...............................\n.....................................,####@...@``````````````````````````````````````````@############+...............................\n......................................@##@.....@`````````````````````````````````````````:###########@,...............................\n.......................................@+......@``````````````````````````````````````````@##########@................................\n...............................................:#``````````````````````````````````````````##########@................................\n................................................@``````````````````````````````````````````+########@,................................\n................................................'+``````````````````````````````````````````@#######@.................................\n.................................................@```````````````````````````````````````````@#####@:.................................\n.................................................'#``````````````````````````````````````````.#####@..................................\n..................................................@```````````````````````````````````````````;###@...................................\n...................................................@```````````````````````````````````````````+#@'...................................\n...................................................'#```````````````````````````````````````````@#....................................\n....................................................##`````````````````````````````````````````@#.....................................\n.....................................................#@```````````````````````````````````````@+......................................\n......................................................:@;```````````````````````````````````;@,.......................................\n.......................................................;@@'```````````````````````````````:@@+;.......................................\n.......................................................@,,'@@'``````````````````````````@@@,,,@.......................................\n......................................................@,,,,,,'@@@@;````````````````.+@@@;,,,,,@.......................................\n......................................................#@+@,,,,,,,,+@@@@@@@@@@@@@@@@@;,,,,,'@@@........................................\n.........................................................+,,,#',,@@..............@,,,,,,,,@...........................................\n..........................................................@@@,#@@,...............:+,,,'@,,@...........................................\n..................................................................................@,,,@.##............................................\n...................................................................................@;@................................................\n....................................................................................:.................................................\n......................................................................................................................................\n......................................................................................................................................\n */\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.math.BigInteger;\nimport java.util.*;\nimport java.util.List;\nimport java.util.stream.Collectors;\nimport java.util.stream.IntStream;\n\nimport static java.lang.Math.max;\nimport static java.lang.Math.min;\nimport static java.lang.Math.pow;\nimport static java.lang.Math.abs;\n\nimport static java.lang.String.format;\n\n\npublic class Main {\n final static int INF = Integer.MAX_VALUE>>1;\n final static int MOD = 1000000007;\n final static int[] dx4 = { 0, -1, 1, 0 };\n final static int[] dy4 = { -1, 0, 0, 1 };\n final static int[] dx8 = { -1, -1, -1, 0, 0, 1, 1, 1 };\n final static int[] dy8 = { -1, 0, 1, -1, 1, -1, 0, 1 };\n public static void main(String[] args) {\n Scanner sc=new Scanner();\n int n=sc.nextInt();\n int[] a = new int[n];\n for(int i=0;i Integer.MAX_VALUE)\n throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n }\n final static private class FixedLongPair {\n final public long x, y;\n final static public FixedLongPair ZEROS=new FixedLongPair(0,0);\n FixedLongPair(long x, long y) {\n this.x = x;\n this.y = y;\n }\n public static double distance(FixedLongPair flp1,FixedLongPair flp2){\n double x = (double) flp1.x - flp2.x;\n double y = (double) flp1.y - flp2.y;\n return Math.sqrt(x*x+y*y);\n }\n\n @Override\n public int hashCode() {\n return (int)x+(int)y;\n }\n\n @Override\n public boolean equals(Object obj) {\n boolean result=super.equals(obj);\n if(obj.getClass()!=this.getClass()){\n return false;\n }\n FixedLongPair pair=(FixedLongPair)obj;\n if(this.x==pair.x&&this.y==pair.y) return true;\n return false;\n }\n\n @Override\n public String toString() {\n return String.format(FixedLongPair.class.getSimpleName()+\":(%d,%d)\", x, y);\n }\n }\n final static private class FixedIntPair {\n final public int x, y;\n final static public FixedIntPair ZEROS=new FixedIntPair(0,0);\n FixedIntPair(int x, int y) {\n this.x = x;\n this.y = y;\n }\n public static double distance(FixedIntPair fip1,FixedIntPair fip2){\n double x = (double) fip1.x - fip2.x;\n double y = (double) fip1.y - fip2.y;\n return Math.sqrt(x*x+y*y);\n }\n\n @Override\n public int hashCode() {\n return x+y;\n }\n\n @Override\n public boolean equals(Object obj) {\n boolean result=super.equals(obj);\n if(obj.getClass()!=this.getClass()){\n return false;\n }\n FixedIntPair pair=(FixedIntPair) obj;\n if(this.x==pair.x&&this.y==pair.y) return true;\n return false;\n }\n\n @Override\n public String toString() {\n return String.format(FixedIntPair.class.getSimpleName()+\":(%d,%d)\", x, y);\n }\n }\n final static private class Tuple{\n //immutabl1でないことに注意(T,Vがmutableの場合変更可能)\n final private T t;\n final private V v;\n Tuple(T t,V v){\n this.t=t;\n this.v=v;\n }\n\n public T getT() {\n return t;\n }\n\n public V getV() {\n return v;\n }\n\n @Override\n public int hashCode() {\n return (t.hashCode()+v.hashCode());\n }\n\n @Override\n @SuppressWarnings(\"unchecked\")\n public boolean equals(Object obj) {\n if(obj.getClass()!=this.getClass()){\n return false;\n }\n Tuple tuple=(Tuple) obj;\n return tuple.t.equals(this.t)&&tuple.v.equals(this.v);\n }\n\n @Override\n public String toString() {\n return String.format(\"=<%s,%s>\",t,v);\n }\n }\n final static private class Util {\n static long gcd(long a,long b){\n //最大公約数 \n if(a%b==0)return b;\n return gcd(b,a%b);\n }\n static long lcm(long a,long b){\n //最小公倍数\n long gcd=gcd(a,b);\n long result=b/gcd;\n return a*result;\n }\n static > Map count(List list){\n //副作用\n Collections.sort(list);\n Map result=new HashMap<>();\n int l=0,r=0;\n while(l count(int[] array){\n //副作用\n Arrays.sort(array);\n Map result=new HashMap<>();\n int l=0,r=0;\n while(l String toStringBWS(Iterable iterable){\n Iterator ite=iterable.iterator();\n return toStringBWS(ite);\n }\n static String toStringBWS(Iterator ite){\n StringBuilder sb=new StringBuilder();\n sb.append(ite.next());\n while(ite.hasNext()){\n sb.append(\" \");\n sb.append(ite.next());\n }\n return sb.toString();\n }\n static int[] factoringInPrimeNumbers(long n,int size){\n //素因数分解\n //sizeがnに比べて小さい場合完全に素因数分解出来ていない可能性がある\n int[] result=new int[size];\n for(int i=2;n>1&&i< result.length;i++){\n while(n%i==0){\n result[i]++;\n n/=i;\n }\n }\n return result;\n\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1552027143, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03232.html", "problem_id": "p03232", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03232/input.txt", "sample_output_relpath": "derived/input_output/data/p03232/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03232/Java/s935855162.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s935855162", "user_id": "u923606520"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "/*\n......................................................................................................................................\n..................................... ________ ____ __________________________________________ .....................................\n..................................... / _____/| | \\ \\__ ___/\\_ _____/\\______ \\.....................................\n...................................../ \\ ___| | / | \\| | | __)_ | _/.....................................\n.....................................\\ \\_\\ \\ | / | \\ | | \\ | | \\.....................................\n..................................... \\______ /______/\\____|__ /____| /_______ / |____|_ /.....................................\n..................................... \\/ \\/ \\/ \\/ .....................................\n......................................................................................................................................\n.............................................................,;'';:...................................................................\n........................................................+@@@@@@@@@@@@@@'..............................................................\n.....................................................#@@@##############@@@:...........................................................\n...................................................@@@####################@@,.........................................................\n.................................................@@#########################@@........................................................\n...............................................:@############################@@.......................................................\n..............................................@@######@@@#';;'#@@@############@@:.....................................................\n.............................................@#####@@,````````````,@@###########@:....................................................\n............................................@####@;``````````````````+@##########@....................................................\n...........................................@###@:``````````````````````#@########@@...................................................\n..........................................@####``````````````````````````@########@@..................................................\n.........................................###@.````````````````````````````@########@+.................................................\n.........................................@#@```````````````````````````````#########@.................................................\n........................................@#@`````````````````````````````````########@@................................................\n.......................................,@@```````````````````````````````````@#######@:...............................................\n.......................................@@`````````````````````````````````````@#######@...............................................\n.......................................@:````````````````````#@@'``````````````@######@+..............................................\n......................................#@```````````````````@@@@@@@#````````````########@..............................................\n......................................@```````````````````@@@@@@@@@@````````````@######@+.............................................\n......................................@``````````````````@@@@@@@+ +```````````+#######@.............................................\n.....................................;:``````````````````@@@@@@@ @````````````@######@'............................................\n.....................................@``````````````````:@@@@@@@ @````````````@#######@............................................\n.....................................@```,@@@#``````````;@@@@@@@ @````````````:#######@:...........................................\n.....................................@``@@@@@@@@````````.@@@@@@@# ,#`````````````@#######@...........................................\n.....................................@`@@@@@@@+'@````````@@@@@@@@@@@``````````````@#######@...........................................\n.....................................@,@@@@@@ ,```:+:``:@@@@@@@@@.``````````````@########@..........................................\n.....................................#@@@@@@@ ;@@#;,,,@``:@@@@@@@````````````````#########@..........................................\n.....................................+@@@@@@@@',,,,,,,,;,```.'+;``````````````````'########@;.........................................\n.....................................'@@@@',,,,,,,,,,,,,@`````````````````````````:#########@.........................................\n....................................:@#,,,,,:;;;;;:,,,,,@`````````````````````````.#########@.........................................\n.................................:@#@@@@#++';;;;;;;;;;;;@``````````````````````````##########+........................................\n...............................#@#+;;;;;;;;;;;;;;;;;;;;':``````````````````````````##########@........................................\n....................................,@#@@@@@#+'';;;;;+@#```````````````````````````##########@........................................\n.....................................@``````````.,,,.``````````````````````````````############.......................................\n.....................................@`````````````````````````````````````````````#######+'+#@.......................................\n.....................................@`````````````````````````````````````````````##########'@.......................................\n.....................................#`````````````````````````````````````````````############@#.....................................\n.....................................:.````````````````````````````````````````````##############@,...................................\n......................................+```````````````````````````````````````````.###############@#..................................\n......................................@```````````````````````````````````````````.################@@.................................\n......................................@```````````````````````````````````````````.###+##############@................................\n......................................@```````````````````````````````````````````.###+###############@...............................\n......................................',``````````````````````````````````````````.####'##############@@..............................\n.......................................@```````````````````````````````````````````#####+##############@:.............................\n.......................................@```````````````````````````````````````````#####'###############@.............................\n.......................................@```````````````````````````````````````````######'################............................\n.......................................#,``````````````````````````````````````````#######'##############@............................\n........................................@``````````````````````````````````````````@######++##############+...........................\n........................................@``````````````````````````````````````````@#######'##############@...........................\n........................................@``````````````````````````````````````````@########'#############@...........................\n.......................................@#'`````````````````````````````````````````@#########'##############..........................\n.......................................@#@`````````````````````````````````````````+#########+'############@..........................\n......................................@##@`````````````````````````````````````````.##########+'###########@..........................\n......................................@##@:`````````````````````````````````````````###########+'###########..........................\n.....................................:@###@`````````````````````````````````````````@###########+'+#########,.........................\n.....................................@####@`````````````````````````````````````````@#############''########..........................\n.....................................@####@.````````````````````````````````````````;##############+'######@..........................\n.....................................@#####@`````````````````````````````````````````################@@@###+..........................\n.....................................@#####@`````````````````````````````````````````@###############@..;;............................\n....................................,@#####@.````````````````````````````````````````+################'...............................\n....................................:#######@`````````````````````````````````````````################@...............................\n....................................:#######@`````````````````````````````````````````@###############@...............................\n....................................,@#######,````````````````````````````````````````:###############@...............................\n.....................................@######@@`````````````````````````````````````````@##############@...............................\n.....................................@######@@`````````````````````````````````````````+##############@...............................\n.....................................@#####@,;;`````````````````````````````````````````@#############@...............................\n.....................................@####@@..@`````````````````````````````````````````+#############@...............................\n.....................................,####@...@``````````````````````````````````````````@############+...............................\n......................................@##@.....@`````````````````````````````````````````:###########@,...............................\n.......................................@+......@``````````````````````````````````````````@##########@................................\n...............................................:#``````````````````````````````````````````##########@................................\n................................................@``````````````````````````````````````````+########@,................................\n................................................'+``````````````````````````````````````````@#######@.................................\n.................................................@```````````````````````````````````````````@#####@:.................................\n.................................................'#``````````````````````````````````````````.#####@..................................\n..................................................@```````````````````````````````````````````;###@...................................\n...................................................@```````````````````````````````````````````+#@'...................................\n...................................................'#```````````````````````````````````````````@#....................................\n....................................................##`````````````````````````````````````````@#.....................................\n.....................................................#@```````````````````````````````````````@+......................................\n......................................................:@;```````````````````````````````````;@,.......................................\n.......................................................;@@'```````````````````````````````:@@+;.......................................\n.......................................................@,,'@@'``````````````````````````@@@,,,@.......................................\n......................................................@,,,,,,'@@@@;````````````````.+@@@;,,,,,@.......................................\n......................................................#@+@,,,,,,,,+@@@@@@@@@@@@@@@@@;,,,,,'@@@........................................\n.........................................................+,,,#',,@@..............@,,,,,,,,@...........................................\n..........................................................@@@,#@@,...............:+,,,'@,,@...........................................\n..................................................................................@,,,@.##............................................\n...................................................................................@;@................................................\n....................................................................................:.................................................\n......................................................................................................................................\n......................................................................................................................................\n */\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.math.BigInteger;\nimport java.util.*;\nimport java.util.List;\nimport java.util.stream.Collectors;\nimport java.util.stream.IntStream;\n\nimport static java.lang.Math.max;\nimport static java.lang.Math.min;\nimport static java.lang.Math.pow;\nimport static java.lang.Math.abs;\n\nimport static java.lang.String.format;\n\n\npublic class Main {\n final static int INF = Integer.MAX_VALUE>>1;\n final static int MOD = 1000000007;\n final static int[] dx4 = { 0, -1, 1, 0 };\n final static int[] dy4 = { -1, 0, 0, 1 };\n final static int[] dx8 = { -1, -1, -1, 0, 0, 1, 1, 1 };\n final static int[] dy8 = { -1, 0, 1, -1, 1, -1, 0, 1 };\n public static void main(String[] args) {\n Scanner sc=new Scanner();\n int n=sc.nextInt();\n int[] a = new int[n];\n for(int i=0;i Integer.MAX_VALUE)\n throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n }\n final static private class FixedLongPair {\n final public long x, y;\n final static public FixedLongPair ZEROS=new FixedLongPair(0,0);\n FixedLongPair(long x, long y) {\n this.x = x;\n this.y = y;\n }\n public static double distance(FixedLongPair flp1,FixedLongPair flp2){\n double x = (double) flp1.x - flp2.x;\n double y = (double) flp1.y - flp2.y;\n return Math.sqrt(x*x+y*y);\n }\n\n @Override\n public int hashCode() {\n return (int)x+(int)y;\n }\n\n @Override\n public boolean equals(Object obj) {\n boolean result=super.equals(obj);\n if(obj.getClass()!=this.getClass()){\n return false;\n }\n FixedLongPair pair=(FixedLongPair)obj;\n if(this.x==pair.x&&this.y==pair.y) return true;\n return false;\n }\n\n @Override\n public String toString() {\n return String.format(FixedLongPair.class.getSimpleName()+\":(%d,%d)\", x, y);\n }\n }\n final static private class FixedIntPair {\n final public int x, y;\n final static public FixedIntPair ZEROS=new FixedIntPair(0,0);\n FixedIntPair(int x, int y) {\n this.x = x;\n this.y = y;\n }\n public static double distance(FixedIntPair fip1,FixedIntPair fip2){\n double x = (double) fip1.x - fip2.x;\n double y = (double) fip1.y - fip2.y;\n return Math.sqrt(x*x+y*y);\n }\n\n @Override\n public int hashCode() {\n return x+y;\n }\n\n @Override\n public boolean equals(Object obj) {\n boolean result=super.equals(obj);\n if(obj.getClass()!=this.getClass()){\n return false;\n }\n FixedIntPair pair=(FixedIntPair) obj;\n if(this.x==pair.x&&this.y==pair.y) return true;\n return false;\n }\n\n @Override\n public String toString() {\n return String.format(FixedIntPair.class.getSimpleName()+\":(%d,%d)\", x, y);\n }\n }\n final static private class Tuple{\n //immutabl1でないことに注意(T,Vがmutableの場合変更可能)\n final private T t;\n final private V v;\n Tuple(T t,V v){\n this.t=t;\n this.v=v;\n }\n\n public T getT() {\n return t;\n }\n\n public V getV() {\n return v;\n }\n\n @Override\n public int hashCode() {\n return (t.hashCode()+v.hashCode());\n }\n\n @Override\n @SuppressWarnings(\"unchecked\")\n public boolean equals(Object obj) {\n if(obj.getClass()!=this.getClass()){\n return false;\n }\n Tuple tuple=(Tuple) obj;\n return tuple.t.equals(this.t)&&tuple.v.equals(this.v);\n }\n\n @Override\n public String toString() {\n return String.format(\"=<%s,%s>\",t,v);\n }\n }\n final static private class Util {\n static long gcd(long a,long b){\n //最大公約数 \n if(a%b==0)return b;\n return gcd(b,a%b);\n }\n static long lcm(long a,long b){\n //最小公倍数\n long gcd=gcd(a,b);\n long result=b/gcd;\n return a*result;\n }\n static > Map count(List list){\n //副作用\n Collections.sort(list);\n Map result=new HashMap<>();\n int l=0,r=0;\n while(l count(int[] array){\n //副作用\n Arrays.sort(array);\n Map result=new HashMap<>();\n int l=0,r=0;\n while(l String toStringBWS(Iterable iterable){\n Iterator ite=iterable.iterator();\n return toStringBWS(ite);\n }\n static String toStringBWS(Iterator ite){\n StringBuilder sb=new StringBuilder();\n sb.append(ite.next());\n while(ite.hasNext()){\n sb.append(\" \");\n sb.append(ite.next());\n }\n return sb.toString();\n }\n static int[] factoringInPrimeNumbers(long n,int size){\n //素因数分解\n //sizeがnに比べて小さい場合完全に素因数分解出来ていない可能性がある\n int[] result=new int[size];\n for(int i=2;n>1&&i< result.length;i++){\n while(n%i==0){\n result[i]++;\n n/=i;\n }\n }\n return result;\n\n }\n }\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are N blocks arranged in a row, numbered 1 to N from left to right.\nEach block has a weight, and the weight of Block i is A_i.\nSnuke will perform the following operation on these blocks N times:\n\nChoose one block that is still not removed, and remove it.\nThe cost of this operation is the sum of the weights of the blocks that are connected to the block being removed (including itself).\nHere, two blocks x and y ( x \\leq y ) are connected when, for all z ( x \\leq z \\leq y ), Block z is still not removed.\n\nThere are N! possible orders in which Snuke removes the blocks.\nFor all of those N! orders, find the total cost of the N operations, and calculate the sum of those N! total costs.\nAs the answer can be extremely large, compute the sum modulo 10^9+7.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFor all of the N! orders, find the total cost of the N operations, and print the sum of those N! total costs, modulo 10^9+7.\n\nSample Input 1\n\n2\n1 2\n\nSample Output 1\n\n9\n\nFirst, we will consider the order \"Block 1 -> Block 2\".\nIn the first operation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 2, as only Block 2 remains.\nThus, the total cost of the two operations for this order is 3+2=5.\n\nThen, we will consider the order \"Block 2 -> Block 1\".\nIn the first operation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 1, as only Block 1 remains.\nThus, the total cost of the two operations for this order is 3+1=4.\n\nTherefore, the answer is 5+4=9.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n212\n\nSample Input 3\n\n10\n1 2 4 8 16 32 64 128 256 512\n\nSample Output 3\n\n880971923", "sample_input": "2\n1 2\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03232", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are N blocks arranged in a row, numbered 1 to N from left to right.\nEach block has a weight, and the weight of Block i is A_i.\nSnuke will perform the following operation on these blocks N times:\n\nChoose one block that is still not removed, and remove it.\nThe cost of this operation is the sum of the weights of the blocks that are connected to the block being removed (including itself).\nHere, two blocks x and y ( x \\leq y ) are connected when, for all z ( x \\leq z \\leq y ), Block z is still not removed.\n\nThere are N! possible orders in which Snuke removes the blocks.\nFor all of those N! orders, find the total cost of the N operations, and calculate the sum of those N! total costs.\nAs the answer can be extremely large, compute the sum modulo 10^9+7.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFor all of the N! orders, find the total cost of the N operations, and print the sum of those N! total costs, modulo 10^9+7.\n\nSample Input 1\n\n2\n1 2\n\nSample Output 1\n\n9\n\nFirst, we will consider the order \"Block 1 -> Block 2\".\nIn the first operation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 2, as only Block 2 remains.\nThus, the total cost of the two operations for this order is 3+2=5.\n\nThen, we will consider the order \"Block 2 -> Block 1\".\nIn the first operation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 1, as only Block 1 remains.\nThus, the total cost of the two operations for this order is 3+1=4.\n\nTherefore, the answer is 5+4=9.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n212\n\nSample Input 3\n\n10\n1 2 4 8 16 32 64 128 256 512\n\nSample Output 3\n\n880971923", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 24641, "cpu_time_ms": 536, "memory_kb": 70104}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s290412820", "group_id": "codeNet:p03232", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.StringTokenizer;\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tInputStream inputStream = System.in;\n\t\tOutputStream outputStream = System.out;\n\t\tFastScanner in = new FastScanner(inputStream);\n\t\tPrintWriter out = new PrintWriter(outputStream);\n\t\tProblemB solver = new ProblemB();\n\t\tsolver.solve(1, in, out);\n\t\tout.close();\n\t}\n\n\tstatic class ProblemB {\n\t\tfinal int N = 200010;\n\t\tfinal int MOD = (int) (1e9 + 7);\n\t\tint[] fact = new int[N];\n\t\tint[] inv = new int[N];\n\t\tint[] invFact = new int[N];\n\n\t\tpublic void solve(int testNumber, FastScanner in, PrintWriter out) {\n\t\t\tprecalc();\n\n\t\t\tint n = in.nextInt();\n\t\t\tint[] a = new int[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\ta[i] = in.nextInt();\n\t\t\t}\n\n\t\t\tlong[] f = new long[n];\n\t\t\tfor (int d = 0; d < n; d++) {\n\t\t\t\tint b = n - 1 - d;\n\t\t\t\tlong cur = 0;\n\t\t\t\tfor (int k = 0; k <= b; k++) {\n\t\t\t\t\tlong v = 1;\n\t\t\t\t\tv = v * fact[n - k - 1] % MOD;\n\t\t\t\t\tv = v * invFact[b - k] % MOD;\n\t\t\t\t\tcur = (cur + v) % MOD;\n\t\t\t\t}\n\t\t\t\tf[d] = cur * fact[b] % MOD;\n\t\t\t}\n\n\t\t\tlong ans = 0;\n//\t\tfor (int i = 0; i < n; i++) {\n//\t\t\tfor (int j = 0; j < n; j++) {\n//\t\t\t\tans = (ans + f[Math.abs(i - j)] * a[i]) % MOD;\n//\t\t\t}\n//\t\t}\n\n\t\t\tlong[] inc = new long[n + 1];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\taddSegment(inc, 0, 0, a[i]);\n\t\t\t\taddSegment(inc, 1, i, a[i]);\n\t\t\t\taddSegment(inc, 1, n - i - 1, a[i]);\n\t\t\t}\n\n\t\t\tlong sum = 0;\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tsum += inc[i];\n\t\t\t\tans = (ans + sum * f[i]) % MOD;\n\t\t\t}\n\n\t\t\tout.println(ans);\n\t\t}\n\n\t\tprivate void addSegment(long[] inc, int l, int r, int val) {\n\t\t\tinc[l] += val;\n\t\t\tif (inc[l] >= MOD) {\n\t\t\t\tinc[l] -= MOD;\n\t\t\t}\n\t\t\tinc[r + 1] -= val;\n\t\t\tif (inc[r + 1] < 0) {\n\t\t\t\tinc[r + 1] += MOD;\n\t\t\t}\n\t\t}\n\n\t\tprivate void precalc() {\n\t\t\tinv[1] = 1;\n\t\t\tfor (int i = 2; i < N; i++) {\n\t\t\t\tinv[i] = (int) ((MOD - (MOD / i) * (long) inv[MOD % i] % MOD) % MOD);\n\t\t\t}\n\t\t\tfact[0] = 1;\n\t\t\tinvFact[0] = 1;\n\t\t\tfor (int i = 1; i < N; i++) {\n\t\t\t\tfact[i] = (int) (i * (long) fact[i - 1] % MOD);\n\t\t\t\tinvFact[i] = (int) (inv[i] * (long) invFact[i - 1] % MOD);\n\t\t\t}\n\t\t}\n\n\t}\n\n\tstatic class FastScanner {\n\t\tprivate BufferedReader in;\n\t\tprivate StringTokenizer st;\n\n\t\tpublic FastScanner(InputStream stream) {\n\t\t\tin = new BufferedReader(new InputStreamReader(stream));\n\t\t}\n\n\t\tpublic String next() {\n\t\t\twhile (st == null || !st.hasMoreTokens()) {\n\t\t\t\ttry {\n\t\t\t\t\tString rl = in.readLine();\n\t\t\t\t\tif (rl == null) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tst = new StringTokenizer(rl);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new RuntimeException(e);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t}\n}\n\n", "language": "Java", "metadata": {"date": 1539487752, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03232.html", "problem_id": "p03232", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03232/input.txt", "sample_output_relpath": "derived/input_output/data/p03232/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03232/Java/s290412820.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s290412820", "user_id": "u113560961"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.StringTokenizer;\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tInputStream inputStream = System.in;\n\t\tOutputStream outputStream = System.out;\n\t\tFastScanner in = new FastScanner(inputStream);\n\t\tPrintWriter out = new PrintWriter(outputStream);\n\t\tProblemB solver = new ProblemB();\n\t\tsolver.solve(1, in, out);\n\t\tout.close();\n\t}\n\n\tstatic class ProblemB {\n\t\tfinal int N = 200010;\n\t\tfinal int MOD = (int) (1e9 + 7);\n\t\tint[] fact = new int[N];\n\t\tint[] inv = new int[N];\n\t\tint[] invFact = new int[N];\n\n\t\tpublic void solve(int testNumber, FastScanner in, PrintWriter out) {\n\t\t\tprecalc();\n\n\t\t\tint n = in.nextInt();\n\t\t\tint[] a = new int[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\ta[i] = in.nextInt();\n\t\t\t}\n\n\t\t\tlong[] f = new long[n];\n\t\t\tfor (int d = 0; d < n; d++) {\n\t\t\t\tint b = n - 1 - d;\n\t\t\t\tlong cur = 0;\n\t\t\t\tfor (int k = 0; k <= b; k++) {\n\t\t\t\t\tlong v = 1;\n\t\t\t\t\tv = v * fact[n - k - 1] % MOD;\n\t\t\t\t\tv = v * invFact[b - k] % MOD;\n\t\t\t\t\tcur = (cur + v) % MOD;\n\t\t\t\t}\n\t\t\t\tf[d] = cur * fact[b] % MOD;\n\t\t\t}\n\n\t\t\tlong ans = 0;\n//\t\tfor (int i = 0; i < n; i++) {\n//\t\t\tfor (int j = 0; j < n; j++) {\n//\t\t\t\tans = (ans + f[Math.abs(i - j)] * a[i]) % MOD;\n//\t\t\t}\n//\t\t}\n\n\t\t\tlong[] inc = new long[n + 1];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\taddSegment(inc, 0, 0, a[i]);\n\t\t\t\taddSegment(inc, 1, i, a[i]);\n\t\t\t\taddSegment(inc, 1, n - i - 1, a[i]);\n\t\t\t}\n\n\t\t\tlong sum = 0;\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tsum += inc[i];\n\t\t\t\tans = (ans + sum * f[i]) % MOD;\n\t\t\t}\n\n\t\t\tout.println(ans);\n\t\t}\n\n\t\tprivate void addSegment(long[] inc, int l, int r, int val) {\n\t\t\tinc[l] += val;\n\t\t\tif (inc[l] >= MOD) {\n\t\t\t\tinc[l] -= MOD;\n\t\t\t}\n\t\t\tinc[r + 1] -= val;\n\t\t\tif (inc[r + 1] < 0) {\n\t\t\t\tinc[r + 1] += MOD;\n\t\t\t}\n\t\t}\n\n\t\tprivate void precalc() {\n\t\t\tinv[1] = 1;\n\t\t\tfor (int i = 2; i < N; i++) {\n\t\t\t\tinv[i] = (int) ((MOD - (MOD / i) * (long) inv[MOD % i] % MOD) % MOD);\n\t\t\t}\n\t\t\tfact[0] = 1;\n\t\t\tinvFact[0] = 1;\n\t\t\tfor (int i = 1; i < N; i++) {\n\t\t\t\tfact[i] = (int) (i * (long) fact[i - 1] % MOD);\n\t\t\t\tinvFact[i] = (int) (inv[i] * (long) invFact[i - 1] % MOD);\n\t\t\t}\n\t\t}\n\n\t}\n\n\tstatic class FastScanner {\n\t\tprivate BufferedReader in;\n\t\tprivate StringTokenizer st;\n\n\t\tpublic FastScanner(InputStream stream) {\n\t\t\tin = new BufferedReader(new InputStreamReader(stream));\n\t\t}\n\n\t\tpublic String next() {\n\t\t\twhile (st == null || !st.hasMoreTokens()) {\n\t\t\t\ttry {\n\t\t\t\t\tString rl = in.readLine();\n\t\t\t\t\tif (rl == null) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tst = new StringTokenizer(rl);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new RuntimeException(e);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t}\n}\n\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are N blocks arranged in a row, numbered 1 to N from left to right.\nEach block has a weight, and the weight of Block i is A_i.\nSnuke will perform the following operation on these blocks N times:\n\nChoose one block that is still not removed, and remove it.\nThe cost of this operation is the sum of the weights of the blocks that are connected to the block being removed (including itself).\nHere, two blocks x and y ( x \\leq y ) are connected when, for all z ( x \\leq z \\leq y ), Block z is still not removed.\n\nThere are N! possible orders in which Snuke removes the blocks.\nFor all of those N! orders, find the total cost of the N operations, and calculate the sum of those N! total costs.\nAs the answer can be extremely large, compute the sum modulo 10^9+7.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFor all of the N! orders, find the total cost of the N operations, and print the sum of those N! total costs, modulo 10^9+7.\n\nSample Input 1\n\n2\n1 2\n\nSample Output 1\n\n9\n\nFirst, we will consider the order \"Block 1 -> Block 2\".\nIn the first operation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 2, as only Block 2 remains.\nThus, the total cost of the two operations for this order is 3+2=5.\n\nThen, we will consider the order \"Block 2 -> Block 1\".\nIn the first operation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 1, as only Block 1 remains.\nThus, the total cost of the two operations for this order is 3+1=4.\n\nTherefore, the answer is 5+4=9.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n212\n\nSample Input 3\n\n10\n1 2 4 8 16 32 64 128 256 512\n\nSample Output 3\n\n880971923", "sample_input": "2\n1 2\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03232", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are N blocks arranged in a row, numbered 1 to N from left to right.\nEach block has a weight, and the weight of Block i is A_i.\nSnuke will perform the following operation on these blocks N times:\n\nChoose one block that is still not removed, and remove it.\nThe cost of this operation is the sum of the weights of the blocks that are connected to the block being removed (including itself).\nHere, two blocks x and y ( x \\leq y ) are connected when, for all z ( x \\leq z \\leq y ), Block z is still not removed.\n\nThere are N! possible orders in which Snuke removes the blocks.\nFor all of those N! orders, find the total cost of the N operations, and calculate the sum of those N! total costs.\nAs the answer can be extremely large, compute the sum modulo 10^9+7.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFor all of the N! orders, find the total cost of the N operations, and print the sum of those N! total costs, modulo 10^9+7.\n\nSample Input 1\n\n2\n1 2\n\nSample Output 1\n\n9\n\nFirst, we will consider the order \"Block 1 -> Block 2\".\nIn the first operation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 2, as only Block 2 remains.\nThus, the total cost of the two operations for this order is 3+2=5.\n\nThen, we will consider the order \"Block 2 -> Block 1\".\nIn the first operation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 1, as only Block 1 remains.\nThus, the total cost of the two operations for this order is 3+1=4.\n\nTherefore, the answer is 5+4=9.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n212\n\nSample Input 3\n\n10\n1 2 4 8 16 32 64 128 256 512\n\nSample Output 3\n\n880971923", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2933, "cpu_time_ms": 2108, "memory_kb": 44048}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s454202518", "group_id": "codeNet:p03233", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.io.BufferedWriter;\nimport java.util.Collection;\nimport java.util.Set;\nimport java.util.InputMismatchException;\nimport java.io.IOException;\nimport java.util.stream.Collectors;\nimport java.util.ArrayList;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.stream.Stream;\nimport java.io.Writer;\nimport java.io.OutputStreamWriter;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author prakharjain\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n OutputWriter out = new OutputWriter(outputStream);\n agc028_c solver = new agc028_c();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class agc028_c {\n long inf = (long) 1e15;\n int mir = 1;\n\n public void solve(int testNumber, InputReader in, OutputWriter out) {\n int n = in.nextInt();\n\n int[][] a = new int[n][2];\n\n List nums = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n a[i][0] = in.nextInt();\n a[i][1] = in.nextInt();\n\n nums.add(new num(a[i][0], i, 0));\n nums.add(new num(a[i][1], i, 1));\n }\n\n long sum = 0;\n nums.sort((n1, n2) -> (int) Math.signum(n1.num - n2.num));\n\n Set ind = new HashSet<>();\n\n for (int i = 0; i < n; i++) {\n ind.add(nums.get(i).i);\n sum += nums.get(i).num;\n }\n\n if (ind.size() < n) {\n out.println(sum);\n return;\n }\n\n ind.clear();\n for (int i = 0; i < n; i++) {\n ind.add(nums.get(i).p);\n }\n\n if (ind.size() == 1) {\n out.println(sum);\n return;\n }\n\n List aInd = new ArrayList<>();\n List bInd = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n if (nums.get(i).p == 0) {\n aInd.add(i);\n } else {\n bInd.add(i);\n }\n }\n\n Set aIndM = new HashSet<>();\n Set bIndM = new HashSet<>();\n\n aIndM.addAll(min(aInd, nums));\n aIndM.addAll(minS(aInd, nums, a, 1));\n aIndM.addAll(max(aInd, nums));\n aIndM.addAll(maxS(aInd, nums, a, 1));\n\n bIndM.addAll(min(bInd, nums));\n bIndM.addAll(minS(bInd, nums, a, 0));\n bIndM.addAll(max(bInd, nums));\n bIndM.addAll(maxS(bInd, nums, a, 0));\n\n long ans = inf;\n for (Integer i : bIndM) {\n for (Integer j : bIndM) {\n if (i == j && bInd.size() > 1)\n continue;\n for (Integer x : aIndM) {\n for (Integer y : aIndM) {\n if (x == y && aInd.size() > 1)\n continue;\n\n long csum = sum;\n\n csum -= Math.max(nums.get(y).num, nums.get(i).num);\n csum += Math.min(a[nums.get(j).i][0], a[nums.get(x).i][1]);\n\n ans = Math.min(ans, csum);\n }\n }\n }\n }\n\n out.println(ans);\n }\n\n List min(List l, List nums) {\n List numList = new ArrayList<>();\n for (int i = 0; i < l.size(); i++) {\n int ind = l.get(i);\n numList.add(new num(nums.get(ind).num, ind, -1));\n }\n\n numList.sort((n1, n2) -> (int) Math.signum(n1.num - n2.num));\n\n numList = numList.subList(0, Math.min(mir, numList.size()));\n\n return numList.stream().map(num -> num.i).collect(Collectors.toList());\n }\n\n List minS(List l, List nums, int[][] a, int p) {\n List numList = new ArrayList<>();\n for (int i = 0; i < l.size(); i++) {\n int ind = l.get(i);\n numList.add(new num(a[nums.get(ind).i][p], ind, -1));\n }\n\n numList.sort((n1, n2) -> (int) Math.signum(n1.num - n2.num));\n\n numList = numList.subList(0, Math.min(mir, numList.size()));\n\n return numList.stream().map(num -> num.i).collect(Collectors.toList());\n }\n\n List max(List l, List nums) {\n List numList = new ArrayList<>();\n for (int i = 0; i < l.size(); i++) {\n int ind = l.get(i);\n numList.add(new num(nums.get(ind).num, ind, -1));\n }\n\n numList.sort((n1, n2) -> (int) Math.signum(n2.num - n1.num));\n\n numList = numList.subList(0, Math.min(mir, numList.size()));\n\n return numList.stream().map(num -> num.i).collect(Collectors.toList());\n }\n\n List maxS(List l, List nums, int[][] a, int p) {\n List numList = new ArrayList<>();\n for (int i = 0; i < l.size(); i++) {\n int ind = l.get(i);\n numList.add(new num(a[nums.get(ind).i][p], ind, -1));\n }\n\n numList.sort((n1, n2) -> (int) Math.signum(n2.num - n1.num));\n\n numList = numList.subList(0, Math.min(mir, numList.size()));\n\n return numList.stream().map(num -> num.i).collect(Collectors.toList());\n }\n\n class num {\n long num;\n int i;\n int p;\n\n public num(long num, int i, int p) {\n this.num = num;\n this.i = i;\n this.p = p;\n }\n\n }\n\n }\n\n static class OutputWriter {\n private final PrintWriter writer;\n\n public OutputWriter(OutputStream outputStream) {\n writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));\n }\n\n public OutputWriter(Writer writer) {\n this.writer = new PrintWriter(writer);\n }\n\n public void close() {\n writer.close();\n }\n\n public void println(long i) {\n writer.println(i);\n }\n\n }\n\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private InputReader.SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n\n public static boolean isWhitespace(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public int read() {\n if (numChars == -1) {\n throw new InputMismatchException();\n }\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0) {\n return -1;\n }\n }\n return buf[curChar++];\n }\n\n public int nextInt() {\n int c = read();\n while (isSpaceChar(c)) {\n c = read();\n }\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n res *= 10;\n res += c - '0';\n c = read();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n\n public boolean isSpaceChar(int c) {\n if (filter != null) {\n return filter.isSpaceChar(c);\n }\n return isWhitespace(c);\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1539554279, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03233.html", "problem_id": "p03233", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03233/input.txt", "sample_output_relpath": "derived/input_output/data/p03233/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03233/Java/s454202518.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s454202518", "user_id": "u485601469"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.io.BufferedWriter;\nimport java.util.Collection;\nimport java.util.Set;\nimport java.util.InputMismatchException;\nimport java.io.IOException;\nimport java.util.stream.Collectors;\nimport java.util.ArrayList;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.stream.Stream;\nimport java.io.Writer;\nimport java.io.OutputStreamWriter;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author prakharjain\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n OutputWriter out = new OutputWriter(outputStream);\n agc028_c solver = new agc028_c();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class agc028_c {\n long inf = (long) 1e15;\n int mir = 1;\n\n public void solve(int testNumber, InputReader in, OutputWriter out) {\n int n = in.nextInt();\n\n int[][] a = new int[n][2];\n\n List nums = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n a[i][0] = in.nextInt();\n a[i][1] = in.nextInt();\n\n nums.add(new num(a[i][0], i, 0));\n nums.add(new num(a[i][1], i, 1));\n }\n\n long sum = 0;\n nums.sort((n1, n2) -> (int) Math.signum(n1.num - n2.num));\n\n Set ind = new HashSet<>();\n\n for (int i = 0; i < n; i++) {\n ind.add(nums.get(i).i);\n sum += nums.get(i).num;\n }\n\n if (ind.size() < n) {\n out.println(sum);\n return;\n }\n\n ind.clear();\n for (int i = 0; i < n; i++) {\n ind.add(nums.get(i).p);\n }\n\n if (ind.size() == 1) {\n out.println(sum);\n return;\n }\n\n List aInd = new ArrayList<>();\n List bInd = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n if (nums.get(i).p == 0) {\n aInd.add(i);\n } else {\n bInd.add(i);\n }\n }\n\n Set aIndM = new HashSet<>();\n Set bIndM = new HashSet<>();\n\n aIndM.addAll(min(aInd, nums));\n aIndM.addAll(minS(aInd, nums, a, 1));\n aIndM.addAll(max(aInd, nums));\n aIndM.addAll(maxS(aInd, nums, a, 1));\n\n bIndM.addAll(min(bInd, nums));\n bIndM.addAll(minS(bInd, nums, a, 0));\n bIndM.addAll(max(bInd, nums));\n bIndM.addAll(maxS(bInd, nums, a, 0));\n\n long ans = inf;\n for (Integer i : bIndM) {\n for (Integer j : bIndM) {\n if (i == j && bInd.size() > 1)\n continue;\n for (Integer x : aIndM) {\n for (Integer y : aIndM) {\n if (x == y && aInd.size() > 1)\n continue;\n\n long csum = sum;\n\n csum -= Math.max(nums.get(y).num, nums.get(i).num);\n csum += Math.min(a[nums.get(j).i][0], a[nums.get(x).i][1]);\n\n ans = Math.min(ans, csum);\n }\n }\n }\n }\n\n out.println(ans);\n }\n\n List min(List l, List nums) {\n List numList = new ArrayList<>();\n for (int i = 0; i < l.size(); i++) {\n int ind = l.get(i);\n numList.add(new num(nums.get(ind).num, ind, -1));\n }\n\n numList.sort((n1, n2) -> (int) Math.signum(n1.num - n2.num));\n\n numList = numList.subList(0, Math.min(mir, numList.size()));\n\n return numList.stream().map(num -> num.i).collect(Collectors.toList());\n }\n\n List minS(List l, List nums, int[][] a, int p) {\n List numList = new ArrayList<>();\n for (int i = 0; i < l.size(); i++) {\n int ind = l.get(i);\n numList.add(new num(a[nums.get(ind).i][p], ind, -1));\n }\n\n numList.sort((n1, n2) -> (int) Math.signum(n1.num - n2.num));\n\n numList = numList.subList(0, Math.min(mir, numList.size()));\n\n return numList.stream().map(num -> num.i).collect(Collectors.toList());\n }\n\n List max(List l, List nums) {\n List numList = new ArrayList<>();\n for (int i = 0; i < l.size(); i++) {\n int ind = l.get(i);\n numList.add(new num(nums.get(ind).num, ind, -1));\n }\n\n numList.sort((n1, n2) -> (int) Math.signum(n2.num - n1.num));\n\n numList = numList.subList(0, Math.min(mir, numList.size()));\n\n return numList.stream().map(num -> num.i).collect(Collectors.toList());\n }\n\n List maxS(List l, List nums, int[][] a, int p) {\n List numList = new ArrayList<>();\n for (int i = 0; i < l.size(); i++) {\n int ind = l.get(i);\n numList.add(new num(a[nums.get(ind).i][p], ind, -1));\n }\n\n numList.sort((n1, n2) -> (int) Math.signum(n2.num - n1.num));\n\n numList = numList.subList(0, Math.min(mir, numList.size()));\n\n return numList.stream().map(num -> num.i).collect(Collectors.toList());\n }\n\n class num {\n long num;\n int i;\n int p;\n\n public num(long num, int i, int p) {\n this.num = num;\n this.i = i;\n this.p = p;\n }\n\n }\n\n }\n\n static class OutputWriter {\n private final PrintWriter writer;\n\n public OutputWriter(OutputStream outputStream) {\n writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));\n }\n\n public OutputWriter(Writer writer) {\n this.writer = new PrintWriter(writer);\n }\n\n public void close() {\n writer.close();\n }\n\n public void println(long i) {\n writer.println(i);\n }\n\n }\n\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private InputReader.SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n\n public static boolean isWhitespace(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public int read() {\n if (numChars == -1) {\n throw new InputMismatchException();\n }\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0) {\n return -1;\n }\n }\n return buf[curChar++];\n }\n\n public int nextInt() {\n int c = read();\n while (isSpaceChar(c)) {\n c = read();\n }\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n res *= 10;\n res += c - '0';\n c = read();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n\n public boolean isSpaceChar(int c) {\n if (filter != null) {\n return filter.isSpaceChar(c);\n }\n return isWhitespace(c);\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\n\n }\n}\n\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nWe have a directed weighted graph with N vertices.\nEach vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i.\n\nIn this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \\leq x,y \\leq N, and its weight is {\\rm min}(A_x,B_y).\n\nWe will consider a directed cycle in this graph that visits every vertex exactly once.\nFind the minimum total weight of the edges in such a cycle.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\nA_2 B_2\n:\nA_N B_N\n\nOutput\n\nPrint the minimum total weight of the edges in such a cycle.\n\nSample Input 1\n\n3\n1 5\n4 2\n6 3\n\nSample Output 1\n\n7\n\nConsider the cycle 1→3→2→1. The weights of those edges are {\\rm min}(A_1,B_3)=1, {\\rm min}(A_3,B_2)=2 and {\\rm min}(A_2,B_1)=4, for a total of 7.\nAs there is no cycle with a total weight of less than 7, the answer is 7.\n\nSample Input 2\n\n4\n1 5\n2 6\n3 7\n4 8\n\nSample Output 2\n\n10\n\nSample Input 3\n\n6\n19 92\n64 64\n78 48\n57 33\n73 6\n95 73\n\nSample Output 3\n\n227", "sample_input": "3\n1 5\n4 2\n6 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03233", "source_text": "Score : 700 points\n\nProblem Statement\n\nWe have a directed weighted graph with N vertices.\nEach vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i.\n\nIn this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \\leq x,y \\leq N, and its weight is {\\rm min}(A_x,B_y).\n\nWe will consider a directed cycle in this graph that visits every vertex exactly once.\nFind the minimum total weight of the edges in such a cycle.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\nA_2 B_2\n:\nA_N B_N\n\nOutput\n\nPrint the minimum total weight of the edges in such a cycle.\n\nSample Input 1\n\n3\n1 5\n4 2\n6 3\n\nSample Output 1\n\n7\n\nConsider the cycle 1→3→2→1. The weights of those edges are {\\rm min}(A_1,B_3)=1, {\\rm min}(A_3,B_2)=2 and {\\rm min}(A_2,B_1)=4, for a total of 7.\nAs there is no cycle with a total weight of less than 7, the answer is 7.\n\nSample Input 2\n\n4\n1 5\n2 6\n3 7\n4 8\n\nSample Output 2\n\n10\n\nSample Input 3\n\n6\n19 92\n64 64\n78 48\n57 33\n73 6\n95 73\n\nSample Output 3\n\n227", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 8468, "cpu_time_ms": 902, "memory_kb": 59248}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s240736204", "group_id": "codeNet:p03238", "input_text": "import java.util.*;\npublic class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int a = sc.nextInt();\n int b = sc.nextInt();\n int c = a+b;\n if(n==1){\n System.out.println(\"Hello World\");\n }else{\n System.out.println(c);\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1538875610, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03238.html", "problem_id": "p03238", "resource_group": "high_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/Java/s240736204.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s240736204", "user_id": "u980960666"}, "prompt_components": {"gold_output": "Hello World\n", "input_to_evaluate": "import java.util.*;\npublic class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int a = sc.nextInt();\n int b = sc.nextInt();\n int c = a+b;\n if(n==1){\n System.out.println(\"Hello World\");\n }else{\n System.out.println(c);\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": 325, "cpu_time_ms": 94, "memory_kb": 23636}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s749373524", "group_id": "codeNet:p03239", "input_text": "import java.util.*;\nimport java.lang.*;\nimport java.io.*;\npublic class Main{\n\tpublic static void main (String[] args){\n\t\tScanner sc = new Scanner (System.in);\n\t\tint N = sc.nextInt();\n\t\tint T = sc.nextInt();\n\t\tInteger[] c = new Integer[N];\n\t\tInteger[] t = new Integer[N];\n\t\tint p = 1001;\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tc[i] = sc.nextInt();\n\t\t}\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tt[i] = sc.nextInt();\n\t\t}\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tif (t[i] <= T && c[i] < p) {\n\t\t\t\tp = c[i];\n\t\t\t}\n\t\t}\n\t\tif (p == 1001) {\n\t\t\tSystem.out.println(\"TLE\");\n\t\t} else {\n\t\t\tSystem.out.println(p);\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1540561801, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03239.html", "problem_id": "p03239", "resource_group": "high_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/Java/s749373524.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s749373524", "user_id": "u499009346"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*;\nimport java.lang.*;\nimport java.io.*;\npublic class Main{\n\tpublic static void main (String[] args){\n\t\tScanner sc = new Scanner (System.in);\n\t\tint N = sc.nextInt();\n\t\tint T = sc.nextInt();\n\t\tInteger[] c = new Integer[N];\n\t\tInteger[] t = new Integer[N];\n\t\tint p = 1001;\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tc[i] = sc.nextInt();\n\t\t}\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tt[i] = sc.nextInt();\n\t\t}\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tif (t[i] <= T && c[i] < p) {\n\t\t\t\tp = c[i];\n\t\t\t}\n\t\t}\n\t\tif (p == 1001) {\n\t\t\tSystem.out.println(\"TLE\");\n\t\t} else {\n\t\t\tSystem.out.println(p);\n\t\t}\n\t}\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": 588, "cpu_time_ms": 111, "memory_kb": 25044}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s033158431", "group_id": "codeNet:p03239", "input_text": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int count = scanner.nextInt();\n int time = scanner.nextInt();\n\n int min_cost=-1;\n for( int i=0; i< count; i++ ) {\n int n = scanner.nextInt();\n int t = scanner.nextInt();\n if( t <= time ) {\n if( min_cost == -1 || min_cost > n )\n min_cost = n;\n }\n }\n if( min_cost == -1 ) {\n System.out.println(\"TLE\");\n } else {\n System.out.println(min_cost);\n }\n }\n}", "language": "Java", "metadata": {"date": 1538875251, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03239.html", "problem_id": "p03239", "resource_group": "high_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/Java/s033158431.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s033158431", "user_id": "u593624455"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int count = scanner.nextInt();\n int time = scanner.nextInt();\n\n int min_cost=-1;\n for( int i=0; i< count; i++ ) {\n int n = scanner.nextInt();\n int t = scanner.nextInt();\n if( t <= time ) {\n if( min_cost == -1 || min_cost > n )\n min_cost = n;\n }\n }\n if( min_cost == -1 ) {\n System.out.println(\"TLE\");\n } else {\n System.out.println(min_cost);\n }\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": 646, "cpu_time_ms": 113, "memory_kb": 21588}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s686660186", "group_id": "codeNet:p03242", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String n = sc.next();\n sc.close();\n\n String ans = \"\";\n for (int i = 0; i < n.length(); i++) {\n if (n.charAt(i) == '1') {\n ans += \"9\";\n } else {\n ans += \"1\";\n }\n }\n System.out.println(ans);\n }\n\n}\n", "language": "Java", "metadata": {"date": 1577728905, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03242.html", "problem_id": "p03242", "resource_group": "high_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/Java/s686660186.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s686660186", "user_id": "u752146446"}, "prompt_components": {"gold_output": "991\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String n = sc.next();\n sc.close();\n\n String ans = \"\";\n for (int i = 0; i < n.length(); i++) {\n if (n.charAt(i) == '1') {\n ans += \"9\";\n } else {\n ans += \"1\";\n }\n }\n System.out.println(ans);\n }\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": 442, "cpu_time_ms": 92, "memory_kb": 20564}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s268548934", "group_id": "codeNet:p03242", "input_text": "import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t String ans = sc.next().replace('1', '0').replace('9', '1').replace('0', '9');\t \n\t System.out.println(ans);\n\t}\n}", "language": "Java", "metadata": {"date": 1550613601, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03242.html", "problem_id": "p03242", "resource_group": "high_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/Java/s268548934.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s268548934", "user_id": "u920525832"}, "prompt_components": {"gold_output": "991\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t String ans = sc.next().replace('1', '0').replace('9', '1').replace('0', '9');\t \n\t System.out.println(ans);\n\t}\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": 243, "cpu_time_ms": 90, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s011465305", "group_id": "codeNet:p03242", "input_text": "import java.util.Scanner;\n\npublic class Main{\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n\n String N2 = String.valueOf(N);\n String result = \"\";\n\n for(int i = 0; i map = new HashMap(N);\n\t\t/*for ( キーのデータ型 key : マップの名前.keySet() ) {\n\t\t\tデータのデータ型 data = マップの名前.get( key );\n\n\t\t\t// keyやdataを使った処理;\n\t\t}*/\n\t\t//int i = Integer.parseInt(s);\n\t\t//Queue qq=new ArrayDeque<>(); //add,poll,peek BFSは前から実行される\n\t\t//Deque dd=new ArrayDeque<>();//push後ろに入れる,poll(pop)後ろからとる,peek addは先頭に入るからバグ注意\n\t\t//stackdfsは後ろから実行される\n\t\t//ArrayList cc = new ArrayList<>(N);\n\t\t//cc.contains(tmp)\n\t\t//Arrays.asList(c).contains(\"a\")\n\t\t//list.set(1,\"walk\");//1 1 2 3 5\n\n\n\t\tprivate static int INF =1000000007;\n\n\n\n\t\tprivate static class D{\n\t\t\tint a,b,c;\n\t\t\t\n\t\t\tD(int a,int b,int c){\n\t\t\t\tthis.a=a;;\n\t\t\t\tthis.b=b;\n\t\t\t\tthis.c=c;\n\t\t\t\t\n\t\t\t}\n\n\t\t}\n\n\n\n\t//Set a=new HashSet();\n\tprivate static int mod=1000000007;\n\t\n\tprivate static ArrayList divisors2(long t) {\n\t\tArrayList c=new ArrayList<>();\n\t\tfor(int i=1;i*i<=t;i++) {\n\t\t\tif(t%i==0) {\n\t\t\t\tif(i*i!=t) {\n\t\t\t\t\tc.add(t/i);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tc.add((long)i);\n\t\t\t}\n\t\t}\n\t\tCollections.sort(c);\n\t\tCollections.reverse(c);\n\t\treturn c;\n\t}\n\t\n\tprivate static int slover() {\n\t\t\n\t\t\n\t\tint t=sc.nextInt();\n\t\tp(Math.ceil(t/111.0)*111);\n\t\treturn 0;\n\t}\n\tprivate static int modPow2(String S,int mod) {\n\t\t//iのt乗をO(log t)で返す\n\t\tint a=2;\n\t\tint res=1;\n\t\tint N=S.length()-1;\n\t\tfor(int i=0;i>1;\n\t\t}\n\t\treturn res;\n\t}\n\tpublic static int pid(int i) {\n\t\tint t=0;\n\t\tint j=0;\n\t\twhile((i>>j)!=0) {\n\t\t\tif((1&(i>>j))==1) {\n\t\t\t\tt++;\n\t\t\t}\n\t\t\tj++;\n\t\t}\n\t\treturn i%t;\n\t}\n\tpublic static long gcd(long num1,long num2) {\n if(num2==0) return num1;\n else return gcd(num2,num1%num2);\n }\n\tpublic static long lcm(long num1,long num2) {\n\t\treturn num1*num2/gcd(num1,num2);\n\t}\n\t//O(N^0.5)\n\tprivate static boolean isPrime(long t) {\n\t\tif(t<2)return false;\n\t\tfor(int i=2;i*i<=t;i++) {\n\t\t\tif(t%i==0)return false;\n\t\t}\n\t\treturn true;\n\t}\n\tprivate static ArrayList divisors(long t) {\n\t\tArrayList c=new ArrayList<>();\n\t\tfor(int i=1;i*i<=t;i++) {\n\t\t\tif(t%i==0) {\n\t\t\t\tif(i*i!=t) {\n\t\t\t\t\tc.add(t/i);\n\t\t\t\t}\n\t\t\t\tc.add((long)i);\n\t\t\t}\n\t\t}\n\t\treturn c;\n\t}\n\tprivate static void bubunwa() {\n\t\tint N=sc.nextInt();\n\t\tint K=sc.nextInt();\n\t\tint a[]=sc.nextIntArray(N, false);\n\n\t\tboolean dp[] =new boolean[K+1];\n\n\t\tArrays.fill(dp, false);\n\t\tdp[0]=true;\n\t\tfor(int i=0;i=0;x--) {\n\t\t\t\tif(dp[x])dp[x+a[i]]=true;\n\t\t\t}\n\t\t}\n\n\t\tp(dp[K] ? \"Yes\":\"No\");\n\t}\n\t\n\tprivate static String bitToString(int i) {\n\t\t\n\t\t\tString T=\"\";\n\t\t\tfor(int j=0;j<2;j++) {\n\t\t\t\t//if(i>>j==0)break;\n\t\t\t\tif((1&i>>j)==1) {\n\t\t\t\t\tT+=\"1\";\n\t\t\t\t}else T+=\"0\";\n\t\t\t}\n\t\t\treturn (i+\" \"+T);\n\n\t\t\n\n\t}\n/*********************************************************************/\n\t//target以下までの値のindexを返す\n\t//target以上が欲しいときは返り値+1すればいい\n\t//0-indexで個数を求めるときはさらにindex+1する必要あり\n\tprivate static int lower_bound(long a[],long target) {\n\t//p(target+ \" \"+Arrays.toString(a));\n\tif(a[0]>target)return -1;\n\t//最後の値がtarget以下であるときは最後のindexを返す。\n\t//target以上が欲しいときは注意する必要あり\n\tif(a[a.length-1]<=target) return a.length-1;\n\n\tint S=-1;\n\tint E=a.length;\n\n\twhile(Starget) {\n\t\t\treturn G;\n\n\t\t}else if(a[G]<=target){\n\t\t\tS=G;\n\t\t}else if(a[G]>target) {\n\t\t\tE=G;\n\t\t}\n\n\t}\n\n\n\treturn -1;\n\t}\n\tstatic String nextPermutation(String s) {\n\t\tArrayList list=new ArrayList<>();\n\t\tfor(int i=0;i=0;i--) {\n\t\t\tif(list.get(i)=L;i--) {\n\t\t\tif(pivot map = new HashMap(N);\n\t\t/*for ( キーのデータ型 key : マップの名前.keySet() ) {\n\t\t\tデータのデータ型 data = マップの名前.get( key );\n\n\t\t\t// keyやdataを使った処理;\n\t\t}*/\n\t\t//int i = Integer.parseInt(s);\n\t\t//Queue qq=new ArrayDeque<>(); //add,poll,peek BFSは前から実行される\n\t\t//Deque dd=new ArrayDeque<>();//push後ろに入れる,poll(pop)後ろからとる,peek addは先頭に入るからバグ注意\n\t\t//stackdfsは後ろから実行される\n\t\t//ArrayList cc = new ArrayList<>(N);\n\t\t//cc.contains(tmp)\n\t\t//Arrays.asList(c).contains(\"a\")\n\t\t//list.set(1,\"walk\");//1 1 2 3 5\n\n\n\t\tprivate static int INF =1000000007;\n\n\n\n\t\tprivate static class D{\n\t\t\tint a,b,c;\n\t\t\t\n\t\t\tD(int a,int b,int c){\n\t\t\t\tthis.a=a;;\n\t\t\t\tthis.b=b;\n\t\t\t\tthis.c=c;\n\t\t\t\t\n\t\t\t}\n\n\t\t}\n\n\n\n\t//Set a=new HashSet();\n\tprivate static int mod=1000000007;\n\t\n\tprivate static ArrayList divisors2(long t) {\n\t\tArrayList c=new ArrayList<>();\n\t\tfor(int i=1;i*i<=t;i++) {\n\t\t\tif(t%i==0) {\n\t\t\t\tif(i*i!=t) {\n\t\t\t\t\tc.add(t/i);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tc.add((long)i);\n\t\t\t}\n\t\t}\n\t\tCollections.sort(c);\n\t\tCollections.reverse(c);\n\t\treturn c;\n\t}\n\t\n\tprivate static int slover() {\n\t\t\n\t\t\n\t\tint t=sc.nextInt();\n\t\tp(Math.ceil(t/111.0)*111);\n\t\treturn 0;\n\t}\n\tprivate static int modPow2(String S,int mod) {\n\t\t//iのt乗をO(log t)で返す\n\t\tint a=2;\n\t\tint res=1;\n\t\tint N=S.length()-1;\n\t\tfor(int i=0;i>1;\n\t\t}\n\t\treturn res;\n\t}\n\tpublic static int pid(int i) {\n\t\tint t=0;\n\t\tint j=0;\n\t\twhile((i>>j)!=0) {\n\t\t\tif((1&(i>>j))==1) {\n\t\t\t\tt++;\n\t\t\t}\n\t\t\tj++;\n\t\t}\n\t\treturn i%t;\n\t}\n\tpublic static long gcd(long num1,long num2) {\n if(num2==0) return num1;\n else return gcd(num2,num1%num2);\n }\n\tpublic static long lcm(long num1,long num2) {\n\t\treturn num1*num2/gcd(num1,num2);\n\t}\n\t//O(N^0.5)\n\tprivate static boolean isPrime(long t) {\n\t\tif(t<2)return false;\n\t\tfor(int i=2;i*i<=t;i++) {\n\t\t\tif(t%i==0)return false;\n\t\t}\n\t\treturn true;\n\t}\n\tprivate static ArrayList divisors(long t) {\n\t\tArrayList c=new ArrayList<>();\n\t\tfor(int i=1;i*i<=t;i++) {\n\t\t\tif(t%i==0) {\n\t\t\t\tif(i*i!=t) {\n\t\t\t\t\tc.add(t/i);\n\t\t\t\t}\n\t\t\t\tc.add((long)i);\n\t\t\t}\n\t\t}\n\t\treturn c;\n\t}\n\tprivate static void bubunwa() {\n\t\tint N=sc.nextInt();\n\t\tint K=sc.nextInt();\n\t\tint a[]=sc.nextIntArray(N, false);\n\n\t\tboolean dp[] =new boolean[K+1];\n\n\t\tArrays.fill(dp, false);\n\t\tdp[0]=true;\n\t\tfor(int i=0;i=0;x--) {\n\t\t\t\tif(dp[x])dp[x+a[i]]=true;\n\t\t\t}\n\t\t}\n\n\t\tp(dp[K] ? \"Yes\":\"No\");\n\t}\n\t\n\tprivate static String bitToString(int i) {\n\t\t\n\t\t\tString T=\"\";\n\t\t\tfor(int j=0;j<2;j++) {\n\t\t\t\t//if(i>>j==0)break;\n\t\t\t\tif((1&i>>j)==1) {\n\t\t\t\t\tT+=\"1\";\n\t\t\t\t}else T+=\"0\";\n\t\t\t}\n\t\t\treturn (i+\" \"+T);\n\n\t\t\n\n\t}\n/*********************************************************************/\n\t//target以下までの値のindexを返す\n\t//target以上が欲しいときは返り値+1すればいい\n\t//0-indexで個数を求めるときはさらにindex+1する必要あり\n\tprivate static int lower_bound(long a[],long target) {\n\t//p(target+ \" \"+Arrays.toString(a));\n\tif(a[0]>target)return -1;\n\t//最後の値がtarget以下であるときは最後のindexを返す。\n\t//target以上が欲しいときは注意する必要あり\n\tif(a[a.length-1]<=target) return a.length-1;\n\n\tint S=-1;\n\tint E=a.length;\n\n\twhile(Starget) {\n\t\t\treturn G;\n\n\t\t}else if(a[G]<=target){\n\t\t\tS=G;\n\t\t}else if(a[G]>target) {\n\t\t\tE=G;\n\t\t}\n\n\t}\n\n\n\treturn -1;\n\t}\n\tstatic String nextPermutation(String s) {\n\t\tArrayList list=new ArrayList<>();\n\t\tfor(int i=0;i=0;i--) {\n\t\t\tif(list.get(i)=L;i--) {\n\t\t\tif(pivot mapEv = new HashMap<>();\n\t\tHashMap mapOd = new HashMap<>();\n\t\tArrayList evlist = new ArrayList<>();\n\t\tArrayList odlist = new ArrayList<>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tif (i%2 == 0) {\n\t\t\t\tint num = sc.nextInt();\n\t\t\t\tif (mapEv.containsKey(num)) {\n\t\t\t\t\tint cnt = mapEv.get(num);\n\t\t\t\t\tmapEv.put(num, cnt+1);\n\t\t\t\t} else {\n\t\t\t\t\tmapEv.put(num, 1);\n\t\t\t\t\tevlist.add(num);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tint num = sc.nextInt();\n\t\t\t\tif (mapOd.containsKey(num)) {\n\t\t\t\t\tint cnt = mapOd.get(num);\n\t\t\t\t\tmapOd.put(num, cnt+1);\n\t\t\t\t} else {\n\t\t\t\t\tmapOd.put(num, 1);\n\t\t\t\t\todlist.add(num);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tint Amax1Number = 0;\n\t\tint Amax2Number = 0;\n\t\tint Amax1 = 0;\n\t\tint Amax2 = 0;\n\n\t\tint Bmax1Number = 0;\n\t\tint Bmax2Number = 0;\n\t\tint Bmax1 = 0;\n\t\tint Bmax2 = 0;\n\t\tint ans = 0;\n\n\t\t//パターンA\n\t\tfor (int i = 0; i < evlist.size(); i++) {\n\t\t\tint tmp = mapEv.get(evlist.get(i));\n\t\t\tif (Amax1 <= tmp) {\n\t\t\t\tAmax2 = Amax1;\n\t\t\t\tAmax1 = tmp;\n\t\t\t\tAmax2Number = Amax1Number;\n\t\t\t\tAmax1Number = evlist.get(i);\n\t\t\t} else if (Amax2 <= tmp) {\n\t\t\t\tAmax2 = tmp;\n\t\t\t}\n\t\t}\n\t\t//パターンB\n\t\tfor (int i = 0; i < odlist.size(); i++) {\n\t\t\tint tmp = mapOd.get(odlist.get(i));\n\t\t\tif (Bmax1 <= tmp) {\n\t\t\t\tBmax2 = Bmax1;\n\t\t\t\tBmax1 = tmp;\n\t\t\t\tBmax2Number = Bmax1Number;\n\t\t\t\tBmax1Number = odlist.get(i);\n\t\t\t} else if (Bmax2 <= tmp) {\n\t\t\t\tBmax2 = tmp;\n\t\t\t}\n\t\t}\n\t\tif (Amax1Number == Bmax1Number) {\n\t\t\t//どちらの場合が良いか判定\n\t\t\tif (Amax1 + Bmax2 < Amax2 + Bmax1) {\n\t\t\t\tans = n - Amax2 - Bmax1;\n\t\t\t} else {\n\t\t\t\tans = n - Amax1 - Bmax2;\n\t\t\t}\n\t\t} else {\n\t\t\tans = n - Amax1 - Bmax1;\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1551654198, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03244.html", "problem_id": "p03244", "resource_group": "high_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/Java/s923525853.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s923525853", "user_id": "u820451342"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\n\t\tHashMap mapEv = new HashMap<>();\n\t\tHashMap mapOd = new HashMap<>();\n\t\tArrayList evlist = new ArrayList<>();\n\t\tArrayList odlist = new ArrayList<>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tif (i%2 == 0) {\n\t\t\t\tint num = sc.nextInt();\n\t\t\t\tif (mapEv.containsKey(num)) {\n\t\t\t\t\tint cnt = mapEv.get(num);\n\t\t\t\t\tmapEv.put(num, cnt+1);\n\t\t\t\t} else {\n\t\t\t\t\tmapEv.put(num, 1);\n\t\t\t\t\tevlist.add(num);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tint num = sc.nextInt();\n\t\t\t\tif (mapOd.containsKey(num)) {\n\t\t\t\t\tint cnt = mapOd.get(num);\n\t\t\t\t\tmapOd.put(num, cnt+1);\n\t\t\t\t} else {\n\t\t\t\t\tmapOd.put(num, 1);\n\t\t\t\t\todlist.add(num);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tint Amax1Number = 0;\n\t\tint Amax2Number = 0;\n\t\tint Amax1 = 0;\n\t\tint Amax2 = 0;\n\n\t\tint Bmax1Number = 0;\n\t\tint Bmax2Number = 0;\n\t\tint Bmax1 = 0;\n\t\tint Bmax2 = 0;\n\t\tint ans = 0;\n\n\t\t//パターンA\n\t\tfor (int i = 0; i < evlist.size(); i++) {\n\t\t\tint tmp = mapEv.get(evlist.get(i));\n\t\t\tif (Amax1 <= tmp) {\n\t\t\t\tAmax2 = Amax1;\n\t\t\t\tAmax1 = tmp;\n\t\t\t\tAmax2Number = Amax1Number;\n\t\t\t\tAmax1Number = evlist.get(i);\n\t\t\t} else if (Amax2 <= tmp) {\n\t\t\t\tAmax2 = tmp;\n\t\t\t}\n\t\t}\n\t\t//パターンB\n\t\tfor (int i = 0; i < odlist.size(); i++) {\n\t\t\tint tmp = mapOd.get(odlist.get(i));\n\t\t\tif (Bmax1 <= tmp) {\n\t\t\t\tBmax2 = Bmax1;\n\t\t\t\tBmax1 = tmp;\n\t\t\t\tBmax2Number = Bmax1Number;\n\t\t\t\tBmax1Number = odlist.get(i);\n\t\t\t} else if (Bmax2 <= tmp) {\n\t\t\t\tBmax2 = tmp;\n\t\t\t}\n\t\t}\n\t\tif (Amax1Number == Bmax1Number) {\n\t\t\t//どちらの場合が良いか判定\n\t\t\tif (Amax1 + Bmax2 < Amax2 + Bmax1) {\n\t\t\t\tans = n - Amax2 - Bmax1;\n\t\t\t} else {\n\t\t\t\tans = n - Amax1 - Bmax2;\n\t\t\t}\n\t\t} else {\n\t\t\tans = n - Amax1 - Bmax1;\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\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": 1862, "cpu_time_ms": 536, "memory_kb": 67004}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s831108663", "group_id": "codeNet:p03247", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.util.ArrayList;\nimport java.util.InputMismatchException;\nimport java.util.List;\nimport java.util.StringTokenizer;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tInputStream inputStream = System.in;\n\t\tOutputStream outputStream = System.out;\n\t\tInputReader in = new InputReader(inputStream);\n\t\tPrintWriter out = new PrintWriter(outputStream);\n\t\tTaskX solver = new TaskX();\n\t\tsolver.solve(1, in, out);\n\t\tout.close();\n\t}\n\n\tstatic int INF = 1 << 30;\n\tstatic long LINF = 1L << 55;\n\tstatic int MOD = 1000000007;\n\tstatic int[] mh4 = { 0, -1, 1, 0 };\n\tstatic int[] mw4 = { -1, 0, 0, 1 };\n\tstatic int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };\n\tstatic int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };\n\n\tstatic class TaskX {\n\n\t\tpublic void solve(int testNumber, InputReader in, PrintWriter out) {\n\n\t\t\tint n = in.nextInt();\n\t\t\tlong[] x = new long[n], y = new long[n], z = new long[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tx[i] = in.nextLong();\n\t\t\t\ty[i] = in.nextLong();\n\t\t\t\tz[i] = x[i] + y[i];\n\t\t\t\tif ((z[i] - z[0]) % 2 != 0) {\n\t\t\t\t\tout.println(-1);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tList list = new ArrayList<>();\n\t\t\tfor (int i = 30; i >= 0; i--) {\n\t\t\t\tlist.add(1 << i);\n\t\t\t}\n\t\t\tif (z[0] % 2 == 0) list.add(1);\n\t\t\tout.println(list.size());\n\t\t\tfor (int i = 0; i < list.size(); i++) {\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tout.print(\" \");\n\t\t\t\t}\n\t\t\t\tout.print(list.get(i));\n\t\t\t}\n\t\t\tout.print(\"\\n\");\n\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tlong tu = x[i] - y[i];\n\t\t\t\tlong tv = x[i] + y[i];\n\n\t\t\t\tfor (int d : list) {\n\t\t\t\t\tif (tu >= 0) {\n\t\t\t\t\t\tif (tv >= 0) {\n\t\t\t\t\t\t\tsb.append(\"L\");\n\t\t\t\t\t\t\ttu -= d;\n\t\t\t\t\t\t\ttv -= d;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsb.append(\"D\");\n\t\t\t\t\t\t\ttu -= d;\n\t\t\t\t\t\t\ttv += d;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (tv >= 0) {\n\t\t\t\t\t\t\tsb.append(\"U\");\n\t\t\t\t\t\t\ttu += d;\n\t\t\t\t\t\t\ttv -= d;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsb.append(\"D\");\n\t\t\t\t\t\t\ttu += d;\n\t\t\t\t\t\t\ttv += d;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tout.println(sb.toString());\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic class InputReader {\n\t\tBufferedReader in;\n\t\tStringTokenizer tok;\n\n\t\tpublic String nextString() {\n\t\t\twhile (!tok.hasMoreTokens()) {\n\t\t\t\ttry {\n\t\t\t\t\ttok = new StringTokenizer(in.readLine(), \" \");\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn tok.nextToken();\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\treturn Integer.parseInt(nextString());\n\t\t}\n\n\t\tpublic long nextLong() {\n\t\t\treturn Long.parseLong(nextString());\n\t\t}\n\n\t\tpublic double nextDouble() {\n\t\t\treturn Double.parseDouble(nextString());\n\t\t}\n\n\t\tpublic int[] nextIntArray(int n) {\n\t\t\tint[] res = new int[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tres[i] = nextInt();\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic int[] nextIntArrayDec(int n) {\n\t\t\tint[] res = new int[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tres[i] = nextInt() - 1;\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic int[] nextIntArray1Index(int n) {\n\t\t\tint[] res = new int[n + 1];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tres[i + 1] = nextInt();\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic long[] nextLongArray(int n) {\n\t\t\tlong[] res = new long[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tres[i] = nextLong();\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic long[] nextLongArrayDec(int n) {\n\t\t\tlong[] res = new long[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tres[i] = nextLong() - 1;\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic long[] nextLongArray1Index(int n) {\n\t\t\tlong[] res = new long[n + 1];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tres[i + 1] = nextLong();\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic double[] nextDoubleArray(int n) {\n\t\t\tdouble[] res = new double[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tres[i] = nextDouble();\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic InputReader(InputStream inputStream) {\n\t\t\tin = new BufferedReader(new InputStreamReader(inputStream));\n\t\t\ttok = new StringTokenizer(\"\");\n\t\t}\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1538335439, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03247.html", "problem_id": "p03247", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03247/input.txt", "sample_output_relpath": "derived/input_output/data/p03247/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03247/Java/s831108663.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s831108663", "user_id": "u266665184"}, "prompt_components": {"gold_output": "2\n1 2\nRL\nUU\nDR\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.util.ArrayList;\nimport java.util.InputMismatchException;\nimport java.util.List;\nimport java.util.StringTokenizer;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tInputStream inputStream = System.in;\n\t\tOutputStream outputStream = System.out;\n\t\tInputReader in = new InputReader(inputStream);\n\t\tPrintWriter out = new PrintWriter(outputStream);\n\t\tTaskX solver = new TaskX();\n\t\tsolver.solve(1, in, out);\n\t\tout.close();\n\t}\n\n\tstatic int INF = 1 << 30;\n\tstatic long LINF = 1L << 55;\n\tstatic int MOD = 1000000007;\n\tstatic int[] mh4 = { 0, -1, 1, 0 };\n\tstatic int[] mw4 = { -1, 0, 0, 1 };\n\tstatic int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };\n\tstatic int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };\n\n\tstatic class TaskX {\n\n\t\tpublic void solve(int testNumber, InputReader in, PrintWriter out) {\n\n\t\t\tint n = in.nextInt();\n\t\t\tlong[] x = new long[n], y = new long[n], z = new long[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tx[i] = in.nextLong();\n\t\t\t\ty[i] = in.nextLong();\n\t\t\t\tz[i] = x[i] + y[i];\n\t\t\t\tif ((z[i] - z[0]) % 2 != 0) {\n\t\t\t\t\tout.println(-1);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tList list = new ArrayList<>();\n\t\t\tfor (int i = 30; i >= 0; i--) {\n\t\t\t\tlist.add(1 << i);\n\t\t\t}\n\t\t\tif (z[0] % 2 == 0) list.add(1);\n\t\t\tout.println(list.size());\n\t\t\tfor (int i = 0; i < list.size(); i++) {\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tout.print(\" \");\n\t\t\t\t}\n\t\t\t\tout.print(list.get(i));\n\t\t\t}\n\t\t\tout.print(\"\\n\");\n\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tlong tu = x[i] - y[i];\n\t\t\t\tlong tv = x[i] + y[i];\n\n\t\t\t\tfor (int d : list) {\n\t\t\t\t\tif (tu >= 0) {\n\t\t\t\t\t\tif (tv >= 0) {\n\t\t\t\t\t\t\tsb.append(\"L\");\n\t\t\t\t\t\t\ttu -= d;\n\t\t\t\t\t\t\ttv -= d;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsb.append(\"D\");\n\t\t\t\t\t\t\ttu -= d;\n\t\t\t\t\t\t\ttv += d;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (tv >= 0) {\n\t\t\t\t\t\t\tsb.append(\"U\");\n\t\t\t\t\t\t\ttu += d;\n\t\t\t\t\t\t\ttv -= d;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsb.append(\"D\");\n\t\t\t\t\t\t\ttu += d;\n\t\t\t\t\t\t\ttv += d;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tout.println(sb.toString());\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic class InputReader {\n\t\tBufferedReader in;\n\t\tStringTokenizer tok;\n\n\t\tpublic String nextString() {\n\t\t\twhile (!tok.hasMoreTokens()) {\n\t\t\t\ttry {\n\t\t\t\t\ttok = new StringTokenizer(in.readLine(), \" \");\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn tok.nextToken();\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\treturn Integer.parseInt(nextString());\n\t\t}\n\n\t\tpublic long nextLong() {\n\t\t\treturn Long.parseLong(nextString());\n\t\t}\n\n\t\tpublic double nextDouble() {\n\t\t\treturn Double.parseDouble(nextString());\n\t\t}\n\n\t\tpublic int[] nextIntArray(int n) {\n\t\t\tint[] res = new int[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tres[i] = nextInt();\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic int[] nextIntArrayDec(int n) {\n\t\t\tint[] res = new int[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tres[i] = nextInt() - 1;\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic int[] nextIntArray1Index(int n) {\n\t\t\tint[] res = new int[n + 1];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tres[i + 1] = nextInt();\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic long[] nextLongArray(int n) {\n\t\t\tlong[] res = new long[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tres[i] = nextLong();\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic long[] nextLongArrayDec(int n) {\n\t\t\tlong[] res = new long[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tres[i] = nextLong() - 1;\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic long[] nextLongArray1Index(int n) {\n\t\t\tlong[] res = new long[n + 1];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tres[i + 1] = nextLong();\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic double[] nextDoubleArray(int n) {\n\t\t\tdouble[] res = new double[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tres[i] = nextDouble();\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic InputReader(InputStream inputStream) {\n\t\t\tin = new BufferedReader(new InputStreamReader(inputStream));\n\t\t\ttok = new StringTokenizer(\"\");\n\t\t}\n\t}\n\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke is introducing a robot arm with the following properties to his factory:\n\nThe robot arm consists of m sections and m+1 joints. The sections are numbered 1, 2, ..., m, and the joints are numbered 0, 1, ..., m. Section i connects Joint i-1 and Joint i. The length of Section i is d_i.\n\nFor each section, its mode can be specified individually. There are four modes: L, R, D and U. The mode of a section decides the direction of that section. If we consider the factory as a coordinate plane, the position of Joint i will be determined as follows (we denote its coordinates as (x_i, y_i)):\n\n(x_0, y_0) = (0, 0).\n\nIf the mode of Section i is L, (x_{i}, y_{i}) = (x_{i-1} - d_{i}, y_{i-1}).\n\nIf the mode of Section i is R, (x_{i}, y_{i}) = (x_{i-1} + d_{i}, y_{i-1}).\n\nIf the mode of Section i is D, (x_{i}, y_{i}) = (x_{i-1}, y_{i-1} - d_{i}).\n\nIf the mode of Section i is U, (x_{i}, y_{i}) = (x_{i-1}, y_{i-1} + d_{i}).\n\nSnuke would like to introduce a robot arm so that the position of Joint m can be matched with all of the N points (X_1, Y_1), (X_2, Y_2), ..., (X_N, Y_N) by properly specifying the modes of the sections.\nIs this possible?\nIf so, find such a robot arm and how to bring Joint m to each point (X_j, Y_j).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 1000\n\n-10^9 \\leq X_i \\leq 10^9\n\n-10^9 \\leq Y_i \\leq 10^9\n\nPartial Score\n\nIn the test cases worth 300 points, -10 \\leq X_i \\leq 10 and -10 \\leq Y_i \\leq 10 hold.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 Y_1\nX_2 Y_2\n:\nX_N Y_N\n\nOutput\n\nIf the condition can be satisfied, follow the following format. If the condition cannot be satisfied, print -1.\n\nm\nd_1 d_2 ... d_m\nw_1\nw_2\n:\nw_N\n\nm and d_i are the configurations of the robot arm. Refer to the problem statement for what each of them means.\nHere, 1 \\leq m \\leq 40 and 1 \\leq d_i \\leq 10^{12} must hold. Also, m and d_i must all be integers.\n\nw_j is a string of length m that represents the way to bring Joint m of the robot arm to point (X_j, Y_j).\nThe i-th character of w_j should be one of the letters L, R, D and U, representing the mode of Section i.\n\nSample Input 1\n\n3\n-1 0\n0 3\n2 -1\n\nSample Output 1\n\n2\n1 2\nRL\nUU\nDR\n\nIn the given way to bring Joint m of the robot arm to each (X_j, Y_j), the positions of the joints will be as follows:\n\nTo (X_1, Y_1) = (-1, 0): First, the position of Joint 0 is (x_0, y_0) = (0, 0). As the mode of Section 1 is R, the position of Joint 1 is (x_1, y_1) = (1, 0). Then, as the mode of Section 2 is L, the position of Joint 2 is (x_2, y_2) = (-1, 0).\n\nTo (X_2, Y_2) = (0, 3): (x_0, y_0) = (0, 0), (x_1, y_1) = (0, 1), (x_2, y_2) = (0, 3).\n\nTo (X_3, Y_3) = (2, -1): (x_0, y_0) = (0, 0), (x_1, y_1) = (0, -1), (x_2, y_2) = (2, -1).\n\nSample Input 2\n\n5\n0 0\n1 0\n2 0\n3 0\n4 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n2\n1 1\n1 1\n\nSample Output 3\n\n2\n1 1\nRU\nUR\n\nThere may be duplicated points among (X_j, Y_j).\n\nSample Input 4\n\n3\n-7 -3\n7 3\n-3 -7\n\nSample Output 4\n\n5\n3 1 4 1 5\nLRDUL\nRDULR\nDULRD", "sample_input": "3\n-1 0\n0 3\n2 -1\n"}, "reference_outputs": ["2\n1 2\nRL\nUU\nDR\n"], "source_document_id": "p03247", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke is introducing a robot arm with the following properties to his factory:\n\nThe robot arm consists of m sections and m+1 joints. The sections are numbered 1, 2, ..., m, and the joints are numbered 0, 1, ..., m. Section i connects Joint i-1 and Joint i. The length of Section i is d_i.\n\nFor each section, its mode can be specified individually. There are four modes: L, R, D and U. The mode of a section decides the direction of that section. If we consider the factory as a coordinate plane, the position of Joint i will be determined as follows (we denote its coordinates as (x_i, y_i)):\n\n(x_0, y_0) = (0, 0).\n\nIf the mode of Section i is L, (x_{i}, y_{i}) = (x_{i-1} - d_{i}, y_{i-1}).\n\nIf the mode of Section i is R, (x_{i}, y_{i}) = (x_{i-1} + d_{i}, y_{i-1}).\n\nIf the mode of Section i is D, (x_{i}, y_{i}) = (x_{i-1}, y_{i-1} - d_{i}).\n\nIf the mode of Section i is U, (x_{i}, y_{i}) = (x_{i-1}, y_{i-1} + d_{i}).\n\nSnuke would like to introduce a robot arm so that the position of Joint m can be matched with all of the N points (X_1, Y_1), (X_2, Y_2), ..., (X_N, Y_N) by properly specifying the modes of the sections.\nIs this possible?\nIf so, find such a robot arm and how to bring Joint m to each point (X_j, Y_j).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 1000\n\n-10^9 \\leq X_i \\leq 10^9\n\n-10^9 \\leq Y_i \\leq 10^9\n\nPartial Score\n\nIn the test cases worth 300 points, -10 \\leq X_i \\leq 10 and -10 \\leq Y_i \\leq 10 hold.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 Y_1\nX_2 Y_2\n:\nX_N Y_N\n\nOutput\n\nIf the condition can be satisfied, follow the following format. If the condition cannot be satisfied, print -1.\n\nm\nd_1 d_2 ... d_m\nw_1\nw_2\n:\nw_N\n\nm and d_i are the configurations of the robot arm. Refer to the problem statement for what each of them means.\nHere, 1 \\leq m \\leq 40 and 1 \\leq d_i \\leq 10^{12} must hold. Also, m and d_i must all be integers.\n\nw_j is a string of length m that represents the way to bring Joint m of the robot arm to point (X_j, Y_j).\nThe i-th character of w_j should be one of the letters L, R, D and U, representing the mode of Section i.\n\nSample Input 1\n\n3\n-1 0\n0 3\n2 -1\n\nSample Output 1\n\n2\n1 2\nRL\nUU\nDR\n\nIn the given way to bring Joint m of the robot arm to each (X_j, Y_j), the positions of the joints will be as follows:\n\nTo (X_1, Y_1) = (-1, 0): First, the position of Joint 0 is (x_0, y_0) = (0, 0). As the mode of Section 1 is R, the position of Joint 1 is (x_1, y_1) = (1, 0). Then, as the mode of Section 2 is L, the position of Joint 2 is (x_2, y_2) = (-1, 0).\n\nTo (X_2, Y_2) = (0, 3): (x_0, y_0) = (0, 0), (x_1, y_1) = (0, 1), (x_2, y_2) = (0, 3).\n\nTo (X_3, Y_3) = (2, -1): (x_0, y_0) = (0, 0), (x_1, y_1) = (0, -1), (x_2, y_2) = (2, -1).\n\nSample Input 2\n\n5\n0 0\n1 0\n2 0\n3 0\n4 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n2\n1 1\n1 1\n\nSample Output 3\n\n2\n1 1\nRU\nUR\n\nThere may be duplicated points among (X_j, Y_j).\n\nSample Input 4\n\n3\n-7 -3\n7 3\n-3 -7\n\nSample Output 4\n\n5\n3 1 4 1 5\nLRDUL\nRDULR\nDULRD", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3935, "cpu_time_ms": 127, "memory_kb": 23892}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s624913701", "group_id": "codeNet:p03253", "input_text": "\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static long N;\n\tpublic static long M;\n\tpublic static long divide = 1000000007;\n\tpublic static Map div = new HashMap<>();\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tN = sc.nextInt();\n\t\tM = sc.nextLong();\n\t\twhile(M != 1) {\n\t\t\tfor(long i = 2; i < M + 1; i++) {\n\t\t\t\tif(M % i == 0) {\n\t\t\t\t\tif(div.containsKey(i)) {\n\t\t\t\t\t\tlong value = div.get(i);\n\t\t\t\t\t\tdiv.put(i, value + 1);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdiv.put(i, 1l);\n\t\t\t\t\t}\n\t\t\t\t\tM /= i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tlong ans = 0;\n\t\tfor(Map.Entry e : div.entrySet()) {\n\t\t\tans = (((long) Comb(N + e.getValue() - 1, e.getValue()) % divide) * ans) % divide;\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n\n\tpublic static double Comb(long i, long j) {\n\t\treturn Fact(i) / Fact(j);\n\t}\n\n\tpublic static long Fact(long i) {\n\t\tif(i == 1) {\n\t\t\treturn 1;\n\t\t} else {\n\t\t\treturn i * Fact(i - 1);\n\t\t}\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1560225879, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03253.html", "problem_id": "p03253", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03253/input.txt", "sample_output_relpath": "derived/input_output/data/p03253/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03253/Java/s624913701.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s624913701", "user_id": "u153556810"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static long N;\n\tpublic static long M;\n\tpublic static long divide = 1000000007;\n\tpublic static Map div = new HashMap<>();\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tN = sc.nextInt();\n\t\tM = sc.nextLong();\n\t\twhile(M != 1) {\n\t\t\tfor(long i = 2; i < M + 1; i++) {\n\t\t\t\tif(M % i == 0) {\n\t\t\t\t\tif(div.containsKey(i)) {\n\t\t\t\t\t\tlong value = div.get(i);\n\t\t\t\t\t\tdiv.put(i, value + 1);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdiv.put(i, 1l);\n\t\t\t\t\t}\n\t\t\t\t\tM /= i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tlong ans = 0;\n\t\tfor(Map.Entry e : div.entrySet()) {\n\t\t\tans = (((long) Comb(N + e.getValue() - 1, e.getValue()) % divide) * ans) % divide;\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n\n\tpublic static double Comb(long i, long j) {\n\t\treturn Fact(i) / Fact(j);\n\t}\n\n\tpublic static long Fact(long i) {\n\t\tif(i == 1) {\n\t\t\treturn 1;\n\t\t} else {\n\t\t\treturn i * Fact(i - 1);\n\t\t}\n\t}\n\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given positive integers N and M.\n\nHow many sequences a of length N consisting of positive integers satisfy a_1 \\times a_2 \\times ... \\times a_N = M? Find the count modulo 10^9+7.\n\nHere, two sequences a' and a'' are considered different when there exists some i such that a_i' \\neq a_i''.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n2 6\n\nSample Output 1\n\n4\n\nFour sequences satisfy the condition: \\{a_1, a_2\\} = \\{1, 6\\}, \\{2, 3\\}, \\{3, 2\\} and \\{6, 1\\}.\n\nSample Input 2\n\n3 12\n\nSample Output 2\n\n18\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n957870001", "sample_input": "2 6\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03253", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given positive integers N and M.\n\nHow many sequences a of length N consisting of positive integers satisfy a_1 \\times a_2 \\times ... \\times a_N = M? Find the count modulo 10^9+7.\n\nHere, two sequences a' and a'' are considered different when there exists some i such that a_i' \\neq a_i''.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n2 6\n\nSample Output 1\n\n4\n\nFour sequences satisfy the condition: \\{a_1, a_2\\} = \\{1, 6\\}, \\{2, 3\\}, \\{3, 2\\} and \\{6, 1\\}.\n\nSample Input 2\n\n3 12\n\nSample Output 2\n\n18\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n957870001", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 985, "cpu_time_ms": 501, "memory_kb": 32852}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s937525410", "group_id": "codeNet:p03253", "input_text": "import java.util.*;\n\nclass Main\n{\n static long MOD = 1000000007;\n\n public static void main (String[] args)\n {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int M = sc.nextInt();\n\n //Mの素因数分解\n\n int x = M;\n int[] mm = new int[50];\n Arrays.fill(mm, 0);\n\n int i = 2;\n int index = 0;\n while( x > 1){\n if(x % i == 0){\n int count = 0;\n while(x % i == 0){\n count++;\n x /= i;\n }\n mm[index] = count;\n }\n else{\n if(mm[index] > 0) index++;\n i++;\n }\n }\n long ans = 1;\n\n int K = index + 1;\n\n for(int j = 0; j < K; j++){\n ans *= calComb(N + mm[j] - 1, Math.min(N-1, mm[j]));\n ans %= MOD;\n }\n System.out.println(ans);\n }\n\n public static long calComb (int n, int m){\n long sumMul = 1;\n long sumDiv1 = 1;\n long ans = 1;\n for(int i = n - m; i < n; i++){\n sumMul *= i + 1;\n sumMul %= MOD;\n sumDiv1 *= n - i;\n sumDiv1 %= MOD;\n }\n sumDiv1 = modPow(sumDiv1, MOD - 2);\n ans *= sumMul * sumDiv1;\n ans %= MOD;\n // System.out.println(sumDiv1);\n return ans;\n }\n public static long modPow(long n, long p){\n if(p == 0) return 1;\n else if( p % 2 == 0){\n long halfP = p / 2;\n return (long) ( Math.pow(modPow(n, halfP), 2) )% MOD;\n }\n else{\n return ( n * modPow(n, p - 1) )% MOD;\n }\n }\n}", "language": "Java", "metadata": {"date": 1537801134, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03253.html", "problem_id": "p03253", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03253/input.txt", "sample_output_relpath": "derived/input_output/data/p03253/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03253/Java/s937525410.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s937525410", "user_id": "u434662823"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*;\n\nclass Main\n{\n static long MOD = 1000000007;\n\n public static void main (String[] args)\n {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int M = sc.nextInt();\n\n //Mの素因数分解\n\n int x = M;\n int[] mm = new int[50];\n Arrays.fill(mm, 0);\n\n int i = 2;\n int index = 0;\n while( x > 1){\n if(x % i == 0){\n int count = 0;\n while(x % i == 0){\n count++;\n x /= i;\n }\n mm[index] = count;\n }\n else{\n if(mm[index] > 0) index++;\n i++;\n }\n }\n long ans = 1;\n\n int K = index + 1;\n\n for(int j = 0; j < K; j++){\n ans *= calComb(N + mm[j] - 1, Math.min(N-1, mm[j]));\n ans %= MOD;\n }\n System.out.println(ans);\n }\n\n public static long calComb (int n, int m){\n long sumMul = 1;\n long sumDiv1 = 1;\n long ans = 1;\n for(int i = n - m; i < n; i++){\n sumMul *= i + 1;\n sumMul %= MOD;\n sumDiv1 *= n - i;\n sumDiv1 %= MOD;\n }\n sumDiv1 = modPow(sumDiv1, MOD - 2);\n ans *= sumMul * sumDiv1;\n ans %= MOD;\n // System.out.println(sumDiv1);\n return ans;\n }\n public static long modPow(long n, long p){\n if(p == 0) return 1;\n else if( p % 2 == 0){\n long halfP = p / 2;\n return (long) ( Math.pow(modPow(n, halfP), 2) )% MOD;\n }\n else{\n return ( n * modPow(n, p - 1) )% MOD;\n }\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given positive integers N and M.\n\nHow many sequences a of length N consisting of positive integers satisfy a_1 \\times a_2 \\times ... \\times a_N = M? Find the count modulo 10^9+7.\n\nHere, two sequences a' and a'' are considered different when there exists some i such that a_i' \\neq a_i''.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n2 6\n\nSample Output 1\n\n4\n\nFour sequences satisfy the condition: \\{a_1, a_2\\} = \\{1, 6\\}, \\{2, 3\\}, \\{3, 2\\} and \\{6, 1\\}.\n\nSample Input 2\n\n3 12\n\nSample Output 2\n\n18\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n957870001", "sample_input": "2 6\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03253", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given positive integers N and M.\n\nHow many sequences a of length N consisting of positive integers satisfy a_1 \\times a_2 \\times ... \\times a_N = M? Find the count modulo 10^9+7.\n\nHere, two sequences a' and a'' are considered different when there exists some i such that a_i' \\neq a_i''.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n2 6\n\nSample Output 1\n\n4\n\nFour sequences satisfy the condition: \\{a_1, a_2\\} = \\{1, 6\\}, \\{2, 3\\}, \\{3, 2\\} and \\{6, 1\\}.\n\nSample Input 2\n\n3 12\n\nSample Output 2\n\n18\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n957870001", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1693, "cpu_time_ms": 225, "memory_kb": 23892}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s230673714", "group_id": "codeNet:p03255", "input_text": "import java.util.*;\n\nclass Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n long X = sc.nextLong();\n long[] p = new long[n];\n for(int i=0;i=0;i--){\n long less = 5*p[i]+X;\n long more = (2*cur+3)*p[i];\n if(more>less) break;\n else{\n cur++;\n cnt++;\n ans += more;\n }\n }\n }\n System.out.println(ans);\n }\n}\n// [\"a\",\"ba\",\"bc\",\"bcb\",\"bcd\",\"bd\"]\n// \"abcd\"", "language": "Java", "metadata": {"date": 1545070314, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03255.html", "problem_id": "p03255", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03255/input.txt", "sample_output_relpath": "derived/input_output/data/p03255/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03255/Java/s230673714.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s230673714", "user_id": "u925103765"}, "prompt_components": {"gold_output": "355\n", "input_to_evaluate": "import java.util.*;\n\nclass Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n long X = sc.nextLong();\n long[] p = new long[n];\n for(int i=0;i=0;i--){\n long less = 5*p[i]+X;\n long more = (2*cur+3)*p[i];\n if(more>less) break;\n else{\n cur++;\n cnt++;\n ans += more;\n }\n }\n }\n System.out.println(ans);\n }\n}\n// [\"a\",\"ba\",\"bc\",\"bcb\",\"bcd\",\"bd\"]\n// \"abcd\"", "problem_context": "Score : 700 points\n\nProblem Statement\n\nSnuke has decided to use a robot to clean his room.\n\nThere are N pieces of trash on a number line.\nThe i-th piece from the left is at position x_i.\nWe would like to put all of them in a trash bin at position 0.\n\nFor the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \\leq 10^{9} holds.\n\nThe robot is initially at position 0.\nIt can freely move left and right along the number line, pick up a piece of trash when it comes to the position of that piece, carry any number of pieces of trash and put them in the trash bin when it comes to position 0. It is not allowed to put pieces of trash anywhere except in the trash bin.\n\nThe robot consumes X points of energy when the robot picks up a piece of trash, or put pieces of trash in the trash bin. (Putting any number of pieces of trash in the trash bin consumes X points of energy.)\nAlso, the robot consumes (k+1)^{2} points of energy to travel by a distance of 1 when the robot is carrying k pieces of trash.\n\nFind the minimum amount of energy required to put all the N pieces of trash in the trash bin.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^{5}\n\n0 < x_1 < ... < x_N \\leq 10^9\n\n1 \\leq X \\leq 10^9\n\nAll values in input are integers.\n\nPartial Scores\n\n400 points will be awarded for passing the test set satisfying N \\leq 2000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nx_1 x_2 ... x_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 100\n1 10\n\nSample Output 1\n\n355\n\nTravel to position 10 by consuming 10 points of energy.\n\nPick up the piece of trash by consuming 100 points of energy.\n\nTravel to position 1 by consuming 36 points of energy.\n\nPick up the piece of trash by consuming 100 points of energy.\n\nTravel to position 0 by consuming 9 points of energy.\n\nPut the two pieces of trash in the trash bin by consuming 100 points of energy.\n\nThis strategy consumes a total of 10+100+36+100+9+100=355 points of energy.\n\nSample Input 2\n\n5 1\n1 999999997 999999998 999999999 1000000000\n\nSample Output 2\n\n19999999983\n\nSample Input 3\n\n10 8851025\n38 87 668 3175 22601 65499 90236 790604 4290609 4894746\n\nSample Output 3\n\n150710136\n\nSample Input 4\n\n16 10\n1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408\n\nSample Output 4\n\n3256017715", "sample_input": "2 100\n1 10\n"}, "reference_outputs": ["355\n"], "source_document_id": "p03255", "source_text": "Score : 700 points\n\nProblem Statement\n\nSnuke has decided to use a robot to clean his room.\n\nThere are N pieces of trash on a number line.\nThe i-th piece from the left is at position x_i.\nWe would like to put all of them in a trash bin at position 0.\n\nFor the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \\leq 10^{9} holds.\n\nThe robot is initially at position 0.\nIt can freely move left and right along the number line, pick up a piece of trash when it comes to the position of that piece, carry any number of pieces of trash and put them in the trash bin when it comes to position 0. It is not allowed to put pieces of trash anywhere except in the trash bin.\n\nThe robot consumes X points of energy when the robot picks up a piece of trash, or put pieces of trash in the trash bin. (Putting any number of pieces of trash in the trash bin consumes X points of energy.)\nAlso, the robot consumes (k+1)^{2} points of energy to travel by a distance of 1 when the robot is carrying k pieces of trash.\n\nFind the minimum amount of energy required to put all the N pieces of trash in the trash bin.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^{5}\n\n0 < x_1 < ... < x_N \\leq 10^9\n\n1 \\leq X \\leq 10^9\n\nAll values in input are integers.\n\nPartial Scores\n\n400 points will be awarded for passing the test set satisfying N \\leq 2000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nx_1 x_2 ... x_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 100\n1 10\n\nSample Output 1\n\n355\n\nTravel to position 10 by consuming 10 points of energy.\n\nPick up the piece of trash by consuming 100 points of energy.\n\nTravel to position 1 by consuming 36 points of energy.\n\nPick up the piece of trash by consuming 100 points of energy.\n\nTravel to position 0 by consuming 9 points of energy.\n\nPut the two pieces of trash in the trash bin by consuming 100 points of energy.\n\nThis strategy consumes a total of 10+100+36+100+9+100=355 points of energy.\n\nSample Input 2\n\n5 1\n1 999999997 999999998 999999999 1000000000\n\nSample Output 2\n\n19999999983\n\nSample Input 3\n\n10 8851025\n38 87 668 3175 22601 65499 90236 790604 4290609 4894746\n\nSample Output 3\n\n150710136\n\nSample Input 4\n\n16 10\n1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408\n\nSample Output 4\n\n3256017715", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 808, "cpu_time_ms": 604, "memory_kb": 80488}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s318577970", "group_id": "codeNet:p03264", "input_text": "import java.util.*;\n \npublic class Main {\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n int K = sc.nextInt();\n int ans;\n if (K%2 == 0)\n ans = (K/2)*(K/2);\n else\n ans = (K/2)*(K/2+1);\n System.out.println(ans);\n }\n} ", "language": "Java", "metadata": {"date": 1592887943, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p03264.html", "problem_id": "p03264", "resource_group": "high_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/Java/s318577970.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s318577970", "user_id": "u442877951"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*;\n \npublic class Main {\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n int K = sc.nextInt();\n int ans;\n if (K%2 == 0)\n ans = (K/2)*(K/2);\n else\n ans = (K/2)*(K/2+1);\n System.out.println(ans);\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": 279, "cpu_time_ms": 117, "memory_kb": 35724}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s469896283", "group_id": "codeNet:p03265", "input_text": "import java.util.*;\n\nclass Main{\n\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint x1 = sc.nextInt();\n\t\tint y1 = sc.nextInt();\n\t\tint x2 = sc.nextInt();\n\t\tint y2 = sc.nextInt();\n\n\t\tint wid = x2 - x1;\n\t\tint heg = y2 - y1;\n\n\t\tSystem.out.print(x2 - heg + \" \");\n\t\tSystem.out.print(y2 + wid + \" \");\n\t\tSystem.out.print(x1 - heg + \" \");\n\t\tSystem.out.println(y1 + wid);\n\n\n\t}\n}", "language": "Java", "metadata": {"date": 1580353425, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03265.html", "problem_id": "p03265", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03265/input.txt", "sample_output_relpath": "derived/input_output/data/p03265/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03265/Java/s469896283.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s469896283", "user_id": "u936066246"}, "prompt_components": {"gold_output": "-1 1 -1 0\n", "input_to_evaluate": "import java.util.*;\n\nclass Main{\n\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint x1 = sc.nextInt();\n\t\tint y1 = sc.nextInt();\n\t\tint x2 = sc.nextInt();\n\t\tint y2 = sc.nextInt();\n\n\t\tint wid = x2 - x1;\n\t\tint heg = y2 - y1;\n\n\t\tSystem.out.print(x2 - heg + \" \");\n\t\tSystem.out.print(y2 + wid + \" \");\n\t\tSystem.out.print(x1 - heg + \" \");\n\t\tSystem.out.println(y1 + wid);\n\n\n\t}\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a square in the xy-plane. The coordinates of its four vertices are (x_1,y_1),(x_2,y_2),(x_3,y_3) and (x_4,y_4) in counter-clockwise order.\n(Assume that the positive x-axis points right, and the positive y-axis points up.)\n\nTakahashi remembers (x_1,y_1) and (x_2,y_2), but he has forgot (x_3,y_3) and (x_4,y_4).\n\nGiven x_1,x_2,y_1,y_2, restore x_3,y_3,x_4,y_4. It can be shown that x_3,y_3,x_4 and y_4 uniquely exist and have integer values.\n\nConstraints\n\n|x_1|,|y_1|,|x_2|,|y_2| \\leq 100\n\n(x_1,y_1) ≠ (x_2,y_2)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 y_1 x_2 y_2\n\nOutput\n\nPrint x_3,y_3,x_4 and y_4 as integers, in this order.\n\nSample Input 1\n\n0 0 0 1\n\nSample Output 1\n\n-1 1 -1 0\n\n(0,0),(0,1),(-1,1),(-1,0) is the four vertices of a square in counter-clockwise order.\nNote that (x_3,y_3)=(1,1),(x_4,y_4)=(1,0) is not accepted, as the vertices are in clockwise order.\n\nSample Input 2\n\n2 3 6 6\n\nSample Output 2\n\n3 10 -1 7\n\nSample Input 3\n\n31 -41 -59 26\n\nSample Output 3\n\n-126 -64 -36 -131", "sample_input": "0 0 0 1\n"}, "reference_outputs": ["-1 1 -1 0\n"], "source_document_id": "p03265", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a square in the xy-plane. The coordinates of its four vertices are (x_1,y_1),(x_2,y_2),(x_3,y_3) and (x_4,y_4) in counter-clockwise order.\n(Assume that the positive x-axis points right, and the positive y-axis points up.)\n\nTakahashi remembers (x_1,y_1) and (x_2,y_2), but he has forgot (x_3,y_3) and (x_4,y_4).\n\nGiven x_1,x_2,y_1,y_2, restore x_3,y_3,x_4,y_4. It can be shown that x_3,y_3,x_4 and y_4 uniquely exist and have integer values.\n\nConstraints\n\n|x_1|,|y_1|,|x_2|,|y_2| \\leq 100\n\n(x_1,y_1) ≠ (x_2,y_2)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 y_1 x_2 y_2\n\nOutput\n\nPrint x_3,y_3,x_4 and y_4 as integers, in this order.\n\nSample Input 1\n\n0 0 0 1\n\nSample Output 1\n\n-1 1 -1 0\n\n(0,0),(0,1),(-1,1),(-1,0) is the four vertices of a square in counter-clockwise order.\nNote that (x_3,y_3)=(1,1),(x_4,y_4)=(1,0) is not accepted, as the vertices are in clockwise order.\n\nSample Input 2\n\n2 3 6 6\n\nSample Output 2\n\n3 10 -1 7\n\nSample Input 3\n\n31 -41 -59 26\n\nSample Output 3\n\n-126 -64 -36 -131", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 405, "cpu_time_ms": 98, "memory_kb": 23764}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s488459874", "group_id": "codeNet:p03265", "input_text": "import java.util.Scanner;\n\npublic class Main{\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint x1 = scan.nextInt();\n\t\tint y1 = scan.nextInt();\n\t\tint x2 = scan.nextInt();\n\t\tint y2 = scan.nextInt();\n\t\tscan.close();\n\t\t//int l = (int)Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));\n\t\tint v1x = x2 - x1;\n\t\tint v1y = y2 - y1;\n\t\tint x4 = -v1y + x1;\n\t\tint y4 = v1x + y1;\n\t\tint v2x = x1 - x4;\n\t\tint v2y = y1 - y4;\n\t\tint x3 = -v2y + x4;\n\t\tint y3 = v2x + y4;\n\n\t\tSystem.out.println(x3 + \" \" + y3 + \" \" + x4 + \" \" + y4);\n\n\n\t}\n}", "language": "Java", "metadata": {"date": 1535852987, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03265.html", "problem_id": "p03265", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03265/input.txt", "sample_output_relpath": "derived/input_output/data/p03265/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03265/Java/s488459874.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s488459874", "user_id": "u634209474"}, "prompt_components": {"gold_output": "-1 1 -1 0\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main{\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint x1 = scan.nextInt();\n\t\tint y1 = scan.nextInt();\n\t\tint x2 = scan.nextInt();\n\t\tint y2 = scan.nextInt();\n\t\tscan.close();\n\t\t//int l = (int)Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));\n\t\tint v1x = x2 - x1;\n\t\tint v1y = y2 - y1;\n\t\tint x4 = -v1y + x1;\n\t\tint y4 = v1x + y1;\n\t\tint v2x = x1 - x4;\n\t\tint v2y = y1 - y4;\n\t\tint x3 = -v2y + x4;\n\t\tint y3 = v2x + y4;\n\n\t\tSystem.out.println(x3 + \" \" + y3 + \" \" + x4 + \" \" + y4);\n\n\n\t}\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a square in the xy-plane. The coordinates of its four vertices are (x_1,y_1),(x_2,y_2),(x_3,y_3) and (x_4,y_4) in counter-clockwise order.\n(Assume that the positive x-axis points right, and the positive y-axis points up.)\n\nTakahashi remembers (x_1,y_1) and (x_2,y_2), but he has forgot (x_3,y_3) and (x_4,y_4).\n\nGiven x_1,x_2,y_1,y_2, restore x_3,y_3,x_4,y_4. It can be shown that x_3,y_3,x_4 and y_4 uniquely exist and have integer values.\n\nConstraints\n\n|x_1|,|y_1|,|x_2|,|y_2| \\leq 100\n\n(x_1,y_1) ≠ (x_2,y_2)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 y_1 x_2 y_2\n\nOutput\n\nPrint x_3,y_3,x_4 and y_4 as integers, in this order.\n\nSample Input 1\n\n0 0 0 1\n\nSample Output 1\n\n-1 1 -1 0\n\n(0,0),(0,1),(-1,1),(-1,0) is the four vertices of a square in counter-clockwise order.\nNote that (x_3,y_3)=(1,1),(x_4,y_4)=(1,0) is not accepted, as the vertices are in clockwise order.\n\nSample Input 2\n\n2 3 6 6\n\nSample Output 2\n\n3 10 -1 7\n\nSample Input 3\n\n31 -41 -59 26\n\nSample Output 3\n\n-126 -64 -36 -131", "sample_input": "0 0 0 1\n"}, "reference_outputs": ["-1 1 -1 0\n"], "source_document_id": "p03265", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a square in the xy-plane. The coordinates of its four vertices are (x_1,y_1),(x_2,y_2),(x_3,y_3) and (x_4,y_4) in counter-clockwise order.\n(Assume that the positive x-axis points right, and the positive y-axis points up.)\n\nTakahashi remembers (x_1,y_1) and (x_2,y_2), but he has forgot (x_3,y_3) and (x_4,y_4).\n\nGiven x_1,x_2,y_1,y_2, restore x_3,y_3,x_4,y_4. It can be shown that x_3,y_3,x_4 and y_4 uniquely exist and have integer values.\n\nConstraints\n\n|x_1|,|y_1|,|x_2|,|y_2| \\leq 100\n\n(x_1,y_1) ≠ (x_2,y_2)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 y_1 x_2 y_2\n\nOutput\n\nPrint x_3,y_3,x_4 and y_4 as integers, in this order.\n\nSample Input 1\n\n0 0 0 1\n\nSample Output 1\n\n-1 1 -1 0\n\n(0,0),(0,1),(-1,1),(-1,0) is the four vertices of a square in counter-clockwise order.\nNote that (x_3,y_3)=(1,1),(x_4,y_4)=(1,0) is not accepted, as the vertices are in clockwise order.\n\nSample Input 2\n\n2 3 6 6\n\nSample Output 2\n\n3 10 -1 7\n\nSample Input 3\n\n31 -41 -59 26\n\nSample Output 3\n\n-126 -64 -36 -131", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 564, "cpu_time_ms": 94, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s323750535", "group_id": "codeNet:p03266", "input_text": "import java.util.Scanner;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint K = sc.nextInt();\n\t\tint ans;\n\t\tif(K % 2 == 1)\n\t\t\tans = (int)Math.pow(N/K, 3);\n\t\telse if(2*N/K % 2 == 1)\n\t\t\tans = (int)(Math.pow(N/K, 3) + Math.pow(N/K+1, 3));\n\t\telse\n\t\t\tans = (int)Math.pow(N/K, 3) * 2;\n\t\tSystem.out.println(ans);\n\t}\n\n}", "language": "Java", "metadata": {"date": 1553744994, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03266.html", "problem_id": "p03266", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03266/input.txt", "sample_output_relpath": "derived/input_output/data/p03266/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03266/Java/s323750535.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s323750535", "user_id": "u912599273"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint K = sc.nextInt();\n\t\tint ans;\n\t\tif(K % 2 == 1)\n\t\t\tans = (int)Math.pow(N/K, 3);\n\t\telse if(2*N/K % 2 == 1)\n\t\t\tans = (int)(Math.pow(N/K, 3) + Math.pow(N/K+1, 3));\n\t\telse\n\t\t\tans = (int)Math.pow(N/K, 3) * 2;\n\t\tSystem.out.println(ans);\n\t}\n\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given integers N and K. Find the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K.\nThe order of a,b,c does matter, and some of them can be the same.\n\nConstraints\n\n1 \\leq N,K \\leq 2\\times 10^5\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n9\n\n(1,1,1),(1,1,3),(1,3,1),(1,3,3),(2,2,2),(3,1,1),(3,1,3),(3,3,1) and (3,3,3) satisfy the condition.\n\nSample Input 2\n\n5 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n27\n\nSample Input 4\n\n35897 932\n\nSample Output 4\n\n114191", "sample_input": "3 2\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03266", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given integers N and K. Find the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K.\nThe order of a,b,c does matter, and some of them can be the same.\n\nConstraints\n\n1 \\leq N,K \\leq 2\\times 10^5\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n9\n\n(1,1,1),(1,1,3),(1,3,1),(1,3,3),(2,2,2),(3,1,1),(3,1,3),(3,3,1) and (3,3,3) satisfy the condition.\n\nSample Input 2\n\n5 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n27\n\nSample Input 4\n\n35897 932\n\nSample Output 4\n\n114191", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 392, "cpu_time_ms": 99, "memory_kb": 21716}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s093126605", "group_id": "codeNet:p03266", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n public static void main(String[] args) {\n \n new Main().run();\n }\n\n public void run(){\n\n try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {\n\n String[] lines = in.readLine().split(\" \");\n int n = Integer.parseInt(lines[0]);\n int k = Integer.parseInt(lines[1]);\n\n long ans;\n if((k & 1) == 0) {\n long a = n / k;\n long b = n / (k / 2);\n long c = b - a;\n ans = (a * a * a) + (c * c * c);\n } else {\n long a = n / k;\n ans = a * a * a;\n }\n\n System.out.println(ans);\n }\n catch(IOException e) {\n System.err.println(e);\n }\n }\n}", "language": "Java", "metadata": {"date": 1538249308, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03266.html", "problem_id": "p03266", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03266/input.txt", "sample_output_relpath": "derived/input_output/data/p03266/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03266/Java/s093126605.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s093126605", "user_id": "u217010036"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n public static void main(String[] args) {\n \n new Main().run();\n }\n\n public void run(){\n\n try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {\n\n String[] lines = in.readLine().split(\" \");\n int n = Integer.parseInt(lines[0]);\n int k = Integer.parseInt(lines[1]);\n\n long ans;\n if((k & 1) == 0) {\n long a = n / k;\n long b = n / (k / 2);\n long c = b - a;\n ans = (a * a * a) + (c * c * c);\n } else {\n long a = n / k;\n ans = a * a * a;\n }\n\n System.out.println(ans);\n }\n catch(IOException e) {\n System.err.println(e);\n }\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given integers N and K. Find the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K.\nThe order of a,b,c does matter, and some of them can be the same.\n\nConstraints\n\n1 \\leq N,K \\leq 2\\times 10^5\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n9\n\n(1,1,1),(1,1,3),(1,3,1),(1,3,3),(2,2,2),(3,1,1),(3,1,3),(3,3,1) and (3,3,3) satisfy the condition.\n\nSample Input 2\n\n5 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n27\n\nSample Input 4\n\n35897 932\n\nSample Output 4\n\n114191", "sample_input": "3 2\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03266", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given integers N and K. Find the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K.\nThe order of a,b,c does matter, and some of them can be the same.\n\nConstraints\n\n1 \\leq N,K \\leq 2\\times 10^5\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n9\n\n(1,1,1),(1,1,3),(1,3,1),(1,3,3),(2,2,2),(3,1,1),(3,1,3),(3,3,1) and (3,3,3) satisfy the condition.\n\nSample Input 2\n\n5 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n27\n\nSample Input 4\n\n35897 932\n\nSample Output 4\n\n114191", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 768, "cpu_time_ms": 71, "memory_kb": 22996}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s720304516", "group_id": "codeNet:p03269", "input_text": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n private static class Solver {\n static class Edge {\n static int n;\n int u, v, w;\n private int correct(int u) {\n if (u == n + 1) {\n return 1;\n }\n return u + 1;\n }\n public Edge(int u, int v, int w) {\n// u = correct(u);\n// v = correct(v);\n this.u = u;\n this.v = v;\n this.w = w;\n }\n }\n private void Solve() {\n int L = inp.nextInt();\n int n = 0;\n int[] a = new int[30];\n for (int d = L; d > 0; d /= 2) {\n a[++n] = d % 2;\n }\n for (int i = 1; i <= n / 2; ++i) {\n int tmp = a[i];\n a[i] = a[n - i + 1];\n a[n - i + 1] = tmp;\n }\n\n Edge.n = n;\n List ans = new ArrayList<>();\n for (int i = 1; i <= n - 1; ++i) {\n ans.add(new Edge(i, i + 1, 0));\n ans.add(new Edge(i, i + 1, 1 << (n - i - 1)));\n }\n for (int i = 1, t = 0; i <= n; ++i) {\n if (i > 1 && a[i] == 1) {\n ans.add(new Edge(1, i, t));\n }\n t = t + (a[i] << (n - i));\n }\n\n out.println(n + \" \" + ans.size());\n for (Edge e: ans) {\n out.println(e.u + \" \" + e.v + \" \" + e.w);\n }\n }\n\n static InputReader inp;\n static PrintWriter out;\n }\n\n private static class InputReader {\n private BufferedReader reader;\n private StringTokenizer tokenizer;\n\n private InputReader(InputStream stream) {\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\n tokenizer = null;\n }\n\n private String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n private int nextInt() {\n return Integer.parseInt(next());\n }\n\n private long nextLong() {\n return Long.parseLong(next());\n }\n\n private double nextDouble() {\n return Double.parseDouble(next());\n }\n\n }\n\n public static void main(String[] args) throws IOException {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Solver.inp = new InputReader(inputStream);\n Solver.out = new PrintWriter(outputStream);\n Solver solver = new Solver();\n solver.Solve();\n Solver.out.close();\n }\n}", "language": "Java", "metadata": {"date": 1535851893, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03269.html", "problem_id": "p03269", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03269/input.txt", "sample_output_relpath": "derived/input_output/data/p03269/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03269/Java/s720304516.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s720304516", "user_id": "u424394888"}, "prompt_components": {"gold_output": "8 10\n1 2 0\n2 3 0\n3 4 0\n1 5 0\n2 6 0\n3 7 0\n4 8 0\n5 6 1\n6 7 1\n7 8 1\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n private static class Solver {\n static class Edge {\n static int n;\n int u, v, w;\n private int correct(int u) {\n if (u == n + 1) {\n return 1;\n }\n return u + 1;\n }\n public Edge(int u, int v, int w) {\n// u = correct(u);\n// v = correct(v);\n this.u = u;\n this.v = v;\n this.w = w;\n }\n }\n private void Solve() {\n int L = inp.nextInt();\n int n = 0;\n int[] a = new int[30];\n for (int d = L; d > 0; d /= 2) {\n a[++n] = d % 2;\n }\n for (int i = 1; i <= n / 2; ++i) {\n int tmp = a[i];\n a[i] = a[n - i + 1];\n a[n - i + 1] = tmp;\n }\n\n Edge.n = n;\n List ans = new ArrayList<>();\n for (int i = 1; i <= n - 1; ++i) {\n ans.add(new Edge(i, i + 1, 0));\n ans.add(new Edge(i, i + 1, 1 << (n - i - 1)));\n }\n for (int i = 1, t = 0; i <= n; ++i) {\n if (i > 1 && a[i] == 1) {\n ans.add(new Edge(1, i, t));\n }\n t = t + (a[i] << (n - i));\n }\n\n out.println(n + \" \" + ans.size());\n for (Edge e: ans) {\n out.println(e.u + \" \" + e.v + \" \" + e.w);\n }\n }\n\n static InputReader inp;\n static PrintWriter out;\n }\n\n private static class InputReader {\n private BufferedReader reader;\n private StringTokenizer tokenizer;\n\n private InputReader(InputStream stream) {\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\n tokenizer = null;\n }\n\n private String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n private int nextInt() {\n return Integer.parseInt(next());\n }\n\n private long nextLong() {\n return Long.parseLong(next());\n }\n\n private double nextDouble() {\n return Double.parseDouble(next());\n }\n\n }\n\n public static void main(String[] args) throws IOException {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Solver.inp = new InputReader(inputStream);\n Solver.out = new PrintWriter(outputStream);\n Solver solver = new Solver();\n solver.Solve();\n Solver.out.close();\n }\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nYou are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists.\n\nThe number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N.\n\nThe number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive).\n\nEvery edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices.\n\nThere are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1.\n\nHere, the length of a path is the sum of the lengths of the edges contained in that path, and two paths are considered different when the sets of the edges contained in those paths are different.\n\nConstraints\n\n2 \\leq L \\leq 10^6\n\nL is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL\n\nOutput\n\nIn the first line, print N and M, the number of the vertices and edges in your graph.\nIn the i-th of the following M lines, print three integers u_i,v_i and w_i, representing the starting vertex, the ending vertex and the length of the i-th edge.\nIf there are multiple solutions, any of them will be accepted.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n8 10\n1 2 0\n2 3 0\n3 4 0\n1 5 0\n2 6 0\n3 7 0\n4 8 0\n5 6 1\n6 7 1\n7 8 1\n\nIn the graph represented by the sample output, there are four paths from Vertex 1 to N=8:\n\n1 → 2 → 3 → 4 → 8 with length 0\n\n1 → 2 → 3 → 7 → 8 with length 1\n\n1 → 2 → 6 → 7 → 8 with length 2\n\n1 → 5 → 6 → 7 → 8 with length 3\n\nThere are other possible solutions.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n5 7\n1 2 0\n2 3 1\n3 4 0\n4 5 0\n2 4 0\n1 3 3\n3 5 1", "sample_input": "4\n"}, "reference_outputs": ["8 10\n1 2 0\n2 3 0\n3 4 0\n1 5 0\n2 6 0\n3 7 0\n4 8 0\n5 6 1\n6 7 1\n7 8 1\n"], "source_document_id": "p03269", "source_text": "Score : 700 points\n\nProblem Statement\n\nYou are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists.\n\nThe number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N.\n\nThe number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive).\n\nEvery edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices.\n\nThere are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1.\n\nHere, the length of a path is the sum of the lengths of the edges contained in that path, and two paths are considered different when the sets of the edges contained in those paths are different.\n\nConstraints\n\n2 \\leq L \\leq 10^6\n\nL is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL\n\nOutput\n\nIn the first line, print N and M, the number of the vertices and edges in your graph.\nIn the i-th of the following M lines, print three integers u_i,v_i and w_i, representing the starting vertex, the ending vertex and the length of the i-th edge.\nIf there are multiple solutions, any of them will be accepted.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n8 10\n1 2 0\n2 3 0\n3 4 0\n1 5 0\n2 6 0\n3 7 0\n4 8 0\n5 6 1\n6 7 1\n7 8 1\n\nIn the graph represented by the sample output, there are four paths from Vertex 1 to N=8:\n\n1 → 2 → 3 → 4 → 8 with length 0\n\n1 → 2 → 3 → 7 → 8 with length 1\n\n1 → 2 → 6 → 7 → 8 with length 2\n\n1 → 5 → 6 → 7 → 8 with length 3\n\nThere are other possible solutions.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n5 7\n1 2 0\n2 3 1\n3 4 0\n4 5 0\n2 4 0\n1 3 3\n3 5 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": 2939, "cpu_time_ms": 73, "memory_kb": 21460}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s854879084", "group_id": "codeNet:p03273", "input_text": "\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n int h = sc.nextInt();\n\tint w = sc.nextInt();\n\tchar[][] a = new char[h][w];\n\tfor(int i=0;i H = new HashSet();\n\tHashSet W = new HashSet();\n\tfor(int i=0;i Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n public double nextDouble() { return Double.parseDouble(next());}\n }\n public static class Basic {\n //math\n private final int MAX = 510000;\n private final long MOD = Main.MOD;\n private final long[] fac = new long[MAX];\n private final long[] finv = new long[MAX];\n private final long[] inv = new long[MAX];\n public long factorial(long num) {\n if (num < 2) return 1;\n else return num * factorial(num - 1);\n }\n public int arraySum(int[] array) {\n int ans = 0;\n for (int value : array) ans += value;\n return ans;\n }\n public double log(double base, double antilogarithm) {\n return Math.log(antilogarithm) / Math.log(base);\n }\n public long gcd(long x, long y) {\n if (y == 0) return x;\n else return gcd(y, x % y);\n }\n public long lcm(long x, long y) {\n return x / gcd(x, y) * y;\n }\n public HashMap factorization(long num) {\n HashMap hash = new HashMap<>();\n long n = num;\n long count = 2;\n while (n > 1) {\n while (n % count == 0) {\n n /= count;\n if (hash.containsKey(count)) hash.put(count, hash.get(count) + 1);\n else hash.put(count, 1L);\n }\n count++;\n }\n return hash;\n }\n public int sum(int[] num) {\n int ans = 0;\n for (int i = 0; i < num.length; i++) {\n ans += num[i];\n }\n return ans;\n }\n public int[] reduce(int small, int big) {\n int ins = 2;\n while (ins <= small) {\n if (small % ins == 0 && big % ins == 0) {\n small /= ins;\n big /= ins;\n ins = 2;\n } else {\n ins++;\n }\n }\n return new int[]{small, big};\n }\n public int reduceCount(int small, int big) {\n int ins = 2;\n int ans = 0;\n while (ins <= small) {\n if (small % ins == 0 && big % ins == 0) {\n small /= ins;\n big /= ins;\n ins = 2;\n ans++;\n } else {\n ins++;\n }\n }\n return ans;\n }\n public int binarySearch(int[] array, int target) {\n int pos = -1;\n int left = 0;\n int right = array.length - 1;\n int middle;\n while (pos == -1 && left <= right) {\n middle = (left + right) / 2;\n if (array[middle] == target) pos = middle;\n else if (array[middle] > target) right = middle - 1;\n else left = middle + 1;\n }\n return pos;\n }\n public long modPow(long a, long n, long mod) {\n long res = 1;\n while (n > 0) {\n if ((n & 1) != 0) res = res * a % mod;\n a = a * a % mod;\n n >>= 1;\n }\n return res;\n }\n public long modinv(long a, long mod) {\n return modPow(a, mod - 2, mod);\n }\n public void COMinit() {\n fac[0] = 1;\n fac[1] = 1;\n finv[0] = 1;\n finv[1] = 1;\n inv[1] = 1;\n for (int i = 2; i < MAX; i++) {\n fac[i] = fac[i - 1] * i % MOD;\n inv[i] = MOD - inv[(int)(MOD % i)] * (MOD / i) % MOD;\n finv[i] = finv[i - 1] * inv[i] % MOD;\n }\n }\n public long COM(int n, int k) {\n if (n < k) return 0;\n if (n < 0 || k < 0) return 0;\n return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;\n }\n public long PER(int n, int k){\n return fac[n]*finv[n-k]%MOD;\n }\n public long HCOM(int n, int k) {\n return COM(n + k - 1, k);\n }\n\n //array\n public int[] remove(int[] ar, int pos) {\n int[] ret = new int[ar.length - 1];\n for (int i = 0; i < pos; i++) ret[i] = ar[i];\n for (int i = pos + 1; i < ar.length; i++) ret[i - 1] = ar[i];\n return ret;\n }\n public int[] nextArray(int size,int cons){\n int[] ret = new int[size];\n for (int i=0;i ans[a[0]] + a[2]) {\n ans[a[1]] = ans[a[0]] + a[2];\n if (i == size - 1) {\n System.out.println(\"negative loop\");\n break;\n }\n }\n }\n }\n return ans;\n }//辺を配列の要素として管理。\n\n }\n public static class Queue{\n private final int max = 1000000;\n private final T[] queue = (T[]) new Object[max];\n private int tail = 0; private int head = 0;\n public void init(){this.head = 0; tail = 0;}\n public boolean isEmpty(){return (head==tail);}\n public boolean isFull(){return (head == (tail+1)%max);}\n public void enqueue(T v){\n if (isFull()){\n System.out.println(\"error: queue is full.\");\n return;\n }\n queue[tail++] = v;\n if (tail == max) tail = 0;\n }\n public T dequeue(){\n if (isEmpty()){\n System.out.println(\"error: queue is empty\");\n return null;\n }\n T res = queue[head];\n ++head;\n if (head == max) head = 0;\n return res;\n }\n }\n public static class Deque{\n private final int max = 1000000;\n private final T[] queue = (T[]) new Object[max];\n private int tail = 0; private int head = 0;\n public void init(){this.head = 0; tail = 0;}\n public boolean isEmpty(){return (head==tail);}\n public boolean isFull(){return (head == (tail+1)%max);}\n public void pushFirst(T v){\n if (isFull()){\n System.out.println(\"error: queue is full.\");\n return;\n }\n head--;\n if (head==-1)head=max-1;\n queue[head] = v;\n }\n public void pushLast(T v){\n if (isFull()){\n System.out.println(\"error: queue is full.\");\n return;\n }\n queue[tail++] = v;\n if (tail == max) tail = 0;\n }\n public T popFirst(){\n if (isEmpty()){\n System.out.println(\"error: queue is empty\");\n return null;\n }\n T res = queue[head];\n ++head;\n if (head == max) head = 0;\n return res;\n }\n public T popLast(){\n if (isEmpty()){\n System.out.println(\"error: queue is empty\");\n return null;\n }\n if (--tail==-1)tail=max-1;\n return queue[tail];\n }\n\n public T peekFirst(){\n if (isEmpty()){\n System.out.println(\"error: queue is empty\");\n return null;\n }\n return queue[head];\n }\n public T peekLast(){\n if (isEmpty()){\n System.out.println(\"error: queue is empty\");\n return null;\n }\n return queue[tail];\n }\n }\n public static class Stack{\n private final int max = 100000;\n private final T[] stack =(T[]) new Object[max];\n private int top = 0;\n public boolean isEmpty(){return (top==0);}\n public boolean isFull(){return (top==max);}\n public void init(){top=0;}\n public void push(T v){\n if (isFull()){\n System.out.println(\"error: stack is full.\");\n return;\n }\n stack[top++] = v;\n }\n public T pop(){\n if (isEmpty()){\n System.out.println(\"error: stack is empty\");\n return null;\n }\n return stack[--top];\n }\n public T peek(){\n if (isEmpty()){\n System.out.println(\"error: stack is empty\");\n return null;\n }\n return stack[top];\n }\n }\n public static class Pair{\n private K A;\n private V B;\n Pair(K a,V b){\n A=a;\n B=b;\n }\n public void changeA(K a){A=a;}\n public void changeB(V b){B=b;}\n public void changeAB(K a,V b){A=a;B=b;}\n public static Comparator numberSortWithA = new Comparator() {\n @Override\n public int compare(Object o1, Object o2) {\n Pair p = (Pair)o1;\n Pair q = (Pair)o2;\n if ((int)p.A<(int)q.A)return -1;\n else if ((int)p.A==(int)q.A){\n if ((int)p.B<(int)q.B)return -1;\n else if ((int)p.B==(int)q.B)return 0;\n else return 1;\n }\n else return 1;\n }\n };\n public static Comparator numberSortWithB = new Comparator() {\n @Override\n public int compare(Object o1, Object o2) {\n Pair p = (Pair)o1;\n Pair q = (Pair)o2;\n if ((int)p.B<(int)q.B)return -1;\n else if ((int)p.B==(int)q.B){\n if ((int)p.A<(int)q.A)return -1;\n else if ((int)p.A==(int)q.A)return 0;\n else return 1;\n }\n else return 1;\n }\n };\n }\n public static class Graph{\n private final HashMap> graph = new HashMap<>();\n private final int Size;\n private int[] Depth;\n Graph(int size){\n for (int i=0;i());\n Size = size;\n }\n\n public void addEdge(int node1,int node2){\n if (graph.containsKey(node1)&&graph.containsKey(node2)){\n graph.get(node1).add(node2);\n graph.get(node2).add(node1);\n }\n }\n public void addDirectEdge(int from,int to){\n if (graph.containsKey(from)&&graph.containsKey(to)){\n graph.get(from).add(to);\n }\n }\n public int[] Depth(int root){\n Queue q = new Queue<>();\n q.enqueue(root);\n boolean[] seen = new boolean[Size];\n Arrays.fill(seen, false);\n seen[root]=true;\n int[] depth = new int[Size];\n depth[root]=0;\n while (!q.isEmpty()){\n int v = q.dequeue();\n for (int u : graph.get(v)){\n if (!seen[u]){\n seen[u]=true;\n q.enqueue(u);\n depth[u]=depth[v]+1;\n }\n }\n }\n Depth = depth.clone();\n return depth;\n }\n }\n public static class WeightedGraph{\n private final HashMap> graph = new HashMap<>();\n private final int Size;\n private long[] Depth;\n WeightedGraph(int size){\n for (int i=0;i());\n Size = size;\n }\n\n public void addEdge(int node1,int node2,int weight){\n if (graph.containsKey(node1)&&graph.containsKey(node2)){\n graph.get(node1).put(node2,weight);\n graph.get(node2).put(node1,weight);\n }\n }\n public void addDirectEdge(int from,int to,int weight){\n if (graph.containsKey(from)&&graph.containsKey(to)){\n graph.get(from).put(to,weight);\n }\n }\n public int[] dijkstra(int root){\n Comparator c = new Comparator() {\n @Override\n public int compare(int[] o1, int[] o2) {\n return Integer.compare(o1[1], o2[1]);\n }\n };\n PriorityQueue q = new PriorityQueue<>(c);\n q.add(new int[]{root,0});\n int[] ret = new int[Size];\n Arrays.fill(ret,Integer.MAX_VALUE);\n ret[root]=0;\n while (!q.isEmpty()){\n int[] v = q.poll();\n if (v[1]<=ret[v[0]]){\n HashMap h = graph.get(v[0]);\n for (int u : h.keySet()){\n if (ret[u]>v[1]+h.get(u)){\n ret[u]=v[1]+h.get(u);\n q.add(new int[]{u,ret[u]});\n }\n }\n }\n }\n return ret;\n }\n\n public long[] Depth(int root){\n Queue q = new Queue<>();\n q.enqueue(root);\n boolean[] seen = new boolean[Size];\n Arrays.fill(seen, false);\n seen[root]=true;\n long[] depth = new long[Size];\n depth[root]=0;\n while (!q.isEmpty()){\n int v = q.dequeue();\n for (int u : graph.get(v).keySet()){\n if (!seen[u]){\n seen[u]=true;\n q.enqueue(u);\n depth[u]=depth[v]+graph.get(v).get(u);\n }\n }\n }\n Depth = depth.clone();\n return depth;\n }\n\n }\n public static class UnionFindTree{\n int[] parent;\n int[] rank;\n int[] Size;\n int Number;\n public UnionFindTree(int size){\n this.parent = new int[size];\n this.rank = new int[size];\n this.Size = new int[size];\n makeSet();\n }\n public void makeSet(){\n for (int i=0;irank[yRoot]){\n parent[yRoot] = xRoot;\n Size[xRoot]+=Size[yRoot];\n Number--;\n }else if (rank[xRoot]{\n T[] Array;\n int Width;\n int Length;\n BitSearch(T[] t, int width){\n Array = t;\n Width = width;\n Length = Array.length;\n }\n void start(){\n long max = (long)Math.pow(Width,Length);\n for (long i=0;i H = new HashSet();\n\tHashSet W = new HashSet();\n\tfor(int i=0;i Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n public double nextDouble() { return Double.parseDouble(next());}\n }\n public static class Basic {\n //math\n private final int MAX = 510000;\n private final long MOD = Main.MOD;\n private final long[] fac = new long[MAX];\n private final long[] finv = new long[MAX];\n private final long[] inv = new long[MAX];\n public long factorial(long num) {\n if (num < 2) return 1;\n else return num * factorial(num - 1);\n }\n public int arraySum(int[] array) {\n int ans = 0;\n for (int value : array) ans += value;\n return ans;\n }\n public double log(double base, double antilogarithm) {\n return Math.log(antilogarithm) / Math.log(base);\n }\n public long gcd(long x, long y) {\n if (y == 0) return x;\n else return gcd(y, x % y);\n }\n public long lcm(long x, long y) {\n return x / gcd(x, y) * y;\n }\n public HashMap factorization(long num) {\n HashMap hash = new HashMap<>();\n long n = num;\n long count = 2;\n while (n > 1) {\n while (n % count == 0) {\n n /= count;\n if (hash.containsKey(count)) hash.put(count, hash.get(count) + 1);\n else hash.put(count, 1L);\n }\n count++;\n }\n return hash;\n }\n public int sum(int[] num) {\n int ans = 0;\n for (int i = 0; i < num.length; i++) {\n ans += num[i];\n }\n return ans;\n }\n public int[] reduce(int small, int big) {\n int ins = 2;\n while (ins <= small) {\n if (small % ins == 0 && big % ins == 0) {\n small /= ins;\n big /= ins;\n ins = 2;\n } else {\n ins++;\n }\n }\n return new int[]{small, big};\n }\n public int reduceCount(int small, int big) {\n int ins = 2;\n int ans = 0;\n while (ins <= small) {\n if (small % ins == 0 && big % ins == 0) {\n small /= ins;\n big /= ins;\n ins = 2;\n ans++;\n } else {\n ins++;\n }\n }\n return ans;\n }\n public int binarySearch(int[] array, int target) {\n int pos = -1;\n int left = 0;\n int right = array.length - 1;\n int middle;\n while (pos == -1 && left <= right) {\n middle = (left + right) / 2;\n if (array[middle] == target) pos = middle;\n else if (array[middle] > target) right = middle - 1;\n else left = middle + 1;\n }\n return pos;\n }\n public long modPow(long a, long n, long mod) {\n long res = 1;\n while (n > 0) {\n if ((n & 1) != 0) res = res * a % mod;\n a = a * a % mod;\n n >>= 1;\n }\n return res;\n }\n public long modinv(long a, long mod) {\n return modPow(a, mod - 2, mod);\n }\n public void COMinit() {\n fac[0] = 1;\n fac[1] = 1;\n finv[0] = 1;\n finv[1] = 1;\n inv[1] = 1;\n for (int i = 2; i < MAX; i++) {\n fac[i] = fac[i - 1] * i % MOD;\n inv[i] = MOD - inv[(int)(MOD % i)] * (MOD / i) % MOD;\n finv[i] = finv[i - 1] * inv[i] % MOD;\n }\n }\n public long COM(int n, int k) {\n if (n < k) return 0;\n if (n < 0 || k < 0) return 0;\n return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;\n }\n public long PER(int n, int k){\n return fac[n]*finv[n-k]%MOD;\n }\n public long HCOM(int n, int k) {\n return COM(n + k - 1, k);\n }\n\n //array\n public int[] remove(int[] ar, int pos) {\n int[] ret = new int[ar.length - 1];\n for (int i = 0; i < pos; i++) ret[i] = ar[i];\n for (int i = pos + 1; i < ar.length; i++) ret[i - 1] = ar[i];\n return ret;\n }\n public int[] nextArray(int size,int cons){\n int[] ret = new int[size];\n for (int i=0;i ans[a[0]] + a[2]) {\n ans[a[1]] = ans[a[0]] + a[2];\n if (i == size - 1) {\n System.out.println(\"negative loop\");\n break;\n }\n }\n }\n }\n return ans;\n }//辺を配列の要素として管理。\n\n }\n public static class Queue{\n private final int max = 1000000;\n private final T[] queue = (T[]) new Object[max];\n private int tail = 0; private int head = 0;\n public void init(){this.head = 0; tail = 0;}\n public boolean isEmpty(){return (head==tail);}\n public boolean isFull(){return (head == (tail+1)%max);}\n public void enqueue(T v){\n if (isFull()){\n System.out.println(\"error: queue is full.\");\n return;\n }\n queue[tail++] = v;\n if (tail == max) tail = 0;\n }\n public T dequeue(){\n if (isEmpty()){\n System.out.println(\"error: queue is empty\");\n return null;\n }\n T res = queue[head];\n ++head;\n if (head == max) head = 0;\n return res;\n }\n }\n public static class Deque{\n private final int max = 1000000;\n private final T[] queue = (T[]) new Object[max];\n private int tail = 0; private int head = 0;\n public void init(){this.head = 0; tail = 0;}\n public boolean isEmpty(){return (head==tail);}\n public boolean isFull(){return (head == (tail+1)%max);}\n public void pushFirst(T v){\n if (isFull()){\n System.out.println(\"error: queue is full.\");\n return;\n }\n head--;\n if (head==-1)head=max-1;\n queue[head] = v;\n }\n public void pushLast(T v){\n if (isFull()){\n System.out.println(\"error: queue is full.\");\n return;\n }\n queue[tail++] = v;\n if (tail == max) tail = 0;\n }\n public T popFirst(){\n if (isEmpty()){\n System.out.println(\"error: queue is empty\");\n return null;\n }\n T res = queue[head];\n ++head;\n if (head == max) head = 0;\n return res;\n }\n public T popLast(){\n if (isEmpty()){\n System.out.println(\"error: queue is empty\");\n return null;\n }\n if (--tail==-1)tail=max-1;\n return queue[tail];\n }\n\n public T peekFirst(){\n if (isEmpty()){\n System.out.println(\"error: queue is empty\");\n return null;\n }\n return queue[head];\n }\n public T peekLast(){\n if (isEmpty()){\n System.out.println(\"error: queue is empty\");\n return null;\n }\n return queue[tail];\n }\n }\n public static class Stack{\n private final int max = 100000;\n private final T[] stack =(T[]) new Object[max];\n private int top = 0;\n public boolean isEmpty(){return (top==0);}\n public boolean isFull(){return (top==max);}\n public void init(){top=0;}\n public void push(T v){\n if (isFull()){\n System.out.println(\"error: stack is full.\");\n return;\n }\n stack[top++] = v;\n }\n public T pop(){\n if (isEmpty()){\n System.out.println(\"error: stack is empty\");\n return null;\n }\n return stack[--top];\n }\n public T peek(){\n if (isEmpty()){\n System.out.println(\"error: stack is empty\");\n return null;\n }\n return stack[top];\n }\n }\n public static class Pair{\n private K A;\n private V B;\n Pair(K a,V b){\n A=a;\n B=b;\n }\n public void changeA(K a){A=a;}\n public void changeB(V b){B=b;}\n public void changeAB(K a,V b){A=a;B=b;}\n public static Comparator numberSortWithA = new Comparator() {\n @Override\n public int compare(Object o1, Object o2) {\n Pair p = (Pair)o1;\n Pair q = (Pair)o2;\n if ((int)p.A<(int)q.A)return -1;\n else if ((int)p.A==(int)q.A){\n if ((int)p.B<(int)q.B)return -1;\n else if ((int)p.B==(int)q.B)return 0;\n else return 1;\n }\n else return 1;\n }\n };\n public static Comparator numberSortWithB = new Comparator() {\n @Override\n public int compare(Object o1, Object o2) {\n Pair p = (Pair)o1;\n Pair q = (Pair)o2;\n if ((int)p.B<(int)q.B)return -1;\n else if ((int)p.B==(int)q.B){\n if ((int)p.A<(int)q.A)return -1;\n else if ((int)p.A==(int)q.A)return 0;\n else return 1;\n }\n else return 1;\n }\n };\n }\n public static class Graph{\n private final HashMap> graph = new HashMap<>();\n private final int Size;\n private int[] Depth;\n Graph(int size){\n for (int i=0;i());\n Size = size;\n }\n\n public void addEdge(int node1,int node2){\n if (graph.containsKey(node1)&&graph.containsKey(node2)){\n graph.get(node1).add(node2);\n graph.get(node2).add(node1);\n }\n }\n public void addDirectEdge(int from,int to){\n if (graph.containsKey(from)&&graph.containsKey(to)){\n graph.get(from).add(to);\n }\n }\n public int[] Depth(int root){\n Queue q = new Queue<>();\n q.enqueue(root);\n boolean[] seen = new boolean[Size];\n Arrays.fill(seen, false);\n seen[root]=true;\n int[] depth = new int[Size];\n depth[root]=0;\n while (!q.isEmpty()){\n int v = q.dequeue();\n for (int u : graph.get(v)){\n if (!seen[u]){\n seen[u]=true;\n q.enqueue(u);\n depth[u]=depth[v]+1;\n }\n }\n }\n Depth = depth.clone();\n return depth;\n }\n }\n public static class WeightedGraph{\n private final HashMap> graph = new HashMap<>();\n private final int Size;\n private long[] Depth;\n WeightedGraph(int size){\n for (int i=0;i());\n Size = size;\n }\n\n public void addEdge(int node1,int node2,int weight){\n if (graph.containsKey(node1)&&graph.containsKey(node2)){\n graph.get(node1).put(node2,weight);\n graph.get(node2).put(node1,weight);\n }\n }\n public void addDirectEdge(int from,int to,int weight){\n if (graph.containsKey(from)&&graph.containsKey(to)){\n graph.get(from).put(to,weight);\n }\n }\n public int[] dijkstra(int root){\n Comparator c = new Comparator() {\n @Override\n public int compare(int[] o1, int[] o2) {\n return Integer.compare(o1[1], o2[1]);\n }\n };\n PriorityQueue q = new PriorityQueue<>(c);\n q.add(new int[]{root,0});\n int[] ret = new int[Size];\n Arrays.fill(ret,Integer.MAX_VALUE);\n ret[root]=0;\n while (!q.isEmpty()){\n int[] v = q.poll();\n if (v[1]<=ret[v[0]]){\n HashMap h = graph.get(v[0]);\n for (int u : h.keySet()){\n if (ret[u]>v[1]+h.get(u)){\n ret[u]=v[1]+h.get(u);\n q.add(new int[]{u,ret[u]});\n }\n }\n }\n }\n return ret;\n }\n\n public long[] Depth(int root){\n Queue q = new Queue<>();\n q.enqueue(root);\n boolean[] seen = new boolean[Size];\n Arrays.fill(seen, false);\n seen[root]=true;\n long[] depth = new long[Size];\n depth[root]=0;\n while (!q.isEmpty()){\n int v = q.dequeue();\n for (int u : graph.get(v).keySet()){\n if (!seen[u]){\n seen[u]=true;\n q.enqueue(u);\n depth[u]=depth[v]+graph.get(v).get(u);\n }\n }\n }\n Depth = depth.clone();\n return depth;\n }\n\n }\n public static class UnionFindTree{\n int[] parent;\n int[] rank;\n int[] Size;\n int Number;\n public UnionFindTree(int size){\n this.parent = new int[size];\n this.rank = new int[size];\n this.Size = new int[size];\n makeSet();\n }\n public void makeSet(){\n for (int i=0;irank[yRoot]){\n parent[yRoot] = xRoot;\n Size[xRoot]+=Size[yRoot];\n Number--;\n }else if (rank[xRoot]{\n T[] Array;\n int Width;\n int Length;\n BitSearch(T[] t, int width){\n Array = t;\n Width = width;\n Length = Array.length;\n }\n void start(){\n long max = (long)Math.pow(Width,Length);\n for (long i=0;i list = new ArrayList<>(candleCount);\n\t\tfor (int i = 0; i < candleCount; i++) {\n\t\t\tlist.add(new Cd(i+1, Integer.parseInt(systemInLine[i])));\n\t\t}\n\t\tshowMessage(list);\n\t\tint left = Integer.MIN_VALUE;\n\t\tint right = Integer.MAX_VALUE;\n\t\tint sum = Integer.MAX_VALUE;\n\t\tfor (int i = 0; i < systemInLine.length&&i+burning-1 list = new ArrayList<>(candleCount);\n\t\tfor (int i = 0; i < candleCount; i++) {\n\t\t\tlist.add(new Cd(i+1, Integer.parseInt(systemInLine[i])));\n\t\t}\n\t\tshowMessage(list);\n\t\tint left = Integer.MIN_VALUE;\n\t\tint right = Integer.MAX_VALUE;\n\t\tint sum = Integer.MAX_VALUE;\n\t\tfor (int i = 0; i < systemInLine.length&&i+burning-1 0) {\n if ((n & 1) == 1) {\n ans = ans * x % mod;\n }\n x = x * x % mod;\n n >>= 1;\n }\n return ans;\n */\n if (n == 0) {\n return 1;\n }\n return n % 2 == 0 ?\n pow(x * x % mod, n / 2) % mod :\n x % mod * pow(x, n - 1) % mod;\n }\n }\n\n private static class ModularNFixedCombination {\n\n private final Modular modular;\n private final long[] comb;\n private final long N;\n\n public ModularNFixedCombination(long N, int size, long mod) {\n this.modular = new Modular(mod);\n this.comb = new long[size + 1];\n this.N = N;\n\n comb[0] = 1;\n\n for (int i = 1; i <= size; i++) {\n comb[i] = ((comb[i - 1] * (N - (i - 1))) % mod * modular.inverse(i)) % mod;\n }\n }\n\n long combination(int n, int k) {\n if (n != N) {\n throw new IllegalStateException();\n }\n return comb[k];\n }\n\n long repeatedCombination(int n, int k) {\n return combination(n + k - 1, k);\n }\n }\n\n private static class ModularCombination {\n\n private final long fact[];\n private final long mod;\n private final Modular modular;\n\n public ModularCombination(int size, long mod) {\n this.fact = new long[size + 1];\n this.mod = mod;\n this.modular = new Modular(mod);\n\n this.fact[0] = 1;\n for (int i = 1; i <= size; i++) {\n fact[i] = (fact[i - 1] * i) % mod;\n }\n }\n\n private long factorial(int n) {\n return fact[n];\n }\n\n long combination(int n, int k) {\n return\n (\n (\n (\n factorial(n) * modular.inverse(factorial(n - k))\n ) % mod\n ) * modular.inverse(factorial(k))\n ) % mod;\n }\n\n long repeatedCombination(int n, int k) {\n return combination(n + k - 1, k);\n }\n }\n\n private static class Scanner {\n\n private final InputStream is;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n Scanner(InputStream is) {\n this.is = is;\n }\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = is.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) {\n return buffer[ptr++];\n } else {\n return -1;\n }\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) {\n ptr++;\n }\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {\n throw new NumberFormatException();\n }\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1584305011, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03281.html", "problem_id": "p03281", "resource_group": "high_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/Java/s124095394.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s124095394", "user_id": "u482226328"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.io.InputStream;\nimport java.io.IOException;\nimport java.io.PrintStream;\nimport java.math.*;\nimport java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n solve(System.in, System.out);\n }\n\n static void solve(InputStream is, PrintStream os) {\n Scanner sc = new Scanner(is);\n\n /* read */\n int n = sc.nextInt();\n int ans = 0;\n for (int i = 1; i <= n; i+=2) {\n if (countFactor(i) == 8) ans++;\n }\n\n os.println(ans);\n }\n\n private static int countFactor(int k) {\n int ans = 0;\n for (int i = 1; i <= k; i++) {\n if (k % i == 0) ans++;\n }\n return ans;\n }\n\n private static long gcd(long m, long n) {\n if (m < n) return gcd(n, m);\n if (n == 0) return m;\n return gcd(n, m % n);\n }\n\n private static long lcm(long m, long n) {\n return m / gcd(m, n) * n;\n }\n\n private static class Modular {\n\n private final long mod;\n\n private Modular(long mod) {\n this.mod = mod;\n }\n\n private long inverse(long n) {\n return pow(n, mod - 2) % mod;\n }\n\n private long pow(long x, long n) {\n /*\n long ans = 1;\n while (n > 0) {\n if ((n & 1) == 1) {\n ans = ans * x % mod;\n }\n x = x * x % mod;\n n >>= 1;\n }\n return ans;\n */\n if (n == 0) {\n return 1;\n }\n return n % 2 == 0 ?\n pow(x * x % mod, n / 2) % mod :\n x % mod * pow(x, n - 1) % mod;\n }\n }\n\n private static class ModularNFixedCombination {\n\n private final Modular modular;\n private final long[] comb;\n private final long N;\n\n public ModularNFixedCombination(long N, int size, long mod) {\n this.modular = new Modular(mod);\n this.comb = new long[size + 1];\n this.N = N;\n\n comb[0] = 1;\n\n for (int i = 1; i <= size; i++) {\n comb[i] = ((comb[i - 1] * (N - (i - 1))) % mod * modular.inverse(i)) % mod;\n }\n }\n\n long combination(int n, int k) {\n if (n != N) {\n throw new IllegalStateException();\n }\n return comb[k];\n }\n\n long repeatedCombination(int n, int k) {\n return combination(n + k - 1, k);\n }\n }\n\n private static class ModularCombination {\n\n private final long fact[];\n private final long mod;\n private final Modular modular;\n\n public ModularCombination(int size, long mod) {\n this.fact = new long[size + 1];\n this.mod = mod;\n this.modular = new Modular(mod);\n\n this.fact[0] = 1;\n for (int i = 1; i <= size; i++) {\n fact[i] = (fact[i - 1] * i) % mod;\n }\n }\n\n private long factorial(int n) {\n return fact[n];\n }\n\n long combination(int n, int k) {\n return\n (\n (\n (\n factorial(n) * modular.inverse(factorial(n - k))\n ) % mod\n ) * modular.inverse(factorial(k))\n ) % mod;\n }\n\n long repeatedCombination(int n, int k) {\n return combination(n + k - 1, k);\n }\n }\n\n private static class Scanner {\n\n private final InputStream is;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n Scanner(InputStream is) {\n this.is = is;\n }\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = is.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) {\n return buffer[ptr++];\n } else {\n return -1;\n }\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) {\n ptr++;\n }\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {\n throw new NumberFormatException();\n }\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n }\n}\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\nConstraints\n\nN is an integer between 1 and 200 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n105\n\nSample Output 1\n\n1\n\nAmong the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n0\n\n1 has one divisor. 3, 5 and 7 are all prime and have two divisors. Thus, there is no number that satisfies the condition.", "sample_input": "105\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03281", "source_text": "Score: 200 points\n\nProblem Statement\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\nConstraints\n\nN is an integer between 1 and 200 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n105\n\nSample Output 1\n\n1\n\nAmong the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n0\n\n1 has one divisor. 3, 5 and 7 are all prime and have two divisors. Thus, there is no number that satisfies the condition.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 73, "memory_kb": 21204}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s173266655", "group_id": "codeNet:p03281", "input_text": "import java.util.ArrayList;\nimport java.util.List;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tsc.close();\n\n\t\tint ans = 0;\n\t\tfor (int i = 1; i <= n; i+=2) {\n\t\t\tif (divList(i).size() == 8) {\n\t\t\t\tans++;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n\n\tstatic List divList(long n) {\n\t\tList list = new ArrayList<>();\n\t\tlong end = (long) Math.sqrt(n);\n\t\tfor (int i = 1; i <= end; i++) {\n\t\t\tif (n % i == 0) {\n\t\t\t\tlist.add((long) i);\n\t\t\t}\n\t\t}\n\t\tint i = end * end == n ? list.size() - 2 : list.size() - 1;\n\t\tfor ( ; i >= 0; i--) {\n\t\t\tlist.add(n / list.get(i));\n\t\t}\n\t\treturn list;\n\t}\n}\n", "language": "Java", "metadata": {"date": 1574397312, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03281.html", "problem_id": "p03281", "resource_group": "high_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/Java/s173266655.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s173266655", "user_id": "u522636435"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.List;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tsc.close();\n\n\t\tint ans = 0;\n\t\tfor (int i = 1; i <= n; i+=2) {\n\t\t\tif (divList(i).size() == 8) {\n\t\t\t\tans++;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n\n\tstatic List divList(long n) {\n\t\tList list = new ArrayList<>();\n\t\tlong end = (long) Math.sqrt(n);\n\t\tfor (int i = 1; i <= end; i++) {\n\t\t\tif (n % i == 0) {\n\t\t\t\tlist.add((long) i);\n\t\t\t}\n\t\t}\n\t\tint i = end * end == n ? list.size() - 2 : list.size() - 1;\n\t\tfor ( ; i >= 0; i--) {\n\t\t\tlist.add(n / list.get(i));\n\t\t}\n\t\treturn list;\n\t}\n}\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\nConstraints\n\nN is an integer between 1 and 200 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n105\n\nSample Output 1\n\n1\n\nAmong the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n0\n\n1 has one divisor. 3, 5 and 7 are all prime and have two divisors. Thus, there is no number that satisfies the condition.", "sample_input": "105\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03281", "source_text": "Score: 200 points\n\nProblem Statement\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\nConstraints\n\nN is an integer between 1 and 200 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n105\n\nSample Output 1\n\n1\n\nAmong the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n0\n\n1 has one divisor. 3, 5 and 7 are all prime and have two divisors. Thus, there is no number that satisfies the condition.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 106, "memory_kb": 21972}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s666695372", "group_id": "codeNet:p03281", "input_text": "import java.util.*;\npublic class Main{\n\tstatic int EightDivsJudge(int k){\n\t\tint num = 0;\n\t\tfor(int i=1; i<=((k+1)/2)*2 - 1; i+=2){\n\t\t\tint count = 0;\n\t\t\tfor(int j=1; j<=i; j++){\n\t\t\t\tif(i%j==0)count++;\n\t\t\t}\n\t\t\tif(count==8)num++;\n\t\t}\n\t\treturn num;\n\t}\n\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tSystem.out.println(EightDivsJudge(n));\n\t}\n}", "language": "Java", "metadata": {"date": 1537239451, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03281.html", "problem_id": "p03281", "resource_group": "high_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/Java/s666695372.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s666695372", "user_id": "u643840641"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*;\npublic class Main{\n\tstatic int EightDivsJudge(int k){\n\t\tint num = 0;\n\t\tfor(int i=1; i<=((k+1)/2)*2 - 1; i+=2){\n\t\t\tint count = 0;\n\t\t\tfor(int j=1; j<=i; j++){\n\t\t\t\tif(i%j==0)count++;\n\t\t\t}\n\t\t\tif(count==8)num++;\n\t\t}\n\t\treturn num;\n\t}\n\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tSystem.out.println(EightDivsJudge(n));\n\t}\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\nConstraints\n\nN is an integer between 1 and 200 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n105\n\nSample Output 1\n\n1\n\nAmong the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n0\n\n1 has one divisor. 3, 5 and 7 are all prime and have two divisors. Thus, there is no number that satisfies the condition.", "sample_input": "105\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03281", "source_text": "Score: 200 points\n\nProblem Statement\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\nConstraints\n\nN is an integer between 1 and 200 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n105\n\nSample Output 1\n\n1\n\nAmong the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n0\n\n1 has one divisor. 3, 5 and 7 are all prime and have two divisors. Thus, there is no number that satisfies the condition.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 94, "memory_kb": 22740}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s579459202", "group_id": "codeNet:p03282", "input_text": "import java.util.*;\n \npublic class Main {\n\t\n public static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n \tString S = sc.next();\n \tlong K = sc.nextLong();\n \tint i = 0;\n \tfor (; i < S.length(); i++) {\n \t\tif (S.charAt(i) == '1') {\n \t\t\tcontinue;\n \t\t} else {\n \t\t\tbreak;\n \t\t}\n \t}\n \tif (K <= i) {\n \t\tSystem.out.println(1);\n \t} else {\n \t\tSystem.out.println(S.charAt(i));\n \t}\n }\n}", "language": "Java", "metadata": {"date": 1590131147, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03282.html", "problem_id": "p03282", "resource_group": "high_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/Java/s579459202.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s579459202", "user_id": "u866594486"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*;\n \npublic class Main {\n\t\n public static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n \tString S = sc.next();\n \tlong K = sc.nextLong();\n \tint i = 0;\n \tfor (; i < S.length(); i++) {\n \t\tif (S.charAt(i) == '1') {\n \t\t\tcontinue;\n \t\t} else {\n \t\t\tbreak;\n \t\t}\n \t}\n \tif (K <= i) {\n \t\tSystem.out.println(1);\n \t} else {\n \t\tSystem.out.println(S.charAt(i));\n \t}\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": 446, "cpu_time_ms": 95, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s318695929", "group_id": "codeNet:p03283", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.math.BigDecimal;\nimport java.text.DecimalFormat;\nimport java.util.AbstractMap;\nimport java.util.ArrayDeque;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Comparator;\nimport java.util.Deque;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.PriorityQueue;\nimport java.util.Queue;\nimport java.util.Set;\nimport java.util.TreeMap;\nimport java.util.TreeSet;\n\nimport static java.util.Comparator.*;\t\t\t\t\n\npublic class Main {\n\t\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n MyInput in = new MyInput(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n \n Solver solver = new Solver();\n solver.solve(1, in, out);\n \n out.close();\n }\n \n // ======================================================================\n\n static class PPP {\n \tpublic int key, val;\n \tpublic PPP(int key, int val) {\n \t\tthis.key = key;\n \t\tthis.val = val;\n \t}\n\t\tpublic int getKey() {\n\t\t\treturn key;\n\t\t}\n\t\tpublic void setKey(int key) {\n\t\t\tthis.key = key;\n\t\t}\n\t\tpublic int getVal() {\n\t\t\treturn val;\n\t\t}\n\t\tpublic void setVal(int val) {\n\t\t\tthis.val = val;\n\t\t}\n }\n\tstatic class Solver {\n\n\t\tint N, M, Q;\n\t\tint[][] sum;\t\t// 2次元 累積和\n\t\t\n\t\t// 2次元 累積和の設定\n\t\tvoid buildSumTable(int[] L, int[] R) {\n\t\t\tsum = new int[N+1][N+1];\n \t\tfor(int i=0; i < M; i++) {\n \t\t\tsum[L[i]][R[i]]++;\n \t\t}\n \t\tfor(int i=1; i <= N; i++) {\n \t\tfor(int j=1; j <= N ; j++) {\n \t\t\tsum[i][j] += sum[i][j-1];\n \t\t\tsum[i][j] += sum[i-1][j];\n \t\t\tsum[i][j] -= sum[i-1][j-1];\n \t\t}\n \t\t}\n\t\t}\n\n\t\tpublic void solve(int testNumber, MyInput in, PrintWriter out) {\n\t\t\tN = in.nextInt();\n\t\t\tM = in.nextInt();\n\t\t\tQ = in.nextInt();\n\t\t\tint[] L = new int[M];\n\t\t\tint[] R = new int[M];\n \t\tfor(int i=0; i < M; i++) {\n \t\t\tL[i] = in.nextInt();\n \t\t\tR[i] = in.nextInt();\n \t\t}\n \t\tbuildSumTable(L, R);\n\t\t\tint p, q;\n \t\tfor(int i=0; i < Q; i++) {\n \t\t\tp = in.nextInt();\n \t\t\tq = in.nextInt();\n \t\t\tout.println(sum[q][q] - sum[p-1][q] - sum[q][p-1] + sum[p-1][p-1]);\n \t\t}\n }\n }\n\n // ======================================================================\n static class Pair extends AbstractMap.SimpleEntry {\n /** serialVersionUID. */\n private static final long serialVersionUID = 6411527075103472113L;\n\n public Pair(final K key, final V value) {\n super(key, value);\n }\n } \n static class MyInput {\n private final BufferedReader in;\n private static int pos;\n private static int readLen;\n private static final char[] buffer = new char[1024 * 8];\n private static char[] str = new char[500 * 8 * 2];\n private static boolean[] isDigit = new boolean[256];\n private static boolean[] isSpace = new boolean[256];\n private static boolean[] isLineSep = new boolean[256];\n \n static {\n for (int i = 0; i < 10; i++) {\n isDigit['0' + i] = true;\n }\n isDigit['-'] = true;\n isSpace[' '] = isSpace['\\r'] = isSpace['\\n'] = isSpace['\\t'] = true;\n isLineSep['\\r'] = isLineSep['\\n'] = true;\n }\n \n public MyInput(InputStream is) {\n in = new BufferedReader(new InputStreamReader(is));\n }\n \n public int read() {\n if (pos >= readLen) {\n pos = 0;\n try {\n readLen = in.read(buffer);\n } catch (IOException e) {\n throw new RuntimeException();\n }\n if (readLen <= 0) {\n throw new MyInput.EndOfFileRuntimeException();\n }\n }\n return buffer[pos++];\n }\n \n public int nextInt() {\n int len = 0;\n str[len++] = nextChar();\n len = reads(len, isSpace);\n int i = 0;\n int ret = 0;\n if (str[0] == '-') {\n i = 1;\n }\n for (; i < len; i++) ret = ret * 10 + str[i] - '0';\n if (str[0] == '-') {\n ret = -ret;\n }\n return ret;\n }\n \n public long nextLong() {\n int len = 0;\n str[len++] = nextChar();\n len = reads(len, isSpace);\n int i = 0;\n long ret = 0L;\n if (str[0] == '-') {\n i = 1;\n }\n for (; i < len; i++) ret = ret * 10 + str[i] - '0';\n if (str[0] == '-') {\n ret = -ret;\n }\n return ret;\n }\n \n public String nextString() {\n \tString ret = new String(nextDChar()).trim();\n return ret;\n }\n \n public char[] nextDChar() {\n int len = 0;\n len = reads(len, isSpace);\n char[] ret = new char[len + 1];\n for (int i=0; i < len; i++)\t\tret[i] = str[i];\n ret[len] = 0x00;\n return ret;\n }\n \n public char nextChar() {\n while (true) {\n final int c = read();\n if (!isSpace[c]) {\n return (char) c;\n }\n }\n }\n \n int reads(int len, boolean[] accept) {\n try {\n while (true) {\n final int c = read();\n if (accept[c]) {\n break;\n }\n if (str.length == len) {\n char[] rep = new char[str.length * 3 / 2];\n System.arraycopy(str, 0, rep, 0, str.length);\n str = rep;\n }\n str[len++] = (char) c;\n }\n } catch (MyInput.EndOfFileRuntimeException e) {\n }\n return len;\n }\n \n static class EndOfFileRuntimeException extends RuntimeException {\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1559108958, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03283.html", "problem_id": "p03283", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03283/input.txt", "sample_output_relpath": "derived/input_output/data/p03283/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03283/Java/s318695929.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s318695929", "user_id": "u181039779"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.math.BigDecimal;\nimport java.text.DecimalFormat;\nimport java.util.AbstractMap;\nimport java.util.ArrayDeque;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Comparator;\nimport java.util.Deque;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.PriorityQueue;\nimport java.util.Queue;\nimport java.util.Set;\nimport java.util.TreeMap;\nimport java.util.TreeSet;\n\nimport static java.util.Comparator.*;\t\t\t\t\n\npublic class Main {\n\t\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n MyInput in = new MyInput(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n \n Solver solver = new Solver();\n solver.solve(1, in, out);\n \n out.close();\n }\n \n // ======================================================================\n\n static class PPP {\n \tpublic int key, val;\n \tpublic PPP(int key, int val) {\n \t\tthis.key = key;\n \t\tthis.val = val;\n \t}\n\t\tpublic int getKey() {\n\t\t\treturn key;\n\t\t}\n\t\tpublic void setKey(int key) {\n\t\t\tthis.key = key;\n\t\t}\n\t\tpublic int getVal() {\n\t\t\treturn val;\n\t\t}\n\t\tpublic void setVal(int val) {\n\t\t\tthis.val = val;\n\t\t}\n }\n\tstatic class Solver {\n\n\t\tint N, M, Q;\n\t\tint[][] sum;\t\t// 2次元 累積和\n\t\t\n\t\t// 2次元 累積和の設定\n\t\tvoid buildSumTable(int[] L, int[] R) {\n\t\t\tsum = new int[N+1][N+1];\n \t\tfor(int i=0; i < M; i++) {\n \t\t\tsum[L[i]][R[i]]++;\n \t\t}\n \t\tfor(int i=1; i <= N; i++) {\n \t\tfor(int j=1; j <= N ; j++) {\n \t\t\tsum[i][j] += sum[i][j-1];\n \t\t\tsum[i][j] += sum[i-1][j];\n \t\t\tsum[i][j] -= sum[i-1][j-1];\n \t\t}\n \t\t}\n\t\t}\n\n\t\tpublic void solve(int testNumber, MyInput in, PrintWriter out) {\n\t\t\tN = in.nextInt();\n\t\t\tM = in.nextInt();\n\t\t\tQ = in.nextInt();\n\t\t\tint[] L = new int[M];\n\t\t\tint[] R = new int[M];\n \t\tfor(int i=0; i < M; i++) {\n \t\t\tL[i] = in.nextInt();\n \t\t\tR[i] = in.nextInt();\n \t\t}\n \t\tbuildSumTable(L, R);\n\t\t\tint p, q;\n \t\tfor(int i=0; i < Q; i++) {\n \t\t\tp = in.nextInt();\n \t\t\tq = in.nextInt();\n \t\t\tout.println(sum[q][q] - sum[p-1][q] - sum[q][p-1] + sum[p-1][p-1]);\n \t\t}\n }\n }\n\n // ======================================================================\n static class Pair extends AbstractMap.SimpleEntry {\n /** serialVersionUID. */\n private static final long serialVersionUID = 6411527075103472113L;\n\n public Pair(final K key, final V value) {\n super(key, value);\n }\n } \n static class MyInput {\n private final BufferedReader in;\n private static int pos;\n private static int readLen;\n private static final char[] buffer = new char[1024 * 8];\n private static char[] str = new char[500 * 8 * 2];\n private static boolean[] isDigit = new boolean[256];\n private static boolean[] isSpace = new boolean[256];\n private static boolean[] isLineSep = new boolean[256];\n \n static {\n for (int i = 0; i < 10; i++) {\n isDigit['0' + i] = true;\n }\n isDigit['-'] = true;\n isSpace[' '] = isSpace['\\r'] = isSpace['\\n'] = isSpace['\\t'] = true;\n isLineSep['\\r'] = isLineSep['\\n'] = true;\n }\n \n public MyInput(InputStream is) {\n in = new BufferedReader(new InputStreamReader(is));\n }\n \n public int read() {\n if (pos >= readLen) {\n pos = 0;\n try {\n readLen = in.read(buffer);\n } catch (IOException e) {\n throw new RuntimeException();\n }\n if (readLen <= 0) {\n throw new MyInput.EndOfFileRuntimeException();\n }\n }\n return buffer[pos++];\n }\n \n public int nextInt() {\n int len = 0;\n str[len++] = nextChar();\n len = reads(len, isSpace);\n int i = 0;\n int ret = 0;\n if (str[0] == '-') {\n i = 1;\n }\n for (; i < len; i++) ret = ret * 10 + str[i] - '0';\n if (str[0] == '-') {\n ret = -ret;\n }\n return ret;\n }\n \n public long nextLong() {\n int len = 0;\n str[len++] = nextChar();\n len = reads(len, isSpace);\n int i = 0;\n long ret = 0L;\n if (str[0] == '-') {\n i = 1;\n }\n for (; i < len; i++) ret = ret * 10 + str[i] - '0';\n if (str[0] == '-') {\n ret = -ret;\n }\n return ret;\n }\n \n public String nextString() {\n \tString ret = new String(nextDChar()).trim();\n return ret;\n }\n \n public char[] nextDChar() {\n int len = 0;\n len = reads(len, isSpace);\n char[] ret = new char[len + 1];\n for (int i=0; i < len; i++)\t\tret[i] = str[i];\n ret[len] = 0x00;\n return ret;\n }\n \n public char nextChar() {\n while (true) {\n final int c = read();\n if (!isSpace[c]) {\n return (char) c;\n }\n }\n }\n \n int reads(int len, boolean[] accept) {\n try {\n while (true) {\n final int c = read();\n if (accept[c]) {\n break;\n }\n if (str.length == len) {\n char[] rep = new char[str.length * 3 / 2];\n System.arraycopy(str, 0, rep, 0, str.length);\n str = rep;\n }\n str[len++] = (char) c;\n }\n } catch (MyInput.EndOfFileRuntimeException e) {\n }\n return len;\n }\n \n static class EndOfFileRuntimeException extends RuntimeException {\n }\n }\n}\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nIn Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east.\nA company called AtCoder Express possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i).\nTakahashi the king is interested in the following Q matters:\n\nThe number of the trains that runs strictly within the section from City p_i to City q_i, that is, the number of trains j such that p_i \\leq L_j and R_j \\leq q_i.\n\nAlthough he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him.\n\nConstraints\n\nN is an integer between 1 and 500 (inclusive).\n\nM is an integer between 1 and 200 \\ 000 (inclusive).\n\nQ is an integer between 1 and 100 \\ 000 (inclusive).\n\n1 \\leq L_i \\leq R_i \\leq N (1 \\leq i \\leq M)\n\n1 \\leq p_i \\leq q_i \\leq N (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\nL_1 R_1\nL_2 R_2\n:\nL_M R_M\np_1 q_1\np_2 q_2\n:\np_Q q_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the number of the trains that runs strictly within the section from City p_i to City q_i.\n\nSample Input 1\n\n2 3 1\n1 1\n1 2\n2 2\n1 2\n\nSample Output 1\n\n3\n\nAs all the trains runs within the section from City 1 to City 2, the answer to the only query is 3.\n\nSample Input 2\n\n10 3 2\n1 5\n2 8\n7 10\n1 7\n3 10\n\nSample Output 2\n\n1\n1\n\nThe first query is on the section from City 1 to 7. There is only one train that runs strictly within that section: Train 1.\nThe second query is on the section from City 3 to 10. There is only one train that runs strictly within that section: Train 3.\n\nSample Input 3\n\n10 10 10\n1 6\n2 9\n4 5\n4 7\n4 7\n5 8\n6 6\n6 7\n7 9\n10 10\n1 8\n1 9\n1 10\n2 8\n2 9\n2 10\n3 8\n3 9\n3 10\n1 10\n\nSample Output 3\n\n7\n9\n10\n6\n8\n9\n6\n7\n8\n10", "sample_input": "2 3 1\n1 1\n1 2\n2 2\n1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03283", "source_text": "Score: 400 points\n\nProblem Statement\n\nIn Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east.\nA company called AtCoder Express possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i).\nTakahashi the king is interested in the following Q matters:\n\nThe number of the trains that runs strictly within the section from City p_i to City q_i, that is, the number of trains j such that p_i \\leq L_j and R_j \\leq q_i.\n\nAlthough he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him.\n\nConstraints\n\nN is an integer between 1 and 500 (inclusive).\n\nM is an integer between 1 and 200 \\ 000 (inclusive).\n\nQ is an integer between 1 and 100 \\ 000 (inclusive).\n\n1 \\leq L_i \\leq R_i \\leq N (1 \\leq i \\leq M)\n\n1 \\leq p_i \\leq q_i \\leq N (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\nL_1 R_1\nL_2 R_2\n:\nL_M R_M\np_1 q_1\np_2 q_2\n:\np_Q q_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the number of the trains that runs strictly within the section from City p_i to City q_i.\n\nSample Input 1\n\n2 3 1\n1 1\n1 2\n2 2\n1 2\n\nSample Output 1\n\n3\n\nAs all the trains runs within the section from City 1 to City 2, the answer to the only query is 3.\n\nSample Input 2\n\n10 3 2\n1 5\n2 8\n7 10\n1 7\n3 10\n\nSample Output 2\n\n1\n1\n\nThe first query is on the section from City 1 to 7. There is only one train that runs strictly within that section: Train 1.\nThe second query is on the section from City 3 to 10. There is only one train that runs strictly within that section: Train 3.\n\nSample Input 3\n\n10 10 10\n1 6\n2 9\n4 5\n4 7\n4 7\n5 8\n6 6\n6 7\n7 9\n10 10\n1 8\n1 9\n1 10\n2 8\n2 9\n2 10\n3 8\n3 9\n3 10\n1 10\n\nSample Output 3\n\n7\n9\n10\n6\n8\n9\n6\n7\n8\n10", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6298, "cpu_time_ms": 319, "memory_kb": 32596}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s581887881", "group_id": "codeNet:p03285", "input_text": "import java.util.Scanner;\npublic class Main {\n\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\t\tScanner scan = new Scanner(System.in);\n\t\t\tint N = scan.nextInt();\n\t\t\tint A = N/4;\n\t\t\tint B = N/7;\n\t\t\tint C = N/28;\n\t\t\tint sum = A+B-C;\n\t\t\tSystem.out.println(sum);\n\t\t\t\n\t\t\t\n\t}\n\n}\n\n", "language": "Java", "metadata": {"date": 1557858328, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03285.html", "problem_id": "p03285", "resource_group": "high_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/Java/s581887881.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s581887881", "user_id": "u319181474"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main {\n\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\t\tScanner scan = new Scanner(System.in);\n\t\t\tint N = scan.nextInt();\n\t\t\tint A = N/4;\n\t\t\tint B = N/7;\n\t\t\tint C = N/28;\n\t\t\tint sum = A+B-C;\n\t\t\tSystem.out.println(sum);\n\t\t\t\n\t\t\t\n\t}\n\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.\n\nConstraints\n\nN is an integer between 1 and 100, inclusive.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes; otherwise, print No.\n\nSample Input 1\n\n11\n\nSample Output 1\n\nYes\n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\nSample Input 2\n\n40\n\nSample Output 2\n\nYes\n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\nSample Input 3\n\n3\n\nSample Output 3\n\nNo\n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than 3 dollars, so there is no such way.", "sample_input": "11\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03285", "source_text": "Score : 200 points\n\nProblem Statement\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.\n\nConstraints\n\nN is an integer between 1 and 100, inclusive.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes; otherwise, print No.\n\nSample Input 1\n\n11\n\nSample Output 1\n\nYes\n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\nSample Input 2\n\n40\n\nSample Output 2\n\nYes\n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\nSample Input 3\n\n3\n\nSample Output 3\n\nNo\n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than 3 dollars, so there is no such way.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 308, "cpu_time_ms": 95, "memory_kb": 23508}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s895886594", "group_id": "codeNet:p03285", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner s = new Scanner(System.in);\n int N = s.nextInt();\n String out;\n if((N % 4) % 7 == 0)\n out = \"Yes\";\n else if((N % 7) % 4 == 0)\n out = \"Yes\";\n else if(((N % 11) % 4) % 7 == 0)\n out = \"Yes\";\n else\n out = \"No\";\n System.out.println(out);\n }\n}\n", "language": "Java", "metadata": {"date": 1534037273, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03285.html", "problem_id": "p03285", "resource_group": "high_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/Java/s895886594.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s895886594", "user_id": "u038803010"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner s = new Scanner(System.in);\n int N = s.nextInt();\n String out;\n if((N % 4) % 7 == 0)\n out = \"Yes\";\n else if((N % 7) % 4 == 0)\n out = \"Yes\";\n else if(((N % 11) % 4) % 7 == 0)\n out = \"Yes\";\n else\n out = \"No\";\n System.out.println(out);\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.\n\nConstraints\n\nN is an integer between 1 and 100, inclusive.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes; otherwise, print No.\n\nSample Input 1\n\n11\n\nSample Output 1\n\nYes\n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\nSample Input 2\n\n40\n\nSample Output 2\n\nYes\n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\nSample Input 3\n\n3\n\nSample Output 3\n\nNo\n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than 3 dollars, so there is no such way.", "sample_input": "11\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03285", "source_text": "Score : 200 points\n\nProblem Statement\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.\n\nConstraints\n\nN is an integer between 1 and 100, inclusive.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes; otherwise, print No.\n\nSample Input 1\n\n11\n\nSample Output 1\n\nYes\n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\nSample Input 2\n\n40\n\nSample Output 2\n\nYes\n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\nSample Input 3\n\n3\n\nSample Output 3\n\nNo\n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than 3 dollars, so there is no such way.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 443, "cpu_time_ms": 193, "memory_kb": 23124}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s993370325", "group_id": "codeNet:p03286", "input_text": "import java.util.*;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\t\n\t\tint nb[] = new int[32];\n\t\t\n\t\tint nn = n<0 ? -n:n;\n\t\tfor(int i=0;nn>0;i++){\n\t\t\tnb[i] = nn & 1;\n\t\t\tnn >>= 1;\n\t\t}\n\t\t\n\t\tint ans[] = new int[256];\n\t\tfor(int i = 0;i<32;i+=2){\n\t\t\tif(n>=0){\n\t\t\t\tif(nb[i] == 1 && nb[i+1] == 0)\n\t\t\t\t\tans[i]++;\n\t\t\t\telse if(nb[i] == 0 && nb[i+1] == 1){\n\t\t\t\t\tans[i+1]++;\n\t\t\t\t\tans[i+2]++;\n\t\t\t\t}\n\t\t\t\telse if(nb[i] == 1 && nb[i+1] == 1){\n\t\t\t\t\tans[i]++;\n\t\t\t\t\tans[i+1]++;\n\t\t\t\t\tans[i+2]++;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\tif(nb[i] == 1 && nb[i+1] == 0){\n\t\t\t\t\tans[i]++;\n\t\t\t\t\tans[i+1]++;\n\t\t\t\t}\n\t\t\t\telse if(nb[i] == 0 && nb[i+1] == 1){\n\t\t\t\t\tans[i+1]++;\n\t\t\t\t}\n\t\t\t\telse if(nb[i] == 1 && nb[i+1] == 1){\n\t\t\t\t\tans[i]++;\n\t\t\t\t\tans[i+2]++;\n\t\t\t\t\tans[i+3]++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i =0;i<250;i++){\n\t\t\twhile(ans[i] >= 2){\n\t\t\t\tans[i]-=2;\n\t\t\t\tans[i+1]++;\n\t\t\t\tans[i+2]++;\n\t\t\t}\n\t\t}\n\t\t\n\t\tint p = 255;\n\t\twhile(p >0 && ans[p] == 0){\n\t\t\tp--;\n\t\t}\n\t\tfor(int i=p;i>=0;i--){\n\t\t\tSystem.out.print(ans[i]);\n\t\t}\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1579196815, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03286.html", "problem_id": "p03286", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03286/input.txt", "sample_output_relpath": "derived/input_output/data/p03286/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03286/Java/s993370325.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s993370325", "user_id": "u353919145"}, "prompt_components": {"gold_output": "1011\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\t\n\t\tint nb[] = new int[32];\n\t\t\n\t\tint nn = n<0 ? -n:n;\n\t\tfor(int i=0;nn>0;i++){\n\t\t\tnb[i] = nn & 1;\n\t\t\tnn >>= 1;\n\t\t}\n\t\t\n\t\tint ans[] = new int[256];\n\t\tfor(int i = 0;i<32;i+=2){\n\t\t\tif(n>=0){\n\t\t\t\tif(nb[i] == 1 && nb[i+1] == 0)\n\t\t\t\t\tans[i]++;\n\t\t\t\telse if(nb[i] == 0 && nb[i+1] == 1){\n\t\t\t\t\tans[i+1]++;\n\t\t\t\t\tans[i+2]++;\n\t\t\t\t}\n\t\t\t\telse if(nb[i] == 1 && nb[i+1] == 1){\n\t\t\t\t\tans[i]++;\n\t\t\t\t\tans[i+1]++;\n\t\t\t\t\tans[i+2]++;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\tif(nb[i] == 1 && nb[i+1] == 0){\n\t\t\t\t\tans[i]++;\n\t\t\t\t\tans[i+1]++;\n\t\t\t\t}\n\t\t\t\telse if(nb[i] == 0 && nb[i+1] == 1){\n\t\t\t\t\tans[i+1]++;\n\t\t\t\t}\n\t\t\t\telse if(nb[i] == 1 && nb[i+1] == 1){\n\t\t\t\t\tans[i]++;\n\t\t\t\t\tans[i+2]++;\n\t\t\t\t\tans[i+3]++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i =0;i<250;i++){\n\t\t\twhile(ans[i] >= 2){\n\t\t\t\tans[i]-=2;\n\t\t\t\tans[i+1]++;\n\t\t\t\tans[i+2]++;\n\t\t\t}\n\t\t}\n\t\t\n\t\tint p = 255;\n\t\twhile(p >0 && ans[p] == 0){\n\t\t\tp--;\n\t\t}\n\t\tfor(int i=p;i>=0;i--){\n\t\t\tSystem.out.print(ans[i]);\n\t\t}\n\t}\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven an integer N, find the base -2 representation of N.\n\nHere, S is the base -2 representation of N when the following are all satisfied:\n\nS is a string consisting of 0 and 1.\n\nUnless S = 0, the initial character of S is 1.\n\nLet S = S_k S_{k-1} ... S_0, then S_0 \\times (-2)^0 + S_1 \\times (-2)^1 + ... + S_k \\times (-2)^k = N.\n\nIt can be proved that, for any integer M, the base -2 representation of M is uniquely determined.\n\nConstraints\n\nEvery value in input is integer.\n\n-10^9 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the base -2 representation of N.\n\nSample Input 1\n\n-9\n\nSample Output 1\n\n1011\n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, 1011 is the base -2 representation of -9.\n\nSample Input 2\n\n123456789\n\nSample Output 2\n\n11000101011001101110100010101\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "sample_input": "-9\n"}, "reference_outputs": ["1011\n"], "source_document_id": "p03286", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven an integer N, find the base -2 representation of N.\n\nHere, S is the base -2 representation of N when the following are all satisfied:\n\nS is a string consisting of 0 and 1.\n\nUnless S = 0, the initial character of S is 1.\n\nLet S = S_k S_{k-1} ... S_0, then S_0 \\times (-2)^0 + S_1 \\times (-2)^1 + ... + S_k \\times (-2)^k = N.\n\nIt can be proved that, for any integer M, the base -2 representation of M is uniquely determined.\n\nConstraints\n\nEvery value in input is integer.\n\n-10^9 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the base -2 representation of N.\n\nSample Input 1\n\n-9\n\nSample Output 1\n\n1011\n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, 1011 is the base -2 representation of -9.\n\nSample Input 2\n\n123456789\n\nSample Output 2\n\n11000101011001101110100010101\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1055, "cpu_time_ms": 108, "memory_kb": 21584}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s910705055", "group_id": "codeNet:p03288", "input_text": "import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.Scanner;\n \n\n//result = Math.pow(num1, num3)\n//StringBuffer str = new StringBuffer(hoge1);\n//String hoge2 = str.reverse().toString();\n//map.containsKey(A)\n\n//Map map = new HashMap(n);\n/*for ( キーのデータ型 key : マップの名前.keySet() ) {\n\tデータのデータ型 data = マップの名前.get( key );\n\t\n\t// keyやdataを使った処理;\n}*/\n//int i = Integer.parseInt(s);\n\n//ArrayList cc = new ArrayList<>(n);\n//Collections.sort(list);\n//Array.sort(list);\n//Arrays.asList(c).contains(\"a\")\n//list.set(1,\"walk\");\npublic class Main {\n\tprivate static Scanner sc = new Scanner(System.in);\n\tstatic void p(String ans) {System.out.println(ans);};\n\tstatic void p(int ans) {System.out.println(ans);};\n\tstatic void p(long ans) {System.out.println(ans);};\n\tstatic void p(double ans) {System.out.println(ans);};\n\tstatic String s;\n\tstatic String g;\n\tstatic int a[]=new int[4];\n\tpublic static void main(String[] args) {\n\t\t//String N=sc.next();\n\t\tint a=sc.nextInt();\n\t\tif(a<1200) {\n\t\t\tp(\"ABC\");\n\t\t}else if(a<2800) {\n\t\t\tp(\"ARC\");\n\t\t}else {\n\t\t\tp(\"AGC\");\n\t\t}\n\t}\n\tstatic boolean dfs(int b,int sum,String v) {\n\t\tg=v;\n\t\tif(b==4)return sum==7;\n\t\tif(dfs(b+1,sum+a[b],v+\"+\"))return true;\n\t\tif(dfs(b+1,sum-a[b],v+\"-\"))return true;\n\t\treturn false;\n\t}\n\t\n\n\t\n\t\n\t\n}\n", "language": "Java", "metadata": {"date": 1586282224, "filename_ext": "java", "original_language": "Java7 (OpenJDK 1.7.0)", "problem_description_relpath": "problem_descriptions/p03288.html", "problem_id": "p03288", "resource_group": "high_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/Java/s910705055.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s910705055", "user_id": "u563321291"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.Scanner;\n \n\n//result = Math.pow(num1, num3)\n//StringBuffer str = new StringBuffer(hoge1);\n//String hoge2 = str.reverse().toString();\n//map.containsKey(A)\n\n//Map map = new HashMap(n);\n/*for ( キーのデータ型 key : マップの名前.keySet() ) {\n\tデータのデータ型 data = マップの名前.get( key );\n\t\n\t// keyやdataを使った処理;\n}*/\n//int i = Integer.parseInt(s);\n\n//ArrayList cc = new ArrayList<>(n);\n//Collections.sort(list);\n//Array.sort(list);\n//Arrays.asList(c).contains(\"a\")\n//list.set(1,\"walk\");\npublic class Main {\n\tprivate static Scanner sc = new Scanner(System.in);\n\tstatic void p(String ans) {System.out.println(ans);};\n\tstatic void p(int ans) {System.out.println(ans);};\n\tstatic void p(long ans) {System.out.println(ans);};\n\tstatic void p(double ans) {System.out.println(ans);};\n\tstatic String s;\n\tstatic String g;\n\tstatic int a[]=new int[4];\n\tpublic static void main(String[] args) {\n\t\t//String N=sc.next();\n\t\tint a=sc.nextInt();\n\t\tif(a<1200) {\n\t\t\tp(\"ABC\");\n\t\t}else if(a<2800) {\n\t\t\tp(\"ARC\");\n\t\t}else {\n\t\t\tp(\"AGC\");\n\t\t}\n\t}\n\tstatic boolean dfs(int b,int sum,String v) {\n\t\tg=v;\n\t\tif(b==4)return sum==7;\n\t\tif(dfs(b+1,sum+a[b],v+\"+\"))return true;\n\t\tif(dfs(b+1,sum-a[b],v+\"-\"))return true;\n\t\treturn false;\n\t}\n\t\n\n\t\n\t\n\t\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": 1391, "cpu_time_ms": 95, "memory_kb": 20820}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s260651867", "group_id": "codeNet:p03288", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc=new Scanner(System.in);\n\t\tint R=sc.nextInt();\n\t\tsc.close();\n\t\tif(R<1200) {\n\t\t\tSystem.out.println(\"ABC\");\n\t\t}\n\t\telse if(R>=1200&&R<2800) {\n\t\t\tSystem.out.println(\"ARC\");\n\t\t}\n\t\telse {\n\t\t\tSystem.out.println(\"AGC\");\n\t\t}\n\t}\n}\n", "language": "Java", "metadata": {"date": 1583886672, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03288.html", "problem_id": "p03288", "resource_group": "high_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/Java/s260651867.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s260651867", "user_id": "u754114382"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc=new Scanner(System.in);\n\t\tint R=sc.nextInt();\n\t\tsc.close();\n\t\tif(R<1200) {\n\t\t\tSystem.out.println(\"ABC\");\n\t\t}\n\t\telse if(R>=1200&&R<2800) {\n\t\t\tSystem.out.println(\"ARC\");\n\t\t}\n\t\telse {\n\t\t\tSystem.out.println(\"AGC\");\n\t\t}\n\t}\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": 322, "cpu_time_ms": 100, "memory_kb": 21588}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s400018210", "group_id": "codeNet:p03290", "input_text": "import java.io.*;\nimport java.math.*;\nimport java.util.*;\n\npublic class Main {\n private static boolean debug = false;\n private static boolean elapsed = false;\n\n private static PrintWriter _out = new PrintWriter(System.out);\n private static PrintWriter _err = new PrintWriter(System.err);\n\n private static final int INF = Integer.MAX_VALUE / 2;\n\n private static class Score {\n public int seq;\n public int p;\n public int c;\n public Score(int seq, int p, int c) {\n this.seq = seq;\n this.p = p;\n this.c = c;\n }\n public String toString() {\n return \"[\" + seq + \", \" + p + \", \" + c + \"]\";\n }\n }\n private int min = Integer.MAX_VALUE;\n private void solve(Scanner sc) {\n int D = sc.nextInt();\n // (1+2+..+10)*100+10*10^6 = 5500 + 10^7 < Integer.MAX_VALUE\n int G = sc.nextInt();\n List list = new ArrayList<>();\n for (int i = 0; i < D; ++i) {\n Score s = new Score(i + 1, sc.nextInt(), sc.nextInt());\n list.add(s);\n }\n search(G, list, 0);\n _out.println(min);\n }\n private Set memo = new HashSet<>();\n private void search(int g, List list, int cnt) {\n String key = g + \":\" + cnt;\n if (memo.contains(key)) {\n return;\n }\n memo.add(key);\n\n if (g <= 0) {\n if (cnt < min) {\n min = cnt;\n }\n return;\n }\n\n for (Score s : list) {\n if (s.p > 0) {\n int i = 0;\n while (s.p - i > 0 && g - s.seq * 100 * i > 0) {\n ++i;\n }\n s.p -= i;\n if (s.p == 0) {\n search(g - s.seq * 100 * i - s.c, list, cnt + i);\n } else {\n search(g - s.seq * 100 * i, list, cnt + i);\n }\n s.p += i;\n }\n }\n }\n private static BigInteger C(long n, long r) {\n BigInteger res = BigInteger.ONE;\n for (long i = n; i > n - r; --i) {\n res = res.multiply(BigInteger.valueOf(i));\n }\n for (long i = r; i > 1; --i) {\n res = res.divide(BigInteger.valueOf(i));\n }\n return res;\n }\n private static BigInteger P(long n, long r) {\n BigInteger res = BigInteger.ONE;\n for (long i = n; i > n - r; --i) {\n res = res.multiply(BigInteger.valueOf(i));\n }\n return res;\n }\n /*\n * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9\n * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18\n */\n public static void main(String[] args) {\n long S = System.currentTimeMillis();\n\n Scanner sc = new Scanner(System.in);\n new Main().solve(sc);\n _out.flush();\n\n long G = System.currentTimeMillis();\n if (elapsed) {\n _err.println((G - S) + \"ms\");\n }\n _err.flush();\n }\n}", "language": "Java", "metadata": {"date": 1533523864, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03290.html", "problem_id": "p03290", "resource_group": "high_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/Java/s400018210.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s400018210", "user_id": "u558245386"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.*;\nimport java.math.*;\nimport java.util.*;\n\npublic class Main {\n private static boolean debug = false;\n private static boolean elapsed = false;\n\n private static PrintWriter _out = new PrintWriter(System.out);\n private static PrintWriter _err = new PrintWriter(System.err);\n\n private static final int INF = Integer.MAX_VALUE / 2;\n\n private static class Score {\n public int seq;\n public int p;\n public int c;\n public Score(int seq, int p, int c) {\n this.seq = seq;\n this.p = p;\n this.c = c;\n }\n public String toString() {\n return \"[\" + seq + \", \" + p + \", \" + c + \"]\";\n }\n }\n private int min = Integer.MAX_VALUE;\n private void solve(Scanner sc) {\n int D = sc.nextInt();\n // (1+2+..+10)*100+10*10^6 = 5500 + 10^7 < Integer.MAX_VALUE\n int G = sc.nextInt();\n List list = new ArrayList<>();\n for (int i = 0; i < D; ++i) {\n Score s = new Score(i + 1, sc.nextInt(), sc.nextInt());\n list.add(s);\n }\n search(G, list, 0);\n _out.println(min);\n }\n private Set memo = new HashSet<>();\n private void search(int g, List list, int cnt) {\n String key = g + \":\" + cnt;\n if (memo.contains(key)) {\n return;\n }\n memo.add(key);\n\n if (g <= 0) {\n if (cnt < min) {\n min = cnt;\n }\n return;\n }\n\n for (Score s : list) {\n if (s.p > 0) {\n int i = 0;\n while (s.p - i > 0 && g - s.seq * 100 * i > 0) {\n ++i;\n }\n s.p -= i;\n if (s.p == 0) {\n search(g - s.seq * 100 * i - s.c, list, cnt + i);\n } else {\n search(g - s.seq * 100 * i, list, cnt + i);\n }\n s.p += i;\n }\n }\n }\n private static BigInteger C(long n, long r) {\n BigInteger res = BigInteger.ONE;\n for (long i = n; i > n - r; --i) {\n res = res.multiply(BigInteger.valueOf(i));\n }\n for (long i = r; i > 1; --i) {\n res = res.divide(BigInteger.valueOf(i));\n }\n return res;\n }\n private static BigInteger P(long n, long r) {\n BigInteger res = BigInteger.ONE;\n for (long i = n; i > n - r; --i) {\n res = res.multiply(BigInteger.valueOf(i));\n }\n return res;\n }\n /*\n * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9\n * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18\n */\n public static void main(String[] args) {\n long S = System.currentTimeMillis();\n\n Scanner sc = new Scanner(System.in);\n new Main().solve(sc);\n _out.flush();\n\n long G = System.currentTimeMillis();\n if (elapsed) {\n _err.println((G - S) + \"ms\");\n }\n _err.flush();\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": 3015, "cpu_time_ms": 121, "memory_kb": 22100}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s422089850", "group_id": "codeNet:p03292", "input_text": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.NoSuchElementException;\n\n\npublic class Main{\n\tstatic FastScanner sc = new FastScanner();\n\tstatic PrintWriter out = new PrintWriter(System.out);\n\tpublic static void main(String[] args) {\n\t\tint a = sc.nextInt();\n\t\tint b = sc.nextInt();\n\t\tint c = sc.nextInt();\n\t\t\n\t\tout.println(Math.max(Math.max(a, b),c)-Math.min(Math.min(a, b),c));\n\t\t\n\t\tout.flush();\n\t}\n\t\n\t\tstatic class FastScanner {\n\t\t private final InputStream in = System.in;\n\t\t private final byte[] buffer = new byte[1024];\n\t\t private int ptr = 0;\n\t\t private int buflen = 0;\n\n\t\t private boolean hasNextByte() {\n\t\t if (ptr < buflen) {\n\t\t return true;\n\t\t } else {\n\t\t ptr = 0;\n\t\t try {\n\t\t buflen = in.read(buffer);\n\t\t } catch (IOException e) {\n\t\t e.printStackTrace();\n\t\t }\n\t\t if (buflen <= 0) {\n\t\t return false;\n\t\t }\n\t\t }\n\t\t return true;\n\t\t }\n\n\t\t private int readByte() {\n\t\t if (hasNextByte()) return buffer[ptr++];\n\t\t else return -1;\n\t\t }\n\n\t\t private static boolean isPrintableChar(int c) {\n\t\t return 33 <= c && c <= 126;\n\t\t }\n\n\t\t private void skipUnprintable() {\n\t\t while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n\t\t }\n\n\t\t public boolean hasNext() {\n\t\t skipUnprintable();\n\t\t return hasNextByte();\n\t\t }\n\n\t\t public String next() {\n\t\t if (!hasNext()) throw new NoSuchElementException();\n\t\t StringBuilder sb = new StringBuilder();\n\t\t int b = readByte();\n\t\t while (isPrintableChar(b)) {\n\t\t sb.appendCodePoint(b);\n\t\t b = readByte();\n\t\t }\n\t\t return sb.toString();\n\t\t }\n\n\t\t public long nextLong() {\n\t\t if (!hasNext()) throw new NoSuchElementException();\n\t\t long n = 0;\n\t\t boolean minus = false;\n\t\t int b = readByte();\n\t\t if (b == '-') {\n\t\t minus = true;\n\t\t b = readByte();\n\t\t }\n\t\t if (b < '0' || '9' < b) {\n\t\t throw new NumberFormatException();\n\t\t }\n\t\t while (true) {\n\t\t if ('0' <= b && b <= '9') {\n\t\t n *= 10;\n\t\t n += b - '0';\n\t\t } else if (b == -1 || !isPrintableChar(b)) {\n\t\t return minus ? -n : n;\n\t\t } else {\n\t\t throw new NumberFormatException();\n\t\t }\n\t\t b = readByte();\n\t\t }\n\t\t }\n\n\t\t public int nextInt() {\n\t\t return (int) nextLong();\n\t\t }\n\n\t\t public int[] nextIntArray(int N, boolean oneBased) {\n\t\t if (oneBased) {\n\t\t int[] array = new int[N + 1];\n\t\t for (int i = 1; i <= N; i++) {\n\t\t array[i] = sc.nextInt();\n\t\t }\n\t\t return array;\n\t\t } else {\n\t\t int[] array = new int[N];\n\t\t for (int i = 0; i < N; i++) {\n\t\t array[i] = sc.nextInt();\n\t\t }\n\t\t return array;\n\t\t }\n\t\t }\n\n\t\t public long[] nextLongArray(int N, boolean oneBased) {\n\t\t if (oneBased) {\n\t\t long[] array = new long[N + 1];\n\t\t for (int i = 1; i <= N; i++) {\n\t\t array[i] = sc.nextLong();\n\t\t }\n\t\t return array;\n\t\t } else {\n\t\t long[] array = new long[N];\n\t\t for (int i = 0; i < N; i++) {\n\t\t array[i] = sc.nextLong();\n\t\t }\n\t\t return array;\n\t\t }\n\t\t }\n\t\t }\n\n\t\t}\t \n\n\n\n", "language": "Java", "metadata": {"date": 1562463614, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03292.html", "problem_id": "p03292", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03292/input.txt", "sample_output_relpath": "derived/input_output/data/p03292/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03292/Java/s422089850.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s422089850", "user_id": "u645304546"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.NoSuchElementException;\n\n\npublic class Main{\n\tstatic FastScanner sc = new FastScanner();\n\tstatic PrintWriter out = new PrintWriter(System.out);\n\tpublic static void main(String[] args) {\n\t\tint a = sc.nextInt();\n\t\tint b = sc.nextInt();\n\t\tint c = sc.nextInt();\n\t\t\n\t\tout.println(Math.max(Math.max(a, b),c)-Math.min(Math.min(a, b),c));\n\t\t\n\t\tout.flush();\n\t}\n\t\n\t\tstatic class FastScanner {\n\t\t private final InputStream in = System.in;\n\t\t private final byte[] buffer = new byte[1024];\n\t\t private int ptr = 0;\n\t\t private int buflen = 0;\n\n\t\t private boolean hasNextByte() {\n\t\t if (ptr < buflen) {\n\t\t return true;\n\t\t } else {\n\t\t ptr = 0;\n\t\t try {\n\t\t buflen = in.read(buffer);\n\t\t } catch (IOException e) {\n\t\t e.printStackTrace();\n\t\t }\n\t\t if (buflen <= 0) {\n\t\t return false;\n\t\t }\n\t\t }\n\t\t return true;\n\t\t }\n\n\t\t private int readByte() {\n\t\t if (hasNextByte()) return buffer[ptr++];\n\t\t else return -1;\n\t\t }\n\n\t\t private static boolean isPrintableChar(int c) {\n\t\t return 33 <= c && c <= 126;\n\t\t }\n\n\t\t private void skipUnprintable() {\n\t\t while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n\t\t }\n\n\t\t public boolean hasNext() {\n\t\t skipUnprintable();\n\t\t return hasNextByte();\n\t\t }\n\n\t\t public String next() {\n\t\t if (!hasNext()) throw new NoSuchElementException();\n\t\t StringBuilder sb = new StringBuilder();\n\t\t int b = readByte();\n\t\t while (isPrintableChar(b)) {\n\t\t sb.appendCodePoint(b);\n\t\t b = readByte();\n\t\t }\n\t\t return sb.toString();\n\t\t }\n\n\t\t public long nextLong() {\n\t\t if (!hasNext()) throw new NoSuchElementException();\n\t\t long n = 0;\n\t\t boolean minus = false;\n\t\t int b = readByte();\n\t\t if (b == '-') {\n\t\t minus = true;\n\t\t b = readByte();\n\t\t }\n\t\t if (b < '0' || '9' < b) {\n\t\t throw new NumberFormatException();\n\t\t }\n\t\t while (true) {\n\t\t if ('0' <= b && b <= '9') {\n\t\t n *= 10;\n\t\t n += b - '0';\n\t\t } else if (b == -1 || !isPrintableChar(b)) {\n\t\t return minus ? -n : n;\n\t\t } else {\n\t\t throw new NumberFormatException();\n\t\t }\n\t\t b = readByte();\n\t\t }\n\t\t }\n\n\t\t public int nextInt() {\n\t\t return (int) nextLong();\n\t\t }\n\n\t\t public int[] nextIntArray(int N, boolean oneBased) {\n\t\t if (oneBased) {\n\t\t int[] array = new int[N + 1];\n\t\t for (int i = 1; i <= N; i++) {\n\t\t array[i] = sc.nextInt();\n\t\t }\n\t\t return array;\n\t\t } else {\n\t\t int[] array = new int[N];\n\t\t for (int i = 0; i < N; i++) {\n\t\t array[i] = sc.nextInt();\n\t\t }\n\t\t return array;\n\t\t }\n\t\t }\n\n\t\t public long[] nextLongArray(int N, boolean oneBased) {\n\t\t if (oneBased) {\n\t\t long[] array = new long[N + 1];\n\t\t for (int i = 1; i <= N; i++) {\n\t\t array[i] = sc.nextLong();\n\t\t }\n\t\t return array;\n\t\t } else {\n\t\t long[] array = new long[N];\n\t\t for (int i = 0; i < N; i++) {\n\t\t array[i] = sc.nextLong();\n\t\t }\n\t\t return array;\n\t\t }\n\t\t }\n\t\t }\n\n\t\t}\t \n\n\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou have three tasks, all of which need to be completed.\n\nFirst, you can complete any one task at cost 0.\n\nThen, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|.\n\nHere, |x| denotes the absolute value of x.\n\nFind the minimum total cost required to complete all the task.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_1, A_2, A_3 \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nPrint the minimum total cost required to complete all the task.\n\nSample Input 1\n\n1 6 3\n\nSample Output 1\n\n5\n\nWhen the tasks are completed in the following order, the total cost will be 5, which is the minimum:\n\nComplete the first task at cost 0.\n\nComplete the third task at cost 2.\n\nComplete the second task at cost 3.\n\nSample Input 2\n\n11 5 5\n\nSample Output 2\n\n6\n\nSample Input 3\n\n100 100 100\n\nSample Output 3\n\n0", "sample_input": "1 6 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03292", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou have three tasks, all of which need to be completed.\n\nFirst, you can complete any one task at cost 0.\n\nThen, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|.\n\nHere, |x| denotes the absolute value of x.\n\nFind the minimum total cost required to complete all the task.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_1, A_2, A_3 \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nPrint the minimum total cost required to complete all the task.\n\nSample Input 1\n\n1 6 3\n\nSample Output 1\n\n5\n\nWhen the tasks are completed in the following order, the total cost will be 5, which is the minimum:\n\nComplete the first task at cost 0.\n\nComplete the third task at cost 2.\n\nComplete the second task at cost 3.\n\nSample Input 2\n\n11 5 5\n\nSample Output 2\n\n6\n\nSample Input 3\n\n100 100 100\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3350, "cpu_time_ms": 72, "memory_kb": 23252}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s203470229", "group_id": "codeNet:p03293", "input_text": "import java.util.*;\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n String S = sc.next();\n String T = sc.next();\n String tmp = S ;\n boolean flg = false;\n \n for(int i=0;i= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0) {\n return -1;\n }\n }\n return buf[curChar++];\n }\n\n public String nextString() {\n int c = read();\n while (isSpaceChar(c)) {\n c = read();\n }\n StringBuilder res = new StringBuilder();\n do {\n if (Character.isValidCodePoint(c)) {\n res.appendCodePoint(c);\n }\n c = read();\n } while (!isSpaceChar(c));\n return res.toString();\n }\n\n public boolean isSpaceChar(int c) {\n if (filter != null) {\n return filter.isSpaceChar(c);\n }\n return isWhitespace(c);\n }\n\n public static boolean isWhitespace(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1566172690, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03293.html", "problem_id": "p03293", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03293/input.txt", "sample_output_relpath": "derived/input_output/data/p03293/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03293/Java/s824645845.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s824645845", "user_id": "u953237709"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.io.BufferedWriter;\nimport java.io.Writer;\nimport java.io.OutputStreamWriter;\nimport java.util.InputMismatchException;\nimport java.io.IOException;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author gaidash\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n OutputWriter out = new OutputWriter(outputStream);\n BStringRotation solver = new BStringRotation();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class BStringRotation {\n public void solve(int testNumber, InputReader in, OutputWriter out) {\n String s = in.nextString();\n String t = in.nextString();\n\n String doubled = t + t;\n out.println(doubled.contains(s) ? \"Yes\" : \"No\");\n }\n\n }\n\n static class OutputWriter {\n private final PrintWriter writer;\n\n public OutputWriter(OutputStream outputStream) {\n writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));\n }\n\n public OutputWriter(Writer writer) {\n this.writer = new PrintWriter(writer);\n }\n\n public void print(Object... objects) {\n for (int i = 0; i < objects.length; i++) {\n if (i != 0) {\n writer.print(' ');\n }\n writer.print(objects[i]);\n }\n }\n\n public void println(Object... objects) {\n print(objects);\n writer.println();\n }\n\n public void close() {\n writer.close();\n }\n\n }\n\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private InputReader.SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n\n public int read() {\n if (numChars == -1) {\n throw new InputMismatchException();\n }\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0) {\n return -1;\n }\n }\n return buf[curChar++];\n }\n\n public String nextString() {\n int c = read();\n while (isSpaceChar(c)) {\n c = read();\n }\n StringBuilder res = new StringBuilder();\n do {\n if (Character.isValidCodePoint(c)) {\n res.appendCodePoint(c);\n }\n c = read();\n } while (!isSpaceChar(c));\n return res.toString();\n }\n\n public boolean isSpaceChar(int c) {\n if (filter != null) {\n return filter.isSpaceChar(c);\n }\n return isWhitespace(c);\n }\n\n public static boolean isWhitespace(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\n\n }\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given string S and T consisting of lowercase English letters.\n\nDetermine if S equals T after rotation.\n\nThat is, determine if S equals T after the following operation is performed some number of times:\n\nOperation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}.\n\nHere, |X| denotes the length of the string X.\n\nConstraints\n\n2 \\leq |S| \\leq 100\n\n|S| = |T|\n\nS and T consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf S equals T after rotation, print Yes; if it does not, print No.\n\nSample Input 1\n\nkyoto\ntokyo\n\nSample Output 1\n\nYes\n\nIn the first operation, kyoto becomes okyot.\n\nIn the second operation, okyot becomes tokyo.\n\nSample Input 2\n\nabc\narc\n\nSample Output 2\n\nNo\n\nabc does not equal arc after any number of operations.\n\nSample Input 3\n\naaaaaaaaaaaaaaab\naaaaaaaaaaaaaaab\n\nSample Output 3\n\nYes", "sample_input": "kyoto\ntokyo\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03293", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given string S and T consisting of lowercase English letters.\n\nDetermine if S equals T after rotation.\n\nThat is, determine if S equals T after the following operation is performed some number of times:\n\nOperation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}.\n\nHere, |X| denotes the length of the string X.\n\nConstraints\n\n2 \\leq |S| \\leq 100\n\n|S| = |T|\n\nS and T consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf S equals T after rotation, print Yes; if it does not, print No.\n\nSample Input 1\n\nkyoto\ntokyo\n\nSample Output 1\n\nYes\n\nIn the first operation, kyoto becomes okyot.\n\nIn the second operation, okyot becomes tokyo.\n\nSample Input 2\n\nabc\narc\n\nSample Output 2\n\nNo\n\nabc does not equal arc after any number of operations.\n\nSample Input 3\n\naaaaaaaaaaaaaaab\naaaaaaaaaaaaaaab\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3646, "cpu_time_ms": 74, "memory_kb": 21332}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s376523195", "group_id": "codeNet:p03294", "input_text": "import java.util.Scanner;\n\nclass Main{\n\tpublic static void main(String[] args) {\n\t\tScanner stdIn=new Scanner(System.in);\n\t\tint n=stdIn.nextInt(),a,i;\n\t\tlong s=-n;\n\t\tfor(i=0;i= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0) {\n return -1;\n }\n }\n return buf[curChar++];\n }\n\n public int nextInt() {\n int c = read();\n while (isSpaceChar(c)) {\n c = read();\n }\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n res *= 10;\n res += c - '0';\n c = read();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n\n public boolean isSpaceChar(int c) {\n if (filter != null) {\n return filter.isSpaceChar(c);\n }\n return isWhitespace(c);\n }\n\n public static boolean isWhitespace(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\n\n }\n\n static class OutputWriter {\n private final PrintWriter writer;\n\n public OutputWriter(OutputStream outputStream) {\n writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));\n }\n\n public OutputWriter(Writer writer) {\n this.writer = new PrintWriter(writer);\n }\n\n public void close() {\n writer.close();\n }\n\n public void print(long i) {\n writer.print(i);\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1530794849, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03309.html", "problem_id": "p03309", "resource_group": "high_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/Java/s444212453.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s444212453", "user_id": "u855192343"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.io.BufferedWriter;\nimport java.io.Writer;\nimport java.io.OutputStreamWriter;\nimport java.util.InputMismatchException;\nimport java.io.IOException;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n OutputWriter out = new OutputWriter(outputStream);\n TaskC solver = new TaskC();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class TaskC {\n public void solve(int testNumber, InputReader in, OutputWriter out) {\n int n = in.nextInt();\n int[] arr = new int[n];\n long sum = 0;\n for (int i = 0; i < arr.length; i++) {\n arr[i] = in.nextInt();\n arr[i] = arr[i] - (i + 1);\n }\n Arrays.sort(arr);\n int middle = arr[arr.length / 2];\n for (int i = 0; i < arr.length; i++) {\n sum += Math.abs(arr[i] - middle);\n }\n out.print(sum);\n }\n\n }\n\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private InputReader.SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n\n public int read() {\n if (numChars == -1) {\n throw new InputMismatchException();\n }\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0) {\n return -1;\n }\n }\n return buf[curChar++];\n }\n\n public int nextInt() {\n int c = read();\n while (isSpaceChar(c)) {\n c = read();\n }\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n res *= 10;\n res += c - '0';\n c = read();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n\n public boolean isSpaceChar(int c) {\n if (filter != null) {\n return filter.isSpaceChar(c);\n }\n return isWhitespace(c);\n }\n\n public static boolean isWhitespace(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\n\n }\n\n static class OutputWriter {\n private final PrintWriter writer;\n\n public OutputWriter(OutputStream outputStream) {\n writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));\n }\n\n public OutputWriter(Writer writer) {\n this.writer = new PrintWriter(writer);\n }\n\n public void close() {\n writer.close();\n }\n\n public void print(long i) {\n writer.print(i);\n }\n\n }\n}\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": 3747, "cpu_time_ms": 172, "memory_kb": 23752}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s889677201", "group_id": "codeNet:p03311", "input_text": "import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Optional;\nimport java.util.Scanner;\nimport java.util.Set;\nimport java.util.stream.IntStream;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tMain main = new Main();\n\t\tmain.solve();\n\t}\n\n\tprivate void solve() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint[] a = new int[N];\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\ta[i] = sc.nextInt() - i;\n\t\t}\n\t\tArrays.sort(a);\n\t\tfor (int i = N - 1; i >= 0; i--) {\n\t\t\ta[i] -= a[0];\n\t\t}\n\t\tlong sum = 0L;\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tsum += a[i];\n\t\t}\n\t\tlong min = sum;\n\t\tlong tmpSum = -sum;\n\t\tfor (int i = N - 1; i >= 0; i--) {\n\t\t\tlong tmp = a[i] * ((i + 1) * 2 - N) + tmpSum;\n\t\t\tif (min > tmp) {\n\t\t\t\tmin = tmp;\n\t\t\t}\n\t\t\ttmpSum += a[i] * 2;\n\t\t}\n\t\tSystem.out.println(min);\n\t}\n\n\tinterface CombCalculator {\n\t\tlong comb(int n, int m);\n\t}\n\n\t/**\n\t * 組み合わせ計算を階乗の値で行うクラスです(MOD対応)\n\t * 階乗とその逆元は前計算してテーブルに格納します。\n\t * C(N, N) % M の計算量は O(1)、 前計算でO(max(N, logM))です。\n\t * sizeを1e8より大きい値で実行するとMLEの危険性があります。\n\t * また素数以外のMODには対応していません(逆元の計算に素数の剰余環の性質を利用しているため)。\n\t */\n\tclass FactorialTableCombCalculator implements CombCalculator {\n\t\tint size;\n\t\tlong[] factorialTable;\n\t\tlong[] inverseFactorialTable;\n\t\tlong mod;\n\n\t\tpublic FactorialTableCombCalculator(int size, long mod) {\n\t\t\tthis.size = size;\n\t\t\tfactorialTable = new long[size + 1];\n\t\t\tinverseFactorialTable = new long[size + 1];\n\t\t\tthis.mod = mod;\n\n\t\t\tfactorialTable[0] = 1L;\n\t\t\tfor (int i = 1; i <= size; i++) {\n\t\t\t\tfactorialTable[i] = (factorialTable[i - 1] * i) % mod;\n\t\t\t}\n\t\t\tinverseFactorialTable[size] = inverse(factorialTable[size], mod);\n\t\t\tfor (int i = size - 1; i >= 0; i--) {\n\t\t\t\tinverseFactorialTable[i] = (inverseFactorialTable[i + 1] * (i + 1)) % mod;\n\t\t\t}\n\t\t}\n\n\t\tprivate long inverse(long n, long mod) {\n\t\t\treturn pow(n, mod - 2, mod);\n\t\t}\n\n\t\tprivate long pow(long n, long p, long mod) {\n\t\t\tif (p == 0) {\n\t\t\t\treturn 1L;\n\t\t\t}\n\t\t\tlong half = pow(n, p / 2, mod);\n\t\t\tlong ret = (half * half) % mod;\n\t\t\tif (p % 2 == 1) {\n\t\t\t\tret = (ret * n) % mod;\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\n\t\t@Override\n\t\tpublic long comb(int n, int m) {\n\t\t\tif (n > size) {\n\t\t\t\tthrow new RuntimeException(\"n is greater than size.\");\n\t\t\t}\n\t\t\tif (n < 0 || m < 0 || n < m) {\n\t\t\t\treturn 0L;\n\t\t\t}\n\t\t\treturn (((factorialTable[n] * inverseFactorialTable[m]) % mod) * inverseFactorialTable[n - m]) % mod;\n\t\t}\n\t}\n\n\t/**\n\t * 組み合わせ計算をテーブルで実装したクラスです(MOD対応)\n\t * 前計算でO(N^2), combはO(1)で実行できます\n\t * sizeを2 * 1e4より大きい値で実行するとMLEの危険性があります\n\t */\n\tclass TableCombCalculator implements CombCalculator {\n\t\tlong[][] table;\n\t\tint size;\n\n\t\tpublic TableCombCalculator(int size, long mod) {\n\t\t\tthis.size = size;\n\t\t\ttable = new long[size + 1][];\n\n\t\t\ttable[0] = new long[1];\n\t\t\ttable[0][0] = 1L;\n\t\t\tfor (int n = 1; n <= size; n++) {\n\t\t\t\ttable[n] = new long[n + 1];\n\t\t\t\ttable[n][0] = 1L;\n\t\t\t\tfor (int m = 1; m < n; m++) {\n\t\t\t\t\ttable[n][m] = (table[n - 1][m - 1] + table[n - 1][m]) % mod;\n\t\t\t\t}\n\t\t\t\ttable[n][n] = 1L;\n\t\t\t}\n\t\t}\n\n\t\t@Override\n\t\tpublic long comb(int n, int m) {\n\t\t\tif (n > size) {\n\t\t\t\tthrow new RuntimeException(\"n is greater than size.\");\n\t\t\t}\n\t\t\tif (n < 0 || m < 0 || n < m) {\n\t\t\t\treturn 0L;\n\t\t\t}\n\t\t\treturn table[n][m];\n\t\t}\n\t}\n\n\tinterface Graph {\n\t\tvoid link(int from, int to, long cost);\n\t\tOptional getCost(int from, int to);\n\t\tint getVertexNum();\n\t}\n\n\tinterface FlowResolver {\n\t\tlong maxFlow(int from, int to);\n\t}\n\n\t/**\n\t * グラフの行列による実装\n\t * 接点数の大きいグラフで使うとMLEで死にそう\n\t */\n\tclass ArrayGraph implements Graph {\n\t\tprivate Long[][] costArray;\n\t\tprivate int vertexNum;\n\n\t\tpublic ArrayGraph(int n) {\n\t\t\tcostArray = new Long[n][];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tcostArray[i] = new Long[n];\n\t\t\t}\n\t\t\tvertexNum = n;\n\t\t}\n\n\t\t@Override\n\t\tpublic void link(int from, int to, long cost) {\n\t\t\tcostArray[from][to] = new Long(cost);\n\t\t}\n\n\t\t@Override\n\t\tpublic Optional getCost(int from, int to) {\n\t\t\treturn Optional.ofNullable(costArray[from][to]);\n\t\t}\n\n\t\t@Override\n\t\tpublic int getVertexNum() {\n\t\t\treturn vertexNum;\n\t\t}\n\t}\n\n\t/**\n\t * DFS(深さ優先探索)による実装\n\t * 計算量はO(E*MaxFlow)のはず (E:辺の数, MaxFlow:最大フロー)\n\t */\n\tclass DfsFlowResolver implements FlowResolver {\n\t\tprivate Graph graph;\n\t\tpublic DfsFlowResolver(Graph graph) {\n\t\t\tthis.graph = graph;\n\t\t}\n\n\t\t/**\n\t\t * 最大フロー(最小カット)を求める\n\t\t * @param from 始点(source)のID\n\t\t * @param to 終点(target)のID\n\t\t * @return 最大フロー(最小カット)\n\t\t */\n\t\tpublic long maxFlow(int from, int to) {\n\t\t\tlong sum = 0L;\n\t\t\tlong currentFlow;\n\t\t\tdo {\n\t\t\t\tcurrentFlow = flow(from, to, Long.MAX_VALUE / 3, new boolean[graph.getVertexNum()]);\n\t\t\t\tsum += currentFlow;\n\t\t\t} while (currentFlow > 0);\n\t\t\treturn sum;\n\t\t}\n\n\t\t/**\n\t\t * フローの実行 グラフの更新も行う\n\t\t * @param from 現在いる節点のID\n\t\t * @param to 終点(target)のID\n\t\t * @param current_flow ここまでの流量\n\t\t * @param passed 既に通った節点か否かを格納した配列\n\t\t * @return 終点(target)に流した流量/戻りのグラフの流量\n\t\t */\n\t\tprivate long flow(int from, int to, long current_flow, boolean[] passed) {\n\t\t\tpassed[from] = true;\n\t\t\tif (from == to) {\n\t\t\t\treturn current_flow;\n\t\t\t}\n\t\t\tfor (int id = 0; id < graph.getVertexNum(); id++) {\n\t\t\t\tif (passed[id]) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tOptional cost = graph.getCost(from, id);\n\t\t\t\tif (cost.orElse(0L) > 0) {\n\t\t\t\t\tlong nextFlow = current_flow < cost.get() ? current_flow : cost.get();\n\t\t\t\t\tlong returnFlow = flow(id, to, nextFlow, passed);\n\t\t\t\t\tif (returnFlow > 0) {\n\t\t\t\t\t\tgraph.link(from, id, cost.get() - returnFlow);\n\t\t\t\t\t\tgraph.link(id, from, graph.getCost(id, from).orElse(0L) + returnFlow);\n\t\t\t\t\t\treturn returnFlow;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn 0L;\n\t\t}\n\t}\n\n\t/**\n\t * 1-indexedのBIT配列\n\t */\n\tclass BinaryIndexedTree {\n\t\tprivate long[] array;\n\n\t\tpublic BinaryIndexedTree(int size) {\n\t\t\tthis.array = new long[size + 1];\n\t\t}\n\n\t\t/**\n\t\t * 指定した要素に値を加算する\n\t\t * 計算量はO(logN)\n\t\t * @param index 加算する要素の添字\n\t\t * @param value 加算する量\n\t\t */\n\t\tpublic void add(int index, long value) {\n\t\t\tfor (int i = index; i < array.length; i += (i & -i)) {\n\t\t\t\tarray[i] += value;\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * 1〜指定した要素までの和を取得する\n\t\t * 計算量はO(logN)\n\t\t * @param index 和の終端となる要素の添字\n\t\t * @return 1〜indexまでの和\n\t\t */\n\t\tpublic long getSum(int index) {\n\t\t\tlong sum = 0L;\n\t\t\tfor (int i = index; i > 0; i -= (i & -i)) {\n\t\t\t\tsum += array[i];\n\t\t\t}\n\t\t\treturn sum;\n\t\t}\n\t}\n\n\t/**\n\t * 1-indexedの2次元BIT配列\n\t */\n\tclass BinaryIndexedTree2D {\n\t\tprivate long[][] array;\n\n\t\tpublic BinaryIndexedTree2D(int size1, int size2) {\n\t\t\tthis.array = new long[size1 + 1][];\n\t\t\tfor (int i = 1; i <= size1; i++) {\n\t\t\t\tthis.array[i] = new long[size2 + 1];\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * 指定した要素に値を加算する\n\t\t * 計算量はO(logN * logN)\n\t\t * @param index1 加算する要素の1次元目の添字\n\t\t * @param index2 加算する要素の2次元目の添字\n\t\t * @param value 加算する量\n\t\t */\n\t\tpublic void add(int index1, int index2, long value) {\n\t\t\tfor (int i1 = index1; i1 < array.length; i1 += (i1 & -i1)) {\n\t\t\t\tfor (int i2 = index2; i2 < array.length; i2 += (i2 & -i2)) {\n\t\t\t\t\tarray[i1][i2] += value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * (1,1)〜指定した要素までの矩形和を取得する\n\t\t * 計算量はO(logN * logN)\n\t\t * @param index1 和の終端となる要素の1次元目の添字\n\t\t * @param index2 和の終端となる要素の2次元目の添字\n\t\t * @return (1,1)〜(index1,index2)までの矩形和\n\t\t */\n\t\tpublic long getSum(int index1, int index2) {\n\t\t\tlong sum = 0L;\n\t\t\tfor (int i1 = index1; i1 > 0; i1 -= (i1 & -i1)) {\n\t\t\t\tfor (int i2 = index2; i2 > 0; i2 -= (i2 & -i2)) {\n\t\t\t\t\tsum += array[i1][i2];\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn sum;\n\t\t}\n\t}\n\n\tinterface UnionFind {\n\t\tvoid union(int A, int B);\n\t\tboolean judge(int A, int B);\n\t\tSet getSet(int id);\n\t}\n\n\t/**\n\t * ArrayUnionFindの拡張\n\t * MapSetで根の添字から根にぶら下がる頂点の集合が取得できるようにした\n\t * getSetメソッドをO(logN * logN)に落とせているはず\n\t * ただしunionメソッドは2倍の計算量になっているので注意(オーダーは変わらないはず)\n\t */\n\tclass SetUnionFind extends ArrayUnionFind {\n\t\tMap> map;\n\t\tpublic SetUnionFind(int size) {\n\t\t\tsuper(size);\n\t\t\tmap = new HashMap<>();\n\t\t\tfor (int i = 0; i < size; i++) {\n\t\t\t\tmap.put(i, new HashSet<>());\n\t\t\t\tmap.get(i).add(i);\n\t\t\t}\n\t\t}\n\n\t\t@Override\n\t\tprotected void unionTo(int source, int dest) {\n\t\t\tsuper.unionTo(source, dest);\n\t\t\tmap.get(dest).addAll(map.get(source));\n\t\t}\n\n\t\t@Override\n\t\tpublic Set getSet(int id) {\n\t\t\treturn map.get(root(id));\n\t\t}\n\t}\n\n\t/**\n\t * 配列によるUnionFindの実装\n\t * getSetメソッドはO(NlogN)なのでTLEに注意\n\t */\n\tclass ArrayUnionFind implements UnionFind {\n\t\tint[] parent;\n\t\tint[] rank;\n\t\tint size;\n\t\tpublic ArrayUnionFind(int size) {\n\t\t\tparent = new int[size];\n\t\t\tfor (int i = 0; i < size; i++) {\n\t\t\t\tparent[i] = i;\n\t\t\t}\n\t\t\trank = new int[size];\n\t\t\tthis.size = size;\n\t\t}\n\n\t\t@Override\n\t\tpublic void union(int A, int B) {\n\t\t\tint rootA = root(A);\n\t\t\tint rootB = root(B);\n\t\t\tif (rootA != rootB) {\n\t\t\t\tif (rank[rootA] < rank[rootB]) {\n\t\t\t\t\tunionTo(rootA, rootB);\n\t\t\t\t} else {\n\t\t\t\t\tunionTo(rootB, rootA);\n\t\t\t\t\tif (rank[rootA] == rank[rootB]) {\n\t\t\t\t\t\trank[rootA]++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tprotected void unionTo(int source, int dest) {\n\t\t\tparent[source] = dest;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean judge(int A, int B) {\n\t\t\treturn root(A) == root(B);\n\t\t}\n\n\t\t@Override\n\t\tpublic Set getSet(int id) {\n\t\t\tSet set = new HashSet<>();\n\t\t\tIntStream.range(0, size).filter(i -> judge(i, id)).forEach(set::add);\n\t\t\treturn set;\n\t\t}\n\n\t\tprotected int root(int id) {\n\t\t\tif (parent[id] == id) {\n\t\t\t\treturn id;\n\t\t\t}\n\t\t\tparent[id] = root(parent[id]);\n\t\t\treturn parent[id];\n\t\t}\n\t}\n\n\t/**\n\t * 素数のユーティリティ\n\t */\n\tclass PrimeNumberUtils {\n\t\tboolean[] isPrimeArray;\n\t\tList primes;\n\n\t\t/**\n\t\t * 素数判定の上限となる値を指定してユーティリティを初期化\n\t\t * @param limit 素数判定の上限(この値以上が素数であるか判定しない)\n\t\t */\n\t\tpublic PrimeNumberUtils(int limit) {\n\t\t\tif (limit > 10000000) {\n\t\t\t\tSystem.err.println(\"上限の値が高すぎるため素数ユーティリティの初期化でTLEする可能性が大変高いです\");\n\t\t\t}\n\t\t\tprimes = new ArrayList<>();\n\t\t\tisPrimeArray = new boolean[limit];\n\t\t\tif (limit > 2) {\n\t\t\t\tprimes.add(2);\n\t\t\t\tisPrimeArray[2] = true;\n\t\t\t}\n\n\t\t\tfor (int i = 3; i < limit; i += 2) {\n\t\t\t\tif (isPrime(i, primes)) {\n\t\t\t\t\tprimes.add(i);\n\t\t\t\t\tisPrimeArray[i] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic List getPrimeNumberList() {\n\t\t\treturn primes;\n\t\t}\n\n\t\tpublic boolean isPrime(int n) {\n\t\t\treturn isPrimeArray[n];\n\t\t}\n\n\t\tprivate boolean isPrime(int n, List primes) {\n\t\t\tfor (int prime : primes) {\n\t\t\t\tif (n % prime == 0) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (prime > Math.sqrt(n)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tinterface BitSet {\n\t\tvoid set(int index, boolean bit);\n\t\tboolean get(int index);\n\t\tvoid shiftRight(int num);\n\t\tvoid shiftLeft(int num);\n\t\tvoid or(BitSet bitset);\n\t\tvoid and(BitSet bitset);\n\t}\n\n\t/**\n\t * Longの配列によるBitSetの実装\n\t * get/setはO(1)\n\t * shift/or/andはO(size / 64)\n\t */\n\tclass LongBit implements BitSet {\n\t\tlong[] bitArray;\n\n\t\tpublic LongBit(int size) {\n\t\t\tbitArray = new long[((size + 63) / 64)];\n\t\t}\n\n\t\t@Override\n\t\tpublic void set(int index, boolean bit) {\n\t\t\tint segment = index / 64;\n\t\t\tint inIndex = index % 64;\n\t\t\tif (bit) {\n\t\t\t\tbitArray[segment] |= 1L << inIndex;\n\t\t\t} else {\n\t\t\t\tbitArray[segment] &= ~(1L << inIndex);\n\t\t\t}\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean get(int index) {\n\t\t\tint segment = index / 64;\n\t\t\tint inIndex = index % 64;\n\t\t\treturn (bitArray[segment] & (1L << inIndex)) != 0L;\n\t\t}\n\n\t\t@Override\n\t\tpublic void shiftRight(int num) {\n\t\t\tint shiftSeg = num / 64;\n\t\t\tint shiftInI = num % 64;\n\t\t\tfor (int segment = 0; segment < bitArray.length; segment++) {\n\t\t\t\tint sourceSeg = segment + shiftSeg;\n\t\t\t\tif (sourceSeg < bitArray.length) {\n\t\t\t\t\tbitArray[segment] = bitArray[sourceSeg] >>> shiftInI;\n\t\t\t\t\tif (shiftInI > 0 && sourceSeg + 1 < bitArray.length) {\n\t\t\t\t\t\tbitArray[segment] |= bitArray[sourceSeg + 1] << (64 - shiftInI);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tbitArray[segment] = 0L;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t@Override\n\t\tpublic void shiftLeft(int num) {\n\t\t\tint shiftSeg = num / 64;\n\t\t\tint shiftInI = num % 64;\n\t\t\tfor (int segment = bitArray.length - 1; segment >= 0; segment--) {\n\t\t\t\tint sourceSeg = segment - shiftSeg;\n\t\t\t\tif (sourceSeg >= 0) {\n\t\t\t\t\tbitArray[segment] = bitArray[sourceSeg] << shiftInI;\n\t\t\t\t\tif (shiftInI > 0 && sourceSeg > 0) {\n\t\t\t\t\t\tbitArray[segment] |= bitArray[sourceSeg - 1] >>> (64 - shiftInI);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tbitArray[segment] = 0L;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic long getLong(int segment) {\n\t\t\treturn bitArray[segment];\n\t\t}\n\n\t\t@Override\n\t\tpublic void or(BitSet bitset) {\n\t\t\tif (!(bitset instanceof LongBit)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor (int segment = 0; segment < bitArray.length; segment++) {\n\t\t\t\tbitArray[segment] |= ((LongBit)bitset).getLong(segment);\n\t\t\t}\n\t\t}\n\n\t\t@Override\n\t\tpublic void and(BitSet bitset) {\n\t\t\tif (!(bitset instanceof LongBit)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor (int segment = 0; segment < bitArray.length; segment++) {\n\t\t\t\tbitArray[segment] &= ((LongBit)bitset).getLong(segment);\n\t\t\t}\n\t\t}\n\t}\n\n}", "language": "Java", "metadata": {"date": 1530493548, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03311.html", "problem_id": "p03311", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03311/input.txt", "sample_output_relpath": "derived/input_output/data/p03311/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03311/Java/s889677201.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s889677201", "user_id": "u564054133"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Optional;\nimport java.util.Scanner;\nimport java.util.Set;\nimport java.util.stream.IntStream;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tMain main = new Main();\n\t\tmain.solve();\n\t}\n\n\tprivate void solve() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint[] a = new int[N];\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\ta[i] = sc.nextInt() - i;\n\t\t}\n\t\tArrays.sort(a);\n\t\tfor (int i = N - 1; i >= 0; i--) {\n\t\t\ta[i] -= a[0];\n\t\t}\n\t\tlong sum = 0L;\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tsum += a[i];\n\t\t}\n\t\tlong min = sum;\n\t\tlong tmpSum = -sum;\n\t\tfor (int i = N - 1; i >= 0; i--) {\n\t\t\tlong tmp = a[i] * ((i + 1) * 2 - N) + tmpSum;\n\t\t\tif (min > tmp) {\n\t\t\t\tmin = tmp;\n\t\t\t}\n\t\t\ttmpSum += a[i] * 2;\n\t\t}\n\t\tSystem.out.println(min);\n\t}\n\n\tinterface CombCalculator {\n\t\tlong comb(int n, int m);\n\t}\n\n\t/**\n\t * 組み合わせ計算を階乗の値で行うクラスです(MOD対応)\n\t * 階乗とその逆元は前計算してテーブルに格納します。\n\t * C(N, N) % M の計算量は O(1)、 前計算でO(max(N, logM))です。\n\t * sizeを1e8より大きい値で実行するとMLEの危険性があります。\n\t * また素数以外のMODには対応していません(逆元の計算に素数の剰余環の性質を利用しているため)。\n\t */\n\tclass FactorialTableCombCalculator implements CombCalculator {\n\t\tint size;\n\t\tlong[] factorialTable;\n\t\tlong[] inverseFactorialTable;\n\t\tlong mod;\n\n\t\tpublic FactorialTableCombCalculator(int size, long mod) {\n\t\t\tthis.size = size;\n\t\t\tfactorialTable = new long[size + 1];\n\t\t\tinverseFactorialTable = new long[size + 1];\n\t\t\tthis.mod = mod;\n\n\t\t\tfactorialTable[0] = 1L;\n\t\t\tfor (int i = 1; i <= size; i++) {\n\t\t\t\tfactorialTable[i] = (factorialTable[i - 1] * i) % mod;\n\t\t\t}\n\t\t\tinverseFactorialTable[size] = inverse(factorialTable[size], mod);\n\t\t\tfor (int i = size - 1; i >= 0; i--) {\n\t\t\t\tinverseFactorialTable[i] = (inverseFactorialTable[i + 1] * (i + 1)) % mod;\n\t\t\t}\n\t\t}\n\n\t\tprivate long inverse(long n, long mod) {\n\t\t\treturn pow(n, mod - 2, mod);\n\t\t}\n\n\t\tprivate long pow(long n, long p, long mod) {\n\t\t\tif (p == 0) {\n\t\t\t\treturn 1L;\n\t\t\t}\n\t\t\tlong half = pow(n, p / 2, mod);\n\t\t\tlong ret = (half * half) % mod;\n\t\t\tif (p % 2 == 1) {\n\t\t\t\tret = (ret * n) % mod;\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\n\t\t@Override\n\t\tpublic long comb(int n, int m) {\n\t\t\tif (n > size) {\n\t\t\t\tthrow new RuntimeException(\"n is greater than size.\");\n\t\t\t}\n\t\t\tif (n < 0 || m < 0 || n < m) {\n\t\t\t\treturn 0L;\n\t\t\t}\n\t\t\treturn (((factorialTable[n] * inverseFactorialTable[m]) % mod) * inverseFactorialTable[n - m]) % mod;\n\t\t}\n\t}\n\n\t/**\n\t * 組み合わせ計算をテーブルで実装したクラスです(MOD対応)\n\t * 前計算でO(N^2), combはO(1)で実行できます\n\t * sizeを2 * 1e4より大きい値で実行するとMLEの危険性があります\n\t */\n\tclass TableCombCalculator implements CombCalculator {\n\t\tlong[][] table;\n\t\tint size;\n\n\t\tpublic TableCombCalculator(int size, long mod) {\n\t\t\tthis.size = size;\n\t\t\ttable = new long[size + 1][];\n\n\t\t\ttable[0] = new long[1];\n\t\t\ttable[0][0] = 1L;\n\t\t\tfor (int n = 1; n <= size; n++) {\n\t\t\t\ttable[n] = new long[n + 1];\n\t\t\t\ttable[n][0] = 1L;\n\t\t\t\tfor (int m = 1; m < n; m++) {\n\t\t\t\t\ttable[n][m] = (table[n - 1][m - 1] + table[n - 1][m]) % mod;\n\t\t\t\t}\n\t\t\t\ttable[n][n] = 1L;\n\t\t\t}\n\t\t}\n\n\t\t@Override\n\t\tpublic long comb(int n, int m) {\n\t\t\tif (n > size) {\n\t\t\t\tthrow new RuntimeException(\"n is greater than size.\");\n\t\t\t}\n\t\t\tif (n < 0 || m < 0 || n < m) {\n\t\t\t\treturn 0L;\n\t\t\t}\n\t\t\treturn table[n][m];\n\t\t}\n\t}\n\n\tinterface Graph {\n\t\tvoid link(int from, int to, long cost);\n\t\tOptional getCost(int from, int to);\n\t\tint getVertexNum();\n\t}\n\n\tinterface FlowResolver {\n\t\tlong maxFlow(int from, int to);\n\t}\n\n\t/**\n\t * グラフの行列による実装\n\t * 接点数の大きいグラフで使うとMLEで死にそう\n\t */\n\tclass ArrayGraph implements Graph {\n\t\tprivate Long[][] costArray;\n\t\tprivate int vertexNum;\n\n\t\tpublic ArrayGraph(int n) {\n\t\t\tcostArray = new Long[n][];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tcostArray[i] = new Long[n];\n\t\t\t}\n\t\t\tvertexNum = n;\n\t\t}\n\n\t\t@Override\n\t\tpublic void link(int from, int to, long cost) {\n\t\t\tcostArray[from][to] = new Long(cost);\n\t\t}\n\n\t\t@Override\n\t\tpublic Optional getCost(int from, int to) {\n\t\t\treturn Optional.ofNullable(costArray[from][to]);\n\t\t}\n\n\t\t@Override\n\t\tpublic int getVertexNum() {\n\t\t\treturn vertexNum;\n\t\t}\n\t}\n\n\t/**\n\t * DFS(深さ優先探索)による実装\n\t * 計算量はO(E*MaxFlow)のはず (E:辺の数, MaxFlow:最大フロー)\n\t */\n\tclass DfsFlowResolver implements FlowResolver {\n\t\tprivate Graph graph;\n\t\tpublic DfsFlowResolver(Graph graph) {\n\t\t\tthis.graph = graph;\n\t\t}\n\n\t\t/**\n\t\t * 最大フロー(最小カット)を求める\n\t\t * @param from 始点(source)のID\n\t\t * @param to 終点(target)のID\n\t\t * @return 最大フロー(最小カット)\n\t\t */\n\t\tpublic long maxFlow(int from, int to) {\n\t\t\tlong sum = 0L;\n\t\t\tlong currentFlow;\n\t\t\tdo {\n\t\t\t\tcurrentFlow = flow(from, to, Long.MAX_VALUE / 3, new boolean[graph.getVertexNum()]);\n\t\t\t\tsum += currentFlow;\n\t\t\t} while (currentFlow > 0);\n\t\t\treturn sum;\n\t\t}\n\n\t\t/**\n\t\t * フローの実行 グラフの更新も行う\n\t\t * @param from 現在いる節点のID\n\t\t * @param to 終点(target)のID\n\t\t * @param current_flow ここまでの流量\n\t\t * @param passed 既に通った節点か否かを格納した配列\n\t\t * @return 終点(target)に流した流量/戻りのグラフの流量\n\t\t */\n\t\tprivate long flow(int from, int to, long current_flow, boolean[] passed) {\n\t\t\tpassed[from] = true;\n\t\t\tif (from == to) {\n\t\t\t\treturn current_flow;\n\t\t\t}\n\t\t\tfor (int id = 0; id < graph.getVertexNum(); id++) {\n\t\t\t\tif (passed[id]) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tOptional cost = graph.getCost(from, id);\n\t\t\t\tif (cost.orElse(0L) > 0) {\n\t\t\t\t\tlong nextFlow = current_flow < cost.get() ? current_flow : cost.get();\n\t\t\t\t\tlong returnFlow = flow(id, to, nextFlow, passed);\n\t\t\t\t\tif (returnFlow > 0) {\n\t\t\t\t\t\tgraph.link(from, id, cost.get() - returnFlow);\n\t\t\t\t\t\tgraph.link(id, from, graph.getCost(id, from).orElse(0L) + returnFlow);\n\t\t\t\t\t\treturn returnFlow;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn 0L;\n\t\t}\n\t}\n\n\t/**\n\t * 1-indexedのBIT配列\n\t */\n\tclass BinaryIndexedTree {\n\t\tprivate long[] array;\n\n\t\tpublic BinaryIndexedTree(int size) {\n\t\t\tthis.array = new long[size + 1];\n\t\t}\n\n\t\t/**\n\t\t * 指定した要素に値を加算する\n\t\t * 計算量はO(logN)\n\t\t * @param index 加算する要素の添字\n\t\t * @param value 加算する量\n\t\t */\n\t\tpublic void add(int index, long value) {\n\t\t\tfor (int i = index; i < array.length; i += (i & -i)) {\n\t\t\t\tarray[i] += value;\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * 1〜指定した要素までの和を取得する\n\t\t * 計算量はO(logN)\n\t\t * @param index 和の終端となる要素の添字\n\t\t * @return 1〜indexまでの和\n\t\t */\n\t\tpublic long getSum(int index) {\n\t\t\tlong sum = 0L;\n\t\t\tfor (int i = index; i > 0; i -= (i & -i)) {\n\t\t\t\tsum += array[i];\n\t\t\t}\n\t\t\treturn sum;\n\t\t}\n\t}\n\n\t/**\n\t * 1-indexedの2次元BIT配列\n\t */\n\tclass BinaryIndexedTree2D {\n\t\tprivate long[][] array;\n\n\t\tpublic BinaryIndexedTree2D(int size1, int size2) {\n\t\t\tthis.array = new long[size1 + 1][];\n\t\t\tfor (int i = 1; i <= size1; i++) {\n\t\t\t\tthis.array[i] = new long[size2 + 1];\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * 指定した要素に値を加算する\n\t\t * 計算量はO(logN * logN)\n\t\t * @param index1 加算する要素の1次元目の添字\n\t\t * @param index2 加算する要素の2次元目の添字\n\t\t * @param value 加算する量\n\t\t */\n\t\tpublic void add(int index1, int index2, long value) {\n\t\t\tfor (int i1 = index1; i1 < array.length; i1 += (i1 & -i1)) {\n\t\t\t\tfor (int i2 = index2; i2 < array.length; i2 += (i2 & -i2)) {\n\t\t\t\t\tarray[i1][i2] += value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * (1,1)〜指定した要素までの矩形和を取得する\n\t\t * 計算量はO(logN * logN)\n\t\t * @param index1 和の終端となる要素の1次元目の添字\n\t\t * @param index2 和の終端となる要素の2次元目の添字\n\t\t * @return (1,1)〜(index1,index2)までの矩形和\n\t\t */\n\t\tpublic long getSum(int index1, int index2) {\n\t\t\tlong sum = 0L;\n\t\t\tfor (int i1 = index1; i1 > 0; i1 -= (i1 & -i1)) {\n\t\t\t\tfor (int i2 = index2; i2 > 0; i2 -= (i2 & -i2)) {\n\t\t\t\t\tsum += array[i1][i2];\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn sum;\n\t\t}\n\t}\n\n\tinterface UnionFind {\n\t\tvoid union(int A, int B);\n\t\tboolean judge(int A, int B);\n\t\tSet getSet(int id);\n\t}\n\n\t/**\n\t * ArrayUnionFindの拡張\n\t * MapSetで根の添字から根にぶら下がる頂点の集合が取得できるようにした\n\t * getSetメソッドをO(logN * logN)に落とせているはず\n\t * ただしunionメソッドは2倍の計算量になっているので注意(オーダーは変わらないはず)\n\t */\n\tclass SetUnionFind extends ArrayUnionFind {\n\t\tMap> map;\n\t\tpublic SetUnionFind(int size) {\n\t\t\tsuper(size);\n\t\t\tmap = new HashMap<>();\n\t\t\tfor (int i = 0; i < size; i++) {\n\t\t\t\tmap.put(i, new HashSet<>());\n\t\t\t\tmap.get(i).add(i);\n\t\t\t}\n\t\t}\n\n\t\t@Override\n\t\tprotected void unionTo(int source, int dest) {\n\t\t\tsuper.unionTo(source, dest);\n\t\t\tmap.get(dest).addAll(map.get(source));\n\t\t}\n\n\t\t@Override\n\t\tpublic Set getSet(int id) {\n\t\t\treturn map.get(root(id));\n\t\t}\n\t}\n\n\t/**\n\t * 配列によるUnionFindの実装\n\t * getSetメソッドはO(NlogN)なのでTLEに注意\n\t */\n\tclass ArrayUnionFind implements UnionFind {\n\t\tint[] parent;\n\t\tint[] rank;\n\t\tint size;\n\t\tpublic ArrayUnionFind(int size) {\n\t\t\tparent = new int[size];\n\t\t\tfor (int i = 0; i < size; i++) {\n\t\t\t\tparent[i] = i;\n\t\t\t}\n\t\t\trank = new int[size];\n\t\t\tthis.size = size;\n\t\t}\n\n\t\t@Override\n\t\tpublic void union(int A, int B) {\n\t\t\tint rootA = root(A);\n\t\t\tint rootB = root(B);\n\t\t\tif (rootA != rootB) {\n\t\t\t\tif (rank[rootA] < rank[rootB]) {\n\t\t\t\t\tunionTo(rootA, rootB);\n\t\t\t\t} else {\n\t\t\t\t\tunionTo(rootB, rootA);\n\t\t\t\t\tif (rank[rootA] == rank[rootB]) {\n\t\t\t\t\t\trank[rootA]++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tprotected void unionTo(int source, int dest) {\n\t\t\tparent[source] = dest;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean judge(int A, int B) {\n\t\t\treturn root(A) == root(B);\n\t\t}\n\n\t\t@Override\n\t\tpublic Set getSet(int id) {\n\t\t\tSet set = new HashSet<>();\n\t\t\tIntStream.range(0, size).filter(i -> judge(i, id)).forEach(set::add);\n\t\t\treturn set;\n\t\t}\n\n\t\tprotected int root(int id) {\n\t\t\tif (parent[id] == id) {\n\t\t\t\treturn id;\n\t\t\t}\n\t\t\tparent[id] = root(parent[id]);\n\t\t\treturn parent[id];\n\t\t}\n\t}\n\n\t/**\n\t * 素数のユーティリティ\n\t */\n\tclass PrimeNumberUtils {\n\t\tboolean[] isPrimeArray;\n\t\tList primes;\n\n\t\t/**\n\t\t * 素数判定の上限となる値を指定してユーティリティを初期化\n\t\t * @param limit 素数判定の上限(この値以上が素数であるか判定しない)\n\t\t */\n\t\tpublic PrimeNumberUtils(int limit) {\n\t\t\tif (limit > 10000000) {\n\t\t\t\tSystem.err.println(\"上限の値が高すぎるため素数ユーティリティの初期化でTLEする可能性が大変高いです\");\n\t\t\t}\n\t\t\tprimes = new ArrayList<>();\n\t\t\tisPrimeArray = new boolean[limit];\n\t\t\tif (limit > 2) {\n\t\t\t\tprimes.add(2);\n\t\t\t\tisPrimeArray[2] = true;\n\t\t\t}\n\n\t\t\tfor (int i = 3; i < limit; i += 2) {\n\t\t\t\tif (isPrime(i, primes)) {\n\t\t\t\t\tprimes.add(i);\n\t\t\t\t\tisPrimeArray[i] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic List getPrimeNumberList() {\n\t\t\treturn primes;\n\t\t}\n\n\t\tpublic boolean isPrime(int n) {\n\t\t\treturn isPrimeArray[n];\n\t\t}\n\n\t\tprivate boolean isPrime(int n, List primes) {\n\t\t\tfor (int prime : primes) {\n\t\t\t\tif (n % prime == 0) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (prime > Math.sqrt(n)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tinterface BitSet {\n\t\tvoid set(int index, boolean bit);\n\t\tboolean get(int index);\n\t\tvoid shiftRight(int num);\n\t\tvoid shiftLeft(int num);\n\t\tvoid or(BitSet bitset);\n\t\tvoid and(BitSet bitset);\n\t}\n\n\t/**\n\t * Longの配列によるBitSetの実装\n\t * get/setはO(1)\n\t * shift/or/andはO(size / 64)\n\t */\n\tclass LongBit implements BitSet {\n\t\tlong[] bitArray;\n\n\t\tpublic LongBit(int size) {\n\t\t\tbitArray = new long[((size + 63) / 64)];\n\t\t}\n\n\t\t@Override\n\t\tpublic void set(int index, boolean bit) {\n\t\t\tint segment = index / 64;\n\t\t\tint inIndex = index % 64;\n\t\t\tif (bit) {\n\t\t\t\tbitArray[segment] |= 1L << inIndex;\n\t\t\t} else {\n\t\t\t\tbitArray[segment] &= ~(1L << inIndex);\n\t\t\t}\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean get(int index) {\n\t\t\tint segment = index / 64;\n\t\t\tint inIndex = index % 64;\n\t\t\treturn (bitArray[segment] & (1L << inIndex)) != 0L;\n\t\t}\n\n\t\t@Override\n\t\tpublic void shiftRight(int num) {\n\t\t\tint shiftSeg = num / 64;\n\t\t\tint shiftInI = num % 64;\n\t\t\tfor (int segment = 0; segment < bitArray.length; segment++) {\n\t\t\t\tint sourceSeg = segment + shiftSeg;\n\t\t\t\tif (sourceSeg < bitArray.length) {\n\t\t\t\t\tbitArray[segment] = bitArray[sourceSeg] >>> shiftInI;\n\t\t\t\t\tif (shiftInI > 0 && sourceSeg + 1 < bitArray.length) {\n\t\t\t\t\t\tbitArray[segment] |= bitArray[sourceSeg + 1] << (64 - shiftInI);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tbitArray[segment] = 0L;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t@Override\n\t\tpublic void shiftLeft(int num) {\n\t\t\tint shiftSeg = num / 64;\n\t\t\tint shiftInI = num % 64;\n\t\t\tfor (int segment = bitArray.length - 1; segment >= 0; segment--) {\n\t\t\t\tint sourceSeg = segment - shiftSeg;\n\t\t\t\tif (sourceSeg >= 0) {\n\t\t\t\t\tbitArray[segment] = bitArray[sourceSeg] << shiftInI;\n\t\t\t\t\tif (shiftInI > 0 && sourceSeg > 0) {\n\t\t\t\t\t\tbitArray[segment] |= bitArray[sourceSeg - 1] >>> (64 - shiftInI);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tbitArray[segment] = 0L;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic long getLong(int segment) {\n\t\t\treturn bitArray[segment];\n\t\t}\n\n\t\t@Override\n\t\tpublic void or(BitSet bitset) {\n\t\t\tif (!(bitset instanceof LongBit)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor (int segment = 0; segment < bitArray.length; segment++) {\n\t\t\t\tbitArray[segment] |= ((LongBit)bitset).getLong(segment);\n\t\t\t}\n\t\t}\n\n\t\t@Override\n\t\tpublic void and(BitSet bitset) {\n\t\t\tif (!(bitset instanceof LongBit)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor (int segment = 0; segment < bitArray.length; segment++) {\n\t\t\t\tbitArray[segment] &= ((LongBit)bitset).getLong(segment);\n\t\t\t}\n\t\t}\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": "p03311", "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": 13874, "cpu_time_ms": 671, "memory_kb": 88932}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s577802852", "group_id": "codeNet:p03318", "input_text": "/*\nString[]の初期化、整数の型がlongになっているか\n関数(splitとかcontainsとか)内では\"+\"とかは正規表現となされるので\"\\\\+\"とする\n配列のコピーはarr1=arr.clone()\nHashSet<>[]はおのおの初期化した?????\n負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意\nある値>=kとして、切り上げた値をとるべき\ntoLowerCase()はアルファベット以外に対して行ってもエラーにはならない\n */\n//入力終了→Ctrl+D\nimport java.time.Year;\nimport java.util.*;\nimport java.awt.*;\nimport java.awt.Graphics.*;\nimport static java.lang.System.*;\nimport static java.lang.Math.*;\npublic class Main {\n public static void main(String[] $) {\n Scanner sc = new Scanner(in);\n long k=sc.nextLong();\n long c=0,i=1;\n while (c0){\n t+=i%10;\n i/=10;\n }\n return t;\n }\n}\n", "language": "Java", "metadata": {"date": 1551833862, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03318.html", "problem_id": "p03318", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03318/input.txt", "sample_output_relpath": "derived/input_output/data/p03318/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03318/Java/s577802852.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s577802852", "user_id": "u881037761"}, "prompt_components": {"gold_output": "1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n", "input_to_evaluate": "/*\nString[]の初期化、整数の型がlongになっているか\n関数(splitとかcontainsとか)内では\"+\"とかは正規表現となされるので\"\\\\+\"とする\n配列のコピーはarr1=arr.clone()\nHashSet<>[]はおのおの初期化した?????\n負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意\nある値>=kとして、切り上げた値をとるべき\ntoLowerCase()はアルファベット以外に対して行ってもエラーにはならない\n */\n//入力終了→Ctrl+D\nimport java.time.Year;\nimport java.util.*;\nimport java.awt.*;\nimport java.awt.Graphics.*;\nimport static java.lang.System.*;\nimport static java.lang.Math.*;\npublic class Main {\n public static void main(String[] $) {\n Scanner sc = new Scanner(in);\n long k=sc.nextLong();\n long c=0,i=1;\n while (c0){\n t+=i%10;\n i/=10;\n }\n return t;\n }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(123) = 1 + 2 + 3 = 6.\n\nWe will call an integer n a Snuke number when, for all positive integers m such that m > n, \\frac{n}{S(n)} \\leq \\frac{m}{S(m)} holds.\n\nGiven an integer K, list the K smallest Snuke numbers.\n\nConstraints\n\n1 \\leq K\n\nThe K-th smallest Snuke number is not greater than 10^{15}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint K lines. The i-th line should contain the i-th smallest Snuke number.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n1\n2\n3\n4\n5\n6\n7\n8\n9\n19", "sample_input": "10\n"}, "reference_outputs": ["1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n"], "source_document_id": "p03318", "source_text": "Score : 500 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(123) = 1 + 2 + 3 = 6.\n\nWe will call an integer n a Snuke number when, for all positive integers m such that m > n, \\frac{n}{S(n)} \\leq \\frac{m}{S(m)} holds.\n\nGiven an integer K, list the K smallest Snuke numbers.\n\nConstraints\n\n1 \\leq K\n\nThe K-th smallest Snuke number is not greater than 10^{15}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint K lines. The i-th line should contain the i-th smallest Snuke number.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n1\n2\n3\n4\n5\n6\n7\n8\n9\n19", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2109, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s212117659", "group_id": "codeNet:p03319", "input_text": "import java.io.*;\nimport java.util.*;\n\n\npublic class Main {\n\n\tprivate static Scanner sc;\n\tprivate static Printer pr;\n\n\tprivate static void solve() {\n\t\tint n = sc.nextInt();\n\t\tint k = sc.nextInt();\n\n\t\tint[] a = new int[n];\n\t\t@SuppressWarnings(\"unused\")\n\t\tint mini = -1;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t\tif (a[i] == 1) {\n\t\t\t\tmini = i;\n\t\t\t}\n\t\t}\n\n\t\tint ans = (n + k - 2) / (k - 1);\n\t\tif (n % (k - 1) == 1) {\n\t\t\tans--;\n\t\t}\n\t\t\n\t\tpr.println(ans);\n\t}\n\n\t// ---------------------------------------------------\n\tpublic static void main(String[] args) {\n\t\tsc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));\n\t\tpr = new Printer(System.out);\n\n\t\tsolve();\n\n//\t\tpr.close();\n\t\tpr.flush();\n//\t\tsc.close();\n\t}\n\n\tstatic String INPUT = null;\n\n\t@SuppressWarnings(\"unused\")\n\tprivate static class Scanner {\n\t\tBufferedReader br;\n\n\t\tScanner (InputStream in) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(in));\n\t\t}\n\n\t\tprivate boolean isPrintable(int ch) {\n\t\t\treturn ch >= '!' && ch <= '~';\n\t\t}\n\n\t\tprivate boolean isCRLF(int ch) {\n\t\t\treturn ch == '\\n' || ch == '\\r' || ch == -1;\n\t\t}\n\n\t\tprivate int nextPrintable() {\n\t\t\ttry {\n\t\t\t\tint ch;\n\t\t\t\twhile (!isPrintable(ch = br.read())) {\n\t\t\t\t\tif (ch == -1) {\n\t\t\t\t\t\tthrow new NoSuchElementException();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn ch;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tString next() {\n\t\t\ttry {\n\t\t\t\tint ch = nextPrintable();\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tdo {\n\t\t\t\t\tsb.appendCodePoint(ch);\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn sb.toString();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tint nextInt() {\n\t\t\ttry {\n\t\t\t\t// parseInt from Integer.parseInt()\n\t\t\t\tboolean negative = false;\n\t\t\t\tint res = 0;\n\t\t\t\tint limit = -Integer.MAX_VALUE;\n\t\t\t\tint radix = 10;\n\n\t\t\t\tint fc = nextPrintable();\n\t\t\t\tif (fc < '0') {\n\t\t\t\t\tif (fc == '-') {\n\t\t\t\t\t\tnegative = true;\n\t\t\t\t\t\tlimit = Integer.MIN_VALUE;\n\t\t\t\t\t} else if (fc != '+') {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tfc = br.read();\n\t\t\t\t}\n\t\t\t\tint multmin = limit / radix;\n\n\t\t\t\tint ch = fc;\n\t\t\t\tdo {\n\t\t\t\t\tint digit = ch - '0';\n\t\t\t\t\tif (digit < 0 || digit >= radix) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tif (res < multmin) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres *= radix;\n\t\t\t\t\tif (res < limit + digit) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres -= digit;\n\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn negative ? res : -res;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\ttry {\n\t\t\t\t// parseLong from Long.parseLong()\n\t\t\t\tboolean negative = false;\n\t\t\t\tlong res = 0;\n\t\t\t\tlong limit = -Long.MAX_VALUE;\n\t\t\t\tint radix = 10;\n\n\t\t\t\tint fc = nextPrintable();\n\t\t\t\tif (fc < '0') {\n\t\t\t\t\tif (fc == '-') {\n\t\t\t\t\t\tnegative = true;\n\t\t\t\t\t\tlimit = Long.MIN_VALUE;\n\t\t\t\t\t} else if (fc != '+') {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tfc = br.read();\n\t\t\t\t}\n\t\t\t\tlong multmin = limit / radix;\n\n\t\t\t\tint ch = fc;\n\t\t\t\tdo {\n\t\t\t\t\tint digit = ch - '0';\n\t\t\t\t\tif (digit < 0 || digit >= radix) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tif (res < multmin) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres *= radix;\n\t\t\t\t\tif (res < limit + digit) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres -= digit;\n\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn negative ? res : -res;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tfloat nextFloat() {\n\t\t\treturn Float.parseFloat(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\ttry {\n\t\t\t\tint ch;\n\t\t\t\twhile (isCRLF(ch = br.read())) {\n\t\t\t\t\tif (ch == -1) {\n\t\t\t\t\t\tthrow new NoSuchElementException();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tdo {\n\t\t\t\t\tsb.appendCodePoint(ch);\n\t\t\t\t} while (!isCRLF(ch = br.read()));\n\n\t\t\t\treturn sb.toString();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tvoid close() {\n\t\t\ttry {\n\t\t\t\tbr.close();\n\t\t\t} catch (IOException e) {\n//\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static class Printer extends PrintWriter {\n\t\tPrinter(OutputStream out) {\n\t\t\tsuper(out);\n\t\t}\n\t}\n}\n", "language": "Java", "metadata": {"date": 1537657558, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03319.html", "problem_id": "p03319", "resource_group": "high_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/Java/s212117659.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s212117659", "user_id": "u900015623"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\n\n\npublic class Main {\n\n\tprivate static Scanner sc;\n\tprivate static Printer pr;\n\n\tprivate static void solve() {\n\t\tint n = sc.nextInt();\n\t\tint k = sc.nextInt();\n\n\t\tint[] a = new int[n];\n\t\t@SuppressWarnings(\"unused\")\n\t\tint mini = -1;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = sc.nextInt();\n\t\t\tif (a[i] == 1) {\n\t\t\t\tmini = i;\n\t\t\t}\n\t\t}\n\n\t\tint ans = (n + k - 2) / (k - 1);\n\t\tif (n % (k - 1) == 1) {\n\t\t\tans--;\n\t\t}\n\t\t\n\t\tpr.println(ans);\n\t}\n\n\t// ---------------------------------------------------\n\tpublic static void main(String[] args) {\n\t\tsc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));\n\t\tpr = new Printer(System.out);\n\n\t\tsolve();\n\n//\t\tpr.close();\n\t\tpr.flush();\n//\t\tsc.close();\n\t}\n\n\tstatic String INPUT = null;\n\n\t@SuppressWarnings(\"unused\")\n\tprivate static class Scanner {\n\t\tBufferedReader br;\n\n\t\tScanner (InputStream in) {\n\t\t\tbr = new BufferedReader(new InputStreamReader(in));\n\t\t}\n\n\t\tprivate boolean isPrintable(int ch) {\n\t\t\treturn ch >= '!' && ch <= '~';\n\t\t}\n\n\t\tprivate boolean isCRLF(int ch) {\n\t\t\treturn ch == '\\n' || ch == '\\r' || ch == -1;\n\t\t}\n\n\t\tprivate int nextPrintable() {\n\t\t\ttry {\n\t\t\t\tint ch;\n\t\t\t\twhile (!isPrintable(ch = br.read())) {\n\t\t\t\t\tif (ch == -1) {\n\t\t\t\t\t\tthrow new NoSuchElementException();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn ch;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tString next() {\n\t\t\ttry {\n\t\t\t\tint ch = nextPrintable();\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tdo {\n\t\t\t\t\tsb.appendCodePoint(ch);\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn sb.toString();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tint nextInt() {\n\t\t\ttry {\n\t\t\t\t// parseInt from Integer.parseInt()\n\t\t\t\tboolean negative = false;\n\t\t\t\tint res = 0;\n\t\t\t\tint limit = -Integer.MAX_VALUE;\n\t\t\t\tint radix = 10;\n\n\t\t\t\tint fc = nextPrintable();\n\t\t\t\tif (fc < '0') {\n\t\t\t\t\tif (fc == '-') {\n\t\t\t\t\t\tnegative = true;\n\t\t\t\t\t\tlimit = Integer.MIN_VALUE;\n\t\t\t\t\t} else if (fc != '+') {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tfc = br.read();\n\t\t\t\t}\n\t\t\t\tint multmin = limit / radix;\n\n\t\t\t\tint ch = fc;\n\t\t\t\tdo {\n\t\t\t\t\tint digit = ch - '0';\n\t\t\t\t\tif (digit < 0 || digit >= radix) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tif (res < multmin) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres *= radix;\n\t\t\t\t\tif (res < limit + digit) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres -= digit;\n\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn negative ? res : -res;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\ttry {\n\t\t\t\t// parseLong from Long.parseLong()\n\t\t\t\tboolean negative = false;\n\t\t\t\tlong res = 0;\n\t\t\t\tlong limit = -Long.MAX_VALUE;\n\t\t\t\tint radix = 10;\n\n\t\t\t\tint fc = nextPrintable();\n\t\t\t\tif (fc < '0') {\n\t\t\t\t\tif (fc == '-') {\n\t\t\t\t\t\tnegative = true;\n\t\t\t\t\t\tlimit = Long.MIN_VALUE;\n\t\t\t\t\t} else if (fc != '+') {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tfc = br.read();\n\t\t\t\t}\n\t\t\t\tlong multmin = limit / radix;\n\n\t\t\t\tint ch = fc;\n\t\t\t\tdo {\n\t\t\t\t\tint digit = ch - '0';\n\t\t\t\t\tif (digit < 0 || digit >= radix) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tif (res < multmin) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres *= radix;\n\t\t\t\t\tif (res < limit + digit) {\n\t\t\t\t\t\tthrow new NumberFormatException();\n\t\t\t\t\t}\n\t\t\t\t\tres -= digit;\n\n\t\t\t\t} while (isPrintable(ch = br.read()));\n\n\t\t\t\treturn negative ? res : -res;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tfloat nextFloat() {\n\t\t\treturn Float.parseFloat(next());\n\t\t}\n\n\t\tdouble nextDouble() {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tString nextLine() {\n\t\t\ttry {\n\t\t\t\tint ch;\n\t\t\t\twhile (isCRLF(ch = br.read())) {\n\t\t\t\t\tif (ch == -1) {\n\t\t\t\t\t\tthrow new NoSuchElementException();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tdo {\n\t\t\t\t\tsb.appendCodePoint(ch);\n\t\t\t\t} while (!isCRLF(ch = br.read()));\n\n\t\t\t\treturn sb.toString();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\n\t\tvoid close() {\n\t\t\ttry {\n\t\t\t\tbr.close();\n\t\t\t} catch (IOException e) {\n//\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static class Printer extends PrintWriter {\n\t\tPrinter(OutputStream out) {\n\t\t\tsuper(out);\n\t\t}\n\t}\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": 4278, "cpu_time_ms": 128, "memory_kb": 24628}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s048039253", "group_id": "codeNet:p03323", "input_text": "import java.util.*;\n\nclass Main{\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n\n if(0 scores = new ArrayList<>();\n long tx = 0;\n long ty = 0;\n long tz = 0;\n for (int j = 0; j < n; j++) {\n if ((i & 1) == 1) {\n // x\n tx = -x[j];\n }\n if ((i & 1) == 0) {\n // x\n tx = x[j];\n }\n if ((i >> 1 & 1) == 1) {\n // y\n ty = -y[j];\n }\n if ((i >> 1 & 1) == 0) {\n // y\n ty = y[j];\n }\n if ((i >> 2 & 1) == 1) {\n tz = -z[j];\n }\n if ((i >> 2 & 1) == 0) {\n tz = z[j];\n }\n scores.add(new Tuple(tx, ty, tz, (tx + ty + tz)));\n }\n Collections.sort(scores, Collections.reverseOrder());\n\n long score = 0;\n for (int k = 0; k < m; k++) {\n score += scores.get(k).score;\n }\n result = Math.max(result, score);\n }\n out.println(result);\n\n }\n\n class Tuple implements Comparable {\n long x;\n long y;\n long z;\n long score;\n\n public Tuple(long x, long y, long z, long score) {\n this.x = x;\n this.y = y;\n this.z = z;\n this.score = score;\n }\n\n public int compareTo(Tuple o) {\n return Long.compare(this.score, o.score);\n }\n\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1601327712, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p03326.html", "problem_id": "p03326", "resource_group": "high_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/Java/s026699931.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s026699931", "user_id": "u745688558"}, "prompt_components": {"gold_output": "56\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.List;\nimport java.util.Scanner;\nimport java.util.Collections;\nimport java.util.ArrayList;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n PatisserieABC solver = new PatisserieABC();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class PatisserieABC {\n public void solve(int testNumber, Scanner in, PrintWriter out) {\n int n = in.nextInt();\n int m = in.nextInt();\n long[] x = new long[n];\n long[] y = new long[n];\n long[] z = new long[n];\n\n for (int i = 0; i < n; i++) {\n x[i] = Long.parseLong(in.next());\n y[i] = Long.parseLong(in.next());\n z[i] = Long.parseLong(in.next());\n }\n\n long result = 0;\n for (int i = 0; i < (1 << 3); i++) {\n List scores = new ArrayList<>();\n long tx = 0;\n long ty = 0;\n long tz = 0;\n for (int j = 0; j < n; j++) {\n if ((i & 1) == 1) {\n // x\n tx = -x[j];\n }\n if ((i & 1) == 0) {\n // x\n tx = x[j];\n }\n if ((i >> 1 & 1) == 1) {\n // y\n ty = -y[j];\n }\n if ((i >> 1 & 1) == 0) {\n // y\n ty = y[j];\n }\n if ((i >> 2 & 1) == 1) {\n tz = -z[j];\n }\n if ((i >> 2 & 1) == 0) {\n tz = z[j];\n }\n scores.add(new Tuple(tx, ty, tz, (tx + ty + tz)));\n }\n Collections.sort(scores, Collections.reverseOrder());\n\n long score = 0;\n for (int k = 0; k < m; k++) {\n score += scores.get(k).score;\n }\n result = Math.max(result, score);\n }\n out.println(result);\n\n }\n\n class Tuple implements Comparable {\n long x;\n long y;\n long z;\n long score;\n\n public Tuple(long x, long y, long z, long score) {\n this.x = x;\n this.y = y;\n this.z = z;\n this.score = score;\n }\n\n public int compareTo(Tuple o) {\n return Long.compare(this.score, o.score);\n }\n\n }\n\n }\n}\n\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nTakahashi became a pastry chef and opened a shop La Confiserie d'ABC to celebrate AtCoder Beginner Contest 100.\n\nThe shop sells N kinds of cakes.\n\nEach kind of cake has three parameters \"beauty\", \"tastiness\" and \"popularity\". The i-th kind of cake has the beauty of x_i, the tastiness of y_i and the popularity of z_i.\n\nThese values may be zero or negative.\n\nRingo has decided to have M pieces of cakes here. He will choose the set of cakes as follows:\n\nDo not have two or more pieces of the same kind of cake.\n\nUnder the condition above, choose the set of cakes to maximize (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity).\n\nFind the maximum possible value of (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) for the set of cakes that Ringo chooses.\n\nConstraints\n\nN is an integer between 1 and 1 \\ 000 (inclusive).\n\nM is an integer between 0 and N (inclusive).\n\nx_i, y_i, z_i \\ (1 \\leq i \\leq N) are integers between -10 \\ 000 \\ 000 \\ 000 and 10 \\ 000 \\ 000 \\ 000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1 z_1\nx_2 y_2 z_2\n: :\nx_N y_N z_N\n\nOutput\n\nPrint the maximum possible value of (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) for the set of cakes that Ringo chooses.\n\nSample Input 1\n\n5 3\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 7 9\n\nSample Output 1\n\n56\n\nConsider having the 2-nd, 4-th and 5-th kinds of cakes. The total beauty, tastiness and popularity will be as follows:\n\nBeauty: 1 + 3 + 9 = 13\n\nTastiness: 5 + 5 + 7 = 17\n\nPopularity: 9 + 8 + 9 = 26\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 13 + 17 + 26 = 56. This is the maximum value.\n\nSample Input 2\n\n5 3\n1 -2 3\n-4 5 -6\n7 -8 -9\n-10 11 -12\n13 -14 15\n\nSample Output 2\n\n54\n\nConsider having the 1-st, 3-rd and 5-th kinds of cakes. The total beauty, tastiness and popularity will be as follows:\n\nBeauty: 1 + 7 + 13 = 21\n\nTastiness: (-2) + (-8) + (-14) = -24\n\nPopularity: 3 + (-9) + 15 = 9\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 21 + 24 + 9 = 54. This is the maximum value.\n\nSample Input 3\n\n10 5\n10 -80 21\n23 8 38\n-94 28 11\n-26 -2 18\n-69 72 79\n-26 -86 -54\n-72 -50 59\n21 65 -32\n40 -94 87\n-62 18 82\n\nSample Output 3\n\n638\n\nIf we have the 3-rd, 4-th, 5-th, 7-th and 10-th kinds of cakes, the total beauty, tastiness and popularity will be -323, 66 and 249, respectively.\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 323 + 66 + 249 = 638. This is the maximum value.\n\nSample Input 4\n\n3 2\n2000000000 -9000000000 4000000000\n7000000000 -5000000000 3000000000\n6000000000 -1000000000 8000000000\n\nSample Output 4\n\n30000000000\n\nThe values of the beauty, tastiness and popularity of the cakes and the value to be printed may not fit into 32-bit integers.", "sample_input": "5 3\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 7 9\n"}, "reference_outputs": ["56\n"], "source_document_id": "p03326", "source_text": "Score: 400 points\n\nProblem Statement\n\nTakahashi became a pastry chef and opened a shop La Confiserie d'ABC to celebrate AtCoder Beginner Contest 100.\n\nThe shop sells N kinds of cakes.\n\nEach kind of cake has three parameters \"beauty\", \"tastiness\" and \"popularity\". The i-th kind of cake has the beauty of x_i, the tastiness of y_i and the popularity of z_i.\n\nThese values may be zero or negative.\n\nRingo has decided to have M pieces of cakes here. He will choose the set of cakes as follows:\n\nDo not have two or more pieces of the same kind of cake.\n\nUnder the condition above, choose the set of cakes to maximize (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity).\n\nFind the maximum possible value of (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) for the set of cakes that Ringo chooses.\n\nConstraints\n\nN is an integer between 1 and 1 \\ 000 (inclusive).\n\nM is an integer between 0 and N (inclusive).\n\nx_i, y_i, z_i \\ (1 \\leq i \\leq N) are integers between -10 \\ 000 \\ 000 \\ 000 and 10 \\ 000 \\ 000 \\ 000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1 z_1\nx_2 y_2 z_2\n: :\nx_N y_N z_N\n\nOutput\n\nPrint the maximum possible value of (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) for the set of cakes that Ringo chooses.\n\nSample Input 1\n\n5 3\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 7 9\n\nSample Output 1\n\n56\n\nConsider having the 2-nd, 4-th and 5-th kinds of cakes. The total beauty, tastiness and popularity will be as follows:\n\nBeauty: 1 + 3 + 9 = 13\n\nTastiness: 5 + 5 + 7 = 17\n\nPopularity: 9 + 8 + 9 = 26\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 13 + 17 + 26 = 56. This is the maximum value.\n\nSample Input 2\n\n5 3\n1 -2 3\n-4 5 -6\n7 -8 -9\n-10 11 -12\n13 -14 15\n\nSample Output 2\n\n54\n\nConsider having the 1-st, 3-rd and 5-th kinds of cakes. The total beauty, tastiness and popularity will be as follows:\n\nBeauty: 1 + 7 + 13 = 21\n\nTastiness: (-2) + (-8) + (-14) = -24\n\nPopularity: 3 + (-9) + 15 = 9\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 21 + 24 + 9 = 54. This is the maximum value.\n\nSample Input 3\n\n10 5\n10 -80 21\n23 8 38\n-94 28 11\n-26 -2 18\n-69 72 79\n-26 -86 -54\n-72 -50 59\n21 65 -32\n40 -94 87\n-62 18 82\n\nSample Output 3\n\n638\n\nIf we have the 3-rd, 4-th, 5-th, 7-th and 10-th kinds of cakes, the total beauty, tastiness and popularity will be -323, 66 and 249, respectively.\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 323 + 66 + 249 = 638. This is the maximum value.\n\nSample Input 4\n\n3 2\n2000000000 -9000000000 4000000000\n7000000000 -5000000000 3000000000\n6000000000 -1000000000 8000000000\n\nSample Output 4\n\n30000000000\n\nThe values of the beauty, tastiness and popularity of the cakes and the value to be printed may not fit into 32-bit integers.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3033, "cpu_time_ms": 178, "memory_kb": 40236}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s306288976", "group_id": "codeNet:p03327", "input_text": "import java.util.*;\n\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n System.out.println( N >= 1000 ? \"ABD\" : \"ABC\" );\n }\n}\n", "language": "Java", "metadata": {"date": 1528678928, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03327.html", "problem_id": "p03327", "resource_group": "high_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/Java/s306288976.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s306288976", "user_id": "u829407811"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n System.out.println( N >= 1000 ? \"ABD\" : \"ABC\" );\n }\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": 208, "cpu_time_ms": 189, "memory_kb": 23764}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s008124729", "group_id": "codeNet:p03328", "input_text": "import java.io.*;\nimport java.util.*;\nimport java.math.BigInteger;\npublic class Main {\n\nstatic long[] list=new long[87];\n\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\n String[] nyuA=sc.nextLine().split(\" \");\n \nint a=Integer.parseInt(nyuA[0]);\nint b=Integer.parseInt(nyuA[1]);\n\nint[] num=new int[1000];\n\nint count=0;\nfor(int i=1;i<=999;i++){\ncount+=i;\nnum[i-1]=count;\n}\n\n\nSystem.out.println(num[b-a-2]-a);\n}\n\n}\n\n", "language": "Java", "metadata": {"date": 1579484385, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03328.html", "problem_id": "p03328", "resource_group": "high_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/Java/s008124729.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s008124729", "user_id": "u878116546"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\nimport java.math.BigInteger;\npublic class Main {\n\nstatic long[] list=new long[87];\n\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\n String[] nyuA=sc.nextLine().split(\" \");\n \nint a=Integer.parseInt(nyuA[0]);\nint b=Integer.parseInt(nyuA[1]);\n\nint[] num=new int[1000];\n\nint count=0;\nfor(int i=1;i<=999;i++){\ncount+=i;\nnum[i-1]=count;\n}\n\n\nSystem.out.println(num[b-a-2]-a);\n}\n\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter.\n\nIt had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower.\n\nAssuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover.\n\nAssume also that the depth of the snow cover is always at least 1 meter.\n\nConstraints\n\n1 \\leq a < b < 499500(=1+2+3+...+999)\n\nAll values in input are integers.\n\nThere is no input that contradicts the assumption.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the depth of the snow cover is x meters, print x as an integer.\n\nSample Input 1\n\n8 13\n\nSample Output 1\n\n2\n\nThe heights of the two towers are 10 meters and 15 meters, respectively.\nThus, we can see that the depth of the snow cover is 2 meters.\n\nSample Input 2\n\n54 65\n\nSample Output 2\n\n1", "sample_input": "8 13\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03328", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter.\n\nIt had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower.\n\nAssuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover.\n\nAssume also that the depth of the snow cover is always at least 1 meter.\n\nConstraints\n\n1 \\leq a < b < 499500(=1+2+3+...+999)\n\nAll values in input are integers.\n\nThere is no input that contradicts the assumption.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the depth of the snow cover is x meters, print x as an integer.\n\nSample Input 1\n\n8 13\n\nSample Output 1\n\n2\n\nThe heights of the two towers are 10 meters and 15 meters, respectively.\nThus, we can see that the depth of the snow cover is 2 meters.\n\nSample Input 2\n\n54 65\n\nSample Output 2\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 102, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s755143652", "group_id": "codeNet:p03328", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Scanner;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author mikit\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n BStoneMonument solver = new BStoneMonument();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class BStoneMonument {\n public void solve(int testNumber, Scanner in, PrintWriter out) {\n int a = in.nextInt(), b = in.nextInt();\n long res = 0;\n for (int i = 1; i <= (b - a); i++) {\n res += i;\n }\n out.println(res - b);\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1528679099, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03328.html", "problem_id": "p03328", "resource_group": "high_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/Java/s755143652.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s755143652", "user_id": "u183509493"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Scanner;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author mikit\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n BStoneMonument solver = new BStoneMonument();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class BStoneMonument {\n public void solve(int testNumber, Scanner in, PrintWriter out) {\n int a = in.nextInt(), b = in.nextInt();\n long res = 0;\n for (int i = 1; i <= (b - a); i++) {\n res += i;\n }\n out.println(res - b);\n }\n\n }\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter.\n\nIt had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower.\n\nAssuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover.\n\nAssume also that the depth of the snow cover is always at least 1 meter.\n\nConstraints\n\n1 \\leq a < b < 499500(=1+2+3+...+999)\n\nAll values in input are integers.\n\nThere is no input that contradicts the assumption.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the depth of the snow cover is x meters, print x as an integer.\n\nSample Input 1\n\n8 13\n\nSample Output 1\n\n2\n\nThe heights of the two towers are 10 meters and 15 meters, respectively.\nThus, we can see that the depth of the snow cover is 2 meters.\n\nSample Input 2\n\n54 65\n\nSample Output 2\n\n1", "sample_input": "8 13\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03328", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter.\n\nIt had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower.\n\nAssuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover.\n\nAssume also that the depth of the snow cover is always at least 1 meter.\n\nConstraints\n\n1 \\leq a < b < 499500(=1+2+3+...+999)\n\nAll values in input are integers.\n\nThere is no input that contradicts the assumption.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the depth of the snow cover is x meters, print x as an integer.\n\nSample Input 1\n\n8 13\n\nSample Output 1\n\n2\n\nThe heights of the two towers are 10 meters and 15 meters, respectively.\nThus, we can see that the depth of the snow cover is 2 meters.\n\nSample Input 2\n\n54 65\n\nSample Output 2\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 123, "memory_kb": 21332}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s382500959", "group_id": "codeNet:p03329", "input_text": "import java.util.*;\npublic class Main {\n\tstatic Scanner sc = new Scanner(System.in);\n\tstatic int[] coin = new int[100001];\n\tpublic static void main(String[] args) {\n\t\tmaketable();\n\t\tint N = sc.nextInt();\n\t\tSystem.out.println(coin[N]);\n\t}\n\tstatic void maketable() {\n\t\tint i,k;\n\t\tfor(i = 0;i <= 100000;i ++) {\n\t\t\tcoin[i] = i;\n\t\t}\n\t\tint s = 6,n = 9;\n\t\twhile(s <= 100000 || n <= 100000) {\n\t\t\tfor(k = s;k <= 100000;k++) {\n\t\t\t\tif(coin[k] > coin[k-s]+1) coin[k] = coin[k-s] + 1;\n\t\t\t}\n\t\t\tfor(k = n;k <= 100000;k++) {\n\t\t\t\tif(coin[k] > coin[k-n]+1) coin[k] = coin[k-n] + 1;\n\t\t\t}\n\t\t\ts = s * 6; n = n * 9;\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1537738694, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03329.html", "problem_id": "p03329", "resource_group": "high_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/Java/s382500959.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s382500959", "user_id": "u843129591"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*;\npublic class Main {\n\tstatic Scanner sc = new Scanner(System.in);\n\tstatic int[] coin = new int[100001];\n\tpublic static void main(String[] args) {\n\t\tmaketable();\n\t\tint N = sc.nextInt();\n\t\tSystem.out.println(coin[N]);\n\t}\n\tstatic void maketable() {\n\t\tint i,k;\n\t\tfor(i = 0;i <= 100000;i ++) {\n\t\t\tcoin[i] = i;\n\t\t}\n\t\tint s = 6,n = 9;\n\t\twhile(s <= 100000 || n <= 100000) {\n\t\t\tfor(k = s;k <= 100000;k++) {\n\t\t\t\tif(coin[k] > coin[k-s]+1) coin[k] = coin[k-s] + 1;\n\t\t\t}\n\t\t\tfor(k = n;k <= 100000;k++) {\n\t\t\t\tif(coin[k] > coin[k-n]+1) coin[k] = coin[k-n] + 1;\n\t\t\t}\n\t\t\ts = s * 6; n = n * 9;\n\t\t}\n\t}\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": 602, "cpu_time_ms": 105, "memory_kb": 23252}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s626135113", "group_id": "codeNet:p03336", "input_text": "import static java.lang.Integer.parseInt;\nimport static java.lang.Long.parseLong;\nimport static java.lang.Math.max;\nimport static java.lang.System.exit;\nimport static java.util.Arrays.fill;\n\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.PrintWriter;\nimport java.util.PriorityQueue;\nimport java.util.StringTokenizer;\n\npublic class Main {\n\n\tstatic class Token implements Comparable {\n\t\tint index;\n\t\tfinal int time;\n\n\t\tToken(int index, int time) {\n\t\t\tthis.index = index;\n\t\t\tthis.time = time;\n\t\t}\n\n\t\tpublic int compareTo(Token o) {\n\t\t\treturn time - o.time;\n\t\t}\n\t}\n\n\tstatic void solve() throws Exception {\n\t\tint c1 = scanInt();\n\t\tint c2 = scanInt();\n\t\tint c = max(c1, c2);\n\t\tint k = scanInt();\n\t\tint bit[] = new int[c];\n\t\tString s1 = scanString();\n\t\tfor (int i = 0; i < c1; i++) {\n\t\t\tif (s1.charAt(i) == '1') {\n\t\t\t\tbit[c1 - i - 1] |= 1;\n\t\t\t}\n\t\t}\n\t\tString s2 = scanString();\n\t\tfor (int i = 0; i < c2; i++) {\n\t\t\tif (s2.charAt(i) == '1') {\n\t\t\t\tbit[c2 - i - 1] |= 2;\n\t\t\t}\n\t\t}\n\t\tint lCap = 2 * c + 2;\n\t\tint lIndex[] = new int[lCap], lValue[] = new int[lCap];\n\t\tint lPrev[] = new int[lCap], lNext[] = new int[lCap], lFree = 1;\n\t\tToken lToken[] = new Token[lCap];\n\t\tfor (int i = 1; i < lCap - 1; i++) {\n\t\t\tlNext[i] = i + 1;\n\t\t}\n\t\tlNext[lCap - 1] = -1;\n\t\tlPrev[0] = lNext[0] = 0;\n\t\tlIndex[0] = lValue[0] = -1;\n\t\tPriorityQueue pq = new PriorityQueue<>();\n\t\tfor (int i = 0; i < c; i++) {\n\t\t\tif (bit[i] == 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tint cur = lFree;\n\t\t\tlFree = lNext[lFree];\n\t\t\tlIndex[cur] = i;\n\t\t\tlValue[cur] = bit[i];\n\t\t\tint last = lPrev[0];\n\t\t\tif (lValue[last] == 3 && lValue[cur] != 3) {\n\t\t\t\tlToken[last] = new Token(last, lIndex[cur] - lIndex[last]);\n\t\t\t\tpq.add(lToken[last]);\n\t\t\t}\n\t\t\tlPrev[cur] = last;\n\t\t\tlNext[cur] = 0;\n\t\t\tlPrev[0] = lNext[last] = cur;\n\t\t}\n\t\tfor (int step = 1; step <= k; step++) {\n\t\t\twhile (!pq.isEmpty() && pq.element().time == step) {\n\t\t\t\tint cur = pq.remove().index;\n\t\t\t\tlToken[cur] = null;\n\t\t\t\tint v;\n\t\t\t\t{\n\t\t\t\t\tint next = lNext[cur];\n\t\t\t\t\tv = lValue[next];\n\t\t\t\t\tlValue[cur] = 3 ^ v;\n\t\t\t\t\tlIndex[cur] += step;\n\t\t\t\t\tint prev = lPrev[cur];\n\t\t\t\t\tif (lValue[prev] == 3) {\n\t\t\t\t\t\tlToken[prev] = new Token(prev, lIndex[cur] - lIndex[prev]);\n\t\t\t\t\t\tpq.add(lToken[prev]);\n\t\t\t\t\t}\n\t\t\t\t\tint next2 = lNext[next];\n\t\t\t\t\tlNext[cur] = next2;\n\t\t\t\t\tlPrev[next2] = cur;\n\t\t\t\t\tlNext[next] = lFree;\n\t\t\t\t\tlFree = next;\n\t\t\t\t}\n\t\t\t\tint curIndex = lIndex[cur];\n\t\t\t\twhile (true) {\n\t\t\t\t\tint next = lNext[cur];\n\t\t\t\t\t++curIndex;\n\t\t\t\t\tif (lValue[next] != 3 && lIndex[next] == curIndex) {\n\t\t\t\t\t\tif (lValue[next] == v) {\n\t\t\t\t\t\t\tint next2 = lNext[next];\n\t\t\t\t\t\t\tlNext[cur] = next2;\n\t\t\t\t\t\t\tlPrev[next2] = cur;\n\t\t\t\t\t\t\tlNext[next] = lFree;\n\t\t\t\t\t\t\tlFree = next;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tlValue[next] = 3;\n\t\t\t\t\t\t\tlIndex[next] -= step;\n\t\t\t\t\t\t\tint next2 = lNext[next];\n\t\t\t\t\t\t\tif (next2 != 0 && lValue[next2] != 3) {\n\t\t\t\t\t\t\t\tlToken[next] = new Token(next, lIndex[next2] - lIndex[next]);\n\t\t\t\t\t\t\t\tpq.add(lToken[next]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tint neww = lFree;\n\t\t\t\t\t\tlFree = lNext[lFree];\n\t\t\t\t\t\tlIndex[neww] = curIndex;\n\t\t\t\t\t\tlValue[neww] = v;\n\t\t\t\t\t\tlPrev[neww] = cur;\n\t\t\t\t\t\tlNext[neww] = next;\n\t\t\t\t\t\tlPrev[next] = lNext[cur] = neww;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tint last = lPrev[0];\n\t\tint maxIndex = lValue[last] == 3 ? lIndex[last] + k : lIndex[last];\n\t\tchar bits0[] = new char[maxIndex + 1], bits1[] = new char[maxIndex + 1];\n\t\tfill(bits0, '0');\n\t\tfill(bits1, '0');\n\t\tint firstBit0 = -1, firstBit1 = -1;\n\t\tfor (int cur = lNext[0]; cur != 0; cur = lNext[cur]) {\n\t\t\tint curValue = lValue[cur];\n\t\t\tint curIndex = curValue == 3 ? lIndex[cur] + k : lIndex[cur];\n\t\t\tif ((curValue & 1) != 0) {\n\t\t\t\tbits0[maxIndex - curIndex] = '1';\n\t\t\t\tfirstBit0 = maxIndex - curIndex;\n\t\t\t}\n\t\t\tif ((curValue & 2) != 0) {\n\t\t\t\tbits1[maxIndex - curIndex] = '1';\n\t\t\t\tfirstBit1 = maxIndex - curIndex;\n\t\t\t}\n\t\t}\n\t\tout.println(new String(bits0, firstBit0, maxIndex - firstBit0 + 1));\n\t\tout.print(new String(bits1, firstBit1, maxIndex - firstBit1 + 1));\n\t}\n\n\tstatic int scanInt() throws IOException {\n\t\treturn parseInt(scanString());\n\t}\n\n\tstatic long scanLong() throws IOException {\n\t\treturn parseLong(scanString());\n\t}\n\n\tstatic String scanString() throws IOException {\n\t\twhile (tok == null || !tok.hasMoreTokens()) {\n\t\t\ttok = new StringTokenizer(in.readLine());\n\t\t}\n\t\treturn tok.nextToken();\n\t}\n\n\tstatic BufferedReader in;\n\tstatic PrintWriter out;\n\tstatic StringTokenizer tok;\n\n\tpublic static void main(String[] args) {\n\t\ttry {\n\t\t\tin = new BufferedReader(new InputStreamReader(System.in));\n\t\t\tout = new PrintWriter(System.out);\n\t\t\tsolve();\n\t\t\tin.close();\n\t\t\tout.close();\n\t\t} catch (Throwable e) {\n\t\t\te.printStackTrace();\n\t\t\texit(1);\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1528081180, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03336.html", "problem_id": "p03336", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03336/input.txt", "sample_output_relpath": "derived/input_output/data/p03336/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03336/Java/s626135113.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s626135113", "user_id": "u441988308"}, "prompt_components": {"gold_output": "10000\n10010\n", "input_to_evaluate": "import static java.lang.Integer.parseInt;\nimport static java.lang.Long.parseLong;\nimport static java.lang.Math.max;\nimport static java.lang.System.exit;\nimport static java.util.Arrays.fill;\n\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.PrintWriter;\nimport java.util.PriorityQueue;\nimport java.util.StringTokenizer;\n\npublic class Main {\n\n\tstatic class Token implements Comparable {\n\t\tint index;\n\t\tfinal int time;\n\n\t\tToken(int index, int time) {\n\t\t\tthis.index = index;\n\t\t\tthis.time = time;\n\t\t}\n\n\t\tpublic int compareTo(Token o) {\n\t\t\treturn time - o.time;\n\t\t}\n\t}\n\n\tstatic void solve() throws Exception {\n\t\tint c1 = scanInt();\n\t\tint c2 = scanInt();\n\t\tint c = max(c1, c2);\n\t\tint k = scanInt();\n\t\tint bit[] = new int[c];\n\t\tString s1 = scanString();\n\t\tfor (int i = 0; i < c1; i++) {\n\t\t\tif (s1.charAt(i) == '1') {\n\t\t\t\tbit[c1 - i - 1] |= 1;\n\t\t\t}\n\t\t}\n\t\tString s2 = scanString();\n\t\tfor (int i = 0; i < c2; i++) {\n\t\t\tif (s2.charAt(i) == '1') {\n\t\t\t\tbit[c2 - i - 1] |= 2;\n\t\t\t}\n\t\t}\n\t\tint lCap = 2 * c + 2;\n\t\tint lIndex[] = new int[lCap], lValue[] = new int[lCap];\n\t\tint lPrev[] = new int[lCap], lNext[] = new int[lCap], lFree = 1;\n\t\tToken lToken[] = new Token[lCap];\n\t\tfor (int i = 1; i < lCap - 1; i++) {\n\t\t\tlNext[i] = i + 1;\n\t\t}\n\t\tlNext[lCap - 1] = -1;\n\t\tlPrev[0] = lNext[0] = 0;\n\t\tlIndex[0] = lValue[0] = -1;\n\t\tPriorityQueue pq = new PriorityQueue<>();\n\t\tfor (int i = 0; i < c; i++) {\n\t\t\tif (bit[i] == 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tint cur = lFree;\n\t\t\tlFree = lNext[lFree];\n\t\t\tlIndex[cur] = i;\n\t\t\tlValue[cur] = bit[i];\n\t\t\tint last = lPrev[0];\n\t\t\tif (lValue[last] == 3 && lValue[cur] != 3) {\n\t\t\t\tlToken[last] = new Token(last, lIndex[cur] - lIndex[last]);\n\t\t\t\tpq.add(lToken[last]);\n\t\t\t}\n\t\t\tlPrev[cur] = last;\n\t\t\tlNext[cur] = 0;\n\t\t\tlPrev[0] = lNext[last] = cur;\n\t\t}\n\t\tfor (int step = 1; step <= k; step++) {\n\t\t\twhile (!pq.isEmpty() && pq.element().time == step) {\n\t\t\t\tint cur = pq.remove().index;\n\t\t\t\tlToken[cur] = null;\n\t\t\t\tint v;\n\t\t\t\t{\n\t\t\t\t\tint next = lNext[cur];\n\t\t\t\t\tv = lValue[next];\n\t\t\t\t\tlValue[cur] = 3 ^ v;\n\t\t\t\t\tlIndex[cur] += step;\n\t\t\t\t\tint prev = lPrev[cur];\n\t\t\t\t\tif (lValue[prev] == 3) {\n\t\t\t\t\t\tlToken[prev] = new Token(prev, lIndex[cur] - lIndex[prev]);\n\t\t\t\t\t\tpq.add(lToken[prev]);\n\t\t\t\t\t}\n\t\t\t\t\tint next2 = lNext[next];\n\t\t\t\t\tlNext[cur] = next2;\n\t\t\t\t\tlPrev[next2] = cur;\n\t\t\t\t\tlNext[next] = lFree;\n\t\t\t\t\tlFree = next;\n\t\t\t\t}\n\t\t\t\tint curIndex = lIndex[cur];\n\t\t\t\twhile (true) {\n\t\t\t\t\tint next = lNext[cur];\n\t\t\t\t\t++curIndex;\n\t\t\t\t\tif (lValue[next] != 3 && lIndex[next] == curIndex) {\n\t\t\t\t\t\tif (lValue[next] == v) {\n\t\t\t\t\t\t\tint next2 = lNext[next];\n\t\t\t\t\t\t\tlNext[cur] = next2;\n\t\t\t\t\t\t\tlPrev[next2] = cur;\n\t\t\t\t\t\t\tlNext[next] = lFree;\n\t\t\t\t\t\t\tlFree = next;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tlValue[next] = 3;\n\t\t\t\t\t\t\tlIndex[next] -= step;\n\t\t\t\t\t\t\tint next2 = lNext[next];\n\t\t\t\t\t\t\tif (next2 != 0 && lValue[next2] != 3) {\n\t\t\t\t\t\t\t\tlToken[next] = new Token(next, lIndex[next2] - lIndex[next]);\n\t\t\t\t\t\t\t\tpq.add(lToken[next]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tint neww = lFree;\n\t\t\t\t\t\tlFree = lNext[lFree];\n\t\t\t\t\t\tlIndex[neww] = curIndex;\n\t\t\t\t\t\tlValue[neww] = v;\n\t\t\t\t\t\tlPrev[neww] = cur;\n\t\t\t\t\t\tlNext[neww] = next;\n\t\t\t\t\t\tlPrev[next] = lNext[cur] = neww;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tint last = lPrev[0];\n\t\tint maxIndex = lValue[last] == 3 ? lIndex[last] + k : lIndex[last];\n\t\tchar bits0[] = new char[maxIndex + 1], bits1[] = new char[maxIndex + 1];\n\t\tfill(bits0, '0');\n\t\tfill(bits1, '0');\n\t\tint firstBit0 = -1, firstBit1 = -1;\n\t\tfor (int cur = lNext[0]; cur != 0; cur = lNext[cur]) {\n\t\t\tint curValue = lValue[cur];\n\t\t\tint curIndex = curValue == 3 ? lIndex[cur] + k : lIndex[cur];\n\t\t\tif ((curValue & 1) != 0) {\n\t\t\t\tbits0[maxIndex - curIndex] = '1';\n\t\t\t\tfirstBit0 = maxIndex - curIndex;\n\t\t\t}\n\t\t\tif ((curValue & 2) != 0) {\n\t\t\t\tbits1[maxIndex - curIndex] = '1';\n\t\t\t\tfirstBit1 = maxIndex - curIndex;\n\t\t\t}\n\t\t}\n\t\tout.println(new String(bits0, firstBit0, maxIndex - firstBit0 + 1));\n\t\tout.print(new String(bits1, firstBit1, maxIndex - firstBit1 + 1));\n\t}\n\n\tstatic int scanInt() throws IOException {\n\t\treturn parseInt(scanString());\n\t}\n\n\tstatic long scanLong() throws IOException {\n\t\treturn parseLong(scanString());\n\t}\n\n\tstatic String scanString() throws IOException {\n\t\twhile (tok == null || !tok.hasMoreTokens()) {\n\t\t\ttok = new StringTokenizer(in.readLine());\n\t\t}\n\t\treturn tok.nextToken();\n\t}\n\n\tstatic BufferedReader in;\n\tstatic PrintWriter out;\n\tstatic StringTokenizer tok;\n\n\tpublic static void main(String[] args) {\n\t\ttry {\n\t\t\tin = new BufferedReader(new InputStreamReader(System.in));\n\t\t\tout = new PrintWriter(System.out);\n\t\t\tsolve();\n\t\t\tin.close();\n\t\t\tout.close();\n\t\t} catch (Throwable e) {\n\t\t\te.printStackTrace();\n\t\t\texit(1);\n\t\t}\n\t}\n}", "problem_context": "Score : 2400 points\n\nProblem Statement\n\nTakahashi and Aoki love calculating things, so they will play with numbers now.\n\nFirst, they came up with one positive integer each. Takahashi came up with X, and Aoki came up with Y.\nThen, they will enjoy themselves by repeating the following operation K times:\n\nCompute the bitwise AND of the number currently kept by Takahashi and the number currently kept by Aoki. Let Z be the result.\n\nThen, add Z to both of the numbers kept by Takahashi and Aoki.\n\nHowever, it turns out that even for the two math maniacs this is just too much work.\nCould you find the number that would be kept by Takahashi and the one that would be kept by Aoki eventually?\n\nNote that input and output are done in binary.\nEspecially, X and Y are given as strings S and T of length N and M consisting of 0 and 1, respectively, whose initial characters are guaranteed to be 1.\n\nConstraints\n\n1 ≤ K ≤ 10^6\n\n1 ≤ N,M ≤ 10^6\n\nThe initial characters of S and T are 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\nS\nT\n\nOutput\n\nIn the first line, print the number that would be kept by Takahashi eventually; in the second line, print the number that would be kept by Aoki eventually.\nThose numbers should be represented in binary and printed as strings consisting of 0 and 1 that begin with 1.\n\nSample Input 1\n\n2 3 3\n11\n101\n\nSample Output 1\n\n10000\n10010\n\nThe values of X and Y after each operation are as follows:\n\nAfter the first operation: (X,Y)=(4,6).\n\nAfter the second operation: (X,Y)=(8,10).\n\nAfter the third operation: (X,Y)=(16,18).\n\nSample Input 2\n\n5 8 3\n10101\n10101001\n\nSample Output 2\n\n100000\n10110100\n\nSample Input 3\n\n10 10 10\n1100110011\n1011001101\n\nSample Output 3\n\n10000100000010001000\n10000100000000100010", "sample_input": "2 3 3\n11\n101\n"}, "reference_outputs": ["10000\n10010\n"], "source_document_id": "p03336", "source_text": "Score : 2400 points\n\nProblem Statement\n\nTakahashi and Aoki love calculating things, so they will play with numbers now.\n\nFirst, they came up with one positive integer each. Takahashi came up with X, and Aoki came up with Y.\nThen, they will enjoy themselves by repeating the following operation K times:\n\nCompute the bitwise AND of the number currently kept by Takahashi and the number currently kept by Aoki. Let Z be the result.\n\nThen, add Z to both of the numbers kept by Takahashi and Aoki.\n\nHowever, it turns out that even for the two math maniacs this is just too much work.\nCould you find the number that would be kept by Takahashi and the one that would be kept by Aoki eventually?\n\nNote that input and output are done in binary.\nEspecially, X and Y are given as strings S and T of length N and M consisting of 0 and 1, respectively, whose initial characters are guaranteed to be 1.\n\nConstraints\n\n1 ≤ K ≤ 10^6\n\n1 ≤ N,M ≤ 10^6\n\nThe initial characters of S and T are 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\nS\nT\n\nOutput\n\nIn the first line, print the number that would be kept by Takahashi eventually; in the second line, print the number that would be kept by Aoki eventually.\nThose numbers should be represented in binary and printed as strings consisting of 0 and 1 that begin with 1.\n\nSample Input 1\n\n2 3 3\n11\n101\n\nSample Output 1\n\n10000\n10010\n\nThe values of X and Y after each operation are as follows:\n\nAfter the first operation: (X,Y)=(4,6).\n\nAfter the second operation: (X,Y)=(8,10).\n\nAfter the third operation: (X,Y)=(16,18).\n\nSample Input 2\n\n5 8 3\n10101\n10101001\n\nSample Output 2\n\n100000\n10110100\n\nSample Input 3\n\n10 10 10\n1100110011\n1011001101\n\nSample Output 3\n\n10000100000010001000\n10000100000000100010", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4686, "cpu_time_ms": 1077, "memory_kb": 117840}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s569413701", "group_id": "codeNet:p03338", "input_text": "import java.util.HashSet;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tString s = sc.next();\n\t\tint cntMax = 0;\n\n\t\tfor (int i = 1; i < n; i++){\n\t\t\tString left = s.substring(0, i);\n\t\t\tString right = s.substring(i, s.length());\n\t\t\tHashSet commonStr = new HashSet();\n\t\t\tint cnt = 0;\n\t\t\tfor (int j = 0; j < left.length(); j++){\n\t\t\t\tif (right.contains(left.substring(j, j+1))){\n\t\t\t\t\tcommonStr.add(left.substring(j, j+1));\n\t\t\t\t}\n\t\t\t}\n\t\t\tcntMax = Math.max(cntMax, commonStr.size());\n\t\t}\n\t\tSystem.out.println(cntMax);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1527383932, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03338.html", "problem_id": "p03338", "resource_group": "high_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/Java/s569413701.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s569413701", "user_id": "u268491792"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.HashSet;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tString s = sc.next();\n\t\tint cntMax = 0;\n\n\t\tfor (int i = 1; i < n; i++){\n\t\t\tString left = s.substring(0, i);\n\t\t\tString right = s.substring(i, s.length());\n\t\t\tHashSet commonStr = new HashSet();\n\t\t\tint cnt = 0;\n\t\t\tfor (int j = 0; j < left.length(); j++){\n\t\t\t\tif (right.contains(left.substring(j, j+1))){\n\t\t\t\t\tcommonStr.add(left.substring(j, j+1));\n\t\t\t\t}\n\t\t\t}\n\t\t\tcntMax = Math.max(cntMax, commonStr.size());\n\t\t}\n\t\tSystem.out.println(cntMax);\n\t}\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": 642, "cpu_time_ms": 112, "memory_kb": 23892}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s736519233", "group_id": "codeNet:p03339", "input_text": "import java.util.Scanner;\n\npublic class Main { \n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n String S = sc.next();\n int countW =0;int countE =0;\n int[] count = new int[N];\n int min =300000;\n for (int i =0; i i && S.charAt(j) == 'E') countE++;\n }\n min = Math.min(countW + countE,min);\n countW =0;countE =0;\n }\n System.out.println(min);\n }\n} ", "language": "Java", "metadata": {"date": 1592865422, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p03339.html", "problem_id": "p03339", "resource_group": "high_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/Java/s736519233.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s736519233", "user_id": "u538283043"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main { \n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n String S = sc.next();\n int countW =0;int countE =0;\n int[] count = new int[N];\n int min =300000;\n for (int i =0; i i && S.charAt(j) == 'E') countE++;\n }\n min = Math.min(countW + countE,min);\n countW =0;countE =0;\n }\n System.out.println(min);\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": 586, "cpu_time_ms": 2207, "memory_kb": 44016}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s621453729", "group_id": "codeNet:p03346", "input_text": "import java.io.*;\nimport java.util.*;\nimport java.math.*;\n// import java.awt.Point;\n \npublic class Main {\n InputStream is;\n PrintWriter out;\n String INPUT = \"\";\n \n long mod = 1_000_000_007;\n long inf = Long.MAX_VALUE;\n\n void solve(){\n int n = ni();\n int[] a = new int[n];\n for(int i = 0; i < n; i++){\n a[i] = ni();\n }\n int ans = 0;\n int res = 0;\n int f = a[0];\n for(int i = 1; i < n; i++){\n if(a[i]==f+1){\n res++;\n f++;\n }\n }\n // out.println(res);\n ans = Math.max(ans, res);\n f = a[n-1];\n res = 0;\n for(int i = n-2; i >= 0; i--){\n if(a[i]==f-1){\n res++;\n f--;\n }\n }\n // out.println(res);\n ans = Math.max(ans, res);\n out.println(n-ans-1);\n }\n\n\n void run() throws Exception\n {\n is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n out = new PrintWriter(System.out);\n long s = System.currentTimeMillis();\n solve();\n out.flush();\n if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+\"ms\");\n }\n \n public static void main(String[] args) throws Exception { new Main().run(); }\n \n private byte[] inbuf = new byte[1024];\n private int lenbuf = 0, ptrbuf = 0;\n \n private int readByte()\n {\n if(lenbuf == -1)throw new InputMismatchException();\n if(ptrbuf >= lenbuf){\n ptrbuf = 0;\n try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }\n if(lenbuf <= 0)return -1;\n }\n return inbuf[ptrbuf++];\n }\n \n private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }\n private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }\n \n private double nd() { return Double.parseDouble(ns()); }\n private char nc() { return (char)skip(); }\n \n private String ns()\n {\n int b = skip();\n StringBuilder sb = new StringBuilder();\n while(!(isSpaceChar(b) && b != ' ')){\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n \n private char[] ns(int n)\n {\n char[] buf = new char[n];\n int b = skip(), p = 0;\n while(p < n && !(isSpaceChar(b))){\n buf[p++] = (char)b;\n b = readByte();\n }\n return n == p ? buf : Arrays.copyOf(buf, p);\n }\n \n private char[][] nm(int n, int m)\n {\n char[][] map = new char[n][];\n for(int i = 0;i < n;i++)map[i] = ns(m);\n return map;\n }\n \n private int[] na(int n)\n {\n int[] a = new int[n];\n for(int i = 0;i < n;i++)a[i] = ni();\n return a;\n }\n \n private int ni()\n {\n int num = 0, b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-'){\n minus = true;\n b = readByte();\n }\n \n while(true){\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n }else{\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n \n private long nl()\n {\n long num = 0;\n int b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-'){\n minus = true;\n b = readByte();\n }\n \n while(true){\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n }else{\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n \n private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); }\n \n}\n", "language": "Java", "metadata": {"date": 1526866921, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03346.html", "problem_id": "p03346", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03346/input.txt", "sample_output_relpath": "derived/input_output/data/p03346/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03346/Java/s621453729.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s621453729", "user_id": "u675503966"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\nimport java.math.*;\n// import java.awt.Point;\n \npublic class Main {\n InputStream is;\n PrintWriter out;\n String INPUT = \"\";\n \n long mod = 1_000_000_007;\n long inf = Long.MAX_VALUE;\n\n void solve(){\n int n = ni();\n int[] a = new int[n];\n for(int i = 0; i < n; i++){\n a[i] = ni();\n }\n int ans = 0;\n int res = 0;\n int f = a[0];\n for(int i = 1; i < n; i++){\n if(a[i]==f+1){\n res++;\n f++;\n }\n }\n // out.println(res);\n ans = Math.max(ans, res);\n f = a[n-1];\n res = 0;\n for(int i = n-2; i >= 0; i--){\n if(a[i]==f-1){\n res++;\n f--;\n }\n }\n // out.println(res);\n ans = Math.max(ans, res);\n out.println(n-ans-1);\n }\n\n\n void run() throws Exception\n {\n is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n out = new PrintWriter(System.out);\n long s = System.currentTimeMillis();\n solve();\n out.flush();\n if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+\"ms\");\n }\n \n public static void main(String[] args) throws Exception { new Main().run(); }\n \n private byte[] inbuf = new byte[1024];\n private int lenbuf = 0, ptrbuf = 0;\n \n private int readByte()\n {\n if(lenbuf == -1)throw new InputMismatchException();\n if(ptrbuf >= lenbuf){\n ptrbuf = 0;\n try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }\n if(lenbuf <= 0)return -1;\n }\n return inbuf[ptrbuf++];\n }\n \n private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }\n private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }\n \n private double nd() { return Double.parseDouble(ns()); }\n private char nc() { return (char)skip(); }\n \n private String ns()\n {\n int b = skip();\n StringBuilder sb = new StringBuilder();\n while(!(isSpaceChar(b) && b != ' ')){\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n \n private char[] ns(int n)\n {\n char[] buf = new char[n];\n int b = skip(), p = 0;\n while(p < n && !(isSpaceChar(b))){\n buf[p++] = (char)b;\n b = readByte();\n }\n return n == p ? buf : Arrays.copyOf(buf, p);\n }\n \n private char[][] nm(int n, int m)\n {\n char[][] map = new char[n][];\n for(int i = 0;i < n;i++)map[i] = ns(m);\n return map;\n }\n \n private int[] na(int n)\n {\n int[] a = new int[n];\n for(int i = 0;i < n;i++)a[i] = ni();\n return a;\n }\n \n private int ni()\n {\n int num = 0, b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-'){\n minus = true;\n b = readByte();\n }\n \n while(true){\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n }else{\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n \n private long nl()\n {\n long num = 0;\n int b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-'){\n minus = true;\n b = readByte();\n }\n \n while(true){\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n }else{\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n \n private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); }\n \n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N.\nYou would like to sort this sequence in ascending order by repeating the following operation:\n\nChoose an element in the sequence and move it to the beginning or the end of the sequence.\n\nFind the minimum number of operations required.\nIt can be proved that it is actually possible to sort the sequence using this operation.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n(P_1,P_2,...,P_N) is a permutation of (1,2,...,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\n:\nP_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4\n1\n3\n2\n4\n\nSample Output 1\n\n2\n\nFor example, the sequence can be sorted in ascending order as follows:\n\nMove 2 to the beginning. The sequence is now (2,1,3,4).\n\nMove 1 to the beginning. The sequence is now (1,2,3,4).\n\nSample Input 2\n\n6\n3\n2\n5\n1\n4\n6\n\nSample Output 2\n\n4\n\nSample Input 3\n\n8\n6\n3\n1\n2\n7\n4\n8\n5\n\nSample Output 3\n\n5", "sample_input": "4\n1\n3\n2\n4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03346", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N.\nYou would like to sort this sequence in ascending order by repeating the following operation:\n\nChoose an element in the sequence and move it to the beginning or the end of the sequence.\n\nFind the minimum number of operations required.\nIt can be proved that it is actually possible to sort the sequence using this operation.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n(P_1,P_2,...,P_N) is a permutation of (1,2,...,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\n:\nP_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4\n1\n3\n2\n4\n\nSample Output 1\n\n2\n\nFor example, the sequence can be sorted in ascending order as follows:\n\nMove 2 to the beginning. The sequence is now (2,1,3,4).\n\nMove 1 to the beginning. The sequence is now (1,2,3,4).\n\nSample Input 2\n\n6\n3\n2\n5\n1\n4\n6\n\nSample Output 2\n\n4\n\nSample Input 3\n\n8\n6\n3\n1\n2\n7\n4\n8\n5\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": 3953, "cpu_time_ms": 157, "memory_kb": 24020}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s152590559", "group_id": "codeNet:p03351", "input_text": "import java.util.*;\n\npublic class Main{\n public static void main(String[] args){\n Scanner sc=new Scanner(System.in);\n int[] dis=new int[3];\n for(int i=0;i<3;i++){\n dis[i]=sc.nextInt();\n }\n int d=sc.nextInt();\n if(Math.abs(dis[2]-dis[0])<=d){\n System.out.println(\"Yes\");\n }else if(Math.abs(dis[1]-dis[0])<=d && Math.abs(dis[2]-dis[1])<=d){\n System.out.println(\"Yes\");\n }else{\n System.out.println(\"No\");\n }\n }\n}", "language": "Java", "metadata": {"date": 1573570257, "filename_ext": "java", "original_language": "Java7 (OpenJDK 1.7.0)", "problem_description_relpath": "problem_descriptions/p03351.html", "problem_id": "p03351", "resource_group": "high_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/Java/s152590559.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s152590559", "user_id": "u431125128"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main{\n public static void main(String[] args){\n Scanner sc=new Scanner(System.in);\n int[] dis=new int[3];\n for(int i=0;i<3;i++){\n dis[i]=sc.nextInt();\n }\n int d=sc.nextInt();\n if(Math.abs(dis[2]-dis[0])<=d){\n System.out.println(\"Yes\");\n }else if(Math.abs(dis[1]-dis[0])<=d && Math.abs(dis[2]-dis[1])<=d){\n System.out.println(\"Yes\");\n }else{\n System.out.println(\"No\");\n }\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": 458, "cpu_time_ms": 99, "memory_kb": 22868}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s717041770", "group_id": "codeNet:p03351", "input_text": "import java.util.Scanner;\n\nclass Main {\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n\n double num;\n\n System.err.print(\"num: \");\n num = sc.nextDouble();\n\n double temporaryNum = 1;\n\n while (num >= temporaryNum) {\n for (int i = 1; Math.pow(i, 2) <= num; i++) {\n for (int n = 2; Math.pow(i, n) <= num; n++) {\n if (temporaryNum < Math.pow(i, n)) {\n temporaryNum = Math.pow(i, n);\n }\n }\n }\n }\n System.out.println(temporaryNum);\n return;\n }\n}\n", "language": "Java", "metadata": {"date": 1570455491, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03351.html", "problem_id": "p03351", "resource_group": "high_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/Java/s717041770.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s717041770", "user_id": "u110115790"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\n\nclass Main {\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n\n double num;\n\n System.err.print(\"num: \");\n num = sc.nextDouble();\n\n double temporaryNum = 1;\n\n while (num >= temporaryNum) {\n for (int i = 1; Math.pow(i, 2) <= num; i++) {\n for (int n = 2; Math.pow(i, n) <= num; n++) {\n if (temporaryNum < Math.pow(i, n)) {\n temporaryNum = Math.pow(i, n);\n }\n }\n }\n }\n System.out.println(temporaryNum);\n return;\n }\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": 553, "cpu_time_ms": 2109, "memory_kb": 25172}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s178548554", "group_id": "codeNet:p03353", "input_text": "import java.util.Scanner;\nimport java.util.TreeSet;\n\nclass Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tString s = sc.next(); int K = sc.nextInt();\n\t\tTreeSet ans = new TreeSet();\n\t\tfor(int k = 1; k <= K; k++) {\n\t\t\tfor(int i = 0; i + k <= s.length(); i++) {\n\t\t\t\tans.add(s.substring(i, i + k));\n\t\t\t}\n\t\t}\n\t\twhile(K > 1) {\n\t\t\tans.pollFirst();\n\t\t\tK--;\n\t\t}\n\t\tSystem.out.println(ans.pollFirst());\n\t}\n}", "language": "Java", "metadata": {"date": 1563288333, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03353.html", "problem_id": "p03353", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03353/input.txt", "sample_output_relpath": "derived/input_output/data/p03353/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03353/Java/s178548554.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s178548554", "user_id": "u198062737"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "import java.util.Scanner;\nimport java.util.TreeSet;\n\nclass Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tString s = sc.next(); int K = sc.nextInt();\n\t\tTreeSet ans = new TreeSet();\n\t\tfor(int k = 1; k <= K; k++) {\n\t\t\tfor(int i = 0; i + k <= s.length(); i++) {\n\t\t\t\tans.add(s.substring(i, i + k));\n\t\t\t}\n\t\t}\n\t\twhile(K > 1) {\n\t\t\tans.pollFirst();\n\t\t\tK--;\n\t\t}\n\t\tSystem.out.println(ans.pollFirst());\n\t}\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string s.\nAmong the different substrings of s, print the K-th lexicographically smallest one.\n\nA substring of s is a string obtained by taking out a non-empty contiguous part in s.\nFor example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string are not.\nAlso, we say that substrings are different when they are different as strings.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 ≤ |s| ≤ 5000\n\ns consists of lowercase English letters.\n\n1 ≤ K ≤ 5\n\ns has at least K different substrings.\n\nPartial Score\n\n200 points will be awarded as a partial score for passing the test set satisfying |s| ≤ 50.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nK\n\nOutput\n\nPrint the K-th lexicographically smallest substring of K.\n\nSample Input 1\n\naba\n4\n\nSample Output 1\n\nb\n\ns has five substrings: a, b, ab, ba and aba.\nAmong them, we should print the fourth smallest one, b.\nNote that we do not count a twice.\n\nSample Input 2\n\natcoderandatcodeer\n5\n\nSample Output 2\n\nandat\n\nSample Input 3\n\nz\n1\n\nSample Output 3\n\nz", "sample_input": "aba\n4\n"}, "reference_outputs": ["b\n"], "source_document_id": "p03353", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string s.\nAmong the different substrings of s, print the K-th lexicographically smallest one.\n\nA substring of s is a string obtained by taking out a non-empty contiguous part in s.\nFor example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string are not.\nAlso, we say that substrings are different when they are different as strings.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 ≤ |s| ≤ 5000\n\ns consists of lowercase English letters.\n\n1 ≤ K ≤ 5\n\ns has at least K different substrings.\n\nPartial Score\n\n200 points will be awarded as a partial score for passing the test set satisfying |s| ≤ 50.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nK\n\nOutput\n\nPrint the K-th lexicographically smallest substring of K.\n\nSample Input 1\n\naba\n4\n\nSample Output 1\n\nb\n\ns has five substrings: a, b, ab, ba and aba.\nAmong them, we should print the fourth smallest one, b.\nNote that we do not count a twice.\n\nSample Input 2\n\natcoderandatcodeer\n5\n\nSample Output 2\n\nandat\n\nSample Input 3\n\nz\n1\n\nSample Output 3\n\nz", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 453, "cpu_time_ms": 141, "memory_kb": 25812}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s555724866", "group_id": "codeNet:p03353", "input_text": "import java.util.HashSet;\nimport java.util.Iterator;\nimport java.util.Scanner;\nimport java.util.Set;\nimport java.util.TreeSet;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner reader = new Scanner(System.in);\n\t\tString s = reader.next();\n\t\tint K = reader.nextInt();\n\t\tString ans = \"\";\n\t\tSet set = new HashSet();\n\n\t\tfor (int i = 1; i <= K&&i <= s.length(); i++) {\n\t\t\tfor (int j = 0; j <= s.length() - i; j++) {\n\t\t\t\tString sb = s.substring(j, j+i);\n\t\t\t\tset.add(sb);\n\t\t\t}\n\t\t}\n\n\t\tSet sortedSet = new TreeSet(set);\n\n\t\tIterator itr = sortedSet.iterator();\n\t\tint count = 0;\n\t\twhile (count < K && itr.hasNext()) {\n\t\t\tans = itr.next();\n\t\t\tcount++;\n\t\t}\n\n\t\tSystem.out.print(ans);\n\t\treader.close();\n\t}\n}\n\n\n\n", "language": "Java", "metadata": {"date": 1554326660, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03353.html", "problem_id": "p03353", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03353/input.txt", "sample_output_relpath": "derived/input_output/data/p03353/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03353/Java/s555724866.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s555724866", "user_id": "u431954591"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "import java.util.HashSet;\nimport java.util.Iterator;\nimport java.util.Scanner;\nimport java.util.Set;\nimport java.util.TreeSet;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner reader = new Scanner(System.in);\n\t\tString s = reader.next();\n\t\tint K = reader.nextInt();\n\t\tString ans = \"\";\n\t\tSet set = new HashSet();\n\n\t\tfor (int i = 1; i <= K&&i <= s.length(); i++) {\n\t\t\tfor (int j = 0; j <= s.length() - i; j++) {\n\t\t\t\tString sb = s.substring(j, j+i);\n\t\t\t\tset.add(sb);\n\t\t\t}\n\t\t}\n\n\t\tSet sortedSet = new TreeSet(set);\n\n\t\tIterator itr = sortedSet.iterator();\n\t\tint count = 0;\n\t\twhile (count < K && itr.hasNext()) {\n\t\t\tans = itr.next();\n\t\t\tcount++;\n\t\t}\n\n\t\tSystem.out.print(ans);\n\t\treader.close();\n\t}\n}\n\n\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string s.\nAmong the different substrings of s, print the K-th lexicographically smallest one.\n\nA substring of s is a string obtained by taking out a non-empty contiguous part in s.\nFor example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string are not.\nAlso, we say that substrings are different when they are different as strings.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 ≤ |s| ≤ 5000\n\ns consists of lowercase English letters.\n\n1 ≤ K ≤ 5\n\ns has at least K different substrings.\n\nPartial Score\n\n200 points will be awarded as a partial score for passing the test set satisfying |s| ≤ 50.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nK\n\nOutput\n\nPrint the K-th lexicographically smallest substring of K.\n\nSample Input 1\n\naba\n4\n\nSample Output 1\n\nb\n\ns has five substrings: a, b, ab, ba and aba.\nAmong them, we should print the fourth smallest one, b.\nNote that we do not count a twice.\n\nSample Input 2\n\natcoderandatcodeer\n5\n\nSample Output 2\n\nandat\n\nSample Input 3\n\nz\n1\n\nSample Output 3\n\nz", "sample_input": "aba\n4\n"}, "reference_outputs": ["b\n"], "source_document_id": "p03353", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string s.\nAmong the different substrings of s, print the K-th lexicographically smallest one.\n\nA substring of s is a string obtained by taking out a non-empty contiguous part in s.\nFor example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string are not.\nAlso, we say that substrings are different when they are different as strings.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 ≤ |s| ≤ 5000\n\ns consists of lowercase English letters.\n\n1 ≤ K ≤ 5\n\ns has at least K different substrings.\n\nPartial Score\n\n200 points will be awarded as a partial score for passing the test set satisfying |s| ≤ 50.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nK\n\nOutput\n\nPrint the K-th lexicographically smallest substring of K.\n\nSample Input 1\n\naba\n4\n\nSample Output 1\n\nb\n\ns has five substrings: a, b, ab, ba and aba.\nAmong them, we should print the fourth smallest one, b.\nNote that we do not count a twice.\n\nSample Input 2\n\natcoderandatcodeer\n5\n\nSample Output 2\n\nandat\n\nSample Input 3\n\nz\n1\n\nSample Output 3\n\nz", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 162, "memory_kb": 27100}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s529807759", "group_id": "codeNet:p03356", "input_text": "import java.util.ArrayList;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Scanner;\nimport java.util.Set;\n\npublic class Main {\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint m = sc.nextInt();\n\t\tint[] p = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tp[i] = sc.nextInt() - 1;\n\t\t}\n\t\tList> list = new ArrayList>();\n\t\tList> listP = new ArrayList>();\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tint x = sc.nextInt() - 1;\n\t\t\tint y = sc.nextInt() - 1;\n\t\t\tint xi = -1;\n\t\t\tint yi = -1;\n\t\t\tfor (int j = 0; j < list.size(); j++) {\n\t\t\t\tif (list.get(j).contains(x)) {\n\t\t\t\t\txi = j;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (int j = 0; j < list.size(); j++) {\n\t\t\t\tif (list.get(j).contains(y)) {\n\t\t\t\t\tyi = j;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (xi == -1) {\n\t\t\t\tif (yi == -1) {\n\t\t\t\t\tSet set = new HashSet();\n\t\t\t\t\tset.add(x);\n\t\t\t\t\tset.add(y);\n\t\t\t\t\tlist.add(set);\n\t\t\t\t\tSet setP = new HashSet();\n\t\t\t\t\tsetP.add(p[x]);\n\t\t\t\t\tsetP.add(p[y]);\n\t\t\t\t\tlistP.add(setP);\n\t\t\t\t} else {\n\t\t\t\t\tlist.get(yi).add(x);\n\t\t\t\t\tlistP.get(yi).add(p[x]);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (yi == -1) {\n\t\t\t\t\tlist.get(xi).add(y);\n\t\t\t\t\tlistP.get(xi).add(p[y]);\n\t\t\t\t} else {\n\t\t\t\t\tlist.get(xi).addAll(list.get(yi));\n\t\t\t\t\tlist.remove(yi);\n\t\t\t\t\tlistP.get(xi).addAll(listP.get(yi));\n\t\t\t\t\tlistP.remove(yi);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tsc.close();\n\n\t\tint ans = 0;\n\t\tfor (int j = 0; j < list.size(); j++) {\n\t\t\tfor (Integer i : list.get(j)) {\n\t\t\t\tif (listP.get(j).contains(i)) {\n\t\t\t\t\tans++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tif (p[i] == i) {\n\t\t\t\tboolean flg = false;\n\t\t\t\tfor (int j = 0; j < list.size(); j++) {\n\t\t\t\t\tif (listP.get(j).contains(i)) {\n\t\t\t\t\t\tflg = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!flg) {\n\t\t\t\t\tans++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1556595849, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03356.html", "problem_id": "p03356", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03356/input.txt", "sample_output_relpath": "derived/input_output/data/p03356/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03356/Java/s529807759.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s529807759", "user_id": "u522636435"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Scanner;\nimport java.util.Set;\n\npublic class Main {\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint m = sc.nextInt();\n\t\tint[] p = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tp[i] = sc.nextInt() - 1;\n\t\t}\n\t\tList> list = new ArrayList>();\n\t\tList> listP = new ArrayList>();\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tint x = sc.nextInt() - 1;\n\t\t\tint y = sc.nextInt() - 1;\n\t\t\tint xi = -1;\n\t\t\tint yi = -1;\n\t\t\tfor (int j = 0; j < list.size(); j++) {\n\t\t\t\tif (list.get(j).contains(x)) {\n\t\t\t\t\txi = j;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (int j = 0; j < list.size(); j++) {\n\t\t\t\tif (list.get(j).contains(y)) {\n\t\t\t\t\tyi = j;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (xi == -1) {\n\t\t\t\tif (yi == -1) {\n\t\t\t\t\tSet set = new HashSet();\n\t\t\t\t\tset.add(x);\n\t\t\t\t\tset.add(y);\n\t\t\t\t\tlist.add(set);\n\t\t\t\t\tSet setP = new HashSet();\n\t\t\t\t\tsetP.add(p[x]);\n\t\t\t\t\tsetP.add(p[y]);\n\t\t\t\t\tlistP.add(setP);\n\t\t\t\t} else {\n\t\t\t\t\tlist.get(yi).add(x);\n\t\t\t\t\tlistP.get(yi).add(p[x]);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (yi == -1) {\n\t\t\t\t\tlist.get(xi).add(y);\n\t\t\t\t\tlistP.get(xi).add(p[y]);\n\t\t\t\t} else {\n\t\t\t\t\tlist.get(xi).addAll(list.get(yi));\n\t\t\t\t\tlist.remove(yi);\n\t\t\t\t\tlistP.get(xi).addAll(listP.get(yi));\n\t\t\t\t\tlistP.remove(yi);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tsc.close();\n\n\t\tint ans = 0;\n\t\tfor (int j = 0; j < list.size(); j++) {\n\t\t\tfor (Integer i : list.get(j)) {\n\t\t\t\tif (listP.get(j).contains(i)) {\n\t\t\t\t\tans++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tif (p[i] == i) {\n\t\t\t\tboolean flg = false;\n\t\t\t\tfor (int j = 0; j < list.size(); j++) {\n\t\t\t\t\tif (listP.get(j).contains(i)) {\n\t\t\t\t\t\tflg = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!flg) {\n\t\t\t\t\tans++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a permutation of the integers from 1 through N, p_1, p_2, .., p_N.\nWe also have M pairs of two integers between 1 and N (inclusive), represented as (x_1,y_1), (x_2,y_2), .., (x_M,y_M).\nAtCoDeer the deer is going to perform the following operation on p as many times as desired so that the number of i (1 ≤ i ≤ N) such that p_i = i is maximized:\n\nChoose j such that 1 ≤ j ≤ M, and swap p_{x_j} and p_{y_j}.\n\nFind the maximum possible number of i such that p_i = i after operations.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ M ≤ 10^5\n\np is a permutation of integers from 1 through N.\n\n1 ≤ x_j,y_j ≤ N\n\nx_j ≠ y_j\n\nIf i ≠ j, \\{x_i,y_i\\} ≠ \\{x_j,y_j\\}.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 p_2 .. p_N\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the maximum possible number of i such that p_i = i after operations.\n\nSample Input 1\n\n5 2\n5 3 1 4 2\n1 3\n5 4\n\nSample Output 1\n\n2\n\nIf we perform the operation by choosing j=1, p becomes 1 3 5 4 2, which is optimal, so the answer is 2.\n\nSample Input 2\n\n3 2\n3 2 1\n1 2\n2 3\n\nSample Output 2\n\n3\n\nIf we perform the operation by, for example, choosing j=1, j=2, j=1 in this order, p becomes 1 2 3, which is obviously optimal.\nNote that we may choose the same j any number of times.\n\nSample Input 3\n\n10 8\n5 3 6 8 7 10 9 1 2 4\n3 1\n4 1\n5 9\n2 5\n6 5\n3 5\n8 9\n7 9\n\nSample Output 3\n\n8\n\nSample Input 4\n\n5 1\n1 2 3 4 5\n1 5\n\nSample Output 4\n\n5\n\nWe do not have to perform the operation.", "sample_input": "5 2\n5 3 1 4 2\n1 3\n5 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03356", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a permutation of the integers from 1 through N, p_1, p_2, .., p_N.\nWe also have M pairs of two integers between 1 and N (inclusive), represented as (x_1,y_1), (x_2,y_2), .., (x_M,y_M).\nAtCoDeer the deer is going to perform the following operation on p as many times as desired so that the number of i (1 ≤ i ≤ N) such that p_i = i is maximized:\n\nChoose j such that 1 ≤ j ≤ M, and swap p_{x_j} and p_{y_j}.\n\nFind the maximum possible number of i such that p_i = i after operations.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ M ≤ 10^5\n\np is a permutation of integers from 1 through N.\n\n1 ≤ x_j,y_j ≤ N\n\nx_j ≠ y_j\n\nIf i ≠ j, \\{x_i,y_i\\} ≠ \\{x_j,y_j\\}.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 p_2 .. p_N\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the maximum possible number of i such that p_i = i after operations.\n\nSample Input 1\n\n5 2\n5 3 1 4 2\n1 3\n5 4\n\nSample Output 1\n\n2\n\nIf we perform the operation by choosing j=1, p becomes 1 3 5 4 2, which is optimal, so the answer is 2.\n\nSample Input 2\n\n3 2\n3 2 1\n1 2\n2 3\n\nSample Output 2\n\n3\n\nIf we perform the operation by, for example, choosing j=1, j=2, j=1 in this order, p becomes 1 2 3, which is obviously optimal.\nNote that we may choose the same j any number of times.\n\nSample Input 3\n\n10 8\n5 3 6 8 7 10 9 1 2 4\n3 1\n4 1\n5 9\n2 5\n6 5\n3 5\n8 9\n7 9\n\nSample Output 3\n\n8\n\nSample Input 4\n\n5 1\n1 2 3 4 5\n1 5\n\nSample Output 4\n\n5\n\nWe do not have to perform the operation.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1868, "cpu_time_ms": 2110, "memory_kb": 360928}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s123053087", "group_id": "codeNet:p03359", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t\n\tScanner stdIn = new Scanner(System.in);\n\t\tint a=stdIn.nextInt();\n\t\tint b=stdIn.nextInt();\n\t\t\n\tif(b>=a){\n\t\tSystem.out.println(a);\n\t}\n\telse\n\t\tSystem.out.println(a-1);\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1528266140, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03359.html", "problem_id": "p03359", "resource_group": "high_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/Java/s123053087.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s123053087", "user_id": "u733054042"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t\n\tScanner stdIn = new Scanner(System.in);\n\t\tint a=stdIn.nextInt();\n\t\tint b=stdIn.nextInt();\n\t\t\n\tif(b>=a){\n\t\tSystem.out.println(a);\n\t}\n\telse\n\t\tSystem.out.println(a-1);\n\t}\n\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": 265, "cpu_time_ms": 95, "memory_kb": 21716}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s638723414", "group_id": "codeNet:p03359", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n int a = Integer.parseInt(sc.next());\n int b = Integer.parseInt(sc.next());\n if (a <= b) {\n System.out.println(a);\n } else {\n System.out.println(a - 1);\n }\n\n }\n}", "language": "Java", "metadata": {"date": 1525568654, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03359.html", "problem_id": "p03359", "resource_group": "high_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/Java/s638723414.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s638723414", "user_id": "u705467084"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n int a = Integer.parseInt(sc.next());\n int b = Integer.parseInt(sc.next());\n if (a <= b) {\n System.out.println(a);\n } else {\n System.out.println(a - 1);\n }\n\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": 320, "cpu_time_ms": 92, "memory_kb": 21460}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s117050346", "group_id": "codeNet:p03360", "input_text": "import java.util.Scanner;\nclass Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int[] number = new int[3];\n int sum = 0;\n \n for(int i=0;i<3;i++){\n number[i] = sc.nextInt();\n sum += number[i];\n }\n int K = sc.nextInt();\n int max = number[0];\n \n for(int j=0;j<2;j++){\n if(number[j+1]>number[j]){\n max = number[j+1];\n }\n }\n int answer = (int)(sum-max+max*Math.pow(2,K));\n System.out.println(answer);\n }\n}\n ", "language": "Java", "metadata": {"date": 1573446095, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03360.html", "problem_id": "p03360", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03360/input.txt", "sample_output_relpath": "derived/input_output/data/p03360/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03360/Java/s117050346.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s117050346", "user_id": "u796481713"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "import java.util.Scanner;\nclass Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int[] number = new int[3];\n int sum = 0;\n \n for(int i=0;i<3;i++){\n number[i] = sc.nextInt();\n sum += number[i];\n }\n int K = sc.nextInt();\n int max = number[0];\n \n for(int j=0;j<2;j++){\n if(number[j+1]>number[j]){\n max = number[j+1];\n }\n }\n int answer = (int)(sum-max+max*Math.pow(2,K));\n System.out.println(answer);\n }\n}\n ", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThere are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:\n\nChoose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.\n\nWhat is the largest possible sum of the integers written on the blackboard after K operations?\n\nConstraints\n\nA, B and C are integers between 1 and 50 (inclusive).\n\nK is an integer between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nPrint the largest possible sum of the integers written on the blackboard after K operations by E869220.\n\nSample Input 1\n\n5 3 11\n1\n\nSample Output 1\n\n30\n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120 can perform the operation once.\n\nThere are three choices:\n\nDouble 5: The integers written on the board after the operation are 10, 3, 11.\n\nDouble 3: The integers written on the board after the operation are 5, 6, 11.\n\nDouble 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5 + 3 + 22 = 30, which is the largest among 1. through 3.\n\nSample Input 2\n\n3 3 4\n2\n\nSample Output 2\n\n22\n\nE869120 can perform the operation twice. The sum of the integers eventually written on the blackboard is maximized as follows:\n\nFirst, double 4. The integers written on the board are now 3, 3, 8.\n\nNext, double 8. The integers written on the board are now 3, 3, 16.\n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 + 16 = 22.", "sample_input": "5 3 11\n1\n"}, "reference_outputs": ["30\n"], "source_document_id": "p03360", "source_text": "Score: 200 points\n\nProblem Statement\n\nThere are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:\n\nChoose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.\n\nWhat is the largest possible sum of the integers written on the blackboard after K operations?\n\nConstraints\n\nA, B and C are integers between 1 and 50 (inclusive).\n\nK is an integer between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nPrint the largest possible sum of the integers written on the blackboard after K operations by E869220.\n\nSample Input 1\n\n5 3 11\n1\n\nSample Output 1\n\n30\n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120 can perform the operation once.\n\nThere are three choices:\n\nDouble 5: The integers written on the board after the operation are 10, 3, 11.\n\nDouble 3: The integers written on the board after the operation are 5, 6, 11.\n\nDouble 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5 + 3 + 22 = 30, which is the largest among 1. through 3.\n\nSample Input 2\n\n3 3 4\n2\n\nSample Output 2\n\n22\n\nE869120 can perform the operation twice. The sum of the integers eventually written on the blackboard is maximized as follows:\n\nFirst, double 4. The integers written on the board are now 3, 3, 8.\n\nNext, double 8. The integers written on the board are now 3, 3, 16.\n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 + 16 = 22.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 98, "memory_kb": 23764}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s025647998", "group_id": "codeNet:p03360", "input_text": "import java.util.*;\n\nclass Main {\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n int c = sc.nextInt();\n int k = sc.nextInt();\n\n int max = Math.max(a, Math.max(b,c));\n int sum = a + b + c + max * (int)Math.pow(2, k) - max;\n\n System.out.println(sum);\n }\n}", "language": "Java", "metadata": {"date": 1527559429, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03360.html", "problem_id": "p03360", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03360/input.txt", "sample_output_relpath": "derived/input_output/data/p03360/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03360/Java/s025647998.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s025647998", "user_id": "u334624175"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "import java.util.*;\n\nclass Main {\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n int c = sc.nextInt();\n int k = sc.nextInt();\n\n int max = Math.max(a, Math.max(b,c));\n int sum = a + b + c + max * (int)Math.pow(2, k) - max;\n\n System.out.println(sum);\n }\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThere are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:\n\nChoose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.\n\nWhat is the largest possible sum of the integers written on the blackboard after K operations?\n\nConstraints\n\nA, B and C are integers between 1 and 50 (inclusive).\n\nK is an integer between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nPrint the largest possible sum of the integers written on the blackboard after K operations by E869220.\n\nSample Input 1\n\n5 3 11\n1\n\nSample Output 1\n\n30\n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120 can perform the operation once.\n\nThere are three choices:\n\nDouble 5: The integers written on the board after the operation are 10, 3, 11.\n\nDouble 3: The integers written on the board after the operation are 5, 6, 11.\n\nDouble 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5 + 3 + 22 = 30, which is the largest among 1. through 3.\n\nSample Input 2\n\n3 3 4\n2\n\nSample Output 2\n\n22\n\nE869120 can perform the operation twice. The sum of the integers eventually written on the blackboard is maximized as follows:\n\nFirst, double 4. The integers written on the board are now 3, 3, 8.\n\nNext, double 8. The integers written on the board are now 3, 3, 16.\n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 + 16 = 22.", "sample_input": "5 3 11\n1\n"}, "reference_outputs": ["30\n"], "source_document_id": "p03360", "source_text": "Score: 200 points\n\nProblem Statement\n\nThere are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:\n\nChoose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.\n\nWhat is the largest possible sum of the integers written on the blackboard after K operations?\n\nConstraints\n\nA, B and C are integers between 1 and 50 (inclusive).\n\nK is an integer between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nPrint the largest possible sum of the integers written on the blackboard after K operations by E869220.\n\nSample Input 1\n\n5 3 11\n1\n\nSample Output 1\n\n30\n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120 can perform the operation once.\n\nThere are three choices:\n\nDouble 5: The integers written on the board after the operation are 10, 3, 11.\n\nDouble 3: The integers written on the board after the operation are 5, 6, 11.\n\nDouble 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5 + 3 + 22 = 30, which is the largest among 1. through 3.\n\nSample Input 2\n\n3 3 4\n2\n\nSample Output 2\n\n22\n\nE869120 can perform the operation twice. The sum of the integers eventually written on the blackboard is maximized as follows:\n\nFirst, double 4. The integers written on the board are now 3, 3, 8.\n\nNext, double 8. The integers written on the board are now 3, 3, 16.\n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 + 16 = 22.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 359, "cpu_time_ms": 92, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s177140830", "group_id": "codeNet:p03361", "input_text": "import java.util.*;\n\npublic class Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc=new Scanner(System.in);\n\t\tint h=sc.nextInt();\n\t\tint w=sc.nextInt();\n\t\tint flag=0;\n\n\t\tchar s[][]=new char[52][52];\n\n\t\tfor(int i=0;i 0; i++) {\n if (i % 5 == 1) {\n System.out.print(i + \" \");\n N--;\n }\n }\n }\n}", "language": "Java", "metadata": {"date": 1525575673, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03362.html", "problem_id": "p03362", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03362/input.txt", "sample_output_relpath": "derived/input_output/data/p03362/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03362/Java/s838885275.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s838885275", "user_id": "u568545273"}, "prompt_components": {"gold_output": "3 5 7 11 31\n", "input_to_evaluate": "import java.util.Scanner;\nimport java.util.Arrays;\n\npublic class Main {\n\n public static void main(String[] args) {\n new Main().solve();\n }\n\n void solve() {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n for (int i = 5; N > 0; i++) {\n if (i % 5 == 1) {\n System.out.print(i + \" \");\n N--;\n }\n }\n }\n}", "problem_context": "Score: 400 points\n\nProblem Statement\n\nPrint a sequence a_1, a_2, ..., a_N whose length is N that satisfies the following conditions:\n\na_i (1 \\leq i \\leq N) is a prime number at most 55 555.\n\nThe values of a_1, a_2, ..., a_N are all different.\n\nIn every choice of five different integers from a_1, a_2, ..., a_N, the sum of those integers is a composite number.\n\nIf there are multiple such sequences, printing any of them is accepted.\n\nNotes\n\nAn integer N not less than 2 is called a prime number if it cannot be divided evenly by any integers except 1 and N, and called a composite number otherwise.\n\nConstraints\n\nN is an integer between 5 and 55 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N numbers a_1, a_2, a_3, ..., a_N in a line, with spaces in between.\n\nSample Input 1\n\n5\n\nSample Output 1\n\n3 5 7 11 31\n\nLet us see if this output actually satisfies the conditions.\n\nFirst, 3, 5, 7, 11 and 31 are all different, and all of them are prime numbers.\n\nThe only way to choose five among them is to choose all of them, whose sum is a_1+a_2+a_3+a_4+a_5=57, which is a composite number.\n\nThere are also other possible outputs, such as 2 3 5 7 13, 11 13 17 19 31 and 7 11 5 31 3.\n\nSample Input 2\n\n6\n\nSample Output 2\n\n2 3 5 7 11 13\n\n2, 3, 5, 7, 11, 13 are all different prime numbers.\n\n2+3+5+7+11=28 is a composite number.\n\n2+3+5+7+13=30 is a composite number.\n\n2+3+5+11+13=34 is a composite number.\n\n2+3+7+11+13=36 is a composite number.\n\n2+5+7+11+13=38 is a composite number.\n\n3+5+7+11+13=39 is a composite number.\n\nThus, the sequence 2 3 5 7 11 13 satisfies the conditions.\n\nSample Input 3\n\n8\n\nSample Output 3\n\n2 5 7 13 19 37 67 79", "sample_input": "5\n"}, "reference_outputs": ["3 5 7 11 31\n"], "source_document_id": "p03362", "source_text": "Score: 400 points\n\nProblem Statement\n\nPrint a sequence a_1, a_2, ..., a_N whose length is N that satisfies the following conditions:\n\na_i (1 \\leq i \\leq N) is a prime number at most 55 555.\n\nThe values of a_1, a_2, ..., a_N are all different.\n\nIn every choice of five different integers from a_1, a_2, ..., a_N, the sum of those integers is a composite number.\n\nIf there are multiple such sequences, printing any of them is accepted.\n\nNotes\n\nAn integer N not less than 2 is called a prime number if it cannot be divided evenly by any integers except 1 and N, and called a composite number otherwise.\n\nConstraints\n\nN is an integer between 5 and 55 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N numbers a_1, a_2, a_3, ..., a_N in a line, with spaces in between.\n\nSample Input 1\n\n5\n\nSample Output 1\n\n3 5 7 11 31\n\nLet us see if this output actually satisfies the conditions.\n\nFirst, 3, 5, 7, 11 and 31 are all different, and all of them are prime numbers.\n\nThe only way to choose five among them is to choose all of them, whose sum is a_1+a_2+a_3+a_4+a_5=57, which is a composite number.\n\nThere are also other possible outputs, such as 2 3 5 7 13, 11 13 17 19 31 and 7 11 5 31 3.\n\nSample Input 2\n\n6\n\nSample Output 2\n\n2 3 5 7 11 13\n\n2, 3, 5, 7, 11, 13 are all different prime numbers.\n\n2+3+5+7+11=28 is a composite number.\n\n2+3+5+7+13=30 is a composite number.\n\n2+3+5+11+13=34 is a composite number.\n\n2+3+7+11+13=36 is a composite number.\n\n2+5+7+11+13=38 is a composite number.\n\n3+5+7+11+13=39 is a composite number.\n\nThus, the sequence 2 3 5 7 11 13 satisfies the conditions.\n\nSample Input 3\n\n8\n\nSample Output 3\n\n2 5 7 13 19 37 67 79", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 410, "cpu_time_ms": 99, "memory_kb": 20820}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s188022611", "group_id": "codeNet:p03363", "input_text": "import java.util.*;\npublic class Main {\n public static void main(String[]$) {\n Scanner sc = new Scanner(System.in);\n int n=Integer.parseInt(sc.next());\n long[] a=new long[n+1];\n a[0]=0;\n HashMap m=new HashMap<>();\n m.put(a[0],0);\n for (int i = 1; i m=new HashMap<>();\n m.put(a[0],0);\n for (int i = 1; i 0; x >>= 1) {\n if (x % 2 == 1) res = MULT(res, a);\n a = MULT(a, a);\n }\n\n return res;\n }\n\n long DIV(long a, long b) {\n return MULT(a, POW(b, MOD - 2));\n }\n /* end */\n\n public void solve() {\n int a = in.nextInt(), b = in.nextInt(), c = in.nextInt(), x = in.nextInt(), y = in.nextInt();\n if (a + b <= 2 * c) {\n System.out.println(a * x + b * y);\n return;\n }\n int res = 0;\n int z = Math.min(x, y);\n res += 2 * c * z;\n x -= z; y -= z;\n res += (a <= 2 * c) ? a * x : 2 * c * x;\n res += (b <= 2 * c) ? b * y : 2 * c * y;\n System.out.println(res);\n }\n\n public static void main(final String[] args) {\n new Main().solve();\n }\n\n class FastScanner {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n\n public FastScanner(InputStream stream) {\n this.stream = stream;\n // stream = new FileInputStream(new File(\"dec.in\"));\n\n }\n\n int read() {\n if (numChars == -1)\n throw new InputMismatchException();\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }\n\n boolean isSpaceChar(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n boolean isEndline(int c) {\n return c == '\\n' || c == '\\r' || c == -1;\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n int[] nextIntArray(int n) {\n int[] array = new int[n];\n for (int i = 0; i < n; i++)\n array[i] = nextInt();\n\n return array;\n }\n\n int[][] nextIntMap(int n, int m) {\n int[][] map = new int[n][m];\n for (int i = 0; i < n; i++) {\n map[i] = in.nextIntArray(m);\n }\n return map;\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n long[] nextLongArray(int n) {\n long[] array = new long[n];\n for (int i = 0; i < n; i++)\n array[i] = nextLong();\n\n return array;\n }\n\n long[][] nextLongMap(int n, int m) {\n long[][] map = new long[n][m];\n for (int i = 0; i < n; i++) {\n map[i] = in.nextLongArray(m);\n }\n return map;\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n double[] nextDoubleArray(int n) {\n double[] array = new double[n];\n for (int i = 0; i < n; i++)\n array[i] = nextDouble();\n\n return array;\n }\n\n double[][] nextDoubleMap(int n, int m) {\n double[][] map = new double[n][m];\n for (int i = 0; i < n; i++) {\n map[i] = in.nextDoubleArray(m);\n }\n return map;\n }\n\n String next() {\n int c = read();\n while (isSpaceChar(c))\n c = read();\n StringBuilder res = new StringBuilder();\n do {\n res.appendCodePoint(c);\n c = read();\n } while (!isSpaceChar(c));\n return res.toString();\n }\n\n String[] nextStringArray(int n) {\n String[] array = new String[n];\n for (int i = 0; i < n; i++)\n array[i] = next();\n\n return array;\n }\n\n String nextLine() {\n int c = read();\n while (isEndline(c))\n c = read();\n StringBuilder res = new StringBuilder();\n do {\n res.appendCodePoint(c);\n c = read();\n } while (!isEndline(c));\n return res.toString();\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1525239544, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03373.html", "problem_id": "p03373", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03373/input.txt", "sample_output_relpath": "derived/input_output/data/p03373/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03373/Java/s909308113.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s909308113", "user_id": "u617255029"}, "prompt_components": {"gold_output": "7900\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.Arrays;\nimport java.util.InputMismatchException;\n\npublic class Main {\n final FastScanner in = new FastScanner(System.in);\n\n final long MOD = (long)((1e9) + 7);\n\n /* MOD_CALCULATION */\n long ADD(long a, long b) {\n return (a + b) % MOD;\n }\n\n long SUB(long a, long b) {\n return (a - b + MOD) % MOD;\n }\n\n long MULT(long a, long b) {\n return (a * b) % MOD;\n }\n\n long POW(long a, long x) {\n long res = 1;\n for ( ; x > 0; x >>= 1) {\n if (x % 2 == 1) res = MULT(res, a);\n a = MULT(a, a);\n }\n\n return res;\n }\n\n long DIV(long a, long b) {\n return MULT(a, POW(b, MOD - 2));\n }\n /* end */\n\n public void solve() {\n int a = in.nextInt(), b = in.nextInt(), c = in.nextInt(), x = in.nextInt(), y = in.nextInt();\n if (a + b <= 2 * c) {\n System.out.println(a * x + b * y);\n return;\n }\n int res = 0;\n int z = Math.min(x, y);\n res += 2 * c * z;\n x -= z; y -= z;\n res += (a <= 2 * c) ? a * x : 2 * c * x;\n res += (b <= 2 * c) ? b * y : 2 * c * y;\n System.out.println(res);\n }\n\n public static void main(final String[] args) {\n new Main().solve();\n }\n\n class FastScanner {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n\n public FastScanner(InputStream stream) {\n this.stream = stream;\n // stream = new FileInputStream(new File(\"dec.in\"));\n\n }\n\n int read() {\n if (numChars == -1)\n throw new InputMismatchException();\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }\n\n boolean isSpaceChar(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n boolean isEndline(int c) {\n return c == '\\n' || c == '\\r' || c == -1;\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n int[] nextIntArray(int n) {\n int[] array = new int[n];\n for (int i = 0; i < n; i++)\n array[i] = nextInt();\n\n return array;\n }\n\n int[][] nextIntMap(int n, int m) {\n int[][] map = new int[n][m];\n for (int i = 0; i < n; i++) {\n map[i] = in.nextIntArray(m);\n }\n return map;\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n long[] nextLongArray(int n) {\n long[] array = new long[n];\n for (int i = 0; i < n; i++)\n array[i] = nextLong();\n\n return array;\n }\n\n long[][] nextLongMap(int n, int m) {\n long[][] map = new long[n][m];\n for (int i = 0; i < n; i++) {\n map[i] = in.nextLongArray(m);\n }\n return map;\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n double[] nextDoubleArray(int n) {\n double[] array = new double[n];\n for (int i = 0; i < n; i++)\n array[i] = nextDouble();\n\n return array;\n }\n\n double[][] nextDoubleMap(int n, int m) {\n double[][] map = new double[n][m];\n for (int i = 0; i < n; i++) {\n map[i] = in.nextDoubleArray(m);\n }\n return map;\n }\n\n String next() {\n int c = read();\n while (isSpaceChar(c))\n c = read();\n StringBuilder res = new StringBuilder();\n do {\n res.appendCodePoint(c);\n c = read();\n } while (!isSpaceChar(c));\n return res.toString();\n }\n\n String[] nextStringArray(int n) {\n String[] array = new String[n];\n for (int i = 0; i < n; i++)\n array[i] = next();\n\n return array;\n }\n\n String nextLine() {\n int c = read();\n while (isEndline(c))\n c = read();\n StringBuilder res = new StringBuilder();\n do {\n res.appendCodePoint(c);\n c = read();\n } while (!isEndline(c));\n return res.toString();\n }\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.\n\nNakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.\n\nConstraints\n\n1 ≤ A, B, C ≤ 5000\n\n1 ≤ X, Y ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C X Y\n\nOutput\n\nPrint the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.\n\nSample Input 1\n\n1500 2000 1600 3 2\n\nSample Output 1\n\n7900\n\nIt is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.\n\nSample Input 2\n\n1500 2000 1900 3 2\n\nSample Output 2\n\n8500\n\nIt is optimal to directly buy three A-pizzas and two B-pizzas.\n\nSample Input 3\n\n1500 2000 500 90000 100000\n\nSample Output 3\n\n100000000\n\nIt is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.", "sample_input": "1500 2000 1600 3 2\n"}, "reference_outputs": ["7900\n"], "source_document_id": "p03373", "source_text": "Score : 300 points\n\nProblem Statement\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.\n\nNakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.\n\nConstraints\n\n1 ≤ A, B, C ≤ 5000\n\n1 ≤ X, Y ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C X Y\n\nOutput\n\nPrint the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.\n\nSample Input 1\n\n1500 2000 1600 3 2\n\nSample Output 1\n\n7900\n\nIt is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.\n\nSample Input 2\n\n1500 2000 1900 3 2\n\nSample Output 2\n\n8500\n\nIt is optimal to directly buy three A-pizzas and two B-pizzas.\n\nSample Input 3\n\n1500 2000 500 90000 100000\n\nSample Output 3\n\n100000000\n\nIt is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4771, "cpu_time_ms": 70, "memory_kb": 23124}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s208632310", "group_id": "codeNet:p03377", "input_text": "import java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n int x = sc.nextInt();\n\n int y = x-a;\n\n if (y < 0) {\n System.out.println(\"No\");\n } else {\n if (b >= y) {\n System.out.println(\"Yes\");\n } else {\n System.out.println(\"No\");\n }\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1572383333, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03377.html", "problem_id": "p03377", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03377/input.txt", "sample_output_relpath": "derived/input_output/data/p03377/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03377/Java/s208632310.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s208632310", "user_id": "u387775763"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n int x = sc.nextInt();\n\n int y = x-a;\n\n if (y < 0) {\n System.out.println(\"No\");\n } else {\n if (b >= y) {\n System.out.println(\"Yes\");\n } else {\n System.out.println(\"No\");\n }\n }\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are a total of A + B cats and dogs.\nAmong them, A are known to be cats, but the remaining B are not known to be either cats or dogs.\n\nDetermine if it is possible that there are exactly X cats among these A + B animals.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\n1 \\leq X \\leq 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B X\n\nOutput\n\nIf it is possible that there are exactly X cats, print YES; if it is impossible, print NO.\n\nSample Input 1\n\n3 5 4\n\nSample Output 1\n\nYES\n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4 cats in total.\n\nSample Input 2\n\n2 2 6\n\nSample Output 2\n\nNO\n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in total.\n\nSample Input 3\n\n5 3 2\n\nSample Output 3\n\nNO\n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in total.", "sample_input": "3 5 4\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03377", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are a total of A + B cats and dogs.\nAmong them, A are known to be cats, but the remaining B are not known to be either cats or dogs.\n\nDetermine if it is possible that there are exactly X cats among these A + B animals.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\n1 \\leq X \\leq 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B X\n\nOutput\n\nIf it is possible that there are exactly X cats, print YES; if it is impossible, print NO.\n\nSample Input 1\n\n3 5 4\n\nSample Output 1\n\nYES\n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4 cats in total.\n\nSample Input 2\n\n2 2 6\n\nSample Output 2\n\nNO\n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in total.\n\nSample Input 3\n\n5 3 2\n\nSample Output 3\n\nNO\n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in total.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 97, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s347346483", "group_id": "codeNet:p03377", "input_text": "import java.util.Scanner;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\tScanner sc=new Scanner(System.in);\n\t\tint a=sc.nextInt();\n\t\tint b=sc.nextInt();\n\t\tint x=sc.nextInt();\n\t\tif(0 Integer.MAX_VALUE)\n throw new NumberFormatException();\n return (int) nl;\n }\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n}\n", "language": "Java", "metadata": {"date": 1537190556, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03378.html", "problem_id": "p03378", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03378/input.txt", "sample_output_relpath": "derived/input_output/data/p03378/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03378/Java/s540998285.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s540998285", "user_id": "u796942881"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.io.IOException;\nimport java.util.NoSuchElementException;\n\nimport java.io.BufferedReader;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\n\nimport java.util.Arrays;\n\npublic class Main {\n public static void main(String[] args) throws IOException {\n try (\n BufferedReader reader = new BufferedReader(\n new InputStreamReader(System.in))) {\n FastScanner fs = new FastScanner();\n\n final int N = fs.nextInt();\n final int M = fs.nextInt();\n final int X = fs.nextInt();\n\n int[] A = new int[N];\n\n Arrays.fill(A, 0);\n\n for (int i = 0; i < M; i++) {\n int m = fs.nextInt();\n A[m - 1] += 1;\n }\n\n for (int i = 0; i < N - 1; i++) A[i + 1] += A[i];\n\n System.out.println(Math.min(A[X - 1], A[N - 1] - A[X - 1]));\n }\n }\n}\n\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n private int readByte() {\n if (hasNextByte()) return buffer[ptr++];\n else return -1;\n }\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n public boolean hasNext() {\n while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n return hasNextByte();\n }\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while(isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while(true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if(b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)\n throw new NumberFormatException();\n return (int) nl;\n }\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right.\n\nInitially, you are in Square X.\nYou can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N.\nHowever, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1.\nIt is guaranteed that there is no toll gate in Square 0, Square X and Square N.\n\nFind the minimum cost incurred before reaching the goal.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq M \\leq 100\n\n1 \\leq X \\leq N - 1\n\n1 \\leq A_1 < A_2 < ... < A_M \\leq N\n\nA_i \\neq X\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the minimum cost incurred before reaching the goal.\n\nSample Input 1\n\n5 3 3\n1 2 4\n\nSample Output 1\n\n1\n\nThe optimal solution is as follows:\n\nFirst, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n\nThen, travel from Square 4 to Square 5. This time, no cost is incurred.\n\nNow, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\nSample Input 2\n\n7 3 2\n4 5 6\n\nSample Output 2\n\n0\n\nWe may be able to reach the goal at no cost.\n\nSample Input 3\n\n10 7 5\n1 2 3 4 6 8 9\n\nSample Output 3\n\n3", "sample_input": "5 3 3\n1 2 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03378", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right.\n\nInitially, you are in Square X.\nYou can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N.\nHowever, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1.\nIt is guaranteed that there is no toll gate in Square 0, Square X and Square N.\n\nFind the minimum cost incurred before reaching the goal.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq M \\leq 100\n\n1 \\leq X \\leq N - 1\n\n1 \\leq A_1 < A_2 < ... < A_M \\leq N\n\nA_i \\neq X\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the minimum cost incurred before reaching the goal.\n\nSample Input 1\n\n5 3 3\n1 2 4\n\nSample Output 1\n\n1\n\nThe optimal solution is as follows:\n\nFirst, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n\nThen, travel from Square 4 to Square 5. This time, no cost is incurred.\n\nNow, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\nSample Input 2\n\n7 3 2\n4 5 6\n\nSample Output 2\n\n0\n\nWe may be able to reach the goal at no cost.\n\nSample Input 3\n\n10 7 5\n1 2 3 4 6 8 9\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3088, "cpu_time_ms": 72, "memory_kb": 22612}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s719275489", "group_id": "codeNet:p03380", "input_text": "import java.util.*;\nimport java.util.Map.Entry;\n \nclass Main {\n\t static int mod = (int) (Math.pow(10,9)+7);\n//\t static int mod = 998244353;\n public static void main(String[] args) {\n\t \n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n \n long[] a = new long[(int)N];\n for (int i=0 ; 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": 1091, "cpu_time_ms": 483, "memory_kb": 50496}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s694420116", "group_id": "codeNet:p03385", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tString S = sc.next();\n\t\tString ans = \"\";\n\n\t\tif ( S.contains(\"a\") && S.contains(\"b\") && S.contains(\"c\") ) {\n\t\t\tans = \"Yes\";\n\t\t} else {\n\t\t\tans = \"No\";\n\t\t}\n\n\t\tSystem.out.println( ans );\n\t}\n}", "language": "Java", "metadata": {"date": 1566854972, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03385.html", "problem_id": "p03385", "resource_group": "high_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/Java/s694420116.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s694420116", "user_id": "u202101624"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tString S = sc.next();\n\t\tString ans = \"\";\n\n\t\tif ( S.contains(\"a\") && S.contains(\"b\") && S.contains(\"c\") ) {\n\t\t\tans = \"Yes\";\n\t\t} else {\n\t\t\tans = \"No\";\n\t\t}\n\n\t\tSystem.out.println( ans );\n\t}\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length 3 consisting of a, b and c. Determine if S can be obtained by permuting abc.\n\nConstraints\n\n|S|=3\n\nS consists of a, b and c.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S can be obtained by permuting abc, print Yes; otherwise, print No.\n\nSample Input 1\n\nbac\n\nSample Output 1\n\nYes\n\nSwapping the first and second characters in bac results in abc.\n\nSample Input 2\n\nbab\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nabc\n\nSample Output 3\n\nYes\n\nSample Input 4\n\naaa\n\nSample Output 4\n\nNo", "sample_input": "bac\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03385", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length 3 consisting of a, b and c. Determine if S can be obtained by permuting abc.\n\nConstraints\n\n|S|=3\n\nS consists of a, b and c.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S can be obtained by permuting abc, print Yes; otherwise, print No.\n\nSample Input 1\n\nbac\n\nSample Output 1\n\nYes\n\nSwapping the first and second characters in bac results in abc.\n\nSample Input 2\n\nbab\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nabc\n\nSample Output 3\n\nYes\n\nSample Input 4\n\naaa\n\nSample Output 4\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 90, "memory_kb": 23764}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s796664409", "group_id": "codeNet:p03386", "input_text": "import java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner s = new Scanner(System.in);\n int a = s.nextInt();\n int b = s.nextInt();\n\n if (a == b) {\n System.out.println(a);\n System.exit(0);\n }\n\n int k = s.nextInt();\n boolean f = true;\n Set set = new TreeSet<>();\n\n for (int i = 0; i < k; i++) {\n if (i >= b) {\n f = false;\n break;\n }\n set.add(a + i);\n\n }\n if (f) {\n for (int i = k - 1; i >= 0; i--) {\n if (b - i < 0) {\n break;\n }\n set.add(b - i);\n }\n\n }\n for (Integer integer : set) {\n System.out.println(integer);\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1531511176, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03386.html", "problem_id": "p03386", "resource_group": "high_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/Java/s796664409.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s796664409", "user_id": "u534918612"}, "prompt_components": {"gold_output": "3\n4\n7\n8\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner s = new Scanner(System.in);\n int a = s.nextInt();\n int b = s.nextInt();\n\n if (a == b) {\n System.out.println(a);\n System.exit(0);\n }\n\n int k = s.nextInt();\n boolean f = true;\n Set set = new TreeSet<>();\n\n for (int i = 0; i < k; i++) {\n if (i >= b) {\n f = false;\n break;\n }\n set.add(a + i);\n\n }\n if (f) {\n for (int i = k - 1; i >= 0; i--) {\n if (b - i < 0) {\n break;\n }\n set.add(b - i);\n }\n\n }\n for (Integer integer : set) {\n System.out.println(integer);\n }\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": 849, "cpu_time_ms": 121, "memory_kb": 21972}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s748724958", "group_id": "codeNet:p03387", "input_text": "import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.IOException;\nimport java.util.Arrays;\n\npublic class Main {\n public static void main(String[] args) throws IOException {\n BufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n String[] str = in.readLine().split(\" \");\n int a = Integer.parseInt(str[0]);\n int b = Integer.parseInt(str[1]);\n int c = Integer.parseInt(str[2]);\n int sum = a+b+c;\n int max = Math.max(Math.max(a,b),c);\n int min = Math.min(Math.min(a,b),c);\n int middle = sum-max-min;\n int count = 0;\n if((3*max)%2 != sum%2) {\n max++;\n count++;\n }\n count+=(3*max-sum)/2;\n \n System.out.println(count);\n }\n}", "language": "Java", "metadata": {"date": 1597526794, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p03387.html", "problem_id": "p03387", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03387/input.txt", "sample_output_relpath": "derived/input_output/data/p03387/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03387/Java/s748724958.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s748724958", "user_id": "u572345088"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.IOException;\nimport java.util.Arrays;\n\npublic class Main {\n public static void main(String[] args) throws IOException {\n BufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n String[] str = in.readLine().split(\" \");\n int a = Integer.parseInt(str[0]);\n int b = Integer.parseInt(str[1]);\n int c = Integer.parseInt(str[2]);\n int sum = a+b+c;\n int max = Math.max(Math.max(a,b),c);\n int min = Math.min(Math.min(a,b),c);\n int middle = sum-max-min;\n int count = 0;\n if((3*max)%2 != sum%2) {\n max++;\n count++;\n }\n count+=(3*max-sum)/2;\n \n System.out.println(count);\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:\n\nChoose two among A, B and C, then increase both by 1.\n\nChoose one among A, B and C, then increase it by 2.\n\nIt can be proved that we can always make A, B and C all equal by repeatedly performing these operations.\n\nConstraints\n\n0 \\leq A,B,C \\leq 50\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the minimum number of operations required to make A, B and C all equal.\n\nSample Input 1\n\n2 5 4\n\nSample Output 1\n\n2\n\nWe can make A, B and C all equal by the following operations:\n\nIncrease A and C by 1. Now, A, B, C are 3, 5, 5, respectively.\n\nIncrease A by 2. Now, A, B, C are 5, 5, 5, respectively.\n\nSample Input 2\n\n2 6 3\n\nSample Output 2\n\n5\n\nSample Input 3\n\n31 41 5\n\nSample Output 3\n\n23", "sample_input": "2 5 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03387", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:\n\nChoose two among A, B and C, then increase both by 1.\n\nChoose one among A, B and C, then increase it by 2.\n\nIt can be proved that we can always make A, B and C all equal by repeatedly performing these operations.\n\nConstraints\n\n0 \\leq A,B,C \\leq 50\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the minimum number of operations required to make A, B and C all equal.\n\nSample Input 1\n\n2 5 4\n\nSample Output 1\n\n2\n\nWe can make A, B and C all equal by the following operations:\n\nIncrease A and C by 1. Now, A, B, C are 3, 5, 5, respectively.\n\nIncrease A by 2. Now, A, B, C are 5, 5, 5, respectively.\n\nSample Input 2\n\n2 6 3\n\nSample Output 2\n\n5\n\nSample Input 3\n\n31 41 5\n\nSample Output 3\n\n23", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 83, "memory_kb": 32616}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s713941429", "group_id": "codeNet:p03387", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.stream.IntStream;\nimport java.io.UncheckedIOException;\nimport java.util.Arrays;\nimport java.util.StringTokenizer;\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author mikit\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n LightScanner in = new LightScanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n CSameIntegers solver = new CSameIntegers();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class CSameIntegers {\n public void solve(int testNumber, LightScanner in, PrintWriter out) {\n int[] n = in.ints(3);\n Arrays.sort(n);\n int x = (n[1] - n[0] + 1) / 2;\n n[0] += x * 2;\n int y = n[2] - n[0];\n n[0] += y;\n n[1] += y;\n out.println(x + y + (n[1] == n[2] ? 0 : 2));\n }\n\n }\n\n static class LightScanner {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n\n public LightScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n }\n\n public String string() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new UncheckedIOException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int ints() {\n return Integer.parseInt(string());\n }\n\n public int[] ints(int length) {\n return IntStream.range(0, length).map(x -> ints()).toArray();\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1538111737, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03387.html", "problem_id": "p03387", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03387/input.txt", "sample_output_relpath": "derived/input_output/data/p03387/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03387/Java/s713941429.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s713941429", "user_id": "u183509493"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.stream.IntStream;\nimport java.io.UncheckedIOException;\nimport java.util.Arrays;\nimport java.util.StringTokenizer;\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author mikit\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n LightScanner in = new LightScanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n CSameIntegers solver = new CSameIntegers();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class CSameIntegers {\n public void solve(int testNumber, LightScanner in, PrintWriter out) {\n int[] n = in.ints(3);\n Arrays.sort(n);\n int x = (n[1] - n[0] + 1) / 2;\n n[0] += x * 2;\n int y = n[2] - n[0];\n n[0] += y;\n n[1] += y;\n out.println(x + y + (n[1] == n[2] ? 0 : 2));\n }\n\n }\n\n static class LightScanner {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n\n public LightScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n }\n\n public String string() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new UncheckedIOException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int ints() {\n return Integer.parseInt(string());\n }\n\n public int[] ints(int length) {\n return IntStream.range(0, length).map(x -> ints()).toArray();\n }\n\n }\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:\n\nChoose two among A, B and C, then increase both by 1.\n\nChoose one among A, B and C, then increase it by 2.\n\nIt can be proved that we can always make A, B and C all equal by repeatedly performing these operations.\n\nConstraints\n\n0 \\leq A,B,C \\leq 50\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the minimum number of operations required to make A, B and C all equal.\n\nSample Input 1\n\n2 5 4\n\nSample Output 1\n\n2\n\nWe can make A, B and C all equal by the following operations:\n\nIncrease A and C by 1. Now, A, B, C are 3, 5, 5, respectively.\n\nIncrease A by 2. Now, A, B, C are 5, 5, 5, respectively.\n\nSample Input 2\n\n2 6 3\n\nSample Output 2\n\n5\n\nSample Input 3\n\n31 41 5\n\nSample Output 3\n\n23", "sample_input": "2 5 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03387", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:\n\nChoose two among A, B and C, then increase both by 1.\n\nChoose one among A, B and C, then increase it by 2.\n\nIt can be proved that we can always make A, B and C all equal by repeatedly performing these operations.\n\nConstraints\n\n0 \\leq A,B,C \\leq 50\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the minimum number of operations required to make A, B and C all equal.\n\nSample Input 1\n\n2 5 4\n\nSample Output 1\n\n2\n\nWe can make A, B and C all equal by the following operations:\n\nIncrease A and C by 1. Now, A, B, C are 3, 5, 5, respectively.\n\nIncrease A by 2. Now, A, B, C are 5, 5, 5, respectively.\n\nSample Input 2\n\n2 6 3\n\nSample Output 2\n\n5\n\nSample Input 3\n\n31 41 5\n\nSample Output 3\n\n23", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2091, "cpu_time_ms": 160, "memory_kb": 27220}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s986593923", "group_id": "codeNet:p03390", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.io.IOException;\nimport java.util.NoSuchElementException;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n FasterScanner in = new FasterScanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskD solver = new TaskD();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class TaskD {\n public void solve(int testNumber, FasterScanner in, PrintWriter out) {\n final int n = in.nextInt();\n for (int i = 0; i < n; i++) {\n long a = in.nextInt();\n long b = in.nextInt();\n long score = a * b;\n if (a == 1 && b == 1) {\n out.println(0);\n } else if (a == 1 || b == 1) {\n long ans = (Math.max(a, b) / 2) - 1;\n out.println(ans);\n } else {\n long ans = (long) ((Math.sqrt(score) - 1) * 2);\n out.println(ans);\n }\n }\n }\n\n }\n\n static class FasterScanner {\n private InputStream in;\n private byte[] buffer;\n private int bufPointer;\n private int bufLength;\n\n public FasterScanner(InputStream in) {\n this.in = in;\n buffer = new byte[1024];\n }\n\n private boolean hasNextByte() {\n if (bufPointer < bufLength) return true;\n bufPointer = 0;\n try {\n bufLength = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n return (bufLength > 0);\n }\n\n private int readByte() {\n if (hasNextByte()) return buffer[bufPointer++];\n return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return (c >= 33 && c <= 126);\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;\n return hasNextByte();\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || b > '9') throw new NumberFormatException();\n\n while (true) {\n if (b >= '0' && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1523152945, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03390.html", "problem_id": "p03390", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03390/input.txt", "sample_output_relpath": "derived/input_output/data/p03390/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03390/Java/s986593923.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s986593923", "user_id": "u510349606"}, "prompt_components": {"gold_output": "1\n12\n4\n11\n14\n57\n31\n671644785\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.io.IOException;\nimport java.util.NoSuchElementException;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n FasterScanner in = new FasterScanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskD solver = new TaskD();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class TaskD {\n public void solve(int testNumber, FasterScanner in, PrintWriter out) {\n final int n = in.nextInt();\n for (int i = 0; i < n; i++) {\n long a = in.nextInt();\n long b = in.nextInt();\n long score = a * b;\n if (a == 1 && b == 1) {\n out.println(0);\n } else if (a == 1 || b == 1) {\n long ans = (Math.max(a, b) / 2) - 1;\n out.println(ans);\n } else {\n long ans = (long) ((Math.sqrt(score) - 1) * 2);\n out.println(ans);\n }\n }\n }\n\n }\n\n static class FasterScanner {\n private InputStream in;\n private byte[] buffer;\n private int bufPointer;\n private int bufLength;\n\n public FasterScanner(InputStream in) {\n this.in = in;\n buffer = new byte[1024];\n }\n\n private boolean hasNextByte() {\n if (bufPointer < bufLength) return true;\n bufPointer = 0;\n try {\n bufLength = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n return (bufLength > 0);\n }\n\n private int readByte() {\n if (hasNextByte()) return buffer[bufPointer++];\n return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return (c >= 33 && c <= 126);\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;\n return hasNextByte();\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || b > '9') throw new NumberFormatException();\n\n while (true) {\n if (b >= '0' && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n }\n}\n\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\n10^{10^{10}} participants, including Takahashi, competed in two programming contests.\nIn each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.\n\nThe score of a participant is the product of his/her ranks in the two contests.\n\nProcess the following Q queries:\n\nIn the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.\n\nConstraints\n\n1 \\leq Q \\leq 100\n\n1\\leq A_i,B_i\\leq 10^9(1\\leq i\\leq Q)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nA_1 B_1\n:\nA_Q B_Q\n\nOutput\n\nFor each query, print the maximum possible number of participants whose scores are smaller than Takahashi's.\n\nSample Input 1\n\n8\n1 4\n10 5\n3 3\n4 11\n8 9\n22 40\n8 36\n314159265 358979323\n\nSample Output 1\n\n1\n12\n4\n11\n14\n57\n31\n671644785\n\nLet us denote a participant who was ranked x-th in the first contest and y-th in the second contest as (x,y).\n\nIn the first query, (2,1) is a possible candidate of a participant whose score is smaller than Takahashi's. There are never two or more participants whose scores are smaller than Takahashi's, so we should print 1.", "sample_input": "8\n1 4\n10 5\n3 3\n4 11\n8 9\n22 40\n8 36\n314159265 358979323\n"}, "reference_outputs": ["1\n12\n4\n11\n14\n57\n31\n671644785\n"], "source_document_id": "p03390", "source_text": "Score : 700 points\n\nProblem Statement\n\n10^{10^{10}} participants, including Takahashi, competed in two programming contests.\nIn each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.\n\nThe score of a participant is the product of his/her ranks in the two contests.\n\nProcess the following Q queries:\n\nIn the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.\n\nConstraints\n\n1 \\leq Q \\leq 100\n\n1\\leq A_i,B_i\\leq 10^9(1\\leq i\\leq Q)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nA_1 B_1\n:\nA_Q B_Q\n\nOutput\n\nFor each query, print the maximum possible number of participants whose scores are smaller than Takahashi's.\n\nSample Input 1\n\n8\n1 4\n10 5\n3 3\n4 11\n8 9\n22 40\n8 36\n314159265 358979323\n\nSample Output 1\n\n1\n12\n4\n11\n14\n57\n31\n671644785\n\nLet us denote a participant who was ranked x-th in the first contest and y-th in the second contest as (x,y).\n\nIn the first query, (2,1) is a possible candidate of a participant whose score is smaller than Takahashi's. There are never two or more participants whose scores are smaller than Takahashi's, so we should print 1.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3331, "cpu_time_ms": 72, "memory_kb": 21460}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s257387778", "group_id": "codeNet:p03393", "input_text": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.*;\n\n\npublic class Main {\n\n char[] ch;\n\n private void solve() {\n ch = next().toCharArray();\n\n if (ch.length < 26) {\n\n int[] cnt = new int[26];\n for(char c : ch) {\n cnt[c-'a']++;\n }\n\n int index = -1;\n for (int i = 0; i < 26; i++) {\n if (cnt[i] == 0) {\n index = i;\n break;\n }\n }\n\n StringBuilder sb = new StringBuilder();\n sb.append(ch);\n sb.append((char) ('a' + index));\n out.println(sb);\n return;\n } else {\n\n int[][] cnt = new int[ch.length + 1][26];\n for (int i = 0; i < ch.length; i++) {\n for (int j = 0; j < 26; j++) {\n cnt[i + 1][j] += cnt[i][j];\n }\n cnt[i + 1][ch[i] - 'a']++;\n }\n\n for (int i = ch.length - 1; i >= 0; i--) {\n int c = ch[i] - 'a';\n int index = -1;\n for (int j = 25; j > c; j--) {\n if (cnt[i][j] == 0) {\n index = j;\n }\n }\n\n if (index != -1) {\n ch[i] = (char) ('a' + index);\n out.println(String.valueOf(ch, 0, i + 1));\n return;\n }\n }\n }\n out.println(-1);\n }\n public static void main(String[] args) {\n out.flush();\n new Main().solve();\n out.close();\n }\n\n /* Input */\n private static final InputStream in = System.in;\n private static final PrintWriter out = new PrintWriter(System.out);\n private final byte[] buffer = new byte[4096];\n private int p = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (p < buflen)\n return true;\n p = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0)\n return false;\n return true;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrint(buffer[p])) {\n p++;\n }\n return hasNextByte();\n }\n\n private boolean isPrint(int ch) {\n if (ch >= '!' && ch <= '~')\n return true;\n return false;\n }\n\n private int nextByte() {\n if (!hasNextByte())\n return -1;\n return buffer[p++];\n }\n\n public String next() {\n if (!hasNext())\n throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = -1;\n while (isPrint((b = nextByte()))) {\n sb.appendCodePoint(b);\n }\n return sb.toString();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n}\n", "language": "Java", "metadata": {"date": 1525364280, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03393.html", "problem_id": "p03393", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03393/input.txt", "sample_output_relpath": "derived/input_output/data/p03393/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03393/Java/s257387778.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s257387778", "user_id": "u516438812"}, "prompt_components": {"gold_output": "atcoderb\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.*;\n\n\npublic class Main {\n\n char[] ch;\n\n private void solve() {\n ch = next().toCharArray();\n\n if (ch.length < 26) {\n\n int[] cnt = new int[26];\n for(char c : ch) {\n cnt[c-'a']++;\n }\n\n int index = -1;\n for (int i = 0; i < 26; i++) {\n if (cnt[i] == 0) {\n index = i;\n break;\n }\n }\n\n StringBuilder sb = new StringBuilder();\n sb.append(ch);\n sb.append((char) ('a' + index));\n out.println(sb);\n return;\n } else {\n\n int[][] cnt = new int[ch.length + 1][26];\n for (int i = 0; i < ch.length; i++) {\n for (int j = 0; j < 26; j++) {\n cnt[i + 1][j] += cnt[i][j];\n }\n cnt[i + 1][ch[i] - 'a']++;\n }\n\n for (int i = ch.length - 1; i >= 0; i--) {\n int c = ch[i] - 'a';\n int index = -1;\n for (int j = 25; j > c; j--) {\n if (cnt[i][j] == 0) {\n index = j;\n }\n }\n\n if (index != -1) {\n ch[i] = (char) ('a' + index);\n out.println(String.valueOf(ch, 0, i + 1));\n return;\n }\n }\n }\n out.println(-1);\n }\n public static void main(String[] args) {\n out.flush();\n new Main().solve();\n out.close();\n }\n\n /* Input */\n private static final InputStream in = System.in;\n private static final PrintWriter out = new PrintWriter(System.out);\n private final byte[] buffer = new byte[4096];\n private int p = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (p < buflen)\n return true;\n p = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0)\n return false;\n return true;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrint(buffer[p])) {\n p++;\n }\n return hasNextByte();\n }\n\n private boolean isPrint(int ch) {\n if (ch >= '!' && ch <= '~')\n return true;\n return false;\n }\n\n private int nextByte() {\n if (!hasNextByte())\n return -1;\n return buffer[p++];\n }\n\n public String next() {\n if (!hasNext())\n throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = -1;\n while (isPrint((b = nextByte()))) {\n sb.appendCodePoint(b);\n }\n return sb.toString();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGotou just received a dictionary. However, he doesn't recognize the language used in the dictionary. He did some analysis on the dictionary and realizes that the dictionary contains all possible diverse words in lexicographical order.\n\nA word is called diverse if and only if it is a nonempty string of English lowercase letters and all letters in the word are distinct. For example, atcoder, zscoder and agc are diverse words while gotou and connect aren't diverse words.\n\nGiven a diverse word S, determine the next word that appears after S in the dictionary, i.e. the lexicographically smallest diverse word that is lexicographically larger than S, or determine that it doesn't exist.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 \\leq |S| \\leq 26\n\nS is a diverse word.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the next word that appears after S in the dictionary, or -1 if it doesn't exist.\n\nSample Input 1\n\natcoder\n\nSample Output 1\n\natcoderb\n\natcoderb is the lexicographically smallest diverse word that is lexicographically larger than atcoder. Note that atcoderb is lexicographically smaller than b.\n\nSample Input 2\n\nabc\n\nSample Output 2\n\nabcd\n\nSample Input 3\n\nzyxwvutsrqponmlkjihgfedcba\n\nSample Output 3\n\n-1\n\nThis is the lexicographically largest diverse word, so the answer is -1.\n\nSample Input 4\n\nabcdefghijklmnopqrstuvwzyx\n\nSample Output 4\n\nabcdefghijklmnopqrstuvx", "sample_input": "atcoder\n"}, "reference_outputs": ["atcoderb\n"], "source_document_id": "p03393", "source_text": "Score : 300 points\n\nProblem Statement\n\nGotou just received a dictionary. However, he doesn't recognize the language used in the dictionary. He did some analysis on the dictionary and realizes that the dictionary contains all possible diverse words in lexicographical order.\n\nA word is called diverse if and only if it is a nonempty string of English lowercase letters and all letters in the word are distinct. For example, atcoder, zscoder and agc are diverse words while gotou and connect aren't diverse words.\n\nGiven a diverse word S, determine the next word that appears after S in the dictionary, i.e. the lexicographically smallest diverse word that is lexicographically larger than S, or determine that it doesn't exist.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 \\leq |S| \\leq 26\n\nS is a diverse word.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the next word that appears after S in the dictionary, or -1 if it doesn't exist.\n\nSample Input 1\n\natcoder\n\nSample Output 1\n\natcoderb\n\natcoderb is the lexicographically smallest diverse word that is lexicographically larger than atcoder. Note that atcoderb is lexicographically smaller than b.\n\nSample Input 2\n\nabc\n\nSample Output 2\n\nabcd\n\nSample Input 3\n\nzyxwvutsrqponmlkjihgfedcba\n\nSample Output 3\n\n-1\n\nThis is the lexicographically largest diverse word, so the answer is -1.\n\nSample Input 4\n\nabcdefghijklmnopqrstuvwzyx\n\nSample Output 4\n\nabcdefghijklmnopqrstuvx", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3144, "cpu_time_ms": 69, "memory_kb": 22484}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s427571314", "group_id": "codeNet:p03399", "input_text": "import java.util.Scanner;\n\nclass Main {\n public static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n \tint A = sc.nextInt();\n \tint B = sc.nextInt();\n \tint C = sc.nextInt();\n \tint D = sc.nextInt();\n \tint total = 0;\n\n \tif(A<=B){\n \t\ttotal += A;\n \t}else{\n \t\ttotal+=B;\n \t}\n \tif(C<=D){\n \t\ttotal +=C;\n \t}else{\n \t\ttotal +=D;\n \t}\n\n\n\n \tSystem.out.println(total);\n\n}\n\n}", "language": "Java", "metadata": {"date": 1558029843, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03399.html", "problem_id": "p03399", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03399/input.txt", "sample_output_relpath": "derived/input_output/data/p03399/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03399/Java/s427571314.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s427571314", "user_id": "u223718904"}, "prompt_components": {"gold_output": "520\n", "input_to_evaluate": "import java.util.Scanner;\n\nclass Main {\n public static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n \tint A = sc.nextInt();\n \tint B = sc.nextInt();\n \tint C = sc.nextInt();\n \tint D = sc.nextInt();\n \tint total = 0;\n\n \tif(A<=B){\n \t\ttotal += A;\n \t}else{\n \t\ttotal+=B;\n \t}\n \tif(C<=D){\n \t\ttotal +=C;\n \t}else{\n \t\ttotal +=D;\n \t}\n\n\n\n \tSystem.out.println(total);\n\n}\n\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou planned a trip using trains and buses.\nThe train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket.\nSimilarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket.\n\nFind the minimum total fare when the optimal choices are made for trains and buses.\n\nConstraints\n\n1 \\leq A \\leq 1 000\n\n1 \\leq B \\leq 1 000\n\n1 \\leq C \\leq 1 000\n\n1 \\leq D \\leq 1 000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\n\nOutput\n\nPrint the minimum total fare.\n\nSample Input 1\n\n600\n300\n220\n420\n\nSample Output 1\n\n520\n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you buy an unlimited ticket.\nThus, the optimal choice for trains is to buy an unlimited ticket for 300 yen.\nOn the other hand, the optimal choice for buses is to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\nSample Input 2\n\n555\n555\n400\n200\n\nSample Output 2\n\n755\n\nSample Input 3\n\n549\n817\n715\n603\n\nSample Output 3\n\n1152", "sample_input": "600\n300\n220\n420\n"}, "reference_outputs": ["520\n"], "source_document_id": "p03399", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou planned a trip using trains and buses.\nThe train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket.\nSimilarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket.\n\nFind the minimum total fare when the optimal choices are made for trains and buses.\n\nConstraints\n\n1 \\leq A \\leq 1 000\n\n1 \\leq B \\leq 1 000\n\n1 \\leq C \\leq 1 000\n\n1 \\leq D \\leq 1 000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\n\nOutput\n\nPrint the minimum total fare.\n\nSample Input 1\n\n600\n300\n220\n420\n\nSample Output 1\n\n520\n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you buy an unlimited ticket.\nThus, the optimal choice for trains is to buy an unlimited ticket for 300 yen.\nOn the other hand, the optimal choice for buses is to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\nSample Input 2\n\n555\n555\n400\n200\n\nSample Output 2\n\n755\n\nSample Input 3\n\n549\n817\n715\n603\n\nSample Output 3\n\n1152", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 432, "cpu_time_ms": 94, "memory_kb": 21716}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s444043145", "group_id": "codeNet:p03400", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int d = sc.nextInt();\n int x = sc.nextInt();\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n }\n int sum = 0;\n for (int i = 0; i < n; i++) {\n sum++;\n sum += (d - 1) / a[i];\n }\n System.out.println(sum + x);\n }\n}", "language": "Java", "metadata": {"date": 1565181449, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03400.html", "problem_id": "p03400", "resource_group": "high_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/Java/s444043145.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s444043145", "user_id": "u207048881"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int d = sc.nextInt();\n int x = sc.nextInt();\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n }\n int sum = 0;\n for (int i = 0; i < n; i++) {\n sum++;\n sum += (d - 1) / a[i];\n }\n System.out.println(sum + x);\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSome number of chocolate pieces were prepared for a training camp.\nThe camp had N participants and lasted for D days.\nThe i-th participant (1 \\leq i \\leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on.\nAs a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces.\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq D \\leq 100\n\n1 \\leq X \\leq 100\n\n1 \\leq A_i \\leq 100 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD X\nA_1\nA_2\n:\nA_N\n\nOutput\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nSample Input 1\n\n3\n7 1\n2\n5\n10\n\nSample Output 1\n\n8\n\nThe camp has 3 participants and lasts for 7 days.\nEach participant eats chocolate pieces as follows:\n\nThe first participant eats one chocolate piece on Day 1, 3, 5 and 7, for a total of four.\n\nThe second participant eats one chocolate piece on Day 1 and 6, for a total of two.\n\nThe third participant eats one chocolate piece only on Day 1, for a total of one.\n\nSince the number of pieces remaining at the end of the camp is one, the number of pieces prepared at the beginning of the camp is 1 + 4 + 2 + 1 = 8.\n\nSample Input 2\n\n2\n8 20\n1\n10\n\nSample Output 2\n\n29\n\nSample Input 3\n\n5\n30 44\n26\n18\n81\n18\n6\n\nSample Output 3\n\n56", "sample_input": "3\n7 1\n2\n5\n10\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03400", "source_text": "Score : 200 points\n\nProblem Statement\n\nSome number of chocolate pieces were prepared for a training camp.\nThe camp had N participants and lasted for D days.\nThe i-th participant (1 \\leq i \\leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on.\nAs a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces.\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq D \\leq 100\n\n1 \\leq X \\leq 100\n\n1 \\leq A_i \\leq 100 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD X\nA_1\nA_2\n:\nA_N\n\nOutput\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nSample Input 1\n\n3\n7 1\n2\n5\n10\n\nSample Output 1\n\n8\n\nThe camp has 3 participants and lasts for 7 days.\nEach participant eats chocolate pieces as follows:\n\nThe first participant eats one chocolate piece on Day 1, 3, 5 and 7, for a total of four.\n\nThe second participant eats one chocolate piece on Day 1 and 6, for a total of two.\n\nThe third participant eats one chocolate piece only on Day 1, for a total of one.\n\nSince the number of pieces remaining at the end of the camp is one, the number of pieces prepared at the beginning of the camp is 1 + 4 + 2 + 1 = 8.\n\nSample Input 2\n\n2\n8 20\n1\n10\n\nSample Output 2\n\n29\n\nSample Input 3\n\n5\n30 44\n26\n18\n81\n18\n6\n\nSample Output 3\n\n56", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 499, "cpu_time_ms": 109, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s542527001", "group_id": "codeNet:p03401", "input_text": "import java.util.ArrayList;\nimport java.util.List;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint points = sc.nextInt();\n\n\t\tList list = new ArrayList<>();\n\t\tlist.add(0);\n\n\t\tfor (int i = 0; i < points; i++) {\n\t\t\tlist.add(sc.nextInt());\n\t\t}\n\t\tsc.close();\n\t\tlist.add(0);\n\n\t\tList tempList = new ArrayList<>(list);\n\t\tint temp;\n\n\t\tfor (int i = 1; i < list.size() - 1; i++) {\n\n\t\t\ttempList.remove(i);\n\t\t\tSystem.out.println(calc(tempList));\n\t\t\ttempList = new ArrayList<>(list);\n\t\t}\n\t}\n\n\tprivate static int calc(List list) {\n\n\t\tint temp = 0;\n\t\tfor (int i = 0; i < list.size() - 1; i++) {\n\t\t\ttemp += Math.abs(list.get(i + 1) - list.get(i));\n\t\t}\n\n\t\treturn temp;\n\t}\n}", "language": "Java", "metadata": {"date": 1549661094, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03401.html", "problem_id": "p03401", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03401/input.txt", "sample_output_relpath": "derived/input_output/data/p03401/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03401/Java/s542527001.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s542527001", "user_id": "u249053326"}, "prompt_components": {"gold_output": "12\n8\n10\n", "input_to_evaluate": "import java.util.ArrayList;\nimport java.util.List;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint points = sc.nextInt();\n\n\t\tList list = new ArrayList<>();\n\t\tlist.add(0);\n\n\t\tfor (int i = 0; i < points; i++) {\n\t\t\tlist.add(sc.nextInt());\n\t\t}\n\t\tsc.close();\n\t\tlist.add(0);\n\n\t\tList tempList = new ArrayList<>(list);\n\t\tint temp;\n\n\t\tfor (int i = 1; i < list.size() - 1; i++) {\n\n\t\t\ttempList.remove(i);\n\t\t\tSystem.out.println(calc(tempList));\n\t\t\ttempList = new ArrayList<>(list);\n\t\t}\n\t}\n\n\tprivate static int calc(List list) {\n\n\t\tint temp = 0;\n\t\tfor (int i = 0; i < list.size() - 1; i++) {\n\t\t\ttemp += Math.abs(list.get(i + 1) - list.get(i));\n\t\t}\n\n\t\treturn temp;\n\t}\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N sightseeing spots on the x-axis, numbered 1, 2, ..., N.\nSpot i is at the point with coordinate A_i.\nIt costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis.\n\nYou planned a trip along the axis.\nIn this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0.\n\nHowever, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i.\nYou will visit the remaining spots as planned in the order they are numbered.\nYou will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned.\n\nFor each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n-5000 \\leq A_i \\leq 5000 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint N lines.\nIn the i-th line, print the total cost of travel during the trip when the visit to Spot i is canceled.\n\nSample Input 1\n\n3\n3 5 -1\n\nSample Output 1\n\n12\n8\n10\n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit to Spot i is canceled, are as follows:\n\nFor i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n\nFor i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n\nFor i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\nSample Input 2\n\n5\n1 1 1 2 0\n\nSample Output 2\n\n4\n4\n4\n2\n4\n\nSample Input 3\n\n6\n-679 -2409 -3258 3095 -3291 -4462\n\nSample Output 3\n\n21630\n21630\n19932\n8924\n21630\n19288", "sample_input": "3\n3 5 -1\n"}, "reference_outputs": ["12\n8\n10\n"], "source_document_id": "p03401", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N sightseeing spots on the x-axis, numbered 1, 2, ..., N.\nSpot i is at the point with coordinate A_i.\nIt costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis.\n\nYou planned a trip along the axis.\nIn this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0.\n\nHowever, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i.\nYou will visit the remaining spots as planned in the order they are numbered.\nYou will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned.\n\nFor each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n-5000 \\leq A_i \\leq 5000 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint N lines.\nIn the i-th line, print the total cost of travel during the trip when the visit to Spot i is canceled.\n\nSample Input 1\n\n3\n3 5 -1\n\nSample Output 1\n\n12\n8\n10\n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit to Spot i is canceled, are as follows:\n\nFor i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n\nFor i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n\nFor i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\nSample Input 2\n\n5\n1 1 1 2 0\n\nSample Output 2\n\n4\n4\n4\n2\n4\n\nSample Input 3\n\n6\n-679 -2409 -3258 3095 -3291 -4462\n\nSample Output 3\n\n21630\n21630\n19932\n8924\n21630\n19288", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2110, "memory_kb": 355556}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s765143096", "group_id": "codeNet:p03403", "input_text": "import java.util.*;\n \npublic class Main {\n \n\tstatic Main instance = new Main();\n \n\tpublic static void main(String[] args) {\n \n\t\tScanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int[] a = new int[N+1];\n a[0] = 0;\n int price = 0;\n \n for(int i = 1; i < N+1 ; i++){\n a[i] = sc.nextInt();\n price += Math.abs(a[i]-a[i-1]);\n }\n price += Math.abs(0-a[N]);\n \n int h = price;\n for(int i = 1; i+1 < N+1; i++){\n price = h;\n int tmp1 = Math.abs(a[i]-a[i-1]);\n int tmp2 = Math.abs(a[i+1]-a[i]);\n int tmp3 = Math.abs(a[i+1]-a[i-1]);\n price = price -tmp1-tmp2+tmp3;\n \n System.out.println(price);\n }\n \n int last = 0;\n for(int i = 1; i < N; i++){\n last += Math.abs(a[i]-a[i-1]);\n }\n last += Math.abs(0-a[N-1]);\n System.out.println(last);\n\t}\n}", "language": "Java", "metadata": {"date": 1598900410, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p03403.html", "problem_id": "p03403", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03403/input.txt", "sample_output_relpath": "derived/input_output/data/p03403/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03403/Java/s765143096.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s765143096", "user_id": "u251825204"}, "prompt_components": {"gold_output": "12\n8\n10\n", "input_to_evaluate": "import java.util.*;\n \npublic class Main {\n \n\tstatic Main instance = new Main();\n \n\tpublic static void main(String[] args) {\n \n\t\tScanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int[] a = new int[N+1];\n a[0] = 0;\n int price = 0;\n \n for(int i = 1; i < N+1 ; i++){\n a[i] = sc.nextInt();\n price += Math.abs(a[i]-a[i-1]);\n }\n price += Math.abs(0-a[N]);\n \n int h = price;\n for(int i = 1; i+1 < N+1; i++){\n price = h;\n int tmp1 = Math.abs(a[i]-a[i-1]);\n int tmp2 = Math.abs(a[i+1]-a[i]);\n int tmp3 = Math.abs(a[i+1]-a[i-1]);\n price = price -tmp1-tmp2+tmp3;\n \n System.out.println(price);\n }\n \n int last = 0;\n for(int i = 1; i < N; i++){\n last += Math.abs(a[i]-a[i-1]);\n }\n last += Math.abs(0-a[N-1]);\n System.out.println(last);\n\t}\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N sightseeing spots on the x-axis, numbered 1, 2, ..., N.\nSpot i is at the point with coordinate A_i.\nIt costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis.\n\nYou planned a trip along the axis.\nIn this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0.\n\nHowever, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i.\nYou will visit the remaining spots as planned in the order they are numbered.\nYou will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned.\n\nFor each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n-5000 \\leq A_i \\leq 5000 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint N lines.\nIn the i-th line, print the total cost of travel during the trip when the visit to Spot i is canceled.\n\nSample Input 1\n\n3\n3 5 -1\n\nSample Output 1\n\n12\n8\n10\n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit to Spot i is canceled, are as follows:\n\nFor i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n\nFor i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n\nFor i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\nSample Input 2\n\n5\n1 1 1 2 0\n\nSample Output 2\n\n4\n4\n4\n2\n4\n\nSample Input 3\n\n6\n-679 -2409 -3258 3095 -3291 -4462\n\nSample Output 3\n\n21630\n21630\n19932\n8924\n21630\n19288", "sample_input": "3\n3 5 -1\n"}, "reference_outputs": ["12\n8\n10\n"], "source_document_id": "p03403", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N sightseeing spots on the x-axis, numbered 1, 2, ..., N.\nSpot i is at the point with coordinate A_i.\nIt costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis.\n\nYou planned a trip along the axis.\nIn this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0.\n\nHowever, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i.\nYou will visit the remaining spots as planned in the order they are numbered.\nYou will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned.\n\nFor each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n-5000 \\leq A_i \\leq 5000 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint N lines.\nIn the i-th line, print the total cost of travel during the trip when the visit to Spot i is canceled.\n\nSample Input 1\n\n3\n3 5 -1\n\nSample Output 1\n\n12\n8\n10\n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit to Spot i is canceled, are as follows:\n\nFor i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n\nFor i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n\nFor i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\nSample Input 2\n\n5\n1 1 1 2 0\n\nSample Output 2\n\n4\n4\n4\n2\n4\n\nSample Input 3\n\n6\n-679 -2409 -3258 3095 -3291 -4462\n\nSample Output 3\n\n21630\n21630\n19932\n8924\n21630\n19288", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 952, "cpu_time_ms": 936, "memory_kb": 60136}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s025112441", "group_id": "codeNet:p03403", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(final String[] args) {\n Scanner sc = new Scanner(System.in);\n int n =sc.nextInt();\n int[] a = new int[n+2];\n int sum = 0;\n for (int i = 1; i <= n; i++) {\n a[i] = sc.nextInt();\n sum += Math.abs(a[i-1] - a[i]);\n\n }\n sum += Math.abs(0 - a[n]);\n\n for (int i = 1; i <= n; i++) {\n int p = check(a[i-1], a[i], a[i-+1]);\n if (p == 1) {\n System.out.println(sum);\n } else {\n int tmp = sum;\n tmp -= (Math.abs(a[i] - a[i-1]) + Math.abs(a[i] - a[i+1]));\n tmp += Math.abs(a[i+1] - a[i-1]);\n System.out.println(tmp);\n }\n }\n }\n\n private static int check(int prev, int cur, int next) {\n if ((prev <= cur && cur <= next) || (next <= cur && cur <= prev)) {\n return 1;\n }\n if ((cur <= prev && prev <= next) || (next <= prev && prev <= cur)) {\n return 2;\n }\n return 3;\n }\n}", "language": "Java", "metadata": {"date": 1593133062, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p03403.html", "problem_id": "p03403", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03403/input.txt", "sample_output_relpath": "derived/input_output/data/p03403/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03403/Java/s025112441.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s025112441", "user_id": "u291818671"}, "prompt_components": {"gold_output": "12\n8\n10\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(final String[] args) {\n Scanner sc = new Scanner(System.in);\n int n =sc.nextInt();\n int[] a = new int[n+2];\n int sum = 0;\n for (int i = 1; i <= n; i++) {\n a[i] = sc.nextInt();\n sum += Math.abs(a[i-1] - a[i]);\n\n }\n sum += Math.abs(0 - a[n]);\n\n for (int i = 1; i <= n; i++) {\n int p = check(a[i-1], a[i], a[i-+1]);\n if (p == 1) {\n System.out.println(sum);\n } else {\n int tmp = sum;\n tmp -= (Math.abs(a[i] - a[i-1]) + Math.abs(a[i] - a[i+1]));\n tmp += Math.abs(a[i+1] - a[i-1]);\n System.out.println(tmp);\n }\n }\n }\n\n private static int check(int prev, int cur, int next) {\n if ((prev <= cur && cur <= next) || (next <= cur && cur <= prev)) {\n return 1;\n }\n if ((cur <= prev && prev <= next) || (next <= prev && prev <= cur)) {\n return 2;\n }\n return 3;\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N sightseeing spots on the x-axis, numbered 1, 2, ..., N.\nSpot i is at the point with coordinate A_i.\nIt costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis.\n\nYou planned a trip along the axis.\nIn this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0.\n\nHowever, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i.\nYou will visit the remaining spots as planned in the order they are numbered.\nYou will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned.\n\nFor each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n-5000 \\leq A_i \\leq 5000 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint N lines.\nIn the i-th line, print the total cost of travel during the trip when the visit to Spot i is canceled.\n\nSample Input 1\n\n3\n3 5 -1\n\nSample Output 1\n\n12\n8\n10\n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit to Spot i is canceled, are as follows:\n\nFor i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n\nFor i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n\nFor i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\nSample Input 2\n\n5\n1 1 1 2 0\n\nSample Output 2\n\n4\n4\n4\n2\n4\n\nSample Input 3\n\n6\n-679 -2409 -3258 3095 -3291 -4462\n\nSample Output 3\n\n21630\n21630\n19932\n8924\n21630\n19288", "sample_input": "3\n3 5 -1\n"}, "reference_outputs": ["12\n8\n10\n"], "source_document_id": "p03403", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N sightseeing spots on the x-axis, numbered 1, 2, ..., N.\nSpot i is at the point with coordinate A_i.\nIt costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis.\n\nYou planned a trip along the axis.\nIn this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0.\n\nHowever, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i.\nYou will visit the remaining spots as planned in the order they are numbered.\nYou will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned.\n\nFor each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n-5000 \\leq A_i \\leq 5000 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint N lines.\nIn the i-th line, print the total cost of travel during the trip when the visit to Spot i is canceled.\n\nSample Input 1\n\n3\n3 5 -1\n\nSample Output 1\n\n12\n8\n10\n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit to Spot i is canceled, are as follows:\n\nFor i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n\nFor i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n\nFor i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\nSample Input 2\n\n5\n1 1 1 2 0\n\nSample Output 2\n\n4\n4\n4\n2\n4\n\nSample Input 3\n\n6\n-679 -2409 -3258 3095 -3291 -4462\n\nSample Output 3\n\n21630\n21630\n19932\n8924\n21630\n19288", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1091, "cpu_time_ms": 942, "memory_kb": 60236}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s383217057", "group_id": "codeNet:p03404", "input_text": "//package com.company;\n\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n static long TIME_START, TIME_END;\n public static void main(String[] args) throws IOException {\n Scanner sc = new Scanner(System.in);\n// Scanner sc = new Scanner(new FileInputStream(\"Test.in\"));\n PrintWriter pw = new PrintWriter(System.out);\n// PrintWriter pw = new PrintWriter(new FileOutputStream(\"Test.out\"));\n// PrintWriter pw = new PrintWriter(new FileOutputStream(\"Test.in\"));\n\n Runtime runtime = Runtime.getRuntime();\n long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();\n TIME_START = System.currentTimeMillis();\n Task t = new Task();\n t.solve(sc, pw);\n TIME_END = System.currentTimeMillis();\n long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();\n pw.close();\n// System.out.println(\"Memory increased:\" + (usedMemoryAfter-usedMemoryBefore) / 1000000 );\n// System.out.println(\"Time used: \" + (TIME_END - TIME_START) + \".\");\n\n }\n\n\n public static class Task {\n\n\n public void solve(Scanner sc, PrintWriter pw) throws IOException {\n int A = sc.nextInt();\n int B = sc.nextInt();\n A--;//white\n B--;//black\n int[][] grid = new int[100][100];\n for (int i = 50; i < 100; i++) {\n Arrays.fill(grid[i], 1);\n }\n for (int i = 0; i < 50; i++) {\n for (int j = (i & 1); j < 100; j+= 2) {\n if (A > 0) {\n grid[i][j] = 1;\n A--;\n }\n }\n }\n\n for (int i = 99; i >= 0; i--) {\n for (int j = (i & 1); j < 100; j += 2) {\n if (B > 0) {\n grid[i][j] = 0;\n B--;\n }\n }\n }\n pw.println(\"100 100\");\n for (int i = 0; i < 100; i++) {\n for (int j = 0; j < 100; j++) {\n pw.print(grid[i][j] == 1 ? '.': '#');\n }\n pw.println();\n }\n\n }\n\n\n\n\n }\n\n static class Scanner {\n StringTokenizer st;\n BufferedReader br;\n\n public Scanner(InputStream s){ br = new BufferedReader(new InputStreamReader(s));}\n\n public Scanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(s);}\n\n public String next() throws IOException\n {\n while (st == null || !st.hasMoreTokens())\n st = new StringTokenizer(br.readLine());\n return st.nextToken();\n }\n\n public int nextInt() throws IOException {return Integer.parseInt(next());}\n\n public long nextLong() throws IOException {return Long.parseLong(next());}\n\n public String nextLine() throws IOException {return br.readLine();}\n\n public double nextDouble() throws IOException { return Double.parseDouble(next()); }\n\n public boolean ready() throws IOException {return br.ready();}\n }\n}\n", "language": "Java", "metadata": {"date": 1522224690, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03404.html", "problem_id": "p03404", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03404/input.txt", "sample_output_relpath": "derived/input_output/data/p03404/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03404/Java/s383217057.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s383217057", "user_id": "u394059586"}, "prompt_components": {"gold_output": "3 3\n##.\n..#\n#.#\n", "input_to_evaluate": "//package com.company;\n\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n static long TIME_START, TIME_END;\n public static void main(String[] args) throws IOException {\n Scanner sc = new Scanner(System.in);\n// Scanner sc = new Scanner(new FileInputStream(\"Test.in\"));\n PrintWriter pw = new PrintWriter(System.out);\n// PrintWriter pw = new PrintWriter(new FileOutputStream(\"Test.out\"));\n// PrintWriter pw = new PrintWriter(new FileOutputStream(\"Test.in\"));\n\n Runtime runtime = Runtime.getRuntime();\n long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();\n TIME_START = System.currentTimeMillis();\n Task t = new Task();\n t.solve(sc, pw);\n TIME_END = System.currentTimeMillis();\n long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();\n pw.close();\n// System.out.println(\"Memory increased:\" + (usedMemoryAfter-usedMemoryBefore) / 1000000 );\n// System.out.println(\"Time used: \" + (TIME_END - TIME_START) + \".\");\n\n }\n\n\n public static class Task {\n\n\n public void solve(Scanner sc, PrintWriter pw) throws IOException {\n int A = sc.nextInt();\n int B = sc.nextInt();\n A--;//white\n B--;//black\n int[][] grid = new int[100][100];\n for (int i = 50; i < 100; i++) {\n Arrays.fill(grid[i], 1);\n }\n for (int i = 0; i < 50; i++) {\n for (int j = (i & 1); j < 100; j+= 2) {\n if (A > 0) {\n grid[i][j] = 1;\n A--;\n }\n }\n }\n\n for (int i = 99; i >= 0; i--) {\n for (int j = (i & 1); j < 100; j += 2) {\n if (B > 0) {\n grid[i][j] = 0;\n B--;\n }\n }\n }\n pw.println(\"100 100\");\n for (int i = 0; i < 100; i++) {\n for (int j = 0; j < 100; j++) {\n pw.print(grid[i][j] == 1 ? '.': '#');\n }\n pw.println();\n }\n\n }\n\n\n\n\n }\n\n static class Scanner {\n StringTokenizer st;\n BufferedReader br;\n\n public Scanner(InputStream s){ br = new BufferedReader(new InputStreamReader(s));}\n\n public Scanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(s);}\n\n public String next() throws IOException\n {\n while (st == null || !st.hasMoreTokens())\n st = new StringTokenizer(br.readLine());\n return st.nextToken();\n }\n\n public int nextInt() throws IOException {return Integer.parseInt(next());}\n\n public long nextLong() throws IOException {return Long.parseLong(next());}\n\n public String nextLine() throws IOException {return br.readLine();}\n\n public double nextDouble() throws IOException { return Double.parseDouble(next()); }\n\n public boolean ready() throws IOException {return br.ready();}\n }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given two integers A and B.\n\nPrint a grid where each square is painted white or black that satisfies the following conditions, in the format specified in Output section:\n\nLet the size of the grid be h \\times w (h vertical, w horizontal). Both h and w are at most 100.\n\nThe set of the squares painted white is divided into exactly A connected components.\n\nThe set of the squares painted black is divided into exactly B connected components.\n\nIt can be proved that there always exist one or more solutions under the conditions specified in Constraints section.\nIf there are multiple solutions, any of them may be printed.\n\nNotes\n\nTwo squares painted white, c_1 and c_2, are called connected when the square c_2 can be reached from the square c_1 passing only white squares by repeatedly moving up, down, left or right to an adjacent square.\n\nA set of squares painted white, S, forms a connected component when the following conditions are met:\n\nAny two squares in S are connected.\n\nNo pair of a square painted white that is not included in S and a square included in S is connected.\n\nA connected component of squares painted black is defined similarly.\n\nConstraints\n\n1 \\leq A \\leq 500\n\n1 \\leq B \\leq 500\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nOutput should be in the following format:\n\nIn the first line, print integers h and w representing the size of the grid you constructed, with a space in between.\n\nThen, print h more lines. The i-th (1 \\leq i \\leq h) of these lines should contain a string s_i as follows:\n\nIf the square at the i-th row and j-th column (1 \\leq j \\leq w) in the grid is painted white, the j-th character in s_i should be ..\n\nIf the square at the i-th row and j-th column (1 \\leq j \\leq w) in the grid is painted black, the j-th character in s_i should be #.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n3 3\n##.\n..#\n#.#\n\nThis output corresponds to the grid below:\n\nSample Input 2\n\n7 8\n\nSample Output 2\n\n3 5\n#.#.#\n.#.#.\n#.#.#\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n4 2\n..\n#.\n##\n##\n\nSample Input 4\n\n3 14\n\nSample Output 4\n\n8 18\n..................\n..................\n....##.......####.\n....#.#.....#.....\n...#...#....#.....\n..#.###.#...#.....\n.#.......#..#.....\n#.........#..####.", "sample_input": "2 3\n"}, "reference_outputs": ["3 3\n##.\n..#\n#.#\n"], "source_document_id": "p03404", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given two integers A and B.\n\nPrint a grid where each square is painted white or black that satisfies the following conditions, in the format specified in Output section:\n\nLet the size of the grid be h \\times w (h vertical, w horizontal). Both h and w are at most 100.\n\nThe set of the squares painted white is divided into exactly A connected components.\n\nThe set of the squares painted black is divided into exactly B connected components.\n\nIt can be proved that there always exist one or more solutions under the conditions specified in Constraints section.\nIf there are multiple solutions, any of them may be printed.\n\nNotes\n\nTwo squares painted white, c_1 and c_2, are called connected when the square c_2 can be reached from the square c_1 passing only white squares by repeatedly moving up, down, left or right to an adjacent square.\n\nA set of squares painted white, S, forms a connected component when the following conditions are met:\n\nAny two squares in S are connected.\n\nNo pair of a square painted white that is not included in S and a square included in S is connected.\n\nA connected component of squares painted black is defined similarly.\n\nConstraints\n\n1 \\leq A \\leq 500\n\n1 \\leq B \\leq 500\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nOutput should be in the following format:\n\nIn the first line, print integers h and w representing the size of the grid you constructed, with a space in between.\n\nThen, print h more lines. The i-th (1 \\leq i \\leq h) of these lines should contain a string s_i as follows:\n\nIf the square at the i-th row and j-th column (1 \\leq j \\leq w) in the grid is painted white, the j-th character in s_i should be ..\n\nIf the square at the i-th row and j-th column (1 \\leq j \\leq w) in the grid is painted black, the j-th character in s_i should be #.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n3 3\n##.\n..#\n#.#\n\nThis output corresponds to the grid below:\n\nSample Input 2\n\n7 8\n\nSample Output 2\n\n3 5\n#.#.#\n.#.#.\n#.#.#\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n4 2\n..\n#.\n##\n##\n\nSample Input 4\n\n3 14\n\nSample Output 4\n\n8 18\n..................\n..................\n....##.......####.\n....#.#.....#.....\n...#...#....#.....\n..#.###.#...#.....\n.#.......#..#.....\n#.........#..####.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3124, "cpu_time_ms": 88, "memory_kb": 25172}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s823323477", "group_id": "codeNet:p03407", "input_text": "import java.util.*;\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tInteger a = sc.nextInt();\n\t\tInteger b = sc.nextInt();\n\t\tint price = sc.nextInt();\n\t\tInteger[] coins = {1, 5, 10, 50, 100, 500};\n\t\tif (!Arrays.asList(coins).contains(a)) {\n\t\t\ta = 0;\n\t\t}\n\t\tif (!Arrays.asList(coins).contains(b)) {\n\t\t\tb = 0;\n\t\t}\n\t\tif (a + b < price) {\n\t\t\tSystem.out.println(\"No\");\n\t\t} else {\n\t\t\tSystem.out.println(\"Yes\");\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1522027758, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03407.html", "problem_id": "p03407", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03407/input.txt", "sample_output_relpath": "derived/input_output/data/p03407/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03407/Java/s823323477.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s823323477", "user_id": "u752395175"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*;\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tInteger a = sc.nextInt();\n\t\tInteger b = sc.nextInt();\n\t\tint price = sc.nextInt();\n\t\tInteger[] coins = {1, 5, 10, 50, 100, 500};\n\t\tif (!Arrays.asList(coins).contains(a)) {\n\t\t\ta = 0;\n\t\t}\n\t\tif (!Arrays.asList(coins).contains(b)) {\n\t\t\tb = 0;\n\t\t}\n\t\tif (a + b < price) {\n\t\t\tSystem.out.println(\"No\");\n\t\t} else {\n\t\t\tSystem.out.println(\"Yes\");\n\t\t}\n\t}\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAn elementary school student Takahashi has come to a variety store.\n\nHe has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it?\n\nNote that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq A, B \\leq 500\n\n1 \\leq C \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf Takahashi can buy the toy, print Yes; if he cannot, print No.\n\nSample Input 1\n\n50 100 120\n\nSample Output 1\n\nYes\n\nHe has 50 + 100 = 150 yen, so he can buy the 120-yen toy.\n\nSample Input 2\n\n500 100 1000\n\nSample Output 2\n\nNo\n\nHe has 500 + 100 = 600 yen, but he cannot buy the 1000-yen toy.\n\nSample Input 3\n\n19 123 143\n\nSample Output 3\n\nNo\n\nThere are 19-yen and 123-yen coins in Takahashi Kingdom, which are rather hard to use.\n\nSample Input 4\n\n19 123 142\n\nSample Output 4\n\nYes", "sample_input": "50 100 120\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03407", "source_text": "Score : 100 points\n\nProblem Statement\n\nAn elementary school student Takahashi has come to a variety store.\n\nHe has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it?\n\nNote that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq A, B \\leq 500\n\n1 \\leq C \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf Takahashi can buy the toy, print Yes; if he cannot, print No.\n\nSample Input 1\n\n50 100 120\n\nSample Output 1\n\nYes\n\nHe has 50 + 100 = 150 yen, so he can buy the 120-yen toy.\n\nSample Input 2\n\n500 100 1000\n\nSample Output 2\n\nNo\n\nHe has 500 + 100 = 600 yen, but he cannot buy the 1000-yen toy.\n\nSample Input 3\n\n19 123 143\n\nSample Output 3\n\nNo\n\nThere are 19-yen and 123-yen coins in Takahashi Kingdom, which are rather hard to use.\n\nSample Input 4\n\n19 123 142\n\nSample Output 4\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 94, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s250953777", "group_id": "codeNet:p03408", "input_text": "package abc091;\nimport java.util.Scanner;\npublic class Main {\n public static void main(String[] args){\n Main instB;\n instB = new Main();\n Scanner sc = new Scanner(System.in);\n //N、S →青いカード\n int N = sc.nextInt();\n String[] S = new String[N];\n for( int i = 0; i();\n\t\tRed = new HashMap();\n\t}\n\n\tpublic void readHead(String str) {\n\t\tString[] strArr = str.split(\" \");\n\t\t// N = Integer.parseInt(strArr[0]);\n\t\t// System.out.println(N);\n\t}\n\n\tpublic void readN(String str) {\n\t\tN = Integer.parseInt(str);\n\t\tcnt = 0;\n\t}\n\n\tpublic void readM(String str) {\n\t\tM = Integer.parseInt(str);\n\t\tcnt = 0;\n\t}\n\n\tpublic boolean hasNextN() {\n\t\treturn cnt < N;\n\t}\n\n\tpublic boolean hasNextM() {\n\t\treturn cnt < M;\n\t}\n\n\tpublic void readBody(String str) {\n\t\t// System.out.println(str);\n\t\tcnt++;\n\t}\n\n\tHashMap Blue;\n\n\tpublic void readBodyN(String str) {\n\t\t// System.out.println(str);\n\t\tif (Blue.containsKey(str))\n\t\t\tBlue.put(str, Blue.get(str) + 1);\n\t\telse\n\t\t\tBlue.put(str, 1);\n\t\tcnt++;\n\t}\n\n\tHashMap Red;\n\n\tpublic void readBodyM(String str) {\n\t\t// System.out.println(str);\n\t\tif (Red.containsKey(str))\n\t\t\tRed.put(str, Red.get(str) + 1);\n\t\telse\n\t\t\tRed.put(str, 1);\n\t\tcnt++;\n\t}\n\n\tpublic void solve() {\n\t\tint ans = 0;\n\t\tfor (String key : Blue.keySet()) {\n\t\t\tint n = Blue.get(key);\n\t\t\tif (Red.containsKey(key))\n\t\t\t\tn -= Red.get(key);\n\t\t\tif (n > ans)\n\t\t\t\tans = n;\n\t\t}\n\n\t\tSystem.out.println(ans);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1521337321, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03408.html", "problem_id": "p03408", "resource_group": "high_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/Java/s671667040.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s671667040", "user_id": "u366035313"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.HashMap;\n\nclass Main {\n\tpublic static void main(String args[]) throws IOException {\n\t\tBufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n\t\tSolver solver = new Solver();\n\t\tsolver.init();\n\t\t// solver.readHead(in.readLine());\n\t\t// for (; solver.hasNext();) {\n\t\t// solver.readBody(in.readLine());\n\t\t// }\n\t\t// solver.solve();\n\t\tsolver.readN(in.readLine());\n\t\tfor (; solver.hasNextN();) {\n\t\t\tsolver.readBodyN(in.readLine());\n\t\t}\n\t\tsolver.readM(in.readLine());\n\t\tfor (; solver.hasNextM();) {\n\t\t\tsolver.readBodyM(in.readLine());\n\t\t}\n\t\tsolver.solve();\n\t}\n}\n\nclass Solver {\n\tint N;\n\tint M;\n\tint cnt;\n\n\tpublic void init() {\n\t\tN = 0;\n\t\tM = 0;\n\t\tcnt = 0;\n\t\tBlue = new HashMap();\n\t\tRed = new HashMap();\n\t}\n\n\tpublic void readHead(String str) {\n\t\tString[] strArr = str.split(\" \");\n\t\t// N = Integer.parseInt(strArr[0]);\n\t\t// System.out.println(N);\n\t}\n\n\tpublic void readN(String str) {\n\t\tN = Integer.parseInt(str);\n\t\tcnt = 0;\n\t}\n\n\tpublic void readM(String str) {\n\t\tM = Integer.parseInt(str);\n\t\tcnt = 0;\n\t}\n\n\tpublic boolean hasNextN() {\n\t\treturn cnt < N;\n\t}\n\n\tpublic boolean hasNextM() {\n\t\treturn cnt < M;\n\t}\n\n\tpublic void readBody(String str) {\n\t\t// System.out.println(str);\n\t\tcnt++;\n\t}\n\n\tHashMap Blue;\n\n\tpublic void readBodyN(String str) {\n\t\t// System.out.println(str);\n\t\tif (Blue.containsKey(str))\n\t\t\tBlue.put(str, Blue.get(str) + 1);\n\t\telse\n\t\t\tBlue.put(str, 1);\n\t\tcnt++;\n\t}\n\n\tHashMap Red;\n\n\tpublic void readBodyM(String str) {\n\t\t// System.out.println(str);\n\t\tif (Red.containsKey(str))\n\t\t\tRed.put(str, Red.get(str) + 1);\n\t\telse\n\t\t\tRed.put(str, 1);\n\t\tcnt++;\n\t}\n\n\tpublic void solve() {\n\t\tint ans = 0;\n\t\tfor (String key : Blue.keySet()) {\n\t\t\tint n = Blue.get(key);\n\t\t\tif (Red.containsKey(key))\n\t\t\t\tn -= Red.get(key);\n\t\t\tif (n > ans)\n\t\t\t\tans = n;\n\t\t}\n\n\t\tSystem.out.println(ans);\n\t}\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": 1965, "cpu_time_ms": 70, "memory_kb": 21332}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s094187914", "group_id": "codeNet:p03409", "input_text": "import java.awt.Point;\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.Arrays;\n\nimport static java.lang.Integer.parseInt;\n\npublic class Main {\n\n final int MIN = -1_000_000_000;\n public static void main(String[] args) {\n new Main().run();\n }\n\n public void run() {\n\n try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {\n\n int n = parseInt(in.readLine());\n\n pxPoint[] reds = new pxPoint[n];\n pxPoint[] blues = new pxPoint[n];\n String[] lines;\n for(int i=0, x=0, y=0; i= p.y) {\n p.x = reds[j].x;\n p.y = reds[j].y;\n maxJ = j;\n }\n }\n }\n if(maxJ != MIN) {\n ans++;\n isDone[maxJ] = true;\n p.x = MIN; p.y = MIN; maxJ = MIN;\n }\n }\n\n System.out.println(ans);\n // for (pxPoint p : reds) {\n // System.out.println(p.x + \" \" + p.y);\n // }\n }\n catch(IOException e) {\n System.err.println(e);\n }\n }\n\n class pxPoint extends Point implements Comparable {\n\n public pxPoint() {\n super();\n }\n public pxPoint(int x, int y) {\n super(x, y);\n }\n\n // @Override\n public int compareTo(pxPoint obj) {\n if(this.x == obj.x) return 0;\n return this.x > obj.x ? 1 : -1;\n }\n }\n}", "language": "Java", "metadata": {"date": 1541361185, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03409.html", "problem_id": "p03409", "resource_group": "high_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/Java/s094187914.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s094187914", "user_id": "u217010036"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.awt.Point;\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.Arrays;\n\nimport static java.lang.Integer.parseInt;\n\npublic class Main {\n\n final int MIN = -1_000_000_000;\n public static void main(String[] args) {\n new Main().run();\n }\n\n public void run() {\n\n try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {\n\n int n = parseInt(in.readLine());\n\n pxPoint[] reds = new pxPoint[n];\n pxPoint[] blues = new pxPoint[n];\n String[] lines;\n for(int i=0, x=0, y=0; i= p.y) {\n p.x = reds[j].x;\n p.y = reds[j].y;\n maxJ = j;\n }\n }\n }\n if(maxJ != MIN) {\n ans++;\n isDone[maxJ] = true;\n p.x = MIN; p.y = MIN; maxJ = MIN;\n }\n }\n\n System.out.println(ans);\n // for (pxPoint p : reds) {\n // System.out.println(p.x + \" \" + p.y);\n // }\n }\n catch(IOException e) {\n System.err.println(e);\n }\n }\n\n class pxPoint extends Point implements Comparable {\n\n public pxPoint() {\n super();\n }\n public pxPoint(int x, int y) {\n super(x, y);\n }\n\n // @Override\n public int compareTo(pxPoint obj) {\n if(this.x == obj.x) return 0;\n return this.x > obj.x ? 1 : -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": 2058, "cpu_time_ms": 76, "memory_kb": 22868}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s976591729", "group_id": "codeNet:p03417", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int i = sc.nextInt()-2;\n int j = sc.nextInt()-2;\n System.out.println(Math.abs(i*j));\n }\n}\n", "language": "Java", "metadata": {"date": 1573600802, "filename_ext": "java", "original_language": "Java7 (OpenJDK 1.7.0)", "problem_description_relpath": "problem_descriptions/p03417.html", "problem_id": "p03417", "resource_group": "high_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/Java/s976591729.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s976591729", "user_id": "u410807621"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int i = sc.nextInt()-2;\n int j = sc.nextInt()-2;\n System.out.println(Math.abs(i*j));\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": 245, "cpu_time_ms": 95, "memory_kb": 20948}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s557976063", "group_id": "codeNet:p03417", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner((System.in));\n\t\tint n = sc.nextInt();\n\t\tint m = sc.nextInt();\n\t\tlong ans = 0;\n\n\t\tif (n == 1 && m == 1) {\n\t\t\tans = 1;\n\t\t} else if (n == 1) {\n\t\t\tans = m - 1;\n\t\t} else if (m == 1) {\n\t\t\tans = n - 1;\n\t\t} else if (n > 2 && m > 2) {\n\t\t\tans = Math.abs((n - 2) * (m - 2));\n\t\t}\n\t\t\n\t\tSystem.out.println(ans);\n\n\t\tsc.close();\n\t}\n}\n", "language": "Java", "metadata": {"date": 1562861052, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03417.html", "problem_id": "p03417", "resource_group": "high_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/Java/s557976063.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s557976063", "user_id": "u650591877"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner((System.in));\n\t\tint n = sc.nextInt();\n\t\tint m = sc.nextInt();\n\t\tlong ans = 0;\n\n\t\tif (n == 1 && m == 1) {\n\t\t\tans = 1;\n\t\t} else if (n == 1) {\n\t\t\tans = m - 1;\n\t\t} else if (m == 1) {\n\t\t\tans = n - 1;\n\t\t} else if (n > 2 && m > 2) {\n\t\t\tans = Math.abs((n - 2) * (m - 2));\n\t\t}\n\t\t\n\t\tSystem.out.println(ans);\n\n\t\tsc.close();\n\t}\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": 434, "cpu_time_ms": 95, "memory_kb": 21716}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s445787770", "group_id": "codeNet:p03418", "input_text": "import java.util.*;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint K = sc.nextInt();\n\t\tint answer = 0;\n\t\tfor (int a = K; a < N; a++) {\n\t\t\tfor (int b = a + 1; b < N + 1; b++) {\n\t\t\t\tif (((N - a) % b) == 0) {\n\t\t\t\t\tanswer += (N - a) / b;\n\t\t\t\t} else {\n\t\t\t\t\tanswer += 1 + (N - a) / b;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(answer);\n\t}\n\n}", "language": "Java", "metadata": {"date": 1520821033, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03418.html", "problem_id": "p03418", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03418/input.txt", "sample_output_relpath": "derived/input_output/data/p03418/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03418/Java/s445787770.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s445787770", "user_id": "u248364740"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint K = sc.nextInt();\n\t\tint answer = 0;\n\t\tfor (int a = K; a < N; a++) {\n\t\t\tfor (int b = a + 1; b < N + 1; b++) {\n\t\t\t\tif (((N - a) % b) == 0) {\n\t\t\t\t\tanswer += (N - a) / b;\n\t\t\t\t} else {\n\t\t\t\t\tanswer += 1 + (N - a) / b;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(answer);\n\t}\n\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": "p03418", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten.\nHe remembers that the remainder of a divided by b was greater than or equal to K.\nFind the number of possible pairs that he may have had.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N-1\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of possible pairs that he may have had.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n7\n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\nSample Input 2\n\n10 0\n\nSample Output 2\n\n100\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n287927211", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2109, "memory_kb": 23636}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s965756426", "group_id": "codeNet:p03423", "input_text": "import java.util.*;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint count = 0;\n\t\tint n = N;\n\t\tfor(int i = 0; i < N;i++) {\n\t\t\tif(n > 3) {\n\t\t\t\tn = n-3;\n\t\t\t\tcount++;\n\t\t\t}else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n}", "language": "Java", "metadata": {"date": 1597731418, "filename_ext": "java", "original_language": "Java (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03423.html", "problem_id": "p03423", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03423/input.txt", "sample_output_relpath": "derived/input_output/data/p03423/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03423/Java/s965756426.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s965756426", "user_id": "u025377431"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt();\n\t\tint count = 0;\n\t\tint n = N;\n\t\tfor(int i = 0; i < N;i++) {\n\t\t\tif(n > 3) {\n\t\t\t\tn = n-3;\n\t\t\t\tcount++;\n\t\t\t}else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N students in a school.\n\nWe will divide these students into some groups, and in each group they will discuss some themes.\n\nYou think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible.\n\nDivide the students so that the number of groups consisting of three or more students is maximized.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf you can form at most x groups consisting of three or more students, print x.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n2\n\nFor example, you can form a group of three students and another of five students.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0\n\nSometimes you cannot form any group consisting of three or more students, regardless of how you divide the students.\n\nSample Input 3\n\n9\n\nSample Output 3\n\n3", "sample_input": "8\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03423", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N students in a school.\n\nWe will divide these students into some groups, and in each group they will discuss some themes.\n\nYou think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible.\n\nDivide the students so that the number of groups consisting of three or more students is maximized.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf you can form at most x groups consisting of three or more students, print x.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n2\n\nFor example, you can form a group of three students and another of five students.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0\n\nSometimes you cannot form any group consisting of three or more students, regardless of how you divide the students.\n\nSample Input 3\n\n9\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 105, "memory_kb": 27060}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s229863443", "group_id": "codeNet:p03423", "input_text": "import java.util.*;\n\nclass Main{\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n\n int N = sc.nextInt();\n\n System.out.println(N/3);\n\n }\n}\n", "language": "Java", "metadata": {"date": 1556310694, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03423.html", "problem_id": "p03423", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03423/input.txt", "sample_output_relpath": "derived/input_output/data/p03423/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03423/Java/s229863443.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s229863443", "user_id": "u364124935"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*;\n\nclass Main{\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n\n int N = sc.nextInt();\n\n System.out.println(N/3);\n\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N students in a school.\n\nWe will divide these students into some groups, and in each group they will discuss some themes.\n\nYou think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible.\n\nDivide the students so that the number of groups consisting of three or more students is maximized.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf you can form at most x groups consisting of three or more students, print x.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n2\n\nFor example, you can form a group of three students and another of five students.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0\n\nSometimes you cannot form any group consisting of three or more students, regardless of how you divide the students.\n\nSample Input 3\n\n9\n\nSample Output 3\n\n3", "sample_input": "8\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03423", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N students in a school.\n\nWe will divide these students into some groups, and in each group they will discuss some themes.\n\nYou think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible.\n\nDivide the students so that the number of groups consisting of three or more students is maximized.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf you can form at most x groups consisting of three or more students, print x.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n2\n\nFor example, you can form a group of three students and another of five students.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0\n\nSometimes you cannot form any group consisting of three or more students, regardless of how you divide the students.\n\nSample Input 3\n\n9\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 96, "memory_kb": 23124}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s049070594", "group_id": "codeNet:p03424", "input_text": "import java.util.*;\nimport java.util.Arrays;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N;\n N = sc.nextInt();\n\n ArrayList List = new ArrayList();\n for (int a = 0; a < N; a++) {\n List.add(sc.next());\n }\n if (Arrays.asList(List).contains(\"Y\")) {\n System.out.println(\"three\");\n } else {\n System.out.println(\"four\");\n }\n }\n}", "language": "Java", "metadata": {"date": 1527541403, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03424.html", "problem_id": "p03424", "resource_group": "high_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/Java/s049070594.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s049070594", "user_id": "u497542154"}, "prompt_components": {"gold_output": "Four\n", "input_to_evaluate": "import java.util.*;\nimport java.util.Arrays;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N;\n N = sc.nextInt();\n\n ArrayList List = new ArrayList();\n for (int a = 0; a < N; a++) {\n List.add(sc.next());\n }\n if (Arrays.asList(List).contains(\"Y\")) {\n System.out.println(\"three\");\n } else {\n System.out.println(\"four\");\n }\n }\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": 501, "cpu_time_ms": 106, "memory_kb": 23764}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s763893280", "group_id": "codeNet:p03424", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tString answer = \"Three\";\n\t\tScanner sc = new Scanner(System.in);\n\t\tint hina = sc.nextInt();\n\t\tint p = 0;\t// 桃色\n\t\tint w = 0;\t// 白色\n\t\tint g = 0;\t// 緑色\n\t\tint y = 0;\t// 黄色\n\n\t\tString tmp;\n\t\tfor (int i = 0; i < hina; i++) {\n\t\t\ttmp = sc.next();\n\t\t\t// ひなあられの文字列判定\n\t\t\tswitch (tmp) {\n\t\t\tcase \"P\":\n\t\t\t\tif (p > 0) break;\n\t\t\t\tp++;\n\t\t\t\tbreak;\n\n\t\t\tcase \"W\":\n\t\t\t\tif (w > 0) break;\n\t\t\t\tw++;\n\t\t\t\tbreak;\n\n\t\t\tcase \"G\":\n\t\t\t\tif (g > 0) break;\n\t\t\t\tg++;\n\t\t\t\tbreak;\n\n\t\t\tcase \"Y\":\n\t\t\t\tif (y > 0) break;\n\t\t\t\ty++;\n\t\t\t\tbreak;\n\n\t\t\t}\n\t\t\t// 4種類だと確定した場合スキップ\n\t\t\tif (p + w + g + y == 4) {\n\t\t\t\tanswer = \"Four\";\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t}\n\n\t\tSystem.out.println(answer);\n\n\t}\n\n}", "language": "Java", "metadata": {"date": 1520718786, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03424.html", "problem_id": "p03424", "resource_group": "high_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/Java/s763893280.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s763893280", "user_id": "u770332301"}, "prompt_components": {"gold_output": "Four\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tString answer = \"Three\";\n\t\tScanner sc = new Scanner(System.in);\n\t\tint hina = sc.nextInt();\n\t\tint p = 0;\t// 桃色\n\t\tint w = 0;\t// 白色\n\t\tint g = 0;\t// 緑色\n\t\tint y = 0;\t// 黄色\n\n\t\tString tmp;\n\t\tfor (int i = 0; i < hina; i++) {\n\t\t\ttmp = sc.next();\n\t\t\t// ひなあられの文字列判定\n\t\t\tswitch (tmp) {\n\t\t\tcase \"P\":\n\t\t\t\tif (p > 0) break;\n\t\t\t\tp++;\n\t\t\t\tbreak;\n\n\t\t\tcase \"W\":\n\t\t\t\tif (w > 0) break;\n\t\t\t\tw++;\n\t\t\t\tbreak;\n\n\t\t\tcase \"G\":\n\t\t\t\tif (g > 0) break;\n\t\t\t\tg++;\n\t\t\t\tbreak;\n\n\t\t\tcase \"Y\":\n\t\t\t\tif (y > 0) break;\n\t\t\t\ty++;\n\t\t\t\tbreak;\n\n\t\t\t}\n\t\t\t// 4種類だと確定した場合スキップ\n\t\t\tif (p + w + g + y == 4) {\n\t\t\t\tanswer = \"Four\";\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t}\n\n\t\tSystem.out.println(answer);\n\n\t}\n\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": 790, "cpu_time_ms": 155, "memory_kb": 22996}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s103620515", "group_id": "codeNet:p03426", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Scanner;\nimport java.util.HashMap;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author Silviase\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n DPracticalSkillTest solver = new DPracticalSkillTest();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class DPracticalSkillTest {\n public void solve(int testNumber, Scanner in, PrintWriter out) {\n int h = in.nextInt();\n int w = in.nextInt();\n int d = in.nextInt();\n HashMap hm = new HashMap<>();\n int[] cumDist = new int[h * w + 1];\n for (int i = 0; i <= d; i++) {\n cumDist[i] = 0;\n }\n for (int i = 0; i < h; i++) {\n for (int j = 0; j < w; j++) {\n Pair p = new Pair(i, j);\n int val = in.nextInt();\n hm.put(val, p);\n }\n }\n\n for (int i = d + 1; i <= h * w; i++) {\n Pair p1 = new Pair(hm.get(i).x, hm.get(i).y);\n Pair p2 = new Pair(hm.get(i - d).x, hm.get(i - d).y);\n cumDist[i] = cumDist[i - d] + Pair.dist(p1, p2);\n }\n int q = in.nextInt();\n for (int i = 0; i < q; i++) {\n int st = in.nextInt();\n int en = in.nextInt();\n out.println(cumDist[en] - cumDist[st]);\n }\n }\n\n }\n\n static class Pair {\n int x;\n int y;\n\n public Pair(int x, int y) {\n this.x = x;\n this.y = y;\n }\n\n static int dist(Pair p1, Pair p2) {\n return Math.abs(p1.x - p2.x) + Math.abs(p1.y - p2.y);\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1575042796, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03426.html", "problem_id": "p03426", "resource_group": "high_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/Java/s103620515.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s103620515", "user_id": "u902576227"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Scanner;\nimport java.util.HashMap;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author Silviase\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n DPracticalSkillTest solver = new DPracticalSkillTest();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class DPracticalSkillTest {\n public void solve(int testNumber, Scanner in, PrintWriter out) {\n int h = in.nextInt();\n int w = in.nextInt();\n int d = in.nextInt();\n HashMap hm = new HashMap<>();\n int[] cumDist = new int[h * w + 1];\n for (int i = 0; i <= d; i++) {\n cumDist[i] = 0;\n }\n for (int i = 0; i < h; i++) {\n for (int j = 0; j < w; j++) {\n Pair p = new Pair(i, j);\n int val = in.nextInt();\n hm.put(val, p);\n }\n }\n\n for (int i = d + 1; i <= h * w; i++) {\n Pair p1 = new Pair(hm.get(i).x, hm.get(i).y);\n Pair p2 = new Pair(hm.get(i - d).x, hm.get(i - d).y);\n cumDist[i] = cumDist[i - d] + Pair.dist(p1, p2);\n }\n int q = in.nextInt();\n for (int i = 0; i < q; i++) {\n int st = in.nextInt();\n int en = in.nextInt();\n out.println(cumDist[en] - cumDist[st]);\n }\n }\n\n }\n\n static class Pair {\n int x;\n int y;\n\n public Pair(int x, int y) {\n this.x = x;\n this.y = y;\n }\n\n static int dist(Pair p1, Pair p2) {\n return Math.abs(p1.x - p2.x) + Math.abs(p1.y - p2.y);\n }\n\n }\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": 2087, "cpu_time_ms": 783, "memory_kb": 99804}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s868236269", "group_id": "codeNet:p03426", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.Iterator;\nimport java.util.AbstractSet;\nimport java.util.Set;\nimport java.awt.Point;\nimport java.util.InputMismatchException;\nimport java.util.Random;\nimport java.io.IOException;\nimport java.util.AbstractMap;\nimport java.util.Map;\nimport java.util.Map.Entry;\nimport java.util.NoSuchElementException;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author Pradyumn\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n FastReader in = new FastReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskD solver = new TaskD();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class TaskD {\n public void solve(int testNumber, FastReader in, PrintWriter out) {\n int h = in.nextInt();\n int w = in.nextInt();\n int D = in.nextInt();\n EHashMap map = new EHashMap<>();\n for (int i = 0; i < h; ++i) {\n for (int j = 0; j < w; ++j) {\n map.put(in.nextInt(), new Point(i + 1, j + 1));\n }\n }\n int[][] pre = new int[h * w + 1][h * w + 1];\n ArrayUtils.fill(pre, -1);\n int Q = in.nextInt();\n for (int q = 0; q < Q; ++q) {\n int l = in.nextInt();\n int r = in.nextInt();\n int sum = 0;\n int last = l;\n int ll = l;\n while (ll != r) {\n ll += D;\n Point pn = map.get(ll);\n Point pl = map.get(last);\n if (pre[last][r] != -1) {\n sum += pre[last][r];\n break;\n }\n last = ll;\n pre[l][ll] = sum;\n sum += Math.abs(pn.x - pl.x) + Math.abs(pn.y - pl.y);\n }\n out.println(sum);\n }\n }\n\n }\n\n static class EHashMap extends AbstractMap {\n private final int[] shifts = new int[10];\n private int size;\n private HashEntry[] data;\n private int capacity;\n private Set> entrySet;\n\n {\n Random random = new Random(System.currentTimeMillis());\n for (int i = 0; i < 10; i++) {\n shifts[i] = 1 + 3 * i + random.nextInt(3);\n }\n }\n\n public EHashMap() {\n this(4);\n }\n\n private void setCapacity(int size) {\n capacity = Integer.highestOneBit(4 * size);\n data = new HashEntry[capacity];\n }\n\n public EHashMap(int maxSize) {\n setCapacity(maxSize);\n entrySet = new AbstractSet>() {\n\n public Iterator> iterator() {\n return new Iterator>() {\n private HashEntry last = null;\n private HashEntry current = null;\n private HashEntry base = null;\n private int lastIndex = -1;\n private int index = -1;\n\n public boolean hasNext() {\n if (current == null) {\n for (index++; index < capacity; index++) {\n if (data[index] != null) {\n base = current = data[index];\n break;\n }\n }\n }\n return current != null;\n }\n\n public Entry next() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n last = current;\n lastIndex = index;\n current = current.next;\n if (base.next != last) {\n base = base.next;\n }\n return last;\n }\n\n public void remove() {\n if (last == null) {\n throw new IllegalStateException();\n }\n size--;\n if (base == last) {\n data[lastIndex] = last.next;\n } else {\n base.next = last.next;\n }\n }\n };\n }\n\n\n public int size() {\n return size;\n }\n };\n }\n\n public EHashMap(Map map) {\n this(map.size());\n putAll(map);\n }\n\n\n public Set> entrySet() {\n return entrySet;\n }\n\n\n public void clear() {\n Arrays.fill(data, null);\n size = 0;\n }\n\n private int index(Object o) {\n return getHash(o.hashCode()) & (capacity - 1);\n }\n\n private int getHash(int h) {\n int result = h;\n for (int i : shifts) {\n result ^= h >>> i;\n }\n return result;\n }\n\n\n public V remove(Object o) {\n if (o == null) {\n return null;\n }\n int index = index(o);\n HashEntry current = data[index];\n HashEntry last = null;\n while (current != null) {\n if (current.key.equals(o)) {\n if (last == null) {\n data[index] = current.next;\n } else {\n last.next = current.next;\n }\n size--;\n return current.value;\n }\n last = current;\n current = current.next;\n }\n return null;\n }\n\n\n public V put(E e, V value) {\n if (e == null) {\n return null;\n }\n int index = index(e);\n HashEntry current = data[index];\n if (current != null) {\n while (true) {\n if (current.key.equals(e)) {\n V oldValue = current.value;\n current.value = value;\n return oldValue;\n }\n if (current.next == null) {\n break;\n }\n current = current.next;\n }\n }\n if (current == null) {\n data[index] = new HashEntry(e, value);\n } else {\n current.next = new HashEntry(e, value);\n }\n size++;\n if (2 * size > capacity) {\n HashEntry[] oldData = data;\n setCapacity(size);\n for (HashEntry entry : oldData) {\n while (entry != null) {\n HashEntry next = entry.next;\n index = index(entry.key);\n entry.next = data[index];\n data[index] = entry;\n entry = next;\n }\n }\n }\n return null;\n }\n\n\n public V get(Object o) {\n if (o == null) {\n return null;\n }\n int index = index(o);\n HashEntry current = data[index];\n while (current != null) {\n if (current.key.equals(o)) {\n return current.value;\n }\n current = current.next;\n }\n return null;\n }\n\n\n public boolean containsKey(Object o) {\n if (o == null) {\n return false;\n }\n int index = index(o);\n HashEntry current = data[index];\n while (current != null) {\n if (current.key.equals(o)) {\n return true;\n }\n current = current.next;\n }\n return false;\n }\n\n\n public int size() {\n return size;\n }\n\n private class HashEntry implements Entry {\n private final E key;\n private V value;\n private HashEntry next;\n\n private HashEntry(E key, V value) {\n this.key = key;\n this.value = value;\n }\n\n public E getKey() {\n return key;\n }\n\n public V getValue() {\n return value;\n }\n\n public V setValue(V value) {\n V oldValue = this.value;\n this.value = value;\n return oldValue;\n }\n\n }\n\n }\n\n static class ArrayUtils {\n public static void fill(int[][] array, int value) {\n for (int[] row : array) {\n Arrays.fill(row, value);\n }\n }\n\n }\n\n static class FastReader {\n private InputStream stream;\n private byte[] buf = new byte[8192];\n private int curChar;\n private int pnumChars;\n\n public FastReader(InputStream stream) {\n this.stream = stream;\n }\n\n private int pread() {\n if (pnumChars == -1) {\n throw new InputMismatchException();\n }\n if (curChar >= pnumChars) {\n curChar = 0;\n try {\n pnumChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (pnumChars <= 0) {\n return -1;\n }\n }\n return buf[curChar++];\n }\n\n public int nextInt() {\n int c = pread();\n while (isSpaceChar(c))\n c = pread();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = pread();\n }\n int res = 0;\n do {\n if (c == ',') {\n c = pread();\n }\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n res *= 10;\n res += c - '0';\n c = pread();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n\n private boolean isSpaceChar(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1520216675, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03426.html", "problem_id": "p03426", "resource_group": "high_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/Java/s868236269.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s868236269", "user_id": "u841100466"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.Iterator;\nimport java.util.AbstractSet;\nimport java.util.Set;\nimport java.awt.Point;\nimport java.util.InputMismatchException;\nimport java.util.Random;\nimport java.io.IOException;\nimport java.util.AbstractMap;\nimport java.util.Map;\nimport java.util.Map.Entry;\nimport java.util.NoSuchElementException;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author Pradyumn\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n FastReader in = new FastReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskD solver = new TaskD();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class TaskD {\n public void solve(int testNumber, FastReader in, PrintWriter out) {\n int h = in.nextInt();\n int w = in.nextInt();\n int D = in.nextInt();\n EHashMap map = new EHashMap<>();\n for (int i = 0; i < h; ++i) {\n for (int j = 0; j < w; ++j) {\n map.put(in.nextInt(), new Point(i + 1, j + 1));\n }\n }\n int[][] pre = new int[h * w + 1][h * w + 1];\n ArrayUtils.fill(pre, -1);\n int Q = in.nextInt();\n for (int q = 0; q < Q; ++q) {\n int l = in.nextInt();\n int r = in.nextInt();\n int sum = 0;\n int last = l;\n int ll = l;\n while (ll != r) {\n ll += D;\n Point pn = map.get(ll);\n Point pl = map.get(last);\n if (pre[last][r] != -1) {\n sum += pre[last][r];\n break;\n }\n last = ll;\n pre[l][ll] = sum;\n sum += Math.abs(pn.x - pl.x) + Math.abs(pn.y - pl.y);\n }\n out.println(sum);\n }\n }\n\n }\n\n static class EHashMap extends AbstractMap {\n private final int[] shifts = new int[10];\n private int size;\n private HashEntry[] data;\n private int capacity;\n private Set> entrySet;\n\n {\n Random random = new Random(System.currentTimeMillis());\n for (int i = 0; i < 10; i++) {\n shifts[i] = 1 + 3 * i + random.nextInt(3);\n }\n }\n\n public EHashMap() {\n this(4);\n }\n\n private void setCapacity(int size) {\n capacity = Integer.highestOneBit(4 * size);\n data = new HashEntry[capacity];\n }\n\n public EHashMap(int maxSize) {\n setCapacity(maxSize);\n entrySet = new AbstractSet>() {\n\n public Iterator> iterator() {\n return new Iterator>() {\n private HashEntry last = null;\n private HashEntry current = null;\n private HashEntry base = null;\n private int lastIndex = -1;\n private int index = -1;\n\n public boolean hasNext() {\n if (current == null) {\n for (index++; index < capacity; index++) {\n if (data[index] != null) {\n base = current = data[index];\n break;\n }\n }\n }\n return current != null;\n }\n\n public Entry next() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n last = current;\n lastIndex = index;\n current = current.next;\n if (base.next != last) {\n base = base.next;\n }\n return last;\n }\n\n public void remove() {\n if (last == null) {\n throw new IllegalStateException();\n }\n size--;\n if (base == last) {\n data[lastIndex] = last.next;\n } else {\n base.next = last.next;\n }\n }\n };\n }\n\n\n public int size() {\n return size;\n }\n };\n }\n\n public EHashMap(Map map) {\n this(map.size());\n putAll(map);\n }\n\n\n public Set> entrySet() {\n return entrySet;\n }\n\n\n public void clear() {\n Arrays.fill(data, null);\n size = 0;\n }\n\n private int index(Object o) {\n return getHash(o.hashCode()) & (capacity - 1);\n }\n\n private int getHash(int h) {\n int result = h;\n for (int i : shifts) {\n result ^= h >>> i;\n }\n return result;\n }\n\n\n public V remove(Object o) {\n if (o == null) {\n return null;\n }\n int index = index(o);\n HashEntry current = data[index];\n HashEntry last = null;\n while (current != null) {\n if (current.key.equals(o)) {\n if (last == null) {\n data[index] = current.next;\n } else {\n last.next = current.next;\n }\n size--;\n return current.value;\n }\n last = current;\n current = current.next;\n }\n return null;\n }\n\n\n public V put(E e, V value) {\n if (e == null) {\n return null;\n }\n int index = index(e);\n HashEntry current = data[index];\n if (current != null) {\n while (true) {\n if (current.key.equals(e)) {\n V oldValue = current.value;\n current.value = value;\n return oldValue;\n }\n if (current.next == null) {\n break;\n }\n current = current.next;\n }\n }\n if (current == null) {\n data[index] = new HashEntry(e, value);\n } else {\n current.next = new HashEntry(e, value);\n }\n size++;\n if (2 * size > capacity) {\n HashEntry[] oldData = data;\n setCapacity(size);\n for (HashEntry entry : oldData) {\n while (entry != null) {\n HashEntry next = entry.next;\n index = index(entry.key);\n entry.next = data[index];\n data[index] = entry;\n entry = next;\n }\n }\n }\n return null;\n }\n\n\n public V get(Object o) {\n if (o == null) {\n return null;\n }\n int index = index(o);\n HashEntry current = data[index];\n while (current != null) {\n if (current.key.equals(o)) {\n return current.value;\n }\n current = current.next;\n }\n return null;\n }\n\n\n public boolean containsKey(Object o) {\n if (o == null) {\n return false;\n }\n int index = index(o);\n HashEntry current = data[index];\n while (current != null) {\n if (current.key.equals(o)) {\n return true;\n }\n current = current.next;\n }\n return false;\n }\n\n\n public int size() {\n return size;\n }\n\n private class HashEntry implements Entry {\n private final E key;\n private V value;\n private HashEntry next;\n\n private HashEntry(E key, V value) {\n this.key = key;\n this.value = value;\n }\n\n public E getKey() {\n return key;\n }\n\n public V getValue() {\n return value;\n }\n\n public V setValue(V value) {\n V oldValue = this.value;\n this.value = value;\n return oldValue;\n }\n\n }\n\n }\n\n static class ArrayUtils {\n public static void fill(int[][] array, int value) {\n for (int[] row : array) {\n Arrays.fill(row, value);\n }\n }\n\n }\n\n static class FastReader {\n private InputStream stream;\n private byte[] buf = new byte[8192];\n private int curChar;\n private int pnumChars;\n\n public FastReader(InputStream stream) {\n this.stream = stream;\n }\n\n private int pread() {\n if (pnumChars == -1) {\n throw new InputMismatchException();\n }\n if (curChar >= pnumChars) {\n curChar = 0;\n try {\n pnumChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (pnumChars <= 0) {\n return -1;\n }\n }\n return buf[curChar++];\n }\n\n public int nextInt() {\n int c = pread();\n while (isSpaceChar(c))\n c = pread();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = pread();\n }\n int res = 0;\n do {\n if (c == ',') {\n c = pread();\n }\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n res *= 10;\n res += c - '0';\n c = pread();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n\n private boolean isSpaceChar(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n }\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": 11262, "cpu_time_ms": 1141, "memory_kb": 958612}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s045648179", "group_id": "codeNet:p03427", "input_text": "import java.util.*;\n\nimport static java.lang.System.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String N = sc.next();\n\n int[] arr = new int[N.length()];\n for (int i = 0; i < N.length(); i++) {\n arr[i] = N.charAt(i) - '0';\n }\n\n int max = 0;\n for (int i = 0; i < arr.length && arr[i] != 0; i++) {\n int tmp = 0;\n for (int j = 0; j < arr.length; j++) {\n if (i == j) {\n tmp += arr[j] - 1;\n tmp += (arr.length - j - 1) * 9;\n break;\n } else {\n tmp += arr[j];\n }\n }\n max = Math.max(max, tmp);\n }\n\n out.println(max);\n }\n}", "language": "Java", "metadata": {"date": 1555181099, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03427.html", "problem_id": "p03427", "resource_group": "high_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/Java/s045648179.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s045648179", "user_id": "u925940521"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "import java.util.*;\n\nimport static java.lang.System.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String N = sc.next();\n\n int[] arr = new int[N.length()];\n for (int i = 0; i < N.length(); i++) {\n arr[i] = N.charAt(i) - '0';\n }\n\n int max = 0;\n for (int i = 0; i < arr.length && arr[i] != 0; i++) {\n int tmp = 0;\n for (int j = 0; j < arr.length; j++) {\n if (i == j) {\n tmp += arr[j] - 1;\n tmp += (arr.length - j - 1) * 9;\n break;\n } else {\n tmp += arr[j];\n }\n }\n max = Math.max(max, tmp);\n }\n\n out.println(max);\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": 818, "cpu_time_ms": 96, "memory_kb": 21716}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s756956951", "group_id": "codeNet:p03433", "input_text": "import java.util.*;\nclass Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint a = sc.nextInt();\n\t\tif ((n % 500) == 0 || (n % 500) == a){\n\t\t\tSystem.out.println(\"Yes\");\n\t\t} else {\n\t\t\tSystem.out.println(\"No\");\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1585424271, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03433.html", "problem_id": "p03433", "resource_group": "high_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/Java/s756956951.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s756956951", "user_id": "u499587940"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*;\nclass Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint a = sc.nextInt();\n\t\tif ((n % 500) == 0 || (n % 500) == a){\n\t\t\tSystem.out.println(\"Yes\");\n\t\t} else {\n\t\t\tSystem.out.println(\"No\");\n\t\t}\n\t}\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": 279, "cpu_time_ms": 93, "memory_kb": 21716}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s725656644", "group_id": "codeNet:p03433", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tprivate static Scanner sc;\n\n\tpublic static void main(String[] args) {\n\n\t\tsc = new Scanner(System.in);\n\n\t\tint b = sc.nextInt() % 500;\n\n\t\tif (b <= sc.nextInt()) {\n\t\t\t System.out.print(\"Yes\");\n\t\t} else {\n\t\t\t System.out.print(\"No\");\n\t\t}\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1551807487, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03433.html", "problem_id": "p03433", "resource_group": "high_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/Java/s725656644.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s725656644", "user_id": "u434997850"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tprivate static Scanner sc;\n\n\tpublic static void main(String[] args) {\n\n\t\tsc = new Scanner(System.in);\n\n\t\tint b = sc.nextInt() % 500;\n\n\t\tif (b <= sc.nextInt()) {\n\t\t\t System.out.print(\"Yes\");\n\t\t} else {\n\t\t\t System.out.print(\"No\");\n\t\t}\n\t}\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": 288, "cpu_time_ms": 95, "memory_kb": 25300}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s784911807", "group_id": "codeNet:p03433", "input_text": "import java.util.Scanner;\nimport java.util.Arrays;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n long N = sc.nextInt();\n long A = sc.nextInt();\n long i;\n while(N>500){\n N=N-500;\n }\n if (A > N) {\n System.out.println(\"Yes\");\n } else {\n System.out.println(\"No\");\n }\n }\n}", "language": "Java", "metadata": {"date": 1519005946, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03433.html", "problem_id": "p03433", "resource_group": "high_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/Java/s784911807.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s784911807", "user_id": "u568545273"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\nimport java.util.Arrays;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n long N = sc.nextInt();\n long A = sc.nextInt();\n long i;\n while(N>500){\n N=N-500;\n }\n if (A > N) {\n System.out.println(\"Yes\");\n } else {\n System.out.println(\"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": 426, "cpu_time_ms": 110, "memory_kb": 21972}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s934912004", "group_id": "codeNet:p03434", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int[] array = new int[100];\n \n int difference = 0;\n for(int i = 0; i < N; i++){\n array[i] = sc.nextInt();\n }\n Arrays.sort(array);\n \n int Alice = 0;\n int Bob = 0;\n for(int i = 99; i > 99-N; i--){\n if(i % 2 ==1){\n Alice += array[i];\n }else{\n Bob += array[i];\n }\n }\n System.out.println(Alice-Bob);\n }\n}", "language": "Java", "metadata": {"date": 1570595547, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03434.html", "problem_id": "p03434", "resource_group": "high_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/Java/s934912004.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s934912004", "user_id": "u687188289"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int[] array = new int[100];\n \n int difference = 0;\n for(int i = 0; i < N; i++){\n array[i] = sc.nextInt();\n }\n Arrays.sort(array);\n \n int Alice = 0;\n int Bob = 0;\n for(int i = 99; i > 99-N; i--){\n if(i % 2 ==1){\n Alice += array[i];\n }else{\n Bob += array[i];\n }\n }\n System.out.println(Alice-Bob);\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": 522, "cpu_time_ms": 109, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s544029143", "group_id": "codeNet:p03434", "input_text": "\n\nimport java.io.*;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.StringTokenizer;\n\npublic class Main {\n public static void main(String[] args) throws IOException {\n FastScanner in = new FastScanner();\n int N = in.nextInt();\n ArrayList cards = new ArrayList<>();\n\n\n for (int i =0; i < N; i++)\n {\n cards.add(in.nextInt());\n }\n\n Collections.sort(cards,Collections.reverseOrder());\n\n int Maxscore = 0;\n\n for (int i =0; i < cards.size(); i ++)\n {\n if (i%2==0)\n {\n Maxscore += cards.get(i);\n }\n else\n {\n Maxscore -= cards.get(i);\n }\n }\n }\n\n public static class FastScanner {\n BufferedReader br;\n StringTokenizer st;\n\n public FastScanner(String s) {\n try {\n br = new BufferedReader(new FileReader(s));\n } catch (FileNotFoundException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n }\n\n public FastScanner() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n\n String nextToken() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n String nextLine() {\n st = null;\n try {\n return br.readLine();\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n return null;\n }\n\n int nextInt() {\n return Integer.parseInt(nextToken());\n }\n\n long nextLong() {\n return Long.parseLong(nextToken());\n }\n\n double nextDouble() {\n return Double.parseDouble(nextToken());\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1519808056, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03434.html", "problem_id": "p03434", "resource_group": "high_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/Java/s544029143.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s544029143", "user_id": "u522305303"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\n\nimport java.io.*;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.StringTokenizer;\n\npublic class Main {\n public static void main(String[] args) throws IOException {\n FastScanner in = new FastScanner();\n int N = in.nextInt();\n ArrayList cards = new ArrayList<>();\n\n\n for (int i =0; i < N; i++)\n {\n cards.add(in.nextInt());\n }\n\n Collections.sort(cards,Collections.reverseOrder());\n\n int Maxscore = 0;\n\n for (int i =0; i < cards.size(); i ++)\n {\n if (i%2==0)\n {\n Maxscore += cards.get(i);\n }\n else\n {\n Maxscore -= cards.get(i);\n }\n }\n }\n\n public static class FastScanner {\n BufferedReader br;\n StringTokenizer st;\n\n public FastScanner(String s) {\n try {\n br = new BufferedReader(new FileReader(s));\n } catch (FileNotFoundException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n }\n\n public FastScanner() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n\n String nextToken() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n String nextLine() {\n st = null;\n try {\n return br.readLine();\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n return null;\n }\n\n int nextInt() {\n return Integer.parseInt(nextToken());\n }\n\n long nextLong() {\n return Long.parseLong(nextToken());\n }\n\n double nextDouble() {\n return Double.parseDouble(nextToken());\n }\n }\n}\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nWe have N cards. A number a_i is written on the i-th card.\n\nAlice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.\n\nThe game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.\n\nConstraints\n\nN is an integer between 1 and 100 (inclusive).\n\na_i \\ (1 \\leq i \\leq N) is an integer between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 a_3 ... a_N\n\nOutput\n\nPrint Alice's score minus Bob's score when both players take the optimal strategy to maximize their scores.\n\nSample Input 1\n\n2\n3 1\n\nSample Output 1\n\n2\n\nFirst, Alice will take the card with 3. Then, Bob will take the card with 1.\nThe difference of their scores will be 3 - 1 = 2.\n\nSample Input 2\n\n3\n2 7 4\n\nSample Output 2\n\n5\n\nFirst, Alice will take the card with 7. Then, Bob will take the card with 4. Lastly, Alice will take the card with 2. The difference of their scores will be 7 - 4 + 2 = 5. The difference of their scores will be 3 - 1 = 2.\n\nSample Input 3\n\n4\n20 18 2 18\n\nSample Output 3\n\n18", "sample_input": "2\n3 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03434", "source_text": "Score: 200 points\n\nProblem Statement\n\nWe have N cards. A number a_i is written on the i-th card.\n\nAlice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.\n\nThe game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.\n\nConstraints\n\nN is an integer between 1 and 100 (inclusive).\n\na_i \\ (1 \\leq i \\leq N) is an integer between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 a_3 ... a_N\n\nOutput\n\nPrint Alice's score minus Bob's score when both players take the optimal strategy to maximize their scores.\n\nSample Input 1\n\n2\n3 1\n\nSample Output 1\n\n2\n\nFirst, Alice will take the card with 3. Then, Bob will take the card with 1.\nThe difference of their scores will be 3 - 1 = 2.\n\nSample Input 2\n\n3\n2 7 4\n\nSample Output 2\n\n5\n\nFirst, Alice will take the card with 7. Then, Bob will take the card with 4. Lastly, Alice will take the card with 2. The difference of their scores will be 7 - 4 + 2 = 5. The difference of their scores will be 3 - 1 = 2.\n\nSample Input 3\n\n4\n20 18 2 18\n\nSample Output 3\n\n18", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2200, "cpu_time_ms": 83, "memory_kb": 25044}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s946080830", "group_id": "codeNet:p03435", "input_text": "import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args) throws Exception{\n\tScanner scn = new Scanner(System.in);\n\tint c = scn.nextInt();\n int check = 0;\n int[] a = new int[c];\n for(int i=0; i> q = new ArrayDeque<>();\n\t\tq.add(Arrays.asList(0,0));\n\t\t\n\t\tint[][] m = new int[H][W];\n\t\tm[0][0] = 1;\n\t\t\n\t\tint[] dw = {0, 1, 0, -1 };\n\t\tint[] dh = {-1, 0, 1, 0 };\n\t\t\n\t\twhile(!q.isEmpty()) {\n\t\t\tList l = q.poll();\n\t\t\tint h = l.get(0);\n\t\t\tint w = l.get(1);\n\t\t\t\n\t\t\tif(h==H-1 && w==W-1) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tfor(int i=0;i<4;i++) {\n\t\t\t\tint nh = h+dh[i];\n\t\t\t\tint nw = w+dw[i];\n\t\t\t\t\n\t\t\t\tif(nh>=0 && nh=0 && nw arr[i] ? candidate : arr[i];\n\t\t}\n\t\treturn candidate;\n\t}\n\n\t@SuppressWarnings(\"unused\")\n\tprivate long max(long[] arr) {\n\t\tif(arr == null || arr.length == 0) {\n\t\t\tthrow new IllegalArgumentException(Arrays.toString(arr));\n\t\t}\n\n\t\tlong candidate = arr[0];\n\t\tfor(int i=1;i arr[i] ? candidate : arr[i];\n\t\t}\n\t\treturn candidate;\n\t}\n\n\t@SuppressWarnings(\"unused\")\n\tprivate int min(int[] arr) {\n\t\tif(arr == null || arr.length == 0) {\n\t\t\tthrow new IllegalArgumentException(Arrays.toString(arr));\n\t\t}\n\n\t\tint candidate = arr[0];\n\t\tfor(int i=1;i> q = new ArrayDeque<>();\n\t\tq.add(Arrays.asList(0,0));\n\t\t\n\t\tint[][] m = new int[H][W];\n\t\tm[0][0] = 1;\n\t\t\n\t\tint[] dw = {0, 1, 0, -1 };\n\t\tint[] dh = {-1, 0, 1, 0 };\n\t\t\n\t\twhile(!q.isEmpty()) {\n\t\t\tList l = q.poll();\n\t\t\tint h = l.get(0);\n\t\t\tint w = l.get(1);\n\t\t\t\n\t\t\tif(h==H-1 && w==W-1) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tfor(int i=0;i<4;i++) {\n\t\t\t\tint nh = h+dh[i];\n\t\t\t\tint nw = w+dw[i];\n\t\t\t\t\n\t\t\t\tif(nh>=0 && nh=0 && nw arr[i] ? candidate : arr[i];\n\t\t}\n\t\treturn candidate;\n\t}\n\n\t@SuppressWarnings(\"unused\")\n\tprivate long max(long[] arr) {\n\t\tif(arr == null || arr.length == 0) {\n\t\t\tthrow new IllegalArgumentException(Arrays.toString(arr));\n\t\t}\n\n\t\tlong candidate = arr[0];\n\t\tfor(int i=1;i arr[i] ? candidate : arr[i];\n\t\t}\n\t\treturn candidate;\n\t}\n\n\t@SuppressWarnings(\"unused\")\n\tprivate int min(int[] arr) {\n\t\tif(arr == null || arr.length == 0) {\n\t\t\tthrow new IllegalArgumentException(Arrays.toString(arr));\n\t\t}\n\n\t\tint candidate = arr[0];\n\t\tfor(int i=1;i q = new ArrayDeque<>();\n q.add(new Node(0, 0, 0));\n Set visited = new HashSet<>();\n int[][] dirs = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}};\n\n int cost = 0;\n while (!q.isEmpty()) {\n Node n = q.poll();\n if (n.h == H - 1 && n.w == W - 1) {\n cost = n.c;\n break;\n }\n String s = String.format(\"%d:%d\", n.h, n.w);\n if (visited.contains(s)) {\n continue;\n }\n visited.add(s);\n for (int[] d: dirs) {\n int nh = n.h + d[0];\n int nw = n.w + d[1];\n if (nh >= 0 && nh < H && nw >= 0 && nw < W && grid[nh][nw] == '.') {\n q.add(new Node(nh, nw, n.c + 1));\n }\n }\n }\n\n int w = 0;\n for (char[] l: grid)\n for (char n: l)\n if (n == '.') {\n w++;\n }\n\n System.out.println(w - cost - 1);\n }\n\n}", "language": "Java", "metadata": {"date": 1573125006, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03436.html", "problem_id": "p03436", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03436/input.txt", "sample_output_relpath": "derived/input_output/data/p03436/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03436/Java/s664642956.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s664642956", "user_id": "u241874341"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.math.BigDecimal;\nimport java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) {\n final Scanner scanner = new Scanner(System.in);\n solve(scanner);\n }\n\n static class Period {\n int s;\n int e;\n\n public Period(int s, int e) {\n this.s = s;\n this.e = e;\n }\n }\n\n static class Node {\n int h;\n int w;\n int c;\n\n public Node(int h, int w, int c) {\n this.h = h;\n this.w = w;\n this.c = c;\n }\n }\n\n static void solve(Scanner scanner) {\n int H = scanner.nextInt(), W = scanner.nextInt();\n scanner.nextLine();\n char[][] grid = new char[H][W];\n for (int i = 0; i < H; i++) {\n grid[i] = scanner.nextLine().toCharArray();\n }\n\n Queue q = new ArrayDeque<>();\n q.add(new Node(0, 0, 0));\n Set visited = new HashSet<>();\n int[][] dirs = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}};\n\n int cost = 0;\n while (!q.isEmpty()) {\n Node n = q.poll();\n if (n.h == H - 1 && n.w == W - 1) {\n cost = n.c;\n break;\n }\n String s = String.format(\"%d:%d\", n.h, n.w);\n if (visited.contains(s)) {\n continue;\n }\n visited.add(s);\n for (int[] d: dirs) {\n int nh = n.h + d[0];\n int nw = n.w + d[1];\n if (nh >= 0 && nh < H && nw >= 0 && nw < W && grid[nh][nw] == '.') {\n q.add(new Node(nh, nw, n.c + 1));\n }\n }\n }\n\n int w = 0;\n for (char[] l: grid)\n for (char n: l)\n if (n == '.') {\n w++;\n }\n\n System.out.println(w - cost - 1);\n }\n\n}", "problem_context": "Score: 400 points\n\nProblem statement\n\nWe have an H \\times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j).\n\nSnuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares.\n\nBefore Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game.\n\nWhen the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares.\n\nThe color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is .; if square (i, j) is initially painted by black, s_{i, j} is #.\n\nConstraints\n\nH is an integer between 2 and 50 (inclusive).\n\nW is an integer between 2 and 50 (inclusive).\n\ns_{i, j} is . or # (1 \\leq i \\leq H, 1 \\leq j \\leq W).\n\ns_{1, 1} and s_{H, W} are ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1}s_{1, 2}s_{1, 3} ... s_{1, W}\ns_{2, 1}s_{2, 2}s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1}s_{H, 2}s_{H, 3} ... s_{H, W}\n\nOutput\n\nPrint the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed.\n\nSample Input 1\n\n3 3\n..#\n#..\n...\n\nSample Output 1\n\n2\n\nThe score 2 can be achieved by changing the color of squares as follows:\n\nSample Input 2\n\n10 37\n.....................................\n...#...####...####..###...###...###..\n..#.#..#...#.##....#...#.#...#.#...#.\n..#.#..#...#.#.....#...#.#...#.#...#.\n.#...#.#..##.#.....#...#.#.###.#.###.\n.#####.####..#.....#...#..##....##...\n.#...#.#...#.#.....#...#.#...#.#...#.\n.#...#.#...#.##....#...#.#...#.#...#.\n.#...#.####...####..###...###...###..\n.....................................\n\nSample Output 2\n\n209", "sample_input": "3 3\n..#\n#..\n...\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03436", "source_text": "Score: 400 points\n\nProblem statement\n\nWe have an H \\times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j).\n\nSnuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares.\n\nBefore Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game.\n\nWhen the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares.\n\nThe color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is .; if square (i, j) is initially painted by black, s_{i, j} is #.\n\nConstraints\n\nH is an integer between 2 and 50 (inclusive).\n\nW is an integer between 2 and 50 (inclusive).\n\ns_{i, j} is . or # (1 \\leq i \\leq H, 1 \\leq j \\leq W).\n\ns_{1, 1} and s_{H, W} are ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1}s_{1, 2}s_{1, 3} ... s_{1, W}\ns_{2, 1}s_{2, 2}s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1}s_{H, 2}s_{H, 3} ... s_{H, W}\n\nOutput\n\nPrint the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed.\n\nSample Input 1\n\n3 3\n..#\n#..\n...\n\nSample Output 1\n\n2\n\nThe score 2 can be achieved by changing the color of squares as follows:\n\nSample Input 2\n\n10 37\n.....................................\n...#...####...####..###...###...###..\n..#.#..#...#.##....#...#.#...#.#...#.\n..#.#..#...#.#.....#...#.#...#.#...#.\n.#...#.#..##.#.....#...#.#.###.#.###.\n.#####.####..#.....#...#..##....##...\n.#...#.#...#.#.....#...#.#...#.#...#.\n.#...#.#...#.##....#...#.#...#.#...#.\n.#...#.####...####..###...###...###..\n.....................................\n\nSample Output 2\n\n209", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1875, "cpu_time_ms": 266, "memory_kb": 33876}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s918347237", "group_id": "codeNet:p03437", "input_text": "//package javaapplication1;\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.PrintStream;\nimport java.io.PrintWriter;\nimport java.lang.reflect.Array;\nimport static java.lang.reflect.Array.set;\nimport java.math.BigInteger;\nimport java.util.AbstractList;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.Date;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Random;\nimport java.util.Scanner;\nimport java.util.Set;\nimport java.util.Stack;\nimport java.util.StringTokenizer;\nimport static jdk.nashorn.internal.objects.Global.Infinity;\nimport static jdk.nashorn.internal.objects.NativeMath.round;\nimport sun.awt.HKSCS;\n\n/*\n PARTIAL AUTHOR GEORGE\n MAINLY GEEKSFORGEEKS ALL RIGHTS RESERVED.\n*/\npublic class Main {\n static boolean isSubSequence(String str1, String str2, int m, int n)\n {\n \n if (m == 0) \n return true;\n if (n == 0) \n return false;\n \n \n if (str1.charAt(m-1) == str2.charAt(n-1))\n return isSubSequence(str1, str2, m-1, n-1);\n \n \n return isSubSequence(str1, str2, m, n-1);\n }\n\n public static void main(String[] args) throws IOException{\n BufferedReader BR=new BufferedReader(new InputStreamReader(System.in));\n PrintWriter PW=new PrintWriter(new PrintStream(System.out));\n In IN=new In(BR);\n Out OUT=new Out(PW);\n Scanner SC=new Scanner(System.in);\n //DataStructure DS=new DataStructure();\n Functions F=new Functions();\n //QuickSort QS=new QuickSort();\n //BinarySearch BS=new BinarySearch();\n //FIB fubbonanci=new FIB(93);\n //Map>Pos=new HashMap<>();\n //Setans=new HashSet<>();\n //StringPermutationGenerator SPG=new StringPermutationGenerator();\n long n,m;\n n=IN.nextLong();\n m=IN.nextLong();\n for (long i = n; i <=Math.pow(10, 18); i*=n) {\n if(i%m!=0){System.out.println(i);System.exit(0);}\n }\n for (long i = m; i <=Math.pow(10, 18); i*=m) {\n if(i%n!=0){System.out.println(i);System.exit(0);}\n }\n System.out.println(-1);\n }\n\n protected static class In {\n private BufferedReader reader;\n private StringTokenizer tokenizer = new StringTokenizer(\"\");\n public In(BufferedReader reader) {\n this.reader = reader;\n }\n \n public String next() throws IOException {\n while (!tokenizer.hasMoreTokens())\n tokenizer = new StringTokenizer(reader.readLine());\n return tokenizer.nextToken();\n }\n\n public int nextInt() throws IOException {\n return Integer.parseInt(next());\n }\n\n public long nextLong() throws IOException {\n return Long.parseLong(next());\n }\n\n public double nextDouble() throws IOException {\n return Double.parseDouble(next());\n }\n\n public int[] nextIntArray(int n) throws IOException {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = nextInt();\n return a;\n }\n\n public int[] nextIntArray1(int n) throws IOException {\n int[] a = new int[n + 1];\n for (int i = 1; i <= n; i++)\n a[i] = nextInt();\n return a;\n }\n\n public int[] nextIntArraySorted(int n) throws IOException {\n int[] a = nextIntArray(n);\n Random r = new Random();\n for (int i = 0; i < n; i++) {\n int j = i + r.nextInt(n - i);\n int t = a[i];\n a[i] = a[j];\n a[j] = t;\n }\n Arrays.sort(a);\n return a;\n }\n\n public long[] nextLongArray(int n) throws IOException {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = nextLong();\n return a;\n }\n\n public long[] nextLongArray1(int n) throws IOException {\n long[] a = new long[n + 1];\n for (int i = 1; i <= n; i++)\n a[i] = nextLong();\n return a;\n }\n\n public long[] nextLongArraySorted(int n) throws IOException {\n long[] a = nextLongArray(n);\n Random r = new Random();\n for (int i = 0; i < n; i++) {\n int j = i + r.nextInt(n - i);\n long t = a[i];\n a[i] = a[j];\n a[j] = t;\n }\n Arrays.sort(a);\n return a;\n }\n }\n protected static class Out {\n private PrintWriter writer;\n private static boolean local = System\n .getProperty(\"ONLINE_JUDGE\") == null;\n\n public Out(PrintWriter writer) {\n this.writer = writer;\n }\n\n public void print(char c) {\n writer.print(c);\n }\n\n public void print(int a) {\n writer.print(a);\n }\n\n public void println(Object a) {\n writer.println(a);\n }\n\n public void println(Object[] os) {\n for (int i = 0; i < os.length; i++) {\n writer.print(os[i]);\n writer.print(' ');\n }\n writer.println();\n }\n\n public void println(int[] a) {\n for (int i = 0; i < a.length; i++) {\n writer.print(a[i]);\n writer.print(' ');\n }\n writer.println();\n }\n\n public void println(long[] a) {\n for (int i = 0; i < a.length; i++) {\n writer.print(a[i]);\n writer.print(' ');\n }\n writer.println();\n }\n\n public static void db(Object... objects) {\n if (local)\n System.out.println(Arrays.deepToString(objects));\n }\n }\n public static class QuickSort{ \n protected static int [] intArray;\n protected static long [] longArray;\n protected static double [] DoubleArray;\n protected static char [] charArray;\n protected static int Size;\n public QuickSort() {\n }\n \n protected static int partition(int arr[],int low,int high)\n {\n int pivot=arr[high];\n int i=low-1;\n int temp=0;\n for (int j = low; j < high; ++j) {\n if(arr[j]<=pivot)\n {\n ++i;\n temp = arr[i];\n arr[i] = arr[j];\n arr[j] = temp;\n }\n }\n temp = arr[i+1];\n arr[i+1] = arr[high];\n arr[high] = temp;\n return i+1;\n \n }\n protected static int partition(long arr[],int low,int high)\n {\n long pivot=arr[high];\n int i=low-1;\n long temp=0;\n for (int j = low; j < high; ++j) {\n if(arr[j]<=pivot)\n {\n ++i;\n temp = arr[i];\n arr[i] = arr[j];\n arr[j] = temp;\n }\n }\n temp = arr[i+1];\n arr[i+1] = arr[high];\n arr[high] = temp;\n return i+1;\n \n }\n protected static int partition(double arr[],int low,int high)\n {\n double pivot=arr[high];\n int i=low-1;\n double temp=0;\n for (int j = low; j < high; ++j) {\n if(arr[j]<=pivot)\n {\n ++i;\n temp = arr[i];\n arr[i] = arr[j];\n arr[j] = temp;\n }\n }\n temp = arr[i+1];\n arr[i+1] = arr[high];\n arr[high] = temp;\n return i+1;\n \n }\n protected static int partition(char arr[],int low,int high)\n {\n char pivot=arr[high];\n int i=low-1;\n char temp=0;\n for (int j = low; j < high; ++j) {\n if(arr[j]<=pivot)\n {\n ++i;\n temp = arr[i];\n arr[i] = arr[j];\n arr[j] = temp;\n }\n }\n temp = arr[i+1];\n arr[i+1] = arr[high];\n arr[high] = temp;\n return i+1;\n \n }\n protected static void sort(int arr[],int low, int high)\n {\n if(low < high)\n {\n int pi=partition(arr, low, high);\n sort(arr, low, pi-1);\n sort(arr, pi+1, high);\n \n }\n \n }\n protected static void sort(long arr[],int low, int high)\n {\n if(low < high)\n {\n int pi=partition(arr, low, high);\n sort(arr, low, pi-1);\n sort(arr, pi+1, high);\n \n }\n }\n\n protected static void sort(double arr[],int low, int high)\n {\n if(low < high)\n {\n int pi=partition(arr, low, high);\n sort(arr, low, pi-1);\n sort(arr, pi+1, high);\n \n }\n }\n protected static void sort(char arr[],int low, int high)\n {\n if(low < high)\n {\n int pi=partition(arr, low, high);\n sort(arr, low, pi-1);\n sort(arr, pi+1, high);\n \n }\n }\n protected static void printArray(int arr[])\n {\n int n = arr.length;\n for (int i=0; i i == key);\n }\n public static boolean contains(final long[] arr, final long key) {\n return Arrays.stream(arr).anyMatch(i -> i == key);\n }\n public static boolean contains(final double[] arr, final double key) {\n return Arrays.stream(arr).anyMatch(i -> i == key);\n }\n protected static long NCR(long N, long R){\n if(N < R)\n return 0;\n if(R == 0 || R == N)\n return 1;\n return NCR(N-1,R-1)+NCR(N-1,R);\n }\n protected static long NCR(int N, int R){\n if(N < R)\n return 0;\n if(R == 0 || R == N)\n return 1;\n return NCR(N-1,R-1)+NCR(N-1,R);\n }\n protected static String changeCharInPosition(int position, char ch, String str){\n char[] charArray = str.toCharArray();\n charArray[position] = ch;\n return new String(charArray);\n }\n protected static boolean isPrime(long n) {\n if(n < 2) return false;\n if(n == 2 || n == 3) return true;\n if(n%2 == 0 || n%3 == 0) return false;\n long sqrtN = (long)Math.sqrt(n)+1;\n for(long i = 6L; i <= sqrtN; i += 6) {\n if(n%(i-1) == 0 || n%(i+1) == 0) return false;\n }\n return true;\n }\n protected static long Gcd(long p, long q) {\n if (q == 0) return p;\n else return Gcd(q, p % q);\n }\n protected static boolean isPrime(int n) {\n if(n < 2) return false;\n if(n == 2 || n == 3) return true;\n if(n%2 == 0 || n%3 == 0) return false;\n int sqrtN = (int)Math.sqrt(n)+1;\n for(long i = 6L; i <= sqrtN; i += 6) {\n if(n%(i-1) == 0 || n%(i+1) == 0) return false;\n }\n return true;\n }\n }\n public static class BinarySearch{\n private static int middle;\n private static int L;\n private static int R;\n public BinarySearch() {\n \n }\n protected static int Search(int [] arr,int element){\n R=arr.length-1;\n L=0;\n return BS(arr, L, R, element);\n }\n protected static int Search(long [] arr,long element){\n R=arr.length-1;\n L=0;\n return BS(arr, L, R, element);\n }\n protected static int Search(char [] arr,char element){\n R=arr.length-1;\n L=0;\n return BS(arr, L, R, element);\n }\n protected static int Search(double [] arr,double element){\n R=arr.length-1;\n L=0;\n return BS(arr, L, R, element);\n }\n protected static int BS(int [] arr,int L,int R,int element){ \n if(R>=L) \n {\n middle=L+(R-L)/2; \n if(arr[middle]==element)\n { \n return middle;\n } \n else if(arr[middle]>element)\n {\n return BS(arr, L,middle-1, element);\n } \n else \n { \n return BS(arr, middle+1, R, element);\n } \n } \n else\n {\n return -1;\n }\n }\n protected static int BS(long [] arr,int L,int R,long element){ \n if(R>=L) \n {\n middle=L+(R-L)/2; \n if(arr[middle]==element)\n { \n return middle;\n } \n else if(arr[middle]>element)\n {\n return BS(arr, L,middle-1, element);\n } \n else \n { \n return BS(arr, middle+1, R, element);\n } \n } \n else\n {\n return -1;\n }\n }\n protected static int BS(char [] arr,int L,int R,char element){ \n if(R>=L) \n {\n middle=L+(R-L)/2; \n if(arr[middle]==element)\n { \n return middle;\n } \n else if(arr[middle]>element)\n {\n return BS(arr, L,middle-1, element);\n } \n else \n { \n return BS(arr, middle+1, R, element);\n } \n } \n else\n {\n return -1;\n }\n }\n protected static int BS(double [] arr,int L,int R,double element){ \n if(R>=L) \n {\n middle=L+(R-L)/2; \n if(arr[middle]==element)\n { \n return middle;\n } \n else if(arr[middle]>element)\n {\n return BS(arr, L,middle-1, element);\n } \n else \n { \n return BS(arr, middle+1, R, element);\n } \n } \n else\n {\n return -1;\n }\n }\n } \n public static class DataStructure{\n\n public DataStructure() {\n }\n \n \n static void stack_push(Stack stack)\n {\n for(int i = 0; i < 5; i++)\n {\n stack.push(i);\n }\n }\n \n \n // Popping element from the top of the stack\n static void stack_pop(Stack stack)\n {\n System.out.println(\"Pop :\");\n \n for(int i = 0; i < 5; i++)\n {\n Integer y = (Integer) stack.pop();\n System.out.println(y);\n }\n }\n \n // Displaying element on the top of the stack\n static void stack_peek(Stack stack)\n {\n Integer element = (Integer) stack.peek();\n System.out.println(\"Element on stack top : \" + element);\n }\n \n // Searching element in the stack\n static void stack_search(Stack stack, int element)\n {\n Integer pos = (Integer) stack.search(element);\n \n if(pos == -1)\n System.out.println(\"Element not found\");\n else\n System.out.println(\"Element is found at position \" + pos);\n }\n \n }\n public static class FIB {\n \n protected static int MAX = 1000;\n protected static long f[];\n protected static int size=0;\n // Returns n'th fibonacci number using \n // table f[]\n \n public FIB(int n)\n {\n f=new long[MAX];\n this.size=n;\n fib();\n }\n\n protected static void fib() {\n f[0]=0;f[1]=1;\n for (int i = 2; i < size; i++) {\n //if(f[i-1]+f[i-2]>Long.MAX_VALUE){f[i]=0;continue;}\n f[i]=f[i-1]+f[i-2];\n }\n }\n protected static void printSeries(){\n for (int i = 0; i generatePermutations(String input) {\n\n input = input.toLowerCase();\n Set result = new HashSet<>();\n permutations(\"\", input, result);\n return result;\n\n }\n private void permutations(String prefix, String letters, Set result) {\n\n if (letters.length() == 0) {\n\n result.add(prefix);\n\n } else {\n\n for (int i = 0; i < letters.length(); i++) {\n\n String letter = letters.substring(i, i + 1);\n\n String otherLetters = letters.substring(0, i) + letters.substring(i + 1);\n\n permutations(prefix + letter, otherLetters, result);\n\n }\n\n }\n\n }\n\n } \n}\n/*\nSome References for doing things \n-Removing all Leading zeros in a string \ns.replaceFirst(\"^0+(?!$)\", \"\");\n-Creating comprator\npublic static class CustomComparator implements Comparator {\n @Override\n public int compare(c o1, c o2) {\n return o1.score.compareTo(o2.score);\n }\n}\n-how to write switch case\n switch(x)\n {\n case 1:\n return l;\n ...\n default:\n return m;\n }\n-Convert numbers of and to different bases\n Integer.toString(Integer.parseInt(number, base1), base2);\n-Split over white spaces:\n myString.split(\"\\\\s+\");\n-how to know if 4 points will form a square or a rectangle:\n public static class point{\n int a,b;\n public point(int a, int b) {\n this.a = a;\n this.b = b;\n }\n\n @Override\n public String toString() {\n return \"point{\" + \"a=\" + a + \", b=\" + b + '}';\n }\n }\n public static int distSq(point p, point q)\n {\n return (p.a - q.a)*(p.a - q.a) +\n (p.b - q.b)*(p.b - q.b);\n }\n public static boolean isSquare(point p1, point p2, point p3, point p4)\n {\n int d2 = distSq(p1, p2); // from p1 to p2\n int d3 = distSq(p1, p3); // from p1 to p3\n int d4 = distSq(p1, p4); // from p1 to p4\n\n // If lengths if (p1, p2) and (p1, p3) are same, then\n // following conditions must met to form a square.\n // 1) Square of length of (p1, p4) is same as twice\n // the square of (p1, p2)\n // 2) p4 is at same distance from p2 and p3\n if (d2 == d3 && 2*d2 == d4)\n {\n int d = distSq(p2, p4);\n return (d == distSq(p3, p4) && d == d2);\n }\n\n // The below two cases are similar to above case\n if (d3 == d4 && 2*d3 == d2)\n {\n int d = distSq(p2, p3);\n return (d == distSq(p2, p4) && d == d3);\n }\n if (d2 == d4 && 2*d2 == d3)\n {\n int d = distSq(p2, p3);\n return (d == distSq(p3, p4) && d == d2);\n }\n\n return false;\n }\n public static boolean isRectangle(point p1,point p2,point p3,point p4)\n {\n double cx,cy;\n double dd1,dd2,dd3,dd4;\n double x1,y1,x2,y2,x3,y3,x4,y4;\n x1=p1.a;y1=p1.b;x2=p2.a;y2=p2.b;x3=p3.a;y3=p3.b;x4=p4.a;y4=p4.b;\n cx=(x1+x2+x3+x4)/4;\n cy=(y1+y2+y3+y4)/4;\n\n dd1=(cx-x1)*(cx-x1)+(cy-y1)*(cy-y1);\n dd2=(cx-x2)*(cx-x2)+(cy-y2)*(cy-y2);\n dd3=(cx-x3)*(cx-x3)+(cy-y3)*(cy-y3);\n dd4=(cx-x4)*(cx-x4)+(cy-y4)*(cy-y4);\n return dd1==dd2 && dd1==dd3 && dd1==dd4;\n }\n*/\n", "language": "Java", "metadata": {"date": 1517725347, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03437.html", "problem_id": "p03437", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03437/input.txt", "sample_output_relpath": "derived/input_output/data/p03437/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03437/Java/s918347237.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s918347237", "user_id": "u415306170"}, "prompt_components": {"gold_output": "16\n", "input_to_evaluate": "//package javaapplication1;\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.PrintStream;\nimport java.io.PrintWriter;\nimport java.lang.reflect.Array;\nimport static java.lang.reflect.Array.set;\nimport java.math.BigInteger;\nimport java.util.AbstractList;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.Date;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Random;\nimport java.util.Scanner;\nimport java.util.Set;\nimport java.util.Stack;\nimport java.util.StringTokenizer;\nimport static jdk.nashorn.internal.objects.Global.Infinity;\nimport static jdk.nashorn.internal.objects.NativeMath.round;\nimport sun.awt.HKSCS;\n\n/*\n PARTIAL AUTHOR GEORGE\n MAINLY GEEKSFORGEEKS ALL RIGHTS RESERVED.\n*/\npublic class Main {\n static boolean isSubSequence(String str1, String str2, int m, int n)\n {\n \n if (m == 0) \n return true;\n if (n == 0) \n return false;\n \n \n if (str1.charAt(m-1) == str2.charAt(n-1))\n return isSubSequence(str1, str2, m-1, n-1);\n \n \n return isSubSequence(str1, str2, m, n-1);\n }\n\n public static void main(String[] args) throws IOException{\n BufferedReader BR=new BufferedReader(new InputStreamReader(System.in));\n PrintWriter PW=new PrintWriter(new PrintStream(System.out));\n In IN=new In(BR);\n Out OUT=new Out(PW);\n Scanner SC=new Scanner(System.in);\n //DataStructure DS=new DataStructure();\n Functions F=new Functions();\n //QuickSort QS=new QuickSort();\n //BinarySearch BS=new BinarySearch();\n //FIB fubbonanci=new FIB(93);\n //Map>Pos=new HashMap<>();\n //Setans=new HashSet<>();\n //StringPermutationGenerator SPG=new StringPermutationGenerator();\n long n,m;\n n=IN.nextLong();\n m=IN.nextLong();\n for (long i = n; i <=Math.pow(10, 18); i*=n) {\n if(i%m!=0){System.out.println(i);System.exit(0);}\n }\n for (long i = m; i <=Math.pow(10, 18); i*=m) {\n if(i%n!=0){System.out.println(i);System.exit(0);}\n }\n System.out.println(-1);\n }\n\n protected static class In {\n private BufferedReader reader;\n private StringTokenizer tokenizer = new StringTokenizer(\"\");\n public In(BufferedReader reader) {\n this.reader = reader;\n }\n \n public String next() throws IOException {\n while (!tokenizer.hasMoreTokens())\n tokenizer = new StringTokenizer(reader.readLine());\n return tokenizer.nextToken();\n }\n\n public int nextInt() throws IOException {\n return Integer.parseInt(next());\n }\n\n public long nextLong() throws IOException {\n return Long.parseLong(next());\n }\n\n public double nextDouble() throws IOException {\n return Double.parseDouble(next());\n }\n\n public int[] nextIntArray(int n) throws IOException {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = nextInt();\n return a;\n }\n\n public int[] nextIntArray1(int n) throws IOException {\n int[] a = new int[n + 1];\n for (int i = 1; i <= n; i++)\n a[i] = nextInt();\n return a;\n }\n\n public int[] nextIntArraySorted(int n) throws IOException {\n int[] a = nextIntArray(n);\n Random r = new Random();\n for (int i = 0; i < n; i++) {\n int j = i + r.nextInt(n - i);\n int t = a[i];\n a[i] = a[j];\n a[j] = t;\n }\n Arrays.sort(a);\n return a;\n }\n\n public long[] nextLongArray(int n) throws IOException {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = nextLong();\n return a;\n }\n\n public long[] nextLongArray1(int n) throws IOException {\n long[] a = new long[n + 1];\n for (int i = 1; i <= n; i++)\n a[i] = nextLong();\n return a;\n }\n\n public long[] nextLongArraySorted(int n) throws IOException {\n long[] a = nextLongArray(n);\n Random r = new Random();\n for (int i = 0; i < n; i++) {\n int j = i + r.nextInt(n - i);\n long t = a[i];\n a[i] = a[j];\n a[j] = t;\n }\n Arrays.sort(a);\n return a;\n }\n }\n protected static class Out {\n private PrintWriter writer;\n private static boolean local = System\n .getProperty(\"ONLINE_JUDGE\") == null;\n\n public Out(PrintWriter writer) {\n this.writer = writer;\n }\n\n public void print(char c) {\n writer.print(c);\n }\n\n public void print(int a) {\n writer.print(a);\n }\n\n public void println(Object a) {\n writer.println(a);\n }\n\n public void println(Object[] os) {\n for (int i = 0; i < os.length; i++) {\n writer.print(os[i]);\n writer.print(' ');\n }\n writer.println();\n }\n\n public void println(int[] a) {\n for (int i = 0; i < a.length; i++) {\n writer.print(a[i]);\n writer.print(' ');\n }\n writer.println();\n }\n\n public void println(long[] a) {\n for (int i = 0; i < a.length; i++) {\n writer.print(a[i]);\n writer.print(' ');\n }\n writer.println();\n }\n\n public static void db(Object... objects) {\n if (local)\n System.out.println(Arrays.deepToString(objects));\n }\n }\n public static class QuickSort{ \n protected static int [] intArray;\n protected static long [] longArray;\n protected static double [] DoubleArray;\n protected static char [] charArray;\n protected static int Size;\n public QuickSort() {\n }\n \n protected static int partition(int arr[],int low,int high)\n {\n int pivot=arr[high];\n int i=low-1;\n int temp=0;\n for (int j = low; j < high; ++j) {\n if(arr[j]<=pivot)\n {\n ++i;\n temp = arr[i];\n arr[i] = arr[j];\n arr[j] = temp;\n }\n }\n temp = arr[i+1];\n arr[i+1] = arr[high];\n arr[high] = temp;\n return i+1;\n \n }\n protected static int partition(long arr[],int low,int high)\n {\n long pivot=arr[high];\n int i=low-1;\n long temp=0;\n for (int j = low; j < high; ++j) {\n if(arr[j]<=pivot)\n {\n ++i;\n temp = arr[i];\n arr[i] = arr[j];\n arr[j] = temp;\n }\n }\n temp = arr[i+1];\n arr[i+1] = arr[high];\n arr[high] = temp;\n return i+1;\n \n }\n protected static int partition(double arr[],int low,int high)\n {\n double pivot=arr[high];\n int i=low-1;\n double temp=0;\n for (int j = low; j < high; ++j) {\n if(arr[j]<=pivot)\n {\n ++i;\n temp = arr[i];\n arr[i] = arr[j];\n arr[j] = temp;\n }\n }\n temp = arr[i+1];\n arr[i+1] = arr[high];\n arr[high] = temp;\n return i+1;\n \n }\n protected static int partition(char arr[],int low,int high)\n {\n char pivot=arr[high];\n int i=low-1;\n char temp=0;\n for (int j = low; j < high; ++j) {\n if(arr[j]<=pivot)\n {\n ++i;\n temp = arr[i];\n arr[i] = arr[j];\n arr[j] = temp;\n }\n }\n temp = arr[i+1];\n arr[i+1] = arr[high];\n arr[high] = temp;\n return i+1;\n \n }\n protected static void sort(int arr[],int low, int high)\n {\n if(low < high)\n {\n int pi=partition(arr, low, high);\n sort(arr, low, pi-1);\n sort(arr, pi+1, high);\n \n }\n \n }\n protected static void sort(long arr[],int low, int high)\n {\n if(low < high)\n {\n int pi=partition(arr, low, high);\n sort(arr, low, pi-1);\n sort(arr, pi+1, high);\n \n }\n }\n\n protected static void sort(double arr[],int low, int high)\n {\n if(low < high)\n {\n int pi=partition(arr, low, high);\n sort(arr, low, pi-1);\n sort(arr, pi+1, high);\n \n }\n }\n protected static void sort(char arr[],int low, int high)\n {\n if(low < high)\n {\n int pi=partition(arr, low, high);\n sort(arr, low, pi-1);\n sort(arr, pi+1, high);\n \n }\n }\n protected static void printArray(int arr[])\n {\n int n = arr.length;\n for (int i=0; i i == key);\n }\n public static boolean contains(final long[] arr, final long key) {\n return Arrays.stream(arr).anyMatch(i -> i == key);\n }\n public static boolean contains(final double[] arr, final double key) {\n return Arrays.stream(arr).anyMatch(i -> i == key);\n }\n protected static long NCR(long N, long R){\n if(N < R)\n return 0;\n if(R == 0 || R == N)\n return 1;\n return NCR(N-1,R-1)+NCR(N-1,R);\n }\n protected static long NCR(int N, int R){\n if(N < R)\n return 0;\n if(R == 0 || R == N)\n return 1;\n return NCR(N-1,R-1)+NCR(N-1,R);\n }\n protected static String changeCharInPosition(int position, char ch, String str){\n char[] charArray = str.toCharArray();\n charArray[position] = ch;\n return new String(charArray);\n }\n protected static boolean isPrime(long n) {\n if(n < 2) return false;\n if(n == 2 || n == 3) return true;\n if(n%2 == 0 || n%3 == 0) return false;\n long sqrtN = (long)Math.sqrt(n)+1;\n for(long i = 6L; i <= sqrtN; i += 6) {\n if(n%(i-1) == 0 || n%(i+1) == 0) return false;\n }\n return true;\n }\n protected static long Gcd(long p, long q) {\n if (q == 0) return p;\n else return Gcd(q, p % q);\n }\n protected static boolean isPrime(int n) {\n if(n < 2) return false;\n if(n == 2 || n == 3) return true;\n if(n%2 == 0 || n%3 == 0) return false;\n int sqrtN = (int)Math.sqrt(n)+1;\n for(long i = 6L; i <= sqrtN; i += 6) {\n if(n%(i-1) == 0 || n%(i+1) == 0) return false;\n }\n return true;\n }\n }\n public static class BinarySearch{\n private static int middle;\n private static int L;\n private static int R;\n public BinarySearch() {\n \n }\n protected static int Search(int [] arr,int element){\n R=arr.length-1;\n L=0;\n return BS(arr, L, R, element);\n }\n protected static int Search(long [] arr,long element){\n R=arr.length-1;\n L=0;\n return BS(arr, L, R, element);\n }\n protected static int Search(char [] arr,char element){\n R=arr.length-1;\n L=0;\n return BS(arr, L, R, element);\n }\n protected static int Search(double [] arr,double element){\n R=arr.length-1;\n L=0;\n return BS(arr, L, R, element);\n }\n protected static int BS(int [] arr,int L,int R,int element){ \n if(R>=L) \n {\n middle=L+(R-L)/2; \n if(arr[middle]==element)\n { \n return middle;\n } \n else if(arr[middle]>element)\n {\n return BS(arr, L,middle-1, element);\n } \n else \n { \n return BS(arr, middle+1, R, element);\n } \n } \n else\n {\n return -1;\n }\n }\n protected static int BS(long [] arr,int L,int R,long element){ \n if(R>=L) \n {\n middle=L+(R-L)/2; \n if(arr[middle]==element)\n { \n return middle;\n } \n else if(arr[middle]>element)\n {\n return BS(arr, L,middle-1, element);\n } \n else \n { \n return BS(arr, middle+1, R, element);\n } \n } \n else\n {\n return -1;\n }\n }\n protected static int BS(char [] arr,int L,int R,char element){ \n if(R>=L) \n {\n middle=L+(R-L)/2; \n if(arr[middle]==element)\n { \n return middle;\n } \n else if(arr[middle]>element)\n {\n return BS(arr, L,middle-1, element);\n } \n else \n { \n return BS(arr, middle+1, R, element);\n } \n } \n else\n {\n return -1;\n }\n }\n protected static int BS(double [] arr,int L,int R,double element){ \n if(R>=L) \n {\n middle=L+(R-L)/2; \n if(arr[middle]==element)\n { \n return middle;\n } \n else if(arr[middle]>element)\n {\n return BS(arr, L,middle-1, element);\n } \n else \n { \n return BS(arr, middle+1, R, element);\n } \n } \n else\n {\n return -1;\n }\n }\n } \n public static class DataStructure{\n\n public DataStructure() {\n }\n \n \n static void stack_push(Stack stack)\n {\n for(int i = 0; i < 5; i++)\n {\n stack.push(i);\n }\n }\n \n \n // Popping element from the top of the stack\n static void stack_pop(Stack stack)\n {\n System.out.println(\"Pop :\");\n \n for(int i = 0; i < 5; i++)\n {\n Integer y = (Integer) stack.pop();\n System.out.println(y);\n }\n }\n \n // Displaying element on the top of the stack\n static void stack_peek(Stack stack)\n {\n Integer element = (Integer) stack.peek();\n System.out.println(\"Element on stack top : \" + element);\n }\n \n // Searching element in the stack\n static void stack_search(Stack stack, int element)\n {\n Integer pos = (Integer) stack.search(element);\n \n if(pos == -1)\n System.out.println(\"Element not found\");\n else\n System.out.println(\"Element is found at position \" + pos);\n }\n \n }\n public static class FIB {\n \n protected static int MAX = 1000;\n protected static long f[];\n protected static int size=0;\n // Returns n'th fibonacci number using \n // table f[]\n \n public FIB(int n)\n {\n f=new long[MAX];\n this.size=n;\n fib();\n }\n\n protected static void fib() {\n f[0]=0;f[1]=1;\n for (int i = 2; i < size; i++) {\n //if(f[i-1]+f[i-2]>Long.MAX_VALUE){f[i]=0;continue;}\n f[i]=f[i-1]+f[i-2];\n }\n }\n protected static void printSeries(){\n for (int i = 0; i generatePermutations(String input) {\n\n input = input.toLowerCase();\n Set result = new HashSet<>();\n permutations(\"\", input, result);\n return result;\n\n }\n private void permutations(String prefix, String letters, Set result) {\n\n if (letters.length() == 0) {\n\n result.add(prefix);\n\n } else {\n\n for (int i = 0; i < letters.length(); i++) {\n\n String letter = letters.substring(i, i + 1);\n\n String otherLetters = letters.substring(0, i) + letters.substring(i + 1);\n\n permutations(prefix + letter, otherLetters, result);\n\n }\n\n }\n\n }\n\n } \n}\n/*\nSome References for doing things \n-Removing all Leading zeros in a string \ns.replaceFirst(\"^0+(?!$)\", \"\");\n-Creating comprator\npublic static class CustomComparator implements Comparator {\n @Override\n public int compare(c o1, c o2) {\n return o1.score.compareTo(o2.score);\n }\n}\n-how to write switch case\n switch(x)\n {\n case 1:\n return l;\n ...\n default:\n return m;\n }\n-Convert numbers of and to different bases\n Integer.toString(Integer.parseInt(number, base1), base2);\n-Split over white spaces:\n myString.split(\"\\\\s+\");\n-how to know if 4 points will form a square or a rectangle:\n public static class point{\n int a,b;\n public point(int a, int b) {\n this.a = a;\n this.b = b;\n }\n\n @Override\n public String toString() {\n return \"point{\" + \"a=\" + a + \", b=\" + b + '}';\n }\n }\n public static int distSq(point p, point q)\n {\n return (p.a - q.a)*(p.a - q.a) +\n (p.b - q.b)*(p.b - q.b);\n }\n public static boolean isSquare(point p1, point p2, point p3, point p4)\n {\n int d2 = distSq(p1, p2); // from p1 to p2\n int d3 = distSq(p1, p3); // from p1 to p3\n int d4 = distSq(p1, p4); // from p1 to p4\n\n // If lengths if (p1, p2) and (p1, p3) are same, then\n // following conditions must met to form a square.\n // 1) Square of length of (p1, p4) is same as twice\n // the square of (p1, p2)\n // 2) p4 is at same distance from p2 and p3\n if (d2 == d3 && 2*d2 == d4)\n {\n int d = distSq(p2, p4);\n return (d == distSq(p3, p4) && d == d2);\n }\n\n // The below two cases are similar to above case\n if (d3 == d4 && 2*d3 == d2)\n {\n int d = distSq(p2, p3);\n return (d == distSq(p2, p4) && d == d3);\n }\n if (d2 == d4 && 2*d2 == d3)\n {\n int d = distSq(p2, p3);\n return (d == distSq(p3, p4) && d == d2);\n }\n\n return false;\n }\n public static boolean isRectangle(point p1,point p2,point p3,point p4)\n {\n double cx,cy;\n double dd1,dd2,dd3,dd4;\n double x1,y1,x2,y2,x3,y3,x4,y4;\n x1=p1.a;y1=p1.b;x2=p2.a;y2=p2.b;x3=p3.a;y3=p3.b;x4=p4.a;y4=p4.b;\n cx=(x1+x2+x3+x4)/4;\n cy=(y1+y2+y3+y4)/4;\n\n dd1=(cx-x1)*(cx-x1)+(cy-y1)*(cy-y1);\n dd2=(cx-x2)*(cx-x2)+(cy-y2)*(cy-y2);\n dd3=(cx-x3)*(cx-x3)+(cy-y3)*(cy-y3);\n dd4=(cx-x4)*(cx-x4)+(cy-y4)*(cy-y4);\n return dd1==dd2 && dd1==dd3 && dd1==dd4;\n }\n*/\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given positive integers X and Y.\nIf there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it.\nIf it does not exist, print -1.\n\nConstraints\n\n1 ≤ X,Y ≤ 10^9\n\nX and Y are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.\n\nSample Input 1\n\n8 6\n\nSample Output 1\n\n16\n\nFor example, 16 is a multiple of 8 but not a multiple of 6.\n\nSample Input 2\n\n3 3\n\nSample Output 2\n\n-1\n\nA multiple of 3 is a multiple of 3.", "sample_input": "8 6\n"}, "reference_outputs": ["16\n"], "source_document_id": "p03437", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given positive integers X and Y.\nIf there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it.\nIf it does not exist, print -1.\n\nConstraints\n\n1 ≤ X,Y ≤ 10^9\n\nX and Y are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.\n\nSample Input 1\n\n8 6\n\nSample Output 1\n\n16\n\nFor example, 16 is a multiple of 8 but not a multiple of 6.\n\nSample Input 2\n\n3 3\n\nSample Output 2\n\n-1\n\nA multiple of 3 is a multiple of 3.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 21192, "cpu_time_ms": 2109, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s273428759", "group_id": "codeNet:p03438", "input_text": "import java.util.stream.*;\nimport java.util.*;\n\npublic class Main {\n static Scanner scanner = new Scanner(System.in);\n\n public static void main(String[]$) {\n int n = scanner.nextInt();\n int i = 0, j = 0;\n int[] a = IntStream.range(0, n).map(k -> scanner.nextInt()).toArray();\n for (int k = 0; k < n; k++) {\n a[k] -= scanner.nextInt();\n if (a[k] < 0) {\n i -= a[k];\n } else {\n j += a[k];\n }\n }\n System.out.println(i > 2 * j ? \"Yes\" : \"No\");\n }\n}", "language": "Java", "metadata": {"date": 1555975319, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03438.html", "problem_id": "p03438", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03438/input.txt", "sample_output_relpath": "derived/input_output/data/p03438/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03438/Java/s273428759.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s273428759", "user_id": "u981808900"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.stream.*;\nimport java.util.*;\n\npublic class Main {\n static Scanner scanner = new Scanner(System.in);\n\n public static void main(String[]$) {\n int n = scanner.nextInt();\n int i = 0, j = 0;\n int[] a = IntStream.range(0, n).map(k -> scanner.nextInt()).toArray();\n for (int k = 0; k < n; k++) {\n a[k] -= scanner.nextInt();\n if (a[k] < 0) {\n i -= a[k];\n } else {\n j += a[k];\n }\n }\n System.out.println(i > 2 * j ? \"Yes\" : \"No\");\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N.\nDetermine if we can repeat the following operation zero or more times so that the sequences a and b become equal.\n\nOperation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions simultaneously:\n\nAdd 2 to a_i.\n\nAdd 1 to b_j.\n\nConstraints\n\n1 ≤ N ≤ 10 000\n\n0 ≤ a_i,b_i ≤ 10^9 (1 ≤ i ≤ N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 .. a_N\nb_1 b_2 .. b_N\n\nOutput\n\nIf we can repeat the operation zero or more times so that the sequences a and b become equal, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 2 3\n5 2 2\n\nSample Output 1\n\nYes\n\nFor example, we can perform three operations as follows to do our job:\n\nFirst operation: i=1 and j=2. Now we have a = \\{3,2,3\\}, b = \\{5,3,2\\}.\n\nSecond operation: i=1 and j=2. Now we have a = \\{5,2,3\\}, b = \\{5,4,2\\}.\n\nThird operation: i=2 and j=3. Now we have a = \\{5,4,3\\}, b = \\{5,4,3\\}.\n\nSample Input 2\n\n5\n3 1 4 1 5\n2 7 1 8 2\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n5\n2 7 1 8 2\n3 1 4 1 5\n\nSample Output 3\n\nNo", "sample_input": "3\n1 2 3\n5 2 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03438", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N.\nDetermine if we can repeat the following operation zero or more times so that the sequences a and b become equal.\n\nOperation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions simultaneously:\n\nAdd 2 to a_i.\n\nAdd 1 to b_j.\n\nConstraints\n\n1 ≤ N ≤ 10 000\n\n0 ≤ a_i,b_i ≤ 10^9 (1 ≤ i ≤ N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 .. a_N\nb_1 b_2 .. b_N\n\nOutput\n\nIf we can repeat the operation zero or more times so that the sequences a and b become equal, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 2 3\n5 2 2\n\nSample Output 1\n\nYes\n\nFor example, we can perform three operations as follows to do our job:\n\nFirst operation: i=1 and j=2. Now we have a = \\{3,2,3\\}, b = \\{5,3,2\\}.\n\nSecond operation: i=1 and j=2. Now we have a = \\{5,2,3\\}, b = \\{5,4,2\\}.\n\nThird operation: i=2 and j=3. Now we have a = \\{5,4,3\\}, b = \\{5,4,3\\}.\n\nSample Input 2\n\n5\n3 1 4 1 5\n2 7 1 8 2\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n5\n2 7 1 8 2\n3 1 4 1 5\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 568, "cpu_time_ms": 366, "memory_kb": 44584}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s227278911", "group_id": "codeNet:p03450", "input_text": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.InputMismatchException;\nimport java.util.Iterator;\nimport java.util.NoSuchElementException;\n\npublic class Main {\n static final class UnionFindTree {\n private final int[] parent;\n private final long[] weight;\n public UnionFindTree(int n) {\n if (n < 1) {\n throw new IllegalArgumentException();\n }\n parent = new int[n];\n Arrays.setAll(parent, i -> i);\n\n weight = new long[n];\n }\n public int root(int x) {\n if (parent[x] == x) {\n return x;\n }\n int r = root(parent[x]);\n weight[x] += weight[parent[x]];\n return parent[x] = r;\n }\n public boolean same(int x, int y) {\n return root(x) == root(y);\n }\n public boolean unite(int x, int y) {\n return unite(x, y, 0);\n }\n public boolean unite(int x, int y, long w) {\n int xr = root(x);\n int yr = root(y);\n if (xr == yr) {\n return false;\n }\n weight[yr] = w + weight(x) - weight(y);\n parent[yr] = xr;\n return true;\n }\n public long weight(int x) {\n root(x);\n return weight[x];\n }\n public long diff(int x, int y) {\n if (same(x, y)) {\n return weight(y) - weight(x);\n }\n throw new IllegalArgumentException();\n }\n }\n static void solve(MyScanner in, MyWriter out) {\n int n = in.nextInt();\n int m = in.nextInt();\n int[][] lrd = in.nextVerticalIntArrays(3, m);\n int[] l = lrd[0];\n int[] r = lrd[1];\n int[] d = lrd[2];\n UnionFindTree t = new UnionFindTree(n);\n for (int i = 0; i < m; i++) {\n int left = l[i] - 1;\n int right = r[i] - 1;\n if (t.same(left, right)) {\n if (t.diff(left, right) != d[i]) {\n out.println(\"No\");\n return;\n }\n } else {\n t.unite(left, right, d[i]);\n }\n }\n out.println(\"Yes\");\n }\n\n public static void main(String[] args) {\n MyWriter w = new MyWriter(System.out);\n solve(new MyScanner(System.in), w);\n w.flush();\n }\n\n static final class MyScanner {\n static final int BUFFER_SIZE = 8192;\n private final InputStream in;\n private final byte[] buffer = new byte[BUFFER_SIZE];\n private int point;\n private int readLength;\n MyScanner(InputStream in) {\n this.in = in;\n }\n private byte readByte() {\n if (point < readLength) {\n byte result = buffer[point];\n point += 1;\n return result;\n }\n try {\n readLength = in.read(buffer);\n } catch (IOException e) {\n throw new AssertionError(null, e);\n }\n if (readLength == -1) {\n return -1;\n }\n point = 1;\n return buffer[0];\n }\n private static boolean isPrintableCharExceptSpace(byte c) {\n return 33 <= c && c <= 126;\n }\n public char nextChar() {\n byte c = readByte();\n while (!(c == -1 || isPrintableCharExceptSpace(c))) {\n c = readByte();\n }\n if (c == -1) {\n throw new NoSuchElementException();\n }\n return (char)c;\n }\n public String next() {\n return next(16);\n }\n public String next(int n) {\n byte c = readByte();\n while (!(c == -1 || isPrintableCharExceptSpace(c))) {\n c = readByte();\n }\n if (c == -1) {\n throw new NoSuchElementException();\n }\n StringBuilder b = new StringBuilder(n);\n do {\n b.append((char)c);\n c = readByte();\n } while (c != -1 && isPrintableCharExceptSpace(c));\n return b.toString();\n }\n public long nextLong() {\n byte c = readByte();\n while (!(c == -1 || isPrintableCharExceptSpace(c))) {\n c = readByte();\n }\n if (c == -1) {\n throw new NoSuchElementException();\n }\n boolean minus = false;\n if (c == '-') {\n minus = true;\n c = readByte();\n }\n long result = 0L;\n do {\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n result = result * 10L + (c - '0');\n c = readByte();\n } while (c != -1 && isPrintableCharExceptSpace(c));\n return minus ? -result : result;\n }\n public int nextInt() {\n long n = nextLong();\n if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE) {\n throw new InputMismatchException();\n }\n return (int)n;\n }\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n public int[] nextIntArray(int n) {\n int[] result = new int[n];\n for (int i = 0; i < n; i++) {\n result[i] = nextInt();\n }\n return result;\n }\n public long[] nextLongArray(int n) {\n long[] result = new long[n];\n for (int i = 0; i < n; i++) {\n result[i] = nextLong();\n }\n return result;\n }\n public char[] nextCharArray(int n) {\n char[] result = new char[n];\n for (int i = 0; i < n; i++) {\n result[i] = nextChar();\n }\n return result;\n }\n public char[][] next2dCharArray(int n, int m) {\n char[][] result = new char[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n result[i][j] = nextChar();\n }\n }\n return result;\n }\n public int[][] nextVerticalIntArrays(int arrayCount, int arrayLength) {\n int[][] result = new int[arrayCount][arrayLength];\n for (int i = 0; i < arrayLength; i++) {\n for (int j = 0; j < arrayCount; j++) {\n result[j][i] = nextInt();\n }\n }\n return result;\n }\n public long[][] nextVerticalLongArrays(int arrayCount,\n int arrayLength) {\n long[][] result = new long[arrayCount][arrayLength];\n for (int i = 0; i < arrayLength; i++) {\n for (int j = 0; j < arrayCount; j++) {\n result[j][i] = nextLong();\n }\n }\n return result;\n }\n public char[][] nextVerticalCharArrays(int arrayCount,\n int arrayLength) {\n char[][] result = new char[arrayCount][arrayLength];\n for (int i = 0; i < arrayLength; i++) {\n for (int j = 0; j < arrayCount; j++) {\n result[j][i] = nextChar();\n }\n }\n return result;\n }\n }\n static final class MyWriter extends PrintWriter {\n MyWriter(OutputStream out) {\n super(out);\n }\n public void joinAndPrintln(int[] x) {\n joinAndPrintln(x, \" \");\n }\n public void joinAndPrintln(int[] x, String delimiter) {\n StringBuilder b = new StringBuilder();\n if (x.length > 0) {\n b.append(x[0]);\n for (int i = 1; i < x.length; i++) {\n b.append(delimiter).append(x[i]);\n }\n }\n println(b.toString());\n }\n public void joinAndPrintln(long[] x) {\n joinAndPrintln(x, \" \");\n }\n public void joinAndPrintln(long[] x, String delimiter) {\n StringBuilder b = new StringBuilder();\n if (x.length > 0) {\n b.append(x[0]);\n for (int i = 1; i < x.length; i++) {\n b.append(delimiter).append(x[i]);\n }\n }\n println(b.toString());\n }\n public void joinAndPrintln(Iterable iterable) {\n joinAndPrintln(iterable, \" \");\n }\n public void joinAndPrintln(Iterable iterable, String delimiter) {\n StringBuilder b = new StringBuilder();\n for (Iterator i = iterable.iterator(); i.hasNext();) {\n b.append(i.next());\n while (i.hasNext()) {\n b.append(delimiter).append(i.next());\n }\n }\n println(b.toString());\n }\n }\n}\n", "language": "Java", "metadata": {"date": 1576919098, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03450.html", "problem_id": "p03450", "resource_group": "high_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/Java/s227278911.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s227278911", "user_id": "u097304477"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.InputMismatchException;\nimport java.util.Iterator;\nimport java.util.NoSuchElementException;\n\npublic class Main {\n static final class UnionFindTree {\n private final int[] parent;\n private final long[] weight;\n public UnionFindTree(int n) {\n if (n < 1) {\n throw new IllegalArgumentException();\n }\n parent = new int[n];\n Arrays.setAll(parent, i -> i);\n\n weight = new long[n];\n }\n public int root(int x) {\n if (parent[x] == x) {\n return x;\n }\n int r = root(parent[x]);\n weight[x] += weight[parent[x]];\n return parent[x] = r;\n }\n public boolean same(int x, int y) {\n return root(x) == root(y);\n }\n public boolean unite(int x, int y) {\n return unite(x, y, 0);\n }\n public boolean unite(int x, int y, long w) {\n int xr = root(x);\n int yr = root(y);\n if (xr == yr) {\n return false;\n }\n weight[yr] = w + weight(x) - weight(y);\n parent[yr] = xr;\n return true;\n }\n public long weight(int x) {\n root(x);\n return weight[x];\n }\n public long diff(int x, int y) {\n if (same(x, y)) {\n return weight(y) - weight(x);\n }\n throw new IllegalArgumentException();\n }\n }\n static void solve(MyScanner in, MyWriter out) {\n int n = in.nextInt();\n int m = in.nextInt();\n int[][] lrd = in.nextVerticalIntArrays(3, m);\n int[] l = lrd[0];\n int[] r = lrd[1];\n int[] d = lrd[2];\n UnionFindTree t = new UnionFindTree(n);\n for (int i = 0; i < m; i++) {\n int left = l[i] - 1;\n int right = r[i] - 1;\n if (t.same(left, right)) {\n if (t.diff(left, right) != d[i]) {\n out.println(\"No\");\n return;\n }\n } else {\n t.unite(left, right, d[i]);\n }\n }\n out.println(\"Yes\");\n }\n\n public static void main(String[] args) {\n MyWriter w = new MyWriter(System.out);\n solve(new MyScanner(System.in), w);\n w.flush();\n }\n\n static final class MyScanner {\n static final int BUFFER_SIZE = 8192;\n private final InputStream in;\n private final byte[] buffer = new byte[BUFFER_SIZE];\n private int point;\n private int readLength;\n MyScanner(InputStream in) {\n this.in = in;\n }\n private byte readByte() {\n if (point < readLength) {\n byte result = buffer[point];\n point += 1;\n return result;\n }\n try {\n readLength = in.read(buffer);\n } catch (IOException e) {\n throw new AssertionError(null, e);\n }\n if (readLength == -1) {\n return -1;\n }\n point = 1;\n return buffer[0];\n }\n private static boolean isPrintableCharExceptSpace(byte c) {\n return 33 <= c && c <= 126;\n }\n public char nextChar() {\n byte c = readByte();\n while (!(c == -1 || isPrintableCharExceptSpace(c))) {\n c = readByte();\n }\n if (c == -1) {\n throw new NoSuchElementException();\n }\n return (char)c;\n }\n public String next() {\n return next(16);\n }\n public String next(int n) {\n byte c = readByte();\n while (!(c == -1 || isPrintableCharExceptSpace(c))) {\n c = readByte();\n }\n if (c == -1) {\n throw new NoSuchElementException();\n }\n StringBuilder b = new StringBuilder(n);\n do {\n b.append((char)c);\n c = readByte();\n } while (c != -1 && isPrintableCharExceptSpace(c));\n return b.toString();\n }\n public long nextLong() {\n byte c = readByte();\n while (!(c == -1 || isPrintableCharExceptSpace(c))) {\n c = readByte();\n }\n if (c == -1) {\n throw new NoSuchElementException();\n }\n boolean minus = false;\n if (c == '-') {\n minus = true;\n c = readByte();\n }\n long result = 0L;\n do {\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n result = result * 10L + (c - '0');\n c = readByte();\n } while (c != -1 && isPrintableCharExceptSpace(c));\n return minus ? -result : result;\n }\n public int nextInt() {\n long n = nextLong();\n if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE) {\n throw new InputMismatchException();\n }\n return (int)n;\n }\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n public int[] nextIntArray(int n) {\n int[] result = new int[n];\n for (int i = 0; i < n; i++) {\n result[i] = nextInt();\n }\n return result;\n }\n public long[] nextLongArray(int n) {\n long[] result = new long[n];\n for (int i = 0; i < n; i++) {\n result[i] = nextLong();\n }\n return result;\n }\n public char[] nextCharArray(int n) {\n char[] result = new char[n];\n for (int i = 0; i < n; i++) {\n result[i] = nextChar();\n }\n return result;\n }\n public char[][] next2dCharArray(int n, int m) {\n char[][] result = new char[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n result[i][j] = nextChar();\n }\n }\n return result;\n }\n public int[][] nextVerticalIntArrays(int arrayCount, int arrayLength) {\n int[][] result = new int[arrayCount][arrayLength];\n for (int i = 0; i < arrayLength; i++) {\n for (int j = 0; j < arrayCount; j++) {\n result[j][i] = nextInt();\n }\n }\n return result;\n }\n public long[][] nextVerticalLongArrays(int arrayCount,\n int arrayLength) {\n long[][] result = new long[arrayCount][arrayLength];\n for (int i = 0; i < arrayLength; i++) {\n for (int j = 0; j < arrayCount; j++) {\n result[j][i] = nextLong();\n }\n }\n return result;\n }\n public char[][] nextVerticalCharArrays(int arrayCount,\n int arrayLength) {\n char[][] result = new char[arrayCount][arrayLength];\n for (int i = 0; i < arrayLength; i++) {\n for (int j = 0; j < arrayCount; j++) {\n result[j][i] = nextChar();\n }\n }\n return result;\n }\n }\n static final class MyWriter extends PrintWriter {\n MyWriter(OutputStream out) {\n super(out);\n }\n public void joinAndPrintln(int[] x) {\n joinAndPrintln(x, \" \");\n }\n public void joinAndPrintln(int[] x, String delimiter) {\n StringBuilder b = new StringBuilder();\n if (x.length > 0) {\n b.append(x[0]);\n for (int i = 1; i < x.length; i++) {\n b.append(delimiter).append(x[i]);\n }\n }\n println(b.toString());\n }\n public void joinAndPrintln(long[] x) {\n joinAndPrintln(x, \" \");\n }\n public void joinAndPrintln(long[] x, String delimiter) {\n StringBuilder b = new StringBuilder();\n if (x.length > 0) {\n b.append(x[0]);\n for (int i = 1; i < x.length; i++) {\n b.append(delimiter).append(x[i]);\n }\n }\n println(b.toString());\n }\n public void joinAndPrintln(Iterable iterable) {\n joinAndPrintln(iterable, \" \");\n }\n public void joinAndPrintln(Iterable iterable, String delimiter) {\n StringBuilder b = new StringBuilder();\n for (Iterator i = iterable.iterator(); i.hasNext();) {\n b.append(i.next());\n while (i.hasNext()) {\n b.append(delimiter).append(i.next());\n }\n }\n println(b.toString());\n }\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N people standing on the x-axis.\nLet the coordinate of Person i be x_i.\nFor every i, x_i is an integer between 0 and 10^9 (inclusive).\nIt is possible that more than one person is standing at the same coordinate.\n\nYou will given M pieces of information regarding the positions of these people.\nThe i-th piece of information has the form (L_i, R_i, D_i).\nThis means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds.\n\nIt turns out that some of these M pieces of information may be incorrect.\nDetermine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.\n\nConstraints\n\n1 \\leq N \\leq 100 000\n\n0 \\leq M \\leq 200 000\n\n1 \\leq L_i, R_i \\leq N (1 \\leq i \\leq M)\n\n0 \\leq D_i \\leq 10 000 (1 \\leq i \\leq M)\n\nL_i \\neq R_i (1 \\leq i \\leq M)\n\nIf i \\neq j, then (L_i, R_i) \\neq (L_j, R_j) and (L_i, R_i) \\neq (R_j, L_j).\n\nD_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1 D_1\nL_2 R_2 D_2\n:\nL_M R_M D_M\n\nOutput\n\nIf there exists a set of values (x_1, x_2, ..., x_N) that is consistent with all given pieces of information, print Yes; if it does not exist, print No.\n\nSample Input 1\n\n3 3\n1 2 1\n2 3 1\n1 3 2\n\nSample Output 1\n\nYes\n\nSome possible sets of values (x_1, x_2, x_3) are (0, 1, 2) and (101, 102, 103).\n\nSample Input 2\n\n3 3\n1 2 1\n2 3 1\n1 3 5\n\nSample Output 2\n\nNo\n\nIf the first two pieces of information are correct, x_3 - x_1 = 2 holds, which is contradictory to the last piece of information.\n\nSample Input 3\n\n4 3\n2 1 1\n2 3 5\n3 4 2\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n10 3\n8 7 100\n7 9 100\n9 8 100\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n100 0\n\nSample Output 5\n\nYes", "sample_input": "3 3\n1 2 1\n2 3 1\n1 3 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03450", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N people standing on the x-axis.\nLet the coordinate of Person i be x_i.\nFor every i, x_i is an integer between 0 and 10^9 (inclusive).\nIt is possible that more than one person is standing at the same coordinate.\n\nYou will given M pieces of information regarding the positions of these people.\nThe i-th piece of information has the form (L_i, R_i, D_i).\nThis means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds.\n\nIt turns out that some of these M pieces of information may be incorrect.\nDetermine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.\n\nConstraints\n\n1 \\leq N \\leq 100 000\n\n0 \\leq M \\leq 200 000\n\n1 \\leq L_i, R_i \\leq N (1 \\leq i \\leq M)\n\n0 \\leq D_i \\leq 10 000 (1 \\leq i \\leq M)\n\nL_i \\neq R_i (1 \\leq i \\leq M)\n\nIf i \\neq j, then (L_i, R_i) \\neq (L_j, R_j) and (L_i, R_i) \\neq (R_j, L_j).\n\nD_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1 D_1\nL_2 R_2 D_2\n:\nL_M R_M D_M\n\nOutput\n\nIf there exists a set of values (x_1, x_2, ..., x_N) that is consistent with all given pieces of information, print Yes; if it does not exist, print No.\n\nSample Input 1\n\n3 3\n1 2 1\n2 3 1\n1 3 2\n\nSample Output 1\n\nYes\n\nSome possible sets of values (x_1, x_2, x_3) are (0, 1, 2) and (101, 102, 103).\n\nSample Input 2\n\n3 3\n1 2 1\n2 3 1\n1 3 5\n\nSample Output 2\n\nNo\n\nIf the first two pieces of information are correct, x_3 - x_1 = 2 holds, which is contradictory to the last piece of information.\n\nSample Input 3\n\n4 3\n2 1 1\n2 3 5\n3 4 2\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n10 3\n8 7 100\n7 9 100\n9 8 100\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n100 0\n\nSample Output 5\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 9150, "cpu_time_ms": 299, "memory_kb": 30456}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s983088854", "group_id": "codeNet:p03457", "input_text": "import java.util.*;\npublic class Main {\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int preT = 0;\n int preX = 0;\n int preY = 0;\n\n for(int i=0; i t = new ArrayList<>();\n List x = new ArrayList<>();\n List y = new ArrayList<>();\n t.add(0);\n x.add(0);\n y.add(0);\n for(int i = 0;i < n;i++){\n t.add(sc.nextInt());\n x.add(sc.nextInt());\n y.add(sc.nextInt());\n }\n for(int i = 1;i < n;i++){\n int dt = t.get(i) - t.get(i-1);\n int dist = Math.abs(x.get(i)-x.get(i-1)) + Math.abs(y.get(i)-y.get(i-1));\n if(dist <= dt && ((dist % 2) == (dt % 2))){\n System.out.println(\"Yes\");\n return;\n }\n }\n System.out.println(\"No\");\n }\n}\n", "language": "Java", "metadata": {"date": 1532464852, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03457.html", "problem_id": "p03457", "resource_group": "high_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/Java/s971971201.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s971971201", "user_id": "u076522215"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\nimport java.util.List;\nimport java.util.ArrayList;\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n List t = new ArrayList<>();\n List x = new ArrayList<>();\n List y = new ArrayList<>();\n t.add(0);\n x.add(0);\n y.add(0);\n for(int i = 0;i < n;i++){\n t.add(sc.nextInt());\n x.add(sc.nextInt());\n y.add(sc.nextInt());\n }\n for(int i = 1;i < n;i++){\n int dt = t.get(i) - t.get(i-1);\n int dist = Math.abs(x.get(i)-x.get(i-1)) + Math.abs(y.get(i)-y.get(i-1));\n if(dist <= dt && ((dist % 2) == (dt % 2))){\n System.out.println(\"Yes\");\n return;\n }\n }\n System.out.println(\"No\");\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "sample_input": "2\n3 1 2\n6 1 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "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": 900, "cpu_time_ms": 651, "memory_kb": 92624}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s375235842", "group_id": "codeNet:p03459", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tMain m = new Main();\n\t\tm.run();\n\t}\n\t\n\tScanner sc = new Scanner(System.in);\n\t\n\tvoid run(){\n\t\tint N = sc.nextInt();\n\t\t\n\t\tint prevT = 0;\n\t\tint prevX = 0;\n\t\tint prevY = 0;\n\t\tboolean mutFlag = true;\n\t\tfor (int i = 0; i < N ; i++){\n\t\t\tint t = sc.nextInt();\n\t\t\tint x = sc.nextInt();\n\t\t\tint y = sc.nextInt();\n\t\t\t\n\t\t\tmutFlag = check(t,x,y,prevT,prevX,prevY);\n\t\t\tif(!mutFlag){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tprevT = t;\n\t\t\tprevX = x;\n\t\t\tprevY = y;\n\t\t}\n\t\tSystem.out.println(mutFlag ?\"Yes\" :\"No\");\n\t\t\n\t\t\n\t}\n\t\n\tboolean check(int t1,int x1,int y1, int t0,int x0,int y0){\n\t\tint time = t1 - t0;\n\t\t\n\t\tint distance = Math.abs(x1 - x0) + Math.abs(y1 - y0);\n\t\tif((distance + time) % 2 == 1){\n\t\t\treturn false;\n\t\t}\n\t\treturn distance <= time;\n\t}\n}\n", "language": "Java", "metadata": {"date": 1517049558, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03459.html", "problem_id": "p03459", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03459/input.txt", "sample_output_relpath": "derived/input_output/data/p03459/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03459/Java/s375235842.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s375235842", "user_id": "u673217098"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tMain m = new Main();\n\t\tm.run();\n\t}\n\t\n\tScanner sc = new Scanner(System.in);\n\t\n\tvoid run(){\n\t\tint N = sc.nextInt();\n\t\t\n\t\tint prevT = 0;\n\t\tint prevX = 0;\n\t\tint prevY = 0;\n\t\tboolean mutFlag = true;\n\t\tfor (int i = 0; i < N ; i++){\n\t\t\tint t = sc.nextInt();\n\t\t\tint x = sc.nextInt();\n\t\t\tint y = sc.nextInt();\n\t\t\t\n\t\t\tmutFlag = check(t,x,y,prevT,prevX,prevY);\n\t\t\tif(!mutFlag){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tprevT = t;\n\t\t\tprevX = x;\n\t\t\tprevY = y;\n\t\t}\n\t\tSystem.out.println(mutFlag ?\"Yes\" :\"No\");\n\t\t\n\t\t\n\t}\n\t\n\tboolean check(int t1,int x1,int y1, int t0,int x0,int y0){\n\t\tint time = t1 - t0;\n\t\t\n\t\tint distance = Math.abs(x1 - x0) + Math.abs(y1 - y0);\n\t\tif((distance + time) % 2 == 1){\n\t\t\treturn false;\n\t\t}\n\t\treturn distance <= time;\n\t}\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "sample_input": "2\n3 1 2\n6 1 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03459", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 802, "cpu_time_ms": 562, "memory_kb": 88556}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s268036170", "group_id": "codeNet:p03463", "input_text": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int a = sc.nextInt();\n int b = sc.nextInt();\n sc.close();\n\n if((b-a)%2 == 0){\n System.out.println(\"Alice\");\n }else{\n System.out.println(\"Borys\");\n }\n \n }\n}", "language": "Java", "metadata": {"date": 1515981801, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03463.html", "problem_id": "p03463", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03463/input.txt", "sample_output_relpath": "derived/input_output/data/p03463/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03463/Java/s268036170.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s268036170", "user_id": "u097204018"}, "prompt_components": {"gold_output": "Alice\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int a = sc.nextInt();\n int b = sc.nextInt();\n sc.close();\n\n if((b-a)%2 == 0){\n System.out.println(\"Alice\");\n }else{\n System.out.println(\"Borys\");\n }\n \n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA game is played on a strip consisting of N cells consecutively numbered from 1 to N.\n\nAlice has her token on cell A. Borys has his token on a different cell B.\n\nPlayers take turns, Alice moves first.\nThe moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1.\nNote that it's disallowed to move the token outside the strip or to the cell with the other player's token.\nIn one turn, the token of the moving player must be shifted exactly once.\n\nThe player who can't make a move loses, and the other player wins.\n\nBoth players want to win. Who wins if they play optimally?\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A < B \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint Alice if Alice wins, Borys if Borys wins, and Draw if nobody wins.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\nAlice\n\nAlice can move her token to cell 3.\nAfter that, Borys will be unable to move his token to cell 3, so he will have to move his token to cell 5.\nThen, Alice moves her token to cell 4. Borys can't make a move and loses.\n\nSample Input 2\n\n2 1 2\n\nSample Output 2\n\nBorys\n\nAlice can't make the very first move and loses.\n\nSample Input 3\n\n58 23 42\n\nSample Output 3\n\nBorys", "sample_input": "5 2 4\n"}, "reference_outputs": ["Alice\n"], "source_document_id": "p03463", "source_text": "Score : 300 points\n\nProblem Statement\n\nA game is played on a strip consisting of N cells consecutively numbered from 1 to N.\n\nAlice has her token on cell A. Borys has his token on a different cell B.\n\nPlayers take turns, Alice moves first.\nThe moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1.\nNote that it's disallowed to move the token outside the strip or to the cell with the other player's token.\nIn one turn, the token of the moving player must be shifted exactly once.\n\nThe player who can't make a move loses, and the other player wins.\n\nBoth players want to win. Who wins if they play optimally?\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A < B \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint Alice if Alice wins, Borys if Borys wins, and Draw if nobody wins.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\nAlice\n\nAlice can move her token to cell 3.\nAfter that, Borys will be unable to move his token to cell 3, so he will have to move his token to cell 5.\nThen, Alice moves her token to cell 4. Borys can't make a move and loses.\n\nSample Input 2\n\n2 1 2\n\nSample Output 2\n\nBorys\n\nAlice can't make the very first move and loses.\n\nSample Input 3\n\n58 23 42\n\nSample Output 3\n\nBorys", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 397, "cpu_time_ms": 107, "memory_kb": 23764}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s071237856", "group_id": "codeNet:p03469", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n String S = scanner.next();\n\n S = \"2018\" + S.substring(4,10);\n System.out.println(S);\n }\n\n}", "language": "Java", "metadata": {"date": 1542120892, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03469.html", "problem_id": "p03469", "resource_group": "high_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/Java/s071237856.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s071237856", "user_id": "u764060069"}, "prompt_components": {"gold_output": "2018/01/07\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n String S = scanner.next();\n\n S = \"2018\" + S.substring(4,10);\n System.out.println(S);\n }\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": 258, "cpu_time_ms": 94, "memory_kb": 21716}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s969658493", "group_id": "codeNet:p03473", "input_text": "import java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tInteger time = sc.nextInt();\n\t\tSystem.out.println((24 - time) + 24);\n\t}\n}", "language": "Java", "metadata": {"date": 1526468943, "filename_ext": "java", "original_language": "Java7 (OpenJDK 1.7.0)", "problem_description_relpath": "problem_descriptions/p03473.html", "problem_id": "p03473", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03473/input.txt", "sample_output_relpath": "derived/input_output/data/p03473/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03473/Java/s969658493.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s969658493", "user_id": "u499198368"}, "prompt_components": {"gold_output": "27\n", "input_to_evaluate": "import java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tInteger time = sc.nextInt();\n\t\tSystem.out.println((24 - time) + 24);\n\t}\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nHow many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?\n\nConstraints\n\n1≤M≤23\n\nM is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\n\nOutput\n\nIf we have x hours until New Year at M o'clock on 30th, December, print x.\n\nSample Input 1\n\n21\n\nSample Output 1\n\n27\n\nWe have 27 hours until New Year at 21 o'clock on 30th, December.\n\nSample Input 2\n\n12\n\nSample Output 2\n\n36", "sample_input": "21\n"}, "reference_outputs": ["27\n"], "source_document_id": "p03473", "source_text": "Score : 100 points\n\nProblem Statement\n\nHow many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?\n\nConstraints\n\n1≤M≤23\n\nM is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\n\nOutput\n\nIf we have x hours until New Year at M o'clock on 30th, December, print x.\n\nSample Input 1\n\n21\n\nSample Output 1\n\n27\n\nWe have 27 hours until New Year at 21 o'clock on 30th, December.\n\nSample Input 2\n\n12\n\nSample Output 2\n\n36", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 196, "cpu_time_ms": 95, "memory_kb": 20820}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s630160365", "group_id": "codeNet:p03474", "input_text": "/*\n長さの制約を忘れていた\nどもるがんの法則、間が&&ではなく||だった\n*/\n\nimport java.util.*;\n\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n String blank = sc.nextLine();\n String s = sc.nextLine();\n int i = 0;\n boolean flag = true;\n\n if(s.charAt(a) != '-'){flag = false;}\n for(char c : s.toCharArray()){\n i++;\n if(i == a){continue;}\n if(!('0' <= c) || !(c <= '9')){flag = false; break;}\n //i++;\n //continueされたときにiiを進めれてないのが問題\n }\n if(s.length() != a+b+1){flag = false;}\n\n if(flag){System.out.println(\"Yes\");}\n else{System.out.println(\"No\");}\n\n }\n}\n\n/*\nScanner sc = new Scanner(System.in);\nint n = sc.nextInt();\nString blank = sc.nextLine();\nString s = sc.nextLine();\nSystem.out.println();\nSystem.exit(0)\n*/\n", "language": "Java", "metadata": {"date": 1541859485, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03474.html", "problem_id": "p03474", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03474/input.txt", "sample_output_relpath": "derived/input_output/data/p03474/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03474/Java/s630160365.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s630160365", "user_id": "u075367840"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "/*\n長さの制約を忘れていた\nどもるがんの法則、間が&&ではなく||だった\n*/\n\nimport java.util.*;\n\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n String blank = sc.nextLine();\n String s = sc.nextLine();\n int i = 0;\n boolean flag = true;\n\n if(s.charAt(a) != '-'){flag = false;}\n for(char c : s.toCharArray()){\n i++;\n if(i == a){continue;}\n if(!('0' <= c) || !(c <= '9')){flag = false; break;}\n //i++;\n //continueされたときにiiを進めれてないのが問題\n }\n if(s.length() != a+b+1){flag = false;}\n\n if(flag){System.out.println(\"Yes\");}\n else{System.out.println(\"No\");}\n\n }\n}\n\n/*\nScanner sc = new Scanner(System.in);\nint n = sc.nextInt();\nString blank = sc.nextLine();\nString s = sc.nextLine();\nSystem.out.println();\nSystem.exit(0)\n*/\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThe postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen -, and the other characters are digits from 0 through 9.\n\nYou are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.\n\nConstraints\n\n1≤A,B≤5\n\n|S|=A+B+1\n\nS consists of - and digits from 0 through 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\nS\n\nOutput\n\nPrint Yes if S follows the postal code format in AtCoder Kingdom; print No otherwise.\n\nSample Input 1\n\n3 4\n269-6650\n\nSample Output 1\n\nYes\n\nThe (A+1)-th character of S is -, and the other characters are digits from 0 through 9, so it follows the format.\n\nSample Input 2\n\n1 1\n---\n\nSample Output 2\n\nNo\n\nS contains unnecessary -s other than the (A+1)-th character, so it does not follow the format.\n\nSample Input 3\n\n1 2\n7444\n\nSample Output 3\n\nNo", "sample_input": "3 4\n269-6650\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03474", "source_text": "Score : 200 points\n\nProblem Statement\n\nThe postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen -, and the other characters are digits from 0 through 9.\n\nYou are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.\n\nConstraints\n\n1≤A,B≤5\n\n|S|=A+B+1\n\nS consists of - and digits from 0 through 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\nS\n\nOutput\n\nPrint Yes if S follows the postal code format in AtCoder Kingdom; print No otherwise.\n\nSample Input 1\n\n3 4\n269-6650\n\nSample Output 1\n\nYes\n\nThe (A+1)-th character of S is -, and the other characters are digits from 0 through 9, so it follows the format.\n\nSample Input 2\n\n1 1\n---\n\nSample Output 2\n\nNo\n\nS contains unnecessary -s other than the (A+1)-th character, so it does not follow the format.\n\nSample Input 3\n\n1 2\n7444\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 931, "cpu_time_ms": 96, "memory_kb": 23764}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s516628037", "group_id": "codeNet:p03476", "input_text": "import java.util.*;\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int q = sc.nextInt();\n ArrayList list = sosu(100000);\n int[] s = new int[100001];\n for(int i = 1;i<=100000;i++){\n if(list.contains(i)&&list.contains((i+1)/2))s[i]=s[i-1]+1;\n else s[i]=s[i-1];\n }\n for(int i = 0;i < q;i++){\n int l = sc.nextInt();\n int r = sc.nextInt();\n System.out.println(s[r]-s[l-1]);\n }\n }\n public static ArrayList sosu(int n){\n boolean[] a = new boolean[n+1];\n Arrays.fill(a,true);\n ArrayList list = new ArrayList<>();\n for(int i = 4;i <= n;i+=2)a[i]=false;\n for(int i = 3;i <= Math.sqrt(n);i+=2){\n if(a[i]){\n for(int j = i*2;j <= n;j+=i)a[j]=false;\n }\n }\n for(int i = 2;i <= n;i++)if(a[i])list.add(i);\n return list;\n }\n}\n", "language": "Java", "metadata": {"date": 1570512416, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03476.html", "problem_id": "p03476", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03476/input.txt", "sample_output_relpath": "derived/input_output/data/p03476/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03476/Java/s516628037.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s516628037", "user_id": "u547167033"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*;\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int q = sc.nextInt();\n ArrayList list = sosu(100000);\n int[] s = new int[100001];\n for(int i = 1;i<=100000;i++){\n if(list.contains(i)&&list.contains((i+1)/2))s[i]=s[i-1]+1;\n else s[i]=s[i-1];\n }\n for(int i = 0;i < q;i++){\n int l = sc.nextInt();\n int r = sc.nextInt();\n System.out.println(s[r]-s[l-1]);\n }\n }\n public static ArrayList sosu(int n){\n boolean[] a = new boolean[n+1];\n Arrays.fill(a,true);\n ArrayList list = new ArrayList<>();\n for(int i = 4;i <= n;i+=2)a[i]=false;\n for(int i = 3;i <= Math.sqrt(n);i+=2){\n if(a[i]){\n for(int j = i*2;j <= n;j+=i)a[j]=false;\n }\n }\n for(int i = 2;i <= n;i++)if(a[i])list.add(i);\n return list;\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe say that a odd number N is similar to 2017 when both N and (N+1)/2 are prime.\n\nYou are given Q queries.\n\nIn the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.\n\nConstraints\n\n1≤Q≤10^5\n\n1≤l_i≤r_i≤10^5\n\nl_i and r_i are odd.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line (1≤i≤Q) should contain the response to the i-th query.\n\nSample Input 1\n\n1\n3 7\n\nSample Output 1\n\n2\n\n3 is similar to 2017, since both 3 and (3+1)/2=2 are prime.\n\n5 is similar to 2017, since both 5 and (5+1)/2=3 are prime.\n\n7 is not similar to 2017, since (7+1)/2=4 is not prime, although 7 is prime.\n\nThus, the response to the first query should be 2.\n\nSample Input 2\n\n4\n13 13\n7 11\n7 11\n2017 2017\n\nSample Output 2\n\n1\n0\n0\n1\n\nNote that 2017 is also similar to 2017.\n\nSample Input 3\n\n6\n1 53\n13 91\n37 55\n19 51\n73 91\n13 49\n\nSample Output 3\n\n4\n4\n1\n1\n1\n2", "sample_input": "1\n3 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03476", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe say that a odd number N is similar to 2017 when both N and (N+1)/2 are prime.\n\nYou are given Q queries.\n\nIn the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.\n\nConstraints\n\n1≤Q≤10^5\n\n1≤l_i≤r_i≤10^5\n\nl_i and r_i are odd.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line (1≤i≤Q) should contain the response to the i-th query.\n\nSample Input 1\n\n1\n3 7\n\nSample Output 1\n\n2\n\n3 is similar to 2017, since both 3 and (3+1)/2=2 are prime.\n\n5 is similar to 2017, since both 5 and (5+1)/2=3 are prime.\n\n7 is not similar to 2017, since (7+1)/2=4 is not prime, although 7 is prime.\n\nThus, the response to the first query should be 2.\n\nSample Input 2\n\n4\n13 13\n7 11\n7 11\n2017 2017\n\nSample Output 2\n\n1\n0\n0\n1\n\nNote that 2017 is also similar to 2017.\n\nSample Input 3\n\n6\n1 53\n13 91\n37 55\n19 51\n73 91\n13 49\n\nSample Output 3\n\n4\n4\n1\n1\n1\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 881, "cpu_time_ms": 2073, "memory_kb": 63916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s313172422", "group_id": "codeNet:p03477", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint A = sc.nextInt();\n\t\tint B = sc.nextInt();\n\t\tint C = sc.nextInt();\n\t\tint D = sc.nextInt();\n\t\tint left = A + B;\n\t\tint right = C + D;\n\t\tif (left > right)\n\t\t\tSystem.out.println(\"Left\");\n\t\telse if (left == right)\n\t\t\tSystem.out.println(\"Balanced\");\n\t\telse {\n\t\t\tSystem.out.println(\"Right\");\n\t\t}\n\t\tsc.close();\n\t}\n}", "language": "Java", "metadata": {"date": 1570841522, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03477.html", "problem_id": "p03477", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03477/input.txt", "sample_output_relpath": "derived/input_output/data/p03477/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03477/Java/s313172422.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s313172422", "user_id": "u849975039"}, "prompt_components": {"gold_output": "Left\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint A = sc.nextInt();\n\t\tint B = sc.nextInt();\n\t\tint C = sc.nextInt();\n\t\tint D = sc.nextInt();\n\t\tint left = A + B;\n\t\tint right = C + D;\n\t\tif (left > right)\n\t\t\tSystem.out.println(\"Left\");\n\t\telse if (left == right)\n\t\t\tSystem.out.println(\"Balanced\");\n\t\telse {\n\t\t\tSystem.out.println(\"Right\");\n\t\t}\n\t\tsc.close();\n\t}\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "sample_input": "3 8 7 1\n"}, "reference_outputs": ["Left\n"], "source_document_id": "p03477", "source_text": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 109, "memory_kb": 22096}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s819855290", "group_id": "codeNet:p03479", "input_text": "import java.util.*;\n\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String s = sc.next();\n Long X = Long.parseLong(s);\n String line = sc.next();\n Long Y = Long.parseLong(line);\n Long sum = X * 2;\n int count = 2;\n \n while(true){\n sum = sum * 2;\n if(sum > Y){\n System.out.println(count);\n System.exit(0);\n }\n count++;\n if(X == count){\n System.out.println(count);\n System.exit(0);\n }\n }\n }\n}", "language": "Java", "metadata": {"date": 1514089092, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03479.html", "problem_id": "p03479", "resource_group": "high_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/Java/s819855290.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s819855290", "user_id": "u092945938"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*;\n\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String s = sc.next();\n Long X = Long.parseLong(s);\n String line = sc.next();\n Long Y = Long.parseLong(line);\n Long sum = X * 2;\n int count = 2;\n \n while(true){\n sum = sum * 2;\n if(sum > Y){\n System.out.println(count);\n System.exit(0);\n }\n count++;\n if(X == count){\n System.out.println(count);\n System.exit(0);\n }\n }\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": 645, "cpu_time_ms": 90, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s695273064", "group_id": "codeNet:p03482", "input_text": "import java.util.Scanner;\n\nclass Main{\n\tpublic static void main(String[]$){\n\t\tScanner s=new Scanner(System.in);\n\t\tString c=s.next();\n\t\tint max=c.length();\n\t\tfor(int i=1;i xmv = new ArrayList();\n\t\tList ymv = new ArrayList();\n\t\t\n\t\tint cnt = 0;\n\t\tboolean goX = true;\n\t\tfor(int i=0;i xmv = new ArrayList();\n\t\tList ymv = new ArrayList();\n\t\t\n\t\tint cnt = 0;\n\t\tboolean goX = true;\n\t\tfor(int i=0;i=a[n-1]) remove += (sameElement-a[n-1]);\n \t\telse remove += sameElement;\n \t\tsameElement=1;\n \t}\n }\n if(sameElement>=a[N-1]) remove += (sameElement-a[N-1]);\n else remove += sameElement;\n \n System.out.println(remove);\n \n \n }\n}", "language": "Java", "metadata": {"date": 1513476577, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03489.html", "problem_id": "p03489", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03489/input.txt", "sample_output_relpath": "derived/input_output/data/p03489/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03489/Java/s313273833.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s313273833", "user_id": "u997055883"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int[] a = new int[N];\n for(int n=0;n=a[n-1]) remove += (sameElement-a[n-1]);\n \t\telse remove += sameElement;\n \t\tsameElement=1;\n \t}\n }\n if(sameElement>=a[N-1]) remove += (sameElement-a[N-1]);\n else remove += sameElement;\n \n System.out.println(remove);\n \n \n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "sample_input": "4\n3 3 3 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03489", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 757, "cpu_time_ms": 525, "memory_kb": 50376}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s867431366", "group_id": "codeNet:p03494", "input_text": "import java.util.*;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint count = Integer.parseInt(sc.nextLine());\n\t\tint[] num = new int[count];\n\t\tint[] max = new int[count];\n\t\tint maxOperate = 0;\n\t\tSystem.out.println(\"count\"+ count);\n\t\tfor(int i = 0 ; i < count ;i++) {\n\t\t\tnum[i] = sc.nextInt();\n\t\t\tSystem.out.println(\"i:\"+i+ \",num\" +num[i]);\n\t\t\tmax[i] = 0;\n\t\t\twhile((num[i]%2)==0) {\n\t\t\t\tnum[i] = num[i]/2;\n\t\t\t\tmax[i] += 1;\n\t\t\t}\n\t\t\tif(i == 0) {\n\t\t\t\tmaxOperate = max[i];\n\t\t\t}else if(maxOperate > max[i]) {\n\t\t\t\tmaxOperate = max[i];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(maxOperate);\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1600308294, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p03494.html", "problem_id": "p03494", "resource_group": "high_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/Java/s867431366.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s867431366", "user_id": "u783523887"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint count = Integer.parseInt(sc.nextLine());\n\t\tint[] num = new int[count];\n\t\tint[] max = new int[count];\n\t\tint maxOperate = 0;\n\t\tSystem.out.println(\"count\"+ count);\n\t\tfor(int i = 0 ; i < count ;i++) {\n\t\t\tnum[i] = sc.nextInt();\n\t\t\tSystem.out.println(\"i:\"+i+ \",num\" +num[i]);\n\t\t\tmax[i] = 0;\n\t\t\twhile((num[i]%2)==0) {\n\t\t\t\tnum[i] = num[i]/2;\n\t\t\t\tmax[i] += 1;\n\t\t\t}\n\t\t\tif(i == 0) {\n\t\t\t\tmaxOperate = max[i];\n\t\t\t}else if(maxOperate > max[i]) {\n\t\t\t\tmaxOperate = max[i];\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(maxOperate);\n\t}\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": 635, "cpu_time_ms": 189, "memory_kb": 39496}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s903545562", "group_id": "codeNet:p03494", "input_text": "import java.util.*;\n\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n\n //入力\n int n = sc.nextInt();\n int[] a = new int[n];\n for(int i=0; i0; i--)\n\t\t{\n\t\t\tif(sumk)\n\t\t\t\t\tans+=(sum-k)*i;\n\t//\t\t\tSystem.out.println(ans+\" \"+i);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tans+=occs[i]*i;\n\t//\t\t\tSystem.out.println(ans+\" \"+i);\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n\tstatic StringBuilder ans=new StringBuilder();\n\tstatic class Reader\n\t {\n\t final private int BUFFER_SIZE = 1 << 16;\n\t private DataInputStream din;\n\t private byte[] buffer;\n\t private int bufferPointer, bytesRead;\n\t StringTokenizer st;\n\t \n\t public Reader()\n\t {\n\t din = new DataInputStream(System.in);\n\t buffer = new byte[BUFFER_SIZE];\n\t bufferPointer = bytesRead = 0;\n\t }\n\t \n\t public Reader(String file_name) throws IOException\n\t {\n\t din = new DataInputStream(new FileInputStream(file_name));\n\t buffer = new byte[BUFFER_SIZE];\n\t bufferPointer = bytesRead = 0;\n\t }\n\t \n\t public String next() throws IOException\n\t {\n\t \twhile(st==null||!st.hasMoreElements())\n\t \t{\n\t \t\ttry\n\t \t\t{\n\t \t\t\tst=new StringTokenizer(readLine());\n\t \t\t}\n\t \t\tcatch(IOException e)\n\t \t\t{\n\t \t\t\te.printStackTrace();\n\t \t\t}\n\t \t}\n\t \treturn\n\t \t\t\tst.nextToken();\n\t }\n\t public String readLine() throws IOException\n\t {\n\t byte[] buf = new byte[64]; // line length\n\t int cnt = 0, c;\n\t while ((c = read()) != -1)\n\t {\n\t if (c == '\\n')\n\t break;\n\t buf[cnt++] = (byte) c;\n\t }\n\t return new String(buf, 0, cnt);\n\t }\n\t \n\t public int nextInt() throws IOException\n\t {\n\t int ret = 0;\n\t byte c = read();\n\t while (c <= ' ')\n\t c = read();\n\t boolean neg = (c == '-');\n\t if (neg)\n\t c = read();\n\t do\n\t {\n\t ret = ret * 10 + c - '0';\n\t } while ((c = read()) >= '0' && c <= '9');\n\t \n\t if (neg)\n\t return -ret;\n\t return ret;\n\t }\n\t \n\t public long nextLong() throws IOException\n\t {\n\t long ret = 0;\n\t byte c = read();\n\t while (c <= ' ')\n\t c = read();\n\t boolean neg = (c == '-');\n\t if (neg)\n\t c = read();\n\t do {\n\t ret = ret * 10 + c - '0';\n\t }\n\t while ((c = read()) >= '0' && c <= '9');\n\t if (neg)\n\t return -ret;\n\t return ret;\n\t }\n\t \n\t public double nextDouble() throws IOException\n\t {\n\t double ret = 0, div = 1;\n\t byte c = read();\n\t while (c <= ' ')\n\t c = read();\n\t boolean neg = (c == '-');\n\t if (neg)\n\t c = read();\n\t \n\t do {\n\t ret = ret * 10 + c - '0';\n\t }\n\t while ((c = read()) >= '0' && c <= '9');\n\t \n\t if (c == '.')\n\t {\n\t while ((c = read()) >= '0' && c <= '9')\n\t {\n\t ret += (c - '0') / (div *= 10);\n\t }\n\t }\n\t \n\t if (neg)\n\t return -ret;\n\t return ret;\n\t }\n\t \n\t private void fillBuffer() throws IOException\n\t {\n\t bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);\n\t if (bytesRead == -1)\n\t buffer[0] = -1;\n\t }\n\t \n\t private byte read() throws IOException\n\t {\n\t if (bufferPointer == bytesRead)\n\t fillBuffer();\n\t return buffer[bufferPointer++];\n\t }\n\t \n\t public void close() throws IOException\n\t {\n\t if (din == null)\n\t return;\n\t din.close();\n\t }\n\t }\n} ", "language": "Java", "metadata": {"date": 1512961468, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03495.html", "problem_id": "p03495", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03495/input.txt", "sample_output_relpath": "derived/input_output/data/p03495/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03495/Java/s301027147.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s301027147", "user_id": "u317879811"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\npublic class Main\n{\n\tpublic static void main(String[] args) throws IOException\n\t{\n\t\tReader in=new Reader();\n\t\tint n=in.nextInt(),k=in.nextInt();\n\t\tint a[]=new int[n];\n\t\tfor(int i=0; i0; i--)\n\t\t{\n\t\t\tif(sumk)\n\t\t\t\t\tans+=(sum-k)*i;\n\t//\t\t\tSystem.out.println(ans+\" \"+i);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tans+=occs[i]*i;\n\t//\t\t\tSystem.out.println(ans+\" \"+i);\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n\tstatic StringBuilder ans=new StringBuilder();\n\tstatic class Reader\n\t {\n\t final private int BUFFER_SIZE = 1 << 16;\n\t private DataInputStream din;\n\t private byte[] buffer;\n\t private int bufferPointer, bytesRead;\n\t StringTokenizer st;\n\t \n\t public Reader()\n\t {\n\t din = new DataInputStream(System.in);\n\t buffer = new byte[BUFFER_SIZE];\n\t bufferPointer = bytesRead = 0;\n\t }\n\t \n\t public Reader(String file_name) throws IOException\n\t {\n\t din = new DataInputStream(new FileInputStream(file_name));\n\t buffer = new byte[BUFFER_SIZE];\n\t bufferPointer = bytesRead = 0;\n\t }\n\t \n\t public String next() throws IOException\n\t {\n\t \twhile(st==null||!st.hasMoreElements())\n\t \t{\n\t \t\ttry\n\t \t\t{\n\t \t\t\tst=new StringTokenizer(readLine());\n\t \t\t}\n\t \t\tcatch(IOException e)\n\t \t\t{\n\t \t\t\te.printStackTrace();\n\t \t\t}\n\t \t}\n\t \treturn\n\t \t\t\tst.nextToken();\n\t }\n\t public String readLine() throws IOException\n\t {\n\t byte[] buf = new byte[64]; // line length\n\t int cnt = 0, c;\n\t while ((c = read()) != -1)\n\t {\n\t if (c == '\\n')\n\t break;\n\t buf[cnt++] = (byte) c;\n\t }\n\t return new String(buf, 0, cnt);\n\t }\n\t \n\t public int nextInt() throws IOException\n\t {\n\t int ret = 0;\n\t byte c = read();\n\t while (c <= ' ')\n\t c = read();\n\t boolean neg = (c == '-');\n\t if (neg)\n\t c = read();\n\t do\n\t {\n\t ret = ret * 10 + c - '0';\n\t } while ((c = read()) >= '0' && c <= '9');\n\t \n\t if (neg)\n\t return -ret;\n\t return ret;\n\t }\n\t \n\t public long nextLong() throws IOException\n\t {\n\t long ret = 0;\n\t byte c = read();\n\t while (c <= ' ')\n\t c = read();\n\t boolean neg = (c == '-');\n\t if (neg)\n\t c = read();\n\t do {\n\t ret = ret * 10 + c - '0';\n\t }\n\t while ((c = read()) >= '0' && c <= '9');\n\t if (neg)\n\t return -ret;\n\t return ret;\n\t }\n\t \n\t public double nextDouble() throws IOException\n\t {\n\t double ret = 0, div = 1;\n\t byte c = read();\n\t while (c <= ' ')\n\t c = read();\n\t boolean neg = (c == '-');\n\t if (neg)\n\t c = read();\n\t \n\t do {\n\t ret = ret * 10 + c - '0';\n\t }\n\t while ((c = read()) >= '0' && c <= '9');\n\t \n\t if (c == '.')\n\t {\n\t while ((c = read()) >= '0' && c <= '9')\n\t {\n\t ret += (c - '0') / (div *= 10);\n\t }\n\t }\n\t \n\t if (neg)\n\t return -ret;\n\t return ret;\n\t }\n\t \n\t private void fillBuffer() throws IOException\n\t {\n\t bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);\n\t if (bytesRead == -1)\n\t buffer[0] = -1;\n\t }\n\t \n\t private byte read() throws IOException\n\t {\n\t if (bufferPointer == bytesRead)\n\t fillBuffer();\n\t return buffer[bufferPointer++];\n\t }\n\t \n\t public void close() throws IOException\n\t {\n\t if (din == null)\n\t return;\n\t din.close();\n\t }\n\t }\n} ", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi has N balls. Initially, an integer A_i is written on the i-th ball.\n\nHe would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.\n\nFind the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 200000\n\n1 \\leq A_i \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nSample Input 1\n\n5 2\n1 1 2 2 5\n\nSample Output 1\n\n1\n\nFor example, if we rewrite the integer on the fifth ball to 2, there are two different integers written on the balls: 1 and 2.\nOn the other hand, it is not possible to rewrite the integers on zero balls so that there are at most two different integers written on the balls, so we should print 1.\n\nSample Input 2\n\n4 4\n1 1 2 2\n\nSample Output 2\n\n0\n\nAlready in the beginning, there are two different integers written on the balls, so we do not need to rewrite anything.\n\nSample Input 3\n\n10 3\n5 1 3 2 4 1 1 2 3 4\n\nSample Output 3\n\n3", "sample_input": "5 2\n1 1 2 2 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03495", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi has N balls. Initially, an integer A_i is written on the i-th ball.\n\nHe would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.\n\nFind the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 200000\n\n1 \\leq A_i \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nSample Input 1\n\n5 2\n1 1 2 2 5\n\nSample Output 1\n\n1\n\nFor example, if we rewrite the integer on the fifth ball to 2, there are two different integers written on the balls: 1 and 2.\nOn the other hand, it is not possible to rewrite the integers on zero balls so that there are at most two different integers written on the balls, so we should print 1.\n\nSample Input 2\n\n4 4\n1 1 2 2\n\nSample Output 2\n\n0\n\nAlready in the beginning, there are two different integers written on the balls, so we do not need to rewrite anything.\n\nSample Input 3\n\n10 3\n5 1 3 2 4 1 1 2 3 4\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4555, "cpu_time_ms": 201, "memory_kb": 27224}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s451232638", "group_id": "codeNet:p03502", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint N = sc.nextInt();\n\t\tint a,b,c,d,e,f,g,h,i,fx ;\n\t\tString ans = \" \" ;\n\n\t\tfor (int x = 1 ; x <= N ; x++) {\n\t\t\ta = x % 10 ; //1の位\n\t\t\tb = (x/10) % 10 ; //10の位\n\t\t\tc = (x/100) % 10 ; //100の位\n\t\t\td = (x/1000) % 10 ; //1000の位\n\t\t\te = (x/10000) % 10 ; //10000の位\n\t\t\tf = (x/100000) % 10 ; //100000の位\n\t\t\tg = (x/1000000) % 10 ; //1000000の位\n\t\t\th = (x/10000000) % 10 ; //10000000の位\n\t\t\ti = (x/100000000) % 10 ; //100000000の位\n\t\t\tfx = a+b+c+d+e+f+g+h+i ;\n\n\t\t\tif ( N % fx == 0 ) {\n\t\t\t\tans = \"Yes\" ;\n\t\t\t} else {\n\t\t\t\tans = \"No\" ;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1566582021, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03502.html", "problem_id": "p03502", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03502/input.txt", "sample_output_relpath": "derived/input_output/data/p03502/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03502/Java/s451232638.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s451232638", "user_id": "u202101624"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint N = sc.nextInt();\n\t\tint a,b,c,d,e,f,g,h,i,fx ;\n\t\tString ans = \" \" ;\n\n\t\tfor (int x = 1 ; x <= N ; x++) {\n\t\t\ta = x % 10 ; //1の位\n\t\t\tb = (x/10) % 10 ; //10の位\n\t\t\tc = (x/100) % 10 ; //100の位\n\t\t\td = (x/1000) % 10 ; //1000の位\n\t\t\te = (x/10000) % 10 ; //10000の位\n\t\t\tf = (x/100000) % 10 ; //100000の位\n\t\t\tg = (x/1000000) % 10 ; //1000000の位\n\t\t\th = (x/10000000) % 10 ; //10000000の位\n\t\t\ti = (x/100000000) % 10 ; //100000000の位\n\t\t\tfx = a+b+c+d+e+f+g+h+i ;\n\n\t\t\tif ( N % fx == 0 ) {\n\t\t\t\tans = \"Yes\" ;\n\t\t\t} else {\n\t\t\t\tans = \"No\" ;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAn integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10.\n\nGiven an integer N, determine whether it is a Harshad number.\n\nConstraints\n\n1?N?10^8\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint Yes if N is a Harshad number; print No otherwise.\n\nSample Input 1\n\n12\n\nSample Output 1\n\nYes\n\nf(12)=1+2=3. Since 12 is divisible by 3, 12 is a Harshad number.\n\nSample Input 2\n\n57\n\nSample Output 2\n\nNo\n\nf(57)=5+7=12. Since 57 is not divisible by 12, 12 is not a Harshad number.\n\nSample Input 3\n\n148\n\nSample Output 3\n\nNo", "sample_input": "12\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03502", "source_text": "Score : 200 points\n\nProblem Statement\n\nAn integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10.\n\nGiven an integer N, determine whether it is a Harshad number.\n\nConstraints\n\n1?N?10^8\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint Yes if N is a Harshad number; print No otherwise.\n\nSample Input 1\n\n12\n\nSample Output 1\n\nYes\n\nf(12)=1+2=3. Since 12 is divisible by 3, 12 is a Harshad number.\n\nSample Input 2\n\n57\n\nSample Output 2\n\nNo\n\nf(57)=5+7=12. Since 57 is not divisible by 12, 12 is not a Harshad number.\n\nSample Input 3\n\n148\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2081, "memory_kb": 25300}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s477971691", "group_id": "codeNet:p03543", "input_text": "import java.util.*;\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tA();\n\t}\n\t\n\tpublic static void A() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tInteger n = sc.nextInt();\n\t\tsc.close();\n\t\tString num = n.toString();\n\t\tif(num.charAt(1) != num.charAt(2)) {\n\t\t\tSystem.out.println(\"No\");\n\t\t\treturn;\n\t\t}\n\t\tchar mid = num.charAt(1);\n\t\tif(mid == num.charAt(0) || mid == num.charAt(3)) {\n\t\t\tSystem.out.println(\"Yes\");\n\t\t}\n\t\telse System.out.println(\"No\");\n\t}\n\t\n\t\n}\n", "language": "Java", "metadata": {"date": 1555251570, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03543.html", "problem_id": "p03543", "resource_group": "high_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/Java/s477971691.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s477971691", "user_id": "u086752773"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*;\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tA();\n\t}\n\t\n\tpublic static void A() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tInteger n = sc.nextInt();\n\t\tsc.close();\n\t\tString num = n.toString();\n\t\tif(num.charAt(1) != num.charAt(2)) {\n\t\t\tSystem.out.println(\"No\");\n\t\t\treturn;\n\t\t}\n\t\tchar mid = num.charAt(1);\n\t\tif(mid == num.charAt(0) || mid == num.charAt(3)) {\n\t\t\tSystem.out.println(\"Yes\");\n\t\t}\n\t\telse System.out.println(\"No\");\n\t}\n\t\n\t\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": 470, "cpu_time_ms": 97, "memory_kb": 23508}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s680530983", "group_id": "codeNet:p03543", "input_text": "import java.util.*;\nclass Main\n{\n public static void main (String[] args)\n {\n Scanner sc = new Scanner(System.in);\n String s = sc.next();\n char c0 = s.charAt(0), c1 = s.charAt(1),\n c2 = s.charAt(2), c3 = s.charAt(3);\n String ans = \"No\";\n if((c0 == c1 || c2 == c3) && (c1 == c2)) ans = \"Yes\";\n System.out.print(ans);\n }\n}", "language": "Java", "metadata": {"date": 1540430229, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03543.html", "problem_id": "p03543", "resource_group": "high_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/Java/s680530983.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s680530983", "user_id": "u434662823"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*;\nclass Main\n{\n public static void main (String[] args)\n {\n Scanner sc = new Scanner(System.in);\n String s = sc.next();\n char c0 = s.charAt(0), c1 = s.charAt(1),\n c2 = s.charAt(2), c3 = s.charAt(3);\n String ans = \"No\";\n if((c0 == c1 || c2 == c3) && (c1 == c2)) ans = \"Yes\";\n System.out.print(ans);\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": 383, "cpu_time_ms": 92, "memory_kb": 23380}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s195374253", "group_id": "codeNet:p03551", "input_text": "import java.util.*;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint N = sc.nextInt();\n\t\tint M = sc.nextInt();\n\t\t\n\t\tint commit = 1< getCountMap(int[] array) {\n\t\t\tMap map = new TreeMap<>();\n\t\t\tfor (int x : array)\n\t\t\t\tmap.merge(x, 1, Integer::sum);\n\t\t\treturn map;\n\t\t}\n\t\t/**\n\t\t * 指定された要素以上の値が現れる最初の位置のイテレータを取得する\n\t\t * */\n\t\tpublic static int lowerBinarySearch(int[] a, int obj) {\n\t\t\tint l = 0,r = a.length - 1;\n\t\t\twhile (r - l >= 0) {\n\t\t\t\tint c = (l + r) / 2;\n\t\t\t\tif (obj <= a[c]) {\n\t\t\t\t\tr = c - 1;\n\t\t\t\t} else {\n\t\t\t\t\tl = c + 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn l;\n\t\t}\n\n\t\t/**\n\t\t * 指定された要素より大きい値が現れる最初の位置のイテレータを取得する\n\t\t * */\n\t\tpublic static int upperBinarySearch(int[] a, int obj) {\n\t\t\tint l = 0,r = a.length - 1;\n\t\t\twhile (r - l >= 0) {\n\t\t\t\tint c = (l + r) / 2;\n\t\t\t\tif (a[c] <= obj) {\n\t\t\t\t\tl = c + 1;\n\t\t\t\t} else {\n\t\t\t\t\tr = c - 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn l;\n\t\t}\n\n\t}\n\n\tstatic class InputReader {\n\t\tBufferedReader in;\n\t\tStringTokenizer tok;\n\n\t\tpublic String nextString() {\n\t\t\twhile (!tok.hasMoreTokens()) {\n\t\t\t\ttry {\n\t\t\t\t\ttok = new StringTokenizer(in.readLine(), \" \");\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn tok.nextToken();\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\treturn Integer.parseInt(nextString());\n\t\t}\n\n\t\tpublic long nextLong() {\n\t\t\treturn Long.parseLong(nextString());\n\t\t}\n\n\t\tpublic int[] nextIntArray(int n) {\n\t\t\tint[] res = new int[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tres[i] = nextInt();\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic InputReader(InputStream inputStream) {\n\t\t\tin = new BufferedReader(new InputStreamReader(inputStream));\n\t\t\ttok = new StringTokenizer(\"\");\n\t\t}\n\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1518662317, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03557.html", "problem_id": "p03557", "resource_group": "high_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/Java/s524779040.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s524779040", "user_id": "u266665184"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.InputMismatchException;\nimport java.util.Map;\nimport java.util.StringTokenizer;\nimport java.util.TreeMap;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tInputStream inputStream = System.in;\n\t\tOutputStream outputStream = System.out;\n\t\tInputReader in = new InputReader(inputStream);\n\t\tPrintWriter out = new PrintWriter(outputStream);\n\t\tTaskX solver = new TaskX();\n\t\tsolver.solve(1, in, out);\n\t\tout.close();\n\t}\n\n\tstatic class TaskX {\n\t\tpublic void solve(int testNumber, InputReader in, PrintWriter out) {\n\n\t\t\tint n = in.nextInt();\n\t\t\tint[] a = in.nextIntArray(n);\n\t\t\tArrays.sort(a);\n\t\t\tint[] b = in.nextIntArray(n);\n\t\t\tint[] c = in.nextIntArray(n);\n\t\t\tArrays.sort(c);\n\n\t\t\tlong count = 0L;\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tlong ubc = ArrayUtils.lowerBinarySearch(a, b[i]);\n\t\t\t\tlong obc = n - (ArrayUtils.upperBinarySearch(c, b[i]));\n\t\t\t\tcount += (ubc * obc);\n\t\t\t}\n\t\t\tout.println(count);\n\n\t\t}\n\n\t}\n\n\tstatic class ArrayUtils {\n\t\tpublic static Map getCountMap(int[] array) {\n\t\t\tMap map = new TreeMap<>();\n\t\t\tfor (int x : array)\n\t\t\t\tmap.merge(x, 1, Integer::sum);\n\t\t\treturn map;\n\t\t}\n\t\t/**\n\t\t * 指定された要素以上の値が現れる最初の位置のイテレータを取得する\n\t\t * */\n\t\tpublic static int lowerBinarySearch(int[] a, int obj) {\n\t\t\tint l = 0,r = a.length - 1;\n\t\t\twhile (r - l >= 0) {\n\t\t\t\tint c = (l + r) / 2;\n\t\t\t\tif (obj <= a[c]) {\n\t\t\t\t\tr = c - 1;\n\t\t\t\t} else {\n\t\t\t\t\tl = c + 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn l;\n\t\t}\n\n\t\t/**\n\t\t * 指定された要素より大きい値が現れる最初の位置のイテレータを取得する\n\t\t * */\n\t\tpublic static int upperBinarySearch(int[] a, int obj) {\n\t\t\tint l = 0,r = a.length - 1;\n\t\t\twhile (r - l >= 0) {\n\t\t\t\tint c = (l + r) / 2;\n\t\t\t\tif (a[c] <= obj) {\n\t\t\t\t\tl = c + 1;\n\t\t\t\t} else {\n\t\t\t\t\tr = c - 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn l;\n\t\t}\n\n\t}\n\n\tstatic class InputReader {\n\t\tBufferedReader in;\n\t\tStringTokenizer tok;\n\n\t\tpublic String nextString() {\n\t\t\twhile (!tok.hasMoreTokens()) {\n\t\t\t\ttry {\n\t\t\t\t\ttok = new StringTokenizer(in.readLine(), \" \");\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new InputMismatchException();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn tok.nextToken();\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\treturn Integer.parseInt(nextString());\n\t\t}\n\n\t\tpublic long nextLong() {\n\t\t\treturn Long.parseLong(nextString());\n\t\t}\n\n\t\tpublic int[] nextIntArray(int n) {\n\t\t\tint[] res = new int[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tres[i] = nextInt();\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic InputReader(InputStream inputStream) {\n\t\t\tin = new BufferedReader(new InputStreamReader(inputStream));\n\t\t\ttok = new StringTokenizer(\"\");\n\t\t}\n\n\t}\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": 2820, "cpu_time_ms": 396, "memory_kb": 50536}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s353382056", "group_id": "codeNet:p03560", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.StringTokenizer;\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tInputStream inputStream = System.in;\n\t\tOutputStream outputStream = System.out;\n\t\tFastScanner in = new FastScanner(inputStream);\n\t\tPrintWriter out = new PrintWriter(outputStream);\n\t\tTaskD solver = new TaskD();\n\t\tsolver.solve(1, in, out);\n\t\tout.close();\n\t}\n\n\tstatic class TaskD {\n\t\tpublic void solve(int testNumber, FastScanner in, PrintWriter out) {\n\t\t\tint k = in.nextInt();\n\t\t\tint ans = Integer.MAX_VALUE;\n\t\t\tfor (int i = 1; i <= (int) 3e7; i++) {\n\t\t\t\tlong x = (long) i * k;\n\t\t\t\tint cur = 0;\n\t\t\t\twhile (x > 0) {\n\t\t\t\t\tcur += x % 10;\n\t\t\t\t\tx /= 10;\n\t\t\t\t}\n\t\t\t\tans = Math.min(ans, cur);\n\t\t\t}\n\t\t\tout.println(ans);\n\t\t}\n\n\t}\n\n\tstatic class FastScanner {\n\t\tprivate BufferedReader in;\n\t\tprivate StringTokenizer st;\n\n\t\tpublic FastScanner(InputStream stream) {\n\t\t\tin = new BufferedReader(new InputStreamReader(stream));\n\t\t}\n\n\t\tpublic String next() {\n\t\t\twhile (st == null || !st.hasMoreTokens()) {\n\t\t\t\ttry {\n\t\t\t\t\tString rl = in.readLine();\n\t\t\t\t\tif (rl == null) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tst = new StringTokenizer(rl);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new RuntimeException(e);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t}\n}\n\n", "language": "Java", "metadata": {"date": 1509844517, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03560.html", "problem_id": "p03560", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03560/input.txt", "sample_output_relpath": "derived/input_output/data/p03560/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03560/Java/s353382056.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s353382056", "user_id": "u113560961"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.StringTokenizer;\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tInputStream inputStream = System.in;\n\t\tOutputStream outputStream = System.out;\n\t\tFastScanner in = new FastScanner(inputStream);\n\t\tPrintWriter out = new PrintWriter(outputStream);\n\t\tTaskD solver = new TaskD();\n\t\tsolver.solve(1, in, out);\n\t\tout.close();\n\t}\n\n\tstatic class TaskD {\n\t\tpublic void solve(int testNumber, FastScanner in, PrintWriter out) {\n\t\t\tint k = in.nextInt();\n\t\t\tint ans = Integer.MAX_VALUE;\n\t\t\tfor (int i = 1; i <= (int) 3e7; i++) {\n\t\t\t\tlong x = (long) i * k;\n\t\t\t\tint cur = 0;\n\t\t\t\twhile (x > 0) {\n\t\t\t\t\tcur += x % 10;\n\t\t\t\t\tx /= 10;\n\t\t\t\t}\n\t\t\t\tans = Math.min(ans, cur);\n\t\t\t}\n\t\t\tout.println(ans);\n\t\t}\n\n\t}\n\n\tstatic class FastScanner {\n\t\tprivate BufferedReader in;\n\t\tprivate StringTokenizer st;\n\n\t\tpublic FastScanner(InputStream stream) {\n\t\t\tin = new BufferedReader(new InputStreamReader(stream));\n\t\t}\n\n\t\tpublic String next() {\n\t\t\twhile (st == null || !st.hasMoreTokens()) {\n\t\t\t\ttry {\n\t\t\t\t\tString rl = in.readLine();\n\t\t\t\t\tif (rl == null) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tst = new StringTokenizer(rl);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new RuntimeException(e);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t}\n}\n\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nFind the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nConstraints\n\n2 \\leq K \\leq 10^5\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\n12=6×2 yields the smallest sum.\n\nSample Input 2\n\n41\n\nSample Output 2\n\n5\n\n11111=41×271 yields the smallest sum.\n\nSample Input 3\n\n79992\n\nSample Output 3\n\n36", "sample_input": "6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03560", "source_text": "Score : 700 points\n\nProblem Statement\n\nFind the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nConstraints\n\n2 \\leq K \\leq 10^5\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\n12=6×2 yields the smallest sum.\n\nSample Input 2\n\n41\n\nSample Output 2\n\n5\n\n11111=41×271 yields the smallest sum.\n\nSample Input 3\n\n79992\n\nSample Output 3\n\n36", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1595, "cpu_time_ms": 1068, "memory_kb": 21588}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s477357840", "group_id": "codeNet:p03561", "input_text": "import java.util.*;\n\npublic class Main{\n\n private void print(int[] arrayMid){\n StringBuilder Mid = new StringBuilder();\n for(int i = 0; i < arrayMid.length; i++){\n Mid.append(arrayMid[i] + \" \");\n }\n System.out.print(Mid);\n }\n\n private void Even(int K, int N){\n int[] arrayMid = new int[N];\n arrayMid[0] = K/2;\n for(int i = 1; i < N; i ++){\n arrayMid[i] = K;\n }\n print(arrayMid);\n }\n\n private void Odd(int K, int N){\n int[] arrayMid = new int[N];\n for(int i = 0; i < N; i ++){\n arrayMid[i] = (K + 1) / 2;\n }\n for(int i = 0; i < N / 2; i ++){\n if(arrayMid[arrayMid.length - 1] == 1) arrayMid = Arrays.copyOf(arrayMid, arrayMid.length - 1);\n else arrayMid[arrayMid.length - 1] --;\n }\n print(arrayMid);\n }\n\n private void Judge(int K, int N){\n if(K % 2 == 0) Even(K, N);\n else Odd(K, N);\n }\n\n public static void main(String [] args){\n Scanner input = new Scanner(System.in);\n int[] in = new int[2];\n for(int i = 0; i < 2; i++){\n in[i] = input.nextInt();\n }\n Main myEncyclopedia = new Main();\n myEncyclopedia.Judge(in[0], in[1]);\n input.close();\n\n }\n}", "language": "Java", "metadata": {"date": 1513028383, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03561.html", "problem_id": "p03561", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03561/input.txt", "sample_output_relpath": "derived/input_output/data/p03561/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03561/Java/s477357840.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s477357840", "user_id": "u343976835"}, "prompt_components": {"gold_output": "2 1\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main{\n\n private void print(int[] arrayMid){\n StringBuilder Mid = new StringBuilder();\n for(int i = 0; i < arrayMid.length; i++){\n Mid.append(arrayMid[i] + \" \");\n }\n System.out.print(Mid);\n }\n\n private void Even(int K, int N){\n int[] arrayMid = new int[N];\n arrayMid[0] = K/2;\n for(int i = 1; i < N; i ++){\n arrayMid[i] = K;\n }\n print(arrayMid);\n }\n\n private void Odd(int K, int N){\n int[] arrayMid = new int[N];\n for(int i = 0; i < N; i ++){\n arrayMid[i] = (K + 1) / 2;\n }\n for(int i = 0; i < N / 2; i ++){\n if(arrayMid[arrayMid.length - 1] == 1) arrayMid = Arrays.copyOf(arrayMid, arrayMid.length - 1);\n else arrayMid[arrayMid.length - 1] --;\n }\n print(arrayMid);\n }\n\n private void Judge(int K, int N){\n if(K % 2 == 0) Even(K, N);\n else Odd(K, N);\n }\n\n public static void main(String [] args){\n Scanner input = new Scanner(System.in);\n int[] in = new int[2];\n for(int i = 0; i < 2; i++){\n in[i] = input.nextInt();\n }\n Main myEncyclopedia = new Main();\n myEncyclopedia.Judge(in[0], in[1]);\n input.close();\n\n }\n}", "problem_context": "Score : 800 points\n\nProblem Statement\n\nIn Finite Encyclopedia of Integer Sequences (FEIS), all integer sequences of lengths between 1 and N (inclusive) consisting of integers between 1 and K (inclusive) are listed.\n\nLet the total number of sequences listed in FEIS be X. Among those sequences, find the (X/2)-th (rounded up to the nearest integer) lexicographically smallest one.\n\nConstraints\n\n1 \\leq N,K \\leq 3 × 10^5\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\n\nOutput\n\nPrint the (X/2)-th (rounded up to the nearest integer) lexicographically smallest sequence listed in FEIS, with spaces in between, where X is the total number of sequences listed in FEIS.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n2 1\n\nThere are 12 sequences listed in FEIS: (1),(1,1),(1,2),(1,3),(2),(2,1),(2,2),(2,3),(3),(3,1),(3,2),(3,3).\nThe (12/2 = 6)-th lexicographically smallest one among them is (2,1).\n\nSample Input 2\n\n2 4\n\nSample Output 2\n\n1 2 2 2\n\nSample Input 3\n\n5 14\n\nSample Output 3\n\n3 3 3 3 3 3 3 3 3 3 3 3 2 2", "sample_input": "3 2\n"}, "reference_outputs": ["2 1\n"], "source_document_id": "p03561", "source_text": "Score : 800 points\n\nProblem Statement\n\nIn Finite Encyclopedia of Integer Sequences (FEIS), all integer sequences of lengths between 1 and N (inclusive) consisting of integers between 1 and K (inclusive) are listed.\n\nLet the total number of sequences listed in FEIS be X. Among those sequences, find the (X/2)-th (rounded up to the nearest integer) lexicographically smallest one.\n\nConstraints\n\n1 \\leq N,K \\leq 3 × 10^5\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\n\nOutput\n\nPrint the (X/2)-th (rounded up to the nearest integer) lexicographically smallest sequence listed in FEIS, with spaces in between, where X is the total number of sequences listed in FEIS.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n2 1\n\nThere are 12 sequences listed in FEIS: (1),(1,1),(1,2),(1,3),(2),(2,1),(2,2),(2,3),(3),(3,1),(3,2),(3,3).\nThe (12/2 = 6)-th lexicographically smallest one among them is (2,1).\n\nSample Input 2\n\n2 4\n\nSample Output 2\n\n1 2 2 2\n\nSample Input 3\n\n5 14\n\nSample Output 3\n\n3 3 3 3 3 3 3 3 3 3 3 3 2 2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1309, "cpu_time_ms": 2109, "memory_kb": 348100}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s842785632", "group_id": "codeNet:p03563", "input_text": "import java.util.*;\nclass Main\n{\n public static void main (String[] args)\n {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int k = sc.nextInt();\n int ans = 1;\n System.out.println(2 * k - n);\n }\n}", "language": "Java", "metadata": {"date": 1540510212, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03563.html", "problem_id": "p03563", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03563/input.txt", "sample_output_relpath": "derived/input_output/data/p03563/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03563/Java/s842785632.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s842785632", "user_id": "u434662823"}, "prompt_components": {"gold_output": "2032\n", "input_to_evaluate": "import java.util.*;\nclass Main\n{\n public static void main (String[] args)\n {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int k = sc.nextInt();\n int ans = 1;\n System.out.println(2 * k - n);\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a user of a site that hosts programming contests.\n\nWhen a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows:\n\nLet the current rating of the user be a.\n\nSuppose that the performance of the user in the contest is b.\n\nThen, the new rating of the user will be the avarage of a and b.\n\nFor example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.\n\nTakahashi's current rating is R, and he wants his rating to be exactly G after the next contest.\n\nFind the performance required to achieve it.\n\nConstraints\n\n0 \\leq R, G \\leq 4500\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\nG\n\nOutput\n\nPrint the performance required to achieve the objective.\n\nSample Input 1\n\n2002\n2017\n\nSample Output 1\n\n2032\n\nTakahashi's current rating is 2002.\n\nIf his performance in the contest is 2032, his rating will be the average of 2002 and 2032, which is equal to the desired rating, 2017.\n\nSample Input 2\n\n4500\n0\n\nSample Output 2\n\n-4500\n\nAlthough the current and desired ratings are between 0 and 4500, the performance of a user can be below 0.", "sample_input": "2002\n2017\n"}, "reference_outputs": ["2032\n"], "source_document_id": "p03563", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a user of a site that hosts programming contests.\n\nWhen a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows:\n\nLet the current rating of the user be a.\n\nSuppose that the performance of the user in the contest is b.\n\nThen, the new rating of the user will be the avarage of a and b.\n\nFor example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.\n\nTakahashi's current rating is R, and he wants his rating to be exactly G after the next contest.\n\nFind the performance required to achieve it.\n\nConstraints\n\n0 \\leq R, G \\leq 4500\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\nG\n\nOutput\n\nPrint the performance required to achieve the objective.\n\nSample Input 1\n\n2002\n2017\n\nSample Output 1\n\n2032\n\nTakahashi's current rating is 2002.\n\nIf his performance in the contest is 2032, his rating will be the average of 2002 and 2032, which is equal to the desired rating, 2017.\n\nSample Input 2\n\n4500\n0\n\nSample Output 2\n\n-4500\n\nAlthough the current and desired ratings are between 0 and 4500, the performance of a user can be below 0.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 255, "cpu_time_ms": 93, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s087020109", "group_id": "codeNet:p03567", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\tBufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString S = in.readLine();\n\n\t\tif(S.indexOf(\"AC\") > 0) {\n\t\t\tSystem.out.println(\"Yes\");\n\t\t}else{\n\t\t\tSystem.out.println(\"No\");\n\t\t}\n\t}\n\n}", "language": "Java", "metadata": {"date": 1509325165, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03567.html", "problem_id": "p03567", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03567/input.txt", "sample_output_relpath": "derived/input_output/data/p03567/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03567/Java/s087020109.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s087020109", "user_id": "u960637342"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\tBufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString S = in.readLine();\n\n\t\tif(S.indexOf(\"AC\") > 0) {\n\t\t\tSystem.out.println(\"Yes\");\n\t\t}else{\n\t\t\tSystem.out.println(\"No\");\n\t\t}\n\t}\n\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke built an online judge to hold a programming contest.\n\nWhen a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring.\n(The judge can return any two-character substring of S.)\n\nDetermine whether the judge can return the string AC as the verdict to a program.\n\nConstraints\n\n2 \\leq |S| \\leq 5\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 the judge can return the string AC as a verdict to a program, print Yes; if it cannot, print No.\n\nSample Input 1\n\nBACD\n\nSample Output 1\n\nYes\n\nThe string AC appears in BACD as a contiguous substring (the second and third characters).\n\nSample Input 2\n\nABCD\n\nSample Output 2\n\nNo\n\nAlthough the string ABCD contains both A and C (the first and third characters), the string AC does not appear in ABCD as a contiguous substring.\n\nSample Input 3\n\nCABD\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nACACA\n\nSample Output 4\n\nYes\n\nSample Input 5\n\nXX\n\nSample Output 5\n\nNo", "sample_input": "BACD\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03567", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke built an online judge to hold a programming contest.\n\nWhen a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring.\n(The judge can return any two-character substring of S.)\n\nDetermine whether the judge can return the string AC as the verdict to a program.\n\nConstraints\n\n2 \\leq |S| \\leq 5\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 the judge can return the string AC as a verdict to a program, print Yes; if it cannot, print No.\n\nSample Input 1\n\nBACD\n\nSample Output 1\n\nYes\n\nThe string AC appears in BACD as a contiguous substring (the second and third characters).\n\nSample Input 2\n\nABCD\n\nSample Output 2\n\nNo\n\nAlthough the string ABCD contains both A and C (the first and third characters), the string AC does not appear in ABCD as a contiguous substring.\n\nSample Input 3\n\nCABD\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nACACA\n\nSample Output 4\n\nYes\n\nSample Input 5\n\nXX\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": 443, "cpu_time_ms": 69, "memory_kb": 21076}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s148314423", "group_id": "codeNet:p03578", "input_text": "import java.util.*;\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] d = new int[n];\n for(int i = 0;i < n;i++)d[i]=sc.nextInt();\n int m = sc.nextInt();\n int[] t = new int[m];\n for(int i = 0;i < m;i++)t[i]=sc.nextInt();\n Arrays.sort(d);\n Arrays.sort(t);\n int cnt = 1;\n Map map = new HashMap<>();\n for(int i = 0;i < n-1;i++){\n if(d[i]==d[i+1])cnt++;\n else{\n map.put(d[i],cnt);\n cnt=1;\n }\n }\n map.put(d[n-1],cnt);\n boolean ans = true;\n cnt=1;\n for(int i = 0;i < m-1;i++){\n if(t[i]==t[i+1])cnt++;\n else{\n if(map.get(t[i])==null)ans=false;\n else if(map.get(t[i]) map = new HashMap<>();\n for(int i = 0;i < n-1;i++){\n if(d[i]==d[i+1])cnt++;\n else{\n map.put(d[i],cnt);\n cnt=1;\n }\n }\n map.put(d[n-1],cnt);\n boolean ans = true;\n cnt=1;\n for(int i = 0;i < m-1;i++){\n if(t[i]==t[i+1])cnt++;\n else{\n if(map.get(t[i])==null)ans=false;\n else if(map.get(t[i]) 0 && l % r == 0) {\n long result = l / r;\n out.println(i + \" \" + j + \" \" + r);\n return;\n }\n }\n }\n }\n\n }\n\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private InputReader.SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n\n public int read() {\n if (numChars == -1) {\n throw new InputMismatchException();\n }\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0) {\n return -1;\n }\n }\n return buf[curChar++];\n }\n\n public int nextInt() {\n int c = read();\n while (isSpaceChar(c)) {\n c = read();\n }\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n res *= 10;\n res += c - '0';\n c = read();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n\n public boolean isSpaceChar(int c) {\n if (filter != null) {\n return filter.isSpaceChar(c);\n }\n return isWhitespace(c);\n }\n\n public static boolean isWhitespace(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\n\n }\n\n static class OutputWriter {\n private final PrintWriter writer;\n\n public OutputWriter(OutputStream outputStream) {\n writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));\n }\n\n public OutputWriter(Writer writer) {\n this.writer = new PrintWriter(writer);\n }\n\n public void print(Object... objects) {\n for (int i = 0; i < objects.length; i++) {\n if (i != 0) {\n writer.print(' ');\n }\n writer.print(objects[i]);\n }\n }\n\n public void println(Object... objects) {\n print(objects);\n writer.println();\n }\n\n public void close() {\n writer.close();\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1506834954, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03589.html", "problem_id": "p03589", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03589/input.txt", "sample_output_relpath": "derived/input_output/data/p03589/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03589/Java/s817950518.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s817950518", "user_id": "u855192343"}, "prompt_components": {"gold_output": "1 2 2\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.io.BufferedWriter;\nimport java.io.Writer;\nimport java.io.OutputStreamWriter;\nimport java.util.InputMismatchException;\nimport java.io.IOException;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author littledream1502@gmail.com\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n OutputWriter out = new OutputWriter(outputStream);\n TaskC solver = new TaskC();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class TaskC {\n public void solve(int testNumber, InputReader in, OutputWriter out) {\n int N = in.nextInt();\n int h, n, w;\n for (int i = 1; i < 3501; i++) {\n for (int j = 1; j < 3501; j++) {\n long l = N * i * j;\n long r = 4 * i * j - N * i - N * j;\n if (r > 0 && l % r == 0) {\n long result = l / r;\n out.println(i + \" \" + j + \" \" + r);\n return;\n }\n }\n }\n }\n\n }\n\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private InputReader.SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n\n public int read() {\n if (numChars == -1) {\n throw new InputMismatchException();\n }\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0) {\n return -1;\n }\n }\n return buf[curChar++];\n }\n\n public int nextInt() {\n int c = read();\n while (isSpaceChar(c)) {\n c = read();\n }\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n res *= 10;\n res += c - '0';\n c = read();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n\n public boolean isSpaceChar(int c) {\n if (filter != null) {\n return filter.isSpaceChar(c);\n }\n return isWhitespace(c);\n }\n\n public static boolean isWhitespace(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\n\n }\n\n static class OutputWriter {\n private final PrintWriter writer;\n\n public OutputWriter(OutputStream outputStream) {\n writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));\n }\n\n public OutputWriter(Writer writer) {\n this.writer = new PrintWriter(writer);\n }\n\n public void print(Object... objects) {\n for (int i = 0; i < objects.length; i++) {\n if (i != 0) {\n writer.print(' ');\n }\n writer.print(objects[i]);\n }\n }\n\n public void println(Object... objects) {\n print(objects);\n writer.println();\n }\n\n public void close() {\n writer.close();\n }\n\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": "p03589", "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": 4085, "cpu_time_ms": 93, "memory_kb": 22740}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s699771509", "group_id": "codeNet:p03591", "input_text": "// 作者:杨成瑞先生\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n\tstatic class FastScanner {\n BufferedReader br;\n StringTokenizer st;\n\n public FastScanner() {\n try {\n br = new BufferedReader(new InputStreamReader(System.in));\n st = new StringTokenizer(br.readLine());\n } catch (Exception e){e.printStackTrace();}\n }\n\n public String next() {\n if (st.hasMoreTokens()) return st.nextToken();\n try {st = new StringTokenizer(br.readLine());}\n catch (Exception e) {e.printStackTrace();}\n return st.nextToken();\n }\n\n public int nextInt() {return Integer.parseInt(next());}\n\n public long nextLong() {return Long.parseLong(next());}\n\n public double nextDouble() {return Double.parseDouble(next());}\n\n public String nextLine() {\n String line = \"\";\n if(st.hasMoreTokens()) line = st.nextToken();\n else try {return br.readLine();}catch(IOException e){e.printStackTrace();}\n while(st.hasMoreTokens()) line += \" \"+st.nextToken();\n return line;\n }\n }\n\n\tpublic static void main(String[] args) {\n FastScanner sc = new FastScanner();\n PrintWriter pw = new PrintWriter(System.out);\n\n pw.println(sc.nextLine().substring(0, 5).contains(\"YAKI\") ? \"YES\" : \"NO\");\n \n pw.close();\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1551255347, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03591.html", "problem_id": "p03591", "resource_group": "high_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/Java/s699771509.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s699771509", "user_id": "u147886643"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "// 作者:杨成瑞先生\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n\tstatic class FastScanner {\n BufferedReader br;\n StringTokenizer st;\n\n public FastScanner() {\n try {\n br = new BufferedReader(new InputStreamReader(System.in));\n st = new StringTokenizer(br.readLine());\n } catch (Exception e){e.printStackTrace();}\n }\n\n public String next() {\n if (st.hasMoreTokens()) return st.nextToken();\n try {st = new StringTokenizer(br.readLine());}\n catch (Exception e) {e.printStackTrace();}\n return st.nextToken();\n }\n\n public int nextInt() {return Integer.parseInt(next());}\n\n public long nextLong() {return Long.parseLong(next());}\n\n public double nextDouble() {return Double.parseDouble(next());}\n\n public String nextLine() {\n String line = \"\";\n if(st.hasMoreTokens()) line = st.nextToken();\n else try {return br.readLine();}catch(IOException e){e.printStackTrace();}\n while(st.hasMoreTokens()) line += \" \"+st.nextToken();\n return line;\n }\n }\n\n\tpublic static void main(String[] args) {\n FastScanner sc = new FastScanner();\n PrintWriter pw = new PrintWriter(System.out);\n\n pw.println(sc.nextLine().substring(0, 5).contains(\"YAKI\") ? \"YES\" : \"NO\");\n \n pw.close();\n\t}\n\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": 1450, "cpu_time_ms": 71, "memory_kb": 21204}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s569802793", "group_id": "codeNet:p03592", "input_text": "import java.io.*;\nimport java.time.Year;\nimport java.util.*;\nimport java.util.function.Function;\nimport java.util.stream.Collectors;\nimport java.util.stream.IntStream;\n\nimport static java.lang.Math.*;\nimport static java.lang.String.format;\n\npublic class Main {\n public static void main(String[] args) {\n solve();\n }\n final static int INF = Integer.MAX_VALUE>>1;\n final static int MOD = 1_000_000_007;\n final static int[] dx4 = { 0, 1, 0, -1 };\n final static int[] dy4 = { 1, 0, -1, 0 };\n final static int[] dx9 = {-1, -1, -1, 0, 0, 0, 1, 1,1};\n final static int[] dy9 = {-1, 0, 1, -1, 0, 1, -1, 0,1};\n final static Runnable me=()->{};\n public static void solve(){\n //TODO:Solve problem like ***\n Scanner sc=new Scanner();\n int n = sc.nextInt();\n int m = sc.nextInt();\n int k = sc.nextInt();\n for (int i = 0; i <= n; i++) {\n for (int j = 0; j <= m; j++) {\n if ((i * (m - j)) + (j * (n - i)) == k) {\n put(\"Yes\");\n return;\n }\n }\n }\n put(\"No\");\n\n }\n\n //runWhenEAで使う\n private static Runnable func(Object... objects){\n try{\n assert false;\n return me;\n }catch(AssertionError e){\n return ()->{put(objects);};\n }\n }\n private static void print(Object... objects){\n if(objects.length==1){\n System.out.print(objects[0]);\n }else{\n System.out.print(Arrays.toString(objects));\n }\n }\n private static void put(Object... objects) {\n print(objects);\n put();\n }\n private static void put(){\n System.out.println();\n }\n\n\n private static void runWhenEA(Runnable runnable){\n try{\n assert false;\n }catch(AssertionError e){\n PrintStream ps=System.out;\n PrintStream pse=System.err;\n System.setOut(pse);\n runnable.run();\n System.setOut(ps);\n }\n }\n private static void putM(String name,char[][] mat){\n put(\"---------------------\"+name+\"-----------------\");\n for (int i = 0; i < mat.length; i++) {\n put(Arrays.toString(mat[i]));\n }\n }\n private static void putM(String name,int[][] mat){\n put(\"---------------------\"+name+\"-----------------\");\n for (int i = 0; i < mat.length; i++) {\n put(Arrays.toString(mat[i]));\n }\n }\n private static void putM(String name,long[][] mat){\n put(\"---------------------\"+name+\"-----------------\");\n for (int i = 0; i < mat.length; i++) {\n put(Arrays.toString(mat[i]));\n }\n }\n private static void putM(String name,boolean[][] mat){\n put(\"---------------------\"+name+\"-----------------\");\n for (int i = 0; i < mat.length; i++) {\n put(Arrays.toString(mat[i]));\n }\n }\n final static private class Scanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte())\n return buffer[ptr++];\n else\n return -1;\n }\n\n private boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr]))\n ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext())\n throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext())\n throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)\n throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n }\n final static private class FixedIntPair {\n final public int x, y;\n final static public FixedIntPair ZEROS=new FixedIntPair(0,0);\n FixedIntPair(int x, int y) {\n this.x = x;\n this.y = y;\n }\n public static double distance(FixedIntPair fip1,FixedIntPair fip2){\n double x = (double) fip1.x - fip2.x;\n double y = (double) fip1.y - fip2.y;\n return Math.sqrt(x*x+y*y);\n }\n\n @Override\n public int hashCode() {\n return x*100000+y;\n }\n\n @Override\n public boolean equals(Object obj) {\n if(obj==null)return false;\n if(!(obj instanceof FixedIntPair)) return false;\n FixedIntPair pair=(FixedIntPair) obj;\n return this.x==pair.x&&this.y==pair.y;\n }\n\n @Override\n public String toString() {\n return format(FixedIntPair.class.getSimpleName()+\":(%d,%d)\", x, y);\n }\n }\n final static private class FixedLongPair {\n final public long x, y;\n final static public FixedLongPair ZEROS=new FixedLongPair(0,0);\n FixedLongPair(long x, long y) {\n this.x = x;\n this.y = y;\n }\n public static double distance(FixedLongPair flp1,FixedLongPair flp2){\n double x = (double) flp1.x - flp2.x;\n double y = (double) flp1.y - flp2.y;\n return Math.sqrt(x*x+y*y);\n }\n\n @Override\n public int hashCode() {\n return (int)x+(int)y;\n }\n\n @Override\n public boolean equals(Object obj) {\n if(obj==null)return false;\n if(!(obj instanceof FixedLongPair)) return false;\n FixedLongPair pair=(FixedLongPair)obj;\n return this.x==pair.x&&this.y==pair.y;\n }\n\n @Override\n public String toString() {\n return format(FixedLongPair.class.getSimpleName()+\":(%d,%d)\", x, y);\n }\n }\n final static private class Binary{\n public static String toZeroPadding(int i){\n return format(\"%\"+Integer.toBinaryString(-1).length()+\"s\",Integer.toBinaryString(i)).replace(' ','0');\n }\n public static String toZeroPadding(long i){\n return format(\"%\"+Long.toBinaryString(-1).length()+\"s\",Long.toBinaryString(i)).replace(' ','0');\n }\n }\n\n final static private class Util {\n static long gcd(long a,long b){\n a= abs(a);\n b= abs(b);\n if(a=0&&i=0&&j>1;\n final static int MOD = 1_000_000_007;\n final static int[] dx4 = { 0, 1, 0, -1 };\n final static int[] dy4 = { 1, 0, -1, 0 };\n final static int[] dx9 = {-1, -1, -1, 0, 0, 0, 1, 1,1};\n final static int[] dy9 = {-1, 0, 1, -1, 0, 1, -1, 0,1};\n final static Runnable me=()->{};\n public static void solve(){\n //TODO:Solve problem like ***\n Scanner sc=new Scanner();\n int n = sc.nextInt();\n int m = sc.nextInt();\n int k = sc.nextInt();\n for (int i = 0; i <= n; i++) {\n for (int j = 0; j <= m; j++) {\n if ((i * (m - j)) + (j * (n - i)) == k) {\n put(\"Yes\");\n return;\n }\n }\n }\n put(\"No\");\n\n }\n\n //runWhenEAで使う\n private static Runnable func(Object... objects){\n try{\n assert false;\n return me;\n }catch(AssertionError e){\n return ()->{put(objects);};\n }\n }\n private static void print(Object... objects){\n if(objects.length==1){\n System.out.print(objects[0]);\n }else{\n System.out.print(Arrays.toString(objects));\n }\n }\n private static void put(Object... objects) {\n print(objects);\n put();\n }\n private static void put(){\n System.out.println();\n }\n\n\n private static void runWhenEA(Runnable runnable){\n try{\n assert false;\n }catch(AssertionError e){\n PrintStream ps=System.out;\n PrintStream pse=System.err;\n System.setOut(pse);\n runnable.run();\n System.setOut(ps);\n }\n }\n private static void putM(String name,char[][] mat){\n put(\"---------------------\"+name+\"-----------------\");\n for (int i = 0; i < mat.length; i++) {\n put(Arrays.toString(mat[i]));\n }\n }\n private static void putM(String name,int[][] mat){\n put(\"---------------------\"+name+\"-----------------\");\n for (int i = 0; i < mat.length; i++) {\n put(Arrays.toString(mat[i]));\n }\n }\n private static void putM(String name,long[][] mat){\n put(\"---------------------\"+name+\"-----------------\");\n for (int i = 0; i < mat.length; i++) {\n put(Arrays.toString(mat[i]));\n }\n }\n private static void putM(String name,boolean[][] mat){\n put(\"---------------------\"+name+\"-----------------\");\n for (int i = 0; i < mat.length; i++) {\n put(Arrays.toString(mat[i]));\n }\n }\n final static private class Scanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte())\n return buffer[ptr++];\n else\n return -1;\n }\n\n private boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr]))\n ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext())\n throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext())\n throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)\n throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n }\n final static private class FixedIntPair {\n final public int x, y;\n final static public FixedIntPair ZEROS=new FixedIntPair(0,0);\n FixedIntPair(int x, int y) {\n this.x = x;\n this.y = y;\n }\n public static double distance(FixedIntPair fip1,FixedIntPair fip2){\n double x = (double) fip1.x - fip2.x;\n double y = (double) fip1.y - fip2.y;\n return Math.sqrt(x*x+y*y);\n }\n\n @Override\n public int hashCode() {\n return x*100000+y;\n }\n\n @Override\n public boolean equals(Object obj) {\n if(obj==null)return false;\n if(!(obj instanceof FixedIntPair)) return false;\n FixedIntPair pair=(FixedIntPair) obj;\n return this.x==pair.x&&this.y==pair.y;\n }\n\n @Override\n public String toString() {\n return format(FixedIntPair.class.getSimpleName()+\":(%d,%d)\", x, y);\n }\n }\n final static private class FixedLongPair {\n final public long x, y;\n final static public FixedLongPair ZEROS=new FixedLongPair(0,0);\n FixedLongPair(long x, long y) {\n this.x = x;\n this.y = y;\n }\n public static double distance(FixedLongPair flp1,FixedLongPair flp2){\n double x = (double) flp1.x - flp2.x;\n double y = (double) flp1.y - flp2.y;\n return Math.sqrt(x*x+y*y);\n }\n\n @Override\n public int hashCode() {\n return (int)x+(int)y;\n }\n\n @Override\n public boolean equals(Object obj) {\n if(obj==null)return false;\n if(!(obj instanceof FixedLongPair)) return false;\n FixedLongPair pair=(FixedLongPair)obj;\n return this.x==pair.x&&this.y==pair.y;\n }\n\n @Override\n public String toString() {\n return format(FixedLongPair.class.getSimpleName()+\":(%d,%d)\", x, y);\n }\n }\n final static private class Binary{\n public static String toZeroPadding(int i){\n return format(\"%\"+Integer.toBinaryString(-1).length()+\"s\",Integer.toBinaryString(i)).replace(' ','0');\n }\n public static String toZeroPadding(long i){\n return format(\"%\"+Long.toBinaryString(-1).length()+\"s\",Long.toBinaryString(i)).replace(' ','0');\n }\n }\n\n final static private class Util {\n static long gcd(long a,long b){\n a= abs(a);\n b= abs(b);\n if(a=0&&i=0&&j 0 && alpha[i] % 4 == 0) {\n alpha[i] -= 4;\n g4--;\n i = -1;\n }\n }\n for (int i = 0; i < alpha.length; i++) {\n if (alpha[i] != 0) {\n System.out.println(\"No\");\n return;\n }\n }\n System.out.println(\"Yes\");\n }\n\n}\n", "language": "Java", "metadata": {"date": 1595734336, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p03593.html", "problem_id": "p03593", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03593/input.txt", "sample_output_relpath": "derived/input_output/data/p03593/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03593/Java/s898841690.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s898841690", "user_id": "u494105162"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int h = sc.nextInt();\n int w = sc.nextInt();\n char[][] a = new char[h][w];\n int[] alpha = new int[26];\n for (int i = 0; i < h; i++) {\n a[i] = sc.next().toCharArray();\n for (int j = 0; j < w; j++) {\n alpha[a[i][j] - 'a']++;\n }\n }\n int g1;\n int g2;\n int g4;\n if (h % 2 == 0 && w % 2 == 0) {\n g1 = 0;\n g2 = 0;\n g4 = (h / 2) * (w / 2);\n } else if (h % 2 == 0 || w % 2 == 0) {\n g1 = 0;\n g2 = h / 2 + w / 2;\n g4 = (h / 2) * (w / 2);\n } else {\n g1 = 1;\n g2 = h / 2 + w / 2;\n g4 = (h / 2) * (w / 2);\n }\n for (int i = 0; i < alpha.length; i++) {\n if (g1 == 0) {\n break;\n }\n if (alpha[i] % 4 == 1 || alpha[i] % 4 == 3) {\n alpha[i]--;\n g1--;\n i = -1;\n }\n }\n for (int i = 0; i < alpha.length; i++) {\n if (g2 == 0) {\n break;\n }\n if (alpha[i] % 4 == 2) {\n alpha[i] -= 2;\n g2--;\n i = -1;\n }\n }\n for (int i = 0; i < alpha.length; i++) {\n if (g4 == 0) {\n break;\n }\n if (alpha[i] > 0 && alpha[i] % 4 == 0) {\n alpha[i] -= 4;\n g4--;\n i = -1;\n }\n }\n for (int i = 0; i < alpha.length; i++) {\n if (alpha[i] != 0) {\n System.out.println(\"No\");\n return;\n }\n }\n System.out.println(\"Yes\");\n }\n\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have an H-by-W matrix.\nLet a_{ij} be the element at the i-th row from the top and j-th column from the left.\nIn this matrix, each a_{ij} is a lowercase English letter.\n\nSnuke is creating another H-by-W matrix, A', by freely rearranging the elements in A.\nHere, he wants to satisfy the following condition:\n\nEvery row and column in A' can be read as a palindrome.\n\nDetermine whether he can create a matrix satisfying the condition.\n\nNote\n\nA palindrome is a string that reads the same forward and backward.\nFor example, a, aa, abba and abcba are all palindromes, while ab, abab and abcda are not.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\na_{ij} is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{11}a_{12}...a_{1W}\n:\na_{H1}a_{H2}...a_{HW}\n\nOutput\n\nIf Snuke can create a matrix satisfying the condition, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 4\naabb\naabb\naacc\n\nSample Output 1\n\nYes\n\nFor example, the following matrix satisfies the condition.\n\nabba\nacca\nabba\n\nSample Input 2\n\n2 2\naa\nbb\n\nSample Output 2\n\nNo\n\nIt is not possible to create a matrix satisfying the condition, no matter how we rearrange the elements in A.\n\nSample Input 3\n\n5 1\nt\nw\ne\ne\nt\n\nSample Output 3\n\nYes\n\nFor example, the following matrix satisfies the condition.\n\nt\ne\nw\ne\nt\n\nSample Input 4\n\n2 5\nabxba\nabyba\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n1 1\nz\n\nSample Output 5\n\nYes", "sample_input": "3 4\naabb\naabb\naacc\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03593", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have an H-by-W matrix.\nLet a_{ij} be the element at the i-th row from the top and j-th column from the left.\nIn this matrix, each a_{ij} is a lowercase English letter.\n\nSnuke is creating another H-by-W matrix, A', by freely rearranging the elements in A.\nHere, he wants to satisfy the following condition:\n\nEvery row and column in A' can be read as a palindrome.\n\nDetermine whether he can create a matrix satisfying the condition.\n\nNote\n\nA palindrome is a string that reads the same forward and backward.\nFor example, a, aa, abba and abcba are all palindromes, while ab, abab and abcda are not.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\na_{ij} is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{11}a_{12}...a_{1W}\n:\na_{H1}a_{H2}...a_{HW}\n\nOutput\n\nIf Snuke can create a matrix satisfying the condition, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 4\naabb\naabb\naacc\n\nSample Output 1\n\nYes\n\nFor example, the following matrix satisfies the condition.\n\nabba\nacca\nabba\n\nSample Input 2\n\n2 2\naa\nbb\n\nSample Output 2\n\nNo\n\nIt is not possible to create a matrix satisfying the condition, no matter how we rearrange the elements in A.\n\nSample Input 3\n\n5 1\nt\nw\ne\ne\nt\n\nSample Output 3\n\nYes\n\nFor example, the following matrix satisfies the condition.\n\nt\ne\nw\ne\nt\n\nSample Input 4\n\n2 5\nabxba\nabyba\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n1 1\nz\n\nSample Output 5\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1875, "cpu_time_ms": 158, "memory_kb": 37268}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s456601443", "group_id": "codeNet:p03598", "input_text": "import java.util.*;\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = in.nextInt();\n\t\tint k = in.nextInt();\n\t\tint[] x = new int[n];\n\t\tint result = 0;\n\n\t\tfor (int i = 0; i < x.length; i++) {\n\t\t\tx[i] = in.nextInt();\n\t\t}\n\n\t\tfor (int i = 0; i < x.length; i++) {\n\t\t\tif (x[i] < Math.abs(k-x[i])) {\n\t\t\t\tresult += x[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tresult += Math.abs(k-x[i]);\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(result*2);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1505611364, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03598.html", "problem_id": "p03598", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03598/input.txt", "sample_output_relpath": "derived/input_output/data/p03598/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03598/Java/s456601443.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s456601443", "user_id": "u471368568"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*;\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = in.nextInt();\n\t\tint k = in.nextInt();\n\t\tint[] x = new int[n];\n\t\tint result = 0;\n\n\t\tfor (int i = 0; i < x.length; i++) {\n\t\t\tx[i] = in.nextInt();\n\t\t}\n\n\t\tfor (int i = 0; i < x.length; i++) {\n\t\t\tif (x[i] < Math.abs(k-x[i])) {\n\t\t\t\tresult += x[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tresult += Math.abs(k-x[i]);\n\t\t\t}\n\t\t}\n\n\t\tSystem.out.println(result*2);\n\t}\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i).\nThus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N.\n\nIn order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B.\nThen, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i).\nThus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N.\n\nWhen activated, each type of robot will operate as follows.\n\nWhen a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything.\n\nWhen a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything.\n\nSnuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 100\n\n0 < x_i < K\n\nAll input values are integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\nK\nx_1 x_2 ... x_N\n\nOutputs\n\nPrint the minimum possible total distance covered by robots.\n\nSample Input 1\n\n1\n10\n2\n\nSample Output 1\n\n4\n\nThere are just one ball, one type-A robot and one type-B robot.\n\nIf the type-A robot is used to collect the ball, the distance from the robot to the ball is 2, and the distance from the ball to the original position of the robot is also 2, for a total distance of 4.\n\nSimilarly, if the type-B robot is used, the total distance covered will be 16.\n\nThus, the total distance covered will be minimized when the type-A robot is used. The output should be 4.\n\nSample Input 2\n\n2\n9\n3 6\n\nSample Output 2\n\n12\n\nThe total distance covered will be minimized when the first ball is collected by the type-A robot, and the second ball by the type-B robot.\n\nSample Input 3\n\n5\n20\n11 12 9 17 12\n\nSample Output 3\n\n74", "sample_input": "1\n10\n2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03598", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i).\nThus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N.\n\nIn order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B.\nThen, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i).\nThus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N.\n\nWhen activated, each type of robot will operate as follows.\n\nWhen a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything.\n\nWhen a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything.\n\nSnuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 100\n\n0 < x_i < K\n\nAll input values are integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\nK\nx_1 x_2 ... x_N\n\nOutputs\n\nPrint the minimum possible total distance covered by robots.\n\nSample Input 1\n\n1\n10\n2\n\nSample Output 1\n\n4\n\nThere are just one ball, one type-A robot and one type-B robot.\n\nIf the type-A robot is used to collect the ball, the distance from the robot to the ball is 2, and the distance from the ball to the original position of the robot is also 2, for a total distance of 4.\n\nSimilarly, if the type-B robot is used, the total distance covered will be 16.\n\nThus, the total distance covered will be minimized when the type-A robot is used. The output should be 4.\n\nSample Input 2\n\n2\n9\n3 6\n\nSample Output 2\n\n12\n\nThe total distance covered will be minimized when the first ball is collected by the type-A robot, and the second ball by the type-B robot.\n\nSample Input 3\n\n5\n20\n11 12 9 17 12\n\nSample Output 3\n\n74", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 110, "memory_kb": 21076}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s545421584", "group_id": "codeNet:p03599", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int A = sc.nextInt();\n int B = sc.nextInt();\n int C = sc.nextInt();\n int D = sc.nextInt();\n int E = sc.nextInt();\n int F = sc.nextInt();\n int ans1 = 100 * A;\n int ans2 = 0;\n boolean[] water = new boolean[F + 1];\n boolean[] sugar = new boolean[F + 1];\n for(int i = 1; i <= F; i++) {\n for(int j = 0; j <= 30; j++) {\n int d = i - (100 * A * j);\n if((d >= 0) && ((d % (100 * B)) == 0)) {\n water[i] = true;\n break;\n }\n }\n }\n for(int i = 1; i <= F; i++) {\n for(int j = 0; j <= F; j++) {\n int d = i - (C * j);\n if((d >= 0) && ((d % D) == 0)) {\n sugar[i] = true;\n break;\n }\n }\n }\n for(int i = 0; i <= F; i++) {\n for(int j = 0; j <= (F - i); j++) {\n if(water[i] && sugar[j]) {\n if((E * i) >= (100 * j)) {\n if((ans2 * (i + j)) < (ans1 * j)) {\n ans1 = i + j; \n ans2 = j;\n }\n }\n }\n } \n }\n System.out.println(ans1 + \" \" + ans2);\n }\n}", "language": "Java", "metadata": {"date": 1586978451, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03599.html", "problem_id": "p03599", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03599/input.txt", "sample_output_relpath": "derived/input_output/data/p03599/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03599/Java/s545421584.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s545421584", "user_id": "u653981267"}, "prompt_components": {"gold_output": "110 10\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int A = sc.nextInt();\n int B = sc.nextInt();\n int C = sc.nextInt();\n int D = sc.nextInt();\n int E = sc.nextInt();\n int F = sc.nextInt();\n int ans1 = 100 * A;\n int ans2 = 0;\n boolean[] water = new boolean[F + 1];\n boolean[] sugar = new boolean[F + 1];\n for(int i = 1; i <= F; i++) {\n for(int j = 0; j <= 30; j++) {\n int d = i - (100 * A * j);\n if((d >= 0) && ((d % (100 * B)) == 0)) {\n water[i] = true;\n break;\n }\n }\n }\n for(int i = 1; i <= F; i++) {\n for(int j = 0; j <= F; j++) {\n int d = i - (C * j);\n if((d >= 0) && ((d % D) == 0)) {\n sugar[i] = true;\n break;\n }\n }\n }\n for(int i = 0; i <= F; i++) {\n for(int j = 0; j <= (F - i); j++) {\n if(water[i] && sugar[j]) {\n if((E * i) >= (100 * j)) {\n if((ans2 * (i + j)) < (ans1 * j)) {\n ans1 = i + j; \n ans2 = j;\n }\n }\n }\n } \n }\n System.out.println(ans1 + \" \" + ans2);\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke is making sugar water in a beaker.\nInitially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.\n\nOperation 1: Pour 100A grams of water into the beaker.\n\nOperation 2: Pour 100B grams of water into the beaker.\n\nOperation 3: Put C grams of sugar into the beaker.\n\nOperation 4: Put D grams of sugar into the beaker.\n\nIn our experimental environment, E grams of sugar can dissolve into 100 grams of water.\n\nSnuke will make sugar water with the highest possible density.\n\nThe beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.\nFind the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.\nIf there is more than one candidate, any of them will be accepted.\n\nWe remind you that the sugar water that contains a grams of water and b grams of sugar is \\frac{100b}{a + b} percent.\nAlso, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.\n\nConstraints\n\n1 \\leq A < B \\leq 30\n\n1 \\leq C < D \\leq 30\n\n1 \\leq E \\leq 100\n\n100A \\leq F \\leq 3 000\n\nA, B, C, D, E and F are all integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nA B C D E F\n\nOutputs\n\nPrint two integers separated by a space.\nThe first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.\n\nSample Input 1\n\n1 2 10 20 15 200\n\nSample Output 1\n\n110 10\n\nIn this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.\n\nWe can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.\nIt is not possible to make sugar water with higher density.\nFor example, the following sequences of operations are infeasible:\n\nIf we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.\n\nIf we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.\n\nSample Input 2\n\n1 2 1 2 100 1000\n\nSample Output 2\n\n200 100\n\nThere are other acceptable outputs, such as:\n\n400 200\n\nHowever, the output below is not acceptable:\n\n300 150\n\nThis is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.\n\nSample Input 3\n\n17 19 22 26 55 2802\n\nSample Output 3\n\n2634 934", "sample_input": "1 2 10 20 15 200\n"}, "reference_outputs": ["110 10\n"], "source_document_id": "p03599", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke is making sugar water in a beaker.\nInitially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.\n\nOperation 1: Pour 100A grams of water into the beaker.\n\nOperation 2: Pour 100B grams of water into the beaker.\n\nOperation 3: Put C grams of sugar into the beaker.\n\nOperation 4: Put D grams of sugar into the beaker.\n\nIn our experimental environment, E grams of sugar can dissolve into 100 grams of water.\n\nSnuke will make sugar water with the highest possible density.\n\nThe beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.\nFind the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.\nIf there is more than one candidate, any of them will be accepted.\n\nWe remind you that the sugar water that contains a grams of water and b grams of sugar is \\frac{100b}{a + b} percent.\nAlso, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.\n\nConstraints\n\n1 \\leq A < B \\leq 30\n\n1 \\leq C < D \\leq 30\n\n1 \\leq E \\leq 100\n\n100A \\leq F \\leq 3 000\n\nA, B, C, D, E and F are all integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nA B C D E F\n\nOutputs\n\nPrint two integers separated by a space.\nThe first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.\n\nSample Input 1\n\n1 2 10 20 15 200\n\nSample Output 1\n\n110 10\n\nIn this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.\n\nWe can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.\nIt is not possible to make sugar water with higher density.\nFor example, the following sequences of operations are infeasible:\n\nIf we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.\n\nIf we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.\n\nSample Input 2\n\n1 2 1 2 100 1000\n\nSample Output 2\n\n200 100\n\nThere are other acceptable outputs, such as:\n\n400 200\n\nHowever, the output below is not acceptable:\n\n300 150\n\nThis is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.\n\nSample Input 3\n\n17 19 22 26 55 2802\n\nSample Output 3\n\n2634 934", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1188, "cpu_time_ms": 136, "memory_kb": 23508}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s757900892", "group_id": "codeNet:p03599", "input_text": "import java.io.*;\nimport java.util.*;\nimport java.math.*;\nimport java.awt.Point;\n \npublic class Main {\n\tstatic final long MOD = 998244353L;\n\t//static final long INF = 1000000000000000007L;\n\t//static final long MOD = 1000000007L;\n\t//static final int INF = 1000000007;\n\t\n\t//static long[] factorial;\n\t\n\t\n\tstatic int[][] nums;\n \n\tpublic static void main(String[] args) {\n\t\tFastScanner sc = new FastScanner();\n\t\tPrintWriter pw = new PrintWriter(System.out);\n\t\t\n\t\tint A = sc.ni();\n\t\tint B = sc.ni();\n\t\tint C = sc.ni();\n\t\tint D = sc.ni();\n\t\tint E = sc.ni();\n\t\tint F = sc.ni();\n\t\tboolean[] water = new boolean[(F/100)+1];\n\t\twater[0] = true;\n\t\tfor (int i = 1; i <= (F/100); i++) {\n\t\t\tif (i-A >= 0 && water[i-A]) {\n\t\t\t\twater[i] = true;\n\t\t\t} else if (i-B >= 0 && water[i-B]) {\n\t\t\t\twater[i] = true;\n\t\t\t}\n\t\t}\n\t\t\n\t\tboolean[] sugar = new boolean[E*(F/100)+1];\n\t\tsugar[0] = true;\n\t\tfor (int i = 1; i <= E*(F/100); i++) {\n\t\t\tif (i-C >= 0 && sugar[i-C]) {\n\t\t\t\tsugar[i] = true;\n\t\t\t} else if (i-D >= 0 && sugar[i-D]) {\n\t\t\t\tsugar[i] = true;\n\t\t\t}\n\t\t}\n\t\t\n\t\tdouble ans = 0;\n\t\tint S = 0;\n\t\tint W = 0;\n\t\tfor (int i = 1; i < water.length; i++) {\n\t\t\tfor (int j = 0; j < Math.min(sugar.length,E*i+1); j++) {\n\t\t\t\tif (water[i]&&sugar[j]&&j+100*i <= F) {\n\t\t\t\t\tif ((100.0*j)/(100.0*i+j) > ans) {\n\t\t\t\t\t\tans = (100.0*j)/(100.0*i+j);\n\t\t\t\t\t\tS = j;\n\t\t\t\t\t\tW = 100*i;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tpw.println((W+S) + \" \" + S);\n\t\tpw.close();\n\t}\n\t\n\tpublic static long check(int num) {\n\t\tlong ans = 0;\n\t\tfor (int[] pair: nums) {\n\t\t\tif ((pair[0]|num)==num) {\n\t\t\t\tans += pair[1];\n\t\t\t}\n\t\t}\n\t\treturn ans;\n\t}\n \n\tpublic static long dist(long[] p1, long[] p2) {\n\t\treturn (Math.abs(p2[0]-p1[0])+Math.abs(p2[1]-p1[1]));\n\t}\n\t\n\t//Find the GCD of two numbers\n\tpublic static long gcd(long a, long b) {\n\t\tif (a < b) return gcd(b,a);\n\t\tif (b == 0)\n\t\t\treturn a;\n\t\telse\n\t\t\treturn gcd(b,a%b);\n\t}\n\t\n\t//Fast exponentiation (x^y mod m)\n\tpublic static long power(long x, long y, long m) { \n\t\tif (y < 0) return 0L;\n\t\tlong ans = 1;\n\t\tx %= m;\n\t\twhile (y > 0) { \n\t\t\tif(y % 2 == 1) \n\t\t\t\tans = (ans * x) % m; \n\t\t\ty /= 2; \n\t\t\tx = (x * x) % m;\n\t\t} \n\t\treturn ans; \n\t}\n\t\n\tpublic static int[] shuffle(int[] array) {\n\t\tRandom rgen = new Random();\n\t\tfor (int i = 0; i < array.length; i++) {\n\t\t int randomPosition = rgen.nextInt(array.length);\n\t\t int temp = array[i];\n\t\t array[i] = array[randomPosition];\n\t\t array[randomPosition] = temp;\n\t\t}\n\t\treturn array;\n\t}\n\t\n\tpublic static long[] shuffle(long[] array) {\n\t\tRandom rgen = new Random();\n\t\tfor (int i = 0; i < array.length; i++) {\n\t\t int randomPosition = rgen.nextInt(array.length);\n\t\t long temp = array[i];\n\t\t array[i] = array[randomPosition];\n\t\t array[randomPosition] = temp;\n\t\t}\n\t\treturn array;\n\t}\n\t\n\tpublic static int[][] shuffle(int[][] array) {\n\t\tRandom rgen = new Random();\n\t\tfor (int i = 0; i < array.length; i++) {\n\t\t int randomPosition = rgen.nextInt(array.length);\n\t\t int[] temp = array[i];\n\t\t array[i] = array[randomPosition];\n\t\t array[randomPosition] = temp;\n\t\t}\n\t\treturn array;\n\t}\n\t\n public static int[][] sort(int[][] array) {\n \t//Sort an array (immune to quicksort TLE)\n \n\t\tArrays.sort(array, new Comparator() {\n\t\t\t @Override\n \t public int compare(int[] a, int[] b) {\n\t\t\t\t //return a[0]-b[0]; //ascending order\n\t\t\t\t if (a[1] != b[1]) {\n\t\t\t\t\t return (a[1]-b[1]);\n\t\t\t\t } else {\n\t\t\t\t\t return (a[0]-b[0]);\n\t\t\t\t }\n\t }\n\t\t});\n\t\treturn array;\n\t}\n \n public static long[][] sort(long[][] array) {\n \t//Sort an array (immune to quicksort TLE)\n\t\tRandom rgen = new Random();\n\t\tfor (int i = 0; i < array.length; i++) {\n\t\t int randomPosition = rgen.nextInt(array.length);\n\t\t long[] temp = array[i];\n\t\t array[i] = array[randomPosition];\n\t\t array[randomPosition] = temp;\n\t\t}\n\t\tArrays.sort(array, new Comparator() {\n\t\t\t @Override\n \t public int compare(long[] a, long[] b) {\n\t\t\t\t if (a[0] < b[0])\n\t\t\t\t\t return -1;\n\t\t\t\t else if (a[0] > b[0])\n\t\t\t\t\t return 1;\n\t\t\t\t else\n\t\t\t\t\t return 0;\n\t }\n\t\t});\n\t\treturn array;\n\t}\n \n static class FastScanner { \n BufferedReader br; \n StringTokenizer st; \n \n public FastScanner() { \n br = new BufferedReader(new InputStreamReader(System.in)); \n } \n \n String next() { \n while (st == null || !st.hasMoreElements()) { \n try { \n st = new StringTokenizer(br.readLine());\n } catch (IOException e) { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n }\n \n int ni() { \n return Integer.parseInt(next()); \n }\n \n long nl() { \n return Long.parseLong(next()); \n } \n \n double nd() { \n return Double.parseDouble(next()); \n } \n \n String nextLine() {\n String str = \"\"; \n try { \n str = br.readLine(); \n } catch (IOException e) {\n e.printStackTrace(); \n } \n return str;\n }\n }\n}", "language": "Java", "metadata": {"date": 1585985869, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03599.html", "problem_id": "p03599", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03599/input.txt", "sample_output_relpath": "derived/input_output/data/p03599/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03599/Java/s757900892.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s757900892", "user_id": "u495186373"}, "prompt_components": {"gold_output": "110 10\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\nimport java.math.*;\nimport java.awt.Point;\n \npublic class Main {\n\tstatic final long MOD = 998244353L;\n\t//static final long INF = 1000000000000000007L;\n\t//static final long MOD = 1000000007L;\n\t//static final int INF = 1000000007;\n\t\n\t//static long[] factorial;\n\t\n\t\n\tstatic int[][] nums;\n \n\tpublic static void main(String[] args) {\n\t\tFastScanner sc = new FastScanner();\n\t\tPrintWriter pw = new PrintWriter(System.out);\n\t\t\n\t\tint A = sc.ni();\n\t\tint B = sc.ni();\n\t\tint C = sc.ni();\n\t\tint D = sc.ni();\n\t\tint E = sc.ni();\n\t\tint F = sc.ni();\n\t\tboolean[] water = new boolean[(F/100)+1];\n\t\twater[0] = true;\n\t\tfor (int i = 1; i <= (F/100); i++) {\n\t\t\tif (i-A >= 0 && water[i-A]) {\n\t\t\t\twater[i] = true;\n\t\t\t} else if (i-B >= 0 && water[i-B]) {\n\t\t\t\twater[i] = true;\n\t\t\t}\n\t\t}\n\t\t\n\t\tboolean[] sugar = new boolean[E*(F/100)+1];\n\t\tsugar[0] = true;\n\t\tfor (int i = 1; i <= E*(F/100); i++) {\n\t\t\tif (i-C >= 0 && sugar[i-C]) {\n\t\t\t\tsugar[i] = true;\n\t\t\t} else if (i-D >= 0 && sugar[i-D]) {\n\t\t\t\tsugar[i] = true;\n\t\t\t}\n\t\t}\n\t\t\n\t\tdouble ans = 0;\n\t\tint S = 0;\n\t\tint W = 0;\n\t\tfor (int i = 1; i < water.length; i++) {\n\t\t\tfor (int j = 0; j < Math.min(sugar.length,E*i+1); j++) {\n\t\t\t\tif (water[i]&&sugar[j]&&j+100*i <= F) {\n\t\t\t\t\tif ((100.0*j)/(100.0*i+j) > ans) {\n\t\t\t\t\t\tans = (100.0*j)/(100.0*i+j);\n\t\t\t\t\t\tS = j;\n\t\t\t\t\t\tW = 100*i;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tpw.println((W+S) + \" \" + S);\n\t\tpw.close();\n\t}\n\t\n\tpublic static long check(int num) {\n\t\tlong ans = 0;\n\t\tfor (int[] pair: nums) {\n\t\t\tif ((pair[0]|num)==num) {\n\t\t\t\tans += pair[1];\n\t\t\t}\n\t\t}\n\t\treturn ans;\n\t}\n \n\tpublic static long dist(long[] p1, long[] p2) {\n\t\treturn (Math.abs(p2[0]-p1[0])+Math.abs(p2[1]-p1[1]));\n\t}\n\t\n\t//Find the GCD of two numbers\n\tpublic static long gcd(long a, long b) {\n\t\tif (a < b) return gcd(b,a);\n\t\tif (b == 0)\n\t\t\treturn a;\n\t\telse\n\t\t\treturn gcd(b,a%b);\n\t}\n\t\n\t//Fast exponentiation (x^y mod m)\n\tpublic static long power(long x, long y, long m) { \n\t\tif (y < 0) return 0L;\n\t\tlong ans = 1;\n\t\tx %= m;\n\t\twhile (y > 0) { \n\t\t\tif(y % 2 == 1) \n\t\t\t\tans = (ans * x) % m; \n\t\t\ty /= 2; \n\t\t\tx = (x * x) % m;\n\t\t} \n\t\treturn ans; \n\t}\n\t\n\tpublic static int[] shuffle(int[] array) {\n\t\tRandom rgen = new Random();\n\t\tfor (int i = 0; i < array.length; i++) {\n\t\t int randomPosition = rgen.nextInt(array.length);\n\t\t int temp = array[i];\n\t\t array[i] = array[randomPosition];\n\t\t array[randomPosition] = temp;\n\t\t}\n\t\treturn array;\n\t}\n\t\n\tpublic static long[] shuffle(long[] array) {\n\t\tRandom rgen = new Random();\n\t\tfor (int i = 0; i < array.length; i++) {\n\t\t int randomPosition = rgen.nextInt(array.length);\n\t\t long temp = array[i];\n\t\t array[i] = array[randomPosition];\n\t\t array[randomPosition] = temp;\n\t\t}\n\t\treturn array;\n\t}\n\t\n\tpublic static int[][] shuffle(int[][] array) {\n\t\tRandom rgen = new Random();\n\t\tfor (int i = 0; i < array.length; i++) {\n\t\t int randomPosition = rgen.nextInt(array.length);\n\t\t int[] temp = array[i];\n\t\t array[i] = array[randomPosition];\n\t\t array[randomPosition] = temp;\n\t\t}\n\t\treturn array;\n\t}\n\t\n public static int[][] sort(int[][] array) {\n \t//Sort an array (immune to quicksort TLE)\n \n\t\tArrays.sort(array, new Comparator() {\n\t\t\t @Override\n \t public int compare(int[] a, int[] b) {\n\t\t\t\t //return a[0]-b[0]; //ascending order\n\t\t\t\t if (a[1] != b[1]) {\n\t\t\t\t\t return (a[1]-b[1]);\n\t\t\t\t } else {\n\t\t\t\t\t return (a[0]-b[0]);\n\t\t\t\t }\n\t }\n\t\t});\n\t\treturn array;\n\t}\n \n public static long[][] sort(long[][] array) {\n \t//Sort an array (immune to quicksort TLE)\n\t\tRandom rgen = new Random();\n\t\tfor (int i = 0; i < array.length; i++) {\n\t\t int randomPosition = rgen.nextInt(array.length);\n\t\t long[] temp = array[i];\n\t\t array[i] = array[randomPosition];\n\t\t array[randomPosition] = temp;\n\t\t}\n\t\tArrays.sort(array, new Comparator() {\n\t\t\t @Override\n \t public int compare(long[] a, long[] b) {\n\t\t\t\t if (a[0] < b[0])\n\t\t\t\t\t return -1;\n\t\t\t\t else if (a[0] > b[0])\n\t\t\t\t\t return 1;\n\t\t\t\t else\n\t\t\t\t\t return 0;\n\t }\n\t\t});\n\t\treturn array;\n\t}\n \n static class FastScanner { \n BufferedReader br; \n StringTokenizer st; \n \n public FastScanner() { \n br = new BufferedReader(new InputStreamReader(System.in)); \n } \n \n String next() { \n while (st == null || !st.hasMoreElements()) { \n try { \n st = new StringTokenizer(br.readLine());\n } catch (IOException e) { \n e.printStackTrace(); \n } \n } \n return st.nextToken(); \n }\n \n int ni() { \n return Integer.parseInt(next()); \n }\n \n long nl() { \n return Long.parseLong(next()); \n } \n \n double nd() { \n return Double.parseDouble(next()); \n } \n \n String nextLine() {\n String str = \"\"; \n try { \n str = br.readLine(); \n } catch (IOException e) {\n e.printStackTrace(); \n } \n return str;\n }\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke is making sugar water in a beaker.\nInitially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.\n\nOperation 1: Pour 100A grams of water into the beaker.\n\nOperation 2: Pour 100B grams of water into the beaker.\n\nOperation 3: Put C grams of sugar into the beaker.\n\nOperation 4: Put D grams of sugar into the beaker.\n\nIn our experimental environment, E grams of sugar can dissolve into 100 grams of water.\n\nSnuke will make sugar water with the highest possible density.\n\nThe beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.\nFind the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.\nIf there is more than one candidate, any of them will be accepted.\n\nWe remind you that the sugar water that contains a grams of water and b grams of sugar is \\frac{100b}{a + b} percent.\nAlso, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.\n\nConstraints\n\n1 \\leq A < B \\leq 30\n\n1 \\leq C < D \\leq 30\n\n1 \\leq E \\leq 100\n\n100A \\leq F \\leq 3 000\n\nA, B, C, D, E and F are all integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nA B C D E F\n\nOutputs\n\nPrint two integers separated by a space.\nThe first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.\n\nSample Input 1\n\n1 2 10 20 15 200\n\nSample Output 1\n\n110 10\n\nIn this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.\n\nWe can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.\nIt is not possible to make sugar water with higher density.\nFor example, the following sequences of operations are infeasible:\n\nIf we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.\n\nIf we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.\n\nSample Input 2\n\n1 2 1 2 100 1000\n\nSample Output 2\n\n200 100\n\nThere are other acceptable outputs, such as:\n\n400 200\n\nHowever, the output below is not acceptable:\n\n300 150\n\nThis is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.\n\nSample Input 3\n\n17 19 22 26 55 2802\n\nSample Output 3\n\n2634 934", "sample_input": "1 2 10 20 15 200\n"}, "reference_outputs": ["110 10\n"], "source_document_id": "p03599", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke is making sugar water in a beaker.\nInitially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.\n\nOperation 1: Pour 100A grams of water into the beaker.\n\nOperation 2: Pour 100B grams of water into the beaker.\n\nOperation 3: Put C grams of sugar into the beaker.\n\nOperation 4: Put D grams of sugar into the beaker.\n\nIn our experimental environment, E grams of sugar can dissolve into 100 grams of water.\n\nSnuke will make sugar water with the highest possible density.\n\nThe beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.\nFind the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.\nIf there is more than one candidate, any of them will be accepted.\n\nWe remind you that the sugar water that contains a grams of water and b grams of sugar is \\frac{100b}{a + b} percent.\nAlso, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.\n\nConstraints\n\n1 \\leq A < B \\leq 30\n\n1 \\leq C < D \\leq 30\n\n1 \\leq E \\leq 100\n\n100A \\leq F \\leq 3 000\n\nA, B, C, D, E and F are all integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nA B C D E F\n\nOutputs\n\nPrint two integers separated by a space.\nThe first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.\n\nSample Input 1\n\n1 2 10 20 15 200\n\nSample Output 1\n\n110 10\n\nIn this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.\n\nWe can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.\nIt is not possible to make sugar water with higher density.\nFor example, the following sequences of operations are infeasible:\n\nIf we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.\n\nIf we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.\n\nSample Input 2\n\n1 2 1 2 100 1000\n\nSample Output 2\n\n200 100\n\nThere are other acceptable outputs, such as:\n\n400 200\n\nHowever, the output below is not acceptable:\n\n300 150\n\nThis is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.\n\nSample Input 3\n\n17 19 22 26 55 2802\n\nSample Output 3\n\n2634 934", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5049, "cpu_time_ms": 71, "memory_kb": 21076}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s770889623", "group_id": "codeNet:p03600", "input_text": "import java.util.*;\nimport java.lang.*;\nimport java.io.*;\nimport java.math.BigDecimal;\n\npublic class Main{\n public static void main (String[] args) throws java.lang.Exception {\n InputReader in = new InputReader(System.in);\n PrintWriter w = new PrintWriter(System.out);\n int n = in.nextInt();\n long[][] a = new long[n][n];\n boolean[][] avoid = new boolean[n][n];\n for (int i = 0; i < n; i++)for (int j = 0; j < n; j++)a[i][j] = in.nextLong();\n for (int i = 0; i < n; i++)for (int j = 0; j < n; j++)for (int k = 0; k < n; k++) {\n if (a[i][k] + a[k][j] < a[i][j]) {\n w.println(-1);\n w.close();\n return;\n }\n if (k != i && k != j)\n avoid[i][j] = (a[i][k] + a[k][j] == a[i][j]);\n }\n long ans = 0;\n for (int i = 0; i < n; i++)for (int j = 0; j < n; j++) {\n ans += ((!avoid[i][j]) ? a[i][j] : 0);\n }\n w.println(ans / 2);\n\n w.close();\n }\n\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n\n public int read() {\n if (numChars == -1)\n throw new UnknownError();\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new UnknownError();\n }\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }\n\n public int peek() {\n if (numChars == -1)\n return -1;\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n return -1;\n }\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar];\n }\n\n public void skip(int x) {\n while (x-- > 0)\n read();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n public String nextString() {\n return next();\n }\n\n public String next() {\n int c = read();\n while (isSpaceChar(c))\n c = read();\n StringBuffer res = new StringBuffer();\n do {\n res.appendCodePoint(c);\n c = read();\n } while (!isSpaceChar(c));\n\n return res.toString();\n }\n\n public String nextLine() {\n StringBuffer buf = new StringBuffer();\n int c = read();\n while (c != '\\n' && c != -1) {\n if (c != '\\r')\n buf.appendCodePoint(c);\n c = read();\n }\n return buf.toString();\n }\n\n public double nextDouble() {\n int c = read();\n while (isSpaceChar(c))\n c = read();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n double res = 0;\n while (!isSpaceChar(c) && c != '.') {\n if (c == 'e' || c == 'E')\n return res * Math.pow(10, nextInt());\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = read();\n }\n if (c == '.') {\n c = read();\n double m = 1;\n while (!isSpaceChar(c)) {\n if (c == 'e' || c == 'E')\n return res * Math.pow(10, nextInt());\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n m /= 10;\n res += (c - '0') * m;\n c = read();\n }\n }\n return res * sgn;\n }\n public int[] nextIntArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = nextInt();\n return a;\n }\n public long[] nextLongArray(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = nextLong();\n return a;\n }\n public boolean hasNext() {\n int value;\n while (isSpaceChar(value = peek()) && value != -1)\n read();\n return value != -1;\n }\n\n private boolean isSpaceChar(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n }\n}", "language": "Java", "metadata": {"date": 1506486770, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03600.html", "problem_id": "p03600", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03600/input.txt", "sample_output_relpath": "derived/input_output/data/p03600/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03600/Java/s770889623.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s770889623", "user_id": "u616866689"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*;\nimport java.lang.*;\nimport java.io.*;\nimport java.math.BigDecimal;\n\npublic class Main{\n public static void main (String[] args) throws java.lang.Exception {\n InputReader in = new InputReader(System.in);\n PrintWriter w = new PrintWriter(System.out);\n int n = in.nextInt();\n long[][] a = new long[n][n];\n boolean[][] avoid = new boolean[n][n];\n for (int i = 0; i < n; i++)for (int j = 0; j < n; j++)a[i][j] = in.nextLong();\n for (int i = 0; i < n; i++)for (int j = 0; j < n; j++)for (int k = 0; k < n; k++) {\n if (a[i][k] + a[k][j] < a[i][j]) {\n w.println(-1);\n w.close();\n return;\n }\n if (k != i && k != j)\n avoid[i][j] = (a[i][k] + a[k][j] == a[i][j]);\n }\n long ans = 0;\n for (int i = 0; i < n; i++)for (int j = 0; j < n; j++) {\n ans += ((!avoid[i][j]) ? a[i][j] : 0);\n }\n w.println(ans / 2);\n\n w.close();\n }\n\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n\n public int read() {\n if (numChars == -1)\n throw new UnknownError();\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new UnknownError();\n }\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }\n\n public int peek() {\n if (numChars == -1)\n return -1;\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n return -1;\n }\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar];\n }\n\n public void skip(int x) {\n while (x-- > 0)\n read();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n public String nextString() {\n return next();\n }\n\n public String next() {\n int c = read();\n while (isSpaceChar(c))\n c = read();\n StringBuffer res = new StringBuffer();\n do {\n res.appendCodePoint(c);\n c = read();\n } while (!isSpaceChar(c));\n\n return res.toString();\n }\n\n public String nextLine() {\n StringBuffer buf = new StringBuffer();\n int c = read();\n while (c != '\\n' && c != -1) {\n if (c != '\\r')\n buf.appendCodePoint(c);\n c = read();\n }\n return buf.toString();\n }\n\n public double nextDouble() {\n int c = read();\n while (isSpaceChar(c))\n c = read();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n double res = 0;\n while (!isSpaceChar(c) && c != '.') {\n if (c == 'e' || c == 'E')\n return res * Math.pow(10, nextInt());\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = read();\n }\n if (c == '.') {\n c = read();\n double m = 1;\n while (!isSpaceChar(c)) {\n if (c == 'e' || c == 'E')\n return res * Math.pow(10, nextInt());\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n m /= 10;\n res += (c - '0') * m;\n c = read();\n }\n }\n return res * sgn;\n }\n public int[] nextIntArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = nextInt();\n return a;\n }\n public long[] nextLongArray(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = nextLong();\n return a;\n }\n public boolean hasNext() {\n int value;\n while (isSpaceChar(value = peek()) && value != -1)\n read();\n return value != -1;\n }\n\n private boolean isSpaceChar(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nIn Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads.\nThe following are known about the road network:\n\nPeople traveled between cities only through roads. It was possible to reach any city from any other city, via intermediate cities if necessary.\n\nDifferent roads may have had different lengths, but all the lengths were positive integers.\n\nSnuke the archeologist found a table with N rows and N columns, A, in the ruin of Takahashi Kingdom.\nHe thought that it represented the shortest distances between the cities along the roads in the kingdom.\n\nDetermine whether there exists a road network such that for each u and v, the integer A_{u, v} at the u-th row and v-th column of A is equal to the length of the shortest path from City u to City v.\nIf such a network exist, find the shortest possible total length of the roads.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nIf i ≠ j, 1 \\leq A_{i, j} = A_{j, i} \\leq 10^9.\n\nA_{i, i} = 0\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} ... A_{1, N}\nA_{2, 1} A_{2, 2} ... A_{2, N}\n...\nA_{N, 1} A_{N, 2} ... A_{N, N}\n\nOutputs\n\nIf there exists no network that satisfies the condition, print -1.\nIf it exists, print the shortest possible total length of the roads.\n\nSample Input 1\n\n3\n0 1 3\n1 0 2\n3 2 0\n\nSample Output 1\n\n3\n\nThe network below satisfies the condition:\n\nCity 1 and City 2 is connected by a road of length 1.\n\nCity 2 and City 3 is connected by a road of length 2.\n\nCity 3 and City 1 is not connected by a road.\n\nSample Input 2\n\n3\n0 1 3\n1 0 1\n3 1 0\n\nSample Output 2\n\n-1\n\nAs there is a path of length 1 from City 1 to City 2 and City 2 to City 3, there is a path of length 2 from City 1 to City 3.\nHowever, according to the table, the shortest distance between City 1 and City 3 must be 3.\n\nThus, we conclude that there exists no network that satisfies the condition.\n\nSample Input 3\n\n5\n0 21 18 11 28\n21 0 13 10 26\n18 13 0 23 13\n11 10 23 0 17\n28 26 13 17 0\n\nSample Output 3\n\n82\n\nSample Input 4\n\n3\n0 1000000000 1000000000\n1000000000 0 1000000000\n1000000000 1000000000 0\n\nSample Output 4\n\n3000000000", "sample_input": "3\n0 1 3\n1 0 2\n3 2 0\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03600", "source_text": "Score : 500 points\n\nProblem Statement\n\nIn Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads.\nThe following are known about the road network:\n\nPeople traveled between cities only through roads. It was possible to reach any city from any other city, via intermediate cities if necessary.\n\nDifferent roads may have had different lengths, but all the lengths were positive integers.\n\nSnuke the archeologist found a table with N rows and N columns, A, in the ruin of Takahashi Kingdom.\nHe thought that it represented the shortest distances between the cities along the roads in the kingdom.\n\nDetermine whether there exists a road network such that for each u and v, the integer A_{u, v} at the u-th row and v-th column of A is equal to the length of the shortest path from City u to City v.\nIf such a network exist, find the shortest possible total length of the roads.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nIf i ≠ j, 1 \\leq A_{i, j} = A_{j, i} \\leq 10^9.\n\nA_{i, i} = 0\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} ... A_{1, N}\nA_{2, 1} A_{2, 2} ... A_{2, N}\n...\nA_{N, 1} A_{N, 2} ... A_{N, N}\n\nOutputs\n\nIf there exists no network that satisfies the condition, print -1.\nIf it exists, print the shortest possible total length of the roads.\n\nSample Input 1\n\n3\n0 1 3\n1 0 2\n3 2 0\n\nSample Output 1\n\n3\n\nThe network below satisfies the condition:\n\nCity 1 and City 2 is connected by a road of length 1.\n\nCity 2 and City 3 is connected by a road of length 2.\n\nCity 3 and City 1 is not connected by a road.\n\nSample Input 2\n\n3\n0 1 3\n1 0 1\n3 1 0\n\nSample Output 2\n\n-1\n\nAs there is a path of length 1 from City 1 to City 2 and City 2 to City 3, there is a path of length 2 from City 1 to City 3.\nHowever, according to the table, the shortest distance between City 1 and City 3 must be 3.\n\nThus, we conclude that there exists no network that satisfies the condition.\n\nSample Input 3\n\n5\n0 21 18 11 28\n21 0 13 10 26\n18 13 0 23 13\n11 10 23 0 17\n28 26 13 17 0\n\nSample Output 3\n\n82\n\nSample Input 4\n\n3\n0 1000000000 1000000000\n1000000000 0 1000000000\n1000000000 1000000000 0\n\nSample Output 4\n\n3000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5133, "cpu_time_ms": 309, "memory_kb": 35408}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s915879580", "group_id": "codeNet:p03617", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n long q = sc.nextLong();\n long h = sc.nextLong();\n long s = sc.nextLong();\n long d = sc.nextLong();\n long n = sc.nextLong();\n\n long onel = Math.min(Math.min(4 * q, 2 * h), s);\n long twol = Math.min(onel * 2, d);\n if ((onel * 2) >= d) {\n System.out.println((twol * (n / 2)) + (onel * (n % 2)));\n } else {\n System.out.println(onel * n);\n }\n\n }\n}", "language": "Java", "metadata": {"date": 1594773005, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p03617.html", "problem_id": "p03617", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03617/input.txt", "sample_output_relpath": "derived/input_output/data/p03617/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03617/Java/s915879580.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s915879580", "user_id": "u357544143"}, "prompt_components": {"gold_output": "150\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n long q = sc.nextLong();\n long h = sc.nextLong();\n long s = sc.nextLong();\n long d = sc.nextLong();\n long n = sc.nextLong();\n\n long onel = Math.min(Math.min(4 * q, 2 * h), s);\n long twol = Math.min(onel * 2, d);\n if ((onel * 2) >= d) {\n System.out.println((twol * (n / 2)) + (onel * (n % 2)));\n } else {\n System.out.println(onel * n);\n }\n\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou've come to your favorite store Infinitesco to buy some ice tea.\n\nThe store sells ice tea in bottles of different volumes at different costs.\nSpecifically, a 0.25-liter bottle costs Q yen, a 0.5-liter bottle costs H yen, a 1-liter bottle costs S yen, and a 2-liter bottle costs D yen.\nThe store has an infinite supply of bottles of each type.\n\nYou want to buy exactly N liters of ice tea. How many yen do you have to spend?\n\nConstraints\n\n1 \\leq Q, H, S, D \\leq 10^8\n\n1 \\leq N \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ H S D\nN\n\nOutput\n\nPrint the smallest number of yen you have to spend to buy exactly N liters of ice tea.\n\nSample Input 1\n\n20 30 70 90\n3\n\nSample Output 1\n\n150\n\nBuy one 2-liter bottle and two 0.5-liter bottles. You'll get 3 liters for 90 + 30 + 30 = 150 yen.\n\nSample Input 2\n\n10000 1000 100 10\n1\n\nSample Output 2\n\n100\n\nEven though a 2-liter bottle costs just 10 yen, you need only 1 liter.\nThus, you have to buy a 1-liter bottle for 100 yen.\n\nSample Input 3\n\n10 100 1000 10000\n1\n\nSample Output 3\n\n40\n\nNow it's better to buy four 0.25-liter bottles for 10 + 10 + 10 + 10 = 40 yen.\n\nSample Input 4\n\n12345678 87654321 12345678 87654321\n123456789\n\nSample Output 4\n\n1524157763907942", "sample_input": "20 30 70 90\n3\n"}, "reference_outputs": ["150\n"], "source_document_id": "p03617", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou've come to your favorite store Infinitesco to buy some ice tea.\n\nThe store sells ice tea in bottles of different volumes at different costs.\nSpecifically, a 0.25-liter bottle costs Q yen, a 0.5-liter bottle costs H yen, a 1-liter bottle costs S yen, and a 2-liter bottle costs D yen.\nThe store has an infinite supply of bottles of each type.\n\nYou want to buy exactly N liters of ice tea. How many yen do you have to spend?\n\nConstraints\n\n1 \\leq Q, H, S, D \\leq 10^8\n\n1 \\leq N \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ H S D\nN\n\nOutput\n\nPrint the smallest number of yen you have to spend to buy exactly N liters of ice tea.\n\nSample Input 1\n\n20 30 70 90\n3\n\nSample Output 1\n\n150\n\nBuy one 2-liter bottle and two 0.5-liter bottles. You'll get 3 liters for 90 + 30 + 30 = 150 yen.\n\nSample Input 2\n\n10000 1000 100 10\n1\n\nSample Output 2\n\n100\n\nEven though a 2-liter bottle costs just 10 yen, you need only 1 liter.\nThus, you have to buy a 1-liter bottle for 100 yen.\n\nSample Input 3\n\n10 100 1000 10000\n1\n\nSample Output 3\n\n40\n\nNow it's better to buy four 0.25-liter bottles for 10 + 10 + 10 + 10 = 40 yen.\n\nSample Input 4\n\n12345678 87654321 12345678 87654321\n123456789\n\nSample Output 4\n\n1524157763907942", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 517, "cpu_time_ms": 125, "memory_kb": 35552}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s479956707", "group_id": "codeNet:p03618", "input_text": "import java.util.*;\n\npublic class Main {\n static Scanner scanner = new Scanner(System.in);\n\n public static void main(String[]$) {\n char[] s = scanner.next().toCharArray();\n long ans = s.length * (s.length - 1) / 2 + 1;\n int[] count = new int[26];\n for (char c : s) {\n count[c - 'a']++;\n }\n for (int a : count) {\n ans -= a * (a - 1) / 2;\n }\n System.out.println(ans);\n }\n}", "language": "Java", "metadata": {"date": 1563331658, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03618.html", "problem_id": "p03618", "resource_group": "high_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/Java/s479956707.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s479956707", "user_id": "u981808900"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n static Scanner scanner = new Scanner(System.in);\n\n public static void main(String[]$) {\n char[] s = scanner.next().toCharArray();\n long ans = s.length * (s.length - 1) / 2 + 1;\n int[] count = new int[26];\n for (char c : s) {\n count[c - 'a']++;\n }\n for (int a : count) {\n ans -= a * (a - 1) / 2;\n }\n System.out.println(ans);\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": 457, "cpu_time_ms": 164, "memory_kb": 28452}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s148571682", "group_id": "codeNet:p03618", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tString a = sc.next();\n\t\t\n\t\tlong len = a.length();\n\t\t\n\t\tint[] f = new int[26];\n\t\t\n\t\tfor(int i = 0; i < 26; i++) {\n\t\t\tf[i] = 0;\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < len; i++) {\n\t\t\tf[a.charAt(i)-'a']++;\n\t\t}\n\t\t\n\t\tlong sum = 0;\n\t\tfor(int x:f) {\n\t\t\tsum += x * (x - 1) / 2;\n\t\t}\n\n\t\tSystem.out.println(len*(len - 1) / 2 - sum + 1);\n\t\t\n\t}\n}", "language": "Java", "metadata": {"date": 1509673926, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03618.html", "problem_id": "p03618", "resource_group": "high_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/Java/s148571682.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s148571682", "user_id": "u001648655"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tString a = sc.next();\n\t\t\n\t\tlong len = a.length();\n\t\t\n\t\tint[] f = new int[26];\n\t\t\n\t\tfor(int i = 0; i < 26; i++) {\n\t\t\tf[i] = 0;\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < len; i++) {\n\t\t\tf[a.charAt(i)-'a']++;\n\t\t}\n\t\t\n\t\tlong sum = 0;\n\t\tfor(int x:f) {\n\t\t\tsum += x * (x - 1) / 2;\n\t\t}\n\n\t\tSystem.out.println(len*(len - 1) / 2 - sum + 1);\n\t\t\n\t}\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": 453, "cpu_time_ms": 177, "memory_kb": 28448}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s994942551", "group_id": "codeNet:p03618", "input_text": "import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tchar[] A = sc.next().toCharArray();\n\t\tint N = A.length;\n\t\tint[] cnt = new int[26];\n\t\tfor(int i=0; i0)\n\t\t\t\tans -= (long)cnt[i]*(cnt[i]+1)/2;\n\t\t\n\t\tSystem.out.println(ans);\n\t\t\n\t\tsc.close();\n\t}\n}\n", "language": "Java", "metadata": {"date": 1505272500, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03618.html", "problem_id": "p03618", "resource_group": "high_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/Java/s994942551.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s994942551", "user_id": "u061996193"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tchar[] A = sc.next().toCharArray();\n\t\tint N = A.length;\n\t\tint[] cnt = new int[26];\n\t\tfor(int i=0; i0)\n\t\t\t\tans -= (long)cnt[i]*(cnt[i]+1)/2;\n\t\t\n\t\tSystem.out.println(ans);\n\t\t\n\t\tsc.close();\n\t}\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": 420, "cpu_time_ms": 163, "memory_kb": 26576}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s913286891", "group_id": "codeNet:p03619", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.Set;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayList;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.StringTokenizer;\nimport java.io.BufferedReader;\nimport java.util.Collections;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tInputStream inputStream = System.in;\n\t\tOutputStream outputStream = System.out;\n\t\tFastScanner in = new FastScanner(inputStream);\n\t\tPrintWriter out = new PrintWriter(outputStream);\n\t\tProblemC solver = new ProblemC();\n\t\tsolver.solve(1, in, out);\n\t\tout.close();\n\t}\n\n\tstatic class ProblemC {\n\t\tpublic void solve(int testNumber, FastScanner in, PrintWriter out) {\n\t\t\tint x1 = in.nextInt();\n\t\t\tint y1 = in.nextInt();\n\t\t\tint x2 = in.nextInt();\n\t\t\tint y2 = in.nextInt();\n\t\t\tint n = in.nextInt();\n\t\t\tint[] x = new int[n];\n\t\t\tint[] y = new int[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tx[i] = in.nextInt();\n\t\t\t\ty[i] = in.nextInt();\n\t\t\t}\n\t\t\tif (x1 > x2) {\n\t\t\t\tx1 = -x1;\n\t\t\t\tx2 = -x2;\n\t\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\t\tx[i] = -x[i];\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (y1 > y2) {\n\t\t\t\ty1 = -y1;\n\t\t\t\ty2 = -y2;\n\t\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\t\ty[i] = -y[i];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tdouble ans = 100 * (x2 - x1 + y2 - y1);\n\t\t\tif (x1 == x2) {\n\t\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\t\tif (x[i] == x1 && y[i] >= y1 && y[i] <= y2) {\n\t\t\t\t\t\tans -= 20;\n\t\t\t\t\t\tans += Math.PI * 10;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (y1 == y2) {\n\t\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\t\tif (y[i] == y1 && x[i] >= x1 && x[i] <= x2) {\n\t\t\t\t\t\tans -= 20;\n\t\t\t\t\t\tans += Math.PI * 10;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tList ps = new ArrayList<>();\n\t\t\t\tps.add(new Point(x2, y2));\n\t\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\t\tif (x[i] >= x1 && x[i] <= x2 && y[i] >= y1 && y[i] <= y2) {\n\t\t\t\t\t\tps.add(new Point(x[i], y[i]));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tCollections.sort(ps);\n\t\t\t\tSet xs = new HashSet<>();\n\t\t\t\tfor (Point p : ps) {\n\t\t\t\t\txs.add(p.x);\n\t\t\t\t}\n\t\t\t\tint[] interestingX = new int[xs.size()];\n\t\t\t\tint ptr = 0;\n\t\t\t\tfor (int cx : xs) {\n\t\t\t\t\tinterestingX[ptr++] = cx;\n\t\t\t\t}\n\t\t\t\tArrays.sort(interestingX);\n\t\t\t\tint[] d = new int[ps.size()];\n\t\t\t\tIntervalTree tree = new IntervalTree(xs.size());\n\t\t\t\tfor (int i = 0; i < d.length; i++) {\n\t\t\t\t\tint id = Arrays.binarySearch(interestingX, ps.get(i).x);\n\t\t\t\t\td[i] = 1 + tree.getMax(0, id);\n\t\t\t\t\ttree.set(id, d[i]);\n\t\t\t\t}\n\t\t\t\tint c = d[d.length - 1] - 1;\n\t\t\t\tans -= c * 20;\n\t\t\t\tans += c * Math.PI * 5;\n\t\t\t}\n\t\t\tout.printf(\"%.15f\\n\", ans);\n\t\t}\n\n\t\tclass Point implements Comparable {\n\t\t\tint x;\n\t\t\tint y;\n\n\t\t\tPoint(int x, int y) {\n\t\t\t\tthis.x = x;\n\t\t\t\tthis.y = y;\n\t\t\t}\n\n\t\t\tpublic int compareTo(Point o) {\n\t\t\t\tif (x != o.x) {\n\t\t\t\t\treturn x - o.x;\n\t\t\t\t}\n\t\t\t\tif (y != o.y) {\n\t\t\t\t\treturn y - o.y;\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t}\n\n\t\tclass IntervalTree {\n\t\t\tint[] max;\n\t\t\tint n;\n\n\t\t\tIntervalTree(int n) {\n\t\t\t\tthis.n = n;\n\t\t\t\tmax = new int[4 * n];\n\t\t\t}\n\n\t\t\tvoid set(int pos, int val) {\n\t\t\t\tset(0, pos, 0, n - 1, val);\n\t\t\t}\n\n\t\t\tint getMax(int l, int r) {\n\t\t\t\treturn get(0, l, r, 0, n - 1);\n\t\t\t}\n\n\t\t\tprivate void set(int root, int pos, int L, int R, int val) {\n\t\t\t\tif (pos < L || pos > R) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (pos == L) {\n\t\t\t\t\tmax[root] = val;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tint M = (L + R) / 2;\n\t\t\t\tset(2 * root + 1, pos, L, M, val);\n\t\t\t\tset(2 * root + 2, pos, M + 1, R, val);\n\t\t\t\tmax[root] = Math.max(max[2 * root + 1], max[2 * root + 2]);\n\t\t\t}\n\n\t\t\tprivate int get(int root, int l, int r, int L, int R) {\n\t\t\t\tif (l > r || l > R || L > r || L > R) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tif (l == L && r == R) {\n\t\t\t\t\treturn max[root];\n\t\t\t\t}\n\t\t\t\tint M = (L + R) / 2;\n\t\t\t\tint res = 0;\n\t\t\t\tres = Math.max(res, get(2 * root + 1, l, Math.min(r, M), L, M));\n\t\t\t\tres = Math.max(res, get(2 * root + 2, Math.max(l, M + 1), r, M + 1, R));\n\t\t\t\treturn res;\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tstatic class FastScanner {\n\t\tprivate BufferedReader in;\n\t\tprivate StringTokenizer st;\n\n\t\tpublic FastScanner(InputStream stream) {\n\t\t\tin = new BufferedReader(new InputStreamReader(stream));\n\t\t}\n\n\t\tpublic String next() {\n\t\t\twhile (st == null || !st.hasMoreTokens()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(in.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new RuntimeException(e);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t}\n}\n\n", "language": "Java", "metadata": {"date": 1503803261, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03619.html", "problem_id": "p03619", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03619/input.txt", "sample_output_relpath": "derived/input_output/data/p03619/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03619/Java/s913286891.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s913286891", "user_id": "u113560961"}, "prompt_components": {"gold_output": "891.415926535897938\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.Set;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayList;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.StringTokenizer;\nimport java.io.BufferedReader;\nimport java.util.Collections;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tInputStream inputStream = System.in;\n\t\tOutputStream outputStream = System.out;\n\t\tFastScanner in = new FastScanner(inputStream);\n\t\tPrintWriter out = new PrintWriter(outputStream);\n\t\tProblemC solver = new ProblemC();\n\t\tsolver.solve(1, in, out);\n\t\tout.close();\n\t}\n\n\tstatic class ProblemC {\n\t\tpublic void solve(int testNumber, FastScanner in, PrintWriter out) {\n\t\t\tint x1 = in.nextInt();\n\t\t\tint y1 = in.nextInt();\n\t\t\tint x2 = in.nextInt();\n\t\t\tint y2 = in.nextInt();\n\t\t\tint n = in.nextInt();\n\t\t\tint[] x = new int[n];\n\t\t\tint[] y = new int[n];\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tx[i] = in.nextInt();\n\t\t\t\ty[i] = in.nextInt();\n\t\t\t}\n\t\t\tif (x1 > x2) {\n\t\t\t\tx1 = -x1;\n\t\t\t\tx2 = -x2;\n\t\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\t\tx[i] = -x[i];\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (y1 > y2) {\n\t\t\t\ty1 = -y1;\n\t\t\t\ty2 = -y2;\n\t\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\t\ty[i] = -y[i];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tdouble ans = 100 * (x2 - x1 + y2 - y1);\n\t\t\tif (x1 == x2) {\n\t\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\t\tif (x[i] == x1 && y[i] >= y1 && y[i] <= y2) {\n\t\t\t\t\t\tans -= 20;\n\t\t\t\t\t\tans += Math.PI * 10;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (y1 == y2) {\n\t\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\t\tif (y[i] == y1 && x[i] >= x1 && x[i] <= x2) {\n\t\t\t\t\t\tans -= 20;\n\t\t\t\t\t\tans += Math.PI * 10;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tList ps = new ArrayList<>();\n\t\t\t\tps.add(new Point(x2, y2));\n\t\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\t\tif (x[i] >= x1 && x[i] <= x2 && y[i] >= y1 && y[i] <= y2) {\n\t\t\t\t\t\tps.add(new Point(x[i], y[i]));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tCollections.sort(ps);\n\t\t\t\tSet xs = new HashSet<>();\n\t\t\t\tfor (Point p : ps) {\n\t\t\t\t\txs.add(p.x);\n\t\t\t\t}\n\t\t\t\tint[] interestingX = new int[xs.size()];\n\t\t\t\tint ptr = 0;\n\t\t\t\tfor (int cx : xs) {\n\t\t\t\t\tinterestingX[ptr++] = cx;\n\t\t\t\t}\n\t\t\t\tArrays.sort(interestingX);\n\t\t\t\tint[] d = new int[ps.size()];\n\t\t\t\tIntervalTree tree = new IntervalTree(xs.size());\n\t\t\t\tfor (int i = 0; i < d.length; i++) {\n\t\t\t\t\tint id = Arrays.binarySearch(interestingX, ps.get(i).x);\n\t\t\t\t\td[i] = 1 + tree.getMax(0, id);\n\t\t\t\t\ttree.set(id, d[i]);\n\t\t\t\t}\n\t\t\t\tint c = d[d.length - 1] - 1;\n\t\t\t\tans -= c * 20;\n\t\t\t\tans += c * Math.PI * 5;\n\t\t\t}\n\t\t\tout.printf(\"%.15f\\n\", ans);\n\t\t}\n\n\t\tclass Point implements Comparable {\n\t\t\tint x;\n\t\t\tint y;\n\n\t\t\tPoint(int x, int y) {\n\t\t\t\tthis.x = x;\n\t\t\t\tthis.y = y;\n\t\t\t}\n\n\t\t\tpublic int compareTo(Point o) {\n\t\t\t\tif (x != o.x) {\n\t\t\t\t\treturn x - o.x;\n\t\t\t\t}\n\t\t\t\tif (y != o.y) {\n\t\t\t\t\treturn y - o.y;\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t}\n\n\t\tclass IntervalTree {\n\t\t\tint[] max;\n\t\t\tint n;\n\n\t\t\tIntervalTree(int n) {\n\t\t\t\tthis.n = n;\n\t\t\t\tmax = new int[4 * n];\n\t\t\t}\n\n\t\t\tvoid set(int pos, int val) {\n\t\t\t\tset(0, pos, 0, n - 1, val);\n\t\t\t}\n\n\t\t\tint getMax(int l, int r) {\n\t\t\t\treturn get(0, l, r, 0, n - 1);\n\t\t\t}\n\n\t\t\tprivate void set(int root, int pos, int L, int R, int val) {\n\t\t\t\tif (pos < L || pos > R) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (pos == L) {\n\t\t\t\t\tmax[root] = val;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tint M = (L + R) / 2;\n\t\t\t\tset(2 * root + 1, pos, L, M, val);\n\t\t\t\tset(2 * root + 2, pos, M + 1, R, val);\n\t\t\t\tmax[root] = Math.max(max[2 * root + 1], max[2 * root + 2]);\n\t\t\t}\n\n\t\t\tprivate int get(int root, int l, int r, int L, int R) {\n\t\t\t\tif (l > r || l > R || L > r || L > R) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tif (l == L && r == R) {\n\t\t\t\t\treturn max[root];\n\t\t\t\t}\n\t\t\t\tint M = (L + R) / 2;\n\t\t\t\tint res = 0;\n\t\t\t\tres = Math.max(res, get(2 * root + 1, l, Math.min(r, M), L, M));\n\t\t\t\tres = Math.max(res, get(2 * root + 2, Math.max(l, M + 1), r, M + 1, R));\n\t\t\t\treturn res;\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tstatic class FastScanner {\n\t\tprivate BufferedReader in;\n\t\tprivate StringTokenizer st;\n\n\t\tpublic FastScanner(InputStream stream) {\n\t\t\tin = new BufferedReader(new InputStreamReader(stream));\n\t\t}\n\n\t\tpublic String next() {\n\t\t\twhile (st == null || !st.hasMoreTokens()) {\n\t\t\t\ttry {\n\t\t\t\t\tst = new StringTokenizer(in.readLine());\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new RuntimeException(e);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t\tpublic int nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t}\n}\n\n", "problem_context": "Score : 900 points\n\nProblem Statement\n\nIn the city of Nevermore, there are 10^8 streets and 10^8 avenues, both numbered from 0 to 10^8-1.\nAll streets run straight from west to east, and all avenues run straight from south to north.\nThe distance between neighboring streets and between neighboring avenues is exactly 100 meters.\n\nEvery street intersects every avenue. Every intersection can be described by pair (x, y), where x is avenue ID and y is street ID.\n\nThere are N fountains in the city, situated at intersections (X_i, Y_i).\nUnlike normal intersections, there's a circle with radius 10 meters centered at the intersection, and there are no road parts inside this circle.\n\nThe picture below shows an example of how a part of the city with roads and fountains may look like.\n\nCity governors don't like encountering more than one fountain while moving along the same road.\nTherefore, every street contains at most one fountain on it, as well as every avenue.\n\nCitizens can move along streets, avenues and fountain perimeters.\nWhat is the shortest distance one needs to cover in order to get from intersection (x_1, y_1) to intersection (x_2, y_2)?\n\nConstraints\n\n0 \\leq x_1, y_1, x_2, y_2 < 10^8\n\n1 \\leq N \\leq 200,000\n\n0 \\leq X_i, Y_i < 10^8\n\nX_i \\neq X_j for i \\neq j\n\nY_i \\neq Y_j for i \\neq j\n\nIntersections (x_1, y_1) and (x_2, y_2) are different and don't contain fountains.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 y_1 x_2 y_2\nN\nX_1 Y_1\nX_2 Y_2\n:\nX_N Y_N\n\nOutput\n\nPrint the shortest possible distance one needs to cover in order to get from intersection (x_1, y_1) to intersection (x_2, y_2), in meters.\nYour answer will be considered correct if its absolute or relative error doesn't exceed 10^{-11}.\n\nSample Input 1\n\n1 1 6 5\n3\n3 2\n5 3\n2 4\n\nSample Output 1\n\n891.415926535897938\n\nOne possible shortest path is shown on the picture below. The path starts at the blue point, finishes at the purple point and follows along the red line.\n\nSample Input 2\n\n3 5 6 4\n3\n3 2\n5 3\n2 4\n\nSample Output 2\n\n400.000000000000000\n\nSample Input 3\n\n4 2 2 2\n3\n3 2\n5 3\n2 4\n\nSample Output 3\n\n211.415926535897938", "sample_input": "1 1 6 5\n3\n3 2\n5 3\n2 4\n"}, "reference_outputs": ["891.415926535897938\n"], "source_document_id": "p03619", "source_text": "Score : 900 points\n\nProblem Statement\n\nIn the city of Nevermore, there are 10^8 streets and 10^8 avenues, both numbered from 0 to 10^8-1.\nAll streets run straight from west to east, and all avenues run straight from south to north.\nThe distance between neighboring streets and between neighboring avenues is exactly 100 meters.\n\nEvery street intersects every avenue. Every intersection can be described by pair (x, y), where x is avenue ID and y is street ID.\n\nThere are N fountains in the city, situated at intersections (X_i, Y_i).\nUnlike normal intersections, there's a circle with radius 10 meters centered at the intersection, and there are no road parts inside this circle.\n\nThe picture below shows an example of how a part of the city with roads and fountains may look like.\n\nCity governors don't like encountering more than one fountain while moving along the same road.\nTherefore, every street contains at most one fountain on it, as well as every avenue.\n\nCitizens can move along streets, avenues and fountain perimeters.\nWhat is the shortest distance one needs to cover in order to get from intersection (x_1, y_1) to intersection (x_2, y_2)?\n\nConstraints\n\n0 \\leq x_1, y_1, x_2, y_2 < 10^8\n\n1 \\leq N \\leq 200,000\n\n0 \\leq X_i, Y_i < 10^8\n\nX_i \\neq X_j for i \\neq j\n\nY_i \\neq Y_j for i \\neq j\n\nIntersections (x_1, y_1) and (x_2, y_2) are different and don't contain fountains.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 y_1 x_2 y_2\nN\nX_1 Y_1\nX_2 Y_2\n:\nX_N Y_N\n\nOutput\n\nPrint the shortest possible distance one needs to cover in order to get from intersection (x_1, y_1) to intersection (x_2, y_2), in meters.\nYour answer will be considered correct if its absolute or relative error doesn't exceed 10^{-11}.\n\nSample Input 1\n\n1 1 6 5\n3\n3 2\n5 3\n2 4\n\nSample Output 1\n\n891.415926535897938\n\nOne possible shortest path is shown on the picture below. The path starts at the blue point, finishes at the purple point and follows along the red line.\n\nSample Input 2\n\n3 5 6 4\n3\n3 2\n5 3\n2 4\n\nSample Output 2\n\n400.000000000000000\n\nSample Input 3\n\n4 2 2 2\n3\n3 2\n5 3\n2 4\n\nSample Output 3\n\n211.415926535897938", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4454, "cpu_time_ms": 729, "memory_kb": 69840}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s108112057", "group_id": "codeNet:p03623", "input_text": "import java.util.*;\n \nclass Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int x = sc.nextInt();\n int a = sc.nextInt();\n int b = sc.nextInt();\n \n int y = Math.abs(x-a);\n int z = Math.abs(x-b);\n \n if(y= d || b <= c) {\n \tSystem.out.println(0);\n } else {\n \tint s = Math.max(a, c);\n \tint e = Math.min(a, b);\n \tSystem.out.println(e - s);\n }\n }\n}", "language": "Java", "metadata": {"date": 1577724344, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03632.html", "problem_id": "p03632", "resource_group": "high_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/Java/s250556761.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s250556761", "user_id": "u101079650"}, "prompt_components": {"gold_output": "50\n", "input_to_evaluate": "\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n \n int a = sc.nextInt();\n int b = sc.nextInt();\n int c = sc.nextInt();\n int d = sc.nextInt();\n \n if (a >= d || b <= c) {\n \tSystem.out.println(0);\n } else {\n \tint s = Math.max(a, c);\n \tint e = Math.min(a, b);\n \tSystem.out.println(e - s);\n }\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAlice and Bob are controlling a robot. They each have one switch that controls the robot.\n\nAlice started holding down her button A second after the start-up of the robot, and released her button B second after the start-up.\n\nBob started holding down his button C second after the start-up, and released his button D second after the start-up.\n\nFor how many seconds both Alice and Bob were holding down their buttons?\n\nConstraints\n\n0≤A0) {\n\t\t\tSystem.out.print(Math.min(b, d)-Math.max(a, c));\n\t\t}\n\t\telse System.out.print(\"0\");\n\t}\n\n}", "language": "Java", "metadata": {"date": 1522209500, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03632.html", "problem_id": "p03632", "resource_group": "high_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/Java/s797257997.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s797257997", "user_id": "u802942094"}, "prompt_components": {"gold_output": "50\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\tScanner sc = new Scanner(System.in);\n\t\tint a = sc.nextInt() , b = sc.nextInt(), \n\t\t\t\tc = sc.nextInt(), d = sc.nextInt();\n\t\t\n\t\tif(Math.min(b, d)-Math.max(a, c)>0) {\n\t\t\tSystem.out.print(Math.min(b, d)-Math.max(a, c));\n\t\t}\n\t\telse System.out.print(\"0\");\n\t}\n\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAlice and Bob are controlling a robot. They each have one switch that controls the robot.\n\nAlice started holding down her button A second after the start-up of the robot, and released her button B second after the start-up.\n\nBob started holding down his button C second after the start-up, and released his button D second after the start-up.\n\nFor how many seconds both Alice and Bob were holding down their buttons?\n\nConstraints\n\n0≤A Integer.MAX_VALUE)\n\t\t\tthrow new NumberFormatException();\n\t\treturn (int) nl;\n\t}\n\n\tpublic double nextDouble() {\n\t\treturn Double.parseDouble(next());\n\t}\n}\n", "language": "Java", "metadata": {"date": 1587171754, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03635.html", "problem_id": "p03635", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03635/input.txt", "sample_output_relpath": "derived/input_output/data/p03635/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03635/Java/s569362136.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s569362136", "user_id": "u181039779"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.net.ConnectException;\nimport java.rmi.dgc.Lease;\nimport java.util.ArrayDeque;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.Deque;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.NoSuchElementException;\nimport java.util.Objects;\nimport java.util.PriorityQueue;\nimport java.util.Set;\nimport java.util.Stack;\nimport java.util.TreeMap;\nimport java.util.TreeSet;\n\nimport static java.util.Comparator.*;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tMain main = new Main();\n\t\tmain.solve();\n\t\tmain.out.close();\n\t}\n\n\t// ======================================================================\n\tpublic void solve() {\n\t\tint N = ni();\n\t\tint M = ni();\n\t\tout.println((N-1)*(M-1));\n\t}\n\t\n\t// ------------------------------------------\n\t// ライブラリ\n\t// ------------------------------------------\n\t// Print\n\tprivate PrintWriter out = new PrintWriter(System.out);\n\n\t// Scanner\n\tprivate FastScanner scan = new FastScanner();\n\n\tint ni() {\n\t\treturn scan.nextInt();\n\t}\n\n\tint[] ni(int n) {\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = ni();\n\t\t}\n\t\treturn a;\n\t}\n\n\tint[][] ni(int y, int x) {\n\t\tint[][] a = new int[y][x];\n\t\tfor (int i = 0; i < y; i++) {\n\t\t\tfor (int j = 0; j < x; j++) {\n\t\t\t\ta[i][j] = ni();\n\t\t\t}\n\t\t}\n\t\treturn a;\n\t}\n\n\tlong nl() {\n\t\treturn scan.nextLong();\n\t}\n\n\tlong[] nl(int n) {\n\t\tlong[] a = new long[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = nl();\n\t\t}\n\t\treturn a;\n\t}\n\n\tlong[][] nl(int y, int x) {\n\t\tlong[][] a = new long[y][x];\n\t\tfor (int i = 0; i < y; i++) {\n\t\t\tfor (int j = 0; j < x; j++) {\n\t\t\t\ta[i][j] = nl();\n\t\t\t}\n\t\t}\n\t\treturn a;\n\t}\n\n\tString ns() {\n\t\treturn scan.next();\n\t}\n\n\tString[] ns(int n) {\n\t\tString[] a = new String[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ta[i] = ns();\n\t\t}\n\t\treturn a;\n\t}\n\n\tString[][] ns(int y, int x) {\n\t\tString[][] a = new String[y][x];\n\t\tfor (int i = 0; i < y; i++) {\n\t\t\tfor (int j = 0; j < x; j++) {\n\t\t\t\ta[i][j] = ns();\n\t\t\t}\n\t\t}\n\t\treturn a;\n\t}\n}\n\nclass FastScanner {\n\tprivate final InputStream in = System.in;\n\tprivate final byte[] buffer = new byte[1024];\n\tprivate int ptr = 0;\n\tprivate int buflen = 0;\n\n\tprivate boolean hasNextByte() {\n\t\tif (ptr < buflen) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\tptr = 0;\n\t\t\ttry {\n\t\t\t\tbuflen = in.read(buffer);\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (buflen <= 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tprivate int readByte() {\n\t\tif (hasNextByte())\n\t\t\treturn buffer[ptr++];\n\t\telse\n\t\t\treturn -1;\n\t}\n\n\tprivate static boolean isPrintableChar(int c) {\n\t\treturn 33 <= c && c <= 126;\n\t}\n\n\tpublic boolean hasNext() {\n\t\twhile (hasNextByte() && !isPrintableChar(buffer[ptr]))\n\t\t\tptr++;\n\t\treturn hasNextByte();\n\t}\n\n\tpublic String next() {\n\t\tif (!hasNext())\n\t\t\tthrow new NoSuchElementException();\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint b = readByte();\n\t\twhile (isPrintableChar(b)) {\n\t\t\tsb.appendCodePoint(b);\n\t\t\tb = readByte();\n\t\t}\n\t\treturn sb.toString();\n\t}\n\n\tpublic long nextLong() {\n\t\tif (!hasNext())\n\t\t\tthrow new NoSuchElementException();\n\t\tlong n = 0;\n\t\tboolean minus = false;\n\t\tint b = readByte();\n\t\tif (b == '-') {\n\t\t\tminus = true;\n\t\t\tb = readByte();\n\t\t}\n\t\tif (b < '0' || '9' < b) {\n\t\t\tthrow new NumberFormatException();\n\t\t}\n\t\twhile (true) {\n\t\t\tif ('0' <= b && b <= '9') {\n\t\t\t\tn *= 10;\n\t\t\t\tn += b - '0';\n\t\t\t} else if (b == -1 || !isPrintableChar(b)) {\n\t\t\t\treturn minus ? -n : n;\n\t\t\t} else {\n\t\t\t\tthrow new NumberFormatException();\n\t\t\t}\n\t\t\tb = readByte();\n\t\t}\n\t}\n\n\tpublic int nextInt() {\n\t\tlong nl = nextLong();\n\t\tif (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)\n\t\t\tthrow new NumberFormatException();\n\t\treturn (int) nl;\n\t}\n\n\tpublic double nextDouble() {\n\t\treturn Double.parseDouble(next());\n\t}\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn K-city, there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?\n\nConstraints\n\n2 ≤ n, m ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\n\nOutput\n\nPrint the number of blocks in K-city.\n\nSample Input 1\n\n3 4\n\nSample Output 1\n\n6\n\nThere are six blocks, as shown below:\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n1\n\nThere are one block, as shown below:", "sample_input": "3 4\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03635", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn K-city, there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?\n\nConstraints\n\n2 ≤ n, m ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\n\nOutput\n\nPrint the number of blocks in K-city.\n\nSample Input 1\n\n3 4\n\nSample Output 1\n\n6\n\nThere are six blocks, as shown below:\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n1\n\nThere are one block, as shown below:", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3852, "cpu_time_ms": 75, "memory_kb": 21204}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s875361903", "group_id": "codeNet:p03635", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint m = Integer.parseInt(sc.next());\n\t\tSystem.out.println((n-1)*(m-1));\n\t}\n}", "language": "Java", "metadata": {"date": 1565879178, "filename_ext": "java", "original_language": "Java7 (OpenJDK 1.7.0)", "problem_description_relpath": "problem_descriptions/p03635.html", "problem_id": "p03635", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03635/input.txt", "sample_output_relpath": "derived/input_output/data/p03635/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03635/Java/s875361903.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s875361903", "user_id": "u839537730"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint m = Integer.parseInt(sc.next());\n\t\tSystem.out.println((n-1)*(m-1));\n\t}\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn K-city, there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?\n\nConstraints\n\n2 ≤ n, m ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\n\nOutput\n\nPrint the number of blocks in K-city.\n\nSample Input 1\n\n3 4\n\nSample Output 1\n\n6\n\nThere are six blocks, as shown below:\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n1\n\nThere are one block, as shown below:", "sample_input": "3 4\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03635", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn K-city, there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?\n\nConstraints\n\n2 ≤ n, m ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\n\nOutput\n\nPrint the number of blocks in K-city.\n\nSample Input 1\n\n3 4\n\nSample Output 1\n\n6\n\nThere are six blocks, as shown below:\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n1\n\nThere are one block, as shown below:", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 245, "cpu_time_ms": 93, "memory_kb": 22740}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s232644078", "group_id": "codeNet:p03638", "input_text": "import java.util.*;\n\npublic class Main {\n\tpublic static void main (String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint h = sc.nextInt();\n\t\tint w = sc.nextInt();\n\t\tint n = sc.nextInt();\n\t\tint[] arr = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tarr[i] = sc.nextInt();\n\t\t}\n\t\tint[][] grid = new int[h][w];\n\t\tint nowH = 0;\n\t\tint nowW = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tfor (int j = 0; j < arr[i]; j++) {\n\t\t\t\tgrid[nowH][nowW] = i + 1;\n\t\t\t\tif (nowH % 2 == 0) {\n\t\t\t\t\tif (nowW == w - 1) {\n\t\t\t\t\t\tnowH++;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnowW++;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (nowW == 0) {\n\t\t\t\t\t\tnowH++;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnowW--;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tStringBuilder sb = new StringBuilder();\n\t\tfor (int i = 0; i < h; i++) {\n\t\t\tfor (int j = 0; j < w; j++) {\n\t\t\t\tif (j != 0) {\n\t\t\t\t\tsb.append(\" \");\n\t\t\t\t}\n\t\t\t\tsb.append(grid[i][j]);\n\t\t\t}\n\t\t\tsb.append(\"\\n\");\n\t\t}\n\t\tSystem.out.print(sb);\n\t}\n}\n", "language": "Java", "metadata": {"date": 1546794353, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03638.html", "problem_id": "p03638", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03638/input.txt", "sample_output_relpath": "derived/input_output/data/p03638/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03638/Java/s232644078.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s232644078", "user_id": "u575909439"}, "prompt_components": {"gold_output": "1 1\n2 3\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\tpublic static void main (String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint h = sc.nextInt();\n\t\tint w = sc.nextInt();\n\t\tint n = sc.nextInt();\n\t\tint[] arr = new int[n];\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tarr[i] = sc.nextInt();\n\t\t}\n\t\tint[][] grid = new int[h][w];\n\t\tint nowH = 0;\n\t\tint nowW = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tfor (int j = 0; j < arr[i]; j++) {\n\t\t\t\tgrid[nowH][nowW] = i + 1;\n\t\t\t\tif (nowH % 2 == 0) {\n\t\t\t\t\tif (nowW == w - 1) {\n\t\t\t\t\t\tnowH++;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnowW++;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (nowW == 0) {\n\t\t\t\t\t\tnowH++;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnowW--;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tStringBuilder sb = new StringBuilder();\n\t\tfor (int i = 0; i < h; i++) {\n\t\t\tfor (int j = 0; j < w; j++) {\n\t\t\t\tif (j != 0) {\n\t\t\t\t\tsb.append(\" \");\n\t\t\t\t}\n\t\t\t\tsb.append(grid[i][j]);\n\t\t\t}\n\t\t\tsb.append(\"\\n\");\n\t\t}\n\t\tSystem.out.print(sb);\n\t}\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns of squares.\nSnuke is painting these squares in colors 1, 2, ..., N.\nHere, the following conditions should be satisfied:\n\nFor each i (1 ≤ i ≤ N), there are exactly a_i squares painted in Color i. Here, a_1 + a_2 + ... + a_N = H W.\n\nFor each i (1 ≤ i ≤ N), the squares painted in Color i are 4-connected. That is, every square painted in Color i can be reached from every square painted in Color i by repeatedly traveling to a horizontally or vertically adjacent square painted in Color i.\n\nFind a way to paint the squares so that the conditions are satisfied.\nIt can be shown that a solution always exists.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\n1 ≤ N ≤ H W\n\na_i ≥ 1\n\na_1 + a_2 + ... + a_N = H W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint one way to paint the squares that satisfies the conditions.\nOutput in the following format:\n\nc_{1 1} ... c_{1 W}\n:\nc_{H 1} ... c_{H W}\n\nHere, c_{i j} is the color of the square at the i-th row from the top and j-th column from the left.\n\nSample Input 1\n\n2 2\n3\n2 1 1\n\nSample Output 1\n\n1 1\n2 3\n\nBelow is an example of an invalid solution:\n\n1 2\n3 1\n\nThis is because the squares painted in Color 1 are not 4-connected.\n\nSample Input 2\n\n3 5\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 4 4 4 3\n2 5 4 5 3\n2 5 5 5 3\n\nSample Input 3\n\n1 1\n1\n1\n\nSample Output 3\n\n1", "sample_input": "2 2\n3\n2 1 1\n"}, "reference_outputs": ["1 1\n2 3\n"], "source_document_id": "p03638", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns of squares.\nSnuke is painting these squares in colors 1, 2, ..., N.\nHere, the following conditions should be satisfied:\n\nFor each i (1 ≤ i ≤ N), there are exactly a_i squares painted in Color i. Here, a_1 + a_2 + ... + a_N = H W.\n\nFor each i (1 ≤ i ≤ N), the squares painted in Color i are 4-connected. That is, every square painted in Color i can be reached from every square painted in Color i by repeatedly traveling to a horizontally or vertically adjacent square painted in Color i.\n\nFind a way to paint the squares so that the conditions are satisfied.\nIt can be shown that a solution always exists.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\n1 ≤ N ≤ H W\n\na_i ≥ 1\n\na_1 + a_2 + ... + a_N = H W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint one way to paint the squares that satisfies the conditions.\nOutput in the following format:\n\nc_{1 1} ... c_{1 W}\n:\nc_{H 1} ... c_{H W}\n\nHere, c_{i j} is the color of the square at the i-th row from the top and j-th column from the left.\n\nSample Input 1\n\n2 2\n3\n2 1 1\n\nSample Output 1\n\n1 1\n2 3\n\nBelow is an example of an invalid solution:\n\n1 2\n3 1\n\nThis is because the squares painted in Color 1 are not 4-connected.\n\nSample Input 2\n\n3 5\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 4 4 4 3\n2 5 4 5 3\n2 5 5 5 3\n\nSample Input 3\n\n1 1\n1\n1\n\nSample Output 3\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 883, "cpu_time_ms": 202, "memory_kb": 33304}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s156964574", "group_id": "codeNet:p03638", "input_text": "import java.util.*;\n\npublic class Main {\n\tpublic static void main(String args[]) {\n\t\tScanner input = new Scanner(System.in);\n\t\tint H = input.nextInt();\n\t\tint W = input.nextInt();\n\t\tint N = input.nextInt();\n\t\tint[] arr = new int[N];\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tarr[i] = input.nextInt();\n\t\t}\n\n\t\tint[][] mat = new int[H][W];\n\t\tint dir = 0;\n\t\tint ind = 0;\n\t\tfor (int r = 0; r < mat.length; r++) {\n\t\t\tif (dir % 2 == 0) {\n\t\t\t\tfor (int c = 0; c < mat[0].length; c++) {\n\t\t\t\t\tmat[r][c] = ind + 1;\n\n\t\t\t\t\tif (arr[ind] > 0) {\n\t\t\t\t\t\tarr[ind]--;\n\t\t\t\t\t\tif (arr[ind] == 0) {\n\t\t\t\t\t\t\tind++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (int c = mat[0].length - 1; c >= 0; c--) {\n\t\t\t\t\tmat[r][c] = ind + 1;\n\t\t\t\t\t\n\t\t\t\t\tif (arr[ind] > 0) {\n\t\t\t\t\t\tarr[ind]--;\n\t\t\t\t\t\tif (arr[ind] == 0) {\n\t\t\t\t\t\t\tind++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\t\t\tdir++;\n\t\t}\n\t\tfor (int r = 0; r < mat.length; r++) {\n\t\t\tfor (int c = 0; c < mat[0].length; c++) {\n\t\t\t\tSystem.out.print(mat[r][c] + \" \");\n\t\t\t}\n\t\t\tSystem.out.println();\n\t\t}\n\t}\n}", "language": "Java", "metadata": {"date": 1502072708, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03638.html", "problem_id": "p03638", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03638/input.txt", "sample_output_relpath": "derived/input_output/data/p03638/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03638/Java/s156964574.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s156964574", "user_id": "u886886119"}, "prompt_components": {"gold_output": "1 1\n2 3\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\tpublic static void main(String args[]) {\n\t\tScanner input = new Scanner(System.in);\n\t\tint H = input.nextInt();\n\t\tint W = input.nextInt();\n\t\tint N = input.nextInt();\n\t\tint[] arr = new int[N];\n\t\tfor (int i = 0; i < N; i++) {\n\t\t\tarr[i] = input.nextInt();\n\t\t}\n\n\t\tint[][] mat = new int[H][W];\n\t\tint dir = 0;\n\t\tint ind = 0;\n\t\tfor (int r = 0; r < mat.length; r++) {\n\t\t\tif (dir % 2 == 0) {\n\t\t\t\tfor (int c = 0; c < mat[0].length; c++) {\n\t\t\t\t\tmat[r][c] = ind + 1;\n\n\t\t\t\t\tif (arr[ind] > 0) {\n\t\t\t\t\t\tarr[ind]--;\n\t\t\t\t\t\tif (arr[ind] == 0) {\n\t\t\t\t\t\t\tind++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (int c = mat[0].length - 1; c >= 0; c--) {\n\t\t\t\t\tmat[r][c] = ind + 1;\n\t\t\t\t\t\n\t\t\t\t\tif (arr[ind] > 0) {\n\t\t\t\t\t\tarr[ind]--;\n\t\t\t\t\t\tif (arr[ind] == 0) {\n\t\t\t\t\t\t\tind++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\t\t\tdir++;\n\t\t}\n\t\tfor (int r = 0; r < mat.length; r++) {\n\t\t\tfor (int c = 0; c < mat[0].length; c++) {\n\t\t\t\tSystem.out.print(mat[r][c] + \" \");\n\t\t\t}\n\t\t\tSystem.out.println();\n\t\t}\n\t}\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns of squares.\nSnuke is painting these squares in colors 1, 2, ..., N.\nHere, the following conditions should be satisfied:\n\nFor each i (1 ≤ i ≤ N), there are exactly a_i squares painted in Color i. Here, a_1 + a_2 + ... + a_N = H W.\n\nFor each i (1 ≤ i ≤ N), the squares painted in Color i are 4-connected. That is, every square painted in Color i can be reached from every square painted in Color i by repeatedly traveling to a horizontally or vertically adjacent square painted in Color i.\n\nFind a way to paint the squares so that the conditions are satisfied.\nIt can be shown that a solution always exists.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\n1 ≤ N ≤ H W\n\na_i ≥ 1\n\na_1 + a_2 + ... + a_N = H W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint one way to paint the squares that satisfies the conditions.\nOutput in the following format:\n\nc_{1 1} ... c_{1 W}\n:\nc_{H 1} ... c_{H W}\n\nHere, c_{i j} is the color of the square at the i-th row from the top and j-th column from the left.\n\nSample Input 1\n\n2 2\n3\n2 1 1\n\nSample Output 1\n\n1 1\n2 3\n\nBelow is an example of an invalid solution:\n\n1 2\n3 1\n\nThis is because the squares painted in Color 1 are not 4-connected.\n\nSample Input 2\n\n3 5\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 4 4 4 3\n2 5 4 5 3\n2 5 5 5 3\n\nSample Input 3\n\n1 1\n1\n1\n\nSample Output 3\n\n1", "sample_input": "2 2\n3\n2 1 1\n"}, "reference_outputs": ["1 1\n2 3\n"], "source_document_id": "p03638", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns of squares.\nSnuke is painting these squares in colors 1, 2, ..., N.\nHere, the following conditions should be satisfied:\n\nFor each i (1 ≤ i ≤ N), there are exactly a_i squares painted in Color i. Here, a_1 + a_2 + ... + a_N = H W.\n\nFor each i (1 ≤ i ≤ N), the squares painted in Color i are 4-connected. That is, every square painted in Color i can be reached from every square painted in Color i by repeatedly traveling to a horizontally or vertically adjacent square painted in Color i.\n\nFind a way to paint the squares so that the conditions are satisfied.\nIt can be shown that a solution always exists.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\n1 ≤ N ≤ H W\n\na_i ≥ 1\n\na_1 + a_2 + ... + a_N = H W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint one way to paint the squares that satisfies the conditions.\nOutput in the following format:\n\nc_{1 1} ... c_{1 W}\n:\nc_{H 1} ... c_{H W}\n\nHere, c_{i j} is the color of the square at the i-th row from the top and j-th column from the left.\n\nSample Input 1\n\n2 2\n3\n2 1 1\n\nSample Output 1\n\n1 1\n2 3\n\nBelow is an example of an invalid solution:\n\n1 2\n3 1\n\nThis is because the squares painted in Color 1 are not 4-connected.\n\nSample Input 2\n\n3 5\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 4 4 4 3\n2 5 4 5 3\n2 5 5 5 3\n\nSample Input 3\n\n1 1\n1\n1\n\nSample Output 3\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 984, "cpu_time_ms": 255, "memory_kb": 34512}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s076793327", "group_id": "codeNet:p03640", "input_text": "\nimport java.util.Scanner;\n\npublic class Main {\n\n static Scanner scanner;\n\n public static void main(String[] args) {\n scanner = new Scanner(System.in);\n\n int H=gi();\n int W=gi();\n int N=gi();\n\n int[] ans=new int[H*W];\n\n int ind=0;\n boolean f=true;\n for (int i=1; i<=N;i++) {\n \t int a=gi();\n \t for (int j=0; j count) {\n count = current;\n r = i;\n }\n }\n System.out.println(r);\n sc.close();\n }\n}\n", "language": "Java", "metadata": {"date": 1593436524, "filename_ext": "java", "original_language": "Java (OpenJDK 11.0.6)", "problem_description_relpath": "problem_descriptions/p03644.html", "problem_id": "p03644", "resource_group": "high_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/Java/s501268244.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s501268244", "user_id": "u797868666"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.Scanner;\n\nclass Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int count = 0;\n int r = 1;\n for (int i = 2; i <= n; i++) {\n int current = 0;\n if (i % 2 == 1) {\n continue;\n }\n int j = i;\n while (true) {\n j = j / 2;\n ++current;\n if (j == 0 || j % 2 == 1) {\n break;\n }\n }\n if (current > count) {\n count = current;\n r = i;\n }\n }\n System.out.println(r);\n sc.close();\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves numbers divisible by 2.\n\nYou are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.\n\nHere, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.\n\nFor example,\n\n6 can be divided by 2 once: 6 -> 3.\n\n8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.\n\n3 can be divided by 2 zero times.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n4\n\n4 can be divided by 2 twice, which is the most number of times among 1, 2, ..., 7.\n\nSample Input 2\n\n32\n\nSample Output 2\n\n32\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nSample Input 4\n\n100\n\nSample Output 4\n\n64", "sample_input": "7\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03644", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves numbers divisible by 2.\n\nYou are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.\n\nHere, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.\n\nFor example,\n\n6 can be divided by 2 once: 6 -> 3.\n\n8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.\n\n3 can be divided by 2 zero times.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n4\n\n4 can be divided by 2 twice, which is the most number of times among 1, 2, ..., 7.\n\nSample Input 2\n\n32\n\nSample Output 2\n\n32\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nSample Input 4\n\n100\n\nSample Output 4\n\n64", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 122, "memory_kb": 35832}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s664765181", "group_id": "codeNet:p03644", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int ans = 1;\n while(ans*2 <= n){\n ans *= 2;\n }\n System.out.println(ans);\n }\n}\n", "language": "Java", "metadata": {"date": 1588159906, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03644.html", "problem_id": "p03644", "resource_group": "high_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/Java/s664765181.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s664765181", "user_id": "u578775554"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int ans = 1;\n while(ans*2 <= n){\n ans *= 2;\n }\n System.out.println(ans);\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves numbers divisible by 2.\n\nYou are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.\n\nHere, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.\n\nFor example,\n\n6 can be divided by 2 once: 6 -> 3.\n\n8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.\n\n3 can be divided by 2 zero times.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n4\n\n4 can be divided by 2 twice, which is the most number of times among 1, 2, ..., 7.\n\nSample Input 2\n\n32\n\nSample Output 2\n\n32\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nSample Input 4\n\n100\n\nSample Output 4\n\n64", "sample_input": "7\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03644", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves numbers divisible by 2.\n\nYou are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.\n\nHere, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.\n\nFor example,\n\n6 can be divided by 2 once: 6 -> 3.\n\n8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.\n\n3 can be divided by 2 zero times.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n4\n\n4 can be divided by 2 twice, which is the most number of times among 1, 2, ..., 7.\n\nSample Input 2\n\n32\n\nSample Output 2\n\n32\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nSample Input 4\n\n100\n\nSample Output 4\n\n64", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 96, "memory_kb": 23764}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s933641158", "group_id": "codeNet:p03644", "input_text": "import java.util.Scanner;\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int[] count = new int[N];\n for(int i=1;i<=N;i++){\n int x = i;\n while(i != 0){\n if(x % 2 == 0){\n count[i-1]++;\n x = x / 2;\n }\n else{\n break;\n }\n }\n }\n int max = count[0];\n int soeji = 0;\n for(int i = 1;i< N;i++){\n if(count[i] > max){\n max = count[i];\n soeji = i;\n }\n }\n System.out.println(soeji+1);\n }\n}\n", "language": "Java", "metadata": {"date": 1524163924, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03644.html", "problem_id": "p03644", "resource_group": "high_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/Java/s933641158.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s933641158", "user_id": "u076522215"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int[] count = new int[N];\n for(int i=1;i<=N;i++){\n int x = i;\n while(i != 0){\n if(x % 2 == 0){\n count[i-1]++;\n x = x / 2;\n }\n else{\n break;\n }\n }\n }\n int max = count[0];\n int soeji = 0;\n for(int i = 1;i< N;i++){\n if(count[i] > max){\n max = count[i];\n soeji = i;\n }\n }\n System.out.println(soeji+1);\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves numbers divisible by 2.\n\nYou are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.\n\nHere, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.\n\nFor example,\n\n6 can be divided by 2 once: 6 -> 3.\n\n8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.\n\n3 can be divided by 2 zero times.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n4\n\n4 can be divided by 2 twice, which is the most number of times among 1, 2, ..., 7.\n\nSample Input 2\n\n32\n\nSample Output 2\n\n32\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nSample Input 4\n\n100\n\nSample Output 4\n\n64", "sample_input": "7\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03644", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves numbers divisible by 2.\n\nYou are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.\n\nHere, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.\n\nFor example,\n\n6 can be divided by 2 once: 6 -> 3.\n\n8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.\n\n3 can be divided by 2 zero times.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n4\n\n4 can be divided by 2 twice, which is the most number of times among 1, 2, ..., 7.\n\nSample Input 2\n\n32\n\nSample Output 2\n\n32\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nSample Input 4\n\n100\n\nSample Output 4\n\n64", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 729, "cpu_time_ms": 117, "memory_kb": 22100}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s065162161", "group_id": "codeNet:p03644", "input_text": "import java.io.*;\nimport java.util.*;\n\npublic class Main { // \"Main\" should be used for most online judges\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint result = 0;\n\t\tint tempNumb = 0;\n\t\tint count = 0;\n\t\tfor(int i = n; i > 0; i--){\n\t\t\ttempNumb = i;\n\t\t\twhile(i % 2 == 0) {\n\t\t\t\tcount++;\n\t\t\t\ti = i/2;\n\t\t\t\t//System.out.println(\"in loop\");\n\t\t\t}\n\t\t\t\n\t\t\tif(count > result) {\n\t\t\t\tresult = tempNumb;\n\t\t\t}\n\t\t\tcount = 0;\n\t\t}\n\t\tSystem.out.println(result);\n\n\t\tsc.close();\n\t}\n\t\n}", "language": "Java", "metadata": {"date": 1505828412, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03644.html", "problem_id": "p03644", "resource_group": "high_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/Java/s065162161.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s065162161", "user_id": "u816631826"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\n\npublic class Main { // \"Main\" should be used for most online judges\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint result = 0;\n\t\tint tempNumb = 0;\n\t\tint count = 0;\n\t\tfor(int i = n; i > 0; i--){\n\t\t\ttempNumb = i;\n\t\t\twhile(i % 2 == 0) {\n\t\t\t\tcount++;\n\t\t\t\ti = i/2;\n\t\t\t\t//System.out.println(\"in loop\");\n\t\t\t}\n\t\t\t\n\t\t\tif(count > result) {\n\t\t\t\tresult = tempNumb;\n\t\t\t}\n\t\t\tcount = 0;\n\t\t}\n\t\tSystem.out.println(result);\n\n\t\tsc.close();\n\t}\n\t\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": 530, "cpu_time_ms": 103, "memory_kb": 21972}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s061195808", "group_id": "codeNet:p03645", "input_text": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n\tfinal static long MOD = 1000000007L;\n\tpublic static String[] Ws = null;\n\tpublic static int wsIndx = 0;\n\tpublic static BufferedReader in = null;\n\tpublic static ArrayList list = new ArrayList<>();\n\tpublic static void main(String[] args) throws Exception {\n\n\n\t\tint N = nextInt();\n\t\tint M = nextInt();\n\n\t\tint[][] x = new int[M+1][2];\n\t\tArrayList from1 = new ArrayList<>();\n\t\tArrayList toN = new ArrayList<>();\n\t\tfor(int i=1;i=0){\n\t\t\t\tans=\"POSSIBLE\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n\n\n\n\tpublic static String[] toStringArray(String s) {\n\t\tString[] tmp = new String[s.length()];\n\t\tchar[] c = s.toCharArray();\n\t\tfor (int i = 0; i < tmp.length; i++) {\n\t\t\ttmp[i] = String.valueOf(c[i]);\n\t\t}\n\t\treturn tmp;\n\t}\n\n\tpublic static String concatStringArray(String[] s){\n\t\tStringBuffer sb = new StringBuffer();\n\t\tfor(String x:s){\n\t\t\tsb.append(x);\n\t\t}\n\t\treturn sb.toString();\n\t}\n\n\tpublic static void check() throws Exception{\n\t\tif(in == null){\n\t\t\tin = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\t\tif(Ws==null || Ws.length<=wsIndx){\n\t\t\tWs = in.readLine().split(\" \");\n\t\t\twsIndx=0;\n\t\t}\n\t}\n\tpublic static int nextInt()throws Exception{\n\t\tcheck();\n\t\treturn Integer.parseInt(Ws[wsIndx++]);\n\t}\n\n\tpublic static long nextLong()throws Exception{\n\t\tcheck();\n\t\treturn Long.parseLong(Ws[wsIndx++]);\n\t}\n\n\tpublic static String nextString()throws Exception{\n\t\tcheck();\n\t\treturn Ws[wsIndx++];\n\t}\n\n\tpublic static int[] nextInts()throws Exception{\n\t\tcheck();\n\t\tint[] tmp = new int[Ws.length];\n\t\tfor(int i=0;i list = new ArrayList<>();\n\tpublic static void main(String[] args) throws Exception {\n\n\n\t\tint N = nextInt();\n\t\tint M = nextInt();\n\n\t\tint[][] x = new int[M+1][2];\n\t\tArrayList from1 = new ArrayList<>();\n\t\tArrayList toN = new ArrayList<>();\n\t\tfor(int i=1;i=0){\n\t\t\t\tans=\"POSSIBLE\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n\n\n\n\tpublic static String[] toStringArray(String s) {\n\t\tString[] tmp = new String[s.length()];\n\t\tchar[] c = s.toCharArray();\n\t\tfor (int i = 0; i < tmp.length; i++) {\n\t\t\ttmp[i] = String.valueOf(c[i]);\n\t\t}\n\t\treturn tmp;\n\t}\n\n\tpublic static String concatStringArray(String[] s){\n\t\tStringBuffer sb = new StringBuffer();\n\t\tfor(String x:s){\n\t\t\tsb.append(x);\n\t\t}\n\t\treturn sb.toString();\n\t}\n\n\tpublic static void check() throws Exception{\n\t\tif(in == null){\n\t\t\tin = new BufferedReader(new InputStreamReader(System.in));\n\t\t}\n\t\tif(Ws==null || Ws.length<=wsIndx){\n\t\t\tWs = in.readLine().split(\" \");\n\t\t\twsIndx=0;\n\t\t}\n\t}\n\tpublic static int nextInt()throws Exception{\n\t\tcheck();\n\t\treturn Integer.parseInt(Ws[wsIndx++]);\n\t}\n\n\tpublic static long nextLong()throws Exception{\n\t\tcheck();\n\t\treturn Long.parseLong(Ws[wsIndx++]);\n\t}\n\n\tpublic static String nextString()throws Exception{\n\t\tcheck();\n\t\treturn Ws[wsIndx++];\n\t}\n\n\tpublic static int[] nextInts()throws Exception{\n\t\tcheck();\n\t\tint[] tmp = new int[Ws.length];\n\t\tfor(int i=0;i 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": 2247, "cpu_time_ms": 388, "memory_kb": 69884}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s249998379", "group_id": "codeNet:p03652", "input_text": "import java.util.*;\n\npublic class Main{\n public static void main(String [] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int M = sc.nextInt();\n int [][] A = new int [N][M];\n for(int i = 0; i < N; i++) {\n for(int j = 0; j < M; j++) {\n A[i][j] = sc.nextInt() - 1;\n }\n }\n System.out.println(calcAns(N,M,A));\n }\n\n public static int calcAns(int N,int M,int [][] A) {\n int [] c = new int [M];\n int [] x = new int [M];\n for(int i = 0; i < N; i++) {\n c[A[i][0]] += 1;\n }\n int ret = M;\n for(int cnt = 0; cnt < N - 1; cnt++) {\n // most appeared color\n int p = 0;\n for(int i = 1; i < M; i++) {\n if(c[i] > c[p]) {\n p = i;\n }\n }\n // update ret\n if(c[p] < ret) ret = c[p];\n // delete color p\n c[p] = -1;\n for(int i = 0; i < N; i++) {\n c[A[i][x[i]]] -= 1;\n while(c[A[i][x[i]]] < 0) {\n x[i] = x[i] + 1;\n }\n c[A[i][x[i]]] += 1;\n }\n }\n return ret;\n }\n}\n", "language": "Java", "metadata": {"date": 1501018975, "filename_ext": "java", "original_language": "Java7 (OpenJDK 1.7.0)", "problem_description_relpath": "problem_descriptions/p03652.html", "problem_id": "p03652", "resource_group": "high_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/Java/s249998379.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s249998379", "user_id": "u934019430"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main{\n public static void main(String [] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int M = sc.nextInt();\n int [][] A = new int [N][M];\n for(int i = 0; i < N; i++) {\n for(int j = 0; j < M; j++) {\n A[i][j] = sc.nextInt() - 1;\n }\n }\n System.out.println(calcAns(N,M,A));\n }\n\n public static int calcAns(int N,int M,int [][] A) {\n int [] c = new int [M];\n int [] x = new int [M];\n for(int i = 0; i < N; i++) {\n c[A[i][0]] += 1;\n }\n int ret = M;\n for(int cnt = 0; cnt < N - 1; cnt++) {\n // most appeared color\n int p = 0;\n for(int i = 1; i < M; i++) {\n if(c[i] > c[p]) {\n p = i;\n }\n }\n // update ret\n if(c[p] < ret) ret = c[p];\n // delete color p\n c[p] = -1;\n for(int i = 0; i < N; i++) {\n c[A[i][x[i]]] -= 1;\n while(c[A[i][x[i]]] < 0) {\n x[i] = x[i] + 1;\n }\n c[A[i][x[i]]] += 1;\n }\n }\n return ret;\n }\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": 1262, "cpu_time_ms": 411, "memory_kb": 50144}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s700578246", "group_id": "codeNet:p03657", "input_text": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] values = new int[n];\n int sum = 0;\n for (int i = 0; i < n; i++) {\n values[i] = sc.nextInt();\n sum += values[i];\n }\n\n int minDiff = Integer.MAX_VALUE;\n int firstPileSum = 0;\n for (int i = 0; i < values.length - 1; i++) {\n firstPileSum += values[i];\n int remainSum = sum - firstPileSum;\n int candidate = Math.abs(firstPileSum - remainSum);\n if (candidate < minDiff) {\n minDiff = candidate;\n }\n }\n\n System.out.println(minDiff);\n }\n}\n", "language": "Java", "metadata": {"date": 1501787003, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03657.html", "problem_id": "p03657", "resource_group": "high_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/Java/s700578246.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s700578246", "user_id": "u112523623"}, "prompt_components": {"gold_output": "Possible\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] values = new int[n];\n int sum = 0;\n for (int i = 0; i < n; i++) {\n values[i] = sc.nextInt();\n sum += values[i];\n }\n\n int minDiff = Integer.MAX_VALUE;\n int firstPileSum = 0;\n for (int i = 0; i < values.length - 1; i++) {\n firstPileSum += values[i];\n int remainSum = sum - firstPileSum;\n int candidate = Math.abs(firstPileSum - remainSum);\n if (candidate < minDiff) {\n minDiff = candidate;\n }\n }\n\n System.out.println(minDiff);\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": 762, "cpu_time_ms": 100, "memory_kb": 21716}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s104528643", "group_id": "codeNet:p03661", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.StringTokenizer;\n\npublic class Main{ // \n\n\tpublic static void main(String args[]) {\n\t\tConsoleScanner cin = new ConsoleScanner();\n\t\tPrintWriter cout = new PrintWriter(System.out);\n\t\tsolve(cin, cout);\n\t\tcout.flush();\n\t}\n\n\tstatic long now() {\n\t\treturn System.currentTimeMillis();\n\t}\n\n\tstatic void trace(Object... objects) {\n\t\tassert null != System.out.format(\"trace:%s\\n\", Arrays.deepToString(objects));\n\t}\n\n\tprivate static void solve(ConsoleScanner cin, PrintWriter cout) {\n\t\t// assert solve(1) == 1;\n\n\t\tint n = cin.nextInt();\n\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < a.length; i++)\n\t\t\ta[i] = cin.nextInt();\n\n\t\tlong start = now();\n\n\t\tlong ans = solve(n, a);\n\t\tcout.println(ans);\n\n\t\ttrace(\"elapsed\", now() - start);\n\t}\n\n\tprivate static long solve(int n, int[] a) {\n\t\tlong total = Arrays.stream(a).mapToLong(x -> x).sum();\n\t\tlong ans = Long.MAX_VALUE;\n\t\tlong s = 0;\n\t\tfor (int i = 0; i < n - 1; i++) {\n\t\t\ts += a[i];\n\t\t\tans = Math.min(ans, Math.abs(total - 2 * s));\n\t\t}\n\t\treturn ans;\n\t}\n\n\tstatic class ConsoleScanner {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tStringTokenizer st = new StringTokenizer(\"\");\n\n\t\tString next() {\n\t\t\ttry {\n\t\t\t\twhile (!st.hasMoreElements())\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\treturn st.nextToken();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new AssertionError(e);\n\t\t\t}\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1503204844, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03661.html", "problem_id": "p03661", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03661/input.txt", "sample_output_relpath": "derived/input_output/data/p03661/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03661/Java/s104528643.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s104528643", "user_id": "u120233192"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.StringTokenizer;\n\npublic class Main{ // \n\n\tpublic static void main(String args[]) {\n\t\tConsoleScanner cin = new ConsoleScanner();\n\t\tPrintWriter cout = new PrintWriter(System.out);\n\t\tsolve(cin, cout);\n\t\tcout.flush();\n\t}\n\n\tstatic long now() {\n\t\treturn System.currentTimeMillis();\n\t}\n\n\tstatic void trace(Object... objects) {\n\t\tassert null != System.out.format(\"trace:%s\\n\", Arrays.deepToString(objects));\n\t}\n\n\tprivate static void solve(ConsoleScanner cin, PrintWriter cout) {\n\t\t// assert solve(1) == 1;\n\n\t\tint n = cin.nextInt();\n\n\t\tint[] a = new int[n];\n\t\tfor (int i = 0; i < a.length; i++)\n\t\t\ta[i] = cin.nextInt();\n\n\t\tlong start = now();\n\n\t\tlong ans = solve(n, a);\n\t\tcout.println(ans);\n\n\t\ttrace(\"elapsed\", now() - start);\n\t}\n\n\tprivate static long solve(int n, int[] a) {\n\t\tlong total = Arrays.stream(a).mapToLong(x -> x).sum();\n\t\tlong ans = Long.MAX_VALUE;\n\t\tlong s = 0;\n\t\tfor (int i = 0; i < n - 1; i++) {\n\t\t\ts += a[i];\n\t\t\tans = Math.min(ans, Math.abs(total - 2 * s));\n\t\t}\n\t\treturn ans;\n\t}\n\n\tstatic class ConsoleScanner {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tStringTokenizer st = new StringTokenizer(\"\");\n\n\t\tString next() {\n\t\t\ttry {\n\t\t\t\twhile (!st.hasMoreElements())\n\t\t\t\t\tst = new StringTokenizer(br.readLine());\n\t\t\t\treturn st.nextToken();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new AssertionError(e);\n\t\t\t}\n\t\t}\n\n\t\tint nextInt() {\n\t\t\treturn Integer.parseInt(next());\n\t\t}\n\n\t\tlong nextLong() {\n\t\t\treturn Long.parseLong(next());\n\t\t}\n\t}\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": "p03661", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.\n\nThey will share these cards.\nFirst, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards.\nHere, both Snuke and Raccoon have to take at least one card.\n\nLet the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively.\nThey would like to minimize |x-y|.\nFind the minimum possible value of |x-y|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n-10^{9} \\leq a_i \\leq 10^{9}\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6\n1 2 3 4 5 6\n\nSample Output 1\n\n1\n\nIf Snuke takes four cards from the top, and Raccoon takes the remaining two cards, x=10, y=11, and thus |x-y|=1. This is the minimum possible value.\n\nSample Input 2\n\n2\n10 -10\n\nSample Output 2\n\n20\n\nSnuke can only take one card from the top, and Raccoon can only take the remaining one card. In this case, x=10, y=-10, and thus |x-y|=20.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1637, "cpu_time_ms": 323, "memory_kb": 46436}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s808416180", "group_id": "codeNet:p03671", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint a = sc.nextInt();\n\t\tint b = sc.nextInt();\n\t\tint c = sc.nextInt();\n\n\t\tint A = a+b;\n\t\tint B = b+c;\n\t\tint C = c+a;\n\n\t\tint [] list = new int [] {A, B, C};\n\t\tint min =list[0];\n\n\t\tfor (int i = 1; i < list.length; i++) {\n\t\t\tint M = list[i];\n\t\t\tif (M <= min) {\n\t\t\t\tmin = M;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(min);\n\t}\n}", "language": "Java", "metadata": {"date": 1567100030, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03671.html", "problem_id": "p03671", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03671/input.txt", "sample_output_relpath": "derived/input_output/data/p03671/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03671/Java/s808416180.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s808416180", "user_id": "u202101624"}, "prompt_components": {"gold_output": "1300\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint a = sc.nextInt();\n\t\tint b = sc.nextInt();\n\t\tint c = sc.nextInt();\n\n\t\tint A = a+b;\n\t\tint B = b+c;\n\t\tint C = c+a;\n\n\t\tint [] list = new int [] {A, B, C};\n\t\tint min =list[0];\n\n\t\tfor (int i = 1; i < list.length; i++) {\n\t\t\tint M = list[i];\n\t\t\tif (M <= min) {\n\t\t\t\tmin = M;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(min);\n\t}\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke is buying a bicycle.\nThe bicycle of his choice does not come with a bell, so he has to buy one separately.\n\nHe has very high awareness of safety, and decides to buy two bells, one for each hand.\n\nThe store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively.\nFind the minimum total price of two different bells.\n\nConstraints\n\n1 \\leq a,b,c \\leq 10000\n\na, b and c are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the minimum total price of two different bells.\n\nSample Input 1\n\n700 600 780\n\nSample Output 1\n\n1300\n\nBuying a 700-yen bell and a 600-yen bell costs 1300 yen.\n\nBuying a 700-yen bell and a 780-yen bell costs 1480 yen.\n\nBuying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\nSample Input 2\n\n10000 10000 10000\n\nSample Output 2\n\n20000\n\nBuying any two bells costs 20000 yen.", "sample_input": "700 600 780\n"}, "reference_outputs": ["1300\n"], "source_document_id": "p03671", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke is buying a bicycle.\nThe bicycle of his choice does not come with a bell, so he has to buy one separately.\n\nHe has very high awareness of safety, and decides to buy two bells, one for each hand.\n\nThe store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively.\nFind the minimum total price of two different bells.\n\nConstraints\n\n1 \\leq a,b,c \\leq 10000\n\na, b and c are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the minimum total price of two different bells.\n\nSample Input 1\n\n700 600 780\n\nSample Output 1\n\n1300\n\nBuying a 700-yen bell and a 600-yen bell costs 1300 yen.\n\nBuying a 700-yen bell and a 780-yen bell costs 1480 yen.\n\nBuying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\nSample Input 2\n\n10000 10000 10000\n\nSample Output 2\n\n20000\n\nBuying any two bells costs 20000 yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 442, "cpu_time_ms": 93, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s003231630", "group_id": "codeNet:p03671", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner s = new Scanner(System.in);\n\t\tint a = Integer.parseInt(s.next());\n\t\tint b = Integer.parseInt(s.next());\n\t\tint c = Integer.parseInt(s.next());\n\t\ts.close();\n\n\t\tint min = Math.min(Math.min(a+b, b+c), a+c);\n\n\t\tSystem.out.println(min);\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1501783259, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03671.html", "problem_id": "p03671", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03671/input.txt", "sample_output_relpath": "derived/input_output/data/p03671/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03671/Java/s003231630.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s003231630", "user_id": "u613022324"}, "prompt_components": {"gold_output": "1300\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner s = new Scanner(System.in);\n\t\tint a = Integer.parseInt(s.next());\n\t\tint b = Integer.parseInt(s.next());\n\t\tint c = Integer.parseInt(s.next());\n\t\ts.close();\n\n\t\tint min = Math.min(Math.min(a+b, b+c), a+c);\n\n\t\tSystem.out.println(min);\n\t}\n\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke is buying a bicycle.\nThe bicycle of his choice does not come with a bell, so he has to buy one separately.\n\nHe has very high awareness of safety, and decides to buy two bells, one for each hand.\n\nThe store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively.\nFind the minimum total price of two different bells.\n\nConstraints\n\n1 \\leq a,b,c \\leq 10000\n\na, b and c are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the minimum total price of two different bells.\n\nSample Input 1\n\n700 600 780\n\nSample Output 1\n\n1300\n\nBuying a 700-yen bell and a 600-yen bell costs 1300 yen.\n\nBuying a 700-yen bell and a 780-yen bell costs 1480 yen.\n\nBuying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\nSample Input 2\n\n10000 10000 10000\n\nSample Output 2\n\n20000\n\nBuying any two bells costs 20000 yen.", "sample_input": "700 600 780\n"}, "reference_outputs": ["1300\n"], "source_document_id": "p03671", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke is buying a bicycle.\nThe bicycle of his choice does not come with a bell, so he has to buy one separately.\n\nHe has very high awareness of safety, and decides to buy two bells, one for each hand.\n\nThe store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively.\nFind the minimum total price of two different bells.\n\nConstraints\n\n1 \\leq a,b,c \\leq 10000\n\na, b and c are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the minimum total price of two different bells.\n\nSample Input 1\n\n700 600 780\n\nSample Output 1\n\n1300\n\nBuying a 700-yen bell and a 600-yen bell costs 1300 yen.\n\nBuying a 700-yen bell and a 780-yen bell costs 1480 yen.\n\nBuying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\nSample Input 2\n\n10000 10000 10000\n\nSample Output 2\n\n20000\n\nBuying any two bells costs 20000 yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 338, "cpu_time_ms": 90, "memory_kb": 23124}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s052568565", "group_id": "codeNet:p03671", "input_text": "import java.util.*;\n\npublic class Main{\n public static void main(String args[] ) throws Exception {\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n int c = sc.nextInt();\n int ab = a + b;\n int bc = b + c;\n int ca = c + a;\n int min = Math.min(ab, bc);\n System.out.println(Math.min(min, ca));\n }\n}\n", "language": "Java", "metadata": {"date": 1498957404, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03671.html", "problem_id": "p03671", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03671/input.txt", "sample_output_relpath": "derived/input_output/data/p03671/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03671/Java/s052568565.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s052568565", "user_id": "u038942263"}, "prompt_components": {"gold_output": "1300\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main{\n public static void main(String args[] ) throws Exception {\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n int c = sc.nextInt();\n int ab = a + b;\n int bc = b + c;\n int ca = c + a;\n int min = Math.min(ab, bc);\n System.out.println(Math.min(min, ca));\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke is buying a bicycle.\nThe bicycle of his choice does not come with a bell, so he has to buy one separately.\n\nHe has very high awareness of safety, and decides to buy two bells, one for each hand.\n\nThe store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively.\nFind the minimum total price of two different bells.\n\nConstraints\n\n1 \\leq a,b,c \\leq 10000\n\na, b and c are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the minimum total price of two different bells.\n\nSample Input 1\n\n700 600 780\n\nSample Output 1\n\n1300\n\nBuying a 700-yen bell and a 600-yen bell costs 1300 yen.\n\nBuying a 700-yen bell and a 780-yen bell costs 1480 yen.\n\nBuying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\nSample Input 2\n\n10000 10000 10000\n\nSample Output 2\n\n20000\n\nBuying any two bells costs 20000 yen.", "sample_input": "700 600 780\n"}, "reference_outputs": ["1300\n"], "source_document_id": "p03671", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke is buying a bicycle.\nThe bicycle of his choice does not come with a bell, so he has to buy one separately.\n\nHe has very high awareness of safety, and decides to buy two bells, one for each hand.\n\nThe store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively.\nFind the minimum total price of two different bells.\n\nConstraints\n\n1 \\leq a,b,c \\leq 10000\n\na, b and c are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the minimum total price of two different bells.\n\nSample Input 1\n\n700 600 780\n\nSample Output 1\n\n1300\n\nBuying a 700-yen bell and a 600-yen bell costs 1300 yen.\n\nBuying a 700-yen bell and a 780-yen bell costs 1480 yen.\n\nBuying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\nSample Input 2\n\n10000 10000 10000\n\nSample Output 2\n\n20000\n\nBuying any two bells costs 20000 yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 401, "cpu_time_ms": 114, "memory_kb": 23636}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s335017353", "group_id": "codeNet:p03672", "input_text": "import java.io.*;\nimport java.util.*;\nclass Main{\n\tstatic final long MOD = 1_000_000_007; // 10^9+7\n static final int MAX = 2_147_483_646; // intMax \n static final int INF = 1_000_000_000; // 10^9 \n public static void main(String[] args) throws Exception {\n\t\thayami saori = new hayami();\n\t\tString[] s = saori.nextHayami().split(\"\");\n\t\tboolean flg = true;\n\t\tint ans = 0;\n\t\ta:for(int i = 1;i < s.length;i++){\n\t\t\tfor(int j = 0;j < (s.length-i)/2;j++){\n\t\t\t\tif(!s[j].equals(s[(s.length-i)/2+j])){\n\t\t\t\t\tflg = false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(flg && (s.length - i) % 2 == 0){\n\t\t\t\tans = s.length-i;\n\t\t\t\tbreak a;\n\t\t\t} else {\n\t\t\t\tflg = true;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t\tsaori.close();\n }\n}\n\nclass hayami implements Closeable {\n\tprivate final InputStream in = System.in;\n\tprivate final byte[] hayami = new byte[1024];\n\tprivate int Hayami = 0;\n\tprivate int saori = 0;\n\tprivate boolean HayamiSaori() {\n\t\tif (Hayami < saori) {\n\t\t\treturn true;\n\t\t}else{\n\t\t\tHayami = 0;\n\t\t\ttry {\n\t\t\t\tsaori = in.read(hayami);\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (saori <= 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\tprivate int SaoriHayami() { \n\t\tif (HayamiSaori()) {\n return hayami[Hayami++];\n }else{\n return -1;\n }\n\t}\n\tprivate static boolean hayami_saori(int hayami) { \n\t\treturn 33 <= hayami && hayami <= 126;\n\t}\n\tpublic boolean hayamisaori() { \n\t\twhile(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();\n\t}\n\tpublic String nextHayami() {\n\t\tif (!hayamisaori()) throw new NoSuchElementException();\n\t\tStringBuilder hayamin = new StringBuilder();\n\t\tint saori = SaoriHayami();\n\t\twhile(hayami_saori(saori)) {\n\t\t\thayamin.appendCodePoint(saori);\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t\treturn hayamin.toString();\n\t}\n\tpublic long saorihayami() {//nextLong\n\t\tif (!hayamisaori()) throw new NoSuchElementException();\n\t\tlong hayami = 0;\n\t\tboolean misao = false;\n\t\tint saori = SaoriHayami();\n\t\tif (saori == '-') {\n\t\t\tmisao = true;\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t\tif (saori < '0' || '9' < saori) {\n\t\t\tthrow new NumberFormatException();\n\t\t}\n\t\twhile(true){\n\t\t\tif ('0' <= saori && saori <= '9') {\n\t\t\t\thayami *= 10;\n\t\t\t\thayami += saori - '0';\n\t\t\t}else if(saori == -1 || !hayami_saori(saori)){\n\t\t\t\treturn misao ? -hayami : hayami;\n\t\t\t}else{\n\t\t\t\tthrow new NumberFormatException();\n\t\t\t}\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t}\n\tpublic int saori_hayami() {//nextInt\n\t\tlong hayami = saorihayami();\n\t\tif (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();\n\t\treturn (int) hayami;\n\t}\n\tpublic double Hayamin() { //nextDouble\n\t\treturn Double.parseDouble(nextHayami());\n\t}\n\tpublic void close() {\n\t\ttry {\n\t\t\tin.close();\n\t\t} catch (IOException e) {\n\t\t}\n }\n \n}", "language": "Java", "metadata": {"date": 1587059048, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03672.html", "problem_id": "p03672", "resource_group": "high_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/Java/s335017353.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s335017353", "user_id": "u676749446"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\nclass Main{\n\tstatic final long MOD = 1_000_000_007; // 10^9+7\n static final int MAX = 2_147_483_646; // intMax \n static final int INF = 1_000_000_000; // 10^9 \n public static void main(String[] args) throws Exception {\n\t\thayami saori = new hayami();\n\t\tString[] s = saori.nextHayami().split(\"\");\n\t\tboolean flg = true;\n\t\tint ans = 0;\n\t\ta:for(int i = 1;i < s.length;i++){\n\t\t\tfor(int j = 0;j < (s.length-i)/2;j++){\n\t\t\t\tif(!s[j].equals(s[(s.length-i)/2+j])){\n\t\t\t\t\tflg = false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(flg && (s.length - i) % 2 == 0){\n\t\t\t\tans = s.length-i;\n\t\t\t\tbreak a;\n\t\t\t} else {\n\t\t\t\tflg = true;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t\tsaori.close();\n }\n}\n\nclass hayami implements Closeable {\n\tprivate final InputStream in = System.in;\n\tprivate final byte[] hayami = new byte[1024];\n\tprivate int Hayami = 0;\n\tprivate int saori = 0;\n\tprivate boolean HayamiSaori() {\n\t\tif (Hayami < saori) {\n\t\t\treturn true;\n\t\t}else{\n\t\t\tHayami = 0;\n\t\t\ttry {\n\t\t\t\tsaori = in.read(hayami);\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (saori <= 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\tprivate int SaoriHayami() { \n\t\tif (HayamiSaori()) {\n return hayami[Hayami++];\n }else{\n return -1;\n }\n\t}\n\tprivate static boolean hayami_saori(int hayami) { \n\t\treturn 33 <= hayami && hayami <= 126;\n\t}\n\tpublic boolean hayamisaori() { \n\t\twhile(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();\n\t}\n\tpublic String nextHayami() {\n\t\tif (!hayamisaori()) throw new NoSuchElementException();\n\t\tStringBuilder hayamin = new StringBuilder();\n\t\tint saori = SaoriHayami();\n\t\twhile(hayami_saori(saori)) {\n\t\t\thayamin.appendCodePoint(saori);\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t\treturn hayamin.toString();\n\t}\n\tpublic long saorihayami() {//nextLong\n\t\tif (!hayamisaori()) throw new NoSuchElementException();\n\t\tlong hayami = 0;\n\t\tboolean misao = false;\n\t\tint saori = SaoriHayami();\n\t\tif (saori == '-') {\n\t\t\tmisao = true;\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t\tif (saori < '0' || '9' < saori) {\n\t\t\tthrow new NumberFormatException();\n\t\t}\n\t\twhile(true){\n\t\t\tif ('0' <= saori && saori <= '9') {\n\t\t\t\thayami *= 10;\n\t\t\t\thayami += saori - '0';\n\t\t\t}else if(saori == -1 || !hayami_saori(saori)){\n\t\t\t\treturn misao ? -hayami : hayami;\n\t\t\t}else{\n\t\t\t\tthrow new NumberFormatException();\n\t\t\t}\n\t\t\tsaori = SaoriHayami();\n\t\t}\n\t}\n\tpublic int saori_hayami() {//nextInt\n\t\tlong hayami = saorihayami();\n\t\tif (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();\n\t\treturn (int) hayami;\n\t}\n\tpublic double Hayamin() { //nextDouble\n\t\treturn Double.parseDouble(nextHayami());\n\t}\n\tpublic void close() {\n\t\ttry {\n\t\t\tin.close();\n\t\t} catch (IOException e) {\n\t\t}\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": 2745, "cpu_time_ms": 83, "memory_kb": 21332}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s527183148", "group_id": "codeNet:p03675", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Collection;\nimport java.io.IOException;\nimport java.util.Deque;\nimport java.io.InputStreamReader;\nimport java.util.StringTokenizer;\nimport java.io.BufferedReader;\nimport java.util.ArrayDeque;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author anand.oza\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n CPushpush solver = new CPushpush();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class CPushpush {\n public void solve(int testNumber, InputReader in, PrintWriter out) {\n int n = in.nextInt();\n\n Deque deque = new ArrayDeque<>();\n\n for (int i = 0; i < n; i++) {\n int a = in.nextInt();\n if (i % 2 == 0) {\n deque.addLast(a);\n } else {\n deque.addFirst(a);\n }\n }\n\n StringBuilder sb = new StringBuilder();\n if (n % 2 == 1) {\n while (!deque.isEmpty()) {\n sb.append(deque.pollLast() + \" \");\n }\n } else {\n while (!deque.isEmpty()) {\n sb.append(deque.pollFirst() + \" \");\n }\n }\n sb.deleteCharAt(sb.length() - 1);\n\n out.println(sb);\n }\n\n }\n\n static class InputReader {\n public BufferedReader reader;\n public StringTokenizer tokenizer;\n\n public InputReader(InputStream stream) {\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\n tokenizer = null;\n }\n\n public String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1559827837, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03675.html", "problem_id": "p03675", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03675/input.txt", "sample_output_relpath": "derived/input_output/data/p03675/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03675/Java/s527183148.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s527183148", "user_id": "u670376790"}, "prompt_components": {"gold_output": "4 2 1 3\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Collection;\nimport java.io.IOException;\nimport java.util.Deque;\nimport java.io.InputStreamReader;\nimport java.util.StringTokenizer;\nimport java.io.BufferedReader;\nimport java.util.ArrayDeque;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author anand.oza\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n CPushpush solver = new CPushpush();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class CPushpush {\n public void solve(int testNumber, InputReader in, PrintWriter out) {\n int n = in.nextInt();\n\n Deque deque = new ArrayDeque<>();\n\n for (int i = 0; i < n; i++) {\n int a = in.nextInt();\n if (i % 2 == 0) {\n deque.addLast(a);\n } else {\n deque.addFirst(a);\n }\n }\n\n StringBuilder sb = new StringBuilder();\n if (n % 2 == 1) {\n while (!deque.isEmpty()) {\n sb.append(deque.pollLast() + \" \");\n }\n } else {\n while (!deque.isEmpty()) {\n sb.append(deque.pollFirst() + \" \");\n }\n }\n sb.deleteCharAt(sb.length() - 1);\n\n out.println(sb);\n }\n\n }\n\n static class InputReader {\n public BufferedReader reader;\n public StringTokenizer tokenizer;\n\n public InputReader(InputStream stream) {\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\n tokenizer = null;\n }\n\n public String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n }\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length n, a_1, ..., a_n.\nLet us consider performing the following n operations on an empty sequence b.\n\nThe i-th operation is as follows:\n\nAppend a_i to the end of b.\n\nReverse the order of the elements in b.\n\nFind the sequence b obtained after these n operations.\n\nConstraints\n\n1 \\leq n \\leq 2\\times 10^5\n\n0 \\leq a_i \\leq 10^9\n\nn and a_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint n integers in a line with spaces in between.\nThe i-th integer should be b_i.\n\nSample Input 1\n\n4\n1 2 3 4\n\nSample Output 1\n\n4 2 1 3\n\nAfter step 1 of the first operation, b becomes: 1.\n\nAfter step 2 of the first operation, b becomes: 1.\n\nAfter step 1 of the second operation, b becomes: 1, 2.\n\nAfter step 2 of the second operation, b becomes: 2, 1.\n\nAfter step 1 of the third operation, b becomes: 2, 1, 3.\n\nAfter step 2 of the third operation, b becomes: 3, 1, 2.\n\nAfter step 1 of the fourth operation, b becomes: 3, 1, 2, 4.\n\nAfter step 2 of the fourth operation, b becomes: 4, 2, 1, 3.\n\nThus, the answer is 4 2 1 3.\n\nSample Input 2\n\n3\n1 2 3\n\nSample Output 2\n\n3 1 2\n\nAs shown above in Sample Output 1, b becomes 3, 1, 2 after step 2 of the third operation. Thus, the answer is 3 1 2.\n\nSample Input 3\n\n1\n1000000000\n\nSample Output 3\n\n1000000000\n\nSample Input 4\n\n6\n0 6 7 6 7 0\n\nSample Output 4\n\n0 6 6 0 7 7", "sample_input": "4\n1 2 3 4\n"}, "reference_outputs": ["4 2 1 3\n"], "source_document_id": "p03675", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length n, a_1, ..., a_n.\nLet us consider performing the following n operations on an empty sequence b.\n\nThe i-th operation is as follows:\n\nAppend a_i to the end of b.\n\nReverse the order of the elements in b.\n\nFind the sequence b obtained after these n operations.\n\nConstraints\n\n1 \\leq n \\leq 2\\times 10^5\n\n0 \\leq a_i \\leq 10^9\n\nn and a_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint n integers in a line with spaces in between.\nThe i-th integer should be b_i.\n\nSample Input 1\n\n4\n1 2 3 4\n\nSample Output 1\n\n4 2 1 3\n\nAfter step 1 of the first operation, b becomes: 1.\n\nAfter step 2 of the first operation, b becomes: 1.\n\nAfter step 1 of the second operation, b becomes: 1, 2.\n\nAfter step 2 of the second operation, b becomes: 2, 1.\n\nAfter step 1 of the third operation, b becomes: 2, 1, 3.\n\nAfter step 2 of the third operation, b becomes: 3, 1, 2.\n\nAfter step 1 of the fourth operation, b becomes: 3, 1, 2, 4.\n\nAfter step 2 of the fourth operation, b becomes: 4, 2, 1, 3.\n\nThus, the answer is 4 2 1 3.\n\nSample Input 2\n\n3\n1 2 3\n\nSample Output 2\n\n3 1 2\n\nAs shown above in Sample Output 1, b becomes 3, 1, 2 after step 2 of the third operation. Thus, the answer is 3 1 2.\n\nSample Input 3\n\n1\n1000000000\n\nSample Output 3\n\n1000000000\n\nSample Input 4\n\n6\n0 6 7 6 7 0\n\nSample Output 4\n\n0 6 6 0 7 7", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2463, "cpu_time_ms": 374, "memory_kb": 72408}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s551933935", "group_id": "codeNet:p03675", "input_text": "import java.util.*;\n\nclass Main{ \n public static void main(String[] args){\n \n Scanner sc = new Scanner(System.in); \n \n Deque q = new ArrayDeque();\n \n int n = sc.nextInt();\n \n int a[] = new int[n];\n for(int i = 0;i < n;i++){\n a[i] = sc.nextInt();\n }\n \n if(n%2 == 0){\n for(int i = 0;i < n;i++){\n if(a[i]%2 == 1){\n q.addLast(a[i]);\n }else{\n q.addFirst(a[i]);\n }\n } \n }else{\n for(int i = 0;i < n;i++){\n if(a[i]%2 == 1){\n q.addFirst(a[i]);\n }else{\n q.addLast(a[i]);\n }\n }\n }\n \n while(!q.isEmpty()){\n System.out.print(q.poll());\n System.out.print(\" \");\n }\n \n System.out.println();\n \n \n }\n}\n \n \n\n", "language": "Java", "metadata": {"date": 1509065513, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03675.html", "problem_id": "p03675", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03675/input.txt", "sample_output_relpath": "derived/input_output/data/p03675/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03675/Java/s551933935.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s551933935", "user_id": "u918497744"}, "prompt_components": {"gold_output": "4 2 1 3\n", "input_to_evaluate": "import java.util.*;\n\nclass Main{ \n public static void main(String[] args){\n \n Scanner sc = new Scanner(System.in); \n \n Deque q = new ArrayDeque();\n \n int n = sc.nextInt();\n \n int a[] = new int[n];\n for(int i = 0;i < n;i++){\n a[i] = sc.nextInt();\n }\n \n if(n%2 == 0){\n for(int i = 0;i < n;i++){\n if(a[i]%2 == 1){\n q.addLast(a[i]);\n }else{\n q.addFirst(a[i]);\n }\n } \n }else{\n for(int i = 0;i < n;i++){\n if(a[i]%2 == 1){\n q.addFirst(a[i]);\n }else{\n q.addLast(a[i]);\n }\n }\n }\n \n while(!q.isEmpty()){\n System.out.print(q.poll());\n System.out.print(\" \");\n }\n \n System.out.println();\n \n \n }\n}\n \n \n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length n, a_1, ..., a_n.\nLet us consider performing the following n operations on an empty sequence b.\n\nThe i-th operation is as follows:\n\nAppend a_i to the end of b.\n\nReverse the order of the elements in b.\n\nFind the sequence b obtained after these n operations.\n\nConstraints\n\n1 \\leq n \\leq 2\\times 10^5\n\n0 \\leq a_i \\leq 10^9\n\nn and a_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint n integers in a line with spaces in between.\nThe i-th integer should be b_i.\n\nSample Input 1\n\n4\n1 2 3 4\n\nSample Output 1\n\n4 2 1 3\n\nAfter step 1 of the first operation, b becomes: 1.\n\nAfter step 2 of the first operation, b becomes: 1.\n\nAfter step 1 of the second operation, b becomes: 1, 2.\n\nAfter step 2 of the second operation, b becomes: 2, 1.\n\nAfter step 1 of the third operation, b becomes: 2, 1, 3.\n\nAfter step 2 of the third operation, b becomes: 3, 1, 2.\n\nAfter step 1 of the fourth operation, b becomes: 3, 1, 2, 4.\n\nAfter step 2 of the fourth operation, b becomes: 4, 2, 1, 3.\n\nThus, the answer is 4 2 1 3.\n\nSample Input 2\n\n3\n1 2 3\n\nSample Output 2\n\n3 1 2\n\nAs shown above in Sample Output 1, b becomes 3, 1, 2 after step 2 of the third operation. Thus, the answer is 3 1 2.\n\nSample Input 3\n\n1\n1000000000\n\nSample Output 3\n\n1000000000\n\nSample Input 4\n\n6\n0 6 7 6 7 0\n\nSample Output 4\n\n0 6 6 0 7 7", "sample_input": "4\n1 2 3 4\n"}, "reference_outputs": ["4 2 1 3\n"], "source_document_id": "p03675", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length n, a_1, ..., a_n.\nLet us consider performing the following n operations on an empty sequence b.\n\nThe i-th operation is as follows:\n\nAppend a_i to the end of b.\n\nReverse the order of the elements in b.\n\nFind the sequence b obtained after these n operations.\n\nConstraints\n\n1 \\leq n \\leq 2\\times 10^5\n\n0 \\leq a_i \\leq 10^9\n\nn and a_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint n integers in a line with spaces in between.\nThe i-th integer should be b_i.\n\nSample Input 1\n\n4\n1 2 3 4\n\nSample Output 1\n\n4 2 1 3\n\nAfter step 1 of the first operation, b becomes: 1.\n\nAfter step 2 of the first operation, b becomes: 1.\n\nAfter step 1 of the second operation, b becomes: 1, 2.\n\nAfter step 2 of the second operation, b becomes: 2, 1.\n\nAfter step 1 of the third operation, b becomes: 2, 1, 3.\n\nAfter step 2 of the third operation, b becomes: 3, 1, 2.\n\nAfter step 1 of the fourth operation, b becomes: 3, 1, 2, 4.\n\nAfter step 2 of the fourth operation, b becomes: 4, 2, 1, 3.\n\nThus, the answer is 4 2 1 3.\n\nSample Input 2\n\n3\n1 2 3\n\nSample Output 2\n\n3 1 2\n\nAs shown above in Sample Output 1, b becomes 3, 1, 2 after step 2 of the third operation. Thus, the answer is 3 1 2.\n\nSample Input 3\n\n1\n1000000000\n\nSample Output 3\n\n1000000000\n\nSample Input 4\n\n6\n0 6 7 6 7 0\n\nSample Output 4\n\n0 6 6 0 7 7", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 987, "cpu_time_ms": 1682, "memory_kb": 96216}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s392783670", "group_id": "codeNet:p03676", "input_text": "import java.util.*;\n\npublic class Main {\n static long MOD = (long)Math.pow(10, 9) + 7;\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n long[] kaijou = new long[n + 2];\n kaijou[0] = 1;\n for(int i = 1; i < n + 2; i++) {\n kaijou[i] = (kaijou[i - 1] * (long)i) % MOD;\n }\n int[] suuretu = new int[n + 1];\n long[] aho = new long[n + 1];\n for(int i = 0; i < n + 1; i++) {\n long a = sc.nextLong();\n aho[i] = a;\n suuretu[(int)a]++;\n }\n long u = 0;\n for(int i = 0; i < n + 1; i++) {\n if(suuretu[i] == 2) u = i;\n }\n int index = 0;\n int index2 = 0;\n boolean flg = true;\n for(int i = 0; i < n + 1; i++) {\n if(aho[i] == u) {\n if(flg) {\n flg = false;\n index = i;\n } else {\n index2 = i;\n }\n }\n }\n long unko = (long)(index + n - index2);\n long[] dp = new long[(int)(unko + 1)];\n long[] dp2 = new long[n + 2];\n for(int k = 0; k < unko + 1; k++) {\n long inv = func(kaijou[k], MOD - 2);\n long inv2 = func(kaijou[(int)unko - k], MOD - 2);\n long ret = (kaijou[(int)unko] * inv) % MOD;\n ret = (ret * inv2) % MOD;\n dp[k] = ret;\n }\n for(int k = 0; k < n + 2; k++) {\n long inv = func(kaijou[k], MOD - 2);\n long inv2 = func(kaijou[n + 1 - k], MOD - 2);\n long ret = (kaijou[n + 1] * inv) % MOD;\n ret = (ret * inv2) % MOD;\n dp2[k] = ret;\n }\n for(int k = 1; k <= n + 1; k++) {\n long ans = dp2[k];\n if(k >= 1) {\n if(ans >= dp[k - 1]) {\n ans -= dp[k - 1];\n } else {\n ans = (ans + MOD - dp[k - 1]) % MOD;\n }\n }\n System.out.println(ans);\n }\n }\n\n public static long func(long a, long x) {\n if(x == 0) return 1;\n long t = func(a, x / 2);\n long ret = (t * t) % MOD;\n if(x % 2 == 1) ret = (ret * a) % MOD;\n return ret;\n }\n}\n", "language": "Java", "metadata": {"date": 1499007970, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03676.html", "problem_id": "p03676", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03676/input.txt", "sample_output_relpath": "derived/input_output/data/p03676/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03676/Java/s392783670.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s392783670", "user_id": "u653981267"}, "prompt_components": {"gold_output": "3\n5\n4\n1\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n static long MOD = (long)Math.pow(10, 9) + 7;\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n long[] kaijou = new long[n + 2];\n kaijou[0] = 1;\n for(int i = 1; i < n + 2; i++) {\n kaijou[i] = (kaijou[i - 1] * (long)i) % MOD;\n }\n int[] suuretu = new int[n + 1];\n long[] aho = new long[n + 1];\n for(int i = 0; i < n + 1; i++) {\n long a = sc.nextLong();\n aho[i] = a;\n suuretu[(int)a]++;\n }\n long u = 0;\n for(int i = 0; i < n + 1; i++) {\n if(suuretu[i] == 2) u = i;\n }\n int index = 0;\n int index2 = 0;\n boolean flg = true;\n for(int i = 0; i < n + 1; i++) {\n if(aho[i] == u) {\n if(flg) {\n flg = false;\n index = i;\n } else {\n index2 = i;\n }\n }\n }\n long unko = (long)(index + n - index2);\n long[] dp = new long[(int)(unko + 1)];\n long[] dp2 = new long[n + 2];\n for(int k = 0; k < unko + 1; k++) {\n long inv = func(kaijou[k], MOD - 2);\n long inv2 = func(kaijou[(int)unko - k], MOD - 2);\n long ret = (kaijou[(int)unko] * inv) % MOD;\n ret = (ret * inv2) % MOD;\n dp[k] = ret;\n }\n for(int k = 0; k < n + 2; k++) {\n long inv = func(kaijou[k], MOD - 2);\n long inv2 = func(kaijou[n + 1 - k], MOD - 2);\n long ret = (kaijou[n + 1] * inv) % MOD;\n ret = (ret * inv2) % MOD;\n dp2[k] = ret;\n }\n for(int k = 1; k <= n + 1; k++) {\n long ans = dp2[k];\n if(k >= 1) {\n if(ans >= dp[k - 1]) {\n ans -= dp[k - 1];\n } else {\n ans = (ans + MOD - dp[k - 1]) % MOD;\n }\n }\n System.out.println(ans);\n }\n }\n\n public static long func(long a, long x) {\n if(x == 0) return 1;\n long t = func(a, x / 2);\n long ret = (t * t) % MOD;\n if(x % 2 == 1) ret = (ret * a) % MOD;\n return ret;\n }\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nYou are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n.\nIt is known that each of the n integers 1,...,n appears at least once in this sequence.\n\nFor each integer k=1,...,n+1, find the number of the different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7.\n\nNotes\n\nIf the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence.\n\nA subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. For example, the sequences 1,3,5 and 1,2,3 are subsequences of 1,2,3,4,5, while 3,1,2 and 1,10,100 are not.\n\nConstraints\n\n1 \\leq n \\leq 10^5\n\n1 \\leq a_i \\leq n\n\nEach of the integers 1,...,n appears in the sequence.\n\nn and a_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_{n+1}\n\nOutput\n\nPrint n+1 lines.\nThe k-th line should contain the number of the different subsequences of the given sequence with length k, modulo 10^9+7.\n\nSample Input 1\n\n3\n1 2 1 3\n\nSample Output 1\n\n3\n5\n4\n1\n\nThere are three subsequences with length 1: 1 and 2 and 3.\n\nThere are five subsequences with length 2: 1,1 and 1,2 and 1,3 and 2,1 and 2,3.\n\nThere are four subsequences with length 3: 1,1,3 and 1,2,1 and 1,2,3 and 2,1,3.\n\nThere is one subsequence with length 4: 1,2,1,3.\n\nSample Input 2\n\n1\n1 1\n\nSample Output 2\n\n1\n1\n\nThere is one subsequence with length 1: 1.\n\nThere is one subsequence with length 2: 1,1.\n\nSample Input 3\n\n32\n29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9\n\nSample Output 3\n\n32\n525\n5453\n40919\n237336\n1107568\n4272048\n13884156\n38567100\n92561040\n193536720\n354817320\n573166440\n818809200\n37158313\n166803103\n166803103\n37158313\n818809200\n573166440\n354817320\n193536720\n92561040\n38567100\n13884156\n4272048\n1107568\n237336\n40920\n5456\n528\n33\n1\n\nBe sure to print the numbers modulo 10^9+7.", "sample_input": "3\n1 2 1 3\n"}, "reference_outputs": ["3\n5\n4\n1\n"], "source_document_id": "p03676", "source_text": "Score : 600 points\n\nProblem Statement\n\nYou are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n.\nIt is known that each of the n integers 1,...,n appears at least once in this sequence.\n\nFor each integer k=1,...,n+1, find the number of the different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7.\n\nNotes\n\nIf the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence.\n\nA subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. For example, the sequences 1,3,5 and 1,2,3 are subsequences of 1,2,3,4,5, while 3,1,2 and 1,10,100 are not.\n\nConstraints\n\n1 \\leq n \\leq 10^5\n\n1 \\leq a_i \\leq n\n\nEach of the integers 1,...,n appears in the sequence.\n\nn and a_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_{n+1}\n\nOutput\n\nPrint n+1 lines.\nThe k-th line should contain the number of the different subsequences of the given sequence with length k, modulo 10^9+7.\n\nSample Input 1\n\n3\n1 2 1 3\n\nSample Output 1\n\n3\n5\n4\n1\n\nThere are three subsequences with length 1: 1 and 2 and 3.\n\nThere are five subsequences with length 2: 1,1 and 1,2 and 1,3 and 2,1 and 2,3.\n\nThere are four subsequences with length 3: 1,1,3 and 1,2,1 and 1,2,3 and 2,1,3.\n\nThere is one subsequence with length 4: 1,2,1,3.\n\nSample Input 2\n\n1\n1 1\n\nSample Output 2\n\n1\n1\n\nThere is one subsequence with length 1: 1.\n\nThere is one subsequence with length 2: 1,1.\n\nSample Input 3\n\n32\n29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9\n\nSample Output 3\n\n32\n525\n5453\n40919\n237336\n1107568\n4272048\n13884156\n38567100\n92561040\n193536720\n354817320\n573166440\n818809200\n37158313\n166803103\n166803103\n37158313\n818809200\n573166440\n354817320\n193536720\n92561040\n38567100\n13884156\n4272048\n1107568\n237336\n40920\n5456\n528\n33\n1\n\nBe sure to print the numbers modulo 10^9+7.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1935, "cpu_time_ms": 1349, "memory_kb": 64416}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s085427795", "group_id": "codeNet:p03677", "input_text": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.NoSuchElementException;\nimport java.util.Objects;\nimport java.util.function.BiFunction;\nimport java.util.function.BinaryOperator;\nimport static java.lang.Math.max;\nimport static java.util.Arrays.sort;\nimport static java.util.Objects.isNull;\n\n\npublic class Main {\n public static void main(String[] args) {\n FastScanner fsc = new FastScanner();\n int n = fsc.nextInt();\n int m = fsc.nextInt();\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = fsc.nextInt() - 1;\n }\n LazySegmentTree t = new LazySegmentTree(new long[m], Monoid.ADD, Monoid.ADD, Long::sum, (laz, l) -> laz * l);\n for (int i = 1; i < n; i++) {\n int to = a[i];\n int fr = a[i - 1];\n if (fr < to) {\n t.applyForSegment(fr + 2, to + 1, 1);\n t.applyForSegment(to + 1, to + 2, -(to - fr - 1));\n } else {\n t.applyForSegment(fr + 2, m, 1);\n t.applyForSegment(0, 1, m - fr - 1);\n t.applyForSegment(1, to + 1, 1);\n t.applyForSegment(to + 1, to + 2, -(to + m - fr - 1));\n }\n }\n long max = 0;\n for (int x = 0; x < m; x++) {\n max = max(max, t.query(0, x + 1));\n }\n long sum = 0;\n for (int i = 1; i < n; i++) {\n if (a[i] > a[i - 1]) {\n sum += a[i] - a[i - 1];\n } else {\n sum += a[i] + m - a[i - 1];\n }\n }\n System.out.println(sum - max);\n }\n}\n\n\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n }else{\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}\n private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}\n public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while(isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while(true){\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n public double nextDouble() { return Double.parseDouble(next());}\n}\n\n\n\nclass Range{\n public static final int MAX = +Const.IINF;\n public static final int MIN = -Const.IINF;\n private static final int E_LEFT = MAX;\n private static final int E_RIGHT = MAX;\n private static final int W_LEFT = MIN;\n private static final int W_RIGHT = MAX;\n public static final Range EMPTY = new Range(E_LEFT, E_RIGHT);\n public static final Range WHOLE = new Range(W_LEFT, W_RIGHT);\n\n\n public int left;\n public int right;\n\n public Range(int left, int right){\n if(left >= right){\n this.left = E_LEFT;\n this.right = E_RIGHT;\n } else{\n this.left = left;\n this.right = right;\n }\n }\n public boolean crosses(Range r){\n return this.left < r.right && r.left < this.right;\n }\n public boolean contains(Range r){\n if(this.isEmpty()) return false;\n if(r.isEmpty()) return true;\n return this.left <= r.left && r.right <= this.right;\n }\n public Range leftHalf(){\n if(this.isEmpty()) return EMPTY;\n return new Range(left, (left + right) >> 1);\n }\n public Range rightHalf(){\n if(this.isEmpty()) return EMPTY;\n return new Range((left + right) >> 1, right);\n }\n public int length(){\n return right - left;\n }\n public Range intersection(Range r){\n if(!this.crosses(r)) return EMPTY;\n return new Range(Math.max(this.left, r.left), Math.min(this.right, r.right));\n }\n public ArrayList union(Range r){\n ArrayList union = new ArrayList<>();\n if(this.isEmpty()){\n union.add(r); \n } else if(r.isEmpty()){\n union.add(this);\n } else if(this.crosses(r)){\n union.add(new Range(Math.min(this.left, r.left), Math.max(this.right, r.right)));\n } else {\n if(this.left < r.left){\n union.add(this);\n union.add(r);\n } else{\n union.add(r);\n union.add(this);\n }\n }\n return union;\n }\n public boolean isEmpty(){\n return this.equals(EMPTY);\n }\n public boolean nonEmpty(){\n return !this.isEmpty();\n }\n\n public static boolean crosses(Range r1, Range r2){\n return r1.crosses(r2);\n }\n public static Range leftHalf(Range r){\n return r.leftHalf();\n }\n public static Range rightHalf(Range r){\n return r.rightHalf();\n }\n public static int length(Range r){\n return r.length();\n }\n public static Range interSection(Range... rs){\n Range ret = WHOLE;\n for(Range r: rs) ret = ret.intersection(r);\n return ret;\n }\n public static ArrayList union(Range... rs){\n sort(rs, (u, v) -> Integer.compare(u.left, v.left));\n ArrayList union = new ArrayList<>();\n Range now = null;\n for(Range r: rs){\n if(r.isEmpty()) break;\n if(isNull(now)){\n now = r;\n } else{\n if(r.left <= now.right){\n now.right = r.right;\n } else{\n union.add(now);\n now = r;\n }\n }\n }\n if(!isNull(now) && !now.equals(EMPTY)) union.add(now);\n if(union.isEmpty()) union.add(EMPTY);\n return union;\n }\n public static boolean isEmpty(Range r){\n return r.isEmpty();\n }\n public static boolean nonEmpty(Range r){\n return r.nonEmpty();\n }\n\n @Override\n public boolean equals(Object o){\n if(this == o) {\n return true;\n } else if(!(o instanceof Range)) {\n return false;\n } else {\n Range r = (Range) o;\n return this.left == r.left && this.right == r.right; \n }\n }\n @Override\n public int hashCode(){\n return Objects.hash(left, right);\n }\n @Override\n public String toString(){\n return \"[\"+left+\", \"+right+\")\";\n }\n}\n\n\nclass LazySegmentTree {\n private long[] tree;\n private long[] lazy;\n private final long e;\n private final long lazyIdElm;\n private final BinaryOperator operator;\n private final BinaryOperator lazyOperator;\n private final BinaryOperator appFunc;\n private final BiFunction mergeLazy;\n private final int size;\n private final int leafs;\n private final int height;\n private final int baseOfLeaf;\n\n public LazySegmentTree(long[] t, Monoid monoid, Monoid lazyMonoid, BinaryOperator appFunc, BiFunction mergeLazy) {\n int n = t.length;\n this.operator = monoid.operator;\n this.e = monoid.e;\n this.lazyOperator = lazyMonoid.operator;\n this.lazyIdElm = lazyMonoid.e;\n this.appFunc = appFunc;\n this.mergeLazy = mergeLazy;\n this.height = MathUtil.minimumExponent(n);\n this.leafs = 1 << this.height;\n this.baseOfLeaf = this.leafs - 1;\n this.size = 2 * this.leafs - 1;\n this.lazy = new long[this.size];\n Arrays.fill(this.lazy, this.lazyIdElm);\n this.tree = new long[this.size];\n for (int i = this.size - 1; i >= 0; i--) {\n if (i >= this.baseOfLeaf + n) {\n this.tree[i] = this.e;\n } else if (isLeaf(i)) {\n this.tree[i] = t[i - this.baseOfLeaf];\n } else {\n this.tree[i] = this.operator.apply(this.tree[left(i)], this.tree[right(i)]);\n }\n }\n }\n\n public void applyForSegment(int l, int r, long v) {\n applyForSegment(new Range(l, r), 0, new Range(0, leafs), v);\n }\n\n private void applyForSegment(Range queryRange, int k, Range treeRange, long v) {\n evaluate(k, treeRange);\n if (queryRange.crosses(treeRange)) {\n if (queryRange.contains(treeRange)) {\n lazy[k] = lazyOperator.apply(lazy[k], v);\n evaluate(k, treeRange);\n } else {\n int left = left(k);\n int right = right(k);\n applyForSegment(queryRange, left, treeRange.leftHalf(), v);\n applyForSegment(queryRange, right, treeRange.rightHalf(), v);\n tree[k] = operator.apply(tree[left], tree[right]);\n }\n }\n }\n\n public void applyForPoint(int i, long v) {\n tree[baseOfLeaf + i] = appFunc.apply(tree[baseOfLeaf + i], mergeLazy.apply(v, 1));\n }\n\n public long query(int l, int r) {\n return query(new Range(l, r), 0, new Range(0, leafs));\n }\n\n private long query(Range queryRange, int k, Range treeRange) {\n evaluate(k, treeRange);\n if (!queryRange.crosses(treeRange)) {\n return e;\n } else if (queryRange.contains(treeRange)) {\n return tree[k];\n } else {\n long left = query(queryRange, left(k), treeRange.leftHalf());\n long right = query(queryRange, right(k), treeRange.rightHalf());\n return operator.apply(left, right);\n }\n }\n\n private void evaluate(int k, Range r) {\n if (lazy[k] != lazyIdElm) {\n if (!isLeaf(k)) {\n lazy[left(k)] = lazyOperator.apply(lazy[left(k)], lazy[k]);\n lazy[right(k)] = lazyOperator.apply(lazy[right(k)], lazy[k]);\n }\n tree[k] = appFunc.apply(tree[k], mergeLazy.apply(lazy[k], r.length()));\n lazy[k] = lazyIdElm;\n }\n }\n\n private boolean isLeaf(int i) {\n return i >= baseOfLeaf;\n }\n\n private int left(int k) {\n return 2 * k + 1;\n }\n\n private int right(int k) {\n return 2 * k + 2;\n }\n\n public String toString() {\n StringBuilder sb = new StringBuilder();\n for (int h = 0; h <= height; h++) {\n for (int i = (1 << h) - 1; i < (1 << (h + 1)) - 1; i++) {\n sb.append(tree[i]).append(\" \");\n }\n sb.append('\\n');\n }\n return sb.toString();\n }\n}\n\n\nclass Monoid {\n public static final Monoid ADD = new Monoid<>( 0l, (u, v) -> u + v);\n public static final Monoid MAX = new Monoid<>(-Const.LINF, (u, v) -> u >= v ? u : v);\n public static final Monoid MIN = new Monoid<>( Const.LINF, (u, v) -> u <= v ? u : v);\n public static final Monoid RW = new Monoid<>( Const.LINF, (u, v) -> v);\n public static final Monoid AND = new Monoid<>(-1l, (u, v) -> u & v);\n public static final Monoid OR = new Monoid<>( 0l, (u, v) -> u | v);\n public static final Monoid XOR = new Monoid<>( 0l, (u, v) -> u ^ v);\n public static final Monoid GCD = new Monoid<>( 0l, (u, v) -> MathUtil.gcd(u, v));\n public static final Monoid ADD_MOD = new Monoid<>( 0l, (u, v) -> {\n long sum = u + v;\n if (sum < 0) {\n sum += Const.MOD;\n } else if (sum >= Const.MOD) {\n sum -= Const.MOD;\n } \n return sum;\n });\n public static final Monoid MUL_MOD = new Monoid<>( 1l, (u, v) -> (u * v) % Const.MOD);\n \n public T e;\n public BinaryOperator operator;\n\n public Monoid(T e, BinaryOperator operator) {\n this.e = e;\n this.operator = operator;\n }\n}\n\n\nclass MathUtil{\n /**\n * Enumarate primes equal to or less than n.\n * @param n\n * @return {@code ArrayList} that holds primes.\n */\n public static ArrayList eratosthenes(int n) {\n int[] div = eratosthenesDivisors(n);\n ArrayList result = new ArrayList<>();\n for (int i = 2; i <= n; i++) if (div[i] == i) result.add(i);\n return result;\n }\n /**\n * execute eratosthenes's prime-enumerate algorithm. a[i] holds the greatest\n * divisor of i. if a[i] = i, i is a prime number. This arrary enables you to\n * prime-factorize in O(log n) time.\n * @param n\n * @return divisor array.\n */\n public static int[] eratosthenesDivisors(int n) {\n int[] divisors = new int[n + 1];\n if (n <= 0) return null;\n for (int i = 1; i <= n; i++) {\n if ((i & 1) != 0) divisors[i] = i;\n else divisors[i] = 2;\n }\n for (int i = 3; i <= n; i += 2) {\n if (divisors[i] == i) {\n for (long j = (long) i * i; j <= n; j += i << 1) {\n divisors[(int) j] = i;\n }\n }\n }\n return divisors;\n }\n\n /**\n * Caluculate prime-factorization in O(sqrt(n)) time.\n * @param n\n * @return {@code HashMap} of {prime: index}\n */\n public static HashMap primeFactorization(long n) {\n HashMap primes = new HashMap<>();\n for (long p = 2; p * p <= n; p++) {\n int q = 0;\n while (n % p == 0) {\n n /= p;\n q++;\n }\n if (q > 0) primes.put(p, q);\n }\n if (n > 1) primes.put(n, 1);\n return primes;\n }\n\n private static HashMap lcm(HashMap amap, HashMap bmap) {\n if (amap.size() < bmap.size()) return lcm(bmap, amap);\n HashMap lcm = amap;\n for (Map.Entry e : bmap.entrySet()) {\n long prime = e.getKey();\n if (lcm.containsKey(prime)) lcm.put(prime, Math.max(lcm.get(prime), e.getValue()));\n else lcm.put(prime, e.getValue());\n }\n return lcm;\n }\n private static HashMap lcm(HashMap amap, long b) {\n HashMap bmap = primeFactorization(b);\n return lcm(amap, bmap);\n }\n public static HashMap lcm(long... a) {\n HashMap amap = new HashMap<>();\n for (long c : a) amap = lcm(amap, c);\n return amap;\n }\n\n /**\n * calculate lcm(a, b) fast. (NOT considering overflow.)\n */\n public static long unsafeLCM(long a, long b) {\n return a * b / gcd(a, b);\n }\n\n /**\n * Caluculate the GCD of (a, b)/\n * \n * @param a first value\n * @param b second value\n * @return GCD(a, b)\n */\n public static long gcd(long a, long b) {\n if (a < b) return gcd(b, a);\n if (b == 0) return a;\n if (a == 0) return b;\n long r = a % b;\n while (r != 0) {\n a = b;\n b = r;\n r = a % b;\n }\n return b;\n }\n public static long gcd(long... a){\n long gcd = 0;\n for (long c : a) gcd = gcd(gcd, c);\n return gcd;\n }\n /**\n * Return one of the solutions to {@code ax+by=gcd(a, b)}.\n * @return {@code x}, {@code y}, {@code gcd(a, b)}.\n * @param a a of ax+by=gcd(a, b).\n * @param b b of ax+by=gcd(a, b). class ReferenceLong is a reference type of long.\n */\n public static long[] extGCD(long a, long b) {\n ReferenceLong x = new ReferenceLong();\n ReferenceLong y = new ReferenceLong();\n long[] ret = new long[3];\n ret[2] = extGCD(a, b, x, y);\n ret[0] = x.v;\n ret[1] = y.v;\n return ret;\n }\n private static long extGCD(long a, long b, ReferenceLong x, ReferenceLong y) {\n if (b == 0) {\n x.v = 1;\n y.v = 0;\n return a;\n }\n long d = extGCD(b, a % b, y, x);\n y.v -= a / b * x.v;\n return d;\n }\n private static class ReferenceLong {\n long v = 0;\n }\n\n public static boolean isPowerOfTwo(long n) {\n return (-n & n) == n;\n }\n\n public static int minimumExponent(long n) {\n return 63 - Long.numberOfLeadingZeros(n) + (isPowerOfTwo(n) ? 0 : 1);\n }\n\n public static int minimumExponent(int n) {\n return 31 - Integer.numberOfLeadingZeros(n) + (isPowerOfTwo(n) ? 0 : 1);\n }\n \n public static int minimumExponent(long n, int base) {\n if (base == 2) {\n return minimumExponent(n);\n }\n int i = 0;\n long m = 1;\n while (m < n) {\n i++;\n long r = m * base;\n if ((m | base) >> 31 != 0 && r / base != m) {\n break;\n }\n m = r;\n }\n return i;\n }\n \n /**\n * caluculate a ^ b NOT considering overflow.\n * so if you want to calculate a ^ b (mod p), use ModUtil.pow(a, b).\n * @param a base\n * @param b exponent\n * @return a ^ b\n */\n public static long pow(int a, int b) {\n if (b == 0) return 1;\n long half = pow(a, b >> 1);\n return half * half * ((b & 1) != 0 ? a : 1);\n }\n}\n\nclass Const {\n public static final long MOD7 = 1_000_000_007;\n public static final long MOD9 = 1_000_000_009;\n public static final long MOD99 = 998_244_353;\n public static long MOD = MOD7;\n\n public static final long LINF = 1_000_000_000_000_000_000l;\n public static final int IINF = 1_000_000_000;\n\n public static void setMod(long mod) {\n MOD = mod;\n }\n}\n", "language": "Java", "metadata": {"date": 1583300092, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03677.html", "problem_id": "p03677", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03677/input.txt", "sample_output_relpath": "derived/input_output/data/p03677/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03677/Java/s085427795.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s085427795", "user_id": "u541055501"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.NoSuchElementException;\nimport java.util.Objects;\nimport java.util.function.BiFunction;\nimport java.util.function.BinaryOperator;\nimport static java.lang.Math.max;\nimport static java.util.Arrays.sort;\nimport static java.util.Objects.isNull;\n\n\npublic class Main {\n public static void main(String[] args) {\n FastScanner fsc = new FastScanner();\n int n = fsc.nextInt();\n int m = fsc.nextInt();\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = fsc.nextInt() - 1;\n }\n LazySegmentTree t = new LazySegmentTree(new long[m], Monoid.ADD, Monoid.ADD, Long::sum, (laz, l) -> laz * l);\n for (int i = 1; i < n; i++) {\n int to = a[i];\n int fr = a[i - 1];\n if (fr < to) {\n t.applyForSegment(fr + 2, to + 1, 1);\n t.applyForSegment(to + 1, to + 2, -(to - fr - 1));\n } else {\n t.applyForSegment(fr + 2, m, 1);\n t.applyForSegment(0, 1, m - fr - 1);\n t.applyForSegment(1, to + 1, 1);\n t.applyForSegment(to + 1, to + 2, -(to + m - fr - 1));\n }\n }\n long max = 0;\n for (int x = 0; x < m; x++) {\n max = max(max, t.query(0, x + 1));\n }\n long sum = 0;\n for (int i = 1; i < n; i++) {\n if (a[i] > a[i - 1]) {\n sum += a[i] - a[i - 1];\n } else {\n sum += a[i] + m - a[i - 1];\n }\n }\n System.out.println(sum - max);\n }\n}\n\n\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n }else{\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}\n private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}\n public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while(isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while(true){\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n }else if(b == -1 || !isPrintableChar(b)){\n return minus ? -n : n;\n }else{\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n public double nextDouble() { return Double.parseDouble(next());}\n}\n\n\n\nclass Range{\n public static final int MAX = +Const.IINF;\n public static final int MIN = -Const.IINF;\n private static final int E_LEFT = MAX;\n private static final int E_RIGHT = MAX;\n private static final int W_LEFT = MIN;\n private static final int W_RIGHT = MAX;\n public static final Range EMPTY = new Range(E_LEFT, E_RIGHT);\n public static final Range WHOLE = new Range(W_LEFT, W_RIGHT);\n\n\n public int left;\n public int right;\n\n public Range(int left, int right){\n if(left >= right){\n this.left = E_LEFT;\n this.right = E_RIGHT;\n } else{\n this.left = left;\n this.right = right;\n }\n }\n public boolean crosses(Range r){\n return this.left < r.right && r.left < this.right;\n }\n public boolean contains(Range r){\n if(this.isEmpty()) return false;\n if(r.isEmpty()) return true;\n return this.left <= r.left && r.right <= this.right;\n }\n public Range leftHalf(){\n if(this.isEmpty()) return EMPTY;\n return new Range(left, (left + right) >> 1);\n }\n public Range rightHalf(){\n if(this.isEmpty()) return EMPTY;\n return new Range((left + right) >> 1, right);\n }\n public int length(){\n return right - left;\n }\n public Range intersection(Range r){\n if(!this.crosses(r)) return EMPTY;\n return new Range(Math.max(this.left, r.left), Math.min(this.right, r.right));\n }\n public ArrayList union(Range r){\n ArrayList union = new ArrayList<>();\n if(this.isEmpty()){\n union.add(r); \n } else if(r.isEmpty()){\n union.add(this);\n } else if(this.crosses(r)){\n union.add(new Range(Math.min(this.left, r.left), Math.max(this.right, r.right)));\n } else {\n if(this.left < r.left){\n union.add(this);\n union.add(r);\n } else{\n union.add(r);\n union.add(this);\n }\n }\n return union;\n }\n public boolean isEmpty(){\n return this.equals(EMPTY);\n }\n public boolean nonEmpty(){\n return !this.isEmpty();\n }\n\n public static boolean crosses(Range r1, Range r2){\n return r1.crosses(r2);\n }\n public static Range leftHalf(Range r){\n return r.leftHalf();\n }\n public static Range rightHalf(Range r){\n return r.rightHalf();\n }\n public static int length(Range r){\n return r.length();\n }\n public static Range interSection(Range... rs){\n Range ret = WHOLE;\n for(Range r: rs) ret = ret.intersection(r);\n return ret;\n }\n public static ArrayList union(Range... rs){\n sort(rs, (u, v) -> Integer.compare(u.left, v.left));\n ArrayList union = new ArrayList<>();\n Range now = null;\n for(Range r: rs){\n if(r.isEmpty()) break;\n if(isNull(now)){\n now = r;\n } else{\n if(r.left <= now.right){\n now.right = r.right;\n } else{\n union.add(now);\n now = r;\n }\n }\n }\n if(!isNull(now) && !now.equals(EMPTY)) union.add(now);\n if(union.isEmpty()) union.add(EMPTY);\n return union;\n }\n public static boolean isEmpty(Range r){\n return r.isEmpty();\n }\n public static boolean nonEmpty(Range r){\n return r.nonEmpty();\n }\n\n @Override\n public boolean equals(Object o){\n if(this == o) {\n return true;\n } else if(!(o instanceof Range)) {\n return false;\n } else {\n Range r = (Range) o;\n return this.left == r.left && this.right == r.right; \n }\n }\n @Override\n public int hashCode(){\n return Objects.hash(left, right);\n }\n @Override\n public String toString(){\n return \"[\"+left+\", \"+right+\")\";\n }\n}\n\n\nclass LazySegmentTree {\n private long[] tree;\n private long[] lazy;\n private final long e;\n private final long lazyIdElm;\n private final BinaryOperator operator;\n private final BinaryOperator lazyOperator;\n private final BinaryOperator appFunc;\n private final BiFunction mergeLazy;\n private final int size;\n private final int leafs;\n private final int height;\n private final int baseOfLeaf;\n\n public LazySegmentTree(long[] t, Monoid monoid, Monoid lazyMonoid, BinaryOperator appFunc, BiFunction mergeLazy) {\n int n = t.length;\n this.operator = monoid.operator;\n this.e = monoid.e;\n this.lazyOperator = lazyMonoid.operator;\n this.lazyIdElm = lazyMonoid.e;\n this.appFunc = appFunc;\n this.mergeLazy = mergeLazy;\n this.height = MathUtil.minimumExponent(n);\n this.leafs = 1 << this.height;\n this.baseOfLeaf = this.leafs - 1;\n this.size = 2 * this.leafs - 1;\n this.lazy = new long[this.size];\n Arrays.fill(this.lazy, this.lazyIdElm);\n this.tree = new long[this.size];\n for (int i = this.size - 1; i >= 0; i--) {\n if (i >= this.baseOfLeaf + n) {\n this.tree[i] = this.e;\n } else if (isLeaf(i)) {\n this.tree[i] = t[i - this.baseOfLeaf];\n } else {\n this.tree[i] = this.operator.apply(this.tree[left(i)], this.tree[right(i)]);\n }\n }\n }\n\n public void applyForSegment(int l, int r, long v) {\n applyForSegment(new Range(l, r), 0, new Range(0, leafs), v);\n }\n\n private void applyForSegment(Range queryRange, int k, Range treeRange, long v) {\n evaluate(k, treeRange);\n if (queryRange.crosses(treeRange)) {\n if (queryRange.contains(treeRange)) {\n lazy[k] = lazyOperator.apply(lazy[k], v);\n evaluate(k, treeRange);\n } else {\n int left = left(k);\n int right = right(k);\n applyForSegment(queryRange, left, treeRange.leftHalf(), v);\n applyForSegment(queryRange, right, treeRange.rightHalf(), v);\n tree[k] = operator.apply(tree[left], tree[right]);\n }\n }\n }\n\n public void applyForPoint(int i, long v) {\n tree[baseOfLeaf + i] = appFunc.apply(tree[baseOfLeaf + i], mergeLazy.apply(v, 1));\n }\n\n public long query(int l, int r) {\n return query(new Range(l, r), 0, new Range(0, leafs));\n }\n\n private long query(Range queryRange, int k, Range treeRange) {\n evaluate(k, treeRange);\n if (!queryRange.crosses(treeRange)) {\n return e;\n } else if (queryRange.contains(treeRange)) {\n return tree[k];\n } else {\n long left = query(queryRange, left(k), treeRange.leftHalf());\n long right = query(queryRange, right(k), treeRange.rightHalf());\n return operator.apply(left, right);\n }\n }\n\n private void evaluate(int k, Range r) {\n if (lazy[k] != lazyIdElm) {\n if (!isLeaf(k)) {\n lazy[left(k)] = lazyOperator.apply(lazy[left(k)], lazy[k]);\n lazy[right(k)] = lazyOperator.apply(lazy[right(k)], lazy[k]);\n }\n tree[k] = appFunc.apply(tree[k], mergeLazy.apply(lazy[k], r.length()));\n lazy[k] = lazyIdElm;\n }\n }\n\n private boolean isLeaf(int i) {\n return i >= baseOfLeaf;\n }\n\n private int left(int k) {\n return 2 * k + 1;\n }\n\n private int right(int k) {\n return 2 * k + 2;\n }\n\n public String toString() {\n StringBuilder sb = new StringBuilder();\n for (int h = 0; h <= height; h++) {\n for (int i = (1 << h) - 1; i < (1 << (h + 1)) - 1; i++) {\n sb.append(tree[i]).append(\" \");\n }\n sb.append('\\n');\n }\n return sb.toString();\n }\n}\n\n\nclass Monoid {\n public static final Monoid ADD = new Monoid<>( 0l, (u, v) -> u + v);\n public static final Monoid MAX = new Monoid<>(-Const.LINF, (u, v) -> u >= v ? u : v);\n public static final Monoid MIN = new Monoid<>( Const.LINF, (u, v) -> u <= v ? u : v);\n public static final Monoid RW = new Monoid<>( Const.LINF, (u, v) -> v);\n public static final Monoid AND = new Monoid<>(-1l, (u, v) -> u & v);\n public static final Monoid OR = new Monoid<>( 0l, (u, v) -> u | v);\n public static final Monoid XOR = new Monoid<>( 0l, (u, v) -> u ^ v);\n public static final Monoid GCD = new Monoid<>( 0l, (u, v) -> MathUtil.gcd(u, v));\n public static final Monoid ADD_MOD = new Monoid<>( 0l, (u, v) -> {\n long sum = u + v;\n if (sum < 0) {\n sum += Const.MOD;\n } else if (sum >= Const.MOD) {\n sum -= Const.MOD;\n } \n return sum;\n });\n public static final Monoid MUL_MOD = new Monoid<>( 1l, (u, v) -> (u * v) % Const.MOD);\n \n public T e;\n public BinaryOperator operator;\n\n public Monoid(T e, BinaryOperator operator) {\n this.e = e;\n this.operator = operator;\n }\n}\n\n\nclass MathUtil{\n /**\n * Enumarate primes equal to or less than n.\n * @param n\n * @return {@code ArrayList} that holds primes.\n */\n public static ArrayList eratosthenes(int n) {\n int[] div = eratosthenesDivisors(n);\n ArrayList result = new ArrayList<>();\n for (int i = 2; i <= n; i++) if (div[i] == i) result.add(i);\n return result;\n }\n /**\n * execute eratosthenes's prime-enumerate algorithm. a[i] holds the greatest\n * divisor of i. if a[i] = i, i is a prime number. This arrary enables you to\n * prime-factorize in O(log n) time.\n * @param n\n * @return divisor array.\n */\n public static int[] eratosthenesDivisors(int n) {\n int[] divisors = new int[n + 1];\n if (n <= 0) return null;\n for (int i = 1; i <= n; i++) {\n if ((i & 1) != 0) divisors[i] = i;\n else divisors[i] = 2;\n }\n for (int i = 3; i <= n; i += 2) {\n if (divisors[i] == i) {\n for (long j = (long) i * i; j <= n; j += i << 1) {\n divisors[(int) j] = i;\n }\n }\n }\n return divisors;\n }\n\n /**\n * Caluculate prime-factorization in O(sqrt(n)) time.\n * @param n\n * @return {@code HashMap} of {prime: index}\n */\n public static HashMap primeFactorization(long n) {\n HashMap primes = new HashMap<>();\n for (long p = 2; p * p <= n; p++) {\n int q = 0;\n while (n % p == 0) {\n n /= p;\n q++;\n }\n if (q > 0) primes.put(p, q);\n }\n if (n > 1) primes.put(n, 1);\n return primes;\n }\n\n private static HashMap lcm(HashMap amap, HashMap bmap) {\n if (amap.size() < bmap.size()) return lcm(bmap, amap);\n HashMap lcm = amap;\n for (Map.Entry e : bmap.entrySet()) {\n long prime = e.getKey();\n if (lcm.containsKey(prime)) lcm.put(prime, Math.max(lcm.get(prime), e.getValue()));\n else lcm.put(prime, e.getValue());\n }\n return lcm;\n }\n private static HashMap lcm(HashMap amap, long b) {\n HashMap bmap = primeFactorization(b);\n return lcm(amap, bmap);\n }\n public static HashMap lcm(long... a) {\n HashMap amap = new HashMap<>();\n for (long c : a) amap = lcm(amap, c);\n return amap;\n }\n\n /**\n * calculate lcm(a, b) fast. (NOT considering overflow.)\n */\n public static long unsafeLCM(long a, long b) {\n return a * b / gcd(a, b);\n }\n\n /**\n * Caluculate the GCD of (a, b)/\n * \n * @param a first value\n * @param b second value\n * @return GCD(a, b)\n */\n public static long gcd(long a, long b) {\n if (a < b) return gcd(b, a);\n if (b == 0) return a;\n if (a == 0) return b;\n long r = a % b;\n while (r != 0) {\n a = b;\n b = r;\n r = a % b;\n }\n return b;\n }\n public static long gcd(long... a){\n long gcd = 0;\n for (long c : a) gcd = gcd(gcd, c);\n return gcd;\n }\n /**\n * Return one of the solutions to {@code ax+by=gcd(a, b)}.\n * @return {@code x}, {@code y}, {@code gcd(a, b)}.\n * @param a a of ax+by=gcd(a, b).\n * @param b b of ax+by=gcd(a, b). class ReferenceLong is a reference type of long.\n */\n public static long[] extGCD(long a, long b) {\n ReferenceLong x = new ReferenceLong();\n ReferenceLong y = new ReferenceLong();\n long[] ret = new long[3];\n ret[2] = extGCD(a, b, x, y);\n ret[0] = x.v;\n ret[1] = y.v;\n return ret;\n }\n private static long extGCD(long a, long b, ReferenceLong x, ReferenceLong y) {\n if (b == 0) {\n x.v = 1;\n y.v = 0;\n return a;\n }\n long d = extGCD(b, a % b, y, x);\n y.v -= a / b * x.v;\n return d;\n }\n private static class ReferenceLong {\n long v = 0;\n }\n\n public static boolean isPowerOfTwo(long n) {\n return (-n & n) == n;\n }\n\n public static int minimumExponent(long n) {\n return 63 - Long.numberOfLeadingZeros(n) + (isPowerOfTwo(n) ? 0 : 1);\n }\n\n public static int minimumExponent(int n) {\n return 31 - Integer.numberOfLeadingZeros(n) + (isPowerOfTwo(n) ? 0 : 1);\n }\n \n public static int minimumExponent(long n, int base) {\n if (base == 2) {\n return minimumExponent(n);\n }\n int i = 0;\n long m = 1;\n while (m < n) {\n i++;\n long r = m * base;\n if ((m | base) >> 31 != 0 && r / base != m) {\n break;\n }\n m = r;\n }\n return i;\n }\n \n /**\n * caluculate a ^ b NOT considering overflow.\n * so if you want to calculate a ^ b (mod p), use ModUtil.pow(a, b).\n * @param a base\n * @param b exponent\n * @return a ^ b\n */\n public static long pow(int a, int b) {\n if (b == 0) return 1;\n long half = pow(a, b >> 1);\n return half * half * ((b & 1) != 0 ? a : 1);\n }\n}\n\nclass Const {\n public static final long MOD7 = 1_000_000_007;\n public static final long MOD9 = 1_000_000_009;\n public static final long MOD99 = 998_244_353;\n public static long MOD = MOD7;\n\n public static final long LINF = 1_000_000_000_000_000_000l;\n public static final int IINF = 1_000_000_000;\n\n public static void setMod(long mod) {\n MOD = mod;\n }\n}\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nSnuke is buying a lamp.\nThe light of the lamp can be adjusted to m levels of brightness, represented by integers from 1 through m, by the two buttons on the remote control.\n\nThe first button is a \"forward\" button. When this button is pressed, the brightness level is increased by 1, except when the brightness level is m, in which case the brightness level becomes 1.\n\nThe second button is a \"favorite\" button. When this button is pressed, the brightness level becomes the favorite brightness level x, which is set when the lamp is purchased.\n\nSnuke is thinking of setting the favorite brightness level x so that he can efficiently adjust the brightness.\nHe is planning to change the brightness n-1 times. In the i-th change, the brightness level is changed from a_i to a_{i+1}. The initial brightness level is a_1.\nFind the number of times Snuke needs to press the buttons when x is set to minimize this number.\n\nConstraints\n\n2 \\leq n,m \\leq 10^5\n\n1 \\leq a_i\\leq m\n\na_i \\neq a_{i+1}\n\nn, m and a_i 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 minimum number of times Snuke needs to press the buttons.\n\nSample Input 1\n\n4 6\n1 5 1 4\n\nSample Output 1\n\n5\n\nWhen the favorite brightness level is set to 1, 2, 3, 4, 5 and 6, Snuke needs to press the buttons 8, 9, 7, 5, 6 and 9 times, respectively.\nThus, Snuke should set the favorite brightness level to 4.\nIn this case, the brightness is adjusted as follows:\n\nIn the first change, press the favorite button once, then press the forward button once.\n\nIn the second change, press the forward button twice.\n\nIn the third change, press the favorite button once.\n\nSample Input 2\n\n10 10\n10 9 8 7 6 5 4 3 2 1\n\nSample Output 2\n\n45", "sample_input": "4 6\n1 5 1 4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03677", "source_text": "Score : 700 points\n\nProblem Statement\n\nSnuke is buying a lamp.\nThe light of the lamp can be adjusted to m levels of brightness, represented by integers from 1 through m, by the two buttons on the remote control.\n\nThe first button is a \"forward\" button. When this button is pressed, the brightness level is increased by 1, except when the brightness level is m, in which case the brightness level becomes 1.\n\nThe second button is a \"favorite\" button. When this button is pressed, the brightness level becomes the favorite brightness level x, which is set when the lamp is purchased.\n\nSnuke is thinking of setting the favorite brightness level x so that he can efficiently adjust the brightness.\nHe is planning to change the brightness n-1 times. In the i-th change, the brightness level is changed from a_i to a_{i+1}. The initial brightness level is a_1.\nFind the number of times Snuke needs to press the buttons when x is set to minimize this number.\n\nConstraints\n\n2 \\leq n,m \\leq 10^5\n\n1 \\leq a_i\\leq m\n\na_i \\neq a_{i+1}\n\nn, m and a_i 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 minimum number of times Snuke needs to press the buttons.\n\nSample Input 1\n\n4 6\n1 5 1 4\n\nSample Output 1\n\n5\n\nWhen the favorite brightness level is set to 1, 2, 3, 4, 5 and 6, Snuke needs to press the buttons 8, 9, 7, 5, 6 and 9 times, respectively.\nThus, Snuke should set the favorite brightness level to 4.\nIn this case, the brightness is adjusted as follows:\n\nIn the first change, press the favorite button once, then press the forward button once.\n\nIn the second change, press the forward button twice.\n\nIn the third change, press the favorite button once.\n\nSample Input 2\n\n10 10\n10 9 8 7 6 5 4 3 2 1\n\nSample Output 2\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": 18796, "cpu_time_ms": 973, "memory_kb": 351708}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s212241325", "group_id": "codeNet:p03679", "input_text": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.Arrays;\nimport java.util.NoSuchElementException;\nimport java.util.Random;\nimport java.util.Scanner;\n\nclass UnionFind{\n\tint Parent[];\n\tUnionFind(int n){//Initialize by -1\n\t\tParent=new int[n];\n\t\tArrays.fill(Parent, -1);\n\t}\n\tint root(int A) {//In which tree is A?\n\t\tif(Parent[A]<0)return A;\n\t\treturn Parent[A]=root(Parent[A]);\n\t}\n\tint size(int A) {//size of tree which is include A\n\t\treturn -Parent[root(A)];\n\t}\n\tboolean connect(int A,int B) {//Connect A and B\n\t\tA=root(A);\n\t\tB=root(B);\n\t\tif(A==B) return false;\n\t\tif(size(A)0?gcd(b,a%b):a;}\n\tstatic long lcm (long a, long b) {return a*b/gcd(a,b);}\n\tstatic int max(int a,int b) {return a>b?a:b;}\n\tstatic int min(int a,int b) {return a=b) {\n\t\t\tSystem.out.println(\"delicious\");\n\t\t}\n\t\telse if(can>=b) {\n\t\t\tSystem.out.println(\"safe\");\n\t\t}\n\t\telse {\n\t\t\tSystem.out.println(\"dangerous\");\n\t\t}\n\t\t\n\t}\n\tstatic int lower_bound(int a[],int key) {\n\t\tint right=a.length;\n\t\tint left=0;\n\t\twhile(right-left>1) {\n\t\t\tint mid=(right+left)/2;\n\t\t\tif(a[mid]1) {\n\t\t\tint mid=(right+left)/2;\n\t\t\tif(a[mid]<=key) {\n\t\t\t\tleft=mid;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tright=mid;\n\t\t\t}\n\t\t}\n\t\treturn left;\n\t}\n\tstatic boolean isPrime (long n) {\n\t\tif (n==2) return true;\n\t\tif (n<2 || n%2==0) return false;\n\t\tdouble d = Math.sqrt(n);\n\t\tfor (int i=3; i<=d; i+=2)if(n%i==0){return false;}\n\t\treturn true;\n\t}\n\tstatic int upper_division(int a,int b) {\n\t\tif(a%b==0) {\n\t\t\treturn a/b;\n\t\t}\n\t\telse {\n\t\t\treturn a/b+1;\n\t\t}\n\t}\n\tstatic long lupper_division(long a,long b) {\n\t\tif(a%b==0) {\n\t\t\treturn a/b;\n\t\t}\n\t\telse {\n\t\t\treturn a/b+1;\n\t\t}\n\t}\n\tstatic int[] setArray(int a) {\n\t\tint b[]=new int[a];\n\t\tfor(int i=0;i=0;i--) {\n\t\t\tstrr+=str.charAt(i);\n\t\t}\n\t\treturn strr;\n\t}\n\tpublic static void printArray(int[] que) {\n\t\tfor(int i=0;iInteger.compare(x[0],y[0]));\n\t\treturn a;\n\t}\n\tpublic static long[][] ldoublesort(long[][]a) {\n\t\tArrays.sort(a,(x,y)->Long.compare(x[0],y[0]));\n\t\treturn a;\n\t}\n\tstatic long modpow(long x,long n,long mo) {\n\t\tlong sum=1;\n\t\twhile(n>0) {\n\t\t\tif((n&1)==1) {\n\t\t\t\tsum=sum*x%mo;\n\t\t\t}\n\t\t\tx=x*x%mo;\n\t\t\tn>>=1;\n\t\t}\n\t\treturn sum;\n\t}\n\tpublic static char[] revch(char ch[]) {\n\t\tchar ret[]=new char[ch.length];\n\t\tfor(int i=ch.length-1,j=0;i>=0;i--,j++) {\n\t\t\tret[j]=ch[i];\n\t\t}\n\t\treturn ret;\n\t}\n\tpublic static int[] revint(int ch[]) {\n\t\tint ret[]=new int[ch.length];\n\t\tfor(int i=ch.length-1,j=0;i>=0;i--,j++) {\n\t\t\tret[j]=ch[i];\n\t\t}\n\t\treturn ret;\n\t}\n\tpublic static void warshall_floyd(int v[][],int n) {\n\t\tfor(int k=0;k Integer.MAX_VALUE) throw new NumberFormatException();\n\t\treturn (int) nl;\n\t}\n\tpublic double nextDouble() { return Double.parseDouble(next());}\n\tpublic char nextchar() {\n\t\ttry { return (char)System.in.read(); } catch(Exception e) {\n\t\t\tthrow new RuntimeException(e);\n\t\t}\n\t}\n}\n", "language": "Java", "metadata": {"date": 1584194285, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03679.html", "problem_id": "p03679", "resource_group": "high_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/Java/s212241325.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s212241325", "user_id": "u274962354"}, "prompt_components": {"gold_output": "safe\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.Arrays;\nimport java.util.NoSuchElementException;\nimport java.util.Random;\nimport java.util.Scanner;\n\nclass UnionFind{\n\tint Parent[];\n\tUnionFind(int n){//Initialize by -1\n\t\tParent=new int[n];\n\t\tArrays.fill(Parent, -1);\n\t}\n\tint root(int A) {//In which tree is A?\n\t\tif(Parent[A]<0)return A;\n\t\treturn Parent[A]=root(Parent[A]);\n\t}\n\tint size(int A) {//size of tree which is include A\n\t\treturn -Parent[root(A)];\n\t}\n\tboolean connect(int A,int B) {//Connect A and B\n\t\tA=root(A);\n\t\tB=root(B);\n\t\tif(A==B) return false;\n\t\tif(size(A)0?gcd(b,a%b):a;}\n\tstatic long lcm (long a, long b) {return a*b/gcd(a,b);}\n\tstatic int max(int a,int b) {return a>b?a:b;}\n\tstatic int min(int a,int b) {return a=b) {\n\t\t\tSystem.out.println(\"delicious\");\n\t\t}\n\t\telse if(can>=b) {\n\t\t\tSystem.out.println(\"safe\");\n\t\t}\n\t\telse {\n\t\t\tSystem.out.println(\"dangerous\");\n\t\t}\n\t\t\n\t}\n\tstatic int lower_bound(int a[],int key) {\n\t\tint right=a.length;\n\t\tint left=0;\n\t\twhile(right-left>1) {\n\t\t\tint mid=(right+left)/2;\n\t\t\tif(a[mid]1) {\n\t\t\tint mid=(right+left)/2;\n\t\t\tif(a[mid]<=key) {\n\t\t\t\tleft=mid;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tright=mid;\n\t\t\t}\n\t\t}\n\t\treturn left;\n\t}\n\tstatic boolean isPrime (long n) {\n\t\tif (n==2) return true;\n\t\tif (n<2 || n%2==0) return false;\n\t\tdouble d = Math.sqrt(n);\n\t\tfor (int i=3; i<=d; i+=2)if(n%i==0){return false;}\n\t\treturn true;\n\t}\n\tstatic int upper_division(int a,int b) {\n\t\tif(a%b==0) {\n\t\t\treturn a/b;\n\t\t}\n\t\telse {\n\t\t\treturn a/b+1;\n\t\t}\n\t}\n\tstatic long lupper_division(long a,long b) {\n\t\tif(a%b==0) {\n\t\t\treturn a/b;\n\t\t}\n\t\telse {\n\t\t\treturn a/b+1;\n\t\t}\n\t}\n\tstatic int[] setArray(int a) {\n\t\tint b[]=new int[a];\n\t\tfor(int i=0;i=0;i--) {\n\t\t\tstrr+=str.charAt(i);\n\t\t}\n\t\treturn strr;\n\t}\n\tpublic static void printArray(int[] que) {\n\t\tfor(int i=0;iInteger.compare(x[0],y[0]));\n\t\treturn a;\n\t}\n\tpublic static long[][] ldoublesort(long[][]a) {\n\t\tArrays.sort(a,(x,y)->Long.compare(x[0],y[0]));\n\t\treturn a;\n\t}\n\tstatic long modpow(long x,long n,long mo) {\n\t\tlong sum=1;\n\t\twhile(n>0) {\n\t\t\tif((n&1)==1) {\n\t\t\t\tsum=sum*x%mo;\n\t\t\t}\n\t\t\tx=x*x%mo;\n\t\t\tn>>=1;\n\t\t}\n\t\treturn sum;\n\t}\n\tpublic static char[] revch(char ch[]) {\n\t\tchar ret[]=new char[ch.length];\n\t\tfor(int i=ch.length-1,j=0;i>=0;i--,j++) {\n\t\t\tret[j]=ch[i];\n\t\t}\n\t\treturn ret;\n\t}\n\tpublic static int[] revint(int ch[]) {\n\t\tint ret[]=new int[ch.length];\n\t\tfor(int i=ch.length-1,j=0;i>=0;i--,j++) {\n\t\t\tret[j]=ch[i];\n\t\t}\n\t\treturn ret;\n\t}\n\tpublic static void warshall_floyd(int v[][],int n) {\n\t\tfor(int k=0;k Integer.MAX_VALUE) throw new NumberFormatException();\n\t\treturn (int) nl;\n\t}\n\tpublic double nextDouble() { return Double.parseDouble(next());}\n\tpublic char nextchar() {\n\t\ttry { return (char)System.in.read(); } catch(Exception e) {\n\t\t\tthrow new RuntimeException(e);\n\t\t}\n\t}\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": 5992, "cpu_time_ms": 96, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s504924787", "group_id": "codeNet:p03679", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int x = sc.nextInt();\n int a = sc.nextInt();\n int b = sc.nextInt();\n\n sc.close();\n\n if (a >= b) {\n System.out.println(\"delicious\");\n } else if (a + x >= b) {\n System.out.println(\"safe\");\n } else {\n System.out.println(\"dangerous\");\n }\n }\n}", "language": "Java", "metadata": {"date": 1546577096, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03679.html", "problem_id": "p03679", "resource_group": "high_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/Java/s504924787.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s504924787", "user_id": "u291178324"}, "prompt_components": {"gold_output": "safe\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int x = sc.nextInt();\n int a = sc.nextInt();\n int b = sc.nextInt();\n\n sc.close();\n\n if (a >= b) {\n System.out.println(\"delicious\");\n } else if (a + x >= b) {\n System.out.println(\"safe\");\n } else {\n System.out.println(\"dangerous\");\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": 469, "cpu_time_ms": 100, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s317298358", "group_id": "codeNet:p03682", "input_text": "import java.util.*;\nimport java.math.*;\nimport java.io.*;\nclass Main{\n\tpublic static InputReader sc;\n public static PrintWriter out;\n public static final long MOD = (long)1e9 + 7L;\n public static void main(String[] args){\n \tsc=new InputReader(System.in);\t\n \tout=new PrintWriter(System.out);\n \tint n=sc.nextInt();\n \tArrayList l=new ArrayList();\n \tfor(int i=0;i q=new PriorityQueue(new Comparator(){\n \t\tpublic int compare(Edge e1,Edge e2){\n \t\t\treturn e1.dis-e2.dis;\n \t\t}\n \t});\n \tfor(int i=0;i ValX=new Comparator(){\n \t\tpublic int compare(Pair p1,Pair p2){\n \t\t\treturn p1.x-p2.x;\n \t\t}\n \t\t};\n \t\tpublic static Comparator ValY=new Comparator(){\n \t\t\tpublic int compare(Pair p1,Pair p2){\n \t\t\t\treturn p1.y-p2.y;\n \t\t\t}\n \t\t};\n }\n// static class Pair{\n// \tString x;\n// \tint y;\n// \tPair(){\n// \t\tthis.x=\"\";\n// \t\tthis.y=-1;\n// \t}\n// \tPair(String profit,int val,int count){\n// \t\tthis.x=profit;\n// \t\tthis.y=val;\n// \t}\n// \tpublic static Comparator Val=new Comparator(){\n// \t\tpublic int compare(Pair p1,Pair p2){\n// \t\t\tif(p1.x==p2.y){\n// \t\t\t\treturn p1.y-p2.y;\n// \t\t\t}\n// \t\t\treturn (int)p1.x-(int)p2.x;\n// \t\t}\n// \t};\n// \tpublic int hashCode() {\n// \t\tfinal int prime = 31;\n// \t\tint result = 1;\n// \t\tresult = prime * result + x;\n// \t\tresult = prime * result + x;\n// \t\treturn result;\n// \t}\n// \tpublic boolean equals(Object obj){\n// \t\tif (this == obj)\n// \t return true;\n// \t if (!(obj instanceof Pair)) {\n// \t return false;\n// \t }\n// \t \n// \t Pair p = (Pair) obj;\n// \t if(p.x!=this.x){\n// \t \treturn false;\n// \t }\n// \t else if(p.y!=p.y){\n// \t \treturn false;\n// \t }\n// \t return true;\n// \t}\n// }\n static class DisjointSet{\n \tint n;\n \tint[] par;\n \tint[] rank;\n \tDisjointSet(int n){\n \t\tthis.n=n;\n \t\tthis.par=new int[n];\n \t\tthis.rank=new int[n];\n \t\tmakeSet();\n \t}\n \tvoid makeSet(){\n \t\tfor(int i=0;i=rank[parY]){\n \t\t\t\trank[parX]+=rank[parY];\n \t\t\t\trank[parY]=0;\n \t\t\t\tpar[parY]=parX;\n \t\t\t}\n \t\t\telse{\n \t\t\t\trank[parY]+=rank[parX];\n \t\t\t\trank[parX]=0;\n \t\t\t\tpar[parX]=parY;\n \t\t\t}\n \t\t}\n \t}\n \tint parent(int c){\n \t\tint i=c;\n \t\twhile(i!=par[i]){\n \t\t\ti=par[i];\n \t\t}\n \t\treturn i;\n \t}\n }\n static int gcd(int a,int b){\n \tif(b==0){\n \t\treturn a;\n \t}\n \treturn gcd(b,a%b);\n \t\n }\n static int lcm(int a,int b){\n \tint g;\n \tif(a0 ) {\n if ( (p & 1)==1 ) res = ( res * x ) % m;\n x = ( x * x ) % m; p >>= 1;\n }\n return res;\n }\n static boolean isPrime(int n){\n \t if (n == 2)\n \t return true;\n \t for (long i = 2; i * i <= n; i++) {\n \t if (n % i == 0)\n \t return false;\n \t }\n \t return true;\n }\n \n static void shuffle(int[] A){\n \tfor(int i=A.length-1;i>0;i--){\n \t\tint j=(int)(Math.random()*(i+1));\n \t\tint temp=A[j];\n \t\tA[j]=A[i];\n \t\tA[i]=temp;\n \t}\n }\n \n//\tpublic static class Node implements Comparable{\n//\t int u;\n//\t int v;\n//\t public Node(){\n//\t \t;\n//\t }\n//\t public Node (int u, int v) {\n//\t \tthis.u = u;\n//\t this.v = v;\n//\t }\n//\t \n//\t public void print() {\n//\t out.println(v + \" \" + u + \" \");\n//\t }\n//\t \n//\t public int compareTo(Node n1){\n//\t \treturn this.u-n1.u;\n//\t }\n//\t}\n\tpublic static long pow(long base,long exp,long mod){\n\t\tif(exp==0){\n\t\t\treturn 1;\n\t\t}\n\t\tif(exp==1){\n\t\t\treturn base;\n\t\t}\n\t\tlong temp=exp/2;\n\t\tlong val=pow(base,temp,mod);\n\t\tlong result=val*val;\n\t\tresult=(result%mod);\n\t\tlong AND=exp&1;\n\t\tif(AND==1){\n\t\t\tresult*=base;\n\t\t\tresult=(result%mod);\n\t\t}\n\t\treturn result;\n\t}\n\tpublic static BigInteger pow(BigInteger base, BigInteger exp) {\n\t if(exp.equals(new BigInteger(String.valueOf(0)))){\n\t return new BigInteger(String.valueOf(1));\n\t } \n\t if(exp.equals(new BigInteger(String.valueOf(1))))\n\t return base;\n\t BigInteger temp=exp.divide(new BigInteger(String.valueOf(2)));\n\t BigInteger val = pow(base, temp);\n\t BigInteger result = val.multiply(val);\n\t result=result.remainder(new BigInteger(String.valueOf(MOD)));\n\t BigInteger AND=exp.and(new BigInteger(String.valueOf(1)));\n\t if(AND.equals(new BigInteger(String.valueOf(1)))){\n\t result = result.multiply(base);\n\t result=result.remainder(new BigInteger(String.valueOf(MOD)));\n\t } \n\t return result;\n\t}\n\t \n\tstatic class InputReader {\n\n\t private InputStream stream;\n\t private byte[] buf = new byte[8192];\n\t private int curChar, snumChars;\n\t private SpaceCharFilter filter;\n\n\t public InputReader(InputStream stream) {\n\t this.stream = stream;\n\t }\n\n\t public int snext() {\n\t if (snumChars == -1)\n\t throw new InputMismatchException();\n\t if (curChar >= snumChars) {\n\t curChar = 0;\n\t try {\n\t snumChars = stream.read(buf);\n\t } catch (IOException e) {\n\t throw new InputMismatchException();\n\t }\n\t if (snumChars <= 0)\n\t return -1;\n\t }\n\t return buf[curChar++];\n\t }\n\n\t public int nextInt() {\n\t int c = snext();\n\t while (isSpaceChar(c))\n\t c = snext();\n\t int sgn = 1;\n\t if (c == '-') {\n\t sgn = -1;\n\t c = snext();\n\t }\n\t int res = 0;\n\t do {\n\t if (c < '0' || c > '9')\n\t throw new InputMismatchException();\n\t res *= 10;\n\t res += c - '0';\n\t c = snext();\n\t } while (!isSpaceChar(c));\n\t return res * sgn;\n\t }\n\n\t public long nextLong() {\n\t int c = snext();\n\t while (isSpaceChar(c))\n\t c = snext();\n\t int sgn = 1;\n\t if (c == '-') {\n\t sgn = -1;\n\t c = snext();\n\t }\n\t long res = 0;\n\t do {\n\t if (c < '0' || c > '9')\n\t throw new InputMismatchException();\n\t res *= 10;\n\t res += c - '0';\n\t c = snext();\n\t } while (!isSpaceChar(c));\n\t return res * sgn;\n\t }\n\n\t public int[] nextIntArray(int n) {\n\t int a[] = new int[n];\n\t for (int i = 0; i < n; i++)\n\t a[i] = nextInt();\n\t return a;\n\t }\n\n\t public String readString() {\n\t int c = snext();\n\t while (isSpaceChar(c))\n\t c = snext();\n\t StringBuilder res = new StringBuilder();\n\t do {\n\t res.appendCodePoint(c);\n\t c = snext();\n\t } while (!isSpaceChar(c));\n\t return res.toString();\n\t }\n\n\t public boolean isSpaceChar(int c) {\n\t if (filter != null)\n\t return filter.isSpaceChar(c);\n\t return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n\t }\n\n\t public interface SpaceCharFilter {\n\t public boolean isSpaceChar(int ch);\n\t }\n\t}\n\n}\n\n", "language": "Java", "metadata": {"date": 1498373986, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03682.html", "problem_id": "p03682", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03682/input.txt", "sample_output_relpath": "derived/input_output/data/p03682/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03682/Java/s317298358.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s317298358", "user_id": "u810064626"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*;\nimport java.math.*;\nimport java.io.*;\nclass Main{\n\tpublic static InputReader sc;\n public static PrintWriter out;\n public static final long MOD = (long)1e9 + 7L;\n public static void main(String[] args){\n \tsc=new InputReader(System.in);\t\n \tout=new PrintWriter(System.out);\n \tint n=sc.nextInt();\n \tArrayList l=new ArrayList();\n \tfor(int i=0;i q=new PriorityQueue(new Comparator(){\n \t\tpublic int compare(Edge e1,Edge e2){\n \t\t\treturn e1.dis-e2.dis;\n \t\t}\n \t});\n \tfor(int i=0;i ValX=new Comparator(){\n \t\tpublic int compare(Pair p1,Pair p2){\n \t\t\treturn p1.x-p2.x;\n \t\t}\n \t\t};\n \t\tpublic static Comparator ValY=new Comparator(){\n \t\t\tpublic int compare(Pair p1,Pair p2){\n \t\t\t\treturn p1.y-p2.y;\n \t\t\t}\n \t\t};\n }\n// static class Pair{\n// \tString x;\n// \tint y;\n// \tPair(){\n// \t\tthis.x=\"\";\n// \t\tthis.y=-1;\n// \t}\n// \tPair(String profit,int val,int count){\n// \t\tthis.x=profit;\n// \t\tthis.y=val;\n// \t}\n// \tpublic static Comparator Val=new Comparator(){\n// \t\tpublic int compare(Pair p1,Pair p2){\n// \t\t\tif(p1.x==p2.y){\n// \t\t\t\treturn p1.y-p2.y;\n// \t\t\t}\n// \t\t\treturn (int)p1.x-(int)p2.x;\n// \t\t}\n// \t};\n// \tpublic int hashCode() {\n// \t\tfinal int prime = 31;\n// \t\tint result = 1;\n// \t\tresult = prime * result + x;\n// \t\tresult = prime * result + x;\n// \t\treturn result;\n// \t}\n// \tpublic boolean equals(Object obj){\n// \t\tif (this == obj)\n// \t return true;\n// \t if (!(obj instanceof Pair)) {\n// \t return false;\n// \t }\n// \t \n// \t Pair p = (Pair) obj;\n// \t if(p.x!=this.x){\n// \t \treturn false;\n// \t }\n// \t else if(p.y!=p.y){\n// \t \treturn false;\n// \t }\n// \t return true;\n// \t}\n// }\n static class DisjointSet{\n \tint n;\n \tint[] par;\n \tint[] rank;\n \tDisjointSet(int n){\n \t\tthis.n=n;\n \t\tthis.par=new int[n];\n \t\tthis.rank=new int[n];\n \t\tmakeSet();\n \t}\n \tvoid makeSet(){\n \t\tfor(int i=0;i=rank[parY]){\n \t\t\t\trank[parX]+=rank[parY];\n \t\t\t\trank[parY]=0;\n \t\t\t\tpar[parY]=parX;\n \t\t\t}\n \t\t\telse{\n \t\t\t\trank[parY]+=rank[parX];\n \t\t\t\trank[parX]=0;\n \t\t\t\tpar[parX]=parY;\n \t\t\t}\n \t\t}\n \t}\n \tint parent(int c){\n \t\tint i=c;\n \t\twhile(i!=par[i]){\n \t\t\ti=par[i];\n \t\t}\n \t\treturn i;\n \t}\n }\n static int gcd(int a,int b){\n \tif(b==0){\n \t\treturn a;\n \t}\n \treturn gcd(b,a%b);\n \t\n }\n static int lcm(int a,int b){\n \tint g;\n \tif(a0 ) {\n if ( (p & 1)==1 ) res = ( res * x ) % m;\n x = ( x * x ) % m; p >>= 1;\n }\n return res;\n }\n static boolean isPrime(int n){\n \t if (n == 2)\n \t return true;\n \t for (long i = 2; i * i <= n; i++) {\n \t if (n % i == 0)\n \t return false;\n \t }\n \t return true;\n }\n \n static void shuffle(int[] A){\n \tfor(int i=A.length-1;i>0;i--){\n \t\tint j=(int)(Math.random()*(i+1));\n \t\tint temp=A[j];\n \t\tA[j]=A[i];\n \t\tA[i]=temp;\n \t}\n }\n \n//\tpublic static class Node implements Comparable{\n//\t int u;\n//\t int v;\n//\t public Node(){\n//\t \t;\n//\t }\n//\t public Node (int u, int v) {\n//\t \tthis.u = u;\n//\t this.v = v;\n//\t }\n//\t \n//\t public void print() {\n//\t out.println(v + \" \" + u + \" \");\n//\t }\n//\t \n//\t public int compareTo(Node n1){\n//\t \treturn this.u-n1.u;\n//\t }\n//\t}\n\tpublic static long pow(long base,long exp,long mod){\n\t\tif(exp==0){\n\t\t\treturn 1;\n\t\t}\n\t\tif(exp==1){\n\t\t\treturn base;\n\t\t}\n\t\tlong temp=exp/2;\n\t\tlong val=pow(base,temp,mod);\n\t\tlong result=val*val;\n\t\tresult=(result%mod);\n\t\tlong AND=exp&1;\n\t\tif(AND==1){\n\t\t\tresult*=base;\n\t\t\tresult=(result%mod);\n\t\t}\n\t\treturn result;\n\t}\n\tpublic static BigInteger pow(BigInteger base, BigInteger exp) {\n\t if(exp.equals(new BigInteger(String.valueOf(0)))){\n\t return new BigInteger(String.valueOf(1));\n\t } \n\t if(exp.equals(new BigInteger(String.valueOf(1))))\n\t return base;\n\t BigInteger temp=exp.divide(new BigInteger(String.valueOf(2)));\n\t BigInteger val = pow(base, temp);\n\t BigInteger result = val.multiply(val);\n\t result=result.remainder(new BigInteger(String.valueOf(MOD)));\n\t BigInteger AND=exp.and(new BigInteger(String.valueOf(1)));\n\t if(AND.equals(new BigInteger(String.valueOf(1)))){\n\t result = result.multiply(base);\n\t result=result.remainder(new BigInteger(String.valueOf(MOD)));\n\t } \n\t return result;\n\t}\n\t \n\tstatic class InputReader {\n\n\t private InputStream stream;\n\t private byte[] buf = new byte[8192];\n\t private int curChar, snumChars;\n\t private SpaceCharFilter filter;\n\n\t public InputReader(InputStream stream) {\n\t this.stream = stream;\n\t }\n\n\t public int snext() {\n\t if (snumChars == -1)\n\t throw new InputMismatchException();\n\t if (curChar >= snumChars) {\n\t curChar = 0;\n\t try {\n\t snumChars = stream.read(buf);\n\t } catch (IOException e) {\n\t throw new InputMismatchException();\n\t }\n\t if (snumChars <= 0)\n\t return -1;\n\t }\n\t return buf[curChar++];\n\t }\n\n\t public int nextInt() {\n\t int c = snext();\n\t while (isSpaceChar(c))\n\t c = snext();\n\t int sgn = 1;\n\t if (c == '-') {\n\t sgn = -1;\n\t c = snext();\n\t }\n\t int res = 0;\n\t do {\n\t if (c < '0' || c > '9')\n\t throw new InputMismatchException();\n\t res *= 10;\n\t res += c - '0';\n\t c = snext();\n\t } while (!isSpaceChar(c));\n\t return res * sgn;\n\t }\n\n\t public long nextLong() {\n\t int c = snext();\n\t while (isSpaceChar(c))\n\t c = snext();\n\t int sgn = 1;\n\t if (c == '-') {\n\t sgn = -1;\n\t c = snext();\n\t }\n\t long res = 0;\n\t do {\n\t if (c < '0' || c > '9')\n\t throw new InputMismatchException();\n\t res *= 10;\n\t res += c - '0';\n\t c = snext();\n\t } while (!isSpaceChar(c));\n\t return res * sgn;\n\t }\n\n\t public int[] nextIntArray(int n) {\n\t int a[] = new int[n];\n\t for (int i = 0; i < n; i++)\n\t a[i] = nextInt();\n\t return a;\n\t }\n\n\t public String readString() {\n\t int c = snext();\n\t while (isSpaceChar(c))\n\t c = snext();\n\t StringBuilder res = new StringBuilder();\n\t do {\n\t res.appendCodePoint(c);\n\t c = snext();\n\t } while (!isSpaceChar(c));\n\t return res.toString();\n\t }\n\n\t public boolean isSpaceChar(int c) {\n\t if (filter != null)\n\t return filter.isSpaceChar(c);\n\t return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n\t }\n\n\t public interface SpaceCharFilter {\n\t public boolean isSpaceChar(int ch);\n\t }\n\t}\n\n}\n\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N towns on a plane. The i-th town is located at the coordinates (x_i,y_i). There may be more than one town at the same coordinates.\n\nYou can build a road between two towns at coordinates (a,b) and (c,d) for a cost of min(|a-c|,|b-d|) yen (the currency of Japan). It is not possible to build other types of roads.\n\nYour objective is to build roads so that it will be possible to travel between every pair of towns by traversing roads. At least how much money is necessary to achieve this?\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n0 ≤ x_i,y_i ≤ 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the minimum necessary amount of money in order to build roads so that it will be possible to travel between every pair of towns by traversing roads.\n\nSample Input 1\n\n3\n1 5\n3 9\n7 8\n\nSample Output 1\n\n3\n\nBuild a road between Towns 1 and 2, and another between Towns 2 and 3. The total cost is 2+1=3 yen.\n\nSample Input 2\n\n6\n8 3\n4 9\n12 19\n18 1\n13 5\n7 6\n\nSample Output 2\n\n8", "sample_input": "3\n1 5\n3 9\n7 8\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03682", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N towns on a plane. The i-th town is located at the coordinates (x_i,y_i). There may be more than one town at the same coordinates.\n\nYou can build a road between two towns at coordinates (a,b) and (c,d) for a cost of min(|a-c|,|b-d|) yen (the currency of Japan). It is not possible to build other types of roads.\n\nYour objective is to build roads so that it will be possible to travel between every pair of towns by traversing roads. At least how much money is necessary to achieve this?\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n0 ≤ x_i,y_i ≤ 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the minimum necessary amount of money in order to build roads so that it will be possible to travel between every pair of towns by traversing roads.\n\nSample Input 1\n\n3\n1 5\n3 9\n7 8\n\nSample Output 1\n\n3\n\nBuild a road between Towns 1 and 2, and another between Towns 2 and 3. The total cost is 2+1=3 yen.\n\nSample Input 2\n\n6\n8 3\n4 9\n12 19\n18 1\n13 5\n7 6\n\nSample Output 2\n\n8", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 8589, "cpu_time_ms": 505, "memory_kb": 38520}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s583486597", "group_id": "codeNet:p03683", "input_text": "import java.util.Scanner;\npublic class Main {\n\tpublic static long frac[] = new long[100020];\n\tpublic static final int ZYY = 1000000007;\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint x = scan.nextInt();\n\t\tint y = scan.nextInt();\n\t\tscan.close();\n\t\tif (Math.abs(x - y) > 1) {\n\t\t\tSystem.out.println('0');\n\t\t\treturn;\n\t\t}\n\t\tfrac[0] = 1;\n\t\tfor (int i = 1; i <= 100000; i++)\n\t\t\tfrac[i] = frac[i - 1] * i % ZYY;\n\t\tlong ans = frac[x] * frac[y] % ZYY;\n\t\tif (x == y) ans = ans * 2 % ZYY;\n\t\tSystem.out.println(ans);\n\t\treturn;\n\t}\n}", "language": "Java", "metadata": {"date": 1509836280, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03683.html", "problem_id": "p03683", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03683/input.txt", "sample_output_relpath": "derived/input_output/data/p03683/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03683/Java/s583486597.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s583486597", "user_id": "u089230684"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.Scanner;\npublic class Main {\n\tpublic static long frac[] = new long[100020];\n\tpublic static final int ZYY = 1000000007;\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint x = scan.nextInt();\n\t\tint y = scan.nextInt();\n\t\tscan.close();\n\t\tif (Math.abs(x - y) > 1) {\n\t\t\tSystem.out.println('0');\n\t\t\treturn;\n\t\t}\n\t\tfrac[0] = 1;\n\t\tfor (int i = 1; i <= 100000; i++)\n\t\t\tfrac[i] = frac[i - 1] * i % ZYY;\n\t\tlong ans = frac[x] * frac[y] % ZYY;\n\t\tif (x == y) ans = ans * 2 % ZYY;\n\t\tSystem.out.println(ans);\n\t\treturn;\n\t}\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": "p03683", "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": 560, "cpu_time_ms": 105, "memory_kb": 23380}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s283719882", "group_id": "codeNet:p03689", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.io.BufferedWriter;\nimport java.io.Writer;\nimport java.io.OutputStreamWriter;\nimport java.util.InputMismatchException;\nimport java.io.IOException;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author prakharjain\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n OutputWriter out = new OutputWriter(outputStream);\n agc016c solver = new agc016c();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class agc016c {\n public void solve(int testNumber, InputReader in, OutputWriter out) {\n int r = in.nextInt();\n int c = in.nextInt();\n\n int h = in.nextInt();\n int w = in.nextInt();\n\n int neg = -h * w;\n\n int[][] ans = new int[r][c];\n\n for (int i = 0; i < r; i++) {\n for (int j = 0; j < c; j++) {\n ans[i][j] = 1;\n }\n }\n\n for (int i = h - 1; i < r; i += h) {\n for (int j = w - 1; j < c; j += w) {\n ans[i][j] = neg;\n }\n }\n\n long sum = 0;\n for (int i = 0; i < r; i++) {\n for (int j = 0; j < c; j++) {\n sum += ans[i][j];\n }\n }\n\n if (sum > 0) {\n out.println(\"Yes\");\n for (int i = 0; i < r; i++) {\n for (int j = 0; j < c; j++) {\n out.print(ans[i][j] + \" \");\n }\n out.println();\n }\n } else {\n out.print(\"No\");\n }\n }\n\n }\n\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private InputReader.SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n\n public static boolean isWhitespace(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public int read() {\n if (numChars == -1) {\n throw new InputMismatchException();\n }\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0) {\n return -1;\n }\n }\n return buf[curChar++];\n }\n\n public int nextInt() {\n int c = read();\n while (isSpaceChar(c)) {\n c = read();\n }\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n res *= 10;\n res += c - '0';\n c = read();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n\n public boolean isSpaceChar(int c) {\n if (filter != null) {\n return filter.isSpaceChar(c);\n }\n return isWhitespace(c);\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\n\n }\n\n static class OutputWriter {\n private final PrintWriter writer;\n\n public OutputWriter(OutputStream outputStream) {\n writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));\n }\n\n public OutputWriter(Writer writer) {\n this.writer = new PrintWriter(writer);\n }\n\n public void print(Object... objects) {\n for (int i = 0; i < objects.length; i++) {\n if (i != 0) {\n writer.print(' ');\n }\n writer.print(objects[i]);\n }\n }\n\n public void println() {\n writer.println();\n }\n\n public void println(Object... objects) {\n print(objects);\n writer.println();\n }\n\n public void close() {\n writer.close();\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1535574256, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03689.html", "problem_id": "p03689", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03689/input.txt", "sample_output_relpath": "derived/input_output/data/p03689/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03689/Java/s283719882.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s283719882", "user_id": "u485601469"}, "prompt_components": {"gold_output": "Yes\n1 1 1\n1 -4 1\n1 1 1\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.io.BufferedWriter;\nimport java.io.Writer;\nimport java.io.OutputStreamWriter;\nimport java.util.InputMismatchException;\nimport java.io.IOException;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author prakharjain\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n OutputWriter out = new OutputWriter(outputStream);\n agc016c solver = new agc016c();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class agc016c {\n public void solve(int testNumber, InputReader in, OutputWriter out) {\n int r = in.nextInt();\n int c = in.nextInt();\n\n int h = in.nextInt();\n int w = in.nextInt();\n\n int neg = -h * w;\n\n int[][] ans = new int[r][c];\n\n for (int i = 0; i < r; i++) {\n for (int j = 0; j < c; j++) {\n ans[i][j] = 1;\n }\n }\n\n for (int i = h - 1; i < r; i += h) {\n for (int j = w - 1; j < c; j += w) {\n ans[i][j] = neg;\n }\n }\n\n long sum = 0;\n for (int i = 0; i < r; i++) {\n for (int j = 0; j < c; j++) {\n sum += ans[i][j];\n }\n }\n\n if (sum > 0) {\n out.println(\"Yes\");\n for (int i = 0; i < r; i++) {\n for (int j = 0; j < c; j++) {\n out.print(ans[i][j] + \" \");\n }\n out.println();\n }\n } else {\n out.print(\"No\");\n }\n }\n\n }\n\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private InputReader.SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n\n public static boolean isWhitespace(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n public int read() {\n if (numChars == -1) {\n throw new InputMismatchException();\n }\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0) {\n return -1;\n }\n }\n return buf[curChar++];\n }\n\n public int nextInt() {\n int c = read();\n while (isSpaceChar(c)) {\n c = read();\n }\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n res *= 10;\n res += c - '0';\n c = read();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n\n public boolean isSpaceChar(int c) {\n if (filter != null) {\n return filter.isSpaceChar(c);\n }\n return isWhitespace(c);\n }\n\n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n\n }\n\n }\n\n static class OutputWriter {\n private final PrintWriter writer;\n\n public OutputWriter(OutputStream outputStream) {\n writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));\n }\n\n public OutputWriter(Writer writer) {\n this.writer = new PrintWriter(writer);\n }\n\n public void print(Object... objects) {\n for (int i = 0; i < objects.length; i++) {\n if (i != 0) {\n writer.print(' ');\n }\n writer.print(objects[i]);\n }\n }\n\n public void println() {\n writer.println();\n }\n\n public void println(Object... objects) {\n print(objects);\n writer.println();\n }\n\n public void close() {\n writer.close();\n }\n\n }\n}\n\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nYou are given four integers: H, W, h and w (1 ≤ h ≤ H, 1 ≤ w ≤ W).\nDetermine whether there exists a matrix such that all of the following conditions are held, and construct one such matrix if the answer is positive:\n\nThe matrix has H rows and W columns.\n\nEach element of the matrix is an integer between -10^9 and 10^9 (inclusive).\n\nThe sum of all the elements of the matrix is positive.\n\nThe sum of all the elements within every subrectangle with h rows and w columns in the matrix is negative.\n\nConstraints\n\n1 ≤ h ≤ H ≤ 500\n\n1 ≤ w ≤ W ≤ 500\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W h w\n\nOutput\n\nIf there does not exist a matrix that satisfies all of the conditions, print No.\n\nOtherwise, print Yes in the first line, and print a matrix in the subsequent lines in the following format:\n\na_{11} ... a_{1W}\n:\na_{H1} ... a_{HW}\n\nHere, a_{ij} represents the (i,\\ j) element of the matrix.\n\nSample Input 1\n\n3 3 2 2\n\nSample Output 1\n\nYes\n1 1 1\n1 -4 1\n1 1 1\n\nThe sum of all the elements of this matrix is 4, which is positive.\nAlso, in this matrix, there are four subrectangles with 2 rows and 2 columns as shown below. For each of them, the sum of all the elements inside is -1, which is negative.\n\nSample Input 2\n\n2 4 1 2\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n3 4 2 3\n\nSample Output 3\n\nYes\n2 -5 8 7\n3 -5 -4 -5\n2 1 -1 7", "sample_input": "3 3 2 2\n"}, "reference_outputs": ["Yes\n1 1 1\n1 -4 1\n1 1 1\n"], "source_document_id": "p03689", "source_text": "Score : 700 points\n\nProblem Statement\n\nYou are given four integers: H, W, h and w (1 ≤ h ≤ H, 1 ≤ w ≤ W).\nDetermine whether there exists a matrix such that all of the following conditions are held, and construct one such matrix if the answer is positive:\n\nThe matrix has H rows and W columns.\n\nEach element of the matrix is an integer between -10^9 and 10^9 (inclusive).\n\nThe sum of all the elements of the matrix is positive.\n\nThe sum of all the elements within every subrectangle with h rows and w columns in the matrix is negative.\n\nConstraints\n\n1 ≤ h ≤ H ≤ 500\n\n1 ≤ w ≤ W ≤ 500\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W h w\n\nOutput\n\nIf there does not exist a matrix that satisfies all of the conditions, print No.\n\nOtherwise, print Yes in the first line, and print a matrix in the subsequent lines in the following format:\n\na_{11} ... a_{1W}\n:\na_{H1} ... a_{HW}\n\nHere, a_{ij} represents the (i,\\ j) element of the matrix.\n\nSample Input 1\n\n3 3 2 2\n\nSample Output 1\n\nYes\n1 1 1\n1 -4 1\n1 1 1\n\nThe sum of all the elements of this matrix is 4, which is positive.\nAlso, in this matrix, there are four subrectangles with 2 rows and 2 columns as shown below. For each of them, the sum of all the elements inside is -1, which is negative.\n\nSample Input 2\n\n2 4 1 2\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n3 4 2 3\n\nSample Output 3\n\nYes\n2 -5 8 7\n3 -5 -4 -5\n2 1 -1 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": 4741, "cpu_time_ms": 252, "memory_kb": 47656}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s450160285", "group_id": "codeNet:p03693", "input_text": "import java.util.*;\nimport java.io.*;\n\npublic class Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint r = sc.nextInt();\n\t\tint g = sc.nextInt();\n\t\tint b = sc.nextInt();\n\n\t\tint num = r*100 + g*10 + b;\n\t\tif(num%4 == 0){\n\t\t\tSystem.out.println(\"YES\");\n\t\t}else{\n\t\t\tSystem.out.println(\"NO\");\n\t\t}\n\t}\n}\n", "language": "Java", "metadata": {"date": 1497143198, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03693.html", "problem_id": "p03693", "resource_group": "high_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/Java/s450160285.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s450160285", "user_id": "u527007629"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.util.*;\nimport java.io.*;\n\npublic class Main{\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint r = sc.nextInt();\n\t\tint g = sc.nextInt();\n\t\tint b = sc.nextInt();\n\n\t\tint num = r*100 + g*10 + b;\n\t\tif(num%4 == 0){\n\t\t\tSystem.out.println(\"YES\");\n\t\t}else{\n\t\t\tSystem.out.println(\"NO\");\n\t\t}\n\t}\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": 336, "cpu_time_ms": 92, "memory_kb": 21716}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s511906303", "group_id": "codeNet:p03695", "input_text": "\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.math.BigInteger;\nimport java.util.*;\nimport java.util.stream.IntStream;\nimport java.util.stream.LongStream;\n\npublic class Main {\n\n public Main() throws IOException {\n }\n\n public static void main(String[] args) throws IOException {\n new Main().solve();\n }\n\n // private final InputStream in = Files.newInputStream(Paths.get(\"C:\\\\Users\\\\ryo.suzuki\\\\Downloads\\\\02.txt\"));\n private final InputStream in = System.in;\n private final PrintWriter out = new PrintWriter(System.out);\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private void solve() throws IOException {\n try {\n// solveA();\n solveB();\n// solveC();\n// solveD();\n// solveE();\n// solveF();\n } finally {\n if (in != null) {\n in.close();\n }\n if (out != null) {\n out.flush();\n out.close();\n }\n }\n\n }\n\n // mods\n long MOD = (long) Math.pow(10, 9) + 7;\n\n private void solveA() {\n String s = next();\n out.println(s.substring(0, s.length() - 1) + \"5\");\n }\n\n private void solveB() {\n int n = nextInt();\n int[] a = IntStream.range(0, n).map(i -> nextInt()).toArray();\n Set set = new HashSet();\n int gold = 0;\n for (int aw : a) {\n if (aw < 400)\n set.add(1);\n else if (aw < 800)\n set.add(2);\n else if (aw < 1200)\n set.add(3);\n else if (aw < 1600)\n set.add(4);\n else if (aw < 2000)\n set.add(5);\n else if (aw < 2400)\n set.add(6);\n else if (aw < 2800)\n set.add(7);\n else if (aw < 3200)\n set.add(8);\n else\n gold++;\n }\n out.println(set.size() + \" \" + Math.min(set.size() + gold, 8));\n\n }\n\n private void solveC() {\n\n }\n\n private void solveD() {\n\n }\n\n private void solveE() {\n\n }\n\n private void solveF() {\n\n }\n\n static final long CONST_INF = Long.MAX_VALUE / 4;\n\n\n private static class VectorCalculation {\n /**\n * 点Pと線(AB)の距離\n *\n * @param p\n * @param a\n * @param b\n * @return\n */\n private double distanceDotAndLine(DoublePair p, DoublePair a, DoublePair b) {\n DoublePair ab = new DoublePair(b.x - a.x, b.y - a.y);\n DoublePair ap = new DoublePair(p.x - a.x, p.y - a.y);\n\n // ベクトルAB、APの外積の絶対値が平行四辺形Dの面積になる\n double d = Math.abs(crossVector(ab, ap));\n\n double l = distanceVertex(a, b); // AB間の距離\n\n double h = d / l;\n return h;\n }\n\n /**\n * 2点間距離\n *\n * @param p1\n * @param p2\n * @return\n */\n private double distanceVertex(DoublePair p1, DoublePair p2) {\n double dx = p1.x - p2.x;\n double dy = p1.y - p2.y;\n return Math.sqrt(dx * dx + dy * dy);\n }\n\n /**\n * ベクトル外積\n *\n * @param vl\n * @param vr\n * @return\n */\n private double crossVector(DoublePair vl, DoublePair vr) {\n return vl.x * vr.y - vl.y * vr.x;\n }\n }\n\n private static class DoublePair implements Comparable {\n double x;\n double y;\n\n public DoublePair(double k, double v) {\n this.x = k;\n this.y = v;\n }\n\n public int compareTo(DoublePair pair) {\n return Double.compare(this.y, pair.y);\n }\n }\n\n private static class SimplePair implements Comparable {\n long k;\n long v;\n\n public SimplePair(int k, int v) {\n this.k = k;\n this.v = v;\n }\n\n public SimplePair(long k, long v) {\n this.k = k;\n this.v = v;\n }\n\n public int compareTo(SimplePair pair) {\n return Long.compare(this.v, pair.v);\n }\n }\n\n\n private static class SimpleGraphNode {\n private int n;\n private Map childs;\n\n public SimpleGraphNode(int n) {\n this.n = n;\n childs = new HashMap();\n }\n\n public void addChild(int child, int d) {\n this.childs.put(child, d);\n }\n }\n\n private static class SimpleGraph {\n\n private Map graph;\n\n public SimpleGraph(int[][] list) {\n graph = new HashMap();\n Arrays.stream(list).forEach(l -> {\n int a = l[0];\n int b = l[1];\n int d = l[2];\n graph.put(a, graph.getOrDefault(a, new SimpleGraphNode(a)));\n graph.get(a).addChild(b, d);\n graph.put(b, graph.getOrDefault(b, new SimpleGraphNode(b)));\n graph.get(b).addChild(a, d);\n });\n }\n\n public SimpleGraphNode getNode(int i) {\n return graph.getOrDefault(i, new SimpleGraphNode(-1));\n }\n\n }\n\n private static class GraphNode {\n private long n;\n private Map childs;\n\n public GraphNode(long n) {\n this.n = n;\n childs = new TreeMap();\n }\n\n /**\n * not update\n *\n * @param child\n * @param d\n */\n public void addChild(long child, long d) {\n this.childs.put(child, this.childs.getOrDefault(child, new SimplePair(child, d)));\n }\n\n public SimplePair getChild(long child) {\n return this.childs.getOrDefault(child, new SimplePair(child, CONST_INF));\n }\n }\n\n private static class Graph {\n\n private Map graph;\n int n;\n\n /**\n * @param n 頂点数\n * @param list\n */\n public Graph(int n, int[][] list) {\n this.n = n;\n graph = new HashMap();\n /*\n 隣接行列作成\n 0-indexed\n */\n Arrays.stream(list).forEach(l -> {\n long a = l[0] - 1;\n long b = l[1] - 1;\n long d = l[2];\n graph.put(a, graph.getOrDefault(a, new GraphNode(a)));\n graph.get(a).addChild(b, d);\n graph.put(b, graph.getOrDefault(b, new GraphNode(b)));\n graph.get(b).addChild(a, d);\n });\n /*\n たどり着けない場所はCONST_INFで埋める\n 自分へはCOST=0でたどり着ける\n */\n for (long i = 0; i < n; i++) {\n graph.put(i, graph.getOrDefault(i, new GraphNode(i)));\n GraphNode node = graph.get(i);\n for (int j = 0; j < n; j++) {\n if (i == j)\n node.addChild(j, 0L);\n else\n node.addChild(j, CONST_INF);\n }\n }\n }\n\n /**\n * ワーシャルフロイド\n */\n public void warshallFloyd() {\n for (long k = 0; k < n; k++) {\n for (long i = 0; i < n; i++) {\n for (long j = 0; j < n; j++) {\n long min = Math.min(graph.get(i).getChild(j).v, graph.get(i).getChild(k).v + graph.get(k).getChild(j).v);\n graph.get(i).getChild(j).v = min;\n }\n }\n }\n }\n\n public void partialUpdateAndWarshallFloyd(long x, long y, long w) {\n if (graph.get(x).getChild(y).v > w)\n graph.get(x).getChild(y).v = graph.get(y).getChild(x).v = w;\n long[] l = {x, y};\n for (long k : l) {\n for (long i = 0; i < n; i++) {\n for (long j = 0; j < n; j++) {\n if (graph.get(i).getChild(j).v > graph.get(i).getChild(k).v + graph.get(k).getChild(j).v) {\n graph.get(i).getChild(j).v = graph.get(i).getChild(k).v + graph.get(k).getChild(j).v;\n }\n }\n }\n }\n }\n\n /**\n * 2点間の距離\n *\n * @param from\n * @param to\n * @return\n */\n public long getDistance(long from, long to) {\n return graph.get(from).getChild(to).v;\n }\n\n }\n\n public long calcSimpleCombination(long n, long m, long CONST_MOD) {\n long mole = 1;\n for (long i = 1; i <= n + m; i++) {\n mole *= i;\n mole %= CONST_MOD;\n }\n long deno = 1;\n for (long i = 1; i <= n; i++) {\n deno *= i;\n deno %= CONST_MOD;\n }\n for (int i = 1; i <= m; i++) {\n deno *= i;\n deno %= CONST_MOD;\n }\n deno = modInverse(deno, CONST_MOD);\n return (mole * deno) % CONST_MOD;\n }\n\n long abs(double x) {\n return (long) Math.abs(x);\n }\n\n long round(double x) {\n return Math.round(x);\n }\n\n long floor(double x) {\n return (long) Math.floor(x);\n }\n\n long ceil(double x) {\n return (long) Math.ceil(x);\n }\n\n double sqrt(double x) {\n return Math.sqrt(x);\n }\n\n double pow(double x, double y) {\n return Math.pow(x, y);\n }\n\n long pow(long x, long y) {\n return (long) Math.pow(x, y);\n }\n\n int gcd(int a, int b) {\n return b == 0 ? a : gcd(b, a % b);\n }\n\n long gcd(long a, long b) {\n return b == 0 ? a : gcd(b, a % b);\n }\n\n long lcm(long a, long b) {\n return a * b / gcd(a, b);\n }\n\n public long lcmMod(long... ab) {\n\n Map ps = new HashMap();\n\n for (int abl = 0; abl < ab.length; abl++) {\n long target = ab[abl];\n long l = target;\n for (long p = 2; p * p <= l; p++) {\n long cnt = 0;\n while (target > 1 && target % p == 0) {\n cnt++;\n target /= p;\n }\n if (cnt == 0)\n continue;\n ps.put(p, Long.max(cnt, ps.getOrDefault(p, 0L)));\n }\n if (target > 1)\n ps.put(target, Long.max(1, ps.getOrDefault(target, 0L)));\n }\n long res = 1L;\n for (Map.Entry e : ps.entrySet()) {\n res *= powMod(e.getKey(), e.getValue());\n res %= MOD;\n }\n return res;\n }\n\n int upperToInt(char a) {\n return a - 'A';\n }\n\n int lowerToInt(char a) {\n return a - 'a';\n }\n\n int numToInt(char a) {\n return a - '0';\n }\n\n int charToInt(char a) {\n return a >= 'a' ? lowerToInt(a) : a >= 'A' ? upperToInt(a) : numToInt(a);\n }\n\n char intToUpper(int a) {\n return (char) (a + 'A');\n }\n\n char intToLower(int a) {\n return (char) (a + 'a');\n }\n\n char intToNum(int a) {\n return (char) (a + '0');\n }\n\n void reverse(String array[]) {\n String reversed[] = new String[array.length];\n for (int i = 0; i < array.length; i++) {\n reversed[array.length - i - 1] = array[i];\n }\n for (int i = 0; i < array.length; i++) {\n array[i] = reversed[i];\n }\n }\n\n void reverse(int array[]) {\n int reversed[] = new int[array.length];\n for (int i = 0; i < array.length; i++) {\n reversed[array.length - i - 1] = array[i];\n }\n for (int i = 0; i < array.length; i++) {\n array[i] = reversed[i];\n }\n }\n\n void reverse(long array[]) {\n long reversed[] = new long[array.length];\n for (int i = 0; i < array.length; i++) {\n reversed[array.length - i - 1] = array[i];\n }\n for (int i = 0; i < array.length; i++) {\n array[i] = reversed[i];\n }\n }\n\n void reverse(double array[]) {\n double reversed[] = new double[array.length];\n for (int i = 0; i < array.length; i++) {\n reversed[array.length - i - 1] = array[i];\n }\n for (int i = 0; i < array.length; i++) {\n array[i] = reversed[i];\n }\n }\n\n void reverse(boolean array[]) {\n boolean reversed[] = new boolean[array.length];\n for (int i = 0; i < array.length; i++) {\n reversed[array.length - i - 1] = array[i];\n }\n for (int i = 0; i < array.length; i++) {\n array[i] = reversed[i];\n }\n }\n\n void fill(int array[][], int x) {\n for (int a[] : array) {\n Arrays.fill(a, x);\n }\n }\n\n void fill(long array[][], long x) {\n for (long a[] : array) {\n Arrays.fill(a, x);\n }\n }\n\n void fill(double array[][], double x) {\n for (double a[] : array) {\n Arrays.fill(a, x);\n }\n }\n\n void fill(boolean array[][], boolean x) {\n for (boolean a[] : array) {\n Arrays.fill(a, x);\n }\n }\n\n void fill(int array[][][], int x) {\n for (int a[][] : array) {\n fill(a, x);\n }\n }\n\n void fill(long array[][][], long x) {\n for (long a[][] : array) {\n fill(a, x);\n }\n }\n\n void fill(double array[][][], double x) {\n for (double a[][] : array) {\n fill(a, x);\n }\n }\n\n void fill(boolean array[][][], boolean x) {\n for (boolean a[][] : array) {\n fill(a, x);\n }\n }\n\n long L_INF = (long) 1e18 + 7;\n\n boolean isINF(long a) {\n return abs(a) > L_INF / 1000;\n }\n\n boolean isPlusINF(long a) {\n return a > 0 && isINF(a);\n }\n\n boolean isMinusINF(long a) {\n return isPlusINF(-a);\n }\n\n int I_INF = (int) 1e9 + 7;\n\n boolean isINF(int a) {\n return abs(a) > I_INF / 1000;\n }\n\n boolean isPlusINF(int a) {\n return a > 0 && isINF(a);\n }\n\n boolean isMinusINF(int a) {\n return isPlusINF(-a);\n }\n\n /**\n * 指定したx以下の素数をリストアップする\n */\n public long[] getPrimesUnderX(long x) {\n return LongStream.rangeClosed(2, x)\n .filter(i -> LongStream.rangeClosed(2, (long) Math.sqrt(i)).allMatch(j -> i % j != 0)).toArray();\n }\n\n\n public long mod(long i) {\n return i % MOD + ((i % MOD) < 0 ? MOD : 0);\n }\n\n long powMod(long x, long y) {\n if (y == 0) {\n return 1;\n } else {\n long tmp = powMod(x, y / 2);\n return mod(mod(tmp * tmp) * (y % 2 == 0 ? 1 : x));\n }\n }\n\n long inv(long x) {\n return powMod(x, MOD - 2);\n }\n\n int MAX_FACT = 5_000_100;\n long fact[];\n long invFact[];\n\n /**\n * Combination簡易版\n * 5 C 2\n * 異なる n個のものから r個を選ぶ組み合わせの総数 nCr を求めます。\n * 5!(5*4*3*2*1)\n * /\n * 2!(2*1) * (5-2)!(3*2*1)\n *\n * @param n\n * @param r\n * @return\n */\n private long getComb(int n, int r) {\n long tmp = 1;\n for (int i = 1; i <= r; i++) {\n tmp *= n - i + 1;\n tmp = mod(tmp);\n tmp *= inv(i);\n tmp = mod(tmp);\n }\n return tmp;\n }\n\n /**\n * 階乗計算の事前累積和\n * [1, 1, 2, 3, 4, 5, … FACTORIAL_NUM]\n * mod済\n */\n void prepareFact() {\n fact = new long[MAX_FACT];\n Arrays.fill(fact, 0);\n invFact = new long[MAX_FACT];\n Arrays.fill(invFact, 0);\n fact[0] = 1;\n int maxIndex = (int) min(MAX_FACT, (int) MOD);\n for (int i = 1; i < maxIndex; i++) {\n fact[i] = mod(fact[i - 1] * i);\n }\n invFact[maxIndex - 1] = inv(fact[maxIndex - 1]);\n for (int i = maxIndex - 1; i > 0; i--) {\n invFact[i - 1] = mod(invFact[i] * i);\n }\n }\n\n /**\n * 順列\n * nPk -> n! / (n-k)!\n *\n * @param n\n * @param r\n * @return\n */\n long permutation(int n, int r) {\n if (n < 0 || r < 0 || n < r) {\n return 0;\n }\n return mod(fact[n] * invFact[n - r]);\n }\n\n /**\n * 組み合わせ\n * nCk -> n! / k!・(n-k)!\n *\n * @param n\n * @param r\n * @return\n */\n long combination(int n, int r) {\n if (n < 0 || r < 0 || n < r) {\n return 0;\n }\n return mod(permutation(n, r) * invFact[r]);\n }\n\n /**\n * 重複組合せ nHr (同次積)\n * nHr = (n+r-1)Cr\n * 異なるn個のものから重複を許してr個取る組合せの総数\n * 例:\n * リンゴ,ミカン,牛肉の3種類の果物があります.これらの中から6個の食材を買って帰ります.\n * このとき,何通りの買い方がありますか?ただし,含まれない食材があってもよいものとします\n *\n * @param n\n * @param r\n * @return\n */\n long homogeneousProduct(int n, int r) {\n return combination((n - 1) + r, r);\n }\n\n /**\n * 多項係数\n * 文字aをp個,bをq個,cをr個, dをs個 あわせてn個を1列に並べるときの並べ方\n * n! / p!・q!・r!・s!\n *\n * @param n\n * @param strNum\n * @param mod\n * @return\n */\n\n /**\n * フェルマーの小定理を用いて逆元を求める。\n * ある数xのmod p(pは素数)の逆数x'はx' = x^(p-2)\n * 繰り返し二乗法を用いて計算する。\n * http://satanic0258.hatenablog.com/entry/2016/04/29/004730\n * {@link BigInteger#modInverse(BigInteger)}とどちらが速いか?\n *\n * @param x\n * @return\n */\n private long modInverse(long x, long mod) {\n long res = 1L;\n long k = mod - 2L;\n long y = x;\n while (k != 0) {\n if (k % 2 != 0) {\n res = (res * y) % mod;\n }\n y = (y * y) % mod;\n k /= 2;\n }\n return res;\n }\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte())\n return buffer[ptr++];\n else\n return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n private void skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr]))\n ptr++;\n }\n\n public boolean hasNext() {\n skipUnprintable();\n return hasNextByte();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n public String next() {\n if (!hasNext())\n throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext())\n throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public long min(long... v) {\n long min = Long.MAX_VALUE;\n for (long i : v) min = Math.min(min, i);\n return min;\n }\n\n public long max(long... v) {\n long max = Long.MIN_VALUE;\n for (long i : v) max = Math.max(max, i);\n return max;\n }\n}\n", "language": "Java", "metadata": {"date": 1586275484, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03695.html", "problem_id": "p03695", "resource_group": "high_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/Java/s511906303.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s511906303", "user_id": "u345932819"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.math.BigInteger;\nimport java.util.*;\nimport java.util.stream.IntStream;\nimport java.util.stream.LongStream;\n\npublic class Main {\n\n public Main() throws IOException {\n }\n\n public static void main(String[] args) throws IOException {\n new Main().solve();\n }\n\n // private final InputStream in = Files.newInputStream(Paths.get(\"C:\\\\Users\\\\ryo.suzuki\\\\Downloads\\\\02.txt\"));\n private final InputStream in = System.in;\n private final PrintWriter out = new PrintWriter(System.out);\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private void solve() throws IOException {\n try {\n// solveA();\n solveB();\n// solveC();\n// solveD();\n// solveE();\n// solveF();\n } finally {\n if (in != null) {\n in.close();\n }\n if (out != null) {\n out.flush();\n out.close();\n }\n }\n\n }\n\n // mods\n long MOD = (long) Math.pow(10, 9) + 7;\n\n private void solveA() {\n String s = next();\n out.println(s.substring(0, s.length() - 1) + \"5\");\n }\n\n private void solveB() {\n int n = nextInt();\n int[] a = IntStream.range(0, n).map(i -> nextInt()).toArray();\n Set set = new HashSet();\n int gold = 0;\n for (int aw : a) {\n if (aw < 400)\n set.add(1);\n else if (aw < 800)\n set.add(2);\n else if (aw < 1200)\n set.add(3);\n else if (aw < 1600)\n set.add(4);\n else if (aw < 2000)\n set.add(5);\n else if (aw < 2400)\n set.add(6);\n else if (aw < 2800)\n set.add(7);\n else if (aw < 3200)\n set.add(8);\n else\n gold++;\n }\n out.println(set.size() + \" \" + Math.min(set.size() + gold, 8));\n\n }\n\n private void solveC() {\n\n }\n\n private void solveD() {\n\n }\n\n private void solveE() {\n\n }\n\n private void solveF() {\n\n }\n\n static final long CONST_INF = Long.MAX_VALUE / 4;\n\n\n private static class VectorCalculation {\n /**\n * 点Pと線(AB)の距離\n *\n * @param p\n * @param a\n * @param b\n * @return\n */\n private double distanceDotAndLine(DoublePair p, DoublePair a, DoublePair b) {\n DoublePair ab = new DoublePair(b.x - a.x, b.y - a.y);\n DoublePair ap = new DoublePair(p.x - a.x, p.y - a.y);\n\n // ベクトルAB、APの外積の絶対値が平行四辺形Dの面積になる\n double d = Math.abs(crossVector(ab, ap));\n\n double l = distanceVertex(a, b); // AB間の距離\n\n double h = d / l;\n return h;\n }\n\n /**\n * 2点間距離\n *\n * @param p1\n * @param p2\n * @return\n */\n private double distanceVertex(DoublePair p1, DoublePair p2) {\n double dx = p1.x - p2.x;\n double dy = p1.y - p2.y;\n return Math.sqrt(dx * dx + dy * dy);\n }\n\n /**\n * ベクトル外積\n *\n * @param vl\n * @param vr\n * @return\n */\n private double crossVector(DoublePair vl, DoublePair vr) {\n return vl.x * vr.y - vl.y * vr.x;\n }\n }\n\n private static class DoublePair implements Comparable {\n double x;\n double y;\n\n public DoublePair(double k, double v) {\n this.x = k;\n this.y = v;\n }\n\n public int compareTo(DoublePair pair) {\n return Double.compare(this.y, pair.y);\n }\n }\n\n private static class SimplePair implements Comparable {\n long k;\n long v;\n\n public SimplePair(int k, int v) {\n this.k = k;\n this.v = v;\n }\n\n public SimplePair(long k, long v) {\n this.k = k;\n this.v = v;\n }\n\n public int compareTo(SimplePair pair) {\n return Long.compare(this.v, pair.v);\n }\n }\n\n\n private static class SimpleGraphNode {\n private int n;\n private Map childs;\n\n public SimpleGraphNode(int n) {\n this.n = n;\n childs = new HashMap();\n }\n\n public void addChild(int child, int d) {\n this.childs.put(child, d);\n }\n }\n\n private static class SimpleGraph {\n\n private Map graph;\n\n public SimpleGraph(int[][] list) {\n graph = new HashMap();\n Arrays.stream(list).forEach(l -> {\n int a = l[0];\n int b = l[1];\n int d = l[2];\n graph.put(a, graph.getOrDefault(a, new SimpleGraphNode(a)));\n graph.get(a).addChild(b, d);\n graph.put(b, graph.getOrDefault(b, new SimpleGraphNode(b)));\n graph.get(b).addChild(a, d);\n });\n }\n\n public SimpleGraphNode getNode(int i) {\n return graph.getOrDefault(i, new SimpleGraphNode(-1));\n }\n\n }\n\n private static class GraphNode {\n private long n;\n private Map childs;\n\n public GraphNode(long n) {\n this.n = n;\n childs = new TreeMap();\n }\n\n /**\n * not update\n *\n * @param child\n * @param d\n */\n public void addChild(long child, long d) {\n this.childs.put(child, this.childs.getOrDefault(child, new SimplePair(child, d)));\n }\n\n public SimplePair getChild(long child) {\n return this.childs.getOrDefault(child, new SimplePair(child, CONST_INF));\n }\n }\n\n private static class Graph {\n\n private Map graph;\n int n;\n\n /**\n * @param n 頂点数\n * @param list\n */\n public Graph(int n, int[][] list) {\n this.n = n;\n graph = new HashMap();\n /*\n 隣接行列作成\n 0-indexed\n */\n Arrays.stream(list).forEach(l -> {\n long a = l[0] - 1;\n long b = l[1] - 1;\n long d = l[2];\n graph.put(a, graph.getOrDefault(a, new GraphNode(a)));\n graph.get(a).addChild(b, d);\n graph.put(b, graph.getOrDefault(b, new GraphNode(b)));\n graph.get(b).addChild(a, d);\n });\n /*\n たどり着けない場所はCONST_INFで埋める\n 自分へはCOST=0でたどり着ける\n */\n for (long i = 0; i < n; i++) {\n graph.put(i, graph.getOrDefault(i, new GraphNode(i)));\n GraphNode node = graph.get(i);\n for (int j = 0; j < n; j++) {\n if (i == j)\n node.addChild(j, 0L);\n else\n node.addChild(j, CONST_INF);\n }\n }\n }\n\n /**\n * ワーシャルフロイド\n */\n public void warshallFloyd() {\n for (long k = 0; k < n; k++) {\n for (long i = 0; i < n; i++) {\n for (long j = 0; j < n; j++) {\n long min = Math.min(graph.get(i).getChild(j).v, graph.get(i).getChild(k).v + graph.get(k).getChild(j).v);\n graph.get(i).getChild(j).v = min;\n }\n }\n }\n }\n\n public void partialUpdateAndWarshallFloyd(long x, long y, long w) {\n if (graph.get(x).getChild(y).v > w)\n graph.get(x).getChild(y).v = graph.get(y).getChild(x).v = w;\n long[] l = {x, y};\n for (long k : l) {\n for (long i = 0; i < n; i++) {\n for (long j = 0; j < n; j++) {\n if (graph.get(i).getChild(j).v > graph.get(i).getChild(k).v + graph.get(k).getChild(j).v) {\n graph.get(i).getChild(j).v = graph.get(i).getChild(k).v + graph.get(k).getChild(j).v;\n }\n }\n }\n }\n }\n\n /**\n * 2点間の距離\n *\n * @param from\n * @param to\n * @return\n */\n public long getDistance(long from, long to) {\n return graph.get(from).getChild(to).v;\n }\n\n }\n\n public long calcSimpleCombination(long n, long m, long CONST_MOD) {\n long mole = 1;\n for (long i = 1; i <= n + m; i++) {\n mole *= i;\n mole %= CONST_MOD;\n }\n long deno = 1;\n for (long i = 1; i <= n; i++) {\n deno *= i;\n deno %= CONST_MOD;\n }\n for (int i = 1; i <= m; i++) {\n deno *= i;\n deno %= CONST_MOD;\n }\n deno = modInverse(deno, CONST_MOD);\n return (mole * deno) % CONST_MOD;\n }\n\n long abs(double x) {\n return (long) Math.abs(x);\n }\n\n long round(double x) {\n return Math.round(x);\n }\n\n long floor(double x) {\n return (long) Math.floor(x);\n }\n\n long ceil(double x) {\n return (long) Math.ceil(x);\n }\n\n double sqrt(double x) {\n return Math.sqrt(x);\n }\n\n double pow(double x, double y) {\n return Math.pow(x, y);\n }\n\n long pow(long x, long y) {\n return (long) Math.pow(x, y);\n }\n\n int gcd(int a, int b) {\n return b == 0 ? a : gcd(b, a % b);\n }\n\n long gcd(long a, long b) {\n return b == 0 ? a : gcd(b, a % b);\n }\n\n long lcm(long a, long b) {\n return a * b / gcd(a, b);\n }\n\n public long lcmMod(long... ab) {\n\n Map ps = new HashMap();\n\n for (int abl = 0; abl < ab.length; abl++) {\n long target = ab[abl];\n long l = target;\n for (long p = 2; p * p <= l; p++) {\n long cnt = 0;\n while (target > 1 && target % p == 0) {\n cnt++;\n target /= p;\n }\n if (cnt == 0)\n continue;\n ps.put(p, Long.max(cnt, ps.getOrDefault(p, 0L)));\n }\n if (target > 1)\n ps.put(target, Long.max(1, ps.getOrDefault(target, 0L)));\n }\n long res = 1L;\n for (Map.Entry e : ps.entrySet()) {\n res *= powMod(e.getKey(), e.getValue());\n res %= MOD;\n }\n return res;\n }\n\n int upperToInt(char a) {\n return a - 'A';\n }\n\n int lowerToInt(char a) {\n return a - 'a';\n }\n\n int numToInt(char a) {\n return a - '0';\n }\n\n int charToInt(char a) {\n return a >= 'a' ? lowerToInt(a) : a >= 'A' ? upperToInt(a) : numToInt(a);\n }\n\n char intToUpper(int a) {\n return (char) (a + 'A');\n }\n\n char intToLower(int a) {\n return (char) (a + 'a');\n }\n\n char intToNum(int a) {\n return (char) (a + '0');\n }\n\n void reverse(String array[]) {\n String reversed[] = new String[array.length];\n for (int i = 0; i < array.length; i++) {\n reversed[array.length - i - 1] = array[i];\n }\n for (int i = 0; i < array.length; i++) {\n array[i] = reversed[i];\n }\n }\n\n void reverse(int array[]) {\n int reversed[] = new int[array.length];\n for (int i = 0; i < array.length; i++) {\n reversed[array.length - i - 1] = array[i];\n }\n for (int i = 0; i < array.length; i++) {\n array[i] = reversed[i];\n }\n }\n\n void reverse(long array[]) {\n long reversed[] = new long[array.length];\n for (int i = 0; i < array.length; i++) {\n reversed[array.length - i - 1] = array[i];\n }\n for (int i = 0; i < array.length; i++) {\n array[i] = reversed[i];\n }\n }\n\n void reverse(double array[]) {\n double reversed[] = new double[array.length];\n for (int i = 0; i < array.length; i++) {\n reversed[array.length - i - 1] = array[i];\n }\n for (int i = 0; i < array.length; i++) {\n array[i] = reversed[i];\n }\n }\n\n void reverse(boolean array[]) {\n boolean reversed[] = new boolean[array.length];\n for (int i = 0; i < array.length; i++) {\n reversed[array.length - i - 1] = array[i];\n }\n for (int i = 0; i < array.length; i++) {\n array[i] = reversed[i];\n }\n }\n\n void fill(int array[][], int x) {\n for (int a[] : array) {\n Arrays.fill(a, x);\n }\n }\n\n void fill(long array[][], long x) {\n for (long a[] : array) {\n Arrays.fill(a, x);\n }\n }\n\n void fill(double array[][], double x) {\n for (double a[] : array) {\n Arrays.fill(a, x);\n }\n }\n\n void fill(boolean array[][], boolean x) {\n for (boolean a[] : array) {\n Arrays.fill(a, x);\n }\n }\n\n void fill(int array[][][], int x) {\n for (int a[][] : array) {\n fill(a, x);\n }\n }\n\n void fill(long array[][][], long x) {\n for (long a[][] : array) {\n fill(a, x);\n }\n }\n\n void fill(double array[][][], double x) {\n for (double a[][] : array) {\n fill(a, x);\n }\n }\n\n void fill(boolean array[][][], boolean x) {\n for (boolean a[][] : array) {\n fill(a, x);\n }\n }\n\n long L_INF = (long) 1e18 + 7;\n\n boolean isINF(long a) {\n return abs(a) > L_INF / 1000;\n }\n\n boolean isPlusINF(long a) {\n return a > 0 && isINF(a);\n }\n\n boolean isMinusINF(long a) {\n return isPlusINF(-a);\n }\n\n int I_INF = (int) 1e9 + 7;\n\n boolean isINF(int a) {\n return abs(a) > I_INF / 1000;\n }\n\n boolean isPlusINF(int a) {\n return a > 0 && isINF(a);\n }\n\n boolean isMinusINF(int a) {\n return isPlusINF(-a);\n }\n\n /**\n * 指定したx以下の素数をリストアップする\n */\n public long[] getPrimesUnderX(long x) {\n return LongStream.rangeClosed(2, x)\n .filter(i -> LongStream.rangeClosed(2, (long) Math.sqrt(i)).allMatch(j -> i % j != 0)).toArray();\n }\n\n\n public long mod(long i) {\n return i % MOD + ((i % MOD) < 0 ? MOD : 0);\n }\n\n long powMod(long x, long y) {\n if (y == 0) {\n return 1;\n } else {\n long tmp = powMod(x, y / 2);\n return mod(mod(tmp * tmp) * (y % 2 == 0 ? 1 : x));\n }\n }\n\n long inv(long x) {\n return powMod(x, MOD - 2);\n }\n\n int MAX_FACT = 5_000_100;\n long fact[];\n long invFact[];\n\n /**\n * Combination簡易版\n * 5 C 2\n * 異なる n個のものから r個を選ぶ組み合わせの総数 nCr を求めます。\n * 5!(5*4*3*2*1)\n * /\n * 2!(2*1) * (5-2)!(3*2*1)\n *\n * @param n\n * @param r\n * @return\n */\n private long getComb(int n, int r) {\n long tmp = 1;\n for (int i = 1; i <= r; i++) {\n tmp *= n - i + 1;\n tmp = mod(tmp);\n tmp *= inv(i);\n tmp = mod(tmp);\n }\n return tmp;\n }\n\n /**\n * 階乗計算の事前累積和\n * [1, 1, 2, 3, 4, 5, … FACTORIAL_NUM]\n * mod済\n */\n void prepareFact() {\n fact = new long[MAX_FACT];\n Arrays.fill(fact, 0);\n invFact = new long[MAX_FACT];\n Arrays.fill(invFact, 0);\n fact[0] = 1;\n int maxIndex = (int) min(MAX_FACT, (int) MOD);\n for (int i = 1; i < maxIndex; i++) {\n fact[i] = mod(fact[i - 1] * i);\n }\n invFact[maxIndex - 1] = inv(fact[maxIndex - 1]);\n for (int i = maxIndex - 1; i > 0; i--) {\n invFact[i - 1] = mod(invFact[i] * i);\n }\n }\n\n /**\n * 順列\n * nPk -> n! / (n-k)!\n *\n * @param n\n * @param r\n * @return\n */\n long permutation(int n, int r) {\n if (n < 0 || r < 0 || n < r) {\n return 0;\n }\n return mod(fact[n] * invFact[n - r]);\n }\n\n /**\n * 組み合わせ\n * nCk -> n! / k!・(n-k)!\n *\n * @param n\n * @param r\n * @return\n */\n long combination(int n, int r) {\n if (n < 0 || r < 0 || n < r) {\n return 0;\n }\n return mod(permutation(n, r) * invFact[r]);\n }\n\n /**\n * 重複組合せ nHr (同次積)\n * nHr = (n+r-1)Cr\n * 異なるn個のものから重複を許してr個取る組合せの総数\n * 例:\n * リンゴ,ミカン,牛肉の3種類の果物があります.これらの中から6個の食材を買って帰ります.\n * このとき,何通りの買い方がありますか?ただし,含まれない食材があってもよいものとします\n *\n * @param n\n * @param r\n * @return\n */\n long homogeneousProduct(int n, int r) {\n return combination((n - 1) + r, r);\n }\n\n /**\n * 多項係数\n * 文字aをp個,bをq個,cをr個, dをs個 あわせてn個を1列に並べるときの並べ方\n * n! / p!・q!・r!・s!\n *\n * @param n\n * @param strNum\n * @param mod\n * @return\n */\n\n /**\n * フェルマーの小定理を用いて逆元を求める。\n * ある数xのmod p(pは素数)の逆数x'はx' = x^(p-2)\n * 繰り返し二乗法を用いて計算する。\n * http://satanic0258.hatenablog.com/entry/2016/04/29/004730\n * {@link BigInteger#modInverse(BigInteger)}とどちらが速いか?\n *\n * @param x\n * @return\n */\n private long modInverse(long x, long mod) {\n long res = 1L;\n long k = mod - 2L;\n long y = x;\n while (k != 0) {\n if (k % 2 != 0) {\n res = (res * y) % mod;\n }\n y = (y * y) % mod;\n k /= 2;\n }\n return res;\n }\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte())\n return buffer[ptr++];\n else\n return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n private void skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr]))\n ptr++;\n }\n\n public boolean hasNext() {\n skipUnprintable();\n return hasNextByte();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n public String next() {\n if (!hasNext())\n throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext())\n throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public long min(long... v) {\n long min = Long.MAX_VALUE;\n for (long i : v) min = Math.min(min, i);\n return min;\n }\n\n public long max(long... v) {\n long max = Long.MIN_VALUE;\n for (long i : v) max = Math.max(max, i);\n return 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": 20644, "cpu_time_ms": 201, "memory_kb": 27988}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s891239758", "group_id": "codeNet:p03701", "input_text": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws IOException {\n InputReader in = new InputReader();\n PrintWriter out = new PrintWriter(System.out);\n int test_cases = 1;\n Solver s = new Solver();\n for (int i = 1; i <= test_cases; i++)\n s.solve(1, in, out);\n out.close();\n }\n static class Solver {\n\n public void solve(int test_number, InputReader in, PrintWriter out) throws IOException {\n int n = in.nextInt();\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = in.nextInt();\n }\n Arrays.sort(a);\n int sum = 0;\n for (int i = n - 1; i >= 0; i--) {\n if ((sum + a[i]) % 10 == 0) continue;\n sum += a[i];\n }\n out.println(sum);\n }\n }\n static class InputReader {\n final private int BUFFER_SIZE = 1 << 16;\n private DataInputStream din;\n private byte[] buffer;\n private int bufferPointer, bytesRead;\n\n public InputReader()\n {\n din = new DataInputStream(System.in);\n buffer = new byte[BUFFER_SIZE];\n bufferPointer = bytesRead = 0;\n }\n\n public InputReader(String file_name) throws IOException\n {\n din = new DataInputStream(new FileInputStream(file_name));\n buffer = new byte[BUFFER_SIZE];\n bufferPointer = bytesRead = 0;\n }\n\n\n\n public String next() throws IOException {\n byte[] buf = new byte[64]; // line length\n int cnt = 0, c;\n while ((c = read()) != -1)\n {\n if (c == ' ' || c == '\\n')\n break;\n buf[cnt++] = (byte) c;\n }\n return new String(buf, 0, cnt);\n }\n\n public String nextLine() throws IOException\n {\n byte[] buf = new byte[64]; // line length\n int cnt = 0, c;\n while ((c = read()) != -1)\n {\n if (c == '\\n')\n break;\n buf[cnt++] = (byte) c;\n }\n return new String(buf, 0, cnt);\n }\n\n public int nextInt() throws IOException\n {\n int ret = 0;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n do\n {\n ret = ret * 10 + c - '0';\n } while ((c = read()) >= '0' && c <= '9');\n\n if (neg)\n return -ret;\n return ret;\n }\n\n public long nextLong() throws IOException\n {\n long ret = 0;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n do {\n ret = ret * 10 + c - '0';\n }\n while ((c = read()) >= '0' && c <= '9');\n if (neg)\n return -ret;\n return ret;\n }\n\n public double nextDouble() throws IOException\n {\n double ret = 0, div = 1;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n\n do {\n ret = ret * 10 + c - '0';\n }\n while ((c = read()) >= '0' && c <= '9');\n\n if (c == '.')\n {\n while ((c = read()) >= '0' && c <= '9')\n {\n ret += (c - '0') / (div *= 10);\n }\n }\n\n if (neg)\n return -ret;\n return ret;\n }\n\n private void fillBuffer() throws IOException\n {\n bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);\n if (bytesRead == -1)\n buffer[0] = -1;\n }\n\n private byte read() throws IOException\n {\n if (bufferPointer == bytesRead)\n fillBuffer();\n return buffer[bufferPointer++];\n }\n\n public void close() throws IOException\n {\n if (din == null)\n return;\n din.close();\n }\n }\n}", "language": "Java", "metadata": {"date": 1500077903, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03701.html", "problem_id": "p03701", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03701/input.txt", "sample_output_relpath": "derived/input_output/data/p03701/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03701/Java/s891239758.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s891239758", "user_id": "u632347647"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws IOException {\n InputReader in = new InputReader();\n PrintWriter out = new PrintWriter(System.out);\n int test_cases = 1;\n Solver s = new Solver();\n for (int i = 1; i <= test_cases; i++)\n s.solve(1, in, out);\n out.close();\n }\n static class Solver {\n\n public void solve(int test_number, InputReader in, PrintWriter out) throws IOException {\n int n = in.nextInt();\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = in.nextInt();\n }\n Arrays.sort(a);\n int sum = 0;\n for (int i = n - 1; i >= 0; i--) {\n if ((sum + a[i]) % 10 == 0) continue;\n sum += a[i];\n }\n out.println(sum);\n }\n }\n static class InputReader {\n final private int BUFFER_SIZE = 1 << 16;\n private DataInputStream din;\n private byte[] buffer;\n private int bufferPointer, bytesRead;\n\n public InputReader()\n {\n din = new DataInputStream(System.in);\n buffer = new byte[BUFFER_SIZE];\n bufferPointer = bytesRead = 0;\n }\n\n public InputReader(String file_name) throws IOException\n {\n din = new DataInputStream(new FileInputStream(file_name));\n buffer = new byte[BUFFER_SIZE];\n bufferPointer = bytesRead = 0;\n }\n\n\n\n public String next() throws IOException {\n byte[] buf = new byte[64]; // line length\n int cnt = 0, c;\n while ((c = read()) != -1)\n {\n if (c == ' ' || c == '\\n')\n break;\n buf[cnt++] = (byte) c;\n }\n return new String(buf, 0, cnt);\n }\n\n public String nextLine() throws IOException\n {\n byte[] buf = new byte[64]; // line length\n int cnt = 0, c;\n while ((c = read()) != -1)\n {\n if (c == '\\n')\n break;\n buf[cnt++] = (byte) c;\n }\n return new String(buf, 0, cnt);\n }\n\n public int nextInt() throws IOException\n {\n int ret = 0;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n do\n {\n ret = ret * 10 + c - '0';\n } while ((c = read()) >= '0' && c <= '9');\n\n if (neg)\n return -ret;\n return ret;\n }\n\n public long nextLong() throws IOException\n {\n long ret = 0;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n do {\n ret = ret * 10 + c - '0';\n }\n while ((c = read()) >= '0' && c <= '9');\n if (neg)\n return -ret;\n return ret;\n }\n\n public double nextDouble() throws IOException\n {\n double ret = 0, div = 1;\n byte c = read();\n while (c <= ' ')\n c = read();\n boolean neg = (c == '-');\n if (neg)\n c = read();\n\n do {\n ret = ret * 10 + c - '0';\n }\n while ((c = read()) >= '0' && c <= '9');\n\n if (c == '.')\n {\n while ((c = read()) >= '0' && c <= '9')\n {\n ret += (c - '0') / (div *= 10);\n }\n }\n\n if (neg)\n return -ret;\n return ret;\n }\n\n private void fillBuffer() throws IOException\n {\n bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);\n if (bytesRead == -1)\n buffer[0] = -1;\n }\n\n private byte read() throws IOException\n {\n if (bufferPointer == bytesRead)\n fillBuffer();\n return buffer[bufferPointer++];\n }\n\n public void close() throws IOException\n {\n if (din == null)\n return;\n din.close();\n }\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either \"correct\" or \"incorrect\", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.\n\nHowever, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 100\n\n1 ≤ s_i ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the maximum value that can be displayed as your grade.\n\nSample Input 1\n\n3\n5\n10\n15\n\nSample Output 1\n\n25\n\nYour grade will be 25 if the 10-point and 15-point questions are answered correctly and the 5-point question is not, and this grade will be displayed correctly. Your grade will become 30 if the 5-point question is also answered correctly, but this grade will be incorrectly displayed as 0.\n\nSample Input 2\n\n3\n10\n10\n15\n\nSample Output 2\n\n35\n\nYour grade will be 35 if all the questions are answered correctly, and this grade will be displayed correctly.\n\nSample Input 3\n\n3\n10\n20\n30\n\nSample Output 3\n\n0\n\nRegardless of whether each question is answered correctly or not, your grade will be a multiple of 10 and displayed as 0.", "sample_input": "3\n5\n10\n15\n"}, "reference_outputs": ["25\n"], "source_document_id": "p03701", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either \"correct\" or \"incorrect\", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.\n\nHowever, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 100\n\n1 ≤ s_i ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the maximum value that can be displayed as your grade.\n\nSample Input 1\n\n3\n5\n10\n15\n\nSample Output 1\n\n25\n\nYour grade will be 25 if the 10-point and 15-point questions are answered correctly and the 5-point question is not, and this grade will be displayed correctly. Your grade will become 30 if the 5-point question is also answered correctly, but this grade will be incorrectly displayed as 0.\n\nSample Input 2\n\n3\n10\n10\n15\n\nSample Output 2\n\n35\n\nYour grade will be 35 if all the questions are answered correctly, and this grade will be displayed correctly.\n\nSample Input 3\n\n3\n10\n20\n30\n\nSample Output 3\n\n0\n\nRegardless of whether each question is answered correctly or not, your grade will be a multiple of 10 and displayed as 0.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4446, "cpu_time_ms": 76, "memory_kb": 23380}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s636415567", "group_id": "codeNet:p03703", "input_text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.OutputStreamWriter;\nimport java.io.PrintWriter;\nimport java.io.StreamTokenizer;\nimport java.util.Arrays;\n\npublic class Main {\n static StreamTokenizer in=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); \n static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out)); \n \n public static int nextInt()throws IOException {in.nextToken();return (int)in.nval;} \n public static long nextLong()throws IOException {in.nextToken(); return (long)in.nval;}\n public static String next()throws IOException {in.nextToken();return (String)in.sval;}\n\n\tstatic int[] a = new int[200100];\n\tstatic int[] num = new int[200100];\n\tstatic int[] b = new int[200100];\n\tstatic long[] sum = new long[200100];\n\tstatic long[] c = new long[200100];\n\n public static void main(String[] args) throws IOException {\n \tint n = nextInt(), k = nextInt();\n \tnum[1] = 1;\n \tfor (int i = 2; i <= n + 1; i++) {\n \t\tsum[i] = sum[i - 1] + nextInt() - k;\n \t\tnum[i] = i;\n \t} \n \tqsort(1, n + 1);\n \tfor (int i = 1; i <= n + 1; i++)\n \t\tb[num[i]] = i;\n \tlong ans = 0;\n \tfor (int i = 1; i <= n + 1; i++) {\n\t\t\tint p = b[i];\n\t\t\twhile (p > 0) {\n\t\t\t\tans += c[p];\n\t\t\t\tp -= lowbit(p);\n\t\t\t}\n\t\t\tp = b[i];\n\t\t\twhile (p <= n + 1) {\n\t\t\t\tc[p]++;\n\t\t\t\tp += lowbit(p);\n\t\t\t}\n\t\t}\n \tout.println(ans);\n \tout.flush();\n \tout.close();\n }\n public static int lowbit(int x) {\n \treturn x & -x;\n }\n public static void qsort(int s, int t) {\n \tlong x = sum[(s + t) / 2];\n \tint y = num[(s + t) / 2];\n \tint i = s, j = t;\n \twhile (i < j) {\n \t\twhile (sum[i] < x || sum[i] == x && num[i] < y) i++;\n \t\twhile (sum[j] > x || sum[j] == x && num[j] > y) j--;\n \t\tif (i <= j) {\n \t\t\tlong k = sum[i];\n \t\t\tsum[i] = sum[j];\n \t\t\tsum[j] = k;\n \t\t\tint p = num[i];\n \t\t\tnum[i] = num[j];\n \t\t\tnum[j] = p;\n \t\t\ti++;\n \t\t\tj--;\n \t\t}\n \t}\n \tif (i < t) qsort(i, t);\n \tif (s < j) qsort(s, j);\n }\n}\n", "language": "Java", "metadata": {"date": 1502144231, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03703.html", "problem_id": "p03703", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03703/input.txt", "sample_output_relpath": "derived/input_output/data/p03703/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03703/Java/s636415567.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s636415567", "user_id": "u089230684"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.OutputStreamWriter;\nimport java.io.PrintWriter;\nimport java.io.StreamTokenizer;\nimport java.util.Arrays;\n\npublic class Main {\n static StreamTokenizer in=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); \n static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out)); \n \n public static int nextInt()throws IOException {in.nextToken();return (int)in.nval;} \n public static long nextLong()throws IOException {in.nextToken(); return (long)in.nval;}\n public static String next()throws IOException {in.nextToken();return (String)in.sval;}\n\n\tstatic int[] a = new int[200100];\n\tstatic int[] num = new int[200100];\n\tstatic int[] b = new int[200100];\n\tstatic long[] sum = new long[200100];\n\tstatic long[] c = new long[200100];\n\n public static void main(String[] args) throws IOException {\n \tint n = nextInt(), k = nextInt();\n \tnum[1] = 1;\n \tfor (int i = 2; i <= n + 1; i++) {\n \t\tsum[i] = sum[i - 1] + nextInt() - k;\n \t\tnum[i] = i;\n \t} \n \tqsort(1, n + 1);\n \tfor (int i = 1; i <= n + 1; i++)\n \t\tb[num[i]] = i;\n \tlong ans = 0;\n \tfor (int i = 1; i <= n + 1; i++) {\n\t\t\tint p = b[i];\n\t\t\twhile (p > 0) {\n\t\t\t\tans += c[p];\n\t\t\t\tp -= lowbit(p);\n\t\t\t}\n\t\t\tp = b[i];\n\t\t\twhile (p <= n + 1) {\n\t\t\t\tc[p]++;\n\t\t\t\tp += lowbit(p);\n\t\t\t}\n\t\t}\n \tout.println(ans);\n \tout.flush();\n \tout.close();\n }\n public static int lowbit(int x) {\n \treturn x & -x;\n }\n public static void qsort(int s, int t) {\n \tlong x = sum[(s + t) / 2];\n \tint y = num[(s + t) / 2];\n \tint i = s, j = t;\n \twhile (i < j) {\n \t\twhile (sum[i] < x || sum[i] == x && num[i] < y) i++;\n \t\twhile (sum[j] > x || sum[j] == x && num[j] > y) j--;\n \t\tif (i <= j) {\n \t\t\tlong k = sum[i];\n \t\t\tsum[i] = sum[j];\n \t\t\tsum[j] = k;\n \t\t\tint p = num[i];\n \t\t\tnum[i] = num[j];\n \t\t\tnum[j] = p;\n \t\t\ti++;\n \t\t\tj--;\n \t\t}\n \t}\n \tif (i < t) qsort(i, t);\n \tif (s < j) qsort(s, j);\n }\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nYou are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K.\n\na has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 2 \\times 10^5\n\n1 ≤ K ≤ 10^9\n\n1 ≤ a_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1\na_2\n:\na_N\n\nOutput\n\nPrint the number of the non-empty contiguous subsequences with an arithmetic mean that is greater than or equal to K.\n\nSample Input 1\n\n3 6\n7\n5\n7\n\nSample Output 1\n\n5\n\nAll the non-empty contiguous subsequences of a are listed below:\n\n{a_1} = {7}\n\n{a_1, a_2} = {7, 5}\n\n{a_1, a_2, a_3} = {7, 5, 7}\n\n{a_2} = {5}\n\n{a_2, a_3} = {5, 7}\n\n{a_3} = {7}\n\nTheir means are 7, 6, 19/3, 5, 6 and 7, respectively, and five among them are 6 or greater. Note that {a_1} and {a_3} are indistinguishable by the values of their elements, but we count them individually.\n\nSample Input 2\n\n1 2\n1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7 26\n10\n20\n30\n40\n30\n20\n10\n\nSample Output 3\n\n13", "sample_input": "3 6\n7\n5\n7\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03703", "source_text": "Score : 600 points\n\nProblem Statement\n\nYou are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K.\n\na has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 2 \\times 10^5\n\n1 ≤ K ≤ 10^9\n\n1 ≤ a_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1\na_2\n:\na_N\n\nOutput\n\nPrint the number of the non-empty contiguous subsequences with an arithmetic mean that is greater than or equal to K.\n\nSample Input 1\n\n3 6\n7\n5\n7\n\nSample Output 1\n\n5\n\nAll the non-empty contiguous subsequences of a are listed below:\n\n{a_1} = {7}\n\n{a_1, a_2} = {7, 5}\n\n{a_1, a_2, a_3} = {7, 5, 7}\n\n{a_2} = {5}\n\n{a_2, a_3} = {5, 7}\n\n{a_3} = {7}\n\nTheir means are 7, 6, 19/3, 5, 6 and 7, respectively, and five among them are 6 or greater. Note that {a_1} and {a_3} are indistinguishable by the values of their elements, but we count them individually.\n\nSample Input 2\n\n1 2\n1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7 26\n10\n20\n30\n40\n30\n20\n10\n\nSample Output 3\n\n13", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2070, "cpu_time_ms": 2105, "memory_kb": 30060}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s277068215", "group_id": "codeNet:p03704", "input_text": "import java.io.*;\nimport java.util.*;\nimport java.math.*;\n// import java.awt.Point;\n \npublic class Main {\n InputStream is;\n PrintWriter out;\n String INPUT = \"\";\n \n long MOD = 1_000_000_007;\n long inf = Long.MAX_VALUE;\n\n void solve(){ \n long D = nl();\n long[] init = new long[18];\n init[0] = 1;\n for(int i = 1; i < 18; i++){\n init[i] = init[i-1]*10 + 1;\n }\n long ans = 0;\n if(D%9!=0){\n out.println(0);\n return;\n }\n D /= 9;\n long a = D;\n for(int i = 0; i < 18; i++){\n long s = init[i];\n int p = 1;\n long tmp = 1;\n for(int j = 0; j < 18; j++){\n long res = (D%(long)Math.pow(10,p))/(long)(Math.pow(10,p-1));\n D = D - s*res;\n if(j==0) tmp *= 9 - Math.abs(res);\n else tmp *= 10 - Math.abs(res);\n s = s / (long)Math.pow(10,p+1) * (long)Math.pow(10,p);\n p++;\n if(s==0) break;\n }\n if(i%2==1) tmp *= 10;\n if(D==0) ans += tmp;\n D = a;\n }\n out.println(ans);\n }\n\n void run() throws Exception\n {\n is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n out = new PrintWriter(System.out);\n long s = System.currentTimeMillis();\n solve();\n out.flush();\n if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+\"ms\");\n }\n \n public static void main(String[] args) throws Exception { new Main().run(); }\n \n private byte[] inbuf = new byte[1024];\n private int lenbuf = 0, ptrbuf = 0;\n \n private int readByte()\n {\n if(lenbuf == -1)throw new InputMismatchException();\n if(ptrbuf >= lenbuf){\n ptrbuf = 0;\n try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }\n if(lenbuf <= 0)return -1;\n }\n return inbuf[ptrbuf++];\n }\n \n private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }\n private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }\n \n private double nd() { return Double.parseDouble(ns()); }\n private char nc() { return (char)skip(); }\n \n private String ns()\n {\n int b = skip();\n StringBuilder sb = new StringBuilder();\n while(!(isSpaceChar(b) && b != ' ')){\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n \n private char[] ns(int n)\n {\n char[] buf = new char[n];\n int b = skip(), p = 0;\n while(p < n && !(isSpaceChar(b))){\n buf[p++] = (char)b;\n b = readByte();\n }\n return n == p ? buf : Arrays.copyOf(buf, p);\n }\n \n private char[][] nm(int n, int m)\n {\n char[][] map = new char[n][];\n for(int i = 0;i < n;i++)map[i] = ns(m);\n return map;\n }\n \n private int[] na(int n)\n {\n int[] a = new int[n];\n for(int i = 0;i < n;i++)a[i] = ni();\n return a;\n }\n \n private int ni()\n {\n int num = 0, b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-'){\n minus = true;\n b = readByte();\n }\n \n while(true){\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n }else{\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n \n private long nl()\n {\n long num = 0;\n int b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-'){\n minus = true;\n b = readByte();\n }\n \n while(true){\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n }else{\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n \n private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); }\n \n}", "language": "Java", "metadata": {"date": 1516345883, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03704.html", "problem_id": "p03704", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03704/input.txt", "sample_output_relpath": "derived/input_output/data/p03704/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03704/Java/s277068215.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s277068215", "user_id": "u675503966"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.*;\nimport java.util.*;\nimport java.math.*;\n// import java.awt.Point;\n \npublic class Main {\n InputStream is;\n PrintWriter out;\n String INPUT = \"\";\n \n long MOD = 1_000_000_007;\n long inf = Long.MAX_VALUE;\n\n void solve(){ \n long D = nl();\n long[] init = new long[18];\n init[0] = 1;\n for(int i = 1; i < 18; i++){\n init[i] = init[i-1]*10 + 1;\n }\n long ans = 0;\n if(D%9!=0){\n out.println(0);\n return;\n }\n D /= 9;\n long a = D;\n for(int i = 0; i < 18; i++){\n long s = init[i];\n int p = 1;\n long tmp = 1;\n for(int j = 0; j < 18; j++){\n long res = (D%(long)Math.pow(10,p))/(long)(Math.pow(10,p-1));\n D = D - s*res;\n if(j==0) tmp *= 9 - Math.abs(res);\n else tmp *= 10 - Math.abs(res);\n s = s / (long)Math.pow(10,p+1) * (long)Math.pow(10,p);\n p++;\n if(s==0) break;\n }\n if(i%2==1) tmp *= 10;\n if(D==0) ans += tmp;\n D = a;\n }\n out.println(ans);\n }\n\n void run() throws Exception\n {\n is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n out = new PrintWriter(System.out);\n long s = System.currentTimeMillis();\n solve();\n out.flush();\n if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+\"ms\");\n }\n \n public static void main(String[] args) throws Exception { new Main().run(); }\n \n private byte[] inbuf = new byte[1024];\n private int lenbuf = 0, ptrbuf = 0;\n \n private int readByte()\n {\n if(lenbuf == -1)throw new InputMismatchException();\n if(ptrbuf >= lenbuf){\n ptrbuf = 0;\n try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }\n if(lenbuf <= 0)return -1;\n }\n return inbuf[ptrbuf++];\n }\n \n private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }\n private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }\n \n private double nd() { return Double.parseDouble(ns()); }\n private char nc() { return (char)skip(); }\n \n private String ns()\n {\n int b = skip();\n StringBuilder sb = new StringBuilder();\n while(!(isSpaceChar(b) && b != ' ')){\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n \n private char[] ns(int n)\n {\n char[] buf = new char[n];\n int b = skip(), p = 0;\n while(p < n && !(isSpaceChar(b))){\n buf[p++] = (char)b;\n b = readByte();\n }\n return n == p ? buf : Arrays.copyOf(buf, p);\n }\n \n private char[][] nm(int n, int m)\n {\n char[][] map = new char[n][];\n for(int i = 0;i < n;i++)map[i] = ns(m);\n return map;\n }\n \n private int[] na(int n)\n {\n int[] a = new int[n];\n for(int i = 0;i < n;i++)a[i] = ni();\n return a;\n }\n \n private int ni()\n {\n int num = 0, b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-'){\n minus = true;\n b = readByte();\n }\n \n while(true){\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n }else{\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n \n private long nl()\n {\n long num = 0;\n int b;\n boolean minus = false;\n while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));\n if(b == '-'){\n minus = true;\n b = readByte();\n }\n \n while(true){\n if(b >= '0' && b <= '9'){\n num = num * 10 + (b - '0');\n }else{\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n \n private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); }\n \n}", "problem_context": "Score : 800 points\n\nProblem Statement\n\nFor a positive integer n, we denote the integer obtained by reversing the decimal notation of n (without leading zeroes) by rev(n). For example, rev(123) = 321 and rev(4000) = 4.\n\nYou are given a positive integer D. How many positive integers N satisfy rev(N) = N + D?\n\nConstraints\n\nD is an integer.\n\n1 ≤ D < 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD\n\nOutput\n\nPrint the number of the positive integers N such that rev(N) = N + D.\n\nSample Input 1\n\n63\n\nSample Output 1\n\n2\n\nThere are two positive integers N such that rev(N) = N + 63: N = 18 and 29.\n\nSample Input 2\n\n75\n\nSample Output 2\n\n0\n\nThere are no positive integers N such that rev(N) = N + 75.\n\nSample Input 3\n\n864197532\n\nSample Output 3\n\n1920", "sample_input": "63\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03704", "source_text": "Score : 800 points\n\nProblem Statement\n\nFor a positive integer n, we denote the integer obtained by reversing the decimal notation of n (without leading zeroes) by rev(n). For example, rev(123) = 321 and rev(4000) = 4.\n\nYou are given a positive integer D. How many positive integers N satisfy rev(N) = N + D?\n\nConstraints\n\nD is an integer.\n\n1 ≤ D < 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD\n\nOutput\n\nPrint the number of the positive integers N such that rev(N) = N + D.\n\nSample Input 1\n\n63\n\nSample Output 1\n\n2\n\nThere are two positive integers N such that rev(N) = N + 63: N = 18 and 29.\n\nSample Input 2\n\n75\n\nSample Output 2\n\n0\n\nThere are no positive integers N such that rev(N) = N + 75.\n\nSample Input 3\n\n864197532\n\nSample Output 3\n\n1920", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4235, "cpu_time_ms": 71, "memory_kb": 22612}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s775385415", "group_id": "codeNet:p03704", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.StringTokenizer;\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tInputStream inputStream = System.in;\n\t\tOutputStream outputStream = System.out;\n\t\tFastScanner in = new FastScanner(inputStream);\n\t\tPrintWriter out = new PrintWriter(outputStream);\n\t\tTaskF solver = new TaskF();\n\t\tsolver.solve(1, in, out);\n\t\tout.close();\n\t}\n\n\tstatic class TaskF {\n\t\tint MAX_LEN;\n\t\tint[] a;\n\t\tint[] d;\n\t\tint[] sum;\n\t\tint ans;\n\n\t\tpublic void solve(int testNumber, FastScanner in, PrintWriter out) {\n\t\t\tchar[] dc = in.next().toCharArray();\n\t\t\tMAX_LEN = dc.length + 3;\n\t\t\tans = 0;\n\t\t\ta = new int[MAX_LEN];\n\t\t\td = new int[MAX_LEN];\n\t\t\tsum = new int[MAX_LEN];\n\t\t\tfor (int i = 0; i < dc.length; i++) {\n\t\t\t\td[i] = dc[dc.length - i - 1] - '0';\n\t\t\t}\n\t\t\tArrays.fill(a, -1);\n\t\t\tfor (int len = Math.max(1, dc.length - 2); len < MAX_LEN; len++) {\n\t\t\t\trec(0, 0, len);\n\t\t\t}\n\t\t\tout.println(ans);\n\t\t}\n\n\t\tprivate void rec(int i, int c, int n) {\n\t\t\tif (i == n) {\n\t\t\t\tif (c != 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tint carry = 0;\n\t\t\t\tArrays.fill(sum, 0);\n\t\t\t\tfor (int j = 0; j < MAX_LEN; j++) {\n\t\t\t\t\tint x = a[j] < 0 ? 0 : a[j];\n\t\t\t\t\tsum[j] = (x + d[j] + carry) % 10;\n\t\t\t\t\tcarry = (x + d[j] + carry) / 10;\n\t\t\t\t}\n\t\t\t\tboolean ok = (carry == 0);\n\t\t\t\tfor (int j = n; j < MAX_LEN && ok; j++) {\n\t\t\t\t\tif (sum[j] != 0) {\n\t\t\t\t\t\tok = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (a[n - 1] == 0) {\n\t\t\t\t\tok = false;\n\t\t\t\t}\n\t\t\t\tfor (int j = 0; j < n && ok; j++) {\n\t\t\t\t\tif (a[j] < 0) {\n\t\t\t\t\t\tthrow new AssertionError();\n\t\t\t\t\t}\n\t\t\t\t\tif (sum[j] != a[n - 1 - j]) {\n\t\t\t\t\t\tok = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (ok) {\n\t\t\t\t\t++ans;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tint l = 0;\n\t\t\tint r = 9;\n\t\t\tif (a[i] >= 0) {\n\t\t\t\tl = a[i];\n\t\t\t\tr = a[i];\n\t\t\t}\n\t\t\tif (i == n - 1) {\n\t\t\t\tl = Math.max(l, 1);\n\t\t\t}\n\t\t\tfor (int v = l; v <= r; v++) {\n\t\t\t\ta[i] = v;\n\t\t\t\tint x = (a[i] + d[i] + c) % 10;\n\t\t\t\tint y = (a[i] + d[i] + c) / 10;\n\t\t\t\tint old = a[n - i - 1];\n\t\t\t\tif (old < 0 || old == x) {\n\t\t\t\t\ta[n - i - 1] = x;\n\t\t\t\t\trec(i + 1, y, n);\n\t\t\t\t\ta[n - i - 1] = old;\n\t\t\t\t}\n\t\t\t\ta[i] = -1;\n\t\t\t}\n\t\t}\n\n\t}\n\n\tstatic class FastScanner {\n\t\tprivate BufferedReader in;\n\t\tprivate StringTokenizer st;\n\n\t\tpublic FastScanner(InputStream stream) {\n\t\t\tin = new BufferedReader(new InputStreamReader(stream));\n\t\t}\n\n\t\tpublic String next() {\n\t\t\twhile (st == null || !st.hasMoreTokens()) {\n\t\t\t\ttry {\n\t\t\t\t\tString rl = in.readLine();\n\t\t\t\t\tif (rl == null) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tst = new StringTokenizer(rl);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new RuntimeException(e);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t}\n}\n\n", "language": "Java", "metadata": {"date": 1496542894, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03704.html", "problem_id": "p03704", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03704/input.txt", "sample_output_relpath": "derived/input_output/data/p03704/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03704/Java/s775385415.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s775385415", "user_id": "u113560961"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.StringTokenizer;\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tInputStream inputStream = System.in;\n\t\tOutputStream outputStream = System.out;\n\t\tFastScanner in = new FastScanner(inputStream);\n\t\tPrintWriter out = new PrintWriter(outputStream);\n\t\tTaskF solver = new TaskF();\n\t\tsolver.solve(1, in, out);\n\t\tout.close();\n\t}\n\n\tstatic class TaskF {\n\t\tint MAX_LEN;\n\t\tint[] a;\n\t\tint[] d;\n\t\tint[] sum;\n\t\tint ans;\n\n\t\tpublic void solve(int testNumber, FastScanner in, PrintWriter out) {\n\t\t\tchar[] dc = in.next().toCharArray();\n\t\t\tMAX_LEN = dc.length + 3;\n\t\t\tans = 0;\n\t\t\ta = new int[MAX_LEN];\n\t\t\td = new int[MAX_LEN];\n\t\t\tsum = new int[MAX_LEN];\n\t\t\tfor (int i = 0; i < dc.length; i++) {\n\t\t\t\td[i] = dc[dc.length - i - 1] - '0';\n\t\t\t}\n\t\t\tArrays.fill(a, -1);\n\t\t\tfor (int len = Math.max(1, dc.length - 2); len < MAX_LEN; len++) {\n\t\t\t\trec(0, 0, len);\n\t\t\t}\n\t\t\tout.println(ans);\n\t\t}\n\n\t\tprivate void rec(int i, int c, int n) {\n\t\t\tif (i == n) {\n\t\t\t\tif (c != 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tint carry = 0;\n\t\t\t\tArrays.fill(sum, 0);\n\t\t\t\tfor (int j = 0; j < MAX_LEN; j++) {\n\t\t\t\t\tint x = a[j] < 0 ? 0 : a[j];\n\t\t\t\t\tsum[j] = (x + d[j] + carry) % 10;\n\t\t\t\t\tcarry = (x + d[j] + carry) / 10;\n\t\t\t\t}\n\t\t\t\tboolean ok = (carry == 0);\n\t\t\t\tfor (int j = n; j < MAX_LEN && ok; j++) {\n\t\t\t\t\tif (sum[j] != 0) {\n\t\t\t\t\t\tok = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (a[n - 1] == 0) {\n\t\t\t\t\tok = false;\n\t\t\t\t}\n\t\t\t\tfor (int j = 0; j < n && ok; j++) {\n\t\t\t\t\tif (a[j] < 0) {\n\t\t\t\t\t\tthrow new AssertionError();\n\t\t\t\t\t}\n\t\t\t\t\tif (sum[j] != a[n - 1 - j]) {\n\t\t\t\t\t\tok = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (ok) {\n\t\t\t\t\t++ans;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tint l = 0;\n\t\t\tint r = 9;\n\t\t\tif (a[i] >= 0) {\n\t\t\t\tl = a[i];\n\t\t\t\tr = a[i];\n\t\t\t}\n\t\t\tif (i == n - 1) {\n\t\t\t\tl = Math.max(l, 1);\n\t\t\t}\n\t\t\tfor (int v = l; v <= r; v++) {\n\t\t\t\ta[i] = v;\n\t\t\t\tint x = (a[i] + d[i] + c) % 10;\n\t\t\t\tint y = (a[i] + d[i] + c) / 10;\n\t\t\t\tint old = a[n - i - 1];\n\t\t\t\tif (old < 0 || old == x) {\n\t\t\t\t\ta[n - i - 1] = x;\n\t\t\t\t\trec(i + 1, y, n);\n\t\t\t\t\ta[n - i - 1] = old;\n\t\t\t\t}\n\t\t\t\ta[i] = -1;\n\t\t\t}\n\t\t}\n\n\t}\n\n\tstatic class FastScanner {\n\t\tprivate BufferedReader in;\n\t\tprivate StringTokenizer st;\n\n\t\tpublic FastScanner(InputStream stream) {\n\t\t\tin = new BufferedReader(new InputStreamReader(stream));\n\t\t}\n\n\t\tpublic String next() {\n\t\t\twhile (st == null || !st.hasMoreTokens()) {\n\t\t\t\ttry {\n\t\t\t\t\tString rl = in.readLine();\n\t\t\t\t\tif (rl == null) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tst = new StringTokenizer(rl);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new RuntimeException(e);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn st.nextToken();\n\t\t}\n\n\t}\n}\n\n", "problem_context": "Score : 800 points\n\nProblem Statement\n\nFor a positive integer n, we denote the integer obtained by reversing the decimal notation of n (without leading zeroes) by rev(n). For example, rev(123) = 321 and rev(4000) = 4.\n\nYou are given a positive integer D. How many positive integers N satisfy rev(N) = N + D?\n\nConstraints\n\nD is an integer.\n\n1 ≤ D < 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD\n\nOutput\n\nPrint the number of the positive integers N such that rev(N) = N + D.\n\nSample Input 1\n\n63\n\nSample Output 1\n\n2\n\nThere are two positive integers N such that rev(N) = N + 63: N = 18 and 29.\n\nSample Input 2\n\n75\n\nSample Output 2\n\n0\n\nThere are no positive integers N such that rev(N) = N + 75.\n\nSample Input 3\n\n864197532\n\nSample Output 3\n\n1920", "sample_input": "63\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03704", "source_text": "Score : 800 points\n\nProblem Statement\n\nFor a positive integer n, we denote the integer obtained by reversing the decimal notation of n (without leading zeroes) by rev(n). For example, rev(123) = 321 and rev(4000) = 4.\n\nYou are given a positive integer D. How many positive integers N satisfy rev(N) = N + D?\n\nConstraints\n\nD is an integer.\n\n1 ≤ D < 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD\n\nOutput\n\nPrint the number of the positive integers N such that rev(N) = N + D.\n\nSample Input 1\n\n63\n\nSample Output 1\n\n2\n\nThere are two positive integers N such that rev(N) = N + 63: N = 18 and 29.\n\nSample Input 2\n\n75\n\nSample Output 2\n\n0\n\nThere are no positive integers N such that rev(N) = N + 75.\n\nSample Input 3\n\n864197532\n\nSample Output 3\n\n1920", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2845, "cpu_time_ms": 498, "memory_kb": 24916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s384170364", "group_id": "codeNet:p03713", "input_text": "import java.util.*;\nimport java.awt.*;\nimport java.awt.geom.*;\nimport static java.lang.System.*;\nimport static java.lang.Math.*;\npublic class Main {\n public static void main(String[] $) {\n Scanner sc = new Scanner(in);\n int[] l = new int[2];\n l[0] = sc.nextInt();\n l[1] = sc.nextInt();\n long ans = l[0] * l[1];\n long[] s = new long[3];\n for (int i = 0; i < 2; i++) {\n for (int j = 0; j <= l[i]; j++) {\n s[0]=l[abs(i-1)]*(long)j;\n s[1]=(l[i]-(long)j)/2*l[abs(1-i)];\n s[2]=l[0]*l[1]-s[0]-s[1];\n Arrays.sort(s);\n ans=min(ans,s[2]-s[0]);\n s[0]=l[abs(i-1)]*(long)j;\n s[1]=l[abs(1-i)]/2*(l[i]-(long)j);\n s[2]=l[0]*l[1]-s[0]-s[1];\n Arrays.sort(s);\n ans=min(s[2]-s[0],ans);\n }\n }\n out.println(ans);\n }\n}\n", "language": "Java", "metadata": {"date": 1548631218, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03713.html", "problem_id": "p03713", "resource_group": "high_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/Java/s384170364.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s384170364", "user_id": "u881037761"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "import java.util.*;\nimport java.awt.*;\nimport java.awt.geom.*;\nimport static java.lang.System.*;\nimport static java.lang.Math.*;\npublic class Main {\n public static void main(String[] $) {\n Scanner sc = new Scanner(in);\n int[] l = new int[2];\n l[0] = sc.nextInt();\n l[1] = sc.nextInt();\n long ans = l[0] * l[1];\n long[] s = new long[3];\n for (int i = 0; i < 2; i++) {\n for (int j = 0; j <= l[i]; j++) {\n s[0]=l[abs(i-1)]*(long)j;\n s[1]=(l[i]-(long)j)/2*l[abs(1-i)];\n s[2]=l[0]*l[1]-s[0]-s[1];\n Arrays.sort(s);\n ans=min(ans,s[2]-s[0]);\n s[0]=l[abs(i-1)]*(long)j;\n s[1]=l[abs(1-i)]/2*(l[i]-(long)j);\n s[2]=l[0]*l[1]-s[0]-s[1];\n Arrays.sort(s);\n ans=min(s[2]-s[0],ans);\n }\n }\n out.println(ans);\n }\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": 938, "cpu_time_ms": 162, "memory_kb": 22740}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s467710689", "group_id": "codeNet:p03715", "input_text": "import java.util.*;\n\npublic class Main {\n\tpublic static void main(String []args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint m = sc.nextInt();\n\t\tint n = sc.nextInt();\n\t\tMain soln = new Main();\n\t\tint[] best = soln.cutter(m, n, 1);\n\t\tSystem.out.println(soln.calcDiv(best));\n\t}\n\n\tprivate int[] cutter(int mm, int nn, int cnt) {\n\t\tint[] res = new int[4-cnt];\n\t\tif(cnt==3) {\n\t\t\tres[0] = mm*nn;\n\t\t\treturn res;\n\t\t}\n\n\t\tint minDiv = mm*nn;\n\t\tint[] best = new int[4-cnt];\n\t\tfor(int p=1; p<=mm/2; p++) {\n\t\t\tres[0] = p*nn;\n\t\t\tint[] temp = cutter(mm-p, nn, cnt+1);\n\t\t\tfor(int x=0; x g[][];\n static int n, m;\n static int dp[][][][]=new int[2][3][302][302];\n static void solve() throws IOException {\n Scanner in = new Scanner(System.in);\n PrintWriter out = new PrintWriter(System.out);\n n=in.nextInt();\n m=in.nextInt();\n g=new ArrayList[n+1][4];\n for(int i=0;i<=n;i++)\n for(int j=0;j<4;j++)\n g[i][j]=new ArrayList<>();\n\n for(int i=0;i0;i--) {\n for(int lcu=0;lcu<3;lcu++){\n for(int c1=0;c1=x)\n vv++;\n if(c2>=x)\n vv++;\n if(vv!=ct)\n {\n val=false;\n ct=5;\n break;\n }\n }\n }\n if(!val){\n dp[i&1][lcu][c1][c2]=0;\n continue;\n }\n\n if(i==n+1) {\n dp[i&1][lcu][c1][c2] = 1;\n continue;\n }\n long rrx=0;\n rrx+=dp[(i+1)&1][lcu][c1][c2];\n rrx+=dp[(i+1)&1][(lcu+1)%3][c2][i-1];\n rrx+=dp[(i+1)&1][(lcu+2)%3][i-1][c1];\n dp[i&1][lcu][c1][c2]=(int)(rrx%mod);\n }\n }\n }\n out.println(dp[1][0][0][0]);\n out.close();\n\n }\n static int mod=1000000007;\n// static int sol(int i, int lcu, int c1,int c2){\n// if(i!=n+1 && dp[i][lcu][c1][c2]!=-1)\n// return dp[i][lcu][c1][c2];\n// for(int ct=1;ct<=3;ct++){\n// for(int x:g[i-1][ct]){\n// int vv=1;\n// if(c1>=x)\n// vv++;\n// if(c2>=x)\n// vv++;\n// if(vv!=ct)\n// if(i==n+1)\n// return 0;\n// else\n// return dp[i][lcu][c1][c2]=0;\n// }\n//\n//\n// }\n// if(i==n+1)\n// return 1;\n// long rrx=sol(i+1,lcu,c1,c2);\n// rrx+=sol(i+1, (lcu+1)%3, c2, i-1);\n// rrx+=sol(i+1, (lcu+2)%3, i-1, c1);\n// return (dp[i][lcu][c1][c2]=(int)(rrx%mod));\n// }\n}\n", "language": "Java", "metadata": {"date": 1565998674, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03717.html", "problem_id": "p03717", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03717/input.txt", "sample_output_relpath": "derived/input_output/data/p03717/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03717/Java/s520055794.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s520055794", "user_id": "u905039527"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.StringTokenizer;\nimport java.io.PrintWriter;\n\npublic class Main {\n static class Scanner {\n BufferedReader br;\n StringTokenizer tk = new StringTokenizer(\"\");\n\n public Scanner(InputStream is) {\n br = new BufferedReader(new InputStreamReader(is));\n }\n\n public int nextInt() throws IOException {\n if (tk.hasMoreTokens())\n return Integer.parseInt(tk.nextToken());\n tk = new StringTokenizer(br.readLine());\n return nextInt();\n }\n\n public long nextLong() throws IOException {\n if (tk.hasMoreTokens())\n return Long.parseLong(tk.nextToken());\n tk = new StringTokenizer(br.readLine());\n return nextLong();\n }\n\n public String next() throws IOException {\n if (tk.hasMoreTokens())\n return (tk.nextToken());\n tk = new StringTokenizer(br.readLine());\n return next();\n }\n\n public String nextLine() throws IOException {\n tk = new StringTokenizer(\"\");\n return br.readLine();\n }\n\n public double nextDouble() throws IOException {\n if (tk.hasMoreTokens())\n return Double.parseDouble(tk.nextToken());\n tk = new StringTokenizer(br.readLine());\n return nextDouble();\n }\n\n public char nextChar() throws IOException {\n if (tk.hasMoreTokens())\n return (tk.nextToken().charAt(0));\n tk = new StringTokenizer(br.readLine());\n return nextChar();\n }\n\n public int[] nextIntArray(int n) throws IOException {\n int a[] = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = nextInt();\n return a;\n }\n\n public long[] nextLongArray(int n) throws IOException {\n long a[] = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = nextLong();\n return a;\n }\n\n public int[] nextIntArrayOneBased(int n) throws IOException {\n int a[] = new int[n + 1];\n for (int i = 1; i <= n; i++)\n a[i] = nextInt();\n return a;\n }\n\n public long[] nextLongArrayOneBased(int n) throws IOException {\n long a[] = new long[n + 1];\n for (int i = 1; i <= n; i++)\n a[i] = nextLong();\n return a;\n }\n\n\n }\n\n public static void main(String args[]) throws IOException {\n new Thread(null, new Runnable() {\n public void run() {\n try {\n solve();\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n }, \"1\", 1 << 26).start();\n\n }\n static ArrayList g[][];\n static int n, m;\n static int dp[][][][]=new int[2][3][302][302];\n static void solve() throws IOException {\n Scanner in = new Scanner(System.in);\n PrintWriter out = new PrintWriter(System.out);\n n=in.nextInt();\n m=in.nextInt();\n g=new ArrayList[n+1][4];\n for(int i=0;i<=n;i++)\n for(int j=0;j<4;j++)\n g[i][j]=new ArrayList<>();\n\n for(int i=0;i0;i--) {\n for(int lcu=0;lcu<3;lcu++){\n for(int c1=0;c1=x)\n vv++;\n if(c2>=x)\n vv++;\n if(vv!=ct)\n {\n val=false;\n ct=5;\n break;\n }\n }\n }\n if(!val){\n dp[i&1][lcu][c1][c2]=0;\n continue;\n }\n\n if(i==n+1) {\n dp[i&1][lcu][c1][c2] = 1;\n continue;\n }\n long rrx=0;\n rrx+=dp[(i+1)&1][lcu][c1][c2];\n rrx+=dp[(i+1)&1][(lcu+1)%3][c2][i-1];\n rrx+=dp[(i+1)&1][(lcu+2)%3][i-1][c1];\n dp[i&1][lcu][c1][c2]=(int)(rrx%mod);\n }\n }\n }\n out.println(dp[1][0][0][0]);\n out.close();\n\n }\n static int mod=1000000007;\n// static int sol(int i, int lcu, int c1,int c2){\n// if(i!=n+1 && dp[i][lcu][c1][c2]!=-1)\n// return dp[i][lcu][c1][c2];\n// for(int ct=1;ct<=3;ct++){\n// for(int x:g[i-1][ct]){\n// int vv=1;\n// if(c1>=x)\n// vv++;\n// if(c2>=x)\n// vv++;\n// if(vv!=ct)\n// if(i==n+1)\n// return 0;\n// else\n// return dp[i][lcu][c1][c2]=0;\n// }\n//\n//\n// }\n// if(i==n+1)\n// return 1;\n// long rrx=sol(i+1,lcu,c1,c2);\n// rrx+=sol(i+1, (lcu+1)%3, c2, i-1);\n// rrx+=sol(i+1, (lcu+2)%3, i-1, c1);\n// return (dp[i][lcu][c1][c2]=(int)(rrx%mod));\n// }\n}\n", "problem_context": "Score : 800 points\n\nProblem Statement\n\nThere are N squares arranged in a row.\nThe squares are numbered 1, 2, ..., N, from left to right.\n\nSnuke is painting each square in red, green or blue.\nAccording to his aesthetic sense, the following M conditions must all be satisfied.\nThe i-th condition is:\n\nThere are exactly x_i different colors among squares l_i, l_i + 1, ..., r_i.\n\nIn how many ways can the squares be painted to satisfy all the conditions?\nFind the count modulo 10^9+7.\n\nConstraints\n\n1 ≤ N ≤ 300\n\n1 ≤ M ≤ 300\n\n1 ≤ l_i ≤ r_i ≤ N\n\n1 ≤ x_i ≤ 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nl_1 r_1 x_1\nl_2 r_2 x_2\n:\nl_M r_M x_M\n\nOutput\n\nPrint the number of ways to paint the squares to satisfy all the conditions, modulo 10^9+7.\n\nSample Input 1\n\n3 1\n1 3 3\n\nSample Output 1\n\n6\n\nThe six ways are:\n\nRGB\n\nRBG\n\nGRB\n\nGBR\n\nBRG\n\nBGR\n\nwhere R, G and B correspond to red, green and blue squares, respectively.\n\nSample Input 2\n\n4 2\n1 3 1\n2 4 2\n\nSample Output 2\n\n6\n\nThe six ways are:\n\nRRRG\n\nRRRB\n\nGGGR\n\nGGGB\n\nBBBR\n\nBBBG\n\nSample Input 3\n\n1 3\n1 1 1\n1 1 2\n1 1 3\n\nSample Output 3\n\n0\n\nThere are zero ways.\n\nSample Input 4\n\n8 10\n2 6 2\n5 5 1\n3 5 2\n4 7 3\n4 4 1\n2 3 1\n7 7 1\n1 5 2\n1 7 3\n3 4 2\n\nSample Output 4\n\n108", "sample_input": "3 1\n1 3 3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03717", "source_text": "Score : 800 points\n\nProblem Statement\n\nThere are N squares arranged in a row.\nThe squares are numbered 1, 2, ..., N, from left to right.\n\nSnuke is painting each square in red, green or blue.\nAccording to his aesthetic sense, the following M conditions must all be satisfied.\nThe i-th condition is:\n\nThere are exactly x_i different colors among squares l_i, l_i + 1, ..., r_i.\n\nIn how many ways can the squares be painted to satisfy all the conditions?\nFind the count modulo 10^9+7.\n\nConstraints\n\n1 ≤ N ≤ 300\n\n1 ≤ M ≤ 300\n\n1 ≤ l_i ≤ r_i ≤ N\n\n1 ≤ x_i ≤ 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nl_1 r_1 x_1\nl_2 r_2 x_2\n:\nl_M r_M x_M\n\nOutput\n\nPrint the number of ways to paint the squares to satisfy all the conditions, modulo 10^9+7.\n\nSample Input 1\n\n3 1\n1 3 3\n\nSample Output 1\n\n6\n\nThe six ways are:\n\nRGB\n\nRBG\n\nGRB\n\nGBR\n\nBRG\n\nBGR\n\nwhere R, G and B correspond to red, green and blue squares, respectively.\n\nSample Input 2\n\n4 2\n1 3 1\n2 4 2\n\nSample Output 2\n\n6\n\nThe six ways are:\n\nRRRG\n\nRRRB\n\nGGGR\n\nGGGB\n\nBBBR\n\nBBBG\n\nSample Input 3\n\n1 3\n1 1 1\n1 1 2\n1 1 3\n\nSample Output 3\n\n0\n\nThere are zero ways.\n\nSample Input 4\n\n8 10\n2 6 2\n5 5 1\n3 5 2\n4 7 3\n4 4 1\n2 3 1\n7 7 1\n1 5 2\n1 7 3\n3 4 2\n\nSample Output 4\n\n108", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6137, "cpu_time_ms": 1021, "memory_kb": 29608}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s314838323", "group_id": "codeNet:p03719", "input_text": "import java.util.*;\n\npublic class Main {\n\tpublic static void main(String []args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint a = sc.nextInt();\n\t\tint b = sc.nextInt();\n\t\tint c = sc.nextInt();\n\n\t\tif(c>=a && c<=b) System.out.println(\"Yes\");\n\t\telse System.out.println(\"No\");\n\t}\n}", "language": "Java", "metadata": {"date": 1495543496, "filename_ext": "java", "original_language": "Java7 (OpenJDK 1.7.0)", "problem_description_relpath": "problem_descriptions/p03719.html", "problem_id": "p03719", "resource_group": "high_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/Java/s314838323.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s314838323", "user_id": "u627349438"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n\tpublic static void main(String []args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint a = sc.nextInt();\n\t\tint b = sc.nextInt();\n\t\tint c = sc.nextInt();\n\n\t\tif(c>=a && c<=b) System.out.println(\"Yes\");\n\t\telse System.out.println(\"No\");\n\t}\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": 278, "cpu_time_ms": 96, "memory_kb": 22868}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s050425439", "group_id": "codeNet:p03720", "input_text": "\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint m = sc.nextInt();\n\t\tint[] town = new int[n];\n\t\tfor(int i = 0; i < m; i++) {\n\t\t\ttown[sc.nextInt() - 1] ++;\n\t\t\ttown[sc.nextInt() - 1] ++;\n\t\t}\n\t\tfor(int i : town) {\n\t\t\tSystem.out.println(i);\n\t\t}\n\t}\n\n}\n", "language": "Java", "metadata": {"date": 1591954959, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03720.html", "problem_id": "p03720", "resource_group": "high_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/Java/s050425439.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s050425439", "user_id": "u173207136"}, "prompt_components": {"gold_output": "2\n2\n1\n1\n", "input_to_evaluate": "\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint m = sc.nextInt();\n\t\tint[] town = new int[n];\n\t\tfor(int i = 0; i < m; i++) {\n\t\t\ttown[sc.nextInt() - 1] ++;\n\t\t\ttown[sc.nextInt() - 1] ++;\n\t\t}\n\t\tfor(int i : town) {\n\t\t\tSystem.out.println(i);\n\t\t}\n\t}\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": 358, "cpu_time_ms": 110, "memory_kb": 23124}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s130615729", "group_id": "codeNet:p03721", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n\n int n = Integer.parseInt(sc.next());\n long k = Long.parseLong(sc.next());\n long[] a = new long[100010];\n\n for (int i = 0; i < n; i++) {\n int x = Integer.parseInt(sc.next());\n int y = Integer.parseInt(sc.next());\n a[x] += (long) y;\n }\n\n long sum = 0;\n for (int i = 1; i < a.length; i++) {\n\n sum += (long) a[i];\n if (sum >= k) {\n System.out.println(i);\n break;\n }\n }\n\n sc.close();\n }\n}", "language": "Java", "metadata": {"date": 1566854967, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03721.html", "problem_id": "p03721", "resource_group": "high_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/Java/s130615729.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s130615729", "user_id": "u117657834"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n\n int n = Integer.parseInt(sc.next());\n long k = Long.parseLong(sc.next());\n long[] a = new long[100010];\n\n for (int i = 0; i < n; i++) {\n int x = Integer.parseInt(sc.next());\n int y = Integer.parseInt(sc.next());\n a[x] += (long) y;\n }\n\n long sum = 0;\n for (int i = 1; i < a.length; i++) {\n\n sum += (long) a[i];\n if (sum >= k) {\n System.out.println(i);\n break;\n }\n }\n\n sc.close();\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": 590, "cpu_time_ms": 467, "memory_kb": 50768}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s873092446", "group_id": "codeNet:p03721", "input_text": "import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().solve();\n\t}\n\tint n,k;\n\tvoid solve(){\n\t\tScanner sc=new Scanner(System.in);\n\t\tn=sc.nextInt();\n\t\tk=sc.nextInt();\n\t\tint[]a=new int[n];\n\t\tint[]b=new int[n];\n\t\tPair[] p=new Pair[n];\n\t\tfor(int i=0;i0)continue;\n\t\t\telse{\n\t\t\t\tSystem.out.println(p[i].a);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\tclass Pair implements Comparable{\n\t\tint a;\n\t\tint b;\n\t\tPair(int a,int b){\n\t\t\tthis.a=a;\n\t\t\tthis.b=b;\n\t\t}\n\t\t\n\t\tpublic int compareTo(Pair o){\n\t\t\treturn this.a-o.a;\n\t\t}\n\t}\n}\n", "language": "Java", "metadata": {"date": 1494724686, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03721.html", "problem_id": "p03721", "resource_group": "high_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/Java/s873092446.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s873092446", "user_id": "u369883202"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().solve();\n\t}\n\tint n,k;\n\tvoid solve(){\n\t\tScanner sc=new Scanner(System.in);\n\t\tn=sc.nextInt();\n\t\tk=sc.nextInt();\n\t\tint[]a=new int[n];\n\t\tint[]b=new int[n];\n\t\tPair[] p=new Pair[n];\n\t\tfor(int i=0;i0)continue;\n\t\t\telse{\n\t\t\t\tSystem.out.println(p[i].a);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\tclass Pair implements Comparable{\n\t\tint a;\n\t\tint b;\n\t\tPair(int a,int b){\n\t\t\tthis.a=a;\n\t\t\tthis.b=b;\n\t\t}\n\t\t\n\t\tpublic int compareTo(Pair o){\n\t\t\treturn this.a-o.a;\n\t\t}\n\t}\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": 722, "cpu_time_ms": 604, "memory_kb": 64916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s943167541", "group_id": "codeNet:p03723", "input_text": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n int c = sc.nextInt();\n if (a == b && b == c) {\n System.out.println(-1);\n return;\n }\n\n int count = 0;\n while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {\n int disA = a / 2;\n int disB = b / 2;\n int disC = c / 2;\n a = a/2 + disB + disC;\n b = b/2 + disA + disC;\n b = b/2 + disB + disA;\n count++;\n }\n\n System.out.println(count);\n }\n}\n", "language": "Java", "metadata": {"date": 1586729260, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03723.html", "problem_id": "p03723", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03723/input.txt", "sample_output_relpath": "derived/input_output/data/p03723/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03723/Java/s943167541.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s943167541", "user_id": "u291818671"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n int c = sc.nextInt();\n if (a == b && b == c) {\n System.out.println(-1);\n return;\n }\n\n int count = 0;\n while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {\n int disA = a / 2;\n int disB = b / 2;\n int disC = c / 2;\n a = a/2 + disB + disC;\n b = b/2 + disA + disC;\n b = b/2 + disB + disA;\n count++;\n }\n\n System.out.println(count);\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:\n\nEach person simultaneously divides his cookies in half and gives one half to each of the other two persons.\n\nThis action will be repeated until there is a person with odd number of cookies in hand.\n\nHow many times will they repeat this action?\nNote that the answer may not be finite.\n\nConstraints\n\n1 ≤ A,B,C ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the number of times the action will be performed by the three people, if this number is finite.\nIf it is infinite, print -1 instead.\n\nSample Input 1\n\n4 12 20\n\nSample Output 1\n\n3\n\nInitially, Takahashi, Aoki and Snuke have 4, 12 and 20 cookies. Then,\n\nAfter the first action, they have 16, 12 and 8.\n\nAfter the second action, they have 10, 12 and 14.\n\nAfter the third action, they have 13, 12 and 11.\n\nNow, Takahashi and Snuke have odd number of cookies, and therefore the answer is 3.\n\nSample Input 2\n\n14 14 14\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n454 414 444\n\nSample Output 3\n\n1", "sample_input": "4 12 20\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03723", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:\n\nEach person simultaneously divides his cookies in half and gives one half to each of the other two persons.\n\nThis action will be repeated until there is a person with odd number of cookies in hand.\n\nHow many times will they repeat this action?\nNote that the answer may not be finite.\n\nConstraints\n\n1 ≤ A,B,C ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the number of times the action will be performed by the three people, if this number is finite.\nIf it is infinite, print -1 instead.\n\nSample Input 1\n\n4 12 20\n\nSample Output 1\n\n3\n\nInitially, Takahashi, Aoki and Snuke have 4, 12 and 20 cookies. Then,\n\nAfter the first action, they have 16, 12 and 8.\n\nAfter the second action, they have 10, 12 and 14.\n\nAfter the third action, they have 13, 12 and 11.\n\nNow, Takahashi and Snuke have odd number of cookies, and therefore the answer is 3.\n\nSample Input 2\n\n14 14 14\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n454 414 444\n\nSample Output 3\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 670, "cpu_time_ms": 98, "memory_kb": 21844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s785493121", "group_id": "codeNet:p03723", "input_text": "import java.util.*;\npublic class Main{\n\tpublic static void main(String[] args){\n \tScanner sc = new Scanner(System.in);\n long a = sc.nextLong();\n long b = sc.nextLong();\n long c = sc.nextLong();\n int cnt = 0;\n long s = a+b+c;\n while(a%2==0&&b%2==0&&c%2==0){\n \ta = -a/2+s;\n b = -b/2+s;\n c = -c/2+s;\n cnt++;\n }\n System.out.println(cnt);\n }\n}", "language": "Java", "metadata": {"date": 1569454342, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03723.html", "problem_id": "p03723", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03723/input.txt", "sample_output_relpath": "derived/input_output/data/p03723/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03723/Java/s785493121.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s785493121", "user_id": "u547167033"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.*;\npublic class Main{\n\tpublic static void main(String[] args){\n \tScanner sc = new Scanner(System.in);\n long a = sc.nextLong();\n long b = sc.nextLong();\n long c = sc.nextLong();\n int cnt = 0;\n long s = a+b+c;\n while(a%2==0&&b%2==0&&c%2==0){\n \ta = -a/2+s;\n b = -b/2+s;\n c = -c/2+s;\n cnt++;\n }\n System.out.println(cnt);\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:\n\nEach person simultaneously divides his cookies in half and gives one half to each of the other two persons.\n\nThis action will be repeated until there is a person with odd number of cookies in hand.\n\nHow many times will they repeat this action?\nNote that the answer may not be finite.\n\nConstraints\n\n1 ≤ A,B,C ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the number of times the action will be performed by the three people, if this number is finite.\nIf it is infinite, print -1 instead.\n\nSample Input 1\n\n4 12 20\n\nSample Output 1\n\n3\n\nInitially, Takahashi, Aoki and Snuke have 4, 12 and 20 cookies. Then,\n\nAfter the first action, they have 16, 12 and 8.\n\nAfter the second action, they have 10, 12 and 14.\n\nAfter the third action, they have 13, 12 and 11.\n\nNow, Takahashi and Snuke have odd number of cookies, and therefore the answer is 3.\n\nSample Input 2\n\n14 14 14\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n454 414 444\n\nSample Output 3\n\n1", "sample_input": "4 12 20\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03723", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:\n\nEach person simultaneously divides his cookies in half and gives one half to each of the other two persons.\n\nThis action will be repeated until there is a person with odd number of cookies in hand.\n\nHow many times will they repeat this action?\nNote that the answer may not be finite.\n\nConstraints\n\n1 ≤ A,B,C ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the number of times the action will be performed by the three people, if this number is finite.\nIf it is infinite, print -1 instead.\n\nSample Input 1\n\n4 12 20\n\nSample Output 1\n\n3\n\nInitially, Takahashi, Aoki and Snuke have 4, 12 and 20 cookies. Then,\n\nAfter the first action, they have 16, 12 and 8.\n\nAfter the second action, they have 10, 12 and 14.\n\nAfter the third action, they have 13, 12 and 11.\n\nNow, Takahashi and Snuke have odd number of cookies, and therefore the answer is 3.\n\nSample Input 2\n\n14 14 14\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n454 414 444\n\nSample Output 3\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 410, "cpu_time_ms": 97, "memory_kb": 23636}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s822210247", "group_id": "codeNet:p03724", "input_text": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.StringTokenizer;\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n MyScanner in = new MyScanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n B solver = new B();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class B {\n public void solve(int testNumber, MyScanner in, PrintWriter out) {\n int N = in.nextInt();\n int M = in.nextInt();\n\n int[] count = new int[N + 1];\n for (int i = 0; i < M; i++) {\n int a = in.nextInt();\n int b = in.nextInt();\n count[a]++;\n count[b]++;\n }\n\n for (int n : count) {\n if (n % 2 != 0) {\n out.println(\"NO\");\n return;\n }\n }\n out.println(\"YES\");\n }\n\n }\n\n static class MyScanner {\n private BufferedReader in;\n private StringTokenizer st;\n\n public MyScanner(InputStream stream) {\n in = new BufferedReader(new InputStreamReader(stream));\n }\n\n public String next() {\n while (st == null || !st.hasMoreTokens()) {\n try {\n String rl = in.readLine();\n if (rl == null) {\n return null;\n }\n st = new StringTokenizer(rl);\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return st.nextToken();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n }\n}\n\n", "language": "Java", "metadata": {"date": 1577328139, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03724.html", "problem_id": "p03724", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03724/input.txt", "sample_output_relpath": "derived/input_output/data/p03724/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03724/Java/s822210247.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s822210247", "user_id": "u305384049"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.StringTokenizer;\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n */\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n MyScanner in = new MyScanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n B solver = new B();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class B {\n public void solve(int testNumber, MyScanner in, PrintWriter out) {\n int N = in.nextInt();\n int M = in.nextInt();\n\n int[] count = new int[N + 1];\n for (int i = 0; i < M; i++) {\n int a = in.nextInt();\n int b = in.nextInt();\n count[a]++;\n count[b]++;\n }\n\n for (int n : count) {\n if (n % 2 != 0) {\n out.println(\"NO\");\n return;\n }\n }\n out.println(\"YES\");\n }\n\n }\n\n static class MyScanner {\n private BufferedReader in;\n private StringTokenizer st;\n\n public MyScanner(InputStream stream) {\n in = new BufferedReader(new InputStreamReader(stream));\n }\n\n public String next() {\n while (st == null || !st.hasMoreTokens()) {\n try {\n String rl = in.readLine();\n if (rl == null) {\n return null;\n }\n st = new StringTokenizer(rl);\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return st.nextToken();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n }\n}\n\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi is not good at problems about trees in programming contests, and Aoki is helping him practice.\n\nFirst, Takahashi created a tree with N vertices numbered 1 through N, and wrote 0 at each edge.\n\nThen, Aoki gave him M queries. The i-th of them is as follows:\n\nIncrement the number written at each edge along the path connecting vertices a_i and b_i, by one.\n\nAfter Takahashi executed all of the queries, he told Aoki that, for every edge, the written number became an even number.\nHowever, Aoki forgot to confirm that the graph Takahashi created was actually a tree, and it is possible that Takahashi made a mistake in creating a tree or executing queries.\n\nDetermine whether there exists a tree that has the property mentioned by Takahashi.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ M ≤ 10^5\n\n1 ≤ a_i,b_i ≤ N\n\na_i ≠ b_i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint YES if there exists a tree that has the property mentioned by Takahashi; print NO otherwise.\n\nSample Input 1\n\n4 4\n1 2\n2 4\n1 3\n3 4\n\nSample Output 1\n\nYES\n\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3 and 1-4.\nIn this case, the number written at every edge will become 2.\n\nSample Input 2\n\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\n\nSample Output 2\n\nNO", "sample_input": "4 4\n1 2\n2 4\n1 3\n3 4\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03724", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi is not good at problems about trees in programming contests, and Aoki is helping him practice.\n\nFirst, Takahashi created a tree with N vertices numbered 1 through N, and wrote 0 at each edge.\n\nThen, Aoki gave him M queries. The i-th of them is as follows:\n\nIncrement the number written at each edge along the path connecting vertices a_i and b_i, by one.\n\nAfter Takahashi executed all of the queries, he told Aoki that, for every edge, the written number became an even number.\nHowever, Aoki forgot to confirm that the graph Takahashi created was actually a tree, and it is possible that Takahashi made a mistake in creating a tree or executing queries.\n\nDetermine whether there exists a tree that has the property mentioned by Takahashi.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ M ≤ 10^5\n\n1 ≤ a_i,b_i ≤ N\n\na_i ≠ b_i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint YES if there exists a tree that has the property mentioned by Takahashi; print NO otherwise.\n\nSample Input 1\n\n4 4\n1 2\n2 4\n1 3\n3 4\n\nSample Output 1\n\nYES\n\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3 and 1-4.\nIn this case, the number written at every edge will become 2.\n\nSample Input 2\n\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\n\nSample Output 2\n\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2107, "cpu_time_ms": 211, "memory_kb": 41596}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s284449975", "group_id": "codeNet:p03724", "input_text": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.NoSuchElementException;\n\n\npublic class Main {\n public static void main(String[] args) {\n FastScanner sc = new FastScanner();\n int N = sc.nextInt();\n int M = sc.nextInt();\n \n int[] count = new int[N];\n for (int i = 0; i < M; i ++) {\n int a = sc.nextInt() - 1;\n int b = sc.nextInt() - 1;\n count[a] ++;\n count[b] ++;\n }\n \n boolean flg = true;\n for (int v : count) {\n if (v % 2 == 1) {\n flg = false;\n break;\n }\n }\n System.out.println(flg ? \"YES\" : \"NO\");\n \n }\n\n}\n\n\nclass FastScanner {\n\tpublic static String debug = null;\n\n\tprivate final InputStream in = System.in;\n\tprivate int ptr = 0;\n\tprivate int buflen = 0;\n\tprivate byte[] buffer = new byte[1024];\n\tprivate boolean eos = false;\n\n\tprivate boolean hasNextByte() {\n\t\tif (ptr < buflen) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\tptr = 0;\n\t\t\ttry {\n\t\t\t\tif (debug != null) {\n\t\t\t\t\tbuflen = debug.length();\n\t\t\t\t\tbuffer = debug.getBytes();\n\t\t\t\t\tdebug = \"\";\n\t\t\t\t\teos = true;\n\t\t\t\t} else {\n\t\t\t\t\tbuflen = in.read(buffer);\n\t\t\t\t}\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (buflen < 0) {\n\t\t\t\teos = true;\n\t\t\t\treturn false;\n\t\t\t} else if (buflen == 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tprivate int readByte() {\n\t\tif (hasNextByte())\n\t\t\treturn buffer[ptr++];\n\t\telse\n\t\t\treturn -1;\n\t}\n\n\tprivate static boolean isPrintableChar(int c) {\n\t\treturn 33 <= c && c <= 126;\n\t}\n\n\tprivate void skipUnprintable() {\n\t\twhile (hasNextByte() && !isPrintableChar(buffer[ptr]))\n\t\t\tptr++;\n\t}\n\n\tpublic boolean isEOS() {\n\t\treturn this.eos;\n\t}\n\n\tpublic boolean hasNext() {\n\t\tskipUnprintable();\n\t\treturn hasNextByte();\n\t}\n\n\tpublic String next() {\n\t\tif (!hasNext())\n\t\t\tthrow new NoSuchElementException();\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint b = readByte();\n\t\twhile (isPrintableChar(b)) {\n\t\t\tsb.appendCodePoint(b);\n\t\t\tb = readByte();\n\t\t}\n\t\treturn sb.toString();\n\t}\n\n\tpublic long nextLong() {\n\t\tif (!hasNext())\n\t\t\tthrow new NoSuchElementException();\n\t\tlong n = 0;\n\t\tboolean minus = false;\n\t\tint b = readByte();\n\t\tif (b == '-') {\n\t\t\tminus = true;\n\t\t\tb = readByte();\n\t\t}\n\t\tif (b < '0' || '9' < b) {\n\t\t\tthrow new NumberFormatException();\n\t\t}\n\t\twhile (true) {\n\t\t\tif ('0' <= b && b <= '9') {\n\t\t\t\tn *= 10;\n\t\t\t\tn += b - '0';\n\t\t\t} else if (b == -1 || !isPrintableChar(b)) {\n\t\t\t\treturn minus ? -n : n;\n\t\t\t} else {\n\t\t\t\tthrow new NumberFormatException();\n\t\t\t}\n\t\t\tb = readByte();\n\t\t}\n\t}\n\n\tpublic int nextInt() {\n\t\treturn (int) nextLong();\n\t}\n\n\tpublic long[] nextLongList(int n) {\n\t\treturn nextLongTable(1, n)[0];\n\t}\n\n\tpublic int[] nextIntList(int n) {\n\t\treturn nextIntTable(1, n)[0];\n\t}\n\n\tpublic long[][] nextLongTable(int n, int m) {\n\t\tlong[][] ret = new long[n][m];\n\t\tfor (int i = 0; i < n; i ++) {\n\t\t\tfor (int j = 0; j < m; j ++) {\n\t\t\t\tret[i][j] = nextLong();\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t}\n\n\tpublic int[][] nextIntTable(int n, int m) {\n\t\tint[][] ret = new int[n][m];\n\t\tfor (int i = 0; i < n; i ++) {\n\t\t\tfor (int j = 0; j < m; j ++) {\n\t\t\t\tret[i][j] = nextInt();\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t}\n}", "language": "Java", "metadata": {"date": 1494120418, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03724.html", "problem_id": "p03724", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03724/input.txt", "sample_output_relpath": "derived/input_output/data/p03724/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03724/Java/s284449975.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s284449975", "user_id": "u769201746"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.NoSuchElementException;\n\n\npublic class Main {\n public static void main(String[] args) {\n FastScanner sc = new FastScanner();\n int N = sc.nextInt();\n int M = sc.nextInt();\n \n int[] count = new int[N];\n for (int i = 0; i < M; i ++) {\n int a = sc.nextInt() - 1;\n int b = sc.nextInt() - 1;\n count[a] ++;\n count[b] ++;\n }\n \n boolean flg = true;\n for (int v : count) {\n if (v % 2 == 1) {\n flg = false;\n break;\n }\n }\n System.out.println(flg ? \"YES\" : \"NO\");\n \n }\n\n}\n\n\nclass FastScanner {\n\tpublic static String debug = null;\n\n\tprivate final InputStream in = System.in;\n\tprivate int ptr = 0;\n\tprivate int buflen = 0;\n\tprivate byte[] buffer = new byte[1024];\n\tprivate boolean eos = false;\n\n\tprivate boolean hasNextByte() {\n\t\tif (ptr < buflen) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\tptr = 0;\n\t\t\ttry {\n\t\t\t\tif (debug != null) {\n\t\t\t\t\tbuflen = debug.length();\n\t\t\t\t\tbuffer = debug.getBytes();\n\t\t\t\t\tdebug = \"\";\n\t\t\t\t\teos = true;\n\t\t\t\t} else {\n\t\t\t\t\tbuflen = in.read(buffer);\n\t\t\t\t}\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (buflen < 0) {\n\t\t\t\teos = true;\n\t\t\t\treturn false;\n\t\t\t} else if (buflen == 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tprivate int readByte() {\n\t\tif (hasNextByte())\n\t\t\treturn buffer[ptr++];\n\t\telse\n\t\t\treturn -1;\n\t}\n\n\tprivate static boolean isPrintableChar(int c) {\n\t\treturn 33 <= c && c <= 126;\n\t}\n\n\tprivate void skipUnprintable() {\n\t\twhile (hasNextByte() && !isPrintableChar(buffer[ptr]))\n\t\t\tptr++;\n\t}\n\n\tpublic boolean isEOS() {\n\t\treturn this.eos;\n\t}\n\n\tpublic boolean hasNext() {\n\t\tskipUnprintable();\n\t\treturn hasNextByte();\n\t}\n\n\tpublic String next() {\n\t\tif (!hasNext())\n\t\t\tthrow new NoSuchElementException();\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint b = readByte();\n\t\twhile (isPrintableChar(b)) {\n\t\t\tsb.appendCodePoint(b);\n\t\t\tb = readByte();\n\t\t}\n\t\treturn sb.toString();\n\t}\n\n\tpublic long nextLong() {\n\t\tif (!hasNext())\n\t\t\tthrow new NoSuchElementException();\n\t\tlong n = 0;\n\t\tboolean minus = false;\n\t\tint b = readByte();\n\t\tif (b == '-') {\n\t\t\tminus = true;\n\t\t\tb = readByte();\n\t\t}\n\t\tif (b < '0' || '9' < b) {\n\t\t\tthrow new NumberFormatException();\n\t\t}\n\t\twhile (true) {\n\t\t\tif ('0' <= b && b <= '9') {\n\t\t\t\tn *= 10;\n\t\t\t\tn += b - '0';\n\t\t\t} else if (b == -1 || !isPrintableChar(b)) {\n\t\t\t\treturn minus ? -n : n;\n\t\t\t} else {\n\t\t\t\tthrow new NumberFormatException();\n\t\t\t}\n\t\t\tb = readByte();\n\t\t}\n\t}\n\n\tpublic int nextInt() {\n\t\treturn (int) nextLong();\n\t}\n\n\tpublic long[] nextLongList(int n) {\n\t\treturn nextLongTable(1, n)[0];\n\t}\n\n\tpublic int[] nextIntList(int n) {\n\t\treturn nextIntTable(1, n)[0];\n\t}\n\n\tpublic long[][] nextLongTable(int n, int m) {\n\t\tlong[][] ret = new long[n][m];\n\t\tfor (int i = 0; i < n; i ++) {\n\t\t\tfor (int j = 0; j < m; j ++) {\n\t\t\t\tret[i][j] = nextLong();\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t}\n\n\tpublic int[][] nextIntTable(int n, int m) {\n\t\tint[][] ret = new int[n][m];\n\t\tfor (int i = 0; i < n; i ++) {\n\t\t\tfor (int j = 0; j < m; j ++) {\n\t\t\t\tret[i][j] = nextInt();\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t}\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi is not good at problems about trees in programming contests, and Aoki is helping him practice.\n\nFirst, Takahashi created a tree with N vertices numbered 1 through N, and wrote 0 at each edge.\n\nThen, Aoki gave him M queries. The i-th of them is as follows:\n\nIncrement the number written at each edge along the path connecting vertices a_i and b_i, by one.\n\nAfter Takahashi executed all of the queries, he told Aoki that, for every edge, the written number became an even number.\nHowever, Aoki forgot to confirm that the graph Takahashi created was actually a tree, and it is possible that Takahashi made a mistake in creating a tree or executing queries.\n\nDetermine whether there exists a tree that has the property mentioned by Takahashi.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ M ≤ 10^5\n\n1 ≤ a_i,b_i ≤ N\n\na_i ≠ b_i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint YES if there exists a tree that has the property mentioned by Takahashi; print NO otherwise.\n\nSample Input 1\n\n4 4\n1 2\n2 4\n1 3\n3 4\n\nSample Output 1\n\nYES\n\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3 and 1-4.\nIn this case, the number written at every edge will become 2.\n\nSample Input 2\n\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\n\nSample Output 2\n\nNO", "sample_input": "4 4\n1 2\n2 4\n1 3\n3 4\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03724", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi is not good at problems about trees in programming contests, and Aoki is helping him practice.\n\nFirst, Takahashi created a tree with N vertices numbered 1 through N, and wrote 0 at each edge.\n\nThen, Aoki gave him M queries. The i-th of them is as follows:\n\nIncrement the number written at each edge along the path connecting vertices a_i and b_i, by one.\n\nAfter Takahashi executed all of the queries, he told Aoki that, for every edge, the written number became an even number.\nHowever, Aoki forgot to confirm that the graph Takahashi created was actually a tree, and it is possible that Takahashi made a mistake in creating a tree or executing queries.\n\nDetermine whether there exists a tree that has the property mentioned by Takahashi.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ M ≤ 10^5\n\n1 ≤ a_i,b_i ≤ N\n\na_i ≠ b_i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint YES if there exists a tree that has the property mentioned by Takahashi; print NO otherwise.\n\nSample Input 1\n\n4 4\n1 2\n2 4\n1 3\n3 4\n\nSample Output 1\n\nYES\n\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3 and 1-4.\nIn this case, the number written at every edge will become 2.\n\nSample Input 2\n\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\n\nSample Output 2\n\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3073, "cpu_time_ms": 135, "memory_kb": 22852}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s887219708", "group_id": "codeNet:p03727", "input_text": "import java.io.ByteArrayInputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.*;\n\npublic class Main {\n static InputStream is;\n static PrintWriter out;\n static String INPUT = \"\";\n\n void solve() {\n int n = ni();\n Set edge[] = new Set[n];\n for (int i = 0; i < n; ++i) {\n edge[i] = new HashSet<>();\n }\n Map edges = new HashMap<>();\n Queue pair = new ArrayDeque<>();\n for (int i = 0; i < (n - 1) * 2; ++i) {\n int a = ni() - 1;\n int b = ni() - 1;\n edge[a].add(b);\n edge[b].add(a);\n long key = getKey(a, b);\n int c = inc(edges, key);\n if (c == 2) {\n pair.add(key);\n }\n }\n boolean used[] = new boolean[n];\n for (int m = 1; m < n; ++m) {\n Integer x = -1, y = -1;\n while (!pair.isEmpty()) {\n long key = pair.poll();\n int a = (int) (key >>> 32);\n int b = (int) (key & ((1L << 32) - 1L));\n if (!used[a] && !used[b]) {\n x = a;\n y = b;\n break;\n }\n }\n if (x.equals(-1)) {\n out.println(\"NO\");\n return;\n }\n for (Integer t : edge[y]) {\n edge[t].remove(y);\n if (!t.equals(x)) {\n edge[t].add(x);\n edge[x].add(t);\n long key = getKey(t, x);\n int c = inc(edges, key);\n if (c == 2) {\n pair.add(key);\n }\n }\n }\n used[y] = true;\n }\n out.println(\"YES\");\n }\n\n long getKey(int a, int b) {\n if (a > b) {\n int t = a;\n a = b;\n b = t;\n }\n return (((long) a) << 32) | (long) b;\n }\n\n int inc(Map map, long key) {\n Integer x = map.get(key);\n if (x == null) {\n x = 1;\n } else {\n x += 1;\n }\n map.put(key, x);\n return x;\n }\n\n public static void main(String[] args) throws Exception {\n long S = System.currentTimeMillis();\n is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n out = new PrintWriter(System.out);\n\n new Main().solve();\n out.flush();\n long G = System.currentTimeMillis();\n // tr(G - S + \"ms\");\n }\n\n private static boolean eof() {\n if (lenbuf == -1) return true;\n int lptr = ptrbuf;\n while (lptr < lenbuf)\n if (!isSpaceChar(inbuf[lptr++])) return false;\n\n try {\n is.mark(1000);\n while (true) {\n int b = is.read();\n if (b == -1) {\n is.reset();\n return true;\n } else if (!isSpaceChar(b)) {\n is.reset();\n return false;\n }\n }\n } catch (IOException e) {\n return true;\n }\n }\n\n private static byte[] inbuf = new byte[1024];\n static int lenbuf = 0, ptrbuf = 0;\n\n private static int readByte() {\n if (lenbuf == -1) throw new InputMismatchException();\n if (ptrbuf >= lenbuf) {\n ptrbuf = 0;\n try {\n lenbuf = is.read(inbuf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (lenbuf <= 0) return -1;\n }\n return inbuf[ptrbuf++];\n }\n\n private static boolean isSpaceChar(int c) {\n return !(c >= 33 && c <= 126);\n }\n\n private static int skip() {\n int b;\n while ((b = readByte()) != -1 && isSpaceChar(b))\n ;\n return b;\n }\n\n private static double nd() {\n return Double.parseDouble(ns());\n }\n\n private static char nc() {\n return (char) skip();\n }\n\n private static String ns() {\n int b = skip();\n StringBuilder sb = new StringBuilder();\n while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n private static char[] ns(int n) {\n char[] buf = new char[n];\n int b = skip(), p = 0;\n while (p < n && !(isSpaceChar(b))) {\n buf[p++] = (char) b;\n b = readByte();\n }\n return n == p ? buf : Arrays.copyOf(buf, p);\n }\n\n private static char[][] nm(int n, int m) {\n char[][] map = new char[n][];\n for (int i = 0; i < n; i++)\n map[i] = ns(m);\n return map;\n }\n\n private static int[] na(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = ni();\n return a;\n }\n\n private static int ni() {\n int num = 0, b;\n boolean minus = false;\n while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))\n ;\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n\n while (true) {\n if (b >= '0' && b <= '9') {\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n\n private static long nl() {\n long num = 0;\n int b;\n boolean minus = false;\n while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))\n ;\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n\n while (true) {\n if (b >= '0' && b <= '9') {\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n\n private static void tr(Object... o) {\n System.err.println(Arrays.deepToString(o));\n }\n}", "language": "Java", "metadata": {"date": 1494160911, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03727.html", "problem_id": "p03727", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03727/input.txt", "sample_output_relpath": "derived/input_output/data/p03727/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03727/Java/s887219708.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s887219708", "user_id": "u316355973"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.io.ByteArrayInputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.*;\n\npublic class Main {\n static InputStream is;\n static PrintWriter out;\n static String INPUT = \"\";\n\n void solve() {\n int n = ni();\n Set edge[] = new Set[n];\n for (int i = 0; i < n; ++i) {\n edge[i] = new HashSet<>();\n }\n Map edges = new HashMap<>();\n Queue pair = new ArrayDeque<>();\n for (int i = 0; i < (n - 1) * 2; ++i) {\n int a = ni() - 1;\n int b = ni() - 1;\n edge[a].add(b);\n edge[b].add(a);\n long key = getKey(a, b);\n int c = inc(edges, key);\n if (c == 2) {\n pair.add(key);\n }\n }\n boolean used[] = new boolean[n];\n for (int m = 1; m < n; ++m) {\n Integer x = -1, y = -1;\n while (!pair.isEmpty()) {\n long key = pair.poll();\n int a = (int) (key >>> 32);\n int b = (int) (key & ((1L << 32) - 1L));\n if (!used[a] && !used[b]) {\n x = a;\n y = b;\n break;\n }\n }\n if (x.equals(-1)) {\n out.println(\"NO\");\n return;\n }\n for (Integer t : edge[y]) {\n edge[t].remove(y);\n if (!t.equals(x)) {\n edge[t].add(x);\n edge[x].add(t);\n long key = getKey(t, x);\n int c = inc(edges, key);\n if (c == 2) {\n pair.add(key);\n }\n }\n }\n used[y] = true;\n }\n out.println(\"YES\");\n }\n\n long getKey(int a, int b) {\n if (a > b) {\n int t = a;\n a = b;\n b = t;\n }\n return (((long) a) << 32) | (long) b;\n }\n\n int inc(Map map, long key) {\n Integer x = map.get(key);\n if (x == null) {\n x = 1;\n } else {\n x += 1;\n }\n map.put(key, x);\n return x;\n }\n\n public static void main(String[] args) throws Exception {\n long S = System.currentTimeMillis();\n is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n out = new PrintWriter(System.out);\n\n new Main().solve();\n out.flush();\n long G = System.currentTimeMillis();\n // tr(G - S + \"ms\");\n }\n\n private static boolean eof() {\n if (lenbuf == -1) return true;\n int lptr = ptrbuf;\n while (lptr < lenbuf)\n if (!isSpaceChar(inbuf[lptr++])) return false;\n\n try {\n is.mark(1000);\n while (true) {\n int b = is.read();\n if (b == -1) {\n is.reset();\n return true;\n } else if (!isSpaceChar(b)) {\n is.reset();\n return false;\n }\n }\n } catch (IOException e) {\n return true;\n }\n }\n\n private static byte[] inbuf = new byte[1024];\n static int lenbuf = 0, ptrbuf = 0;\n\n private static int readByte() {\n if (lenbuf == -1) throw new InputMismatchException();\n if (ptrbuf >= lenbuf) {\n ptrbuf = 0;\n try {\n lenbuf = is.read(inbuf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (lenbuf <= 0) return -1;\n }\n return inbuf[ptrbuf++];\n }\n\n private static boolean isSpaceChar(int c) {\n return !(c >= 33 && c <= 126);\n }\n\n private static int skip() {\n int b;\n while ((b = readByte()) != -1 && isSpaceChar(b))\n ;\n return b;\n }\n\n private static double nd() {\n return Double.parseDouble(ns());\n }\n\n private static char nc() {\n return (char) skip();\n }\n\n private static String ns() {\n int b = skip();\n StringBuilder sb = new StringBuilder();\n while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n private static char[] ns(int n) {\n char[] buf = new char[n];\n int b = skip(), p = 0;\n while (p < n && !(isSpaceChar(b))) {\n buf[p++] = (char) b;\n b = readByte();\n }\n return n == p ? buf : Arrays.copyOf(buf, p);\n }\n\n private static char[][] nm(int n, int m) {\n char[][] map = new char[n][];\n for (int i = 0; i < n; i++)\n map[i] = ns(m);\n return map;\n }\n\n private static int[] na(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = ni();\n return a;\n }\n\n private static int ni() {\n int num = 0, b;\n boolean minus = false;\n while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))\n ;\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n\n while (true) {\n if (b >= '0' && b <= '9') {\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n\n private static long nl() {\n long num = 0;\n int b;\n boolean minus = false;\n while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))\n ;\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n\n while (true) {\n if (b >= '0' && b <= '9') {\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n\n private static void tr(Object... o) {\n System.err.println(Arrays.deepToString(o));\n }\n}", "problem_context": "Score : 1400 points\n\nProblem Statement\n\nThere is a tree with N vertices numbered 1 through N.\nThe i-th of the N-1 edges connects vertices a_i and b_i.\n\nInitially, each edge is painted blue.\nTakahashi will convert this blue tree into a red tree, by performing the following operation N-1 times:\n\nSelect a simple path that consists of only blue edges, and remove one of those edges.\n\nThen, span a new red edge between the two endpoints of the selected path.\n\nHis objective is to obtain a tree that has a red edge connecting vertices c_i and d_i, for each i.\n\nDetermine whether this is achievable.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i,b_i,c_i,d_i ≤ N\n\na_i ≠ b_i\n\nc_i ≠ d_i\n\nBoth input graphs are trees.\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}\nc_1 d_1\n:\nc_{N-1} d_{N-1}\n\nOutput\n\nPrint YES if the objective is achievable; print NO otherwise.\n\nSample Input 1\n\n3\n1 2\n2 3\n1 3\n3 2\n\nSample Output 1\n\nYES\n\nThe objective is achievable, as below:\n\nFirst, select the path connecting vertices 1 and 3, and remove a blue edge 1-2. Then, span a new red edge 1-3.\n\nNext, select the path connecting vertices 2 and 3, and remove a blue edge 2-3. Then, span a new red edge 2-3.\n\nSample Input 2\n\n5\n1 2\n2 3\n3 4\n4 5\n3 4\n2 4\n1 4\n1 5\n\nSample Output 2\n\nYES\n\nSample Input 3\n\n6\n1 2\n3 5\n4 6\n1 6\n5 1\n5 3\n1 4\n2 6\n4 3\n5 6\n\nSample Output 3\n\nNO", "sample_input": "3\n1 2\n2 3\n1 3\n3 2\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03727", "source_text": "Score : 1400 points\n\nProblem Statement\n\nThere is a tree with N vertices numbered 1 through N.\nThe i-th of the N-1 edges connects vertices a_i and b_i.\n\nInitially, each edge is painted blue.\nTakahashi will convert this blue tree into a red tree, by performing the following operation N-1 times:\n\nSelect a simple path that consists of only blue edges, and remove one of those edges.\n\nThen, span a new red edge between the two endpoints of the selected path.\n\nHis objective is to obtain a tree that has a red edge connecting vertices c_i and d_i, for each i.\n\nDetermine whether this is achievable.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i,b_i,c_i,d_i ≤ N\n\na_i ≠ b_i\n\nc_i ≠ d_i\n\nBoth input graphs are trees.\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}\nc_1 d_1\n:\nc_{N-1} d_{N-1}\n\nOutput\n\nPrint YES if the objective is achievable; print NO otherwise.\n\nSample Input 1\n\n3\n1 2\n2 3\n1 3\n3 2\n\nSample Output 1\n\nYES\n\nThe objective is achievable, as below:\n\nFirst, select the path connecting vertices 1 and 3, and remove a blue edge 1-2. Then, span a new red edge 1-3.\n\nNext, select the path connecting vertices 2 and 3, and remove a blue edge 2-3. Then, span a new red edge 2-3.\n\nSample Input 2\n\n5\n1 2\n2 3\n3 4\n4 5\n3 4\n2 4\n1 4\n1 5\n\nSample Output 2\n\nYES\n\nSample Input 3\n\n6\n1 2\n3 5\n4 6\n1 6\n5 1\n5 3\n1 4\n2 6\n4 3\n5 6\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": 6142, "cpu_time_ms": 1351, "memory_kb": 146276}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s874198184", "group_id": "codeNet:p03730", "input_text": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint a = scan.nextInt();\n\t\tint b = scan.nextInt();\n\t\tint c = scan.nextInt();\n\t\tString message = \"NO\";\n\t\tint n = 0;\n\t\tint i = 0;\n\t\tfor(i = 0; i < b; i++) {\n\t\t\tn = n + a;\n\t\t\tif(n % b == c) {\n\t\t\t\tmessage = \"YES\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(message);\n\t}\n}", "language": "Java", "metadata": {"date": 1560803578, "filename_ext": "java", "original_language": "Java8 (OpenJDK 1.8.0)", "problem_description_relpath": "problem_descriptions/p03730.html", "problem_id": "p03730", "resource_group": "high_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/Java/s874198184.java", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s874198184", "user_id": "u645389195"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint a = scan.nextInt();\n\t\tint b = scan.nextInt();\n\t\tint c = scan.nextInt();\n\t\tString message = \"NO\";\n\t\tint n = 0;\n\t\tint i = 0;\n\t\tfor(i = 0; i < b; i++) {\n\t\t\tn = n + a;\n\t\t\tif(n % b == c) {\n\t\t\t\tmessage = \"YES\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(message);\n\t}\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": 397, "cpu_time_ms": 95, "memory_kb": 21716}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Java:s307627982", "group_id": "codeNet:p03731", "input_text": "\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.util.ArrayDeque;\nimport java.util.Deque;\nimport java.util.InputMismatchException;\nimport java.util.Map;\nimport java.util.StringTokenizer;\nimport java.util.TreeMap;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tInputStream inputStream = System.in;\n\t\tOutputStream outputStream = System.out;\n\t\tInputReader in = new InputReader(inputStream);\n\t\tPrintWriter out = new PrintWriter(outputStream);\n\t\tTaskX solver = new TaskX();\n\t\tsolver.solve(1, in, out);\n\t\tout.close();\n\t}\n\n\tstatic class TaskX {\n\t\tpublic void solve(int testNumber, InputReader in, PrintWriter out) {\n\n\t\t\tint n = in.nextInt();\n\t\t\tint time = in.nextInt();\n\t\t\tint[] t = in.nextIntArray(n);\n\t\t\tlong sum = 0;\n\t\t\tDeque