{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s783770273", "group_id": "codeNet:p00001", "input_text": "#encoding:utf-8 No.0001\nlist_of_height = []\n\nwhile gets\n list_of_height.push $_.to_i\nend\n\nputs list_of_height.sort.reverse[0..2]", "language": "Ruby", "metadata": {"date": 1411982020, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s783770273.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s783770273", "user_id": "u949338836"}, "prompt_components": {"gold_output": "3776\n2848\n2840\n", "input_to_evaluate": "#encoding:utf-8 No.0001\nlist_of_height = []\n\nwhile gets\n list_of_height.push $_.to_i\nend\n\nputs list_of_height.sort.reverse[0..2]", "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": 128, "cpu_time_ms": 20, "memory_kb": 6096}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s417897264", "group_id": "codeNet:p00001", "input_text": "a = Array.new\n10.times do |i|\n\ta.push(gets.to_i)\nend\n\na.sort!\n\n3.times do |i|\n\tp a[a.size - i - 1]\nend", "language": "Ruby", "metadata": {"date": 1375717226, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s417897264.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s417897264", "user_id": "u348879714"}, "prompt_components": {"gold_output": "3776\n2848\n2840\n", "input_to_evaluate": "a = Array.new\n10.times do |i|\n\ta.push(gets.to_i)\nend\n\na.sort!\n\n3.times do |i|\n\tp a[a.size - i - 1]\nend", "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": 102, "cpu_time_ms": 10, "memory_kb": 6088}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s925146445", "group_id": "codeNet:p00001", "input_text": "x=[]\nn=10\nfor i in 0..(n-1)\n print \"山の高さ\"+(i+1).to_s+\"(整数)>\"\n x[i]=gets.chomp.to_i\nend\nmax=0\nnum=0\nfor i in 0..(n-1)\n if x[i]>=0 && x[i]<=10000\n max=x[i]\n num=i\n break\n end\nend\nfor i in num..(n-1)\n if x[i] > max && x[i]>=0 && x[i]<=10000\n max = x[i]\n end\nend\nputs \"最も高い山の高さ=\"+ max.to_s\nmax2=0\nfor i in num..(n-1)\n if x[i]max2 && x[i]>=0 && x[i]<=10000\n max2 = x[i]\n end\nend\nputs \"2番目に高い山の高さ=\" + max2.to_s\nmax3=0\nfor i in num..(n-1)\n if x[i]max3 && x[i]>=0 && x[i]<=10000\n max3=x[i]\n end\nend\nputs \"3番目に高い山の高さ=\" + max3.to_s", "language": "Ruby", "metadata": {"date": 1399438724, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s925146445.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s925146445", "user_id": "u329665696"}, "prompt_components": {"gold_output": "3776\n2848\n2840\n", "input_to_evaluate": "x=[]\nn=10\nfor i in 0..(n-1)\n print \"山の高さ\"+(i+1).to_s+\"(整数)>\"\n x[i]=gets.chomp.to_i\nend\nmax=0\nnum=0\nfor i in 0..(n-1)\n if x[i]>=0 && x[i]<=10000\n max=x[i]\n num=i\n break\n end\nend\nfor i in num..(n-1)\n if x[i] > max && x[i]>=0 && x[i]<=10000\n max = x[i]\n end\nend\nputs \"最も高い山の高さ=\"+ max.to_s\nmax2=0\nfor i in num..(n-1)\n if x[i]max2 && x[i]>=0 && x[i]<=10000\n max2 = x[i]\n end\nend\nputs \"2番目に高い山の高さ=\" + max2.to_s\nmax3=0\nfor i in num..(n-1)\n if x[i]max3 && x[i]>=0 && x[i]<=10000\n max3=x[i]\n end\nend\nputs \"3番目に高い山の高さ=\" + max3.to_s", "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": 640, "cpu_time_ms": 20, "memory_kb": 6108}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s260834913", "group_id": "codeNet:p00001", "input_text": "i = 0\narray = []\n\nwhile i < 10\n word = gets.chomp\n array.push word.to_i\n i = i+1\nend\n\narray = array.sort\narray = array.reverse\n\nputs array[0]\nputs array[1]\nputs array[2]", "language": "Ruby", "metadata": {"date": 1402306416, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s260834913.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s260834913", "user_id": "u949338836"}, "prompt_components": {"gold_output": "3776\n2848\n2840\n", "input_to_evaluate": "i = 0\narray = []\n\nwhile i < 10\n word = gets.chomp\n array.push word.to_i\n i = i+1\nend\n\narray = array.sort\narray = array.reverse\n\nputs array[0]\nputs array[1]\nputs array[2]", "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": 169, "cpu_time_ms": 20, "memory_kb": 6084}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s590542400", "group_id": "codeNet:p00002", "input_text": "data_set = []\nwhile numbers = gets\n data_set << (numbers[0].to_i + numbers[1].to_i).to_s.length\nend\nputs data_set", "language": "Ruby", "metadata": {"date": 1450075269, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s590542400.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s590542400", "user_id": "u969530080"}, "prompt_components": {"gold_output": "2\n3\n4\n", "input_to_evaluate": "data_set = []\nwhile numbers = gets\n data_set << (numbers[0].to_i + numbers[1].to_i).to_s.length\nend\nputs data_set", "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": 114, "cpu_time_ms": 30, "memory_kb": 8664}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s631580001", "group_id": "codeNet:p00003", "input_text": "# coding: utf-8\nline = gets\nwhile input = gets\n ans = []\n input = input.split(\" \").map!(&:to_i).sort\n ans.push(input[0] % 3,input[1] % 4,input[2] % 5)\n if ans.all? {|n| n == 0} ;puts \"YES\"\n else ;puts \"NO\"\n end\nend\n\n", "language": "Ruby", "metadata": {"date": 1520477607, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s631580001.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s631580001", "user_id": "u503172969"}, "prompt_components": {"gold_output": "YES\nNO\nNO\n", "input_to_evaluate": "# coding: utf-8\nline = gets\nwhile input = gets\n ans = []\n input = input.split(\" \").map!(&:to_i).sort\n ans.push(input[0] % 3,input[1] % 4,input[2] % 5)\n if ans.all? {|n| n == 0} ;puts \"YES\"\n else ;puts \"NO\"\n end\nend\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": 222, "cpu_time_ms": 50, "memory_kb": 6864}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s927160086", "group_id": "codeNet:p00004", "input_text": "input_a = gets.to_s\ninput_b = gets.to_s\n\nformula_a = input_a.split(' ').map(&:to_i)\nformula_b = input_b.split(' ').map(&:to_i)\n\nfa_x = ((formula_a[2] * formula_a[4]) - (formula_a[1] * formula_a[5])) / ((formula_a[0] * formula_a[4]) - (formula_a[1] * formula_a[3]) + 0.000)\nfa_y = ((formula_a[0] * formula_a[5]) - (formula_a[2] * formula_a[3])) / ((formula_a[0] * formula_a[4]) - (formula_a[1] * formula_a[3]) + 0.000)\nfb_x = ((formula_b[2] * formula_b[4]) - (formula_b[1] * formula_b[5])) / ((formula_b[0] * formula_b[4]) - (formula_b[1] * formula_b[3]) + 0.000)\nfb_y = ((formula_b[0] * formula_b[5]) - (formula_b[2] * formula_b[3])) / ((formula_b[0] * formula_b[4]) - (formula_b[1] * formula_b[3]) + 0.000)\n\nputs format('%.3f', fa_x) + \" \" + format('%.3f', fa_y)\nputs format('%.3f', fb_x) + \" \" + format('%.3f', fb_y)", "language": "Ruby", "metadata": {"date": 1481968626, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s927160086.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s927160086", "user_id": "u791170614"}, "prompt_components": {"gold_output": "-1.000 2.000\n1.000 4.000\n", "input_to_evaluate": "input_a = gets.to_s\ninput_b = gets.to_s\n\nformula_a = input_a.split(' ').map(&:to_i)\nformula_b = input_b.split(' ').map(&:to_i)\n\nfa_x = ((formula_a[2] * formula_a[4]) - (formula_a[1] * formula_a[5])) / ((formula_a[0] * formula_a[4]) - (formula_a[1] * formula_a[3]) + 0.000)\nfa_y = ((formula_a[0] * formula_a[5]) - (formula_a[2] * formula_a[3])) / ((formula_a[0] * formula_a[4]) - (formula_a[1] * formula_a[3]) + 0.000)\nfb_x = ((formula_b[2] * formula_b[4]) - (formula_b[1] * formula_b[5])) / ((formula_b[0] * formula_b[4]) - (formula_b[1] * formula_b[3]) + 0.000)\nfb_y = ((formula_b[0] * formula_b[5]) - (formula_b[2] * formula_b[3])) / ((formula_b[0] * formula_b[4]) - (formula_b[1] * formula_b[3]) + 0.000)\n\nputs format('%.3f', fa_x) + \" \" + format('%.3f', fa_y)\nputs format('%.3f', fb_x) + \" \" + format('%.3f', fb_y)", "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": 818, "cpu_time_ms": 30, "memory_kb": 8624}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s464434267", "group_id": "codeNet:p00004", "input_text": "while line = gets\n a, b = line.chomp.split.map(&:to_i)\n gcd = a.gcd(b)\n lcm = a * b / gcd\n puts \"#{gcd} #{lcm}\"\nend", "language": "Ruby", "metadata": {"date": 1495971173, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s464434267.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s464434267", "user_id": "u802537549"}, "prompt_components": {"gold_output": "-1.000 2.000\n1.000 4.000\n", "input_to_evaluate": "while line = gets\n a, b = line.chomp.split.map(&:to_i)\n gcd = a.gcd(b)\n lcm = a * b / gcd\n puts \"#{gcd} #{lcm}\"\nend", "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": 119, "cpu_time_ms": 40, "memory_kb": 8576}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s158939666", "group_id": "codeNet:p00004", "input_text": "while (input = STDIN.gets)!=nil do\n\n\tif input == \"\\n\"\n\t\tbreak\n\tend\n\n\tdata = [0.000,0.000,0.000,0.000,0.000,0.000]\n\txy = [0.000,0.000]\n\n\tinput = input.split(\" \")\n\t\n\tfor i in 0..5 \n\t\tdata[i] = input[i].to_f\n\tend\n\t\t\n\tnum = (data[0]*data[4]) - (data[1]*data[3])\n\n\txy[0] = ( data[4] *data[2] + (data[1]*-1)*data[5])/num\n\txy[1] = ((data[3]*-1)*data[2] + data[0] *data[5])/num\n\t\n\tprintf \"%.3f %.3f\\n\", xy[0].to_f, xy[1].to_f\n\nend", "language": "Ruby", "metadata": {"date": 1374381796, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s158939666.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s158939666", "user_id": "u026715545"}, "prompt_components": {"gold_output": "-1.000 2.000\n1.000 4.000\n", "input_to_evaluate": "while (input = STDIN.gets)!=nil do\n\n\tif input == \"\\n\"\n\t\tbreak\n\tend\n\n\tdata = [0.000,0.000,0.000,0.000,0.000,0.000]\n\txy = [0.000,0.000]\n\n\tinput = input.split(\" \")\n\t\n\tfor i in 0..5 \n\t\tdata[i] = input[i].to_f\n\tend\n\t\t\n\tnum = (data[0]*data[4]) - (data[1]*data[3])\n\n\txy[0] = ( data[4] *data[2] + (data[1]*-1)*data[5])/num\n\txy[1] = ((data[3]*-1)*data[2] + data[0] *data[5])/num\n\t\n\tprintf \"%.3f %.3f\\n\", xy[0].to_f, xy[1].to_f\n\nend", "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": 431, "cpu_time_ms": 20, "memory_kb": 6148}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s184880078", "group_id": "codeNet:p00005", "input_text": "def gcd(a, b)\n a, b = b, a if a > b\n until a == 0\n a, b = b%a, a\n end\n return b\nend\n\ndef lcm(a, b)\n a*b/gcd(a, b)\nend\n\nwhile gets do\n a, b = $_.chomp.split(' ').map(&:to_i)\n puts \"#{gcd(a, b)} #{lcm(a, b)}\"\nend\n", "language": "Ruby", "metadata": {"date": 1538715240, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s184880078.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s184880078", "user_id": "u696058095"}, "prompt_components": {"gold_output": "2 24\n10000000 150000000\n", "input_to_evaluate": "def gcd(a, b)\n a, b = b, a if a > b\n until a == 0\n a, b = b%a, a\n end\n return b\nend\n\ndef lcm(a, b)\n a*b/gcd(a, b)\nend\n\nwhile gets do\n a, b = $_.chomp.split(' ').map(&:to_i)\n puts \"#{gcd(a, b)} #{lcm(a, b)}\"\nend\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": 221, "cpu_time_ms": 40, "memory_kb": 6844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s936511407", "group_id": "codeNet:p00006", "input_text": "puts gets.reverse", "language": "Ruby", "metadata": {"date": 1464148685, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00006.html", "problem_id": "p00006", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00006/input.txt", "sample_output_relpath": "derived/input_output/data/p00006/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00006/Ruby/s936511407.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s936511407", "user_id": "u746732880"}, "prompt_components": {"gold_output": "admin23w\n", "input_to_evaluate": "puts gets.reverse", "problem_context": "Reverse Sequence\n\nWrite a program which reverses a given string str.\n\nInput\n\nstr (the size of str ≤ 20) is given in a line.\n\nOutput\n\nPrint the reversed str in a line.\n\nSample Input\n\nw32nimda\n\nOutput for the Sample Input\n\nadmin23w", "sample_input": "w32nimda\n"}, "reference_outputs": ["admin23w\n"], "source_document_id": "p00006", "source_text": "Reverse Sequence\n\nWrite a program which reverses a given string str.\n\nInput\n\nstr (the size of str ≤ 20) is given in a line.\n\nOutput\n\nPrint the reversed str in a line.\n\nSample Input\n\nw32nimda\n\nOutput for the Sample Input\n\nadmin23w", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 17, "cpu_time_ms": 40, "memory_kb": 8648}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s313750594", "group_id": "codeNet:p00007", "input_text": "debt = 100000\ninterest_rate = 0.05\n\nweek = gets.to_i\nweek.times do\n debt += ((debt * interest_rate) / 1000).ceil * 1000\nend\n\nputs debt", "language": "Ruby", "metadata": {"date": 1433935643, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00007.html", "problem_id": "p00007", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00007/input.txt", "sample_output_relpath": "derived/input_output/data/p00007/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00007/Ruby/s313750594.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s313750594", "user_id": "u188882971"}, "prompt_components": {"gold_output": "130000\n", "input_to_evaluate": "debt = 100000\ninterest_rate = 0.05\n\nweek = gets.to_i\nweek.times do\n debt += ((debt * interest_rate) / 1000).ceil * 1000\nend\n\nputs debt", "problem_context": "Debt Hell\n\nYour friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.\n\nWrite a program which computes the amount of the debt in n weeks.\n\nInput\n\nAn integer n (0 ≤ n ≤ 100) is given in a line.\n\nOutput\n\nPrint the amout of the debt in a line.\n\nSample Input\n\n5\n\nOutput for the Sample Input\n\n130000", "sample_input": "5\n"}, "reference_outputs": ["130000\n"], "source_document_id": "p00007", "source_text": "Debt Hell\n\nYour friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.\n\nWrite a program which computes the amount of the debt in n weeks.\n\nInput\n\nAn integer n (0 ≤ n ≤ 100) is given in a line.\n\nOutput\n\nPrint the amout of the debt in a line.\n\nSample Input\n\n5\n\nOutput for the Sample Input\n\n130000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 135, "cpu_time_ms": 20, "memory_kb": 6100}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s686898626", "group_id": "codeNet:p00007", "input_text": "n = gets.to_i\ndebt = 10**5\nn.times {\n\tdebt*=1.05\n\tdebt = (debt/ 1000.0).ceil * 1000.0}\nputs debt", "language": "Ruby", "metadata": {"date": 1456375026, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00007.html", "problem_id": "p00007", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00007/input.txt", "sample_output_relpath": "derived/input_output/data/p00007/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00007/Ruby/s686898626.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s686898626", "user_id": "u648595404"}, "prompt_components": {"gold_output": "130000\n", "input_to_evaluate": "n = gets.to_i\ndebt = 10**5\nn.times {\n\tdebt*=1.05\n\tdebt = (debt/ 1000.0).ceil * 1000.0}\nputs debt", "problem_context": "Debt Hell\n\nYour friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.\n\nWrite a program which computes the amount of the debt in n weeks.\n\nInput\n\nAn integer n (0 ≤ n ≤ 100) is given in a line.\n\nOutput\n\nPrint the amout of the debt in a line.\n\nSample Input\n\n5\n\nOutput for the Sample Input\n\n130000", "sample_input": "5\n"}, "reference_outputs": ["130000\n"], "source_document_id": "p00007", "source_text": "Debt Hell\n\nYour friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.\n\nWrite a program which computes the amount of the debt in n weeks.\n\nInput\n\nAn integer n (0 ≤ n ≤ 100) is given in a line.\n\nOutput\n\nPrint the amout of the debt in a line.\n\nSample Input\n\n5\n\nOutput for the Sample Input\n\n130000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 96, "cpu_time_ms": 40, "memory_kb": 8464}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s788269947", "group_id": "codeNet:p00008", "input_text": "\n2.times do n = gets.to_i \nsum = 0\n(0..9).each do |a|\n (0..9).each do |b|\n (0..9).each do |c|\n (0..9).each do |d|\n if a + b + c + d == n then\n sum +=1\n end\n end\n end\n end\nend\nputs sum \nend \n", "language": "Ruby", "metadata": {"date": 1529511517, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s788269947.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s788269947", "user_id": "u930055226"}, "prompt_components": {"gold_output": "4\n4\n", "input_to_evaluate": "\n2.times do n = gets.to_i \nsum = 0\n(0..9).each do |a|\n (0..9).each do |b|\n (0..9).each do |c|\n (0..9).each do |d|\n if a + b + c + d == n then\n sum +=1\n end\n end\n end\n end\nend\nputs sum \nend \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": 232, "cpu_time_ms": 50, "memory_kb": 6832}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s235145020", "group_id": "codeNet:p00009", "input_text": "#素数でない数\n# 1\n# 2以外の2の倍数\n# 二乗してもnumberを超えない奇数で割り切れない数\n#素数でない数以外は全て素数\ndef checkPrime(number)\n if number == 1 or number == 2\n return true\n elsif number % 2 == 0\n return false\n else\n i = 3\n while (i * i < number + 1)\n if number % i == 0\n return false\n end\n i += 2\n end\n return true;\n end\nend\n\n#入力バッファ\nn = 0\ninput = \"\"\ncounter = 0\n#メインルーチン\nwhile input = gets\n n = input.to_i\n count = 0\n for i in 2..n\n if checkPrime(i)\n count += 1\n end\n end\n p count\n if (counter += 1) == 30\n break;\n end\nend", "language": "Ruby", "metadata": {"date": 1363366471, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s235145020.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s235145020", "user_id": "u985809245"}, "prompt_components": {"gold_output": "4\n2\n5\n", "input_to_evaluate": "#素数でない数\n# 1\n# 2以外の2の倍数\n# 二乗してもnumberを超えない奇数で割り切れない数\n#素数でない数以外は全て素数\ndef checkPrime(number)\n if number == 1 or number == 2\n return true\n elsif number % 2 == 0\n return false\n else\n i = 3\n while (i * i < number + 1)\n if number % i == 0\n return false\n end\n i += 2\n end\n return true;\n end\nend\n\n#入力バッファ\nn = 0\ninput = \"\"\ncounter = 0\n#メインルーチン\nwhile input = gets\n n = input.to_i\n count = 0\n for i in 2..n\n if checkPrime(i)\n count += 1\n end\n end\n p count\n if (counter += 1) == 30\n break;\n end\nend", "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": 676, "cpu_time_ms": 20000, "memory_kb": 6100}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s231979303", "group_id": "codeNet:p00009", "input_text": "while num = gets()\n if (num.nil? or num == \"\\n\" or num == \"\\n\\r\") then break end\n num = num.to_i\n prime = 0\n\n (2..num).each do |n|\n is_prime = true \n (2...n).each do |a|\n if n % a == 0 then\n is_prime = false\n end\n end\n prime += 1 if is_prime\n end\n puts prime\nend", "language": "Ruby", "metadata": {"date": 1402409913, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s231979303.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s231979303", "user_id": "u888227825"}, "prompt_components": {"gold_output": "4\n2\n5\n", "input_to_evaluate": "while num = gets()\n if (num.nil? or num == \"\\n\" or num == \"\\n\\r\") then break end\n num = num.to_i\n prime = 0\n\n (2..num).each do |n|\n is_prime = true \n (2...n).each do |a|\n if n % a == 0 then\n is_prime = false\n end\n end\n prime += 1 if is_prime\n end\n puts prime\nend", "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": 297, "cpu_time_ms": 39870, "memory_kb": 6088}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s897187653", "group_id": "codeNet:p00012", "input_text": "def in_same_side?(ary_1, ary_2, ary_3, ary_p)\n a, b = ary_1\n c, d = ary_2\n i, k = ary_3\n p, q = ary_p\n alpha = (d - b)/(c - a)\n #ary_1, ary_2を通る直線 y = alpha * x + b - alpha * a\n if a == c\n laterality_ary_3 = i - a\n laterality_ary_p = p - a\n elsif b == d\n laterality_ary_3 = k - b\n laterality_ary_p = q - b\n else\n laterality_ary_3 = k - (alpha*i + b - alpha*a)\n laterality_ary_p = q - (alpha*p + b - alpha*a)\n end\n \n if laterality_ary_3 > 0 == laterality_ary_p > 0\n return true\n else\n return false\n end\nend\n\nwhile line = gets\n p = line.chomp.split.map(&:to_f).each_slice(2).to_a\n \n if in_same_side?(p[0], p[1], p[2], p[3]) && \\\n in_same_side?(p[0], p[2], p[1], p[3]) && \\\n in_same_side?(p[1], p[2], p[0], p[3])\n puts :YES\n else\n puts :NO\n end\nend", "language": "Ruby", "metadata": {"date": 1374518346, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00012.html", "problem_id": "p00012", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00012/input.txt", "sample_output_relpath": "derived/input_output/data/p00012/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00012/Ruby/s897187653.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s897187653", "user_id": "u202852666"}, "prompt_components": {"gold_output": "YES\nNO\n", "input_to_evaluate": "def in_same_side?(ary_1, ary_2, ary_3, ary_p)\n a, b = ary_1\n c, d = ary_2\n i, k = ary_3\n p, q = ary_p\n alpha = (d - b)/(c - a)\n #ary_1, ary_2を通る直線 y = alpha * x + b - alpha * a\n if a == c\n laterality_ary_3 = i - a\n laterality_ary_p = p - a\n elsif b == d\n laterality_ary_3 = k - b\n laterality_ary_p = q - b\n else\n laterality_ary_3 = k - (alpha*i + b - alpha*a)\n laterality_ary_p = q - (alpha*p + b - alpha*a)\n end\n \n if laterality_ary_3 > 0 == laterality_ary_p > 0\n return true\n else\n return false\n end\nend\n\nwhile line = gets\n p = line.chomp.split.map(&:to_f).each_slice(2).to_a\n \n if in_same_side?(p[0], p[1], p[2], p[3]) && \\\n in_same_side?(p[0], p[2], p[1], p[3]) && \\\n in_same_side?(p[1], p[2], p[0], p[3])\n puts :YES\n else\n puts :NO\n end\nend", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nA Point in a Triangle\n\nThere is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.\n\nWrite a program which prints \"YES\" if a point $P$ $(x_p, y_p)$ is in the triangle and \"NO\" if not.\n\nInput\n\nInput consists of several datasets. Each dataset consists of:\n\n$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$\n\nAll the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.\n\nConstraints\n\nYou can assume that:\n\n$ -100 \\leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \\leq 100$\n\n1.0 $\\leq$ Length of each side of a tringle\n\n0.001 $\\leq$ Distance between $P$ and each side of a triangle\n\nOutput\n\nFor each dataset, print \"YES\" or \"NO\" in a line.\n\nSample Input\n\n0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5\n0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0\n\nOutput for the Sample Input\n\nYES\nNO", "sample_input": "0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5\n0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0\n"}, "reference_outputs": ["YES\nNO\n"], "source_document_id": "p00012", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nA Point in a Triangle\n\nThere is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.\n\nWrite a program which prints \"YES\" if a point $P$ $(x_p, y_p)$ is in the triangle and \"NO\" if not.\n\nInput\n\nInput consists of several datasets. Each dataset consists of:\n\n$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$\n\nAll the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.\n\nConstraints\n\nYou can assume that:\n\n$ -100 \\leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \\leq 100$\n\n1.0 $\\leq$ Length of each side of a tringle\n\n0.001 $\\leq$ Distance between $P$ and each side of a triangle\n\nOutput\n\nFor each dataset, print \"YES\" or \"NO\" in a line.\n\nSample Input\n\n0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5\n0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0\n\nOutput for the Sample Input\n\nYES\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 818, "cpu_time_ms": 20, "memory_kb": 6144}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s561895266", "group_id": "codeNet:p00017", "input_text": "class CaesarCipher\n def initialize(str)\n @str_arr = str.split(\" \")\n @answer = []\n @alphabet = (\"a\"..\"z\").to_a\n @first_words = [\"the\", \"this\", \"that\"]\n\n end\n\n def decipher\n first_word = @str_arr.first.split(\"\").map{|c| c.ord - \"a\".ord}\n temp = []\n step_number = 0\n 1.step(25, 1) do |i|\n temp = first_word.map{|c, s = i| @alphabet[c - i]}\n\n if @first_words.include?(temp.join(\"\"))\n step_number = i\n break\n end\n end\n @str_arr.length.times do |i|\n @answer.push @str_arr[i].split(\"\").map {|c, s = step_number|\n if c != \".\"\n @alphabet[c.ord - \"a\".ord - s]\n else\n c\n end\n }.join(\"\")\n end\n @answer.join(\" \")\n end\nend\n\nline = gets.chomp\ncaesar_cipher = CaesarCipher.new(line)\nputs caesar_cipher.decipher", "language": "Ruby", "metadata": {"date": 1447213760, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s561895266.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s561895266", "user_id": "u750346935"}, "prompt_components": {"gold_output": "this is the picture that i took in the trip.\n", "input_to_evaluate": "class CaesarCipher\n def initialize(str)\n @str_arr = str.split(\" \")\n @answer = []\n @alphabet = (\"a\"..\"z\").to_a\n @first_words = [\"the\", \"this\", \"that\"]\n\n end\n\n def decipher\n first_word = @str_arr.first.split(\"\").map{|c| c.ord - \"a\".ord}\n temp = []\n step_number = 0\n 1.step(25, 1) do |i|\n temp = first_word.map{|c, s = i| @alphabet[c - i]}\n\n if @first_words.include?(temp.join(\"\"))\n step_number = i\n break\n end\n end\n @str_arr.length.times do |i|\n @answer.push @str_arr[i].split(\"\").map {|c, s = step_number|\n if c != \".\"\n @alphabet[c.ord - \"a\".ord - s]\n else\n c\n end\n }.join(\"\")\n end\n @answer.join(\" \")\n end\nend\n\nline = gets.chomp\ncaesar_cipher = CaesarCipher.new(line)\nputs caesar_cipher.decipher", "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": 812, "cpu_time_ms": 40, "memory_kb": 8616}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s835451254", "group_id": "codeNet:p00018", "input_text": "puts $<.gets.split.sort{|a,b|b<=>a}*(' ')", "language": "Ruby", "metadata": {"date": 1458464994, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s835451254.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s835451254", "user_id": "u861698758"}, "prompt_components": {"gold_output": "9 7 6 5 3\n", "input_to_evaluate": "puts $<.gets.split.sort{|a,b|b<=>a}*(' ')", "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": 41, "cpu_time_ms": 50, "memory_kb": 8624}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s868410320", "group_id": "codeNet:p00018", "input_text": "str = STDIN.gets\nnums = str.split(\" \")\nnums = nums.sort {|a, b| b <=> a }\n\nputs nums.join(\" \")", "language": "Ruby", "metadata": {"date": 1475660209, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s868410320.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s868410320", "user_id": "u626163867"}, "prompt_components": {"gold_output": "9 7 6 5 3\n", "input_to_evaluate": "str = STDIN.gets\nnums = str.split(\" \")\nnums = nums.sort {|a, b| b <=> a }\n\nputs nums.join(\" \")", "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": 94, "cpu_time_ms": 40, "memory_kb": 8664}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s490248572", "group_id": "codeNet:p00019", "input_text": "n = gets.to_i\nsum = 1\n1.upto(n) {|e| sum *= e}\n\nputs sum\n\n", "language": "Ruby", "metadata": {"date": 1529504883, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00019.html", "problem_id": "p00019", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00019/input.txt", "sample_output_relpath": "derived/input_output/data/p00019/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00019/Ruby/s490248572.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s490248572", "user_id": "u592742011"}, "prompt_components": {"gold_output": "120\n", "input_to_evaluate": "n = gets.to_i\nsum = 1\n1.upto(n) {|e| sum *= e}\n\nputs sum\n\n", "problem_context": "Factorial\n\nWrite a program which reads an integer n and prints the factorial of n. You can assume that n ≤ 20.\n\nInput\n\nAn integer n (1 ≤ n ≤ 20) in a line.\n\nOutput\n\nPrint the factorial of n in a line.\n\nSample Input\n\n5\n\nOutput for the Sample Input\n\n120", "sample_input": "5\n"}, "reference_outputs": ["120\n"], "source_document_id": "p00019", "source_text": "Factorial\n\nWrite a program which reads an integer n and prints the factorial of n. You can assume that n ≤ 20.\n\nInput\n\nAn integer n (1 ≤ n ≤ 20) in a line.\n\nOutput\n\nPrint the factorial of n in a line.\n\nSample Input\n\n5\n\nOutput for the Sample Input\n\n120", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 58, "cpu_time_ms": 40, "memory_kb": 6856}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s375168023", "group_id": "codeNet:p00020", "input_text": "$><<= ary.max()\n\t\tif !ary.max or a.count(i) > ary.max() then ary = []; end\n\t\tary.push(i)\n\tend\nend\n\nary.each do |v|\n\tputs v\nend", "language": "Ruby", "metadata": {"date": 1424783865, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00028.html", "problem_id": "p00028", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00028/input.txt", "sample_output_relpath": "derived/input_output/data/p00028/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00028/Ruby/s263860125.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s263860125", "user_id": "u929523932"}, "prompt_components": {"gold_output": "3\n5\n", "input_to_evaluate": "a = []\n\nloop do\n\ts = gets\n\tif !s then break; end\n\ta.push(s.to_i)\nend\n\nary = []\n\nfor i in a.min..a.max do\n\tif !ary.max or a.count(i) >= ary.max()\n\t\tif !ary.max or a.count(i) > ary.max() then ary = []; end\n\t\tary.push(i)\n\tend\nend\n\nary.each do |v|\n\tputs v\nend", "problem_context": "Mode Value\n\nYour task is to write a program which reads a sequence of integers and prints mode values of the sequence.\nThe mode value is the element which occurs most frequently.\n\nInput\n\nA sequence of integers ai (1 ≤ ai ≤ 100). The number of integers is less than or equals to 100.\n\nOutput\n\nPrint the mode values. If there are several mode values, print them in ascending order.\n\nSample Input\n\n5\n6\n3\n5\n8\n7\n5\n3\n9\n7\n3\n4\n\nOutput for the Sample Input\n\n3\n5\n\nFor example, 3 and 5 respectively occur three times, 7 occurs two times, and others occur only one. So, the mode values are 3 and 5.", "sample_input": "5\n6\n3\n5\n8\n7\n5\n3\n9\n7\n3\n4\n"}, "reference_outputs": ["3\n5\n"], "source_document_id": "p00028", "source_text": "Mode Value\n\nYour task is to write a program which reads a sequence of integers and prints mode values of the sequence.\nThe mode value is the element which occurs most frequently.\n\nInput\n\nA sequence of integers ai (1 ≤ ai ≤ 100). The number of integers is less than or equals to 100.\n\nOutput\n\nPrint the mode values. If there are several mode values, print them in ascending order.\n\nSample Input\n\n5\n6\n3\n5\n8\n7\n5\n3\n9\n7\n3\n4\n\nOutput for the Sample Input\n\n3\n5\n\nFor example, 3 and 5 respectively occur three times, 7 occurs two times, and others occur only one. So, the mode values are 3 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": 255, "cpu_time_ms": 20, "memory_kb": 6084}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s231236630", "group_id": "codeNet:p00028", "input_text": "def mode_value(arr)\n n, mv = 0, []\n \n 100.times do |i|\n if n < arr[i]\n n, mv = arr[i], [i + 1]\n elsif n == arr[i]\n mv << i + 1\n end\n end\n \n return mv\nend\n\narr = Array.new(100, 0)\n\narr[$_.to_i - 1] += 1 while gets\n\nputs mode_value(arr)", "language": "Ruby", "metadata": {"date": 1439399905, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00028.html", "problem_id": "p00028", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00028/input.txt", "sample_output_relpath": "derived/input_output/data/p00028/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00028/Ruby/s231236630.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s231236630", "user_id": "u814658648"}, "prompt_components": {"gold_output": "3\n5\n", "input_to_evaluate": "def mode_value(arr)\n n, mv = 0, []\n \n 100.times do |i|\n if n < arr[i]\n n, mv = arr[i], [i + 1]\n elsif n == arr[i]\n mv << i + 1\n end\n end\n \n return mv\nend\n\narr = Array.new(100, 0)\n\narr[$_.to_i - 1] += 1 while gets\n\nputs mode_value(arr)", "problem_context": "Mode Value\n\nYour task is to write a program which reads a sequence of integers and prints mode values of the sequence.\nThe mode value is the element which occurs most frequently.\n\nInput\n\nA sequence of integers ai (1 ≤ ai ≤ 100). The number of integers is less than or equals to 100.\n\nOutput\n\nPrint the mode values. If there are several mode values, print them in ascending order.\n\nSample Input\n\n5\n6\n3\n5\n8\n7\n5\n3\n9\n7\n3\n4\n\nOutput for the Sample Input\n\n3\n5\n\nFor example, 3 and 5 respectively occur three times, 7 occurs two times, and others occur only one. So, the mode values are 3 and 5.", "sample_input": "5\n6\n3\n5\n8\n7\n5\n3\n9\n7\n3\n4\n"}, "reference_outputs": ["3\n5\n"], "source_document_id": "p00028", "source_text": "Mode Value\n\nYour task is to write a program which reads a sequence of integers and prints mode values of the sequence.\nThe mode value is the element which occurs most frequently.\n\nInput\n\nA sequence of integers ai (1 ≤ ai ≤ 100). The number of integers is less than or equals to 100.\n\nOutput\n\nPrint the mode values. If there are several mode values, print them in ascending order.\n\nSample Input\n\n5\n6\n3\n5\n8\n7\n5\n3\n9\n7\n3\n4\n\nOutput for the Sample Input\n\n3\n5\n\nFor example, 3 and 5 respectively occur three times, 7 occurs two times, and others occur only one. So, the mode values are 3 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": 259, "cpu_time_ms": 20, "memory_kb": 6100}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s143005528", "group_id": "codeNet:p00031", "input_text": "def weight\n master = Array.new(10) { |i| 2**i }\n while gets\n wei = $_.to_i\n spindles = master.select { |i| i < wei }\n result = []\n while true\n break if wei <= 0\n wei -= 1\n minus = spindles.max\n # if minus > wei\n # next\n # end\n # w = w - minus\n # spindles.delete(minus)\n # result << minus\n end\n puts result.sort.join(' ')\n end\nend\n\nweight", "language": "Ruby", "metadata": {"date": 1468764464, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00031.html", "problem_id": "p00031", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00031/input.txt", "sample_output_relpath": "derived/input_output/data/p00031/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00031/Ruby/s143005528.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s143005528", "user_id": "u919623882"}, "prompt_components": {"gold_output": "1 4\n1 2 4\n1 2 4 8 16 32 64\n", "input_to_evaluate": "def weight\n master = Array.new(10) { |i| 2**i }\n while gets\n wei = $_.to_i\n spindles = master.select { |i| i < wei }\n result = []\n while true\n break if wei <= 0\n wei -= 1\n minus = spindles.max\n # if minus > wei\n # next\n # end\n # w = w - minus\n # spindles.delete(minus)\n # result << minus\n end\n puts result.sort.join(' ')\n end\nend\n\nweight", "problem_context": "Weight\n\n祖母が天秤を使っています。天秤は、二つの皿の両方に同じ目方のものを載せると釣合い、そうでない場合には、重い方に傾きます。10 個の分銅の重さは、軽い順に 1g, 2g, 4g, 8g, 16g, 32g, 64g, 128g, 256g, 512g です。\n\n祖母は、「1kg くらいまでグラム単位で量れるのよ。」と言います。「じゃあ、試しに、ここにあるジュースの重さを量ってよ」と言ってみると、祖母は左の皿にジュースを、右の皿に 8g と64g と128g の分銅を載せて釣合わせてから、「分銅の目方の合計は 200g だから、ジュースの目方は 200g ね。どう、正しいでしょう?」と答えました。\n\n左の皿に載せる品物の重さを与えるので、天秤で与えられた重みの品物と釣合わせるときに、右の皿に載せる分銅を軽い順に出力するプログラムを作成して下さい。ただし、量るべき品物の重さは、すべての分銅の重さの合計 (=1023g) 以下とします。\n\nInput\n\n複数のデータセットが与えられます。各データセットに、左の皿に載せる品物の重さが1行に与えられます。入力の最後まで処理して下さい。データセットの数は 50 を超えません。\n\nOutput\n\n各データセットに対して、右の皿に載せる分銅(昇順)を1つの空白で区切って、1行に出力して下さい。\n\nSample Input\n\n5\n7\n127\n\nOutput for the Sample Input\n\n1 4\n1 2 4\n1 2 4 8 16 32 64\n\nHint\n\n分銅の重さは 2 の n 乗 ( n = 0, 1, .... 9 )g です。", "sample_input": "5\n7\n127\n"}, "reference_outputs": ["1 4\n1 2 4\n1 2 4 8 16 32 64\n"], "source_document_id": "p00031", "source_text": "Weight\n\n祖母が天秤を使っています。天秤は、二つの皿の両方に同じ目方のものを載せると釣合い、そうでない場合には、重い方に傾きます。10 個の分銅の重さは、軽い順に 1g, 2g, 4g, 8g, 16g, 32g, 64g, 128g, 256g, 512g です。\n\n祖母は、「1kg くらいまでグラム単位で量れるのよ。」と言います。「じゃあ、試しに、ここにあるジュースの重さを量ってよ」と言ってみると、祖母は左の皿にジュースを、右の皿に 8g と64g と128g の分銅を載せて釣合わせてから、「分銅の目方の合計は 200g だから、ジュースの目方は 200g ね。どう、正しいでしょう?」と答えました。\n\n左の皿に載せる品物の重さを与えるので、天秤で与えられた重みの品物と釣合わせるときに、右の皿に載せる分銅を軽い順に出力するプログラムを作成して下さい。ただし、量るべき品物の重さは、すべての分銅の重さの合計 (=1023g) 以下とします。\n\nInput\n\n複数のデータセットが与えられます。各データセットに、左の皿に載せる品物の重さが1行に与えられます。入力の最後まで処理して下さい。データセットの数は 50 を超えません。\n\nOutput\n\n各データセットに対して、右の皿に載せる分銅(昇順)を1つの空白で区切って、1行に出力して下さい。\n\nSample Input\n\n5\n7\n127\n\nOutput for the Sample Input\n\n1 4\n1 2 4\n1 2 4 8 16 32 64\n\nHint\n\n分銅の重さは 2 の n 乗 ( n = 0, 1, .... 9 )g です。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 8720}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s572339294", "group_id": "codeNet:p00032", "input_text": "hishi = 0\ntyou = 0\nwhile input = gets do\n a,b,c = input.chop.split(\",\").map{|n| n.to_i}\n if a == b then\n hishi += 1\n elsif a**2 + b**2 == c**2 then\n tyou += 1\n end\nend\nputs tyou,hishi\n\n", "language": "Ruby", "metadata": {"date": 1515225991, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00032.html", "problem_id": "p00032", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00032/input.txt", "sample_output_relpath": "derived/input_output/data/p00032/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00032/Ruby/s572339294.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s572339294", "user_id": "u480817624"}, "prompt_components": {"gold_output": "1\n2\n", "input_to_evaluate": "hishi = 0\ntyou = 0\nwhile input = gets do\n a,b,c = input.chop.split(\",\").map{|n| n.to_i}\n if a == b then\n hishi += 1\n elsif a**2 + b**2 == c**2 then\n tyou += 1\n end\nend\nputs tyou,hishi\n\n", "problem_context": "プラスティック板\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", "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": 195, "cpu_time_ms": 40, "memory_kb": 6840}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s323429318", "group_id": "codeNet:p00033", "input_text": "gets\n(n,*a=$_.split.map &:to_i\nputs a.reject!{|i|i>n ?n=i :!0}==a.sort ? :YES: :NO)while gets", "language": "Ruby", "metadata": {"date": 1416479531, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s323429318.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s323429318", "user_id": "u890794282"}, "prompt_components": {"gold_output": "YES\nNO\n", "input_to_evaluate": "gets\n(n,*a=$_.split.map &:to_i\nputs a.reject!{|i|i>n ?n=i :!0}==a.sort ? :YES: :NO)while gets", "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": 93, "cpu_time_ms": 20, "memory_kb": 6096}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s120715274", "group_id": "codeNet:p00041", "input_text": "op = [\"+\",\"-\",\"*\"]\np = op.product(op,op)\n\ndef convp(p, mode)\n st = []\n while p.size > 0\n x = p.shift\n if mode == 0\n case x\n when \"+\"\n st.push(st.pop+st.pop)\n when \"-\"\n st.push(-st.pop+st.pop)\n when \"*\"\n st.push(st.pop*st.pop)\n else #numeric\n st << x\n end\n else\n if x.to_s =~ /[1-9]/\n st.push(x.to_s)\n else\n a,b=st.pop,st.pop\n (x == \"*\" and b.size != 1) ? st.push(\"(\"+b+\")\"+\" \"+x+\" \"+a) : st.push(\"(\"+b+\" \"+x+\" \"+a+\")\")\n end\n end\n end\n return st\nend\n\nloop do\n e,f,g,h = gets.split.map(&:to_i)\n # puts \"#{e},#{f},#{g},#{h}\"\n break if e+f+g+h==0\n catch(:exit) do\n [e,f,g,h].permutation(4) do |a,b,c,d|\n p.each do |l|\n ln = Array.new(5){[a,b]}\n 5.times do |idx|\n case idx\n when 0\n [ln[0],ln[1],ln[2]].each{|x| x << c}\n [ln[3],ln[4]].each{|x| x << l[0]}\n when 1\n ln[0] << d\n [ln[1],ln[2]].each{|x| x << l[0]}\n [ln[3],ln[4]].each{|x| x << c}\n when 2\n ln[0] << l[0]\n [ln[1],ln[4]].each{|x| x << d}\n [ln[2],ln[3]].each{|x| x << l[1]}\n when 3\n [ln[0],ln[1],ln[4]].each{|x| x << l[1]}\n [ln[2],ln[3]].each{|x| x << d}\n when 4\n ln.each{|x| x << l[2]}\n end\n end\n 5.times do |i|\n lnb = Marshal.load(Marshal.dump(ln))\n if convp(ln[i], 0)[0] == 10\n puts convp(lnb[i],1)\n throw(:exit)\n end\n end\n end\n end\n p 0\n end\nend", "language": "Ruby", "metadata": {"date": 1467361056, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00041.html", "problem_id": "p00041", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00041/input.txt", "sample_output_relpath": "derived/input_output/data/p00041/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00041/Ruby/s120715274.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s120715274", "user_id": "u461552210"}, "prompt_components": {"gold_output": "((9 * (9 - 7)) - 8)\n0\n((7 * 5) - (5 * 5))\n", "input_to_evaluate": "op = [\"+\",\"-\",\"*\"]\np = op.product(op,op)\n\ndef convp(p, mode)\n st = []\n while p.size > 0\n x = p.shift\n if mode == 0\n case x\n when \"+\"\n st.push(st.pop+st.pop)\n when \"-\"\n st.push(-st.pop+st.pop)\n when \"*\"\n st.push(st.pop*st.pop)\n else #numeric\n st << x\n end\n else\n if x.to_s =~ /[1-9]/\n st.push(x.to_s)\n else\n a,b=st.pop,st.pop\n (x == \"*\" and b.size != 1) ? st.push(\"(\"+b+\")\"+\" \"+x+\" \"+a) : st.push(\"(\"+b+\" \"+x+\" \"+a+\")\")\n end\n end\n end\n return st\nend\n\nloop do\n e,f,g,h = gets.split.map(&:to_i)\n # puts \"#{e},#{f},#{g},#{h}\"\n break if e+f+g+h==0\n catch(:exit) do\n [e,f,g,h].permutation(4) do |a,b,c,d|\n p.each do |l|\n ln = Array.new(5){[a,b]}\n 5.times do |idx|\n case idx\n when 0\n [ln[0],ln[1],ln[2]].each{|x| x << c}\n [ln[3],ln[4]].each{|x| x << l[0]}\n when 1\n ln[0] << d\n [ln[1],ln[2]].each{|x| x << l[0]}\n [ln[3],ln[4]].each{|x| x << c}\n when 2\n ln[0] << l[0]\n [ln[1],ln[4]].each{|x| x << d}\n [ln[2],ln[3]].each{|x| x << l[1]}\n when 3\n [ln[0],ln[1],ln[4]].each{|x| x << l[1]}\n [ln[2],ln[3]].each{|x| x << d}\n when 4\n ln.each{|x| x << l[2]}\n end\n end\n 5.times do |i|\n lnb = Marshal.load(Marshal.dump(ln))\n if convp(ln[i], 0)[0] == 10\n puts convp(lnb[i],1)\n throw(:exit)\n end\n end\n end\n end\n p 0\n end\nend", "problem_context": "式\n\n与えられた 4 つの 1 から 9 の整数を使って、答えが 10 になる式をつくります。\n4 つの整数 a, b, c, d を入力したとき、下記の条件に従い、答えが 10 になる式を出力するプログラムを作成してください。また、答えが複数ある時は、最初に見つかった答えだけを出力するものとします。答えがない時は、0 と出力してください。\n\n演算子として、加算 (+)、減算 (-)、乗算 (*) だけを使います。除算 (/) は使いません。使用できる演算子は3個です。\n\n数を4つとも使わなければいけません。\n\n4つの数の順番は自由に入れ換えてかまいません。\n\nカッコを使ってもかまいません。使用できるカッコは3組(6個)以下です。\n\nInput\n\n複数のデータセットが与えられます。各データセットの形式は以下のとおり:\n\na b c d\n\n入力は4つの 0 で終了します。データセットの数は 40 を超えません。\n\nOutput\n\n各データセットについて、与えられた 4 つの整数と上記の演算記号およびカッコを組み合わせて値が 10 となる式または 0 を1行に出力してください。式の文字列が 1024 文字を超えてはいけません。\n\nSample Input\n\n8 7 9 9\n4 4 4 4\n5 5 7 5\n0 0 0 0\n\nOutput for the Sample Input\n\n((9 * (9 - 7)) - 8)\n0\n((7 * 5) - (5 * 5))", "sample_input": "8 7 9 9\n4 4 4 4\n5 5 7 5\n0 0 0 0\n"}, "reference_outputs": ["((9 * (9 - 7)) - 8)\n0\n((7 * 5) - (5 * 5))\n"], "source_document_id": "p00041", "source_text": "式\n\n与えられた 4 つの 1 から 9 の整数を使って、答えが 10 になる式をつくります。\n4 つの整数 a, b, c, d を入力したとき、下記の条件に従い、答えが 10 になる式を出力するプログラムを作成してください。また、答えが複数ある時は、最初に見つかった答えだけを出力するものとします。答えがない時は、0 と出力してください。\n\n演算子として、加算 (+)、減算 (-)、乗算 (*) だけを使います。除算 (/) は使いません。使用できる演算子は3個です。\n\n数を4つとも使わなければいけません。\n\n4つの数の順番は自由に入れ換えてかまいません。\n\nカッコを使ってもかまいません。使用できるカッコは3組(6個)以下です。\n\nInput\n\n複数のデータセットが与えられます。各データセットの形式は以下のとおり:\n\na b c d\n\n入力は4つの 0 で終了します。データセットの数は 40 を超えません。\n\nOutput\n\n各データセットについて、与えられた 4 つの整数と上記の演算記号およびカッコを組み合わせて値が 10 となる式または 0 を1行に出力してください。式の文字列が 1024 文字を超えてはいけません。\n\nSample Input\n\n8 7 9 9\n4 4 4 4\n5 5 7 5\n0 0 0 0\n\nOutput for the Sample Input\n\n((9 * (9 - 7)) - 8)\n0\n((7 * 5) - (5 * 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": 1603, "cpu_time_ms": 430, "memory_kb": 9724}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s203920956", "group_id": "codeNet:p00043", "input_text": "def check(table)\n result = 0\n if table.sum <= 2\n result = 1 if table.find {|x| x == 2}\n else\n (1..7).each do |i|\n tmp = table.dup\n if tmp[i].nonzero? and tmp[i + 1].nonzero? and tmp[i + 2].nonzero?\n 3.times {|x| tmp[i + x] -= 1}\n result += check(tmp)\n return 1 if result.nonzero?\n end\n (1..9).each do |j|\n tmp1 = table.dup\n if tmp1[j] >= 3\n tmp1[j] -= 3\n result += check(tmp1)\n return 1 if result.nonzero?\n end\n end\n end\n end\n result\nend\n\n$<.readlines.map(&:chomp).map {|n| n.chars.map(&:to_i)}.each do |data|\n table = Array.new(10, 0)\n data.each {|i| table[i] += 1}\n result = (1..9).map do |i|\n added = table.dup\n added[i] += 1\n next if added[i] > 4\n check(added).nonzero? ? i : nil\n end.compact\n puts result.empty? ? 0 : result.join(\" \")\nend\n", "language": "Ruby", "metadata": {"date": 1545289853, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s203920956.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s203920956", "user_id": "u864617427"}, "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": "def check(table)\n result = 0\n if table.sum <= 2\n result = 1 if table.find {|x| x == 2}\n else\n (1..7).each do |i|\n tmp = table.dup\n if tmp[i].nonzero? and tmp[i + 1].nonzero? and tmp[i + 2].nonzero?\n 3.times {|x| tmp[i + x] -= 1}\n result += check(tmp)\n return 1 if result.nonzero?\n end\n (1..9).each do |j|\n tmp1 = table.dup\n if tmp1[j] >= 3\n tmp1[j] -= 3\n result += check(tmp1)\n return 1 if result.nonzero?\n end\n end\n end\n end\n result\nend\n\n$<.readlines.map(&:chomp).map {|n| n.chars.map(&:to_i)}.each do |data|\n table = Array.new(10, 0)\n data.each {|i| table[i] += 1}\n result = (1..9).map do |i|\n added = table.dup\n added[i] += 1\n next if added[i] > 4\n check(added).nonzero? ? i : nil\n end.compact\n puts result.empty? ? 0 : result.join(\" \")\nend\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": 869, "cpu_time_ms": 3090, "memory_kb": 6880}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s122991402", "group_id": "codeNet:p00056", "input_text": "is_prime = Array.new(50001, true)\nis_prime[0] = is_prime[1] = false\n(2..223).each{|p|\n if is_prime[p]\n (p*2).step(50000,p){|i|\n is_prime[i] = false\n }\n end\n}\n\nf = ->n{\n return (is_prime[n-2] ? 1 : 0) if n.odd?\n (2..(n/2)).count{|i| is_prime[i] and is_prime[n-i]}\n}\n\nloop{\n n = gets.to_i\n break if n==0\n p f[n]\n}\n", "language": "Ruby", "metadata": {"date": 1518807696, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00056.html", "problem_id": "p00056", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00056/input.txt", "sample_output_relpath": "derived/input_output/data/p00056/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00056/Ruby/s122991402.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s122991402", "user_id": "u758382323"}, "prompt_components": {"gold_output": "2\n0\n", "input_to_evaluate": "is_prime = Array.new(50001, true)\nis_prime[0] = is_prime[1] = false\n(2..223).each{|p|\n if is_prime[p]\n (p*2).step(50000,p){|i|\n is_prime[i] = false\n }\n end\n}\n\nf = ->n{\n return (is_prime[n-2] ? 1 : 0) if n.odd?\n (2..(n/2)).count{|i| is_prime[i] and is_prime[n-i]}\n}\n\nloop{\n n = gets.to_i\n break if n==0\n p f[n]\n}\n", "problem_context": "ゴールドバッハの予想\n\n4 以上の偶数は 2 つの素数の和で表すことができるということが知られています。これはゴールドバッハ予想といい、コンピュータの計算によりかなり大きな数まで正しいことが確かめられています。例えば、10 は、7 + 3、5 + 5 の 2 通りの素数の和で表すことができます。\n\n整数 n を入力し、n を 2 つの素数の和で表す組み合わせ数が何通りあるかを出力するプログラムを作成してください。ただし、n は 4 以上、50,000 以下とします。また、入力される n は偶数であるとはかぎりません。\n\nInput\n\n複数のデータセットが与えられます。各データセットに n が1行に与えられます。n が 0 のとき入力の最後とします。データセットの数は 10,000 を超えません。\n\nOutput\n\n各データセットに対して、n を 2 つの素数の和で表す組み合わせ数を1行に出力して下さい。\n\nSample Input\n\n10\n11\n0\n\nOutput for the Sample Input\n\n2\n0", "sample_input": "10\n11\n0\n"}, "reference_outputs": ["2\n0\n"], "source_document_id": "p00056", "source_text": "ゴールドバッハの予想\n\n4 以上の偶数は 2 つの素数の和で表すことができるということが知られています。これはゴールドバッハ予想といい、コンピュータの計算によりかなり大きな数まで正しいことが確かめられています。例えば、10 は、7 + 3、5 + 5 の 2 通りの素数の和で表すことができます。\n\n整数 n を入力し、n を 2 つの素数の和で表す組み合わせ数が何通りあるかを出力するプログラムを作成してください。ただし、n は 4 以上、50,000 以下とします。また、入力される n は偶数であるとはかぎりません。\n\nInput\n\n複数のデータセットが与えられます。各データセットに n が1行に与えられます。n が 0 のとき入力の最後とします。データセットの数は 10,000 を超えません。\n\nOutput\n\n各データセットに対して、n を 2 つの素数の和で表す組み合わせ数を1行に出力して下さい。\n\nSample Input\n\n10\n11\n0\n\nOutput for the Sample Input\n\n2\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 330, "cpu_time_ms": 3180, "memory_kb": 7416}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s937871502", "group_id": "codeNet:p00057", "input_text": "while s=gets\n x=s.chomp.to_i\n puts (x*(x+1)/2+1)\nend", "language": "Ruby", "metadata": {"date": 1454333860, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00057.html", "problem_id": "p00057", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00057/input.txt", "sample_output_relpath": "derived/input_output/data/p00057/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00057/Ruby/s937871502.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s937871502", "user_id": "u289594538"}, "prompt_components": {"gold_output": "2\n7\n", "input_to_evaluate": "while s=gets\n x=s.chomp.to_i\n puts (x*(x+1)/2+1)\nend", "problem_context": "領域の数\n\n無限に広い平面の上に、無限に長い直線を数本引くと、この平面はいくつかの領域に分割されます。たとえば、直線を1本引くと、平面は2つの領域に分割されます。同じ数の直線を引いても、引き方によって得られる領域の数は異なります。たとえば、2 本の直線を平行に引けば得られる領域は 3 つになり、互いに垂直に引けば得られる領域は 4 つになります。\n\nn 本の直線を引くことで得られる最大の領域の数を出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットが与えられます。各データセットに n (1 ≤ n ≤ 10,000) が1行に与えられます。入力の最後まで処理して下さい。\n\nデータセットの数は 50 を超えません。\n\nOutput\n\n各データセットに対して、最大の分割数を1行に出力して下さい。\n\nSample Input\n\n1\n3\n\nOutput for the Sample Input\n\n2\n7", "sample_input": "1\n3\n"}, "reference_outputs": ["2\n7\n"], "source_document_id": "p00057", "source_text": "領域の数\n\n無限に広い平面の上に、無限に長い直線を数本引くと、この平面はいくつかの領域に分割されます。たとえば、直線を1本引くと、平面は2つの領域に分割されます。同じ数の直線を引いても、引き方によって得られる領域の数は異なります。たとえば、2 本の直線を平行に引けば得られる領域は 3 つになり、互いに垂直に引けば得られる領域は 4 つになります。\n\nn 本の直線を引くことで得られる最大の領域の数を出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットが与えられます。各データセットに n (1 ≤ n ≤ 10,000) が1行に与えられます。入力の最後まで処理して下さい。\n\nデータセットの数は 50 を超えません。\n\nOutput\n\n各データセットに対して、最大の分割数を1行に出力して下さい。\n\nSample Input\n\n1\n3\n\nOutput for the Sample Input\n\n2\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": 54, "cpu_time_ms": 40, "memory_kb": 8608}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s294522469", "group_id": "codeNet:p00057", "input_text": "$<.map{|j|i=j.to_i\np i*(i+1)/2+1}", "language": "Ruby", "metadata": {"date": 1489722675, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00057.html", "problem_id": "p00057", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00057/input.txt", "sample_output_relpath": "derived/input_output/data/p00057/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00057/Ruby/s294522469.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s294522469", "user_id": "u072398496"}, "prompt_components": {"gold_output": "2\n7\n", "input_to_evaluate": "$<.map{|j|i=j.to_i\np i*(i+1)/2+1}", "problem_context": "領域の数\n\n無限に広い平面の上に、無限に長い直線を数本引くと、この平面はいくつかの領域に分割されます。たとえば、直線を1本引くと、平面は2つの領域に分割されます。同じ数の直線を引いても、引き方によって得られる領域の数は異なります。たとえば、2 本の直線を平行に引けば得られる領域は 3 つになり、互いに垂直に引けば得られる領域は 4 つになります。\n\nn 本の直線を引くことで得られる最大の領域の数を出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットが与えられます。各データセットに n (1 ≤ n ≤ 10,000) が1行に与えられます。入力の最後まで処理して下さい。\n\nデータセットの数は 50 を超えません。\n\nOutput\n\n各データセットに対して、最大の分割数を1行に出力して下さい。\n\nSample Input\n\n1\n3\n\nOutput for the Sample Input\n\n2\n7", "sample_input": "1\n3\n"}, "reference_outputs": ["2\n7\n"], "source_document_id": "p00057", "source_text": "領域の数\n\n無限に広い平面の上に、無限に長い直線を数本引くと、この平面はいくつかの領域に分割されます。たとえば、直線を1本引くと、平面は2つの領域に分割されます。同じ数の直線を引いても、引き方によって得られる領域の数は異なります。たとえば、2 本の直線を平行に引けば得られる領域は 3 つになり、互いに垂直に引けば得られる領域は 4 つになります。\n\nn 本の直線を引くことで得られる最大の領域の数を出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットが与えられます。各データセットに n (1 ≤ n ≤ 10,000) が1行に与えられます。入力の最後まで処理して下さい。\n\nデータセットの数は 50 を超えません。\n\nOutput\n\n各データセットに対して、最大の分割数を1行に出力して下さい。\n\nSample Input\n\n1\n3\n\nOutput for the Sample Input\n\n2\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": 33, "cpu_time_ms": 40, "memory_kb": 8636}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s842334542", "group_id": "codeNet:p00059", "input_text": "readlines.each do |l|\n xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2 = l.split.map(&:to_f)\n puts (xb1<=xa1 && xa1<=xb2 || xa1<=xb1 && xb1<=xa2) &&\n (yb1<=ya2 && ya2<=yb2 || ya1<=yb2 && yb2<=ya2) ? \"YES\" : \"NO\"\nend", "language": "Ruby", "metadata": {"date": 1366725557, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00059.html", "problem_id": "p00059", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00059/input.txt", "sample_output_relpath": "derived/input_output/data/p00059/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00059/Ruby/s842334542.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s842334542", "user_id": "u662700808"}, "prompt_components": {"gold_output": "YES\nYES\nNO\n", "input_to_evaluate": "readlines.each do |l|\n xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2 = l.split.map(&:to_f)\n puts (xb1<=xa1 && xa1<=xb2 || xa1<=xb1 && xb1<=xa2) &&\n (yb1<=ya2 && ya2<=yb2 || ya1<=yb2 && yb2<=ya2) ? \"YES\" : \"NO\"\nend", "problem_context": "長方形の重なり\n\n底辺が x 軸に対して平行な 2 つの長方形があります。長方形 A の左下の座標 (xa1, ya1) と右上の座標 (xa2, ya2)、長方形 B の左下の座標 (xb1, yb1) と右上の座標 (xb2, yb2) を読み込んで、長方形 A と長方形 B が一部でも重なっていれば YES を、まったく重なっていなければ NO を出力するプログラムを作成してください。ただし、長方形 A と長方形 B は同じものではないとします。また、接しているものも重なっているとみなします。\n\nInput\n\n複数のデータセットが与えられます。各データセットの形式は以下のとおりです。\n\nxa1 ya1 xa2 ya2 xb1 yb1 xb2 yb2\n\n入力される値はそれぞれ -2,000 以上 2,000 以下であり、各値は小数点以下最大 5 桁までの数字を含む実数で与えられます。\n\nデータセットの数は 50 を超えません。\n\nOutput\n\n各データセットに対して、YES または NO を1行に出力して下さい。\n\nSample Input\n\n0.0 0.0 5.0 5.0 1.0 1.0 4.0 4.0\n0.0 0.0 4.0 5.0 1.0 1.0 5.0 5.0\n0.0 0.0 4.0 4.0 -3.0 -5.0 2.0 -1.0\n\nOutput for the Sample Input\n\nYES\nYES\nNO", "sample_input": "0.0 0.0 5.0 5.0 1.0 1.0 4.0 4.0\n0.0 0.0 4.0 5.0 1.0 1.0 5.0 5.0\n0.0 0.0 4.0 4.0 -3.0 -5.0 2.0 -1.0\n"}, "reference_outputs": ["YES\nYES\nNO\n"], "source_document_id": "p00059", "source_text": "長方形の重なり\n\n底辺が x 軸に対して平行な 2 つの長方形があります。長方形 A の左下の座標 (xa1, ya1) と右上の座標 (xa2, ya2)、長方形 B の左下の座標 (xb1, yb1) と右上の座標 (xb2, yb2) を読み込んで、長方形 A と長方形 B が一部でも重なっていれば YES を、まったく重なっていなければ NO を出力するプログラムを作成してください。ただし、長方形 A と長方形 B は同じものではないとします。また、接しているものも重なっているとみなします。\n\nInput\n\n複数のデータセットが与えられます。各データセットの形式は以下のとおりです。\n\nxa1 ya1 xa2 ya2 xb1 yb1 xb2 yb2\n\n入力される値はそれぞれ -2,000 以上 2,000 以下であり、各値は小数点以下最大 5 桁までの数字を含む実数で与えられます。\n\nデータセットの数は 50 を超えません。\n\nOutput\n\n各データセットに対して、YES または NO を1行に出力して下さい。\n\nSample Input\n\n0.0 0.0 5.0 5.0 1.0 1.0 4.0 4.0\n0.0 0.0 4.0 5.0 1.0 1.0 5.0 5.0\n0.0 0.0 4.0 4.0 -3.0 -5.0 2.0 -1.0\n\nOutput for the Sample Input\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": 207, "cpu_time_ms": 20, "memory_kb": 6112}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s804620385", "group_id": "codeNet:p00072", "input_text": "class Node\n attr_reader :id\n @@i = 0\n def self.clear\n @@i = 0\n end\n def initialize\n @u = nil\n @id = @@i\n @@i += 1\n end\n\n def ==(other)\n return find().id == other.find.id\n end\n def find()\n if @u\n return @u = @u.find()\n else\n return self\n end\n end\n\n def join(other)\n if @u\n @u.find.join(other)\n else\n @u = (other.find == (self)) ? nil : other.find\n end\n end\nend\n\ndef main\n while (n = gets.to_i) != 0\n m = gets.to_i\n nodes = Array.new(n){Node.new}\n path = Array.new(m){gets.chomp.split(\",\").map(&:to_i)}.sort_by{|(a, b, c)|c}\n puts path.map{|r|\n unless nodes[r[0]] == nodes[r[1]]\n nodes[r[0]].join(nodes[r[1]])\n r[2] - 100\n else\n 0\n end}.reduce(0){|a, i|a + i / 100}\n Node.clear\n end\nend\nmain", "language": "Ruby", "metadata": {"date": 1450862421, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00072.html", "problem_id": "p00072", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00072/input.txt", "sample_output_relpath": "derived/input_output/data/p00072/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00072/Ruby/s804620385.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s804620385", "user_id": "u514597327"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "class Node\n attr_reader :id\n @@i = 0\n def self.clear\n @@i = 0\n end\n def initialize\n @u = nil\n @id = @@i\n @@i += 1\n end\n\n def ==(other)\n return find().id == other.find.id\n end\n def find()\n if @u\n return @u = @u.find()\n else\n return self\n end\n end\n\n def join(other)\n if @u\n @u.find.join(other)\n else\n @u = (other.find == (self)) ? nil : other.find\n end\n end\nend\n\ndef main\n while (n = gets.to_i) != 0\n m = gets.to_i\n nodes = Array.new(n){Node.new}\n path = Array.new(m){gets.chomp.split(\",\").map(&:to_i)}.sort_by{|(a, b, c)|c}\n puts path.map{|r|\n unless nodes[r[0]] == nodes[r[1]]\n nodes[r[0]].join(nodes[r[1]])\n r[2] - 100\n else\n 0\n end}.reduce(0){|a, i|a + i / 100}\n Node.clear\n end\nend\nmain", "problem_context": "灯篭\n\n会津若松市は「歴史の町」として知られています。今から約 400 年前、蒲生氏郷により城下町の骨格が作られましたが、その後、徳川三代将軍家光公の異母弟「保科正之」公を藩祖とする会津藩 23 万石の中心都市として発展しました。今でも市内のいたるところに史跡や昔日の面影が残っているため、毎年、全国から多くの観光客が訪れています。\n\n今年は、NHK大河ドラマで「新選組!」が放送されているため、新選組ゆかりの地(*1)として、大幅に観光客が増加しています。そこで市では、市内に点在する史跡を結ぶ通り沿いに 100 m 間隔で灯篭を設置して飾りたてることにしました。灯篭を飾ってある通りを辿れば市内の全ての史跡に到達できるように設置することが条件ですが、一筆書きでたどれる必要はありません。しかし、予算が限られているので設置する灯篭の数を最小限にする必要があります。\n\n史跡と史跡を結ぶ通りのデータを読み込んで、必要最小限の灯篭の数を出力するプログラムを作成して下さい。ただし、史跡と史跡の間の距離は 200 m 以上で、100 の倍数で与えられます。おのおのの史跡から一番近い灯篭までの距離は 100 m で、市内の史跡は 100 箇所以内です。史跡自身には灯篭を設置する必要はありません。\n\n(*1) 新選組は会津藩御預という形で発足、白虎隊の悲劇で知られる会津戊辰戦争に参戦、市内天寧寺に土方歳三が近藤勇の墓を建立\n\nInput\n\n複数のデータセットが与えられます。各データセットは以下の形式で与えられます。\n\nn\nm\na1,b1,d1\na2,b2,d2\n:\nam,bm,dm\n\n各データセットの最初の 1 行には史跡の箇所数 n が与えられます。続いて史跡と史跡を結ぶ通りの数 m が与えられます。続く m 行に カンマで区切られてた3 つの数数 ai, bi, di が与えられます。ai, bi は史跡の番号です。史跡の番号は 0 番から n - 1 番まで振られています。ai bi はそれらを結ぶ通りがあることを示し、di は ai bi 間の道路の距離を表します。\n\nn が 0 のとき入力の最後とします。データセットの数は 20 を超えません。\n\nOutput\n\n各データセットに対して、必要最小限の灯篭の数を1行に出力して下さい。\n\nSample Input\n\n4\n4\n0,1,1500\n0,2,2000\n1,2,600\n1,3,500\n0\n\nOutput for the Sample Input\n\n23", "sample_input": "4\n4\n0,1,1500\n0,2,2000\n1,2,600\n1,3,500\n0\n"}, "reference_outputs": ["23\n"], "source_document_id": "p00072", "source_text": "灯篭\n\n会津若松市は「歴史の町」として知られています。今から約 400 年前、蒲生氏郷により城下町の骨格が作られましたが、その後、徳川三代将軍家光公の異母弟「保科正之」公を藩祖とする会津藩 23 万石の中心都市として発展しました。今でも市内のいたるところに史跡や昔日の面影が残っているため、毎年、全国から多くの観光客が訪れています。\n\n今年は、NHK大河ドラマで「新選組!」が放送されているため、新選組ゆかりの地(*1)として、大幅に観光客が増加しています。そこで市では、市内に点在する史跡を結ぶ通り沿いに 100 m 間隔で灯篭を設置して飾りたてることにしました。灯篭を飾ってある通りを辿れば市内の全ての史跡に到達できるように設置することが条件ですが、一筆書きでたどれる必要はありません。しかし、予算が限られているので設置する灯篭の数を最小限にする必要があります。\n\n史跡と史跡を結ぶ通りのデータを読み込んで、必要最小限の灯篭の数を出力するプログラムを作成して下さい。ただし、史跡と史跡の間の距離は 200 m 以上で、100 の倍数で与えられます。おのおのの史跡から一番近い灯篭までの距離は 100 m で、市内の史跡は 100 箇所以内です。史跡自身には灯篭を設置する必要はありません。\n\n(*1) 新選組は会津藩御預という形で発足、白虎隊の悲劇で知られる会津戊辰戦争に参戦、市内天寧寺に土方歳三が近藤勇の墓を建立\n\nInput\n\n複数のデータセットが与えられます。各データセットは以下の形式で与えられます。\n\nn\nm\na1,b1,d1\na2,b2,d2\n:\nam,bm,dm\n\n各データセットの最初の 1 行には史跡の箇所数 n が与えられます。続いて史跡と史跡を結ぶ通りの数 m が与えられます。続く m 行に カンマで区切られてた3 つの数数 ai, bi, di が与えられます。ai, bi は史跡の番号です。史跡の番号は 0 番から n - 1 番まで振られています。ai bi はそれらを結ぶ通りがあることを示し、di は ai bi 間の道路の距離を表します。\n\nn が 0 のとき入力の最後とします。データセットの数は 20 を超えません。\n\nOutput\n\n各データセットに対して、必要最小限の灯篭の数を1行に出力して下さい。\n\nSample Input\n\n4\n4\n0,1,1500\n0,2,2000\n1,2,600\n1,3,500\n0\n\nOutput for the Sample Input\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": 807, "cpu_time_ms": 60, "memory_kb": 8944}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s816405136", "group_id": "codeNet:p00074", "input_text": "loop do\n record_time=2*3600#????????§???????§???°\n time=gets.chomp.split(nil).map(&:to_i)\n break if time.all?{|x|x==-1}\n t=time[2]\n t+=time[1]*60\n t+=time[0]*3600\n #?¨??????????\n rest_of_time=record_time-t\n h=rest_of_time/3600#hour\n m=(rest_of_time%3600)/60#minute\n s=rest_of_time%60#second\n printf(\"%02d:%02d:%02d \\n\",h,m,s)\n #3???????????¢??????\n rest_of_time=(record_time-t)*3\n h=rest_of_time/3600#hour\n m=(rest_of_time%3600)/60#minute\n s=rest_of_time%60#second\n printf(\"%02d:%02d:%02d \\n\",h,m,s)\nend", "language": "Ruby", "metadata": {"date": 1425879537, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00074.html", "problem_id": "p00074", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00074/input.txt", "sample_output_relpath": "derived/input_output/data/p00074/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00074/Ruby/s816405136.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s816405136", "user_id": "u287407095"}, "prompt_components": {"gold_output": "00:30:00\n01:30:00\n", "input_to_evaluate": "loop do\n record_time=2*3600#????????§???????§???°\n time=gets.chomp.split(nil).map(&:to_i)\n break if time.all?{|x|x==-1}\n t=time[2]\n t+=time[1]*60\n t+=time[0]*3600\n #?¨??????????\n rest_of_time=record_time-t\n h=rest_of_time/3600#hour\n m=(rest_of_time%3600)/60#minute\n s=rest_of_time%60#second\n printf(\"%02d:%02d:%02d \\n\",h,m,s)\n #3???????????¢??????\n rest_of_time=(record_time-t)*3\n h=rest_of_time/3600#hour\n m=(rest_of_time%3600)/60#minute\n s=rest_of_time%60#second\n printf(\"%02d:%02d:%02d \\n\",h,m,s)\nend", "problem_context": "ビデオテープ\n\n標準録画で 120 分のビデオテープがあります。テープを完全に巻き戻した状態でビデオデッキのカウンタを 00:00:00 にし、標準録画モードで録画したところ、あるカウンタ値になりました。このカウンタ値(時、分、秒)を入力し、残りのテープの長さ(録画可能時間)を求め、時:分:秒の形式で出力するプログラムを作成して下さい。\n\nただし、2 時間(120分)以内の入力とします。なお、テープ残量は標準録画モードと 3 倍録画モードの場合の2通りを計算し、出力例のように時、分、秒とも 2 桁ずつ出力します。また \"05\" のように 10 の位が 0 の場合は、\"0\" をつけてください。\n\n入力\n\n複数のデータセットが与えられます。各データセットは以下のとおりです。\n\nT H S\n\nT, H, S はそれぞれ時、分、秒を表す整数です。\n\nT, H, S がすべて -1 のとき入力の終わりとします。データセットの数は 50 を超えません。\n\n出力\n\n各データセットごとに\n\n1 行目に、テープの残りを標準録画した場合の録画可能時間の時、分、秒を半角コロン区切りで、\n\n2 行目に、テープの残りを3倍録画した場合の録画可能時間の時、分、秒を半角コロン区切りで\n\n出力して下さい。\n\nSample Input\n\n1 30 0\n-1 -1 -1\n\nOutput for the Sample Input\n\n00:30:00\n01:30:00", "sample_input": "1 30 0\n-1 -1 -1\n"}, "reference_outputs": ["00:30:00\n01:30:00\n"], "source_document_id": "p00074", "source_text": "ビデオテープ\n\n標準録画で 120 分のビデオテープがあります。テープを完全に巻き戻した状態でビデオデッキのカウンタを 00:00:00 にし、標準録画モードで録画したところ、あるカウンタ値になりました。このカウンタ値(時、分、秒)を入力し、残りのテープの長さ(録画可能時間)を求め、時:分:秒の形式で出力するプログラムを作成して下さい。\n\nただし、2 時間(120分)以内の入力とします。なお、テープ残量は標準録画モードと 3 倍録画モードの場合の2通りを計算し、出力例のように時、分、秒とも 2 桁ずつ出力します。また \"05\" のように 10 の位が 0 の場合は、\"0\" をつけてください。\n\n入力\n\n複数のデータセットが与えられます。各データセットは以下のとおりです。\n\nT H S\n\nT, H, S はそれぞれ時、分、秒を表す整数です。\n\nT, H, S がすべて -1 のとき入力の終わりとします。データセットの数は 50 を超えません。\n\n出力\n\n各データセットごとに\n\n1 行目に、テープの残りを標準録画した場合の録画可能時間の時、分、秒を半角コロン区切りで、\n\n2 行目に、テープの残りを3倍録画した場合の録画可能時間の時、分、秒を半角コロン区切りで\n\n出力して下さい。\n\nSample Input\n\n1 30 0\n-1 -1 -1\n\nOutput for the Sample Input\n\n00:30:00\n01:30:00", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 562, "cpu_time_ms": 20, "memory_kb": 6112}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s940914676", "group_id": "codeNet:p00077", "input_text": "while (line = gets)\n str = line.chomp\n status = 0\n uns = \"\"\n num = 0\n str.each_char do |ch|\n case status\n when 0 then\n if ch == \"@\"\n status = 1\n else\n uns += ch\n end\n when 1 then\n num = ch.to_i\n status = 2\n when 2 then\n num.times {uns += ch}\n status = 0\n end\n end\n\n puts uns\nend\n\n", "language": "Ruby", "metadata": {"date": 1530021559, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00077.html", "problem_id": "p00077", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00077/input.txt", "sample_output_relpath": "derived/input_output/data/p00077/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00077/Ruby/s940914676.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s940914676", "user_id": "u592742011"}, "prompt_components": {"gold_output": "abCCCCC10000000050\n999999999+1=1000000000\n", "input_to_evaluate": "while (line = gets)\n str = line.chomp\n status = 0\n uns = \"\"\n num = 0\n str.each_char do |ch|\n case status\n when 0 then\n if ch == \"@\"\n status = 1\n else\n uns += ch\n end\n when 1 then\n num = ch.to_i\n status = 2\n when 2 then\n num.times {uns += ch}\n status = 0\n end\n end\n\n puts uns\nend\n\n", "problem_context": "ランレングス\n\n文字列が連続した場合、ある規則で文字を置き換え文字列を短くすることができます。たとえば、AAAA という文字列の場合、@4A と表現すれば 1 文字分圧縮されます。この規則で圧縮された文字列を入力してもとの文字列に復元するプログラムを作成してください。ただし、復元した文字列に@文字は出現しないものとします。\n\nまた、原文の文字列は英大文字、英小文字、数字、記号であり 100 文字以内、連続する文字は 9 文字以内です。\n\n入力\n\n複数の文字列が与えられます。1行に1つの文字列が与えられます。文字列の数は 50 を超えません。\n\n出力\n\n文字列ごとに、各文字に対して復元した文字列を1行に出力して下さい。\n\nSample Input\n\nab@5C1@8050\n@99+1=1@90\n\nOutput for the Sample Input\n\nabCCCCC10000000050\n999999999+1=1000000000", "sample_input": "ab@5C1@8050\n@99+1=1@90\n"}, "reference_outputs": ["abCCCCC10000000050\n999999999+1=1000000000\n"], "source_document_id": "p00077", "source_text": "ランレングス\n\n文字列が連続した場合、ある規則で文字を置き換え文字列を短くすることができます。たとえば、AAAA という文字列の場合、@4A と表現すれば 1 文字分圧縮されます。この規則で圧縮された文字列を入力してもとの文字列に復元するプログラムを作成してください。ただし、復元した文字列に@文字は出現しないものとします。\n\nまた、原文の文字列は英大文字、英小文字、数字、記号であり 100 文字以内、連続する文字は 9 文字以内です。\n\n入力\n\n複数の文字列が与えられます。1行に1つの文字列が与えられます。文字列の数は 50 を超えません。\n\n出力\n\n文字列ごとに、各文字に対して復元した文字列を1行に出力して下さい。\n\nSample Input\n\nab@5C1@8050\n@99+1=1@90\n\nOutput for the Sample Input\n\nabCCCCC10000000050\n999999999+1=1000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 50, "memory_kb": 6844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s393678582", "group_id": "codeNet:p00089", "input_text": "a = $<.map{|s| s.split(\",\").map(&:to_i)}\n(1..a.size-1).each{|i|\n (0..a[i].size-1).each{|j|\n if a[i-1].size < a[i].size\n a[i][j] = [a[i-1][j] || 0, j > 0 ? a[i-1][j-1] : 0].max + a[i][j]\n else\n a[i][j] = [a[i-1][j], a[i-1][j+1]].max + a[i][j]\n end\n }\n}\np a[-1][0]", "language": "Ruby", "metadata": {"date": 1437936094, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00089.html", "problem_id": "p00089", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00089/input.txt", "sample_output_relpath": "derived/input_output/data/p00089/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00089/Ruby/s393678582.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s393678582", "user_id": "u797180951"}, "prompt_components": {"gold_output": "55\n", "input_to_evaluate": "a = $<.map{|s| s.split(\",\").map(&:to_i)}\n(1..a.size-1).each{|i|\n (0..a[i].size-1).each{|j|\n if a[i-1].size < a[i].size\n a[i][j] = [a[i-1][j] || 0, j > 0 ? a[i-1][j-1] : 0].max + a[i][j]\n else\n a[i][j] = [a[i-1][j], a[i-1][j+1]].max + a[i][j]\n end\n }\n}\np a[-1][0]", "problem_context": "最短経路\n\n図1に例示するように整数(0 以上 99 以下)をひしがたに並べます。このような、ひしがたを表すデータを読み込んで、一番上からスタートして一番下まで次のルールに従って進むとき、通過する整数の和の最大値を出力するプログラムを作成してください。\n\n各ステップで、対角線上の左下か対角線上の右下に進むことができます。\n\n例えば図1の例では、図2に示すように、7,3,8,7,5,7,8,3,7を選んで通ったとき、その和は最大の 55 (7+3+8+7+5+7+8+3+7=55) となります。\n\nInput\n\n入力例に示すように、カンマで区切られた整数の並びが、ひし形状に与えられます。各行に空白文字は含まれません。入力例は図1に対応しています。\nデータの行数は 100 行未満です。\n\nOutput\n\nルールに従って通過する整数の和の最大値を1行に出力します。\n\nSample Input\n\n7\n3,8\n8,1,0\n2,7,4,4\n4,5,2,6,5\n2,7,4,4\n8,1,0\n3,8\n7\n\nSample Output\n\n55", "sample_input": "7\n3,8\n8,1,0\n2,7,4,4\n4,5,2,6,5\n2,7,4,4\n8,1,0\n3,8\n7\n"}, "reference_outputs": ["55\n"], "source_document_id": "p00089", "source_text": "最短経路\n\n図1に例示するように整数(0 以上 99 以下)をひしがたに並べます。このような、ひしがたを表すデータを読み込んで、一番上からスタートして一番下まで次のルールに従って進むとき、通過する整数の和の最大値を出力するプログラムを作成してください。\n\n各ステップで、対角線上の左下か対角線上の右下に進むことができます。\n\n例えば図1の例では、図2に示すように、7,3,8,7,5,7,8,3,7を選んで通ったとき、その和は最大の 55 (7+3+8+7+5+7+8+3+7=55) となります。\n\nInput\n\n入力例に示すように、カンマで区切られた整数の並びが、ひし形状に与えられます。各行に空白文字は含まれません。入力例は図1に対応しています。\nデータの行数は 100 行未満です。\n\nOutput\n\nルールに従って通過する整数の和の最大値を1行に出力します。\n\nSample Input\n\n7\n3,8\n8,1,0\n2,7,4,4\n4,5,2,6,5\n2,7,4,4\n8,1,0\n3,8\n7\n\nSample Output\n\n55", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 311, "cpu_time_ms": 20, "memory_kb": 6108}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s979537521", "group_id": "codeNet:p00090", "input_text": "def calc(a, b)\n (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2 <= 4\nend\nwhile n = gets.to_i\n break if n == 0\n dots = Array.new(n)\n cnt = Array.new(n,1)\n n.times {|i| dots[i] = gets.split(\",\").map(&:to_f)}\n n.times do |i|\n ((i+1)...n).each do |j|\n if calc(dots[i], dots[j])\n cnt[i] += 1\n cnt[j] += 1\n end\n end\n end\n p cnt.max\nend", "language": "Ruby", "metadata": {"date": 1447119908, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00090.html", "problem_id": "p00090", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00090/input.txt", "sample_output_relpath": "derived/input_output/data/p00090/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00090/Ruby/s979537521.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s979537521", "user_id": "u811434779"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "def calc(a, b)\n (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2 <= 4\nend\nwhile n = gets.to_i\n break if n == 0\n dots = Array.new(n)\n cnt = Array.new(n,1)\n n.times {|i| dots[i] = gets.split(\",\").map(&:to_f)}\n n.times do |i|\n ((i+1)...n).each do |j|\n if calc(dots[i], dots[j])\n cnt[i] += 1\n cnt[j] += 1\n end\n end\n end\n p cnt.max\nend", "problem_context": "シールの重なり\n\n1 辺の長さが 10 の正方形の折り紙に半径 1 の円形のシールを n 枚貼ります。シールは重ねて貼ることができます。シールを貼る位置の座標を読み込んで、折り紙上でもっとも多くシールが重なっている場所(シールが1枚だけでも\"重なっている\"とする)でのシールの枚数を出力するプログラムを作成してください。\n\n折り紙の左下を原点とした x, y 座標を与えます。この x, y を円の中心としてシールを貼ることとします。円の中心が折り紙の外に出ることはありません。また、同一座標に複数のシールが貼られることはありません。\n\nInput\n\n複数のデータセットが与えられます。各データセットは以下のような形式で与えられます。\n\nn\nx1,y1\nx2,y2\n:\nxn,yn\n\n1行目にシールの枚数 n (0 ≤ 100) が与えられます。続く n 行に、各シールの中心座標が与えられます。\nxi, yi は i 枚目のシールの中心の x 座標と y 座標を表します。各値は小数点以下最大 6 桁までの数字を含む実数で与えられます。\n\nn が 0 のとき、入力の最後とします。データセットの数は 50 を超えません。\n\nOutput\n\n各データセットに対し、折り紙上で最も多くシールが重なっている場所でのシールの枚数(整数)を出力して下さい。\n\nSample Input\n\n15\n3.14979,8.51743\n2.39506,3.84915\n2.68432,5.39095\n5.61904,9.16332\n7.85653,4.75593\n2.84021,5.41511\n1.79500,8.59211\n7.55389,8.17604\n4.70665,4.66125\n1.63470,4.42538\n7.34959,4.61981\n5.09003,8.11122\n5.24373,1.30066\n0.13517,1.83659\n7.57313,1.58150\n0\n\nOutput for the Sample Input\n\n4\n\nHint\n\n入力例のようにシールを貼った図です。円はシール、数字は入力例の行数を表しています。\n点(2.3,4.6)では、入力例の 2 行目、3 行目、6 行目、10 行目の 4 枚のシールが重なっています。\n\n6 と 9 のおのおのの中心の距離は 2.01293 なので、シールは重なっていません。1 と 12 のおのおのの中心の距離は 1.98231 なので、シールは重なっています。\n\n2つの円が接しているとき(おのおのの中心の距離が 2 のとき)は、重なっているものとします。", "sample_input": "15\n3.14979,8.51743\n2.39506,3.84915\n2.68432,5.39095\n5.61904,9.16332\n7.85653,4.75593\n2.84021,5.41511\n1.79500,8.59211\n7.55389,8.17604\n4.70665,4.66125\n1.63470,4.42538\n7.34959,4.61981\n5.09003,8.11122\n5.24373,1.30066\n0.13517,1.83659\n7.57313,1.58150\n0\n"}, "reference_outputs": ["4\n"], "source_document_id": "p00090", "source_text": "シールの重なり\n\n1 辺の長さが 10 の正方形の折り紙に半径 1 の円形のシールを n 枚貼ります。シールは重ねて貼ることができます。シールを貼る位置の座標を読み込んで、折り紙上でもっとも多くシールが重なっている場所(シールが1枚だけでも\"重なっている\"とする)でのシールの枚数を出力するプログラムを作成してください。\n\n折り紙の左下を原点とした x, y 座標を与えます。この x, y を円の中心としてシールを貼ることとします。円の中心が折り紙の外に出ることはありません。また、同一座標に複数のシールが貼られることはありません。\n\nInput\n\n複数のデータセットが与えられます。各データセットは以下のような形式で与えられます。\n\nn\nx1,y1\nx2,y2\n:\nxn,yn\n\n1行目にシールの枚数 n (0 ≤ 100) が与えられます。続く n 行に、各シールの中心座標が与えられます。\nxi, yi は i 枚目のシールの中心の x 座標と y 座標を表します。各値は小数点以下最大 6 桁までの数字を含む実数で与えられます。\n\nn が 0 のとき、入力の最後とします。データセットの数は 50 を超えません。\n\nOutput\n\n各データセットに対し、折り紙上で最も多くシールが重なっている場所でのシールの枚数(整数)を出力して下さい。\n\nSample Input\n\n15\n3.14979,8.51743\n2.39506,3.84915\n2.68432,5.39095\n5.61904,9.16332\n7.85653,4.75593\n2.84021,5.41511\n1.79500,8.59211\n7.55389,8.17604\n4.70665,4.66125\n1.63470,4.42538\n7.34959,4.61981\n5.09003,8.11122\n5.24373,1.30066\n0.13517,1.83659\n7.57313,1.58150\n0\n\nOutput for the Sample Input\n\n4\n\nHint\n\n入力例のようにシールを貼った図です。円はシール、数字は入力例の行数を表しています。\n点(2.3,4.6)では、入力例の 2 行目、3 行目、6 行目、10 行目の 4 枚のシールが重なっています。\n\n6 と 9 のおのおのの中心の距離は 2.01293 なので、シールは重なっていません。1 と 12 のおのおのの中心の距離は 1.98231 なので、シールは重なっています。\n\n2つの円が接しているとき(おのおのの中心の距離が 2 のとき)は、重なっているものとします。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 40, "memory_kb": 8812}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s233705164", "group_id": "codeNet:p00094", "input_text": "puts gets.split.map(&:to_i).inject(:*) / 3.305785", "language": "Ruby", "metadata": {"date": 1439396908, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00094.html", "problem_id": "p00094", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00094/input.txt", "sample_output_relpath": "derived/input_output/data/p00094/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00094/Ruby/s233705164.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s233705164", "user_id": "u814658648"}, "prompt_components": {"gold_output": "113.437508\n", "input_to_evaluate": "puts gets.split.map(&:to_i).inject(:*) / 3.305785", "problem_context": "坪面積の計算\n\n土地の面積を表現する「○○坪」という単位を聞いたことはないでしょうか? 古来、1人の武士が1日に食べるお米を作る面積を言いました。\n\na[m]× b[m]の土地があります。a と b を入力し、その土地の坪面積 S[坪]を出力するプログラムを作成してください。 1 坪 = 3.305785 [m2] とし、a と b は 100 以下の整数とします。\n\n入力\n\na b\n\n1つの空白で区切られた a と b が1行に与えられる。\n\n出力\n\n坪面積 S を1行に出力する。0.0001 以下の誤差が許される。\n\n入力例1\n\n15 25\n\n出力例1\n\n113.437508", "sample_input": "15 25\n"}, "reference_outputs": ["113.437508\n"], "source_document_id": "p00094", "source_text": "坪面積の計算\n\n土地の面積を表現する「○○坪」という単位を聞いたことはないでしょうか? 古来、1人の武士が1日に食べるお米を作る面積を言いました。\n\na[m]× b[m]の土地があります。a と b を入力し、その土地の坪面積 S[坪]を出力するプログラムを作成してください。 1 坪 = 3.305785 [m2] とし、a と b は 100 以下の整数とします。\n\n入力\n\na b\n\n1つの空白で区切られた a と b が1行に与えられる。\n\n出力\n\n坪面積 S を1行に出力する。0.0001 以下の誤差が許される。\n\n入力例1\n\n15 25\n\n出力例1\n\n113.437508", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 49, "cpu_time_ms": 20, "memory_kb": 6124}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s568225448", "group_id": "codeNet:p00094", "input_text": "a,b = gets.split.map(&:to_i)\nm = a * b\nputs (m / 3.305785).round(6).to_f\n", "language": "Ruby", "metadata": {"date": 1537861226, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00094.html", "problem_id": "p00094", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00094/input.txt", "sample_output_relpath": "derived/input_output/data/p00094/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00094/Ruby/s568225448.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s568225448", "user_id": "u809272156"}, "prompt_components": {"gold_output": "113.437508\n", "input_to_evaluate": "a,b = gets.split.map(&:to_i)\nm = a * b\nputs (m / 3.305785).round(6).to_f\n", "problem_context": "坪面積の計算\n\n土地の面積を表現する「○○坪」という単位を聞いたことはないでしょうか? 古来、1人の武士が1日に食べるお米を作る面積を言いました。\n\na[m]× b[m]の土地があります。a と b を入力し、その土地の坪面積 S[坪]を出力するプログラムを作成してください。 1 坪 = 3.305785 [m2] とし、a と b は 100 以下の整数とします。\n\n入力\n\na b\n\n1つの空白で区切られた a と b が1行に与えられる。\n\n出力\n\n坪面積 S を1行に出力する。0.0001 以下の誤差が許される。\n\n入力例1\n\n15 25\n\n出力例1\n\n113.437508", "sample_input": "15 25\n"}, "reference_outputs": ["113.437508\n"], "source_document_id": "p00094", "source_text": "坪面積の計算\n\n土地の面積を表現する「○○坪」という単位を聞いたことはないでしょうか? 古来、1人の武士が1日に食べるお米を作る面積を言いました。\n\na[m]× b[m]の土地があります。a と b を入力し、その土地の坪面積 S[坪]を出力するプログラムを作成してください。 1 坪 = 3.305785 [m2] とし、a と b は 100 以下の整数とします。\n\n入力\n\na b\n\n1つの空白で区切られた a と b が1行に与えられる。\n\n出力\n\n坪面積 S を1行に出力する。0.0001 以下の誤差が許される。\n\n入力例1\n\n15 25\n\n出力例1\n\n113.437508", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 73, "cpu_time_ms": 50, "memory_kb": 8924}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s167471905", "group_id": "codeNet:p00095", "input_text": "a_max, v_max = 0, -1\n\ngets.to_i.times do\n a, v = gets.split.map(&:to_i)\n a_max, v_max = a, v if v_max < v\n a_max = a if v_max == v && a < a_max\nend\n\nputs \"#{a_max} #{v_max}\"", "language": "Ruby", "metadata": {"date": 1439548221, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00095.html", "problem_id": "p00095", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00095/input.txt", "sample_output_relpath": "derived/input_output/data/p00095/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00095/Ruby/s167471905.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s167471905", "user_id": "u814658648"}, "prompt_components": {"gold_output": "3 42\n", "input_to_evaluate": "a_max, v_max = 0, -1\n\ngets.to_i.times do\n a, v = gets.split.map(&:to_i)\n a_max, v_max = a, v if v_max < v\n a_max = a if v_max == v && a < a_max\nend\n\nputs \"#{a_max} #{v_max}\"", "problem_context": "ワカサギ釣り大会\n\n桧原湖でワカサギ釣り大会が行われました。一番多くのワカサギを獲得した人が優勝者です。\n\n参加者番号と釣った匹数のリストを読み込み、優勝者の番号と釣った匹数を出力するプログラムを作成してください。優勝者が複数いる場合は、その中で参加者番号が最も小さい一人を出力してください。\n\n入力\n\n入力は以下の形式で与えられる。\n\nn\na1 v1\na2 v2\n:\nan vn\n\nn (1 ≤ n ≤ 20) は参加者の数、ai は参加者番号を表す。参加者番号は 1 以上 n 以下の異なる整数である。vi ( 0 ≤ vi ≤ 100) は参加者 ai が獲得した匹数である。\n\n出力\n\n優勝者の参加者番号と釣った匹数を空白区切りで1行に出力せよ。\n\n入力例\n\n6\n1 14\n2 25\n3 42\n4 11\n5 40\n6 37\n\n出力例\n\n3 42", "sample_input": "6\n1 14\n2 25\n3 42\n4 11\n5 40\n6 37\n"}, "reference_outputs": ["3 42\n"], "source_document_id": "p00095", "source_text": "ワカサギ釣り大会\n\n桧原湖でワカサギ釣り大会が行われました。一番多くのワカサギを獲得した人が優勝者です。\n\n参加者番号と釣った匹数のリストを読み込み、優勝者の番号と釣った匹数を出力するプログラムを作成してください。優勝者が複数いる場合は、その中で参加者番号が最も小さい一人を出力してください。\n\n入力\n\n入力は以下の形式で与えられる。\n\nn\na1 v1\na2 v2\n:\nan vn\n\nn (1 ≤ n ≤ 20) は参加者の数、ai は参加者番号を表す。参加者番号は 1 以上 n 以下の異なる整数である。vi ( 0 ≤ vi ≤ 100) は参加者 ai が獲得した匹数である。\n\n出力\n\n優勝者の参加者番号と釣った匹数を空白区切りで1行に出力せよ。\n\n入力例\n\n6\n1 14\n2 25\n3 42\n4 11\n5 40\n6 37\n\n出力例\n\n3 42", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 176, "cpu_time_ms": 20, "memory_kb": 6104}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s190242952", "group_id": "codeNet:p00096", "input_text": "$<.each do |l|\n n = l.to_i\n p ([n - 2000, 0].max..[n, 2000].min).map {|i| ([i, 1000].min - [i - 1000, 0].max + 1) * ([n-i, 1000].min - [n-i - 1000, 0].max + 1) }.inject 0, :+\nend", "language": "Ruby", "metadata": {"date": 1509868626, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00096.html", "problem_id": "p00096", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00096/input.txt", "sample_output_relpath": "derived/input_output/data/p00096/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00096/Ruby/s190242952.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s190242952", "user_id": "u006169802"}, "prompt_components": {"gold_output": "10\n20\n8436\n", "input_to_evaluate": "$<.each do |l|\n n = l.to_i\n p ([n - 2000, 0].max..[n, 2000].min).map {|i| ([i, 1000].min - [i - 1000, 0].max + 1) * ([n-i, 1000].min - [n-i - 1000, 0].max + 1) }.inject 0, :+\nend", "problem_context": "4つの整数の和 II\n\n4,000 以下の正の整数 n を入力し、0 〜 1000 の範囲の整数 a, b, c, d の組で\n\na + b + c + d = n\n\nを満たすものの組み合わせ数を出力するプログラムを作成して下さい。\n\nInput\n\n複数のデータセットが与えられます。各データセットに n が1行に与えられます。入力の最後まで処理して下さい。\n\nデータセットの数は 50 を超えません。\n\nOutput\n\n各データセットごとに、a, b, c, d の組み合わせの個数を1行に出力して下さい。\n\nSample Input\n\n2\n3\n35\n\nOutput for the Sample Input\n\n10\n20\n8436", "sample_input": "2\n3\n35\n"}, "reference_outputs": ["10\n20\n8436\n"], "source_document_id": "p00096", "source_text": "4つの整数の和 II\n\n4,000 以下の正の整数 n を入力し、0 〜 1000 の範囲の整数 a, b, c, d の組で\n\na + b + c + d = n\n\nを満たすものの組み合わせ数を出力するプログラムを作成して下さい。\n\nInput\n\n複数のデータセットが与えられます。各データセットに n が1行に与えられます。入力の最後まで処理して下さい。\n\nデータセットの数は 50 を超えません。\n\nOutput\n\n各データセットごとに、a, b, c, d の組み合わせの個数を1行に出力して下さい。\n\nSample Input\n\n2\n3\n35\n\nOutput for the Sample Input\n\n10\n20\n8436", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 180, "cpu_time_ms": 100, "memory_kb": 8820}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s165929337", "group_id": "codeNet:p00100", "input_text": "while (n=gets.to_i)!=0\n h=Hash.new\n n.times do\n id,val,amo=gets.split.map(&:to_i)\n h.key?(id) ? h[id]+=(val*amo) : h.store(id,val*amo)\n end\n ans=h.select{|k,v| v>=1000000}\n puts ans.empty? ? \"NA\" : ans.keys\nend", "language": "Ruby", "metadata": {"date": 1478565828, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s165929337.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s165929337", "user_id": "u461552210"}, "prompt_components": {"gold_output": "1001\n1003\nNA\n2013\n", "input_to_evaluate": "while (n=gets.to_i)!=0\n h=Hash.new\n n.times do\n id,val,amo=gets.split.map(&:to_i)\n h.key?(id) ? h[id]+=(val*amo) : h.store(id,val*amo)\n end\n ans=h.select{|k,v| v>=1000000}\n puts ans.empty? ? \"NA\" : ans.keys\nend", "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": 221, "cpu_time_ms": 60, "memory_kb": 8816}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s738364829", "group_id": "codeNet:p00101", "input_text": "gets.to_i.times do\n puts gets.gsub(\"Hoshino\", \"Hoshina\")\nend", "language": "Ruby", "metadata": {"date": 1438782698, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00101.html", "problem_id": "p00101", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00101/input.txt", "sample_output_relpath": "derived/input_output/data/p00101/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00101/Ruby/s738364829.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s738364829", "user_id": "u814658648"}, "prompt_components": {"gold_output": "Hoshina\nHashino\nMasayuki Hoshina was the grandson of Ieyasu Tokugawa.\n", "input_to_evaluate": "gets.to_i.times do\n puts gets.gsub(\"Hoshino\", \"Hoshina\")\nend", "problem_context": "Aizu PR\n\nAn English booklet has been created for publicizing Aizu to the world.\nWhen you read it carefully, you found a misnomer (an error in writing) on the last name of Masayuki Hoshina, the lord of the Aizu domain. The booklet says \"Hoshino\" not \"Hoshina\".\n\nYour task is to write a program which replace all the words \"Hoshino\" with \"Hoshina\". You can assume that the number of characters in a text is less than or equal to 1000.\n\nInput\n\nThe input consists of several datasets. There will be the number of datasets n in the first line. There will be n lines. A line consisting of english texts will be given for each dataset.\n\nOutput\n\nFor each dataset, print the converted texts in a line.\n\nSample Input\n\n3\nHoshino\nHashino\nMasayuki Hoshino was the grandson of Ieyasu Tokugawa.\n\nOutput for the Sample Input\n\nHoshina\nHashino\nMasayuki Hoshina was the grandson of Ieyasu Tokugawa.", "sample_input": "3\nHoshino\nHashino\nMasayuki Hoshino was the grandson of Ieyasu Tokugawa.\n"}, "reference_outputs": ["Hoshina\nHashino\nMasayuki Hoshina was the grandson of Ieyasu Tokugawa.\n"], "source_document_id": "p00101", "source_text": "Aizu PR\n\nAn English booklet has been created for publicizing Aizu to the world.\nWhen you read it carefully, you found a misnomer (an error in writing) on the last name of Masayuki Hoshina, the lord of the Aizu domain. The booklet says \"Hoshino\" not \"Hoshina\".\n\nYour task is to write a program which replace all the words \"Hoshino\" with \"Hoshina\". You can assume that the number of characters in a text is less than or equal to 1000.\n\nInput\n\nThe input consists of several datasets. There will be the number of datasets n in the first line. There will be n lines. A line consisting of english texts will be given for each dataset.\n\nOutput\n\nFor each dataset, print the converted texts in a line.\n\nSample Input\n\n3\nHoshino\nHashino\nMasayuki Hoshino was the grandson of Ieyasu Tokugawa.\n\nOutput for the Sample Input\n\nHoshina\nHashino\nMasayuki Hoshina was the grandson of Ieyasu Tokugawa.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 61, "cpu_time_ms": 20, "memory_kb": 6100}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s956175475", "group_id": "codeNet:p00102", "input_text": "while (n=gets.to_i)!=0\n mat=Array.new(n+1){Array.new(n+1,0)}\n ans=Array.new(n+1){Array.new(n+1)}\n n.times.with_index do |id|\n mat[id]=gets.split.map(&:to_i)\n mat[id][n]=mat[id].inject(:+)\n (n+1).times.with_index do |id2|\n mat[n][id2]+=mat[id][id2]\n end\n end\n mat.each.with_index do |item,id|\n item.each.with_index do |ss,id2|\n ans[id][id2]=format(\"%5d\",ss)\n end\n end\n ans.each do |line|\n puts line.join(\" \")\n end\nend", "language": "Ruby", "metadata": {"date": 1478581932, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00102.html", "problem_id": "p00102", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00102/input.txt", "sample_output_relpath": "derived/input_output/data/p00102/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00102/Ruby/s956175475.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s956175475", "user_id": "u461552210"}, "prompt_components": {"gold_output": " 52 96 15 20 183\n 86 22 35 45 188\n 45 78 54 36 213\n 16 86 74 55 231\n 199 282 178 156 815\n 52 96 15 20 183\n 86 22 35 45 188\n 45 78 54 36 213\n 16 86 74 55 231\n 199 282 178 156 815\n", "input_to_evaluate": "while (n=gets.to_i)!=0\n mat=Array.new(n+1){Array.new(n+1,0)}\n ans=Array.new(n+1){Array.new(n+1)}\n n.times.with_index do |id|\n mat[id]=gets.split.map(&:to_i)\n mat[id][n]=mat[id].inject(:+)\n (n+1).times.with_index do |id2|\n mat[n][id2]+=mat[id][id2]\n end\n end\n mat.each.with_index do |item,id|\n item.each.with_index do |ss,id2|\n ans[id][id2]=format(\"%5d\",ss)\n end\n end\n ans.each do |line|\n puts line.join(\" \")\n end\nend", "problem_context": "Matrix-like Computation\n\nYour task is to develop a tiny little part of spreadsheet software.\n\nWrite a program which adds up columns and rows of given table as shown in the following figure:\n\nInput\n\nThe input consists of several datasets. Each dataset consists of:\n\nn (the size of row and column of the given table)\n1st row of the table\n2nd row of the table\n:\n:\nnth row of the table\n\nThe input ends with a line consisting of a single 0.\n\nOutput\n\nFor each dataset, print the table with sums of rows and columns. Each item of the table should be aligned to the right with a margin for five digits. Please see the sample output for details.\n\nSample Input\n\n4\n52 96 15 20\n86 22 35 45\n45 78 54 36\n16 86 74 55\n4\n52 96 15 20\n86 22 35 45\n45 78 54 36\n16 86 74 55\n0\n\nOutput for the Sample Input\n\n52 96 15 20 183\n86 22 35 45 188\n45 78 54 36 213\n16 86 74 55 231\n199 282 178 156 815\n52 96 15 20 183\n86 22 35 45 188\n45 78 54 36 213\n16 86 74 55 231\n199 282 178 156 815", "sample_input": "4\n52 96 15 20\n86 22 35 45\n45 78 54 36\n16 86 74 55\n4\n52 96 15 20\n86 22 35 45\n45 78 54 36\n16 86 74 55\n0\n"}, "reference_outputs": [" 52 96 15 20 183\n 86 22 35 45 188\n 45 78 54 36 213\n 16 86 74 55 231\n 199 282 178 156 815\n 52 96 15 20 183\n 86 22 35 45 188\n 45 78 54 36 213\n 16 86 74 55 231\n 199 282 178 156 815\n"], "source_document_id": "p00102", "source_text": "Matrix-like Computation\n\nYour task is to develop a tiny little part of spreadsheet software.\n\nWrite a program which adds up columns and rows of given table as shown in the following figure:\n\nInput\n\nThe input consists of several datasets. Each dataset consists of:\n\nn (the size of row and column of the given table)\n1st row of the table\n2nd row of the table\n:\n:\nnth row of the table\n\nThe input ends with a line consisting of a single 0.\n\nOutput\n\nFor each dataset, print the table with sums of rows and columns. Each item of the table should be aligned to the right with a margin for five digits. Please see the sample output for details.\n\nSample Input\n\n4\n52 96 15 20\n86 22 35 45\n45 78 54 36\n16 86 74 55\n4\n52 96 15 20\n86 22 35 45\n45 78 54 36\n16 86 74 55\n0\n\nOutput for the Sample Input\n\n52 96 15 20 183\n86 22 35 45 188\n45 78 54 36 213\n16 86 74 55 231\n199 282 178 156 815\n52 96 15 20 183\n86 22 35 45 188\n45 78 54 36 213\n16 86 74 55 231\n199 282 178 156 815", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 455, "cpu_time_ms": 40, "memory_kb": 8764}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s069758716", "group_id": "codeNet:p00103", "input_text": "class BaseBall\n def initialize\n @first=false\n @second=false\n @third=false\n @out=0\n end\n\n def hit\n if @third then\n point=1\n else\n point=0\n end\n @third = false\n @third = true if @second\n @second = true if @first\n @first = true\n return point\n end\n\n def homerun\n point= [@first,@second,@third].select{|x| x}.length + 1\n @first,@second,@third =false\n return point\n end\n\n def out\n @out += 1\n if @out>= 3 then\n @out=0\n return true\n else\n return false\n end\n end\nend\nif true then\n fh=STDIN\nelse\n fh=open(\"in0103.txt\")\nend\nn= fh.gets.chomp.to_i\n0.upto(n-1) { |i|\n point=0\n bb = BaseBall.new\n while fh.gets do\n s = $_.chomp\n if s==\"HIT\" then\n point += bb.hit\n elsif s==\"HOMERUN\" then\n point += bb.homerun\n elsif s==\"OUT\" then\n if bb.out then\n puts point\n break\n end\n end\n end\n}", "language": "Ruby", "metadata": {"date": 1465125688, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00103.html", "problem_id": "p00103", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00103/input.txt", "sample_output_relpath": "derived/input_output/data/p00103/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00103/Ruby/s069758716.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s069758716", "user_id": "u032662562"}, "prompt_components": {"gold_output": "7\n0\n", "input_to_evaluate": "class BaseBall\n def initialize\n @first=false\n @second=false\n @third=false\n @out=0\n end\n\n def hit\n if @third then\n point=1\n else\n point=0\n end\n @third = false\n @third = true if @second\n @second = true if @first\n @first = true\n return point\n end\n\n def homerun\n point= [@first,@second,@third].select{|x| x}.length + 1\n @first,@second,@third =false\n return point\n end\n\n def out\n @out += 1\n if @out>= 3 then\n @out=0\n return true\n else\n return false\n end\n end\nend\nif true then\n fh=STDIN\nelse\n fh=open(\"in0103.txt\")\nend\nn= fh.gets.chomp.to_i\n0.upto(n-1) { |i|\n point=0\n bb = BaseBall.new\n while fh.gets do\n s = $_.chomp\n if s==\"HIT\" then\n point += bb.hit\n elsif s==\"HOMERUN\" then\n point += bb.homerun\n elsif s==\"OUT\" then\n if bb.out then\n puts point\n break\n end\n end\n end\n}", "problem_context": "Baseball Simulation\n\nIchiro likes baseball and has decided to write a program which simulates baseball.\n\nThe program reads events in an inning and prints score in that inning. There are only three events as follows:\n\nSingle hit\n\nput a runner on the first base.\n\nthe runner in the first base advances to the second base and the runner in the second base advances to the third base.\n\nthe runner in the third base advances to the home base (and go out of base) and a point is added to the score.\n\nHome run\n\nall the runners on base advance to the home base.\n\npoints are added to the score by an amount equal to the number of the runners plus one.\n\nOut\n\nThe number of outs is increased by 1.\n\nThe runners and the score remain stationary.\n\nThe inning ends with three-out.\n\nIchiro decided to represent these events using \"HIT\", \"HOMERUN\" and \"OUT\", respectively.\n\nWrite a program which reads events in an inning and prints score in that inning. You can assume that the number of events is less than or equal to 100.\n\nInput\n\nThe input consists of several datasets. In the first line, the number of datasets n is given. Each dataset consists of a list of events (strings) in an inning.\n\nOutput\n\nFor each dataset, prints the score in the corresponding inning.\n\nSample Input\n\n2\nHIT\nOUT\nHOMERUN\nHIT\nHIT\nHOMERUN\nHIT\nOUT\nHIT\nHIT\nHIT\nHIT\nOUT\nHIT\nHIT\nOUT\nHIT\nOUT\nOUT\n\nOutput for the Sample Input\n\n7\n0", "sample_input": "2\nHIT\nOUT\nHOMERUN\nHIT\nHIT\nHOMERUN\nHIT\nOUT\nHIT\nHIT\nHIT\nHIT\nOUT\nHIT\nHIT\nOUT\nHIT\nOUT\nOUT\n"}, "reference_outputs": ["7\n0\n"], "source_document_id": "p00103", "source_text": "Baseball Simulation\n\nIchiro likes baseball and has decided to write a program which simulates baseball.\n\nThe program reads events in an inning and prints score in that inning. There are only three events as follows:\n\nSingle hit\n\nput a runner on the first base.\n\nthe runner in the first base advances to the second base and the runner in the second base advances to the third base.\n\nthe runner in the third base advances to the home base (and go out of base) and a point is added to the score.\n\nHome run\n\nall the runners on base advance to the home base.\n\npoints are added to the score by an amount equal to the number of the runners plus one.\n\nOut\n\nThe number of outs is increased by 1.\n\nThe runners and the score remain stationary.\n\nThe inning ends with three-out.\n\nIchiro decided to represent these events using \"HIT\", \"HOMERUN\" and \"OUT\", respectively.\n\nWrite a program which reads events in an inning and prints score in that inning. You can assume that the number of events is less than or equal to 100.\n\nInput\n\nThe input consists of several datasets. In the first line, the number of datasets n is given. Each dataset consists of a list of events (strings) in an inning.\n\nOutput\n\nFor each dataset, prints the score in the corresponding inning.\n\nSample Input\n\n2\nHIT\nOUT\nHOMERUN\nHIT\nHIT\nHOMERUN\nHIT\nOUT\nHIT\nHIT\nHIT\nHIT\nOUT\nHIT\nHIT\nOUT\nHIT\nOUT\nOUT\n\nOutput for the Sample Input\n\n7\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": 912, "cpu_time_ms": 40, "memory_kb": 8656}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s324552462", "group_id": "codeNet:p00103", "input_text": "left=gets.to_i\nout,runner,score=0,0,0\nwhile left>0\n judge=gets.chomp\n case judge\n when \"HIT\" then\n runner+=1\n if runner>3 then\n runner-=1\n score+=1\n end\n when \"OUT\" then\n out+=1\n if out>=3 then\n puts score\n runner,score=0,0\n left-=1\n end\n when \"HOMERUN\" then\n score+=(runner+1)\n runner=0\n end\nend", "language": "Ruby", "metadata": {"date": 1478584397, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00103.html", "problem_id": "p00103", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00103/input.txt", "sample_output_relpath": "derived/input_output/data/p00103/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00103/Ruby/s324552462.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s324552462", "user_id": "u461552210"}, "prompt_components": {"gold_output": "7\n0\n", "input_to_evaluate": "left=gets.to_i\nout,runner,score=0,0,0\nwhile left>0\n judge=gets.chomp\n case judge\n when \"HIT\" then\n runner+=1\n if runner>3 then\n runner-=1\n score+=1\n end\n when \"OUT\" then\n out+=1\n if out>=3 then\n puts score\n runner,score=0,0\n left-=1\n end\n when \"HOMERUN\" then\n score+=(runner+1)\n runner=0\n end\nend", "problem_context": "Baseball Simulation\n\nIchiro likes baseball and has decided to write a program which simulates baseball.\n\nThe program reads events in an inning and prints score in that inning. There are only three events as follows:\n\nSingle hit\n\nput a runner on the first base.\n\nthe runner in the first base advances to the second base and the runner in the second base advances to the third base.\n\nthe runner in the third base advances to the home base (and go out of base) and a point is added to the score.\n\nHome run\n\nall the runners on base advance to the home base.\n\npoints are added to the score by an amount equal to the number of the runners plus one.\n\nOut\n\nThe number of outs is increased by 1.\n\nThe runners and the score remain stationary.\n\nThe inning ends with three-out.\n\nIchiro decided to represent these events using \"HIT\", \"HOMERUN\" and \"OUT\", respectively.\n\nWrite a program which reads events in an inning and prints score in that inning. You can assume that the number of events is less than or equal to 100.\n\nInput\n\nThe input consists of several datasets. In the first line, the number of datasets n is given. Each dataset consists of a list of events (strings) in an inning.\n\nOutput\n\nFor each dataset, prints the score in the corresponding inning.\n\nSample Input\n\n2\nHIT\nOUT\nHOMERUN\nHIT\nHIT\nHOMERUN\nHIT\nOUT\nHIT\nHIT\nHIT\nHIT\nOUT\nHIT\nHIT\nOUT\nHIT\nOUT\nOUT\n\nOutput for the Sample Input\n\n7\n0", "sample_input": "2\nHIT\nOUT\nHOMERUN\nHIT\nHIT\nHOMERUN\nHIT\nOUT\nHIT\nHIT\nHIT\nHIT\nOUT\nHIT\nHIT\nOUT\nHIT\nOUT\nOUT\n"}, "reference_outputs": ["7\n0\n"], "source_document_id": "p00103", "source_text": "Baseball Simulation\n\nIchiro likes baseball and has decided to write a program which simulates baseball.\n\nThe program reads events in an inning and prints score in that inning. There are only three events as follows:\n\nSingle hit\n\nput a runner on the first base.\n\nthe runner in the first base advances to the second base and the runner in the second base advances to the third base.\n\nthe runner in the third base advances to the home base (and go out of base) and a point is added to the score.\n\nHome run\n\nall the runners on base advance to the home base.\n\npoints are added to the score by an amount equal to the number of the runners plus one.\n\nOut\n\nThe number of outs is increased by 1.\n\nThe runners and the score remain stationary.\n\nThe inning ends with three-out.\n\nIchiro decided to represent these events using \"HIT\", \"HOMERUN\" and \"OUT\", respectively.\n\nWrite a program which reads events in an inning and prints score in that inning. You can assume that the number of events is less than or equal to 100.\n\nInput\n\nThe input consists of several datasets. In the first line, the number of datasets n is given. Each dataset consists of a list of events (strings) in an inning.\n\nOutput\n\nFor each dataset, prints the score in the corresponding inning.\n\nSample Input\n\n2\nHIT\nOUT\nHOMERUN\nHIT\nHIT\nHOMERUN\nHIT\nOUT\nHIT\nHIT\nHIT\nHIT\nOUT\nHIT\nHIT\nOUT\nHIT\nOUT\nOUT\n\nOutput for the Sample Input\n\n7\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": 351, "cpu_time_ms": 60, "memory_kb": 8484}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s645772736", "group_id": "codeNet:p00103", "input_text": "$<.gets.to_i.times do\n\tpoint = 0\n\tout = 0\n\trunner = 0\n\n\twhile out < 3\n\t\tcase $<.gets.chomp\n\t\twhen 'HIT'\n\t\t\trunner == 3 ? point += 1 : runner += 1\n\t\twhen 'OUT'\n\t\t\tout += 1\n\t\twhen 'HOMERUN'\n\t\t\tpoint += runner + 1\n\t\t\trunner = 0\n\t\tend\n\tend\n\n\tp point\nend", "language": "Ruby", "metadata": {"date": 1389207480, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00103.html", "problem_id": "p00103", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00103/input.txt", "sample_output_relpath": "derived/input_output/data/p00103/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00103/Ruby/s645772736.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s645772736", "user_id": "u238839772"}, "prompt_components": {"gold_output": "7\n0\n", "input_to_evaluate": "$<.gets.to_i.times do\n\tpoint = 0\n\tout = 0\n\trunner = 0\n\n\twhile out < 3\n\t\tcase $<.gets.chomp\n\t\twhen 'HIT'\n\t\t\trunner == 3 ? point += 1 : runner += 1\n\t\twhen 'OUT'\n\t\t\tout += 1\n\t\twhen 'HOMERUN'\n\t\t\tpoint += runner + 1\n\t\t\trunner = 0\n\t\tend\n\tend\n\n\tp point\nend", "problem_context": "Baseball Simulation\n\nIchiro likes baseball and has decided to write a program which simulates baseball.\n\nThe program reads events in an inning and prints score in that inning. There are only three events as follows:\n\nSingle hit\n\nput a runner on the first base.\n\nthe runner in the first base advances to the second base and the runner in the second base advances to the third base.\n\nthe runner in the third base advances to the home base (and go out of base) and a point is added to the score.\n\nHome run\n\nall the runners on base advance to the home base.\n\npoints are added to the score by an amount equal to the number of the runners plus one.\n\nOut\n\nThe number of outs is increased by 1.\n\nThe runners and the score remain stationary.\n\nThe inning ends with three-out.\n\nIchiro decided to represent these events using \"HIT\", \"HOMERUN\" and \"OUT\", respectively.\n\nWrite a program which reads events in an inning and prints score in that inning. You can assume that the number of events is less than or equal to 100.\n\nInput\n\nThe input consists of several datasets. In the first line, the number of datasets n is given. Each dataset consists of a list of events (strings) in an inning.\n\nOutput\n\nFor each dataset, prints the score in the corresponding inning.\n\nSample Input\n\n2\nHIT\nOUT\nHOMERUN\nHIT\nHIT\nHOMERUN\nHIT\nOUT\nHIT\nHIT\nHIT\nHIT\nOUT\nHIT\nHIT\nOUT\nHIT\nOUT\nOUT\n\nOutput for the Sample Input\n\n7\n0", "sample_input": "2\nHIT\nOUT\nHOMERUN\nHIT\nHIT\nHOMERUN\nHIT\nOUT\nHIT\nHIT\nHIT\nHIT\nOUT\nHIT\nHIT\nOUT\nHIT\nOUT\nOUT\n"}, "reference_outputs": ["7\n0\n"], "source_document_id": "p00103", "source_text": "Baseball Simulation\n\nIchiro likes baseball and has decided to write a program which simulates baseball.\n\nThe program reads events in an inning and prints score in that inning. There are only three events as follows:\n\nSingle hit\n\nput a runner on the first base.\n\nthe runner in the first base advances to the second base and the runner in the second base advances to the third base.\n\nthe runner in the third base advances to the home base (and go out of base) and a point is added to the score.\n\nHome run\n\nall the runners on base advance to the home base.\n\npoints are added to the score by an amount equal to the number of the runners plus one.\n\nOut\n\nThe number of outs is increased by 1.\n\nThe runners and the score remain stationary.\n\nThe inning ends with three-out.\n\nIchiro decided to represent these events using \"HIT\", \"HOMERUN\" and \"OUT\", respectively.\n\nWrite a program which reads events in an inning and prints score in that inning. You can assume that the number of events is less than or equal to 100.\n\nInput\n\nThe input consists of several datasets. In the first line, the number of datasets n is given. Each dataset consists of a list of events (strings) in an inning.\n\nOutput\n\nFor each dataset, prints the score in the corresponding inning.\n\nSample Input\n\n2\nHIT\nOUT\nHOMERUN\nHIT\nHIT\nHOMERUN\nHIT\nOUT\nHIT\nHIT\nHIT\nHIT\nOUT\nHIT\nHIT\nOUT\nHIT\nOUT\nOUT\n\nOutput for the Sample Input\n\n7\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": 249, "cpu_time_ms": 20, "memory_kb": 6092}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s722576674", "group_id": "codeNet:p00109", "input_text": "gets;$<.each_line.map{|s|p eval(s[0..-3])}", "language": "Ruby", "metadata": {"date": 1418908369, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00109.html", "problem_id": "p00109", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00109/input.txt", "sample_output_relpath": "derived/input_output/data/p00109/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00109/Ruby/s722576674.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s722576674", "user_id": "u525048109"}, "prompt_components": {"gold_output": "-2\n60\n", "input_to_evaluate": "gets;$<.each_line.map{|s|p eval(s[0..-3])}", "problem_context": "Smart Calculator\n\nYour task is to write a program which reads an expression and evaluates it.\n\nThe expression consists of numerical values, operators and parentheses, and the ends with '='.\n\nThe operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division.\n\nPrecedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right.\n\nYou may assume that there is no division by zero.\n\nAll calculation is performed as integers, and after the decimal point should be truncated\n\nLength of the expression will not exceed 100.\n\n-1 × 109 ≤ intermediate results of computation ≤ 109\n\nInput\n\nThe input is a sequence of datasets. The first line contains an integer n which represents the number of datasets. There will be n lines where each line contains an expression.\n\nOutput\n\nFor each datasets, prints the result of calculation.\n\nSample Input\n\n2\n4-2*3=\n4*(8+4+3)=\n\nOutput for the Sample Input\n\n-2\n60", "sample_input": "2\n4-2*3=\n4*(8+4+3)=\n"}, "reference_outputs": ["-2\n60\n"], "source_document_id": "p00109", "source_text": "Smart Calculator\n\nYour task is to write a program which reads an expression and evaluates it.\n\nThe expression consists of numerical values, operators and parentheses, and the ends with '='.\n\nThe operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division.\n\nPrecedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right.\n\nYou may assume that there is no division by zero.\n\nAll calculation is performed as integers, and after the decimal point should be truncated\n\nLength of the expression will not exceed 100.\n\n-1 × 109 ≤ intermediate results of computation ≤ 109\n\nInput\n\nThe input is a sequence of datasets. The first line contains an integer n which represents the number of datasets. There will be n lines where each line contains an expression.\n\nOutput\n\nFor each datasets, prints the result of calculation.\n\nSample Input\n\n2\n4-2*3=\n4*(8+4+3)=\n\nOutput for the Sample Input\n\n-2\n60", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 42, "cpu_time_ms": 20, "memory_kb": 6132}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s376312444", "group_id": "codeNet:p00109", "input_text": "gets.to_i.times { p eval gets[0..-3] }", "language": "Ruby", "metadata": {"date": 1445006910, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00109.html", "problem_id": "p00109", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00109/input.txt", "sample_output_relpath": "derived/input_output/data/p00109/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00109/Ruby/s376312444.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s376312444", "user_id": "u797180951"}, "prompt_components": {"gold_output": "-2\n60\n", "input_to_evaluate": "gets.to_i.times { p eval gets[0..-3] }", "problem_context": "Smart Calculator\n\nYour task is to write a program which reads an expression and evaluates it.\n\nThe expression consists of numerical values, operators and parentheses, and the ends with '='.\n\nThe operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division.\n\nPrecedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right.\n\nYou may assume that there is no division by zero.\n\nAll calculation is performed as integers, and after the decimal point should be truncated\n\nLength of the expression will not exceed 100.\n\n-1 × 109 ≤ intermediate results of computation ≤ 109\n\nInput\n\nThe input is a sequence of datasets. The first line contains an integer n which represents the number of datasets. There will be n lines where each line contains an expression.\n\nOutput\n\nFor each datasets, prints the result of calculation.\n\nSample Input\n\n2\n4-2*3=\n4*(8+4+3)=\n\nOutput for the Sample Input\n\n-2\n60", "sample_input": "2\n4-2*3=\n4*(8+4+3)=\n"}, "reference_outputs": ["-2\n60\n"], "source_document_id": "p00109", "source_text": "Smart Calculator\n\nYour task is to write a program which reads an expression and evaluates it.\n\nThe expression consists of numerical values, operators and parentheses, and the ends with '='.\n\nThe operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division.\n\nPrecedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right.\n\nYou may assume that there is no division by zero.\n\nAll calculation is performed as integers, and after the decimal point should be truncated\n\nLength of the expression will not exceed 100.\n\n-1 × 109 ≤ intermediate results of computation ≤ 109\n\nInput\n\nThe input is a sequence of datasets. The first line contains an integer n which represents the number of datasets. There will be n lines where each line contains an expression.\n\nOutput\n\nFor each datasets, prints the result of calculation.\n\nSample Input\n\n2\n4-2*3=\n4*(8+4+3)=\n\nOutput for the Sample Input\n\n-2\n60", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 38, "cpu_time_ms": 40, "memory_kb": 8672}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s008361093", "group_id": "codeNet:p00109", "input_text": "class Hoge\n def / (x)\n y = self.to_f.fdiv(x)\n if y < 0.0\n y = y.ceil\n else\n y = y.floor\n end\n y\n end\nend\n \n \nwhile n = gets.to_i\n\tn.times{\n \tputs eval(gets.chomp.chop)\n\t}\nend", "language": "Ruby", "metadata": {"date": 1494248753, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00109.html", "problem_id": "p00109", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00109/input.txt", "sample_output_relpath": "derived/input_output/data/p00109/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00109/Ruby/s008361093.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s008361093", "user_id": "u534464795"}, "prompt_components": {"gold_output": "-2\n60\n", "input_to_evaluate": "class Hoge\n def / (x)\n y = self.to_f.fdiv(x)\n if y < 0.0\n y = y.ceil\n else\n y = y.floor\n end\n y\n end\nend\n \n \nwhile n = gets.to_i\n\tn.times{\n \tputs eval(gets.chomp.chop)\n\t}\nend", "problem_context": "Smart Calculator\n\nYour task is to write a program which reads an expression and evaluates it.\n\nThe expression consists of numerical values, operators and parentheses, and the ends with '='.\n\nThe operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division.\n\nPrecedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right.\n\nYou may assume that there is no division by zero.\n\nAll calculation is performed as integers, and after the decimal point should be truncated\n\nLength of the expression will not exceed 100.\n\n-1 × 109 ≤ intermediate results of computation ≤ 109\n\nInput\n\nThe input is a sequence of datasets. The first line contains an integer n which represents the number of datasets. There will be n lines where each line contains an expression.\n\nOutput\n\nFor each datasets, prints the result of calculation.\n\nSample Input\n\n2\n4-2*3=\n4*(8+4+3)=\n\nOutput for the Sample Input\n\n-2\n60", "sample_input": "2\n4-2*3=\n4*(8+4+3)=\n"}, "reference_outputs": ["-2\n60\n"], "source_document_id": "p00109", "source_text": "Smart Calculator\n\nYour task is to write a program which reads an expression and evaluates it.\n\nThe expression consists of numerical values, operators and parentheses, and the ends with '='.\n\nThe operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division.\n\nPrecedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right.\n\nYou may assume that there is no division by zero.\n\nAll calculation is performed as integers, and after the decimal point should be truncated\n\nLength of the expression will not exceed 100.\n\n-1 × 109 ≤ intermediate results of computation ≤ 109\n\nInput\n\nThe input is a sequence of datasets. The first line contains an integer n which represents the number of datasets. There will be n lines where each line contains an expression.\n\nOutput\n\nFor each datasets, prints the result of calculation.\n\nSample Input\n\n2\n4-2*3=\n4*(8+4+3)=\n\nOutput for the Sample Input\n\n-2\n60", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 204, "cpu_time_ms": 40000, "memory_kb": 8680}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s069104095", "group_id": "codeNet:p00109", "input_text": "gets;$<.map{|s|p eval s[0..-3]}", "language": "Ruby", "metadata": {"date": 1500210760, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00109.html", "problem_id": "p00109", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00109/input.txt", "sample_output_relpath": "derived/input_output/data/p00109/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00109/Ruby/s069104095.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s069104095", "user_id": "u868447400"}, "prompt_components": {"gold_output": "-2\n60\n", "input_to_evaluate": "gets;$<.map{|s|p eval s[0..-3]}", "problem_context": "Smart Calculator\n\nYour task is to write a program which reads an expression and evaluates it.\n\nThe expression consists of numerical values, operators and parentheses, and the ends with '='.\n\nThe operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division.\n\nPrecedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right.\n\nYou may assume that there is no division by zero.\n\nAll calculation is performed as integers, and after the decimal point should be truncated\n\nLength of the expression will not exceed 100.\n\n-1 × 109 ≤ intermediate results of computation ≤ 109\n\nInput\n\nThe input is a sequence of datasets. The first line contains an integer n which represents the number of datasets. There will be n lines where each line contains an expression.\n\nOutput\n\nFor each datasets, prints the result of calculation.\n\nSample Input\n\n2\n4-2*3=\n4*(8+4+3)=\n\nOutput for the Sample Input\n\n-2\n60", "sample_input": "2\n4-2*3=\n4*(8+4+3)=\n"}, "reference_outputs": ["-2\n60\n"], "source_document_id": "p00109", "source_text": "Smart Calculator\n\nYour task is to write a program which reads an expression and evaluates it.\n\nThe expression consists of numerical values, operators and parentheses, and the ends with '='.\n\nThe operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division.\n\nPrecedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right.\n\nYou may assume that there is no division by zero.\n\nAll calculation is performed as integers, and after the decimal point should be truncated\n\nLength of the expression will not exceed 100.\n\n-1 × 109 ≤ intermediate results of computation ≤ 109\n\nInput\n\nThe input is a sequence of datasets. The first line contains an integer n which represents the number of datasets. There will be n lines where each line contains an expression.\n\nOutput\n\nFor each datasets, prints the result of calculation.\n\nSample Input\n\n2\n4-2*3=\n4*(8+4+3)=\n\nOutput for the Sample Input\n\n-2\n60", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 31, "cpu_time_ms": 30, "memory_kb": 8644}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s080522951", "group_id": "codeNet:p00112", "input_text": "if true then\n fh=STDIN\nelse\n fh=open(\"in1_0112.txt\")\nend\nn=-999\n\nwhile fh.gets do\n n=$_.chomp.to_i\n break if n==0\n f=[]\n 0.upto(n-1){|i| f[i]=fh.gets.chomp.to_i}\n\n g=f.sort\n acc=0\n h=g.map{|x|\n acc0=acc\n acc+=x\n acc0}\n puts h.inject(0){|acc,x| acc+x}\nend\nabort(\"input strange\") if n!=0", "language": "Ruby", "metadata": {"date": 1466027937, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s080522951.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s080522951", "user_id": "u032662562"}, "prompt_components": {"gold_output": "31\n", "input_to_evaluate": "if true then\n fh=STDIN\nelse\n fh=open(\"in1_0112.txt\")\nend\nn=-999\n\nwhile fh.gets do\n n=$_.chomp.to_i\n break if n==0\n f=[]\n 0.upto(n-1){|i| f[i]=fh.gets.chomp.to_i}\n\n g=f.sort\n acc=0\n h=g.map{|x|\n acc0=acc\n acc+=x\n acc0}\n puts h.inject(0){|acc,x| acc+x}\nend\nabort(\"input strange\") if n!=0", "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": 304, "cpu_time_ms": 40, "memory_kb": 9180}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s197658131", "group_id": "codeNet:p00124", "input_text": "loop do\n n = gets.to_i\n break if n.zero?\n teams = {}\n \n n.times do\n team_and_score = gets.chomp.split\n team = team_and_score.first\n wld = team_and_score[1..-1].map(&:to_i)\n score = 3*wld[0] + wld[2]\n if teams[score].nil?\n teams[score] = [team]\n else\n teams[score] << team\n end\n end\n\n teams.sort.reverse.each do |score_teams|\n s = score_teams.first\n score_teams.last.each{ |t| puts \"#{t},#{s}\"}\n end\nend", "language": "Ruby", "metadata": {"date": 1373811801, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00124.html", "problem_id": "p00124", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00124/input.txt", "sample_output_relpath": "derived/input_output/data/p00124/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00124/Ruby/s197658131.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s197658131", "user_id": "u881491942"}, "prompt_components": {"gold_output": "Spain,7\nJapan,5\nEgypt,3\nCanada,1\n\nPoland,4\nItaly,4\nIndia,0\n", "input_to_evaluate": "loop do\n n = gets.to_i\n break if n.zero?\n teams = {}\n \n n.times do\n team_and_score = gets.chomp.split\n team = team_and_score.first\n wld = team_and_score[1..-1].map(&:to_i)\n score = 3*wld[0] + wld[2]\n if teams[score].nil?\n teams[score] = [team]\n else\n teams[score] << team\n end\n end\n\n teams.sort.reverse.each do |score_teams|\n s = score_teams.first\n score_teams.last.each{ |t| puts \"#{t},#{s}\"}\n end\nend", "problem_context": "リーグ戦のスコアシート\n\nスポーツの大会にはリーグ戦とトーナメント戦があります。サッカーのリーグ戦では勝・負・引分にそれぞれ点数を付け、その勝ち点で順位を競います。勝ち点はそれぞれ勝(3点)、負(0点)、引分(1点)です。\n\nチーム数とリーグ戦の成績を入力とし、成績の良い順(勝ち点の多い順)に並べ替え、チーム名と勝ち点を出力するプログラムを作成してください。勝ち点が同点の場合は入力順に出力してください。\n\nInput\n\n複数のデータセットが与えられます。各データセットは以下の形式で与えられます。\n\nn\nname1 w1 l1 d1\nname2 w2 l2 d2\n:\nnamen wn ln dn\n\n1行目にチーム数 n (n ≤ 10) が与えられます。続く n 行にチーム i の名前 namei (20文字以内のアルファベット)、勝の数 wi、負の数 li、引分の数 di (0 ≤ wi, li, di ≤ 9) が空白区切りで与えられます。\n\nチーム数が 0 のとき、入力の終了とします。データセットの数は 50 を超えません。\n\nOutput\n\nデータセットごとに、並べ替えたチームのリストを出力してください。i 行目に i 番目のチームの名前と勝ち点をカンマで区切って出力してください。\n\nデータセットの間に1つの空行を入れてください。\n\nSample Input\n\n4\nJapan 1 0 2\nEgypt 1 2 0\nCanada 0 2 1\nSpain 2 0 1\n3\nIndia 0 2 0\nPoland 1 0 1\nItaly 1 0 1\n0\n\nOutput for the Sample Input\n\nSpain,7\nJapan,5\nEgypt,3\nCanada,1\n\nPoland,4\nItaly,4\nIndia,0", "sample_input": "4\nJapan 1 0 2\nEgypt 1 2 0\nCanada 0 2 1\nSpain 2 0 1\n3\nIndia 0 2 0\nPoland 1 0 1\nItaly 1 0 1\n0\n"}, "reference_outputs": ["Spain,7\nJapan,5\nEgypt,3\nCanada,1\n\nPoland,4\nItaly,4\nIndia,0\n"], "source_document_id": "p00124", "source_text": "リーグ戦のスコアシート\n\nスポーツの大会にはリーグ戦とトーナメント戦があります。サッカーのリーグ戦では勝・負・引分にそれぞれ点数を付け、その勝ち点で順位を競います。勝ち点はそれぞれ勝(3点)、負(0点)、引分(1点)です。\n\nチーム数とリーグ戦の成績を入力とし、成績の良い順(勝ち点の多い順)に並べ替え、チーム名と勝ち点を出力するプログラムを作成してください。勝ち点が同点の場合は入力順に出力してください。\n\nInput\n\n複数のデータセットが与えられます。各データセットは以下の形式で与えられます。\n\nn\nname1 w1 l1 d1\nname2 w2 l2 d2\n:\nnamen wn ln dn\n\n1行目にチーム数 n (n ≤ 10) が与えられます。続く n 行にチーム i の名前 namei (20文字以内のアルファベット)、勝の数 wi、負の数 li、引分の数 di (0 ≤ wi, li, di ≤ 9) が空白区切りで与えられます。\n\nチーム数が 0 のとき、入力の終了とします。データセットの数は 50 を超えません。\n\nOutput\n\nデータセットごとに、並べ替えたチームのリストを出力してください。i 行目に i 番目のチームの名前と勝ち点をカンマで区切って出力してください。\n\nデータセットの間に1つの空行を入れてください。\n\nSample Input\n\n4\nJapan 1 0 2\nEgypt 1 2 0\nCanada 0 2 1\nSpain 2 0 1\n3\nIndia 0 2 0\nPoland 1 0 1\nItaly 1 0 1\n0\n\nOutput for the Sample Input\n\nSpain,7\nJapan,5\nEgypt,3\nCanada,1\n\nPoland,4\nItaly,4\nIndia,0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 447, "cpu_time_ms": 20, "memory_kb": 6120}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s874114865", "group_id": "codeNet:p00149", "input_text": "$eye_data = [[0, 0, 0, 0], [0, 0, 0, 0]]\n\ndef check(vision, lr)\n case\n when 1.1 <= vision\n $eye_data[lr][0] += 1\n when 0.6 <= vision\n $eye_data[lr][1] += 1\n when 0.2 <= vision\n $eye_data[lr][2] += 1\n else\n $eye_data[lr][3] += 1\n end\nend\n\nreadlines.each do |line|\n l, r = line.chomp.split.map(&:to_f)\n check(l, 0)\n check(r, 1)\nend\n\n0.upto(3) do |i|\n puts \"#{$eye_data[0][i]} #{$eye_data[1][i]}\"\nend", "language": "Ruby", "metadata": {"date": 1373290598, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00149.html", "problem_id": "p00149", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00149/input.txt", "sample_output_relpath": "derived/input_output/data/p00149/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00149/Ruby/s874114865.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s874114865", "user_id": "u881491942"}, "prompt_components": {"gold_output": "2 3\n2 1\n0 0\n0 0\n", "input_to_evaluate": "$eye_data = [[0, 0, 0, 0], [0, 0, 0, 0]]\n\ndef check(vision, lr)\n case\n when 1.1 <= vision\n $eye_data[lr][0] += 1\n when 0.6 <= vision\n $eye_data[lr][1] += 1\n when 0.2 <= vision\n $eye_data[lr][2] += 1\n else\n $eye_data[lr][3] += 1\n end\nend\n\nreadlines.each do |line|\n l, r = line.chomp.split.map(&:to_f)\n check(l, 0)\n check(r, 1)\nend\n\n0.upto(3) do |i|\n puts \"#{$eye_data[0][i]} #{$eye_data[1][i]}\"\nend", "problem_context": "視力検査\n\n視力検査の検査結果データを入力とし、下記の視力判定表に基づいて各判定に当てはまる人数を、左右の視力別に出力するプログラムを作成してください。\n\n判定\n\n視力\n\nA\n\n1.1 以上\n\nB\n\n0.6 以上 1.1 未満\n\nC\n\n0.2 以上 0.6 未満\n\nD\n\n0.2 未満\n\nInput\n\n入力は以下の形式で与えられます。\n\nl1 r1\nl2 r2\nl3 r3\n:\n:\n\ni 行目に i 人目の左の視力を表す実数 li と右の視力を表す実数 ri が空白区切りで与えられます。ただし、視力は 0.1 以上 2.0 以下で、 0.1 刻みで与えられます。\n\n入力の行数は 40 を超えません。\n\nOutput\n\n以下の形式で、判定表を出力してください。\n\n1行目 左の視力がAの人数 右の視力がAの人数(空白区切り)\n\n2行目 左の視力がBの人数 右の視力がBの人数(空白区切り)\n\n3行目 左の視力がCの人数 右の視力がCの人数(空白区切り)\n\n4行目 左の視力がDの人数 右の視力がDの人数(空白区切り)\n\nSample Input\n\n1.0 1.2\n0.8 1.5\n1.2 0.7\n2.0 2.0\n\nOutput for the Sample Input\n\n2 3\n2 1\n0 0\n0 0", "sample_input": "1.0 1.2\n0.8 1.5\n1.2 0.7\n2.0 2.0\n"}, "reference_outputs": ["2 3\n2 1\n0 0\n0 0\n"], "source_document_id": "p00149", "source_text": "視力検査\n\n視力検査の検査結果データを入力とし、下記の視力判定表に基づいて各判定に当てはまる人数を、左右の視力別に出力するプログラムを作成してください。\n\n判定\n\n視力\n\nA\n\n1.1 以上\n\nB\n\n0.6 以上 1.1 未満\n\nC\n\n0.2 以上 0.6 未満\n\nD\n\n0.2 未満\n\nInput\n\n入力は以下の形式で与えられます。\n\nl1 r1\nl2 r2\nl3 r3\n:\n:\n\ni 行目に i 人目の左の視力を表す実数 li と右の視力を表す実数 ri が空白区切りで与えられます。ただし、視力は 0.1 以上 2.0 以下で、 0.1 刻みで与えられます。\n\n入力の行数は 40 を超えません。\n\nOutput\n\n以下の形式で、判定表を出力してください。\n\n1行目 左の視力がAの人数 右の視力がAの人数(空白区切り)\n\n2行目 左の視力がBの人数 右の視力がBの人数(空白区切り)\n\n3行目 左の視力がCの人数 右の視力がCの人数(空白区切り)\n\n4行目 左の視力がDの人数 右の視力がDの人数(空白区切り)\n\nSample Input\n\n1.0 1.2\n0.8 1.5\n1.2 0.7\n2.0 2.0\n\nOutput for the Sample Input\n\n2 3\n2 1\n0 0\n0 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 10, "memory_kb": 6108}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s492721843", "group_id": "codeNet:p00152", "input_text": "loop do\n m = gets.to_i\n break if m.zero?\n m.times.map do\n id, *ss = gets.split.map(&:to_i)\n s, i = 0, 0\n 10.times do |j|\n if ss[i] == 10\n s += ss[i] + ss[i+1] + ss[i+2]\n i += 1\n elsif ss[i] + ss[i+1] == 10\n s += ss[i] + ss[i+1] + ss[i+2]\n i += 2\n else\n s += ss[i] + ss[i+1]\n i += 2\n end\n end\n [-s, id]\n end.sort!.each {|s, id| puts \"#{id.to_i} #{-s}\" }\nend", "language": "Ruby", "metadata": {"date": 1509126764, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00152.html", "problem_id": "p00152", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00152/input.txt", "sample_output_relpath": "derived/input_output/data/p00152/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00152/Ruby/s492721843.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s492721843", "user_id": "u006169802"}, "prompt_components": {"gold_output": "1200 127\n1010 123\n1101 60\n3335 300\n3321 200\n3340 175\n3332 122\n", "input_to_evaluate": "loop do\n m = gets.to_i\n break if m.zero?\n m.times.map do\n id, *ss = gets.split.map(&:to_i)\n s, i = 0, 0\n 10.times do |j|\n if ss[i] == 10\n s += ss[i] + ss[i+1] + ss[i+2]\n i += 1\n elsif ss[i] + ss[i+1] == 10\n s += ss[i] + ss[i+1] + ss[i+2]\n i += 2\n else\n s += ss[i] + ss[i+1]\n i += 2\n end\n end\n [-s, id]\n end.sort!.each {|s, id| puts \"#{id.to_i} #{-s}\" }\nend", "problem_context": "ボウリング\n\nクラスのレクリエーションとしてボウリングを行うことになりました。参加者ごとの投球情報を入力とし、得点の高い順に成績情報を出力するプログラムを作成してください。なお、同点の場合は学籍番号の若い順に出力してください。ただし参加者は 3 名以上 40 名以下とし、1人当たり1ゲームずつ投球しているものとします。\n\nボウリングとは、プレイヤーに対して頂点を向けて正三角形に並べられた、10 本のピンをめがけてボールを転がし、ピンを倒すスポーツです。 1 回目の投球ですべて転倒した場合をストライクと言い、その投球のみで次のフレームに進みます。ストライクでない場合は、残ったピンをそのままにして 2 回目の投球を行います。2 回目の投球ですべて転倒した場合をスペアと言います。2 回目の投球終了後、次のフレームに進みます。\n\n1 ゲームは 10 のフレームから構成され、第 1 から第 9 の各フレームは 2 回投球できます。各フレームの開始時点では、10 本のピンがすべて立った状態で用意されます。第 10 フレームは、ストライクもしくはスペアが出た場合には計 3 回の投球を、それ以外の場合は 2 回の投球を行い、ゲーム終了となります。\n\nスコア例1\n\nスコア例2(最高得点300点の場合)\n\nスコア計算の方法\n\n各フレームにおいてスペア、ストライクがない場合は、 2 回の投球で倒したピンの本数がそのフレームの得点となります。(スコア例1の第 4 フレームと第 8 フレーム)\n\nスペアを出した場合、倒した本数である 10 点に加え、次の投球で倒したピンの本数がこのフレームの得点に加算されます。(スコア例1の第 1 フレームと第 2 フレームの関係など)スコア例1の第 1 フレームでは第 2 フレームの 1 投で倒した 10 本(点)を加えた 20 点が得点となります。第 3 フレームも同様の計算方法です。\n\nストライクを出した場合、倒した本数である 10 点に加え、続く 2 回の投球で倒したピンの本数が加算されます。(スコア例1の第 2 フレームと第 3 フレームの関係など)もちろん続く 2 投中にストライクの場合があります。(スコア例1の第 5 フレームと第 6、7 フレームの関係など)\n\n第 10 フレームのみ、スペア、ストライクを出した場合、3 投して倒したピンの総数が第 10 フレームの得点として加算されます。\n\n各フレームの得点の合計が 1 ゲームの得点となり、最高得点は 300 点となります。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nm\nscore1\nscore2\n:\nscorem\n\n1行目に参加者数 m (3 ≤ m ≤ 40)、続くm 行にi 人目の参加者情報 scorei が与えられます。各参加者情報は1行ずつ次の形式で与えられます。\n\nid s1 s2 ... sn\n\n先頭に学籍番号id (0 ≤ id ≤ 9999)、続いて第 j 投の転倒ピン数 sj (0 ≤ sj ≤ 10) が与えられます。総投球数 n は、12 以上 21 以下であり、得点計算に必要なピン数が過不足なく与えられるものとします。\n\nOutput\n\n入力データセットごとに、学籍番号と得点を、得点の高い順(同点の場合は学籍番号の若い順)に出力します。学籍番号と得点を1つの空白で区切って1行に出力してください。\n\nSample Input\n\n3\n1010 6 3 10 7 1 0 7 9 1 10 6 2 4 3 9 1 9 0\n1200 5 3 9 1 7 1 0 0 8 1 10 10 4 3 9 1 8 2 9\n1101 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3\n4\n3321 8 2 10 9 1 7 0 10 10 10 0 8 10 10 10 10\n3332 5 0 10 9 1 4 1 9 0 10 10 7 1 5 2 8 1\n3335 10 10 10 10 10 10 10 10 10 10 10 10\n3340 8 2 7 3 6 4 8 2 8 2 9 1 7 3 6 4 8 2 9 1 7\n0\n\nOutput for the Sample Input\n\n1200 127\n1010 123\n1101 60\n3335 300\n3321 200\n3340 175\n3332 122", "sample_input": "3\n1010 6 3 10 7 1 0 7 9 1 10 6 2 4 3 9 1 9 0\n1200 5 3 9 1 7 1 0 0 8 1 10 10 4 3 9 1 8 2 9\n1101 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3\n4\n3321 8 2 10 9 1 7 0 10 10 10 0 8 10 10 10 10\n3332 5 0 10 9 1 4 1 9 0 10 10 7 1 5 2 8 1\n3335 10 10 10 10 10 10 10 10 10 10 10 10\n3340 8 2 7 3 6 4 8 2 8 2 9 1 7 3 6 4 8 2 9 1 7\n0\n"}, "reference_outputs": ["1200 127\n1010 123\n1101 60\n3335 300\n3321 200\n3340 175\n3332 122\n"], "source_document_id": "p00152", "source_text": "ボウリング\n\nクラスのレクリエーションとしてボウリングを行うことになりました。参加者ごとの投球情報を入力とし、得点の高い順に成績情報を出力するプログラムを作成してください。なお、同点の場合は学籍番号の若い順に出力してください。ただし参加者は 3 名以上 40 名以下とし、1人当たり1ゲームずつ投球しているものとします。\n\nボウリングとは、プレイヤーに対して頂点を向けて正三角形に並べられた、10 本のピンをめがけてボールを転がし、ピンを倒すスポーツです。 1 回目の投球ですべて転倒した場合をストライクと言い、その投球のみで次のフレームに進みます。ストライクでない場合は、残ったピンをそのままにして 2 回目の投球を行います。2 回目の投球ですべて転倒した場合をスペアと言います。2 回目の投球終了後、次のフレームに進みます。\n\n1 ゲームは 10 のフレームから構成され、第 1 から第 9 の各フレームは 2 回投球できます。各フレームの開始時点では、10 本のピンがすべて立った状態で用意されます。第 10 フレームは、ストライクもしくはスペアが出た場合には計 3 回の投球を、それ以外の場合は 2 回の投球を行い、ゲーム終了となります。\n\nスコア例1\n\nスコア例2(最高得点300点の場合)\n\nスコア計算の方法\n\n各フレームにおいてスペア、ストライクがない場合は、 2 回の投球で倒したピンの本数がそのフレームの得点となります。(スコア例1の第 4 フレームと第 8 フレーム)\n\nスペアを出した場合、倒した本数である 10 点に加え、次の投球で倒したピンの本数がこのフレームの得点に加算されます。(スコア例1の第 1 フレームと第 2 フレームの関係など)スコア例1の第 1 フレームでは第 2 フレームの 1 投で倒した 10 本(点)を加えた 20 点が得点となります。第 3 フレームも同様の計算方法です。\n\nストライクを出した場合、倒した本数である 10 点に加え、続く 2 回の投球で倒したピンの本数が加算されます。(スコア例1の第 2 フレームと第 3 フレームの関係など)もちろん続く 2 投中にストライクの場合があります。(スコア例1の第 5 フレームと第 6、7 フレームの関係など)\n\n第 10 フレームのみ、スペア、ストライクを出した場合、3 投して倒したピンの総数が第 10 フレームの得点として加算されます。\n\n各フレームの得点の合計が 1 ゲームの得点となり、最高得点は 300 点となります。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nm\nscore1\nscore2\n:\nscorem\n\n1行目に参加者数 m (3 ≤ m ≤ 40)、続くm 行にi 人目の参加者情報 scorei が与えられます。各参加者情報は1行ずつ次の形式で与えられます。\n\nid s1 s2 ... sn\n\n先頭に学籍番号id (0 ≤ id ≤ 9999)、続いて第 j 投の転倒ピン数 sj (0 ≤ sj ≤ 10) が与えられます。総投球数 n は、12 以上 21 以下であり、得点計算に必要なピン数が過不足なく与えられるものとします。\n\nOutput\n\n入力データセットごとに、学籍番号と得点を、得点の高い順(同点の場合は学籍番号の若い順)に出力します。学籍番号と得点を1つの空白で区切って1行に出力してください。\n\nSample Input\n\n3\n1010 6 3 10 7 1 0 7 9 1 10 6 2 4 3 9 1 9 0\n1200 5 3 9 1 7 1 0 0 8 1 10 10 4 3 9 1 8 2 9\n1101 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3\n4\n3321 8 2 10 9 1 7 0 10 10 10 0 8 10 10 10 10\n3332 5 0 10 9 1 4 1 9 0 10 10 7 1 5 2 8 1\n3335 10 10 10 10 10 10 10 10 10 10 10 10\n3340 8 2 7 3 6 4 8 2 8 2 9 1 7 3 6 4 8 2 9 1 7\n0\n\nOutput for the Sample Input\n\n1200 127\n1010 123\n1101 60\n3335 300\n3321 200\n3340 175\n3332 122", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 437, "cpu_time_ms": 40, "memory_kb": 8868}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s737125421", "group_id": "codeNet:p00197", "input_text": "def gcd a,b\n res = 0\n while b!=0\n res+=1\n a,b=b,a%b\n end\n [a,res]\nend\n\nloop do\n a,b=gets.chomp.split.map{|x| x.to_i }\n break if a|b==0\n puts (gcd a,b).join(' ')\nend", "language": "Ruby", "metadata": {"date": 1405493078, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00197.html", "problem_id": "p00197", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00197/input.txt", "sample_output_relpath": "derived/input_output/data/p00197/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00197/Ruby/s737125421.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s737125421", "user_id": "u553881259"}, "prompt_components": {"gold_output": "21 3\n5 1\n", "input_to_evaluate": "def gcd a,b\n res = 0\n while b!=0\n res+=1\n a,b=b,a%b\n end\n [a,res]\nend\n\nloop do\n a,b=gets.chomp.split.map{|x| x.to_i }\n break if a|b==0\n puts (gcd a,b).join(' ')\nend", "problem_context": "最大公約数-ユークリッドの互除法\n\n最大公約数は、コンピュータ上で扱う数学には欠かせない要素です。最大公約 数を使うことで、計算の効率が大きく変動することもあります。最大公約数を求めるアルゴリズムのひとつが「ユークリッドの互除法」です。その処理 の流れを以下に示します。\n\n例えば 1071 と 1029 の場合、1071 を X 、1029 を Y に代入して、\n\n       1071 ÷ 1029 の余りは 42 、X に 42 を代入して X と Y を入れ替える。 (1 ステップ)\n\n       1029 ÷ 42 の余りは 21 、X に 21 を代入して X と Y を入れ替える。 (2 ステップ)\n\n       42 ÷ 21 の余りは 0 、X に 0 を代入して X と Y を入れ替える。 (3 ステップ)\n\nY が 0 になったので、この時の X が最大公約数となる。よって最大公約数は 21 。\n\nこのように、たったの 3 ステップで 1071 と 1029 の最大公約数を求めることが出来ました。ユークリッドの互除法は約数を出して比較していく方法に比べ、圧倒的に早く結果を出してくれます。\n\n2つの整数を入力とし、ユークリッドの互除法を用いて最大公約数を求め、その最大公約数と計算にかかったステップ数を出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロふたつの行で示されます。\n各データセットとして2つの整数 a, b (2 ≤ a, b ≤ 231-1) が1行に与えられます。\n\nデータセットの数は 1000 を超えません。\n\nOutput\n\nデータセットごとに、入力された2つの整数の最大公約数と、計算にかかったユークリッドの互除法のステップ数を空白区切りで1行に出力します。\n\nSample Input\n\n1071 1029\n5 5\n0 0\n\nOutput for the Sample Input\n\n21 3\n5 1", "sample_input": "1071 1029\n5 5\n0 0\n"}, "reference_outputs": ["21 3\n5 1\n"], "source_document_id": "p00197", "source_text": "最大公約数-ユークリッドの互除法\n\n最大公約数は、コンピュータ上で扱う数学には欠かせない要素です。最大公約 数を使うことで、計算の効率が大きく変動することもあります。最大公約数を求めるアルゴリズムのひとつが「ユークリッドの互除法」です。その処理 の流れを以下に示します。\n\n例えば 1071 と 1029 の場合、1071 を X 、1029 を Y に代入して、\n\n       1071 ÷ 1029 の余りは 42 、X に 42 を代入して X と Y を入れ替える。 (1 ステップ)\n\n       1029 ÷ 42 の余りは 21 、X に 21 を代入して X と Y を入れ替える。 (2 ステップ)\n\n       42 ÷ 21 の余りは 0 、X に 0 を代入して X と Y を入れ替える。 (3 ステップ)\n\nY が 0 になったので、この時の X が最大公約数となる。よって最大公約数は 21 。\n\nこのように、たったの 3 ステップで 1071 と 1029 の最大公約数を求めることが出来ました。ユークリッドの互除法は約数を出して比較していく方法に比べ、圧倒的に早く結果を出してくれます。\n\n2つの整数を入力とし、ユークリッドの互除法を用いて最大公約数を求め、その最大公約数と計算にかかったステップ数を出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロふたつの行で示されます。\n各データセットとして2つの整数 a, b (2 ≤ a, b ≤ 231-1) が1行に与えられます。\n\nデータセットの数は 1000 を超えません。\n\nOutput\n\nデータセットごとに、入力された2つの整数の最大公約数と、計算にかかったユークリッドの互除法のステップ数を空白区切りで1行に出力します。\n\nSample Input\n\n1071 1029\n5 5\n0 0\n\nOutput for the Sample Input\n\n21 3\n5 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": 177, "cpu_time_ms": 30, "memory_kb": 6104}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s274566944", "group_id": "codeNet:p00201", "input_text": "#!/usr/bin/ruby -Ku\n\nrequire 'pp'\n\ndef check_lowest(item, shop, recipe)\n if recipe.include?(item) then\n sum = 0\n recipe[item].each{ |it|\n tmp = check_lowest(it, shop, recipe)\n sum += tmp\n }\n return [sum, shop[item]].min\n else\n return shop[item] || 0\n end\nend\n\nloop do\n n = gets.to_i\n break if n == 0\n \n shop = Hash.new\n n.times{\n data = gets.split(nil)\n shop[data[0]] = data[1].to_i\n }\n \n m = gets.to_i \n \n recipe = Hash.new\n m.times{\n data = gets.split(nil)\n item, n = data\n recipe[item] = data.slice(2, n.to_i)\n }\n \n item = gets.split(nil)[0]\n \n puts check_lowest(item, shop, recipe)\nend", "language": "Ruby", "metadata": {"date": 1370805469, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00201.html", "problem_id": "p00201", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00201/input.txt", "sample_output_relpath": "derived/input_output/data/p00201/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00201/Ruby/s274566944.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s274566944", "user_id": "u934534598"}, "prompt_components": {"gold_output": "13636\n300000\n", "input_to_evaluate": "#!/usr/bin/ruby -Ku\n\nrequire 'pp'\n\ndef check_lowest(item, shop, recipe)\n if recipe.include?(item) then\n sum = 0\n recipe[item].each{ |it|\n tmp = check_lowest(it, shop, recipe)\n sum += tmp\n }\n return [sum, shop[item]].min\n else\n return shop[item] || 0\n end\nend\n\nloop do\n n = gets.to_i\n break if n == 0\n \n shop = Hash.new\n n.times{\n data = gets.split(nil)\n shop[data[0]] = data[1].to_i\n }\n \n m = gets.to_i \n \n recipe = Hash.new\n m.times{\n data = gets.split(nil)\n item, n = data\n recipe[item] = data.slice(2, n.to_i)\n }\n \n item = gets.split(nil)[0]\n \n puts check_lowest(item, shop, recipe)\nend", "problem_context": "錬金マスター\n\nあなたはついに魔法の釜、錬金釜を手に入れました。錬金釜に複数のアイテムを入れると、新しいア イテムを作ることができます。新しく作ったアイテムは、他のアイテムを作るために錬金釜へ入れることもできます。アイテムを作るために必要なアイテムのリストを記したものを錬金レシピと呼ぶことにします。以下の 3 つは錬金レシピの例です。\n\n木片と糸でラケットができる。\n\nお米と水でおにぎりができる。\n\nラケットとマイクとおにぎりでギターができる。\n\nアイテムはお金を使って手にいれることもできますが、錬金釜で作った方が安くすむ場合もあります。例えば、各アイテムの購入価格が以下のように与えられているとします。\n\nアイテム名\n\n購入価格(円)\n\n木片\n\n3,000\n\n糸\n\n800\n\nお米\n\n36\n\n水\n\n0\n\nラケット\n\n5,000\n\nマイク\n\n9,800\n\nおにぎり\n\n140\n\nギター\n\n98,000\n\nラケットは 5,000 円で購入できますが、木片と糸を購入して錬金すれば 3,800 円で手に入れられます。更に、錬金を重ねることによりとてもお得にアイテムを手に入れられます。図 1 は上記 3 つの錬金レシピ例を組み合わせたものです。ギターは 98,000 円で購入できますが、木片、糸、お米、水、マイクを購入して錬金すれば、たったの 13,636 円で手に入れられます。\n\n図 1\n\nあなたは冒険を楽に進めるため、なるべく安く目的のアイテムを手に入れようと考えました。 アイテムのリスト、錬金レシピのリスト、指定されたアイテムを入力とし、指定されたアイテムを作るために必要な金額の最小値を出力するプログラムを作成して下さい。\n\n各アイテムの数量に限りはないものとします。アイテムは複数のレシピに使われることがありますが、1 つのアイテムを作るためのレシピはたかだか 1 つです。また、あるアイテムを起点としてレシピをたどっていったとき、そのアイテムが再びレシピに現れることはありません。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。各データセットは以下の形式で与えられます。\n\nn\ns1 p1\ns2 p2\n:\nsn pn\nm\no1 k1 q1 q2 ... qk1\no2 k2 q1 q2 ... qk2\n:\nom km q1 q2 ... qkm\nt\n\n1 行目にリストに含まれるアイテムの種類数 n (1 ≤ n ≤ 100) が与えられます。続く n 行に i 番目のアイテムの名前 si (1 文字以上 100 文字以下のアルファベットからなる半角文字列) とそれを購入する場合の値段 pi (0 ≤ pi ≤ 1000000)が与えられます。\n\n続く行に錬金レシピの数 m (0 ≤ m ≤ 100) が与えられます。続く m 行に i 番目のレシピの情報が与えられます。各レシピとして、アイテムの名前 oi、それを作るために必要なアイテムの個数 ki (1 ≤ ki ≤ 100) 、 ki 個のアイテム名 q1, q2 ... qki が与えられます。\n\n最後の行に指定されたアイテム名 t が与えられます。\n\nデータセットの数は 30 を超えません。\n\nOutput\n\n入力データセットごとに、最小の値段を1行に出力します。\n\nSample Input\n\n8\nwood 3000\nstring 800\nrice 36\nwater 0\nracket 5000\nmicrophone 9800\nonigiri 140\nguitar 98000\n3\nracket 2 wood string\nonigiri 2 rice water\nguitar 3 racket microphone onigiri\nguitar\n1\ncomputer 300000\n0\ncomputer\n0\n\nOutput for the Sample Input\n\n13636\n300000", "sample_input": "8\nwood 3000\nstring 800\nrice 36\nwater 0\nracket 5000\nmicrophone 9800\nonigiri 140\nguitar 98000\n3\nracket 2 wood string\nonigiri 2 rice water\nguitar 3 racket microphone onigiri\nguitar\n1\ncomputer 300000\n0\ncomputer\n0\n"}, "reference_outputs": ["13636\n300000\n"], "source_document_id": "p00201", "source_text": "錬金マスター\n\nあなたはついに魔法の釜、錬金釜を手に入れました。錬金釜に複数のアイテムを入れると、新しいア イテムを作ることができます。新しく作ったアイテムは、他のアイテムを作るために錬金釜へ入れることもできます。アイテムを作るために必要なアイテムのリストを記したものを錬金レシピと呼ぶことにします。以下の 3 つは錬金レシピの例です。\n\n木片と糸でラケットができる。\n\nお米と水でおにぎりができる。\n\nラケットとマイクとおにぎりでギターができる。\n\nアイテムはお金を使って手にいれることもできますが、錬金釜で作った方が安くすむ場合もあります。例えば、各アイテムの購入価格が以下のように与えられているとします。\n\nアイテム名\n\n購入価格(円)\n\n木片\n\n3,000\n\n糸\n\n800\n\nお米\n\n36\n\n水\n\n0\n\nラケット\n\n5,000\n\nマイク\n\n9,800\n\nおにぎり\n\n140\n\nギター\n\n98,000\n\nラケットは 5,000 円で購入できますが、木片と糸を購入して錬金すれば 3,800 円で手に入れられます。更に、錬金を重ねることによりとてもお得にアイテムを手に入れられます。図 1 は上記 3 つの錬金レシピ例を組み合わせたものです。ギターは 98,000 円で購入できますが、木片、糸、お米、水、マイクを購入して錬金すれば、たったの 13,636 円で手に入れられます。\n\n図 1\n\nあなたは冒険を楽に進めるため、なるべく安く目的のアイテムを手に入れようと考えました。 アイテムのリスト、錬金レシピのリスト、指定されたアイテムを入力とし、指定されたアイテムを作るために必要な金額の最小値を出力するプログラムを作成して下さい。\n\n各アイテムの数量に限りはないものとします。アイテムは複数のレシピに使われることがありますが、1 つのアイテムを作るためのレシピはたかだか 1 つです。また、あるアイテムを起点としてレシピをたどっていったとき、そのアイテムが再びレシピに現れることはありません。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。各データセットは以下の形式で与えられます。\n\nn\ns1 p1\ns2 p2\n:\nsn pn\nm\no1 k1 q1 q2 ... qk1\no2 k2 q1 q2 ... qk2\n:\nom km q1 q2 ... qkm\nt\n\n1 行目にリストに含まれるアイテムの種類数 n (1 ≤ n ≤ 100) が与えられます。続く n 行に i 番目のアイテムの名前 si (1 文字以上 100 文字以下のアルファベットからなる半角文字列) とそれを購入する場合の値段 pi (0 ≤ pi ≤ 1000000)が与えられます。\n\n続く行に錬金レシピの数 m (0 ≤ m ≤ 100) が与えられます。続く m 行に i 番目のレシピの情報が与えられます。各レシピとして、アイテムの名前 oi、それを作るために必要なアイテムの個数 ki (1 ≤ ki ≤ 100) 、 ki 個のアイテム名 q1, q2 ... qki が与えられます。\n\n最後の行に指定されたアイテム名 t が与えられます。\n\nデータセットの数は 30 を超えません。\n\nOutput\n\n入力データセットごとに、最小の値段を1行に出力します。\n\nSample Input\n\n8\nwood 3000\nstring 800\nrice 36\nwater 0\nracket 5000\nmicrophone 9800\nonigiri 140\nguitar 98000\n3\nracket 2 wood string\nonigiri 2 rice water\nguitar 3 racket microphone onigiri\nguitar\n1\ncomputer 300000\n0\ncomputer\n0\n\nOutput for the Sample Input\n\n13636\n300000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 649, "cpu_time_ms": 20, "memory_kb": 6260}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s167575192", "group_id": "codeNet:p00227", "input_text": "until [0,0] == (num,max = gets.split.map &:to_i)\n next if num.nil?\n ary = gets.split.map &:to_i\n ary.sort!{|a, b| b <=> a }\n c,sum = 0,0\n ary.each do |x|\n c+=1\n sum+=x if ((c%max)!=0) \n end\n p sum\nend", "language": "Ruby", "metadata": {"date": 1398142811, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s167575192.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s167575192", "user_id": "u588130269"}, "prompt_components": {"gold_output": "150\n2100\n", "input_to_evaluate": "until [0,0] == (num,max = gets.split.map &:to_i)\n next if num.nil?\n ary = gets.split.map &:to_i\n ary.sort!{|a, b| b <=> a }\n c,sum = 0,0\n ary.each do |x|\n c+=1\n sum+=x if ((c%max)!=0) \n end\n p sum\nend", "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": 213, "cpu_time_ms": 40, "memory_kb": 6168}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s316829573", "group_id": "codeNet:p00251", "input_text": "a=gets.to_i\ns=gets.to_i\nd=gets.to_i\nf=gets.to_i\ng=gets.to_i\nh=gets.to_i\nj=gets.to_i\nk=gets.to_i\nl=gets.to_i\np=gets.to_i\nprint(\"#{a+s+d+f+g+h+j+k+l+p}\\n\")", "language": "Ruby", "metadata": {"date": 1489905999, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00251.html", "problem_id": "p00251", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00251/input.txt", "sample_output_relpath": "derived/input_output/data/p00251/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00251/Ruby/s316829573.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s316829573", "user_id": "u988213374"}, "prompt_components": {"gold_output": "55\n", "input_to_evaluate": "a=gets.to_i\ns=gets.to_i\nd=gets.to_i\nf=gets.to_i\ng=gets.to_i\nh=gets.to_i\nj=gets.to_i\nk=gets.to_i\nl=gets.to_i\np=gets.to_i\nprint(\"#{a+s+d+f+g+h+j+k+l+p}\\n\")", "problem_context": "10問解いたら何点取れる?\n\n選手の皆さん、パソコン甲子園にようこそ。パソコン甲子園は今年で10周年になりますが、出題される問題数や合計得点は年によって異なります。各問題には難易度に応じて得点が決められています。問題数が10問で、それぞれの問題の得点が与えられるとき、それらの合計を出力するプログラムを作成して下さい。\n\n入力\n\n入力は以下の形式で与えられる。\n\ns1\ns2\n.\n.\ns10\n\n入力は10行からなり、i 行目に問題 i の得点を表す整数 si (0≤ si ≤ 100)が与えられる。\n\n出力\n\n合計得点を1行に出力する。\n\n入力例1\n\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n\n出力例1\n\n55\n\n入力例2\n\n4\n4\n8\n8\n8\n10\n10\n12\n16\n20\n\n出力例2\n\n100", "sample_input": "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n"}, "reference_outputs": ["55\n"], "source_document_id": "p00251", "source_text": "10問解いたら何点取れる?\n\n選手の皆さん、パソコン甲子園にようこそ。パソコン甲子園は今年で10周年になりますが、出題される問題数や合計得点は年によって異なります。各問題には難易度に応じて得点が決められています。問題数が10問で、それぞれの問題の得点が与えられるとき、それらの合計を出力するプログラムを作成して下さい。\n\n入力\n\n入力は以下の形式で与えられる。\n\ns1\ns2\n.\n.\ns10\n\n入力は10行からなり、i 行目に問題 i の得点を表す整数 si (0≤ si ≤ 100)が与えられる。\n\n出力\n\n合計得点を1行に出力する。\n\n入力例1\n\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n\n出力例1\n\n55\n\n入力例2\n\n4\n4\n8\n8\n8\n10\n10\n12\n16\n20\n\n出力例2\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": 153, "cpu_time_ms": 40, "memory_kb": 8684}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s183796406", "group_id": "codeNet:p00345", "input_text": "require 'mathn'\ns = gets.chomp\nif s =~ /(\\d+)\\.(\\d*)\\((\\d+)\\)/\n a, b, c = $1, $2, $3\n d = 10 ** ($2.size + $3.size) - 10 ** $2.size\n n = ($1 + $2 + $3).sub(/^0*/, '').to_i\n x = n / d\n puts [x.numerator, x.denominator] * ?/\nelse\n s =~ /(\\d+)\\.(\\d+)/\n d = 10 ** $2.size\n n = ($1 + $2).sub(/^0*/, '').to_i\n x = n / d\n puts [x.numerator, x.denominator] * ?/\nend\n", "language": "Ruby", "metadata": {"date": 1528387258, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00345.html", "problem_id": "p00345", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00345/input.txt", "sample_output_relpath": "derived/input_output/data/p00345/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00345/Ruby/s183796406.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s183796406", "user_id": "u797180951"}, "prompt_components": {"gold_output": "1/3\n", "input_to_evaluate": "require 'mathn'\ns = gets.chomp\nif s =~ /(\\d+)\\.(\\d*)\\((\\d+)\\)/\n a, b, c = $1, $2, $3\n d = 10 ** ($2.size + $3.size) - 10 ** $2.size\n n = ($1 + $2 + $3).sub(/^0*/, '').to_i\n x = n / d\n puts [x.numerator, x.denominator] * ?/\nelse\n s =~ /(\\d+)\\.(\\d+)/\n d = 10 ** $2.size\n n = ($1 + $2).sub(/^0*/, '').to_i\n x = n / d\n puts [x.numerator, x.denominator] * ?/\nend\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\n実数既約分数化\n\n実数のうち、小数部が循環するものと有限桁のものは分数として表すことができます。\n\n分数で表すことができる実数が与えられたとき、その実数と等しい既約分数(それ以上約分できない分数)を出力するプログラムを作成せよ。\n\nInput\n\n入力は以下の形式で与えられる。\n\nstr\n\n1行に、変換したい実数を表す文字列 str が与えられる。実数の値は 0 より大きい。文字列は数字か「.」、「(」、「)」を含む、長さが 3 以上 8 以下の文字列である。「.」は小数点、「(」は数字の循環の始まり、「)」は数字の循環の終わりを示す。整数部にも小数部にも、必ず1桁以上の数字が与えられるとする。ただし、循環小数が与えられた場合、文字列は以下の条件を満たす。\n\n循環の始まりと終わりのペアは、小数点の右側に一度だけ現れる。\n\n循環の終わりを示す「)」は、文字列の末尾に現れる。\n\n循環の始まりと終わりの間には、必ず1桁以上の数字が与えられる。\n\nOutput\n\n実数を既約分数で表した形式(分子の整数に続けて「/」区切りで分母の整数を並べたもの)で出力する。\n\nSample Input 1\n\n0.(3)\n\nSample Output 1\n\n1/3\n\nSample Input 2\n\n1.0\n\nSample Output 2\n\n1/1\n\nSample Input 3\n\n5.2(143)\n\nSample Output 3\n\n52091/9990\n\nSample Input 4\n\n0.0739\n\nSample Output 4\n\n739/10000", "sample_input": "0.(3)\n"}, "reference_outputs": ["1/3\n"], "source_document_id": "p00345", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\n実数既約分数化\n\n実数のうち、小数部が循環するものと有限桁のものは分数として表すことができます。\n\n分数で表すことができる実数が与えられたとき、その実数と等しい既約分数(それ以上約分できない分数)を出力するプログラムを作成せよ。\n\nInput\n\n入力は以下の形式で与えられる。\n\nstr\n\n1行に、変換したい実数を表す文字列 str が与えられる。実数の値は 0 より大きい。文字列は数字か「.」、「(」、「)」を含む、長さが 3 以上 8 以下の文字列である。「.」は小数点、「(」は数字の循環の始まり、「)」は数字の循環の終わりを示す。整数部にも小数部にも、必ず1桁以上の数字が与えられるとする。ただし、循環小数が与えられた場合、文字列は以下の条件を満たす。\n\n循環の始まりと終わりのペアは、小数点の右側に一度だけ現れる。\n\n循環の終わりを示す「)」は、文字列の末尾に現れる。\n\n循環の始まりと終わりの間には、必ず1桁以上の数字が与えられる。\n\nOutput\n\n実数を既約分数で表した形式(分子の整数に続けて「/」区切りで分母の整数を並べたもの)で出力する。\n\nSample Input 1\n\n0.(3)\n\nSample Output 1\n\n1/3\n\nSample Input 2\n\n1.0\n\nSample Output 2\n\n1/1\n\nSample Input 3\n\n5.2(143)\n\nSample Output 3\n\n52091/9990\n\nSample Input 4\n\n0.0739\n\nSample Output 4\n\n739/10000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 50, "memory_kb": 7372}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s401964965", "group_id": "codeNet:p00377", "input_text": "n, c = gets.chomp.split.map(&:to_i)\nsum = gets.chomp.split.map(&:to_i).inject(:+)\nq, r = sum.divmod(n + 1)\nputs (r == 0) ? q : q + 1\n", "language": "Ruby", "metadata": {"date": 1553135773, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00377.html", "problem_id": "p00377", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00377/input.txt", "sample_output_relpath": "derived/input_output/data/p00377/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00377/Ruby/s401964965.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s401964965", "user_id": "u247371045"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "n, c = gets.chomp.split.map(&:to_i)\nsum = gets.chomp.split.map(&:to_i).inject(:+)\nq, r = sum.divmod(n + 1)\nputs (r == 0) ? q : q + 1\n", "problem_context": "Cake Party\n\n \nI’m planning to have a party on my birthday. Many of my friends will come to the party. Some of them will come with one or more pieces of cakes, but it is not certain if the number of the cakes is a multiple of the number of people coming.\n\nI wish to enjoy the cakes equally among the partiers. So, I decided to apply the following rules. First, all the party attendants are given the same number of cakes. If some remainder occurs, a piece goes on a priority basis to the party host (that’s me!). How many pieces of cake can I enjoy?\n\nGiven the number of my friends and cake information, make a program to calculate how many pieces of cake I can enjoy. Note that I am not counted in the number of my friends.\n\nInput\n\nThe input is given in the following format.\n\n$N$ $C$\n$p_1$ $p_2$ ... $p_C$\n\nThe first line provides the number of my friends $N$ ($1 \\leq N \\leq 100$) and the number of those among them who brought one or more pieces of cake with them $C$ ($1 \\leq C \\leq N$). The second line provides an array of integers $p_i$ ($1 \\leq p_i \\leq100$), each of which shows the number of cakes of the $i$-th friend of mine who was willing to come up with one or more pieces of cake.\n\nOutput\n\nOutput the number of cakes I can enjoy.\n\nSample Input 1\n\n5 4\n5 5 6 5\n\nSample Output 1\n\n4\n\nSample Input 2\n\n7 5\n8 8 8 8 8\n\nSample Output 2\n\n5\n\nSample Input 3\n\n100 3\n3 3 3\n\nSample Output 3\n\n1", "sample_input": "5 4\n5 5 6 5\n"}, "reference_outputs": ["4\n"], "source_document_id": "p00377", "source_text": "Cake Party\n\n \nI’m planning to have a party on my birthday. Many of my friends will come to the party. Some of them will come with one or more pieces of cakes, but it is not certain if the number of the cakes is a multiple of the number of people coming.\n\nI wish to enjoy the cakes equally among the partiers. So, I decided to apply the following rules. First, all the party attendants are given the same number of cakes. If some remainder occurs, a piece goes on a priority basis to the party host (that’s me!). How many pieces of cake can I enjoy?\n\nGiven the number of my friends and cake information, make a program to calculate how many pieces of cake I can enjoy. Note that I am not counted in the number of my friends.\n\nInput\n\nThe input is given in the following format.\n\n$N$ $C$\n$p_1$ $p_2$ ... $p_C$\n\nThe first line provides the number of my friends $N$ ($1 \\leq N \\leq 100$) and the number of those among them who brought one or more pieces of cake with them $C$ ($1 \\leq C \\leq N$). The second line provides an array of integers $p_i$ ($1 \\leq p_i \\leq100$), each of which shows the number of cakes of the $i$-th friend of mine who was willing to come up with one or more pieces of cake.\n\nOutput\n\nOutput the number of cakes I can enjoy.\n\nSample Input 1\n\n5 4\n5 5 6 5\n\nSample Output 1\n\n4\n\nSample Input 2\n\n7 5\n8 8 8 8 8\n\nSample Output 2\n\n5\n\nSample Input 3\n\n100 3\n3 3 3\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": 133, "cpu_time_ms": 40, "memory_kb": 6876}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s306446439", "group_id": "codeNet:p00423", "input_text": "result1 = Array.new\nresult2 = Array.new\nn=1\nwhile true\n\tn = gets.to_i\n\tif n==0\n\tbreak\n\tend\t\n\tscore1=0\n\tscore2=0\n\tn.times do\nnum1,num2 = gets.split.map(&:to_i)\nif num1>num2\n\tscore1 += num1+num2\nelsif num1num2\n\tscore1 += num1+num2\nelsif num1 max_len ? new_len : max_len\n end\n return max_len\n end\n\nend\n\nwhile (n = gets.to_i) != 0 do\n himos = {}\n es_nums = []\n 0.upto(n-1) do |i|\n es = gets.split(\" \").map(&:to_i)\n es.each do |num|\n himos[num] = [] if himos[num].nil?\n himos[num] << Himo.new(i, es)\n end\n end\n lens = []\n himos.each_key {|m| lens << rec(m, himos, 0)}\n puts lens.max\nend", "language": "Ruby", "metadata": {"date": 1446380403, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00431.html", "problem_id": "p00431", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00431/input.txt", "sample_output_relpath": "derived/input_output/data/p00431/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00431/Ruby/s311988946.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s311988946", "user_id": "u329400409"}, "prompt_components": {"gold_output": "5\n6\n4\n", "input_to_evaluate": "class Himo\n attr_accessor :id, :es\n def initialize(id, es)\n @id = id\n @es = es\n end\n def the_other_side(e)\n if e == @es[0]\n @es[1]\n elsif e == @es[1]\n @es[0]\n else\n puts \"error\"\n end\n end\n def to_s\n \"#{@id}, [#{@es[0]},#{@es[1]}]\"\n end\nend\n\ndef rec(m, himos, len)\n if himos[m].nil? || himos[m].empty?\n return len\n else\n max_len = 0\n himos[m].each do |himo|\n l = himo.the_other_side(m)\n himos_copy = himos.dup\n puts \"error2\" unless himos_copy.delete(m)\n new_len = rec(l, himos_copy, len+1)\n max_len = new_len > max_len ? new_len : max_len\n end\n return max_len\n end\n\nend\n\nwhile (n = gets.to_i) != 0 do\n himos = {}\n es_nums = []\n 0.upto(n-1) do |i|\n es = gets.split(\" \").map(&:to_i)\n es.each do |num|\n himos[num] = [] if himos[num].nil?\n himos[num] << Himo.new(i, es)\n end\n end\n lens = []\n himos.each_key {|m| lens << rec(m, himos, 0)}\n puts lens.max\nend", "problem_context": "両端にリングのついた紐を考える.リングは正整数が付いていて,紐を区別する.紐の両端のリングには異なる数 a, b が付けられる.これを,[a, b] と記述する.複数の紐があり,一方の紐と他方の紐のリングに付いている数が同じ場合,そのリングのところで,これらの紐をつなげることができて,つなげてできたものを鎖と呼ぶことにする.例えば,[1, 3] と [3, 4] という紐からは [1, 3, 4] という鎖ができる.紐と鎖や鎖同志も同じ整数が付いているリングのところでつなげることができるものとする.\n\n例えば,鎖 [1, 3, 4] と紐 [5, 1] からは [5, 1, 3, 4] ができ,鎖 [1, 3, 4] と鎖 [2, 3, 5] からは, 中央でクロスしたような形になる.鎖 [1, 3, 4] と鎖 [4, 6, 1] からは, 輪の形ができる.\n\nこのように様々な形ができるが, そのうちの一部で,同じ数の付いたリングは一度だけたどるつながった複数の紐を鎖と呼ぶことにする.例えば,鎖 [1, 3, 4] と鎖[2, 3, 5] からできる,中央でクロスしたような形には, [1, 3, 5],[2, 3, 4] という鎖も含まれ,鎖 [1, 3, 4] と鎖 [4, 6, 1] からできる輪には, [1, 3, 4, 6],[3, 4, 6, 1],[4, 6, 1, 3]などの鎖が含まれる.\n\nこれらの鎖に対して,含まれる数の個数を長さと定義する. 与えられた複数の紐に対して,つなげられるものはすべてつなげると1つ以上の\n鎖を含む形ができる.そのうちの最大の鎖の長さを求めるプログラムを作成せよ.\n\n入力データ の最初の行には紐の個数である正整数 1 ≤ n ≤ 100 が書いてあり,つづく n 行のそれぞれには, 空白で区切られた 2 つの整数 a, b が書いてあり 1 ≤ a < b ≤ 100 となっている.各行の 2 つの整数は 1 つの紐の両端の整数を表わす.\n\n入力例1\n\n入力例2\n\n入力例3\n\n7\n\n6\n\n7\n\n1 3\n\n1 2\n\n1 3\n\n3 4\n\n2 3\n\n2 4\n\n1 4\n\n3 4\n\n3 5\n\n2 7\n\n4 5\n\n4 6\n\n5 7\n\n1 5\n\n6 7\n\n6 7\n\n2 6\n\n2 6\n\n1 7\n\n4 7\n\n \n\n出力例1\n\n出力例2\n\n出力例3\n\n5\n\n6\n\n4\n\n入力\n\n入力は複数のデータセットからなる.n が 0 のとき入力が終了する.データセットの数は 10 を超えない.\n\n出力\n\nデータセットごとに、最大の鎖の長さを1行に出力する.\n\n入力例\n\n7\n1 3\n3 4\n1 4\n2 7\n5 7\n6 7\n1 7\n6\n1 2\n2 3\n3 4\n4 5\n1 5\n2 6\n7\n1 3\n2 4\n3 5\n4 6\n6 7\n2 6\n4 7\n0\n\n出力例\n\n5\n6\n4\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "7\n1 3\n3 4\n1 4\n2 7\n5 7\n6 7\n1 7\n6\n1 2\n2 3\n3 4\n4 5\n1 5\n2 6\n7\n1 3\n2 4\n3 5\n4 6\n6 7\n2 6\n4 7\n0\n"}, "reference_outputs": ["5\n6\n4\n"], "source_document_id": "p00431", "source_text": "両端にリングのついた紐を考える.リングは正整数が付いていて,紐を区別する.紐の両端のリングには異なる数 a, b が付けられる.これを,[a, b] と記述する.複数の紐があり,一方の紐と他方の紐のリングに付いている数が同じ場合,そのリングのところで,これらの紐をつなげることができて,つなげてできたものを鎖と呼ぶことにする.例えば,[1, 3] と [3, 4] という紐からは [1, 3, 4] という鎖ができる.紐と鎖や鎖同志も同じ整数が付いているリングのところでつなげることができるものとする.\n\n例えば,鎖 [1, 3, 4] と紐 [5, 1] からは [5, 1, 3, 4] ができ,鎖 [1, 3, 4] と鎖 [2, 3, 5] からは, 中央でクロスしたような形になる.鎖 [1, 3, 4] と鎖 [4, 6, 1] からは, 輪の形ができる.\n\nこのように様々な形ができるが, そのうちの一部で,同じ数の付いたリングは一度だけたどるつながった複数の紐を鎖と呼ぶことにする.例えば,鎖 [1, 3, 4] と鎖[2, 3, 5] からできる,中央でクロスしたような形には, [1, 3, 5],[2, 3, 4] という鎖も含まれ,鎖 [1, 3, 4] と鎖 [4, 6, 1] からできる輪には, [1, 3, 4, 6],[3, 4, 6, 1],[4, 6, 1, 3]などの鎖が含まれる.\n\nこれらの鎖に対して,含まれる数の個数を長さと定義する. 与えられた複数の紐に対して,つなげられるものはすべてつなげると1つ以上の\n鎖を含む形ができる.そのうちの最大の鎖の長さを求めるプログラムを作成せよ.\n\n入力データ の最初の行には紐の個数である正整数 1 ≤ n ≤ 100 が書いてあり,つづく n 行のそれぞれには, 空白で区切られた 2 つの整数 a, b が書いてあり 1 ≤ a < b ≤ 100 となっている.各行の 2 つの整数は 1 つの紐の両端の整数を表わす.\n\n入力例1\n\n入力例2\n\n入力例3\n\n7\n\n6\n\n7\n\n1 3\n\n1 2\n\n1 3\n\n3 4\n\n2 3\n\n2 4\n\n1 4\n\n3 4\n\n3 5\n\n2 7\n\n4 5\n\n4 6\n\n5 7\n\n1 5\n\n6 7\n\n6 7\n\n2 6\n\n2 6\n\n1 7\n\n4 7\n\n \n\n出力例1\n\n出力例2\n\n出力例3\n\n5\n\n6\n\n4\n\n入力\n\n入力は複数のデータセットからなる.n が 0 のとき入力が終了する.データセットの数は 10 を超えない.\n\n出力\n\nデータセットごとに、最大の鎖の長さを1行に出力する.\n\n入力例\n\n7\n1 3\n3 4\n1 4\n2 7\n5 7\n6 7\n1 7\n6\n1 2\n2 3\n3 4\n4 5\n1 5\n2 6\n7\n1 3\n2 4\n3 5\n4 6\n6 7\n2 6\n4 7\n0\n\n出力例\n\n5\n6\n4\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 981, "cpu_time_ms": 40000, "memory_kb": 64840}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s141176651", "group_id": "codeNet:p00445", "input_text": "#encoding:utf-8 No.0522 2014.12.11\nwhile gets\n joi = 0\n ioi = 0\n i = 0\n\n while i < $_.length - 2\n if $_[i,3] == \"JOI\"\n joi += 1\n end\n \n if $_[i,3] == \"IOI\"\n ioi += 1\n end\n end\n\n puts joi,ioi\nend", "language": "Ruby", "metadata": {"date": 1418272882, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00445.html", "problem_id": "p00445", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00445/input.txt", "sample_output_relpath": "derived/input_output/data/p00445/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00445/Ruby/s141176651.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s141176651", "user_id": "u949338836"}, "prompt_components": {"gold_output": "2\n0\n1\n3\n2\n3\n", "input_to_evaluate": "#encoding:utf-8 No.0522 2014.12.11\nwhile gets\n joi = 0\n ioi = 0\n i = 0\n\n while i < $_.length - 2\n if $_[i,3] == \"JOI\"\n joi += 1\n end\n \n if $_[i,3] == \"IOI\"\n ioi += 1\n end\n end\n\n puts joi,ioi\nend", "problem_context": "JOIとIOI\n\n問題\n\n与えられた文字列内の連続する3文字が,JOIまたはIOIという並びになっている個所がそれぞれ何個所あるのかを数え上げるプログラムを作成せよ.文字列はアルファベットの大文字だけからなる.例えば下図の「JOIOIOI」という文字列にはJOIが1個所,IOIが2個所に含まれている.\n\n入力\n\n入力は複数のデータセットからなる.各データセットは1行であり,10000文字以下のアルファベットの大文字からなる.入力は EOF で終了する.\n\nデータセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに, 1行目に見つかったJOIの個数,2行目に見つかったIOIの個数をそれぞれ出力せよ.\n\n入出力例\n\n入力例\n\nJOIJOI\nJOIOIOIOI\nJOIOIJOINXNXJIOIOIOJ\n\n出力例\n\n2\n0\n1\n3\n2\n3\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "JOIJOI\nJOIOIOIOI\nJOIOIJOINXNXJIOIOIOJ\n"}, "reference_outputs": ["2\n0\n1\n3\n2\n3\n"], "source_document_id": "p00445", "source_text": "JOIとIOI\n\n問題\n\n与えられた文字列内の連続する3文字が,JOIまたはIOIという並びになっている個所がそれぞれ何個所あるのかを数え上げるプログラムを作成せよ.文字列はアルファベットの大文字だけからなる.例えば下図の「JOIOIOI」という文字列にはJOIが1個所,IOIが2個所に含まれている.\n\n入力\n\n入力は複数のデータセットからなる.各データセットは1行であり,10000文字以下のアルファベットの大文字からなる.入力は EOF で終了する.\n\nデータセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに, 1行目に見つかったJOIの個数,2行目に見つかったIOIの個数をそれぞれ出力せよ.\n\n入出力例\n\n入力例\n\nJOIJOI\nJOIOIOIOI\nJOIOIJOINXNXJIOIOIOJ\n\n出力例\n\n2\n0\n1\n3\n2\n3\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": 225, "cpu_time_ms": 19930, "memory_kb": 6096}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s742760816", "group_id": "codeNet:p00461", "input_text": "loop {\n n = gets.to_i\n break if n == 0\n gets\n str = gets.chomp\n chunks = str.scan(/((IO)+I)/).map{|s, _| (s.size - 1) / 2}\n count = 0\n chunks.each{|c|\n count += c - n + 1 if c >= n\n }\n p count\n}", "language": "Ruby", "metadata": {"date": 1437926190, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00461.html", "problem_id": "p00461", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00461/input.txt", "sample_output_relpath": "derived/input_output/data/p00461/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00461/Ruby/s742760816.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s742760816", "user_id": "u797180951"}, "prompt_components": {"gold_output": "4\n2\n", "input_to_evaluate": "loop {\n n = gets.to_i\n break if n == 0\n gets\n str = gets.chomp\n chunks = str.scan(/((IO)+I)/).map{|s, _| (s.size - 1) / 2}\n count = 0\n chunks.each{|c|\n count += c - n + 1 if c >= n\n }\n p count\n}", "problem_context": "IOIOI\n\n問題\n\n整数 n (1 ≤ n) に対し, n + 1 個の I と n 個の O を I から始めて交互に並べてできる文字列を Pn とする.ここで I と O はそれぞれ英大文字のアイとオーである.\n\nP1\n\nIOI\n\nP2\n\nIOIOI\n\nP3\n\nIOIOIOI\n\n.\n\n.\n\n.\n\nPn\n\nIOIOIO ... OI (O が n 個)\n\n図 1-1 本問で考える文字列 Pn\n\n整数 n と, I と O のみからなる文字列 s が与えられた時, s の中に Pn が何ヶ所含まれているかを出力するプログラムを作成せよ.\n\n例\n\nn が 1, s が OOIOIOIOIIOII の場合, P1 は IOI であり,下図 1-2 に示した 4ヶ所に含まれている.よって,出力は 4 である.\n\nOOIOIOIOIIOII\n\nOOIOIOIOIIOII\n\nOOIOIOIOIIOII\n\nOOIOIOIOIIOII\n\n図 1-2 n が 1, s が OOIOIOIOIIOII の場合の例\n\nn が 2, s が OOIOIOIOIIOII の場合, P2 は IOIOI であり,下図 1-3 に示した 2ヶ所に含まれている.よって,出力は 2 である.\n\nOOIOIOIOIIOII\n\nOOIOIOIOIIOII\n\n図 1-3 n が 2, s が OOIOIOIOIIOII の場合の例\n\n入力\n\n入力は複数のデータセットからなる.各データセットは以下の形式で与えられる.\n\n1 行目には整数 n (1 ≤ n ≤ 1000000) が書かれている.\n\n2 行目には整数 m (1 ≤ m ≤ 1000000) が書かれている. m は s の文字数を表す.\n\n3 行目には文字列 s が書かれている. s は I と O のみからなる.\n\n全ての採点用データで, 2n + 1 ≤ m である.採点用データのうち, 配点の 50% 分については, n ≤ 100, m ≤ 10000 を満たす.\n\nn が 0 のとき入力の終了を示す. データセットの数は 10 を超えない.\n\n出力\n\nデータセットごとに,文字列 s に文字列 Pn が何ヶ所含まれるかを表す 1 つの整数を1 行に出力する. s に Pn が含まれていない場合は,整数として 0 を出力せよ.\n\n入出力例\n\n入力例\n\n1\n13\nOOIOIOIOIIOII\n2\n13\nOOIOIOIOIIOII\n0\n\n出力例\n\n4\n2\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "1\n13\nOOIOIOIOIIOII\n2\n13\nOOIOIOIOIIOII\n0\n"}, "reference_outputs": ["4\n2\n"], "source_document_id": "p00461", "source_text": "IOIOI\n\n問題\n\n整数 n (1 ≤ n) に対し, n + 1 個の I と n 個の O を I から始めて交互に並べてできる文字列を Pn とする.ここで I と O はそれぞれ英大文字のアイとオーである.\n\nP1\n\nIOI\n\nP2\n\nIOIOI\n\nP3\n\nIOIOIOI\n\n.\n\n.\n\n.\n\nPn\n\nIOIOIO ... OI (O が n 個)\n\n図 1-1 本問で考える文字列 Pn\n\n整数 n と, I と O のみからなる文字列 s が与えられた時, s の中に Pn が何ヶ所含まれているかを出力するプログラムを作成せよ.\n\n例\n\nn が 1, s が OOIOIOIOIIOII の場合, P1 は IOI であり,下図 1-2 に示した 4ヶ所に含まれている.よって,出力は 4 である.\n\nOOIOIOIOIIOII\n\nOOIOIOIOIIOII\n\nOOIOIOIOIIOII\n\nOOIOIOIOIIOII\n\n図 1-2 n が 1, s が OOIOIOIOIIOII の場合の例\n\nn が 2, s が OOIOIOIOIIOII の場合, P2 は IOIOI であり,下図 1-3 に示した 2ヶ所に含まれている.よって,出力は 2 である.\n\nOOIOIOIOIIOII\n\nOOIOIOIOIIOII\n\n図 1-3 n が 2, s が OOIOIOIOIIOII の場合の例\n\n入力\n\n入力は複数のデータセットからなる.各データセットは以下の形式で与えられる.\n\n1 行目には整数 n (1 ≤ n ≤ 1000000) が書かれている.\n\n2 行目には整数 m (1 ≤ m ≤ 1000000) が書かれている. m は s の文字数を表す.\n\n3 行目には文字列 s が書かれている. s は I と O のみからなる.\n\n全ての採点用データで, 2n + 1 ≤ m である.採点用データのうち, 配点の 50% 分については, n ≤ 100, m ≤ 10000 を満たす.\n\nn が 0 のとき入力の終了を示す. データセットの数は 10 を超えない.\n\n出力\n\nデータセットごとに,文字列 s に文字列 Pn が何ヶ所含まれるかを表す 1 つの整数を1 行に出力する. s に Pn が含まれていない場合は,整数として 0 を出力せよ.\n\n入出力例\n\n入力例\n\n1\n13\nOOIOIOIOIIOII\n2\n13\nOOIOIOIOIIOII\n0\n\n出力例\n\n4\n2\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 228, "cpu_time_ms": 30, "memory_kb": 10284}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s765095920", "group_id": "codeNet:p00466", "input_text": "total = gets.to_i\n\nsum = 0\nloop do\n data = gets.to_i\n break if data == 0\n sum += data\nend\n\nputs total - sum\n", "language": "Ruby", "metadata": {"date": 1531836970, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00466.html", "problem_id": "p00466", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00466/input.txt", "sample_output_relpath": "derived/input_output/data/p00466/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00466/Ruby/s765095920.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s765095920", "user_id": "u592742011"}, "prompt_components": {"gold_output": "600\n", "input_to_evaluate": "total = gets.to_i\n\nsum = 0\nloop do\n data = gets.to_i\n break if data == 0\n sum += data\nend\n\nputs total - sum\n", "problem_context": "レシート\n\n問題\n\n太郎君は10冊の本を購入した.\n後日,\nレシートをもとに価格を調べようとしたが,\nレシートには汚れがあり,\nある本の価格が読み取れなかった.\nその本の価格を,\n10冊の総額と他の9冊の価格から計算することにした.\n\n価格が読み取れなかった本の価格を出力するプログラムを書け.\nなお,本の価格はすべて正の整数である.\nまた,消費税を考慮する必要はない.\n\n入力\n\n入力は複数のデータセットからなる.各データセットは以下の形式で与えられる.\n\n各データセットは10行からなり,1行に1つずつ正の整数が書かれている.\n1行目の整数は10冊の総額を,\n2行目から10行目の整数は読み取れた価格を表している.\nなお,10冊の総額は10000以下である.\n\n総額 が 0 のとき入力の終了を示す.データセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに,価格が読み取れなかった本の価格を1 行に出力する.\n\n入出力例\n\n入力例\n\n9850\n1050\n800\n420\n380\n600\n820\n2400\n1800\n980\n0\n\n出力例\n\n600\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "9850\n1050\n800\n420\n380\n600\n820\n2400\n1800\n980\n0\n"}, "reference_outputs": ["600\n"], "source_document_id": "p00466", "source_text": "レシート\n\n問題\n\n太郎君は10冊の本を購入した.\n後日,\nレシートをもとに価格を調べようとしたが,\nレシートには汚れがあり,\nある本の価格が読み取れなかった.\nその本の価格を,\n10冊の総額と他の9冊の価格から計算することにした.\n\n価格が読み取れなかった本の価格を出力するプログラムを書け.\nなお,本の価格はすべて正の整数である.\nまた,消費税を考慮する必要はない.\n\n入力\n\n入力は複数のデータセットからなる.各データセットは以下の形式で与えられる.\n\n各データセットは10行からなり,1行に1つずつ正の整数が書かれている.\n1行目の整数は10冊の総額を,\n2行目から10行目の整数は読み取れた価格を表している.\nなお,10冊の総額は10000以下である.\n\n総額 が 0 のとき入力の終了を示す.データセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに,価格が読み取れなかった本の価格を1 行に出力する.\n\n入出力例\n\n入力例\n\n9850\n1050\n800\n420\n380\n600\n820\n2400\n1800\n980\n0\n\n出力例\n\n600\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": 117, "cpu_time_ms": 50, "memory_kb": 6836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s016886086", "group_id": "codeNet:p00485", "input_text": "def calc(a, b, c)\n (a+b+c+1)/2\nend\n\nn, m, k = gets.split.map(&:to_i)\nl1 = Array.new(n){ [0]*n }\nl2 = Array.new(n){ [] }\nl3 = []\nm.times do\n a, b, c = gets.split.map(&:to_i)\n a -= 1; b -= 1\n l1[a][b] = l1[b][a] = c\n l2[a] << b; l2[b] << a\n l3 << [a,b,c]\nend\n\nvisited = [false]*n\narr = []\ndist = [1<<31]*n\nk.times do\n visited[i = gets.to_i - 1] = true\n arr << i\n dist[i] = 0\nend\n\nuntil arr.empty?\n s = arr.min{ |a,b| dist[a] <=> dist[b] }\n arr.delete s\n l2[s].each do |t|\n d = dist[s] + l1[s][t]\n if (old = dist[t]) > d\n dist[t] = d\n arr << t if old == 1 << 31\n end\n end\nend\nret = 0\nm.times{ |i| ret = [ret, calc(dist[l3[i][0]], dist[l3[i][1]], l3[i][2])].max }\np ret", "language": "Ruby", "metadata": {"date": 1450341019, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00485.html", "problem_id": "p00485", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00485/input.txt", "sample_output_relpath": "derived/input_output/data/p00485/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00485/Ruby/s016886086.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s016886086", "user_id": "u811434779"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "def calc(a, b, c)\n (a+b+c+1)/2\nend\n\nn, m, k = gets.split.map(&:to_i)\nl1 = Array.new(n){ [0]*n }\nl2 = Array.new(n){ [] }\nl3 = []\nm.times do\n a, b, c = gets.split.map(&:to_i)\n a -= 1; b -= 1\n l1[a][b] = l1[b][a] = c\n l2[a] << b; l2[b] << a\n l3 << [a,b,c]\nend\n\nvisited = [false]*n\narr = []\ndist = [1<<31]*n\nk.times do\n visited[i = gets.to_i - 1] = true\n arr << i\n dist[i] = 0\nend\n\nuntil arr.empty?\n s = arr.min{ |a,b| dist[a] <=> dist[b] }\n arr.delete s\n l2[s].each do |t|\n d = dist[s] + l1[s][t]\n if (old = dist[t]) > d\n dist[t] = d\n arr << t if old == 1 << 31\n end\n end\nend\nret = 0\nm.times{ |i| ret = [ret, calc(dist[l3[i][0]], dist[l3[i][1]], l3[i][2])].max }\np ret", "problem_context": "JOI 国の買い物事情(Shopping in JOI Kingdom)\n\nJOI 国にはN 個の町があり,それらの間はM 本の双方向に通行可能な道路で結ばれている.K 個の町にはショッピングモールがあり,国民は道路を通ってそれらの町のいずれかに行き買い物をする.\n\n家の場所によっては,買い物に行くために長い距離を移動する必要があり,それは非常に不便である.国王はこの実情を把握するため,ショッピングモールのある町までの最短距離が家の場所によってどれだけ長くなりうるのかを調べることにした.家は道路の途中に建てられることもあるので(入力例1 の説明を参照),この調査は非常に大変である.そこで国王は,優秀なプログラマーであるあなたに,調査を行うプログラムの作成を依頼した.\n\n課題\n\n道路の情報とショッピングモールのある町の情報が与えられるとき,ショッピングモールのある町からもっとも遠い道路上の点(端点も含む) までの距離を求めるプログラムを作成せよ.町の中を移動するのにかかる距離は無視してよい.\n\n制限\n\n2 ≤ N ≤ 3000     JOI 国の町の個数\n\n1 ≤ M ≤ 100000 = 105     JOI 国の道路の本数\n\n1 ≤ K ≤ N     ショッピングモールがある町の個数\n\n1 ≤ li ≤ 1000     i 番目の道路の長さ\n\n入力\n\n標準入力から以下の入力を読み込め.\n\n1 行目には整数N, M, K が空白区切りで書かれている.N はJOI 国の町の個数を,M はJOI 国の道路の本数を,i>K はショッピングモールがある町の個数をそれぞれ表す.町には1, 2, ..., N の番号がつけられている.\n\n続くM 行は道路の情報を表す.i + 1 行目(1 ≤ i ≤ M) には整数ai, bi, li (1 ≤ ai ≤ N, 1 ≤ bi ≤ N, 1 ≤ li ≤ 1000) が空白区切りで書かれている.これは,i 本目の道路が町ai と町bi を結んでおり,長さがli であることを表す.道路の両端が同じ町であることはない.また,任意の2 つの町p, q に対し,pとq を結ぶ道路は2 本以上存在しない.どの町からどの町へもいくつかの道路をたどって行くことができる.\n\n続くK 行はショッピングモールの情報を表す.i+M+1 行目(1 ≤ i ≤ K) には1 つの整数si (1 ≤ si ≤ N)が書かれている.これは町si にショッピングモールがあることを表す.s1, ..., sK の中に同じ値が2\n回以上現れることはない.\n\n出力\n\n標準出力に,ショッピングモールのある町までの最短距離の最大値の小数点以下を四捨五入した整数1\nつを出力せよ.\n\n採点基準\n\n採点用データのうち,配点の40% 分については,K = 1 を満たす.\n\n入出力の例\n\n入力例1\n\n3 3 1\n1 2 1\n2 3 1\n3 1 1\n1\n\n出力例1\n\n2\n\n入力例1 は次のような町を表す.道路の長さはすべて1 である.ショッピングモールは町1 にしかない.\n\nショッピングモールのある町までもっとも遠い点は,町2 と町3 を結ぶ道路上の,町2 から距離0.5 の位置にある点であり,ショッピングモールのある町までの距離は1.5 である.よって,それを四捨五入した値である2 を出力する.\n\n入力例2\n\n4 5 2\n1 2 4\n1 3 1\n2 3 2\n2 4 2\n3 4 1\n2\n4\n\n出力例2\n\n3\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "3 3 1\n1 2 1\n2 3 1\n3 1 1\n1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p00485", "source_text": "JOI 国の買い物事情(Shopping in JOI Kingdom)\n\nJOI 国にはN 個の町があり,それらの間はM 本の双方向に通行可能な道路で結ばれている.K 個の町にはショッピングモールがあり,国民は道路を通ってそれらの町のいずれかに行き買い物をする.\n\n家の場所によっては,買い物に行くために長い距離を移動する必要があり,それは非常に不便である.国王はこの実情を把握するため,ショッピングモールのある町までの最短距離が家の場所によってどれだけ長くなりうるのかを調べることにした.家は道路の途中に建てられることもあるので(入力例1 の説明を参照),この調査は非常に大変である.そこで国王は,優秀なプログラマーであるあなたに,調査を行うプログラムの作成を依頼した.\n\n課題\n\n道路の情報とショッピングモールのある町の情報が与えられるとき,ショッピングモールのある町からもっとも遠い道路上の点(端点も含む) までの距離を求めるプログラムを作成せよ.町の中を移動するのにかかる距離は無視してよい.\n\n制限\n\n2 ≤ N ≤ 3000     JOI 国の町の個数\n\n1 ≤ M ≤ 100000 = 105     JOI 国の道路の本数\n\n1 ≤ K ≤ N     ショッピングモールがある町の個数\n\n1 ≤ li ≤ 1000     i 番目の道路の長さ\n\n入力\n\n標準入力から以下の入力を読み込め.\n\n1 行目には整数N, M, K が空白区切りで書かれている.N はJOI 国の町の個数を,M はJOI 国の道路の本数を,i>K はショッピングモールがある町の個数をそれぞれ表す.町には1, 2, ..., N の番号がつけられている.\n\n続くM 行は道路の情報を表す.i + 1 行目(1 ≤ i ≤ M) には整数ai, bi, li (1 ≤ ai ≤ N, 1 ≤ bi ≤ N, 1 ≤ li ≤ 1000) が空白区切りで書かれている.これは,i 本目の道路が町ai と町bi を結んでおり,長さがli であることを表す.道路の両端が同じ町であることはない.また,任意の2 つの町p, q に対し,pとq を結ぶ道路は2 本以上存在しない.どの町からどの町へもいくつかの道路をたどって行くことができる.\n\n続くK 行はショッピングモールの情報を表す.i+M+1 行目(1 ≤ i ≤ K) には1 つの整数si (1 ≤ si ≤ N)が書かれている.これは町si にショッピングモールがあることを表す.s1, ..., sK の中に同じ値が2\n回以上現れることはない.\n\n出力\n\n標準出力に,ショッピングモールのある町までの最短距離の最大値の小数点以下を四捨五入した整数1\nつを出力せよ.\n\n採点基準\n\n採点用データのうち,配点の40% 分については,K = 1 を満たす.\n\n入出力の例\n\n入力例1\n\n3 3 1\n1 2 1\n2 3 1\n3 1 1\n1\n\n出力例1\n\n2\n\n入力例1 は次のような町を表す.道路の長さはすべて1 である.ショッピングモールは町1 にしかない.\n\nショッピングモールのある町までもっとも遠い点は,町2 と町3 を結ぶ道路上の,町2 から距離0.5 の位置にある点であり,ショッピングモールのある町までの距離は1.5 である.よって,それを四捨五入した値である2 を出力する.\n\n入力例2\n\n4 5 2\n1 2 4\n1 3 1\n2 3 2\n2 4 2\n3 4 1\n2\n4\n\n出力例2\n\n3\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": 697, "cpu_time_ms": 1110, "memory_kb": 88580}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s962581240", "group_id": "codeNet:p00507", "input_text": "n=gets.to_i\na=[]\nn.times{a.push(gets.to_i)}\na=a.sort[0..2]\nres=[]\na.permutation(2){|num|res.push(num.join.to_i)}\np res.sort[2]\n", "language": "Ruby", "metadata": {"date": 1535564752, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00507.html", "problem_id": "p00507", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00507/input.txt", "sample_output_relpath": "derived/input_output/data/p00507/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00507/Ruby/s962581240.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s962581240", "user_id": "u067629267"}, "prompt_components": {"gold_output": "52\n", "input_to_evaluate": "n=gets.to_i\na=[]\nn.times{a.push(gets.to_i)}\na=a.sort[0..2]\nres=[]\na.permutation(2){|num|res.push(num.join.to_i)}\np res.sort[2]\n", "problem_context": "問題 3\n\n 入力ファイルの1行目に正整数 n (n≧3)が書いてあり,\nつづく n 行に異なる正整数 a1, ..., an が\n1つずつ書いてある.\na1, ..., an から異なる2個を選んで作られる\n順列を(数として見て)小さい順に並べたとき,\n3番目に来るものを出力せよ.\n\n ただし,\n例えば,a1 = 1,a4 = 11 のような場合も,\na1a4 と a4a1 は異なる順列とみなす.\nまた,\n1≦ai≦10000 (i=1, ..., n) かつ 3≦n≦104 である.\n\n出力ファイルにおいては,\n出力の最後にも改行コードを入れること.\n\n入出力例\n\n入力例1\n\n3\n2\n7\n5\n\n出力例1\n\n52\n\n入力例2\n\n4\n17\n888\n1\n71\n\n出力例2\n\n171\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "3\n2\n7\n5\n"}, "reference_outputs": ["52\n"], "source_document_id": "p00507", "source_text": "問題 3\n\n 入力ファイルの1行目に正整数 n (n≧3)が書いてあり,\nつづく n 行に異なる正整数 a1, ..., an が\n1つずつ書いてある.\na1, ..., an から異なる2個を選んで作られる\n順列を(数として見て)小さい順に並べたとき,\n3番目に来るものを出力せよ.\n\n ただし,\n例えば,a1 = 1,a4 = 11 のような場合も,\na1a4 と a4a1 は異なる順列とみなす.\nまた,\n1≦ai≦10000 (i=1, ..., n) かつ 3≦n≦104 である.\n\n出力ファイルにおいては,\n出力の最後にも改行コードを入れること.\n\n入出力例\n\n入力例1\n\n3\n2\n7\n5\n\n出力例1\n\n52\n\n入力例2\n\n4\n17\n888\n1\n71\n\n出力例2\n\n171\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": 127, "cpu_time_ms": 40, "memory_kb": 6848}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s127426964", "group_id": "codeNet:p00509", "input_text": "def prime?(n)\n (2 ... n).each do |i|\n return false if n % i == 0\n break if i * i > n\n end\n true\nend\n\ndef solve(n, c)\n return (n == 1 ? 11 : \"99\"*n) if c < 0\n\n 1.step(10**n, 2).map{|i|\n s = ((\"%0#{n}d\"%i).reverse + c.to_s + \"%0#{n}d\"%i).to_i\n prime?(s) ? s : 0\n }.max\nend\n\nputs solve(*gets.split.map(&:to_i))", "language": "Ruby", "metadata": {"date": 1414734234, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00509.html", "problem_id": "p00509", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00509/input.txt", "sample_output_relpath": "derived/input_output/data/p00509/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00509/Ruby/s127426964.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s127426964", "user_id": "u392015442"}, "prompt_components": {"gold_output": "101\n", "input_to_evaluate": "def prime?(n)\n (2 ... n).each do |i|\n return false if n % i == 0\n break if i * i > n\n end\n true\nend\n\ndef solve(n, c)\n return (n == 1 ? 11 : \"99\"*n) if c < 0\n\n 1.step(10**n, 2).map{|i|\n s = ((\"%0#{n}d\"%i).reverse + c.to_s + \"%0#{n}d\"%i).to_i\n prime?(s) ? s : 0\n }.max\nend\n\nputs solve(*gets.split.map(&:to_i))", "problem_context": "問題5\n\n J中学校の運動会で次のようなクラス対抗の競技を行なうことになった.\n各クラスから生徒代表の男女 n ペア\n\n        (男子生徒 b1, 女子生徒 g1), (男子生徒 b2, 女子生徒 g2), … , (男子生徒 bn, 女子生徒 gn)\n\nを選び,\n0 から 9 までの数字が書かれた旗を自由に選んでもらい\n(それぞれの旗は十分な個数ある),\n横一列に並んでもらう.\nただし,\nペアになっている男子生徒と女子生徒は同じ番号の旗を一人1つずつ\n選ばなければならず,\n並び順は\n\n        b1 b2 … bn c gn … g2 g1\n\nのように,\n男子生徒達 n 人の並び順\nb1 b2 … bn とは逆の順番\ngn … g2 g1 で女子生徒達は\n並ばなければならない.\n中央の c には,\nクラス担任の先生があらかじめ審判長によって指定された\n番号の付いた旗を持って立つ場合と,\n立たないことを審判長に指定される場合とがある.\n\n こうして並んだ生徒達(と先生)が持った旗の番号\nを 2n 桁(または 2n+1 桁)の整数と考えたとき,\nそれが素数である方が勝ちである.\nただし,\n両クラスとも素数だった場合あるいは両クラスとも素数でなかった場合には,\n数が大きい方が勝ちである. また,\n\n  \n\n      0 b2 … bn c gn … g2 0\n あるいは \n0 b2 … bn gn … g2 0\n\nのように先頭に 0 が来るものは,\n普通使われる数の表し方ではないので禁止されている.\n\n J中学校の生徒であるあなたは,\n自分のクラスが勝つためにはどのように並ぶのがよいかを\n考えなければならない.\n\n 入力ファイルの1行目に正整数 n と\n1桁の整数 c(先生が持つ旗の番号)が\n1つの半角空白文字で区切られて書かれている.\nc<0 のときは,\n先生が中央に立たないことを表わす.\n\n与えられる入力は 1≦n≦10 である.\n\n 負けない並び方の順番\n\n  \n\n     b1 b2 … bn c gn … g2 g1\n または \nb1 b2 … bn gn … g2 g1\n\nを出力せよ.\n\n出力ファイルにおいては,\n出力の最後にも改行コードを入れること.\n\n入出力例\n\n入力例1\n\n1 0\n\n出力例1\n\n101\n\n入力例2\n\n1 5\n\n出力例2\n\n757\n\n入力例3\n\n3 7\n\n出力例3\n\n9957599\n\n入力例4\n\n1 -1\n\n出力例4\n\n11\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "1 0\n"}, "reference_outputs": ["101\n"], "source_document_id": "p00509", "source_text": "問題5\n\n J中学校の運動会で次のようなクラス対抗の競技を行なうことになった.\n各クラスから生徒代表の男女 n ペア\n\n        (男子生徒 b1, 女子生徒 g1), (男子生徒 b2, 女子生徒 g2), … , (男子生徒 bn, 女子生徒 gn)\n\nを選び,\n0 から 9 までの数字が書かれた旗を自由に選んでもらい\n(それぞれの旗は十分な個数ある),\n横一列に並んでもらう.\nただし,\nペアになっている男子生徒と女子生徒は同じ番号の旗を一人1つずつ\n選ばなければならず,\n並び順は\n\n        b1 b2 … bn c gn … g2 g1\n\nのように,\n男子生徒達 n 人の並び順\nb1 b2 … bn とは逆の順番\ngn … g2 g1 で女子生徒達は\n並ばなければならない.\n中央の c には,\nクラス担任の先生があらかじめ審判長によって指定された\n番号の付いた旗を持って立つ場合と,\n立たないことを審判長に指定される場合とがある.\n\n こうして並んだ生徒達(と先生)が持った旗の番号\nを 2n 桁(または 2n+1 桁)の整数と考えたとき,\nそれが素数である方が勝ちである.\nただし,\n両クラスとも素数だった場合あるいは両クラスとも素数でなかった場合には,\n数が大きい方が勝ちである. また,\n\n  \n\n      0 b2 … bn c gn … g2 0\n あるいは \n0 b2 … bn gn … g2 0\n\nのように先頭に 0 が来るものは,\n普通使われる数の表し方ではないので禁止されている.\n\n J中学校の生徒であるあなたは,\n自分のクラスが勝つためにはどのように並ぶのがよいかを\n考えなければならない.\n\n 入力ファイルの1行目に正整数 n と\n1桁の整数 c(先生が持つ旗の番号)が\n1つの半角空白文字で区切られて書かれている.\nc<0 のときは,\n先生が中央に立たないことを表わす.\n\n与えられる入力は 1≦n≦10 である.\n\n 負けない並び方の順番\n\n  \n\n     b1 b2 … bn c gn … g2 g1\n または \nb1 b2 … bn gn … g2 g1\n\nを出力せよ.\n\n出力ファイルにおいては,\n出力の最後にも改行コードを入れること.\n\n入出力例\n\n入力例1\n\n1 0\n\n出力例1\n\n101\n\n入力例2\n\n1 5\n\n出力例2\n\n757\n\n入力例3\n\n3 7\n\n出力例3\n\n9957599\n\n入力例4\n\n1 -1\n\n出力例4\n\n11\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": 325, "cpu_time_ms": 1200, "memory_kb": 6184}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s060741940", "group_id": "codeNet:p00594", "input_text": "class Stack\n def initialize\n @sz = 0\n @elem = []\n end\n\n def push obj\n @elem << obj\n @sz += 1\n end\n\n # returns obj or nil if the stack is empty \n def pop\n obj = @elem.last\n @sz -= 1 if @sz > 0\n @elem = @elem[0..-2]\n obj\n end\n\n def peak\n obj = @elem.last\n obj\n end\n\n def empty?\n @sz == 0\n end\nend\n\n\ndef main\n while num = gets\n num = num.chomp.to_i\n break if num == 0\n arr = gets.chomp.split(/\\s/).collect { |x| x.to_i}\n stack = Stack.new\n stack.push arr[0]\n (1..arr.size - 1).each do |i|\n if stack.empty?\n stack.push arr[i]\n else\n elem = stack.peak\n if arr[i] == elem\n stack.push arr[i]\n else\n stack.pop\n end\n end \n end \n\n if stack.empty?\n puts \"NO COLOR\"\n else\n puts stack.peak\n end\n end \nend\n\nmain", "language": "Ruby", "metadata": {"date": 1379182137, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00594.html", "problem_id": "p00594", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00594/input.txt", "sample_output_relpath": "derived/input_output/data/p00594/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00594/Ruby/s060741940.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s060741940", "user_id": "u284474275"}, "prompt_components": {"gold_output": "NO COLOR\n5\n", "input_to_evaluate": "class Stack\n def initialize\n @sz = 0\n @elem = []\n end\n\n def push obj\n @elem << obj\n @sz += 1\n end\n\n # returns obj or nil if the stack is empty \n def pop\n obj = @elem.last\n @sz -= 1 if @sz > 0\n @elem = @elem[0..-2]\n obj\n end\n\n def peak\n obj = @elem.last\n obj\n end\n\n def empty?\n @sz == 0\n end\nend\n\n\ndef main\n while num = gets\n num = num.chomp.to_i\n break if num == 0\n arr = gets.chomp.split(/\\s/).collect { |x| x.to_i}\n stack = Stack.new\n stack.push arr[0]\n (1..arr.size - 1).each do |i|\n if stack.empty?\n stack.push arr[i]\n else\n elem = stack.peak\n if arr[i] == elem\n stack.push arr[i]\n else\n stack.pop\n end\n end \n end \n\n if stack.empty?\n puts \"NO COLOR\"\n else\n puts stack.peak\n end\n end \nend\n\nmain", "problem_context": "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", "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": 966, "cpu_time_ms": 15190, "memory_kb": 985588}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s233621852", "group_id": "codeNet:p00597", "input_text": "until (n = gets.to_i).zero?\n dp = Array.new(n / 2 + 1){0}\n dp[1] = 1\n (2 .. n / 2).each do |i| dp[i] = 3 * dp[i - 1] + 1 end\n\n result = n\n (1 ... n / 2).each do |i|\n result += 4 * dp[i]\n end\n result += 2 * dp[n / 2] if n.odd?\n p result\nend", "language": "Ruby", "metadata": {"date": 1403848108, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00597.html", "problem_id": "p00597", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00597/input.txt", "sample_output_relpath": "derived/input_output/data/p00597/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00597/Ruby/s233621852.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s233621852", "user_id": "u392015442"}, "prompt_components": {"gold_output": "1\n8\n", "input_to_evaluate": "until (n = gets.to_i).zero?\n dp = Array.new(n / 2 + 1){0}\n dp[1] = 1\n (2 .. n / 2).each do |i| dp[i] = 3 * dp[i - 1] + 1 end\n\n result = n\n (1 ... n / 2).each do |i|\n result += 4 * dp[i]\n end\n result += 2 * dp[n / 2] if n.odd?\n p result\nend", "problem_context": "Problem C: Finding the Largest Carbon Compound Given Its Longest Chain\n\nAn bydrocarbon is an organic compound which contains only carbons and hydrogens. An isomer is a compound that has the same number of carbons but different structures. Heptane, for example, is a hydrocarbon with 7 carbons. It has nine isomers. The structural formula of three are shown in Figure 1. Carbons are represented by the letter C, and bonds between carbons are represented by a straight line. In all figures, hydrogens are not represented for simplicity. Each carbon can be connected to a maximum of 4 carbons.\n\nFigure 1: These three examples of isomers of heptane have the same number of carbons but different structures.\n\nLet define a chain in an isomer as a sequence of connected carbons without branches. An isomer can have many chains of the same length. Figure 2 shows the longest chain of carbons for each of the represented isomer. Note that there can be many instances of longest chain in an isomer.\n\nFigure 2: The figures shows one instance of longest chain of carbons in each isomer. The first and the second isomers show longest chains of 5 carbons. The longest chain in the third isomer has 4 carbons.\n\nYour task is to identify the number of carbons of the largest possible carbon compound whose longest carbon chain has n (1 ≤ n ≤ 30) carbons.\n\nInput\n\nEach input contains a list of number of carbons, i.e. the length of a carbon chain.\n\nThe number of input lines is less than or equal to 30.\n\nOutput\n\nFor each number n in input, identify the number of carbons of the largest possible carbon compound whose longest carbon chain has n carbons.\n\nSample Input\n\n1\n4\n\nOutput for the Sample Input\n\n1\n8", "sample_input": "1\n4\n"}, "reference_outputs": ["1\n8\n"], "source_document_id": "p00597", "source_text": "Problem C: Finding the Largest Carbon Compound Given Its Longest Chain\n\nAn bydrocarbon is an organic compound which contains only carbons and hydrogens. An isomer is a compound that has the same number of carbons but different structures. Heptane, for example, is a hydrocarbon with 7 carbons. It has nine isomers. The structural formula of three are shown in Figure 1. Carbons are represented by the letter C, and bonds between carbons are represented by a straight line. In all figures, hydrogens are not represented for simplicity. Each carbon can be connected to a maximum of 4 carbons.\n\nFigure 1: These three examples of isomers of heptane have the same number of carbons but different structures.\n\nLet define a chain in an isomer as a sequence of connected carbons without branches. An isomer can have many chains of the same length. Figure 2 shows the longest chain of carbons for each of the represented isomer. Note that there can be many instances of longest chain in an isomer.\n\nFigure 2: The figures shows one instance of longest chain of carbons in each isomer. The first and the second isomers show longest chains of 5 carbons. The longest chain in the third isomer has 4 carbons.\n\nYour task is to identify the number of carbons of the largest possible carbon compound whose longest carbon chain has n (1 ≤ n ≤ 30) carbons.\n\nInput\n\nEach input contains a list of number of carbons, i.e. the length of a carbon chain.\n\nThe number of input lines is less than or equal to 30.\n\nOutput\n\nFor each number n in input, identify the number of carbons of the largest possible carbon compound whose longest carbon chain has n carbons.\n\nSample Input\n\n1\n4\n\nOutput for the Sample Input\n\n1\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": 250, "cpu_time_ms": 10, "memory_kb": 6096}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s893155173", "group_id": "codeNet:p00633", "input_text": "include Math\n\ndef inc(arr,x2,y2,r2)\n\tarr.each{|cir|\n\t\tx1,y1,r1 = cir\n\t\td2 = ((x1-x2)**2 + (y1-y2)**2)\n\t\tif (((r1-r2)**2) >= d2 ) then\n\t\t\tif r1 < r2 then\n\t\t\t\tarr.delete(cir)\n\t\t\t\tarr.push([x2,y2,r2])\n\t\t\t\treturn\n\t\t\telse\n\t\t\t\treturn\n\t\t\tend\n\t\tend\n\t}\n\tarr.push([x2,y2,r2])\nend\n\ndef calc(arr)\n\tans = 0\n\twhile(!arr.empty?) do\n\t\tcir1 = arr.pop\n\t\tx1,y1,r1 = cir1\n\t\tans += r1 * 2 * PI\n\t\tarr.each{|cir2|\n\t\t\tx2,y2,r2 = cir2\n\t\t\td2 = ((x1-x2)**2 + (y1-y2)**2)\n\t\t\tif ((r1 - r2) ** 2) < d2 and (d2 < ((r1 + r2) ** 2)) then\n\t\t\t\td = sqrt(d2)\n\t\t\t\tr12 = r1**2\n\t\t\t\tr22 = r2**2\n\t\t\t\ttheta1 = Math.acos((d2+r12-r22)/(2*d*r1))\n\t\t\t\ttheta2 = Math.acos((d2-r12+r22)/(2*d*r2))\n\t\t\t\tans -= (r1 * theta1 + r2 * theta2) * 2\n\t\t\tend\n\t\t}\n\tend\n\treturn ans\nend\n\nloop do\n\tn = gets.to_i\n\tif (n == 0) then\n\t\texit\n\tend\n\t\n\tarr = []\n\tsum = 0\n\tn.times{|i|\t\n\t\tx,y,r = gets.chomp.split.map(&:to_i)\n\t\tinc(arr,x,y,r)\n\t}\n\n\tp calc(arr)\nend", "language": "Ruby", "metadata": {"date": 1400142236, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00633.html", "problem_id": "p00633", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00633/input.txt", "sample_output_relpath": "derived/input_output/data/p00633/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00633/Ruby/s893155173.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s893155173", "user_id": "u533425205"}, "prompt_components": {"gold_output": "39.664699289572\n45.627024663706\n", "input_to_evaluate": "include Math\n\ndef inc(arr,x2,y2,r2)\n\tarr.each{|cir|\n\t\tx1,y1,r1 = cir\n\t\td2 = ((x1-x2)**2 + (y1-y2)**2)\n\t\tif (((r1-r2)**2) >= d2 ) then\n\t\t\tif r1 < r2 then\n\t\t\t\tarr.delete(cir)\n\t\t\t\tarr.push([x2,y2,r2])\n\t\t\t\treturn\n\t\t\telse\n\t\t\t\treturn\n\t\t\tend\n\t\tend\n\t}\n\tarr.push([x2,y2,r2])\nend\n\ndef calc(arr)\n\tans = 0\n\twhile(!arr.empty?) do\n\t\tcir1 = arr.pop\n\t\tx1,y1,r1 = cir1\n\t\tans += r1 * 2 * PI\n\t\tarr.each{|cir2|\n\t\t\tx2,y2,r2 = cir2\n\t\t\td2 = ((x1-x2)**2 + (y1-y2)**2)\n\t\t\tif ((r1 - r2) ** 2) < d2 and (d2 < ((r1 + r2) ** 2)) then\n\t\t\t\td = sqrt(d2)\n\t\t\t\tr12 = r1**2\n\t\t\t\tr22 = r2**2\n\t\t\t\ttheta1 = Math.acos((d2+r12-r22)/(2*d*r1))\n\t\t\t\ttheta2 = Math.acos((d2-r12+r22)/(2*d*r2))\n\t\t\t\tans -= (r1 * theta1 + r2 * theta2) * 2\n\t\t\tend\n\t\t}\n\tend\n\treturn ans\nend\n\nloop do\n\tn = gets.to_i\n\tif (n == 0) then\n\t\texit\n\tend\n\t\n\tarr = []\n\tsum = 0\n\tn.times{|i|\t\n\t\tx,y,r = gets.chomp.split.map(&:to_i)\n\t\tinc(arr,x,y,r)\n\t}\n\n\tp calc(arr)\nend", "problem_context": "Problem 07: Crop Circle\n\nアルゼンチンの広大な農地に突如ミステリーサークルが出没した。ミステリーサークルは重なっているもの、ポツンとあるもの、大きいもの、小さいものと合計 n 個確認された。\n\nあるミステリーハンターが空中からミステリーサークルの全体像を撮影しようと試みたところ、各円の輪郭がはっきりしていなかったため、映像にその美しい模様を映し出すことが難しいことが分かった。\n\nそこで、そのミステリーハンターは輪郭に沿って特殊素材の紐を設置し、輪郭を強調する提案をした。\n\n紐を設置する部分は、あるミステリーサークルの円周上で、他のどのミステリーサークルにも含まれない部分である。\n\n撮影隊は必要な紐の長さを計測するために、プログラムの作成をあなたに依頼した。各ミステリーサークルの中心座標と半径を入力し、設置する紐の長さを報告するプログラムを作成せよ。\n\n参考として入出力例の1つ目と2つ目のケースをそれぞれ図1、図2に示す。紐の部分が太い線で示されている。\n\n図1\n\n図2\n\nInput\n\n入力として複数のデータセットが与えられる。各データセットは以下の形式で与えられる:\n\nn (ミステリーサークルの数:整数)\n\nx1 y1 r1  (1 個目のサークルの中心座標と半径:空白区切りの実数)\n\nx2 y2 r2  (2 個目のサークルの中心座標と半径:空白区切りの実数)\n\n.\n\n.\n\nxn yn rn  (n 個目のサークルの中心座標と半径:空白区切りの実数)\n\nn が 0 のとき、入力の終わりを示す。\n\nOutput\n\n各データセットに対して、紐の長さを1行に出力せよ。出力は 0.000001 以下の誤差を含んでもよい。\n\nConstraints\n\nn ≤ 100\n\n-1000 ≤ xi, yi ≤ 1000\n\n0 < ri ≤ 100\n\nSample Input\n\n4\n6 4 2\n4 7 3\n7 10 3\n13 6 1\n4\n7 4 2\n4 7 3\n7 10 3\n11 6 3\n0\n\nOutput for the Sample Input\n\n39.664699289572\n45.627024663706", "sample_input": "4\n6 4 2\n4 7 3\n7 10 3\n13 6 1\n4\n7 4 2\n4 7 3\n7 10 3\n11 6 3\n0\n"}, "reference_outputs": ["39.664699289572\n45.627024663706\n"], "source_document_id": "p00633", "source_text": "Problem 07: Crop Circle\n\nアルゼンチンの広大な農地に突如ミステリーサークルが出没した。ミステリーサークルは重なっているもの、ポツンとあるもの、大きいもの、小さいものと合計 n 個確認された。\n\nあるミステリーハンターが空中からミステリーサークルの全体像を撮影しようと試みたところ、各円の輪郭がはっきりしていなかったため、映像にその美しい模様を映し出すことが難しいことが分かった。\n\nそこで、そのミステリーハンターは輪郭に沿って特殊素材の紐を設置し、輪郭を強調する提案をした。\n\n紐を設置する部分は、あるミステリーサークルの円周上で、他のどのミステリーサークルにも含まれない部分である。\n\n撮影隊は必要な紐の長さを計測するために、プログラムの作成をあなたに依頼した。各ミステリーサークルの中心座標と半径を入力し、設置する紐の長さを報告するプログラムを作成せよ。\n\n参考として入出力例の1つ目と2つ目のケースをそれぞれ図1、図2に示す。紐の部分が太い線で示されている。\n\n図1\n\n図2\n\nInput\n\n入力として複数のデータセットが与えられる。各データセットは以下の形式で与えられる:\n\nn (ミステリーサークルの数:整数)\n\nx1 y1 r1  (1 個目のサークルの中心座標と半径:空白区切りの実数)\n\nx2 y2 r2  (2 個目のサークルの中心座標と半径:空白区切りの実数)\n\n.\n\n.\n\nxn yn rn  (n 個目のサークルの中心座標と半径:空白区切りの実数)\n\nn が 0 のとき、入力の終わりを示す。\n\nOutput\n\n各データセットに対して、紐の長さを1行に出力せよ。出力は 0.000001 以下の誤差を含んでもよい。\n\nConstraints\n\nn ≤ 100\n\n-1000 ≤ xi, yi ≤ 1000\n\n0 < ri ≤ 100\n\nSample Input\n\n4\n6 4 2\n4 7 3\n7 10 3\n13 6 1\n4\n7 4 2\n4 7 3\n7 10 3\n11 6 3\n0\n\nOutput for the Sample Input\n\n39.664699289572\n45.627024663706", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 886, "cpu_time_ms": 30, "memory_kb": 6200}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s703602034", "group_id": "codeNet:p00710", "input_text": "loop{\n\tn,r = gets.split(nil)\n\tn = n.to_i()\n\tr = r.to_i()\n\tif ((n==0) and (r==0)) then\n\t\tbreak\n\tend\n\t\n\tarr = [*1..n]\n\tarr.reverse!\n\t\n\tfor i in 1..r do\n\t\tp,c =gets.split.map(&:to_i)\n\t\t\n\t\tarr2 = arr[p-1..p+c-2]\n\t\tif (p == 1) then\n\t\t\tarr3 =[]\n\t\telse\n\t\t\tarr3 = arr[0..p-2]\n\t\tend\n\t\t\n\t\tarr = arr2+arr3+arr[p+c-1..n-1]\n\t\t\n\tend\n\tp arr[0]\n}", "language": "Ruby", "metadata": {"date": 1399859048, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00710.html", "problem_id": "p00710", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00710/input.txt", "sample_output_relpath": "derived/input_output/data/p00710/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00710/Ruby/s703602034.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s703602034", "user_id": "u533425205"}, "prompt_components": {"gold_output": "4\n4\n", "input_to_evaluate": "loop{\n\tn,r = gets.split(nil)\n\tn = n.to_i()\n\tr = r.to_i()\n\tif ((n==0) and (r==0)) then\n\t\tbreak\n\tend\n\t\n\tarr = [*1..n]\n\tarr.reverse!\n\t\n\tfor i in 1..r do\n\t\tp,c =gets.split.map(&:to_i)\n\t\t\n\t\tarr2 = arr[p-1..p+c-2]\n\t\tif (p == 1) then\n\t\t\tarr3 =[]\n\t\telse\n\t\t\tarr3 = arr[0..p-2]\n\t\tend\n\t\t\n\t\tarr = arr2+arr3+arr[p+c-1..n-1]\n\t\t\n\tend\n\tp arr[0]\n}", "problem_context": "Problem A: Hanafuda Shuffle\n\nThere are a number of ways to shuffle a deck of cards. Hanafuda\nshuffling for Japanese card game 'Hanafuda' is one such example.\nThe following is how to perform Hanafuda shuffling.\n\nThere is a deck of n cards. Starting from the p-th card\nfrom the top of the deck, c cards are pulled out\nand put on the top of the deck, as shown in Figure 1.\nThis operation, called a cutting operation, is repeated.\n\nWrite a program that simulates Hanafuda shuffling and answers which\ncard will be finally placed on the top of the deck.\n\nFigure 1: Cutting operation\n\nInput\n\nThe input consists of multiple data sets.\nEach data set starts with a line containing two positive integers n\n(1 <= n <= 50) and r (1 <= r <= 50); n and\nr are the number of cards in the deck and the number of cutting\noperations, respectively.\n\nThere are r more lines in the data set, each of which\nrepresents a cutting operation. These cutting operations\nare performed in the listed order.\nEach line contains two positive integers p and c\n(p + c <= n + 1).\nStarting from the p-th card from the top of the deck, c\ncards should be pulled out and put on the top.\n\nThe end of the input is indicated by a line which contains two zeros.\n\nEach input line contains exactly two integers separated by a space\ncharacter.\nThere are no other characters in the line.\n\nOutput\n\nFor each data set in the input, your program\nshould write the number of the top card after the shuffle.\nAssume that at the beginning the cards\nare numbered from 1 to n, from the bottom to the top.\nEach number should be written in a separate line\nwithout any superfluous characters such as leading or following spaces.\n\nSample Input\n\n5 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 3\n0 0\n\nOutput for the Sample Input\n\n4\n4", "sample_input": "5 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 3\n0 0\n"}, "reference_outputs": ["4\n4\n"], "source_document_id": "p00710", "source_text": "Problem A: Hanafuda Shuffle\n\nThere are a number of ways to shuffle a deck of cards. Hanafuda\nshuffling for Japanese card game 'Hanafuda' is one such example.\nThe following is how to perform Hanafuda shuffling.\n\nThere is a deck of n cards. Starting from the p-th card\nfrom the top of the deck, c cards are pulled out\nand put on the top of the deck, as shown in Figure 1.\nThis operation, called a cutting operation, is repeated.\n\nWrite a program that simulates Hanafuda shuffling and answers which\ncard will be finally placed on the top of the deck.\n\nFigure 1: Cutting operation\n\nInput\n\nThe input consists of multiple data sets.\nEach data set starts with a line containing two positive integers n\n(1 <= n <= 50) and r (1 <= r <= 50); n and\nr are the number of cards in the deck and the number of cutting\noperations, respectively.\n\nThere are r more lines in the data set, each of which\nrepresents a cutting operation. These cutting operations\nare performed in the listed order.\nEach line contains two positive integers p and c\n(p + c <= n + 1).\nStarting from the p-th card from the top of the deck, c\ncards should be pulled out and put on the top.\n\nThe end of the input is indicated by a line which contains two zeros.\n\nEach input line contains exactly two integers separated by a space\ncharacter.\nThere are no other characters in the line.\n\nOutput\n\nFor each data set in the input, your program\nshould write the number of the top card after the shuffle.\nAssume that at the beginning the cards\nare numbered from 1 to n, from the bottom to the top.\nEach number should be written in a separate line\nwithout any superfluous characters such as leading or following spaces.\n\nSample Input\n\n5 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 3\n0 0\n\nOutput for the Sample Input\n\n4\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 330, "cpu_time_ms": 30, "memory_kb": 6136}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s735901222", "group_id": "codeNet:p00750", "input_text": "require 'set'\n \nclass Arrow\n attr_reader :source, :sink, :label\n\n def initialize(source, sink, label)\n @source = source\n @sink = sink\n @label = label\n end\nend\n\ndef push(queue, key, value)\n size = queue.size\n index = queue.index{|target, _| target >= key} || size\n return queue[index][1] if index < size && queue[index][0] == key\n \n return nil if index > 0 && !key.start_with?(queue[index - 1][0])\n queue.slice!(index..-1) if index < size && !queue[index][0].start_with?(key)\n\n queue.insert(index, [key, value])\n value\nend\n\ndef calc(n, arrows, start, goal)\n ins = Array.new(n){[]}\n arrows.each do |arrow|\n ins[arrow.sink] << arrow.source\n end\n\n reachable_from = {}\n stack = [goal]\n until stack.empty?\n node = stack.pop\n reachable_from[node] = true\n ins[node].each do |source|\n stack << source unless reachable_from[source]\n end\n end\n\n return nil unless reachable_from[start]\n arrows.select!{|arrow| reachable_from[arrow.sink]}\n\n outs = Array.new(n){[]}\n arrows.each do |arrow|\n outs[arrow.source] << arrow\n end\n\n max = n * arrows.map{|arrow| arrow.label.size}.max\n\n queue = [['', {start => true}]]\n until queue.empty?\n spell, map = queue.shift\n return spell if map[goal]\n\n return nil if spell.size > max\n\n map.each do |node, _|\n outs[node].each do |arrow|\n t = push(queue, spell + arrow.label, {})\n t[arrow.sink] = true if t\n end\n end\n end\n nil\nend\n\nloop do\n n, a, s, g = gets.split.map(&:to_i)\n break if n == 0\n\n arrows = (0...a).map do |i|\n x, y, lab = gets.split\n Arrow.new(x.to_i, y.to_i, lab)\n end\n\n puts calc(n, arrows, s, g) || 'NO'\nend", "language": "Ruby", "metadata": {"date": 1492253059, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00750.html", "problem_id": "p00750", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00750/input.txt", "sample_output_relpath": "derived/input_output/data/p00750/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00750/Ruby/s735901222.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s735901222", "user_id": "u620112474"}, "prompt_components": {"gold_output": "abracadabra\nNO\nopqr\nNO\n", "input_to_evaluate": "require 'set'\n \nclass Arrow\n attr_reader :source, :sink, :label\n\n def initialize(source, sink, label)\n @source = source\n @sink = sink\n @label = label\n end\nend\n\ndef push(queue, key, value)\n size = queue.size\n index = queue.index{|target, _| target >= key} || size\n return queue[index][1] if index < size && queue[index][0] == key\n \n return nil if index > 0 && !key.start_with?(queue[index - 1][0])\n queue.slice!(index..-1) if index < size && !queue[index][0].start_with?(key)\n\n queue.insert(index, [key, value])\n value\nend\n\ndef calc(n, arrows, start, goal)\n ins = Array.new(n){[]}\n arrows.each do |arrow|\n ins[arrow.sink] << arrow.source\n end\n\n reachable_from = {}\n stack = [goal]\n until stack.empty?\n node = stack.pop\n reachable_from[node] = true\n ins[node].each do |source|\n stack << source unless reachable_from[source]\n end\n end\n\n return nil unless reachable_from[start]\n arrows.select!{|arrow| reachable_from[arrow.sink]}\n\n outs = Array.new(n){[]}\n arrows.each do |arrow|\n outs[arrow.source] << arrow\n end\n\n max = n * arrows.map{|arrow| arrow.label.size}.max\n\n queue = [['', {start => true}]]\n until queue.empty?\n spell, map = queue.shift\n return spell if map[goal]\n\n return nil if spell.size > max\n\n map.each do |node, _|\n outs[node].each do |arrow|\n t = push(queue, spell + arrow.label, {})\n t[arrow.sink] = true if t\n end\n end\n end\n nil\nend\n\nloop do\n n, a, s, g = gets.split.map(&:to_i)\n break if n == 0\n\n arrows = (0...a).map do |i|\n x, y, lab = gets.split\n Arrow.new(x.to_i, y.to_i, lab)\n end\n\n puts calc(n, arrows, s, g) || 'NO'\nend", "problem_context": "Problem E: The Most Powerful Spell\n\nLong long ago, there lived a wizard who invented a lot of \"magical patterns.\"\nIn a room where one of his magical patterns is drawn on the floor,\nanyone can use magic by casting magic spells!\nThe set of spells usable in the room depends on the drawn magical pattern.\nYour task is to compute, for each given magical pattern,\nthe most powerful spell enabled by the pattern.\n\nA spell is a string of lowercase letters.\nAmong the spells, lexicographically earlier one is more powerful.\nNote that a string w is defined to be lexicographically earlier than a string u\nwhen w has smaller letter\nin the order a 1 --\"cada\"--> 3 --\"bra\"--> 2.\n\nAnother example is \"oilcadabraketdadabra\", obtained from the path\n\n    \n0 --\"oil\"--> 1 --\"cada\"--> 3 --\"bra\"--> 2 --\"ket\"--> 3 --\"da\"--> 3 --\"da\"--> 3 --\"bra\"--> 2.\n\nThe spell \"abracadabra\" is more powerful than \"oilcadabraketdadabra\"\nbecause it is lexicographically earlier.\nIn fact, no other spell enabled by the magical pattern is more powerful than \"abracadabra\".\nThus \"abracadabra\" is the answer you have to compute.\n\nWhen you cannot determine the most powerful spell, please answer \"NO\".\nThere are two such cases.\nOne is the case when no path exists from the star node to the gold node.\nThe other case is when for every usable spell there always exist more powerful spells.\nThe situation is exemplified in the following figure:\n\"ab\" is more powerful than \"b\", and \"aab\" is more powerful than \"ab\", and so on.\nFor any spell, by prepending \"a\", we obtain a lexicographically earlier\n(hence more powerful) spell.\n\nInput\n\nThe input consists of at most 150 datasets.\nEach dataset is formatted as follows.\n\nn a s g\n\nx1 y1 lab1\n\nx2 y2 lab2\n\n...\n\nxa ya laba\n\nThe first line of a dataset contains four integers.\nn is the number of the nodes, and a is the number of the arrows.\nThe numbers s and g indicate the star node and the gold node, respectively.\nThen a lines describing the arrows follow.\nEach line consists of two integers and one string.\nThe line \"xi yi labi\" represents\nan arrow from the node xi to the node yi\nwith the associated label labi .\nValues in the dataset satisfy:\n2 ≤ n ≤ 40,\n0 ≤ a ≤ 400,\n0 ≤ s, g, xi , yi < n ,\ns ≠g,\nand\nlabi is a string of 1 to 6 lowercase letters.\nBe careful that there may be self-connecting arrows (i.e., xi = yi ),\nand multiple arrows connecting the same pair of nodes\n(i.e., xi = xj and yi = yj\nfor some i ≠ j ).\n\nThe end of the input is indicated by a line containing four zeros.\n\nOutput\n\nFor each dataset, output a line containing the most powerful spell for the magical pattern.\nIf there does not exist such a spell, output \"NO\" (without quotes).\nEach line should not have any other characters.\n\nSample Input\n\n4 7 0 2\n0 1 abra\n0 1 oil\n2 0 ket\n1 3 cada\n3 3 da\n3 2 bra\n2 3 ket\n2 2 0 1\n0 0 a\n0 1 b\n5 6 3 0\n3 1 op\n3 2 op\n3 4 opq\n1 0 st\n2 0 qr\n4 0 r\n2 1 0 1\n1 1 loooop\n0 0 0 0\n\nOutput for the Sample Input\n\nabracadabra\nNO\nopqr\nNO", "sample_input": "4 7 0 2\n0 1 abra\n0 1 oil\n2 0 ket\n1 3 cada\n3 3 da\n3 2 bra\n2 3 ket\n2 2 0 1\n0 0 a\n0 1 b\n5 6 3 0\n3 1 op\n3 2 op\n3 4 opq\n1 0 st\n2 0 qr\n4 0 r\n2 1 0 1\n1 1 loooop\n0 0 0 0\n"}, "reference_outputs": ["abracadabra\nNO\nopqr\nNO\n"], "source_document_id": "p00750", "source_text": "Problem E: The Most Powerful Spell\n\nLong long ago, there lived a wizard who invented a lot of \"magical patterns.\"\nIn a room where one of his magical patterns is drawn on the floor,\nanyone can use magic by casting magic spells!\nThe set of spells usable in the room depends on the drawn magical pattern.\nYour task is to compute, for each given magical pattern,\nthe most powerful spell enabled by the pattern.\n\nA spell is a string of lowercase letters.\nAmong the spells, lexicographically earlier one is more powerful.\nNote that a string w is defined to be lexicographically earlier than a string u\nwhen w has smaller letter\nin the order a 1 --\"cada\"--> 3 --\"bra\"--> 2.\n\nAnother example is \"oilcadabraketdadabra\", obtained from the path\n\n    \n0 --\"oil\"--> 1 --\"cada\"--> 3 --\"bra\"--> 2 --\"ket\"--> 3 --\"da\"--> 3 --\"da\"--> 3 --\"bra\"--> 2.\n\nThe spell \"abracadabra\" is more powerful than \"oilcadabraketdadabra\"\nbecause it is lexicographically earlier.\nIn fact, no other spell enabled by the magical pattern is more powerful than \"abracadabra\".\nThus \"abracadabra\" is the answer you have to compute.\n\nWhen you cannot determine the most powerful spell, please answer \"NO\".\nThere are two such cases.\nOne is the case when no path exists from the star node to the gold node.\nThe other case is when for every usable spell there always exist more powerful spells.\nThe situation is exemplified in the following figure:\n\"ab\" is more powerful than \"b\", and \"aab\" is more powerful than \"ab\", and so on.\nFor any spell, by prepending \"a\", we obtain a lexicographically earlier\n(hence more powerful) spell.\n\nInput\n\nThe input consists of at most 150 datasets.\nEach dataset is formatted as follows.\n\nn a s g\n\nx1 y1 lab1\n\nx2 y2 lab2\n\n...\n\nxa ya laba\n\nThe first line of a dataset contains four integers.\nn is the number of the nodes, and a is the number of the arrows.\nThe numbers s and g indicate the star node and the gold node, respectively.\nThen a lines describing the arrows follow.\nEach line consists of two integers and one string.\nThe line \"xi yi labi\" represents\nan arrow from the node xi to the node yi\nwith the associated label labi .\nValues in the dataset satisfy:\n2 ≤ n ≤ 40,\n0 ≤ a ≤ 400,\n0 ≤ s, g, xi , yi < n ,\ns ≠g,\nand\nlabi is a string of 1 to 6 lowercase letters.\nBe careful that there may be self-connecting arrows (i.e., xi = yi ),\nand multiple arrows connecting the same pair of nodes\n(i.e., xi = xj and yi = yj\nfor some i ≠ j ).\n\nThe end of the input is indicated by a line containing four zeros.\n\nOutput\n\nFor each dataset, output a line containing the most powerful spell for the magical pattern.\nIf there does not exist such a spell, output \"NO\" (without quotes).\nEach line should not have any other characters.\n\nSample Input\n\n4 7 0 2\n0 1 abra\n0 1 oil\n2 0 ket\n1 3 cada\n3 3 da\n3 2 bra\n2 3 ket\n2 2 0 1\n0 0 a\n0 1 b\n5 6 3 0\n3 1 op\n3 2 op\n3 4 opq\n1 0 st\n2 0 qr\n4 0 r\n2 1 0 1\n1 1 loooop\n0 0 0 0\n\nOutput for the Sample Input\n\nabracadabra\nNO\nopqr\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": 1652, "cpu_time_ms": 230, "memory_kb": 9900}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s998624789", "group_id": "codeNet:p00750", "input_text": "\nclass Entry\n attr_reader :spell, :nodes\n\n def initialize(spell, nodes)\n @spell = spell\n @nodes = nodes\n end\nend\n \nclass Arrow\n attr_reader :source, :sink, :label\n\n def initialize(source, sink, label)\n @source = source\n @sink = sink\n @label = label\n end\nend\n\ndef push(queue, spell)\n size = queue.size\n index = queue.index{|entry| entry.spell >= spell} || size\n return queue[index].nodes if index < size && queue[index].spell == spell\n\n return nil if index > 0 && !spell.start_with?(queue[index - 1].spell)\n queue.slice!(index..-1) if index < size && !queue[index].spell.start_with?(spell)\n\n nodes = {}\n queue.insert(index, Entry.new(spell, nodes))\n nodes\nend\n\ndef calc(n, arrows, start, goal)\n ins = Array.new(n){[]}\n arrows.each do |arrow|\n ins[arrow.sink] << arrow.source\n end\n\n reachable_from = {}\n stack = [goal]\n until stack.empty?\n node = stack.pop\n reachable_from[node] = true\n ins[node].each do |source|\n stack << source unless reachable_from[source]\n end\n end\n\n return nil unless reachable_from[start]\n arrows.select!{|arrow| reachable_from[arrow.sink]}\n\n outs = Array.new(n){[]}\n arrows.each do |arrow|\n outs[arrow.source] << arrow\n end\n\n limit = n * arrows.map{|arrow| arrow.label.size}.max\n\n queue = [Entry.new('', {start => true})]\n until queue.empty?\n entry = queue.shift\n spell = entry.spell\n nodes = entry.nodes\n return spell if nodes[goal]\n return nil if spell.size > limit\n\n nodes.each do |node, _|\n outs[node].each do |arrow|\n new_nodes = push(queue, spell + arrow.label)\n new_nodes[arrow.sink] = true if new_nodes\n end\n end\n end\n nil\nend\n\nloop do\n n, a, s, g = gets.split.map(&:to_i)\n break if n == 0\n\n arrows = (0...a).map do |i|\n x, y, lab = gets.split\n Arrow.new(x.to_i, y.to_i, lab)\n end\n\n puts calc(n, arrows, s, g) || 'NO'\nend", "language": "Ruby", "metadata": {"date": 1492253702, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00750.html", "problem_id": "p00750", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00750/input.txt", "sample_output_relpath": "derived/input_output/data/p00750/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00750/Ruby/s998624789.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s998624789", "user_id": "u620112474"}, "prompt_components": {"gold_output": "abracadabra\nNO\nopqr\nNO\n", "input_to_evaluate": "\nclass Entry\n attr_reader :spell, :nodes\n\n def initialize(spell, nodes)\n @spell = spell\n @nodes = nodes\n end\nend\n \nclass Arrow\n attr_reader :source, :sink, :label\n\n def initialize(source, sink, label)\n @source = source\n @sink = sink\n @label = label\n end\nend\n\ndef push(queue, spell)\n size = queue.size\n index = queue.index{|entry| entry.spell >= spell} || size\n return queue[index].nodes if index < size && queue[index].spell == spell\n\n return nil if index > 0 && !spell.start_with?(queue[index - 1].spell)\n queue.slice!(index..-1) if index < size && !queue[index].spell.start_with?(spell)\n\n nodes = {}\n queue.insert(index, Entry.new(spell, nodes))\n nodes\nend\n\ndef calc(n, arrows, start, goal)\n ins = Array.new(n){[]}\n arrows.each do |arrow|\n ins[arrow.sink] << arrow.source\n end\n\n reachable_from = {}\n stack = [goal]\n until stack.empty?\n node = stack.pop\n reachable_from[node] = true\n ins[node].each do |source|\n stack << source unless reachable_from[source]\n end\n end\n\n return nil unless reachable_from[start]\n arrows.select!{|arrow| reachable_from[arrow.sink]}\n\n outs = Array.new(n){[]}\n arrows.each do |arrow|\n outs[arrow.source] << arrow\n end\n\n limit = n * arrows.map{|arrow| arrow.label.size}.max\n\n queue = [Entry.new('', {start => true})]\n until queue.empty?\n entry = queue.shift\n spell = entry.spell\n nodes = entry.nodes\n return spell if nodes[goal]\n return nil if spell.size > limit\n\n nodes.each do |node, _|\n outs[node].each do |arrow|\n new_nodes = push(queue, spell + arrow.label)\n new_nodes[arrow.sink] = true if new_nodes\n end\n end\n end\n nil\nend\n\nloop do\n n, a, s, g = gets.split.map(&:to_i)\n break if n == 0\n\n arrows = (0...a).map do |i|\n x, y, lab = gets.split\n Arrow.new(x.to_i, y.to_i, lab)\n end\n\n puts calc(n, arrows, s, g) || 'NO'\nend", "problem_context": "Problem E: The Most Powerful Spell\n\nLong long ago, there lived a wizard who invented a lot of \"magical patterns.\"\nIn a room where one of his magical patterns is drawn on the floor,\nanyone can use magic by casting magic spells!\nThe set of spells usable in the room depends on the drawn magical pattern.\nYour task is to compute, for each given magical pattern,\nthe most powerful spell enabled by the pattern.\n\nA spell is a string of lowercase letters.\nAmong the spells, lexicographically earlier one is more powerful.\nNote that a string w is defined to be lexicographically earlier than a string u\nwhen w has smaller letter\nin the order a 1 --\"cada\"--> 3 --\"bra\"--> 2.\n\nAnother example is \"oilcadabraketdadabra\", obtained from the path\n\n    \n0 --\"oil\"--> 1 --\"cada\"--> 3 --\"bra\"--> 2 --\"ket\"--> 3 --\"da\"--> 3 --\"da\"--> 3 --\"bra\"--> 2.\n\nThe spell \"abracadabra\" is more powerful than \"oilcadabraketdadabra\"\nbecause it is lexicographically earlier.\nIn fact, no other spell enabled by the magical pattern is more powerful than \"abracadabra\".\nThus \"abracadabra\" is the answer you have to compute.\n\nWhen you cannot determine the most powerful spell, please answer \"NO\".\nThere are two such cases.\nOne is the case when no path exists from the star node to the gold node.\nThe other case is when for every usable spell there always exist more powerful spells.\nThe situation is exemplified in the following figure:\n\"ab\" is more powerful than \"b\", and \"aab\" is more powerful than \"ab\", and so on.\nFor any spell, by prepending \"a\", we obtain a lexicographically earlier\n(hence more powerful) spell.\n\nInput\n\nThe input consists of at most 150 datasets.\nEach dataset is formatted as follows.\n\nn a s g\n\nx1 y1 lab1\n\nx2 y2 lab2\n\n...\n\nxa ya laba\n\nThe first line of a dataset contains four integers.\nn is the number of the nodes, and a is the number of the arrows.\nThe numbers s and g indicate the star node and the gold node, respectively.\nThen a lines describing the arrows follow.\nEach line consists of two integers and one string.\nThe line \"xi yi labi\" represents\nan arrow from the node xi to the node yi\nwith the associated label labi .\nValues in the dataset satisfy:\n2 ≤ n ≤ 40,\n0 ≤ a ≤ 400,\n0 ≤ s, g, xi , yi < n ,\ns ≠g,\nand\nlabi is a string of 1 to 6 lowercase letters.\nBe careful that there may be self-connecting arrows (i.e., xi = yi ),\nand multiple arrows connecting the same pair of nodes\n(i.e., xi = xj and yi = yj\nfor some i ≠ j ).\n\nThe end of the input is indicated by a line containing four zeros.\n\nOutput\n\nFor each dataset, output a line containing the most powerful spell for the magical pattern.\nIf there does not exist such a spell, output \"NO\" (without quotes).\nEach line should not have any other characters.\n\nSample Input\n\n4 7 0 2\n0 1 abra\n0 1 oil\n2 0 ket\n1 3 cada\n3 3 da\n3 2 bra\n2 3 ket\n2 2 0 1\n0 0 a\n0 1 b\n5 6 3 0\n3 1 op\n3 2 op\n3 4 opq\n1 0 st\n2 0 qr\n4 0 r\n2 1 0 1\n1 1 loooop\n0 0 0 0\n\nOutput for the Sample Input\n\nabracadabra\nNO\nopqr\nNO", "sample_input": "4 7 0 2\n0 1 abra\n0 1 oil\n2 0 ket\n1 3 cada\n3 3 da\n3 2 bra\n2 3 ket\n2 2 0 1\n0 0 a\n0 1 b\n5 6 3 0\n3 1 op\n3 2 op\n3 4 opq\n1 0 st\n2 0 qr\n4 0 r\n2 1 0 1\n1 1 loooop\n0 0 0 0\n"}, "reference_outputs": ["abracadabra\nNO\nopqr\nNO\n"], "source_document_id": "p00750", "source_text": "Problem E: The Most Powerful Spell\n\nLong long ago, there lived a wizard who invented a lot of \"magical patterns.\"\nIn a room where one of his magical patterns is drawn on the floor,\nanyone can use magic by casting magic spells!\nThe set of spells usable in the room depends on the drawn magical pattern.\nYour task is to compute, for each given magical pattern,\nthe most powerful spell enabled by the pattern.\n\nA spell is a string of lowercase letters.\nAmong the spells, lexicographically earlier one is more powerful.\nNote that a string w is defined to be lexicographically earlier than a string u\nwhen w has smaller letter\nin the order a 1 --\"cada\"--> 3 --\"bra\"--> 2.\n\nAnother example is \"oilcadabraketdadabra\", obtained from the path\n\n    \n0 --\"oil\"--> 1 --\"cada\"--> 3 --\"bra\"--> 2 --\"ket\"--> 3 --\"da\"--> 3 --\"da\"--> 3 --\"bra\"--> 2.\n\nThe spell \"abracadabra\" is more powerful than \"oilcadabraketdadabra\"\nbecause it is lexicographically earlier.\nIn fact, no other spell enabled by the magical pattern is more powerful than \"abracadabra\".\nThus \"abracadabra\" is the answer you have to compute.\n\nWhen you cannot determine the most powerful spell, please answer \"NO\".\nThere are two such cases.\nOne is the case when no path exists from the star node to the gold node.\nThe other case is when for every usable spell there always exist more powerful spells.\nThe situation is exemplified in the following figure:\n\"ab\" is more powerful than \"b\", and \"aab\" is more powerful than \"ab\", and so on.\nFor any spell, by prepending \"a\", we obtain a lexicographically earlier\n(hence more powerful) spell.\n\nInput\n\nThe input consists of at most 150 datasets.\nEach dataset is formatted as follows.\n\nn a s g\n\nx1 y1 lab1\n\nx2 y2 lab2\n\n...\n\nxa ya laba\n\nThe first line of a dataset contains four integers.\nn is the number of the nodes, and a is the number of the arrows.\nThe numbers s and g indicate the star node and the gold node, respectively.\nThen a lines describing the arrows follow.\nEach line consists of two integers and one string.\nThe line \"xi yi labi\" represents\nan arrow from the node xi to the node yi\nwith the associated label labi .\nValues in the dataset satisfy:\n2 ≤ n ≤ 40,\n0 ≤ a ≤ 400,\n0 ≤ s, g, xi , yi < n ,\ns ≠g,\nand\nlabi is a string of 1 to 6 lowercase letters.\nBe careful that there may be self-connecting arrows (i.e., xi = yi ),\nand multiple arrows connecting the same pair of nodes\n(i.e., xi = xj and yi = yj\nfor some i ≠ j ).\n\nThe end of the input is indicated by a line containing four zeros.\n\nOutput\n\nFor each dataset, output a line containing the most powerful spell for the magical pattern.\nIf there does not exist such a spell, output \"NO\" (without quotes).\nEach line should not have any other characters.\n\nSample Input\n\n4 7 0 2\n0 1 abra\n0 1 oil\n2 0 ket\n1 3 cada\n3 3 da\n3 2 bra\n2 3 ket\n2 2 0 1\n0 0 a\n0 1 b\n5 6 3 0\n3 1 op\n3 2 op\n3 4 opq\n1 0 st\n2 0 qr\n4 0 r\n2 1 0 1\n1 1 loooop\n0 0 0 0\n\nOutput for the Sample Input\n\nabracadabra\nNO\nopqr\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": 1877, "cpu_time_ms": 220, "memory_kb": 10848}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s550272314", "group_id": "codeNet:p00767", "input_text": "#前計算をしておく\n$hw_dict = []\ndef init_dict()\n\tfor w in (1..151)\n\t\tfor h in (1...w)\n\t\t\telm = [h*h+w*w,h,w]\n\t\t\t$hw_dict.push(elm)\n\t\tend\n\tend\n\t$hw_dict = $hw_dict.sort()\nend\n\ndef pred_pair(p1,p2)\n\tif p1[0] < p2[0]\n\t\t1\n\telsif p1[0] > p2[0]\n\t\t-1\n\telse\n\t\tif p1[1] < p2[1]\n\t\t\t1\n\t\telsif p1[1] > p2[1]\n\t\t\t-1\n\t\telse\n\t\t\t0\n\t\tend\n\tend\nend\n\n\ndef solve(h,w)\n\tl = 0\n\tr = $hw_dict.length() - 1\n\tp = [h*h+w*w,h,w]\n\tansp = 0\n\tfound = 0\n\twhile r - l > 1\n\t\tm = (l + r) / 2\n\t\tif pred_pair(p,$hw_dict[m]) > 0\n\t\t\tr = m\n\t\telsif pred_pair(p,$hw_dict[m]) < 0\n\t\t\tl = m\n\t\telse\n\t\t\tansp = m + 1\n\t\t\tfound = 1\n\t\t\tbreak\n\t\tend\n\tend\n\tif found == 0\n\t\tansp = r\n\tend\n\t[$hw_dict[ansp][1],$hw_dict[ansp][2]]\nend\n\ninit_dict()\nfor i in (0..10)\n\tp $hw_dict[i]\nend\n\nwhile nums = STDIN.gets().chomp().split(\" \")\n\tif nums[0].to_i() == 0 && nums[1].to_i() == 0\n\t\texit\n\telse\n\t\tans = solve(nums[0].to_i(),nums[1].to_i())\n\t\tputs \"#{ans[0]} #{ans[1]}\"\n\tend\nend", "language": "Ruby", "metadata": {"date": 1418892322, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00767.html", "problem_id": "p00767", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00767/input.txt", "sample_output_relpath": "derived/input_output/data/p00767/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00767/Ruby/s550272314.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s550272314", "user_id": "u226964304"}, "prompt_components": {"gold_output": "1 3\n2 3\n1 4\n2 4\n3 4\n1 8\n4 7\n2 8\n3 140\n89 109\n", "input_to_evaluate": "#前計算をしておく\n$hw_dict = []\ndef init_dict()\n\tfor w in (1..151)\n\t\tfor h in (1...w)\n\t\t\telm = [h*h+w*w,h,w]\n\t\t\t$hw_dict.push(elm)\n\t\tend\n\tend\n\t$hw_dict = $hw_dict.sort()\nend\n\ndef pred_pair(p1,p2)\n\tif p1[0] < p2[0]\n\t\t1\n\telsif p1[0] > p2[0]\n\t\t-1\n\telse\n\t\tif p1[1] < p2[1]\n\t\t\t1\n\t\telsif p1[1] > p2[1]\n\t\t\t-1\n\t\telse\n\t\t\t0\n\t\tend\n\tend\nend\n\n\ndef solve(h,w)\n\tl = 0\n\tr = $hw_dict.length() - 1\n\tp = [h*h+w*w,h,w]\n\tansp = 0\n\tfound = 0\n\twhile r - l > 1\n\t\tm = (l + r) / 2\n\t\tif pred_pair(p,$hw_dict[m]) > 0\n\t\t\tr = m\n\t\telsif pred_pair(p,$hw_dict[m]) < 0\n\t\t\tl = m\n\t\telse\n\t\t\tansp = m + 1\n\t\t\tfound = 1\n\t\t\tbreak\n\t\tend\n\tend\n\tif found == 0\n\t\tansp = r\n\tend\n\t[$hw_dict[ansp][1],$hw_dict[ansp][2]]\nend\n\ninit_dict()\nfor i in (0..10)\n\tp $hw_dict[i]\nend\n\nwhile nums = STDIN.gets().chomp().split(\" \")\n\tif nums[0].to_i() == 0 && nums[1].to_i() == 0\n\t\texit\n\telse\n\t\tans = solve(nums[0].to_i(),nums[1].to_i())\n\t\tputs \"#{ans[0]} #{ans[1]}\"\n\tend\nend", "problem_context": "Integral Rectangles\n\nLet us consider rectangles whose height, h, and\nwidth, w, are both integers. We call such rectangles\nintegral rectangles. In this problem, we consider only wide\nintegral rectangles, i.e., those with w > h.\n\nWe define the following ordering of wide integral rectangles. Given\ntwo wide integral rectangles,\n\nThe one shorter in its diagonal line is smaller, and\n\nIf the two have diagonal lines with the same length, the one shorter\nin its height is smaller.\n\nGiven a wide integral rectangle, find the smallest wide integral\nrectangle bigger than the given one.\n\nInput\n\nThe entire input consists of multiple datasets. The number of\ndatasets is no more than 100. Each dataset describes a wide integral\nrectangle by specifying its height and width, namely h\nand w, separated by a space in a line, as follows.\n\nh w\n\nFor each dataset, h and w (>h) are both\nintegers greater than 0 and no more than 100.\n\nThe end of the input is indicated by a line of two zeros separated by a space.\n\nOutput\n\nFor each dataset, print in a line two numbers describing the\nheight and width, namely h and w (> h), of the\nsmallest wide integral rectangle bigger than the one described in the\ndataset. Put a space between the numbers. No other\ncharacters are allowed in the output.\n\nFor any wide integral rectangle given in the input, the width and\nheight of the smallest wide integral rectangle bigger than the given\none are both known to be not greater than 150.\n\nIn addition, although\nthe ordering of wide integral rectangles uses the comparison of\nlengths of diagonal lines, this comparison can be replaced with that\nof squares (self-products) of lengths of diagonal lines, which can\navoid unnecessary troubles possibly caused by the use of floating-point\nnumbers.\n\nSample Input\n\n1 2\n1 3\n2 3\n1 4\n2 4\n5 6\n1 8\n4 7\n98 100\n99 100\n0 0\n\nOutput for the Sample Input\n\n1 3\n2 3\n1 4\n2 4\n3 4\n1 8\n4 7\n2 8\n3 140\n89 109", "sample_input": "1 2\n1 3\n2 3\n1 4\n2 4\n5 6\n1 8\n4 7\n98 100\n99 100\n0 0\n"}, "reference_outputs": ["1 3\n2 3\n1 4\n2 4\n3 4\n1 8\n4 7\n2 8\n3 140\n89 109\n"], "source_document_id": "p00767", "source_text": "Integral Rectangles\n\nLet us consider rectangles whose height, h, and\nwidth, w, are both integers. We call such rectangles\nintegral rectangles. In this problem, we consider only wide\nintegral rectangles, i.e., those with w > h.\n\nWe define the following ordering of wide integral rectangles. Given\ntwo wide integral rectangles,\n\nThe one shorter in its diagonal line is smaller, and\n\nIf the two have diagonal lines with the same length, the one shorter\nin its height is smaller.\n\nGiven a wide integral rectangle, find the smallest wide integral\nrectangle bigger than the given one.\n\nInput\n\nThe entire input consists of multiple datasets. The number of\ndatasets is no more than 100. Each dataset describes a wide integral\nrectangle by specifying its height and width, namely h\nand w, separated by a space in a line, as follows.\n\nh w\n\nFor each dataset, h and w (>h) are both\nintegers greater than 0 and no more than 100.\n\nThe end of the input is indicated by a line of two zeros separated by a space.\n\nOutput\n\nFor each dataset, print in a line two numbers describing the\nheight and width, namely h and w (> h), of the\nsmallest wide integral rectangle bigger than the one described in the\ndataset. Put a space between the numbers. No other\ncharacters are allowed in the output.\n\nFor any wide integral rectangle given in the input, the width and\nheight of the smallest wide integral rectangle bigger than the given\none are both known to be not greater than 150.\n\nIn addition, although\nthe ordering of wide integral rectangles uses the comparison of\nlengths of diagonal lines, this comparison can be replaced with that\nof squares (self-products) of lengths of diagonal lines, which can\navoid unnecessary troubles possibly caused by the use of floating-point\nnumbers.\n\nSample Input\n\n1 2\n1 3\n2 3\n1 4\n2 4\n5 6\n1 8\n4 7\n98 100\n99 100\n0 0\n\nOutput for the Sample Input\n\n1 3\n2 3\n1 4\n2 4\n3 4\n1 8\n4 7\n2 8\n3 140\n89 109", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 919, "cpu_time_ms": 50, "memory_kb": 6444}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s153545057", "group_id": "codeNet:p00872", "input_text": "def gcd(m, n)\n\tif m < n \n\t\tgcd(n, m)\n\telsif n == 0\n\t\tm\n\telse\n\t\tgcd(n, m % n)\n\tend \nend\n\ndef lcm(m, n)\n\tm * n / gcd(m, n)\nend\n\nclass Array\n def ary_gcd\n inject{|l, x| gcd(l, x)}\n end\n def ary_lcm\n inject{|l, x| lcm(l, x)}\n end\nend\n\nclass Poly < Hash\n def self.var\n x = self.new(0)\n x[1] = 1\n x\n end\n\n def degree\n self.keys.max || 0\n end\n\n def self.num(n)\n d = self.new(0)\n d[0] = n\n d\n end\n\n def normalize!\n each_key do |k|\n delete(k) if self[k] == 0\n end\n self\n end\n\n def +(other)\n sum = self.class.num(0)\n self.each {|k, c| sum[k] += c}\n other.each {|k, c| sum[k] += c}\n sum.normalize!\n end\n\n def -(other)\n diff = self.class.num(0)\n self.each {|k, c| diff[k] += c}\n other.each {|k, c| diff[k] -= c}\n diff.normalize!\n end\n\n def -@\n m = self * self.class.num(-1)\n m.normalize!\n end\n\n def *(other)\n prod = self.class.num(0)\n self.each do |k1, c1| \n other.each do |k2, c2|\n prod[k1 + k2] += c1 * c2\n end\n end\n prod.normalize!\n end\n\n def **(k)\n return Poly.num(1) if k == 0\n return self if k == 1\n self * self ** (k - 1)\n end\n\n def zero?\n self.empty? || (degree == 0 && self[0] == 0)\n end\n\n def to_integral\n l = values.map {|x| x.kind_of?(Rational) ? x.denominator : 1}.ary_lcm\n v = self * Poly.num(l)\n g = v.values.map(&:to_i).map(&:abs).ary_gcd\n v.each_key {|k| v[k] = (v[k] / g).to_i}\n if v[v.degree] < 0\n v.each_key {|k| v[k] *= -1} \n end\n v\n end\n\n def to_s\n x = to_integral\n a = x.keys.sort.reverse.map do |k|\n if k == 0\n x[k]\n else\n \"#{x[k] == 1 ? '' : x[k]}x#{k==1 ? '' : ?^ + k.to_s}\"\n end\n end\n a.join(?+).gsub(\"+-\", ?-)\n end\n\nend\n\ndef get_exp(s, i)\n if s[i] == ?-\n t, j = get_term(s, i+1)\n return nil unless t\n\n j += 1 if s[j] == ?+\n e, k = get_exp(s, j)\n if e\n return [-t + e, k] if e\n else\n return [-t, j]\n end\n end\n\n t, j = get_term(s, i)\n return nil unless t\n\n j += 1 if s[j] == ?+\n e, k = get_exp(s, j)\n if e\n return [t + e, k] if e\n else\n return [t, j]\n end\nend\n\ndef get_term(s, i)\n f, j = get_factor(s, i)\n return nil unless f\n\n t, k = get_term(s, j)\n if t\n return [f * t, k]\n else\n return [f, j]\n end\nend\n\ndef get_factor(s, i)\n pr, j = get_primary(s, i)\n return nil unless pr\n if s[j] == ?^\n d, k = get_number(s, j+1)\n return nil unless d\n return [pr**d, k]\n else\n return [pr, j] \n end\nend\n\ndef get_primary(s, i)\n return [Poly::var, i+1] if s[i] == ?x\n v, j = get_number(s, i)\n return [Poly::num(v), j] if v\n return nil unless s[i] == ?(\n e, j = get_exp(s, i+1)\n return nil unless e && s[j] == ?)\n return [e, j+1]\nend\n\ndef get_number(s, i)\n return nil unless s[i] =~ /\\d/\n j = i\n j += 1 while s[j] =~ /\\d/\n return [s[i..j-1].to_i, j]\nend\n\nrequire 'rational'\ndef poly_gcd(e1, e2)\n return poly_gcd(e2, e1) if e1.degree < e2.degree\n return e1 if e2.zero?\n\n until e1.zero? || e1.degree < e2.degree \n r = Rational(e1[e1.degree], e2[e2.degree])\n e1 -= e2 * Poly::num(r) * Poly::var ** (e1.degree - e2.degree)\n end\n\n poly_gcd(e2, e1)\nend\n\nloop do\n s = gets.chomp\n break if s == ?.\n e1, _ = get_exp(s, 0)\n s = gets.chomp\n e2, _ = get_exp(s, 0)\n puts poly_gcd(e1, e2)\nend", "language": "Ruby", "metadata": {"date": 1480780290, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00872.html", "problem_id": "p00872", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00872/input.txt", "sample_output_relpath": "derived/input_output/data/p00872/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00872/Ruby/s153545057.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s153545057", "user_id": "u797180951"}, "prompt_components": {"gold_output": "x^2-2x+1\nx+5\n1\n", "input_to_evaluate": "def gcd(m, n)\n\tif m < n \n\t\tgcd(n, m)\n\telsif n == 0\n\t\tm\n\telse\n\t\tgcd(n, m % n)\n\tend \nend\n\ndef lcm(m, n)\n\tm * n / gcd(m, n)\nend\n\nclass Array\n def ary_gcd\n inject{|l, x| gcd(l, x)}\n end\n def ary_lcm\n inject{|l, x| lcm(l, x)}\n end\nend\n\nclass Poly < Hash\n def self.var\n x = self.new(0)\n x[1] = 1\n x\n end\n\n def degree\n self.keys.max || 0\n end\n\n def self.num(n)\n d = self.new(0)\n d[0] = n\n d\n end\n\n def normalize!\n each_key do |k|\n delete(k) if self[k] == 0\n end\n self\n end\n\n def +(other)\n sum = self.class.num(0)\n self.each {|k, c| sum[k] += c}\n other.each {|k, c| sum[k] += c}\n sum.normalize!\n end\n\n def -(other)\n diff = self.class.num(0)\n self.each {|k, c| diff[k] += c}\n other.each {|k, c| diff[k] -= c}\n diff.normalize!\n end\n\n def -@\n m = self * self.class.num(-1)\n m.normalize!\n end\n\n def *(other)\n prod = self.class.num(0)\n self.each do |k1, c1| \n other.each do |k2, c2|\n prod[k1 + k2] += c1 * c2\n end\n end\n prod.normalize!\n end\n\n def **(k)\n return Poly.num(1) if k == 0\n return self if k == 1\n self * self ** (k - 1)\n end\n\n def zero?\n self.empty? || (degree == 0 && self[0] == 0)\n end\n\n def to_integral\n l = values.map {|x| x.kind_of?(Rational) ? x.denominator : 1}.ary_lcm\n v = self * Poly.num(l)\n g = v.values.map(&:to_i).map(&:abs).ary_gcd\n v.each_key {|k| v[k] = (v[k] / g).to_i}\n if v[v.degree] < 0\n v.each_key {|k| v[k] *= -1} \n end\n v\n end\n\n def to_s\n x = to_integral\n a = x.keys.sort.reverse.map do |k|\n if k == 0\n x[k]\n else\n \"#{x[k] == 1 ? '' : x[k]}x#{k==1 ? '' : ?^ + k.to_s}\"\n end\n end\n a.join(?+).gsub(\"+-\", ?-)\n end\n\nend\n\ndef get_exp(s, i)\n if s[i] == ?-\n t, j = get_term(s, i+1)\n return nil unless t\n\n j += 1 if s[j] == ?+\n e, k = get_exp(s, j)\n if e\n return [-t + e, k] if e\n else\n return [-t, j]\n end\n end\n\n t, j = get_term(s, i)\n return nil unless t\n\n j += 1 if s[j] == ?+\n e, k = get_exp(s, j)\n if e\n return [t + e, k] if e\n else\n return [t, j]\n end\nend\n\ndef get_term(s, i)\n f, j = get_factor(s, i)\n return nil unless f\n\n t, k = get_term(s, j)\n if t\n return [f * t, k]\n else\n return [f, j]\n end\nend\n\ndef get_factor(s, i)\n pr, j = get_primary(s, i)\n return nil unless pr\n if s[j] == ?^\n d, k = get_number(s, j+1)\n return nil unless d\n return [pr**d, k]\n else\n return [pr, j] \n end\nend\n\ndef get_primary(s, i)\n return [Poly::var, i+1] if s[i] == ?x\n v, j = get_number(s, i)\n return [Poly::num(v), j] if v\n return nil unless s[i] == ?(\n e, j = get_exp(s, i+1)\n return nil unless e && s[j] == ?)\n return [e, j+1]\nend\n\ndef get_number(s, i)\n return nil unless s[i] =~ /\\d/\n j = i\n j += 1 while s[j] =~ /\\d/\n return [s[i..j-1].to_i, j]\nend\n\nrequire 'rational'\ndef poly_gcd(e1, e2)\n return poly_gcd(e2, e1) if e1.degree < e2.degree\n return e1 if e2.zero?\n\n until e1.zero? || e1.degree < e2.degree \n r = Rational(e1[e1.degree], e2[e2.degree])\n e1 -= e2 * Poly::num(r) * Poly::var ** (e1.degree - e2.degree)\n end\n\n poly_gcd(e2, e1)\nend\n\nloop do\n s = gets.chomp\n break if s == ?.\n e1, _ = get_exp(s, 0)\n s = gets.chomp\n e2, _ = get_exp(s, 0)\n puts poly_gcd(e1, e2)\nend", "problem_context": "Problem I: Common Polynomial\n\nMath teacher Mr. Matsudaira is teaching expansion and factoring of polynomials to his students.\nLast week he instructed the students to write two polynomials (with a single variable x), and\nto report GCM (greatest common measure) of them as a homework, but he found it boring to\ncheck their answers manually. So you are asked to write a program to check the answers.\n\nHereinafter, only those polynomials with integral coefficients, called integral polynomials, are\nconsidered.\n\nWhen two integral polynomials A and B are given, an integral polynomial C is a common factor\nof A and B if there are some integral polynomials X and Y such that A = CX and B = CY.\n\nGCM of two integral polynomials is a common factor which has the highest degree (for x, here);\nyou have to write a program which calculates the GCM of two polynomials.\n\nIt is known that GCM of given two polynomials is unique when constant multiplication factor is\nignored. That is, when C and D are both GCM of some two polynomials A and B, p × C = q × D\nfor some nonzero integers p and q.\n\nInput\n\nThe input consists of multiple datasets. Each dataset constitutes a pair of input lines, each\nrepresenting a polynomial as an expression defined below.\n\nA primary is a variable x, a sequence of digits 0 - 9, or an expression enclosed within ( ... ). Examples:\nx, 99, (x+1)\n\nA factor is a primary by itself or a primary followed by an exponent. An exponent consists\nof a symbol ^ followed by a sequence of digits 0 - 9. Examples:\nx^05, 1^15, (x+1)^3\n\nA term consists of one or more adjoining factors. Examples:\n4x, (x+1)(x-2), 3(x+1)^2\n\nAn expression is one or more terms connected by either + or -. Additionally, the first\nterm of an expression may optionally be preceded with a minus sign -. Examples:\n-x+1, 3(x+1)^2-x(x-1)^2\n\nInteger constants, exponents, multiplications (adjoining), additions (+) and subtractions/negations\n(-) have their ordinary meanings. A sequence of digits is always interpreted as an integer con-\nstant. For example, 99 means 99, not 9 × 9.\n\nAny subexpressions of the input, when fully expanded normalized, have coefficients less than\n100 and degrees of x less than 10. Digit sequences in exponents represent non-zero values.\n\nAll the datasets are designed so that a standard algorithm with 32-bit two’s complement integers\ncan solve the problem without overflows.\n\nThe end of the input is indicated by a line containing a period.\n\nOutput\n\nFor each of the dataset, output GCM polynomial expression in a line, in the format below.\n\nc0x^p0 ± c1x^p1 ... ± cnx^pn\n\nWhere ci and pi (i = 0, . . . , n) are positive integers with p0 > p1 > . . . > pn, and the greatest\ncommon divisor of {ci | i = 0, . . . , n} is 1.\n\nAdditionally:\n\nWhen ci is equal to 1, it should be omitted unless corresponding pi is 0,\n\nx^0 should be omitted as a whole, and\n\nx^1 should be written as x.\n\nSample Input\n\n-(x^3-3x^2+3x-1)\n(x-1)^2\nx^2+10x+25\nx^2+6x+5\nx^3+1\nx-1\n.\n\nOutput for the Sample Input\n\nx^2-2x+1\nx+5\n1", "sample_input": "-(x^3-3x^2+3x-1)\n(x-1)^2\nx^2+10x+25\nx^2+6x+5\nx^3+1\nx-1\n.\n"}, "reference_outputs": ["x^2-2x+1\nx+5\n1\n"], "source_document_id": "p00872", "source_text": "Problem I: Common Polynomial\n\nMath teacher Mr. Matsudaira is teaching expansion and factoring of polynomials to his students.\nLast week he instructed the students to write two polynomials (with a single variable x), and\nto report GCM (greatest common measure) of them as a homework, but he found it boring to\ncheck their answers manually. So you are asked to write a program to check the answers.\n\nHereinafter, only those polynomials with integral coefficients, called integral polynomials, are\nconsidered.\n\nWhen two integral polynomials A and B are given, an integral polynomial C is a common factor\nof A and B if there are some integral polynomials X and Y such that A = CX and B = CY.\n\nGCM of two integral polynomials is a common factor which has the highest degree (for x, here);\nyou have to write a program which calculates the GCM of two polynomials.\n\nIt is known that GCM of given two polynomials is unique when constant multiplication factor is\nignored. That is, when C and D are both GCM of some two polynomials A and B, p × C = q × D\nfor some nonzero integers p and q.\n\nInput\n\nThe input consists of multiple datasets. Each dataset constitutes a pair of input lines, each\nrepresenting a polynomial as an expression defined below.\n\nA primary is a variable x, a sequence of digits 0 - 9, or an expression enclosed within ( ... ). Examples:\nx, 99, (x+1)\n\nA factor is a primary by itself or a primary followed by an exponent. An exponent consists\nof a symbol ^ followed by a sequence of digits 0 - 9. Examples:\nx^05, 1^15, (x+1)^3\n\nA term consists of one or more adjoining factors. Examples:\n4x, (x+1)(x-2), 3(x+1)^2\n\nAn expression is one or more terms connected by either + or -. Additionally, the first\nterm of an expression may optionally be preceded with a minus sign -. Examples:\n-x+1, 3(x+1)^2-x(x-1)^2\n\nInteger constants, exponents, multiplications (adjoining), additions (+) and subtractions/negations\n(-) have their ordinary meanings. A sequence of digits is always interpreted as an integer con-\nstant. For example, 99 means 99, not 9 × 9.\n\nAny subexpressions of the input, when fully expanded normalized, have coefficients less than\n100 and degrees of x less than 10. Digit sequences in exponents represent non-zero values.\n\nAll the datasets are designed so that a standard algorithm with 32-bit two’s complement integers\ncan solve the problem without overflows.\n\nThe end of the input is indicated by a line containing a period.\n\nOutput\n\nFor each of the dataset, output GCM polynomial expression in a line, in the format below.\n\nc0x^p0 ± c1x^p1 ... ± cnx^pn\n\nWhere ci and pi (i = 0, . . . , n) are positive integers with p0 > p1 > . . . > pn, and the greatest\ncommon divisor of {ci | i = 0, . . . , n} is 1.\n\nAdditionally:\n\nWhen ci is equal to 1, it should be omitted unless corresponding pi is 0,\n\nx^0 should be omitted as a whole, and\n\nx^1 should be written as x.\n\nSample Input\n\n-(x^3-3x^2+3x-1)\n(x-1)^2\nx^2+10x+25\nx^2+6x+5\nx^3+1\nx-1\n.\n\nOutput for the Sample Input\n\nx^2-2x+1\nx+5\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": 3736, "cpu_time_ms": 60, "memory_kb": 9060}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s187920133", "group_id": "codeNet:p00874", "input_text": "### constant\n\nMAX_H = 20\n\n### main\n\nloop do\n w, d = gets.split.map(&:to_i)\n break if (w | d) == 0\n\n hxs = gets.split.map(&:to_i)\n hys = gets.split.map(&:to_i)\n\n hxcs = (MAX_H + 1).times.map{0}\n hycs = (MAX_H + 1).times.map{0}\n\n hxs.each{|h| hxcs[h] += 1}\n hys.each{|h| hycs[h] += 1}\n\n count = 0\n for h in (1..MAX_H)\n count += ((hxcs[h] > hycs[h]) ? hxcs[h] : hycs[h]) * h\n end\n p count\nend", "language": "Ruby", "metadata": {"date": 1425312693, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00874.html", "problem_id": "p00874", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00874/input.txt", "sample_output_relpath": "derived/input_output/data/p00874/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00874/Ruby/s187920133.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s187920133", "user_id": "u137027976"}, "prompt_components": {"gold_output": "15\n15\n21\n21\n15\n13\n32\n90\n186\n", "input_to_evaluate": "### constant\n\nMAX_H = 20\n\n### main\n\nloop do\n w, d = gets.split.map(&:to_i)\n break if (w | d) == 0\n\n hxs = gets.split.map(&:to_i)\n hys = gets.split.map(&:to_i)\n\n hxcs = (MAX_H + 1).times.map{0}\n hycs = (MAX_H + 1).times.map{0}\n\n hxs.each{|h| hxcs[h] += 1}\n hys.each{|h| hycs[h] += 1}\n\n count = 0\n for h in (1..MAX_H)\n count += ((hxcs[h] > hycs[h]) ? hxcs[h] : hycs[h]) * h\n end\n p count\nend", "problem_context": "Problem A: Cubist Artwork\n\nInternational Center for Picassonian Cubism is a Spanish national museum of cubist artworks,\ndedicated to Pablo Picasso. The center held a competition for an artwork that will be displayed\nin front of the facade of the museum building. The artwork is a collection of cubes that are\npiled up on the ground and is intended to amuse visitors, who will be curious how the shape of\nthe collection of cubes changes when it is seen from the front and the sides.\n\nThe artwork is a collection of cubes with edges of one foot long and is built on a flat ground\nthat is divided into a grid of one foot by one foot squares. Due to some technical reasons, cubes\nof the artwork must be either put on the ground, fitting into a unit square in the grid, or put\non another cube in the way that the bottom face of the upper cube exactly meets the top face\nof the lower cube. No other way of putting cubes is possible.\n\nYou are a member of the judging committee responsible for selecting one out of a plenty of\nartwork proposals submitted to the competition. The decision is made primarily based on\nartistic quality but the cost for installing the artwork is another important factor. Your task is\nto investigate the installation cost for each proposal. The cost is proportional to the number of\ncubes, so you have to figure out the minimum number of cubes needed for installation.\n\nEach design proposal of an artwork consists of the front view and the side view (the view seen\nfrom the right-hand side), as shown in Figure 1.\n\nFigure 1: An example of an artwork proposal\n\nThe front view (resp., the side view) indicates the maximum heights of piles of cubes for each\ncolumn line (resp., row line) of the grid.\n\nThere are several ways to install this proposal of artwork, such as the following figures.\n\nIn these figures, the dotted lines on the ground indicate the grid lines. The left figure makes use\nof 16 cubes, which is not optimal. That is, the artwork can be installed with a fewer number\nof cubes. Actually, the right one is optimal and only uses 13 cubes. Note that, a single pile of\nheight three in the right figure plays the roles of two such piles in the left one.\n\nNotice that swapping columns of cubes does not change the side view. Similarly, swapping\nrows does not change the front view. Thus, such swaps do not change the costs of building the\nartworks.\n\nFor example, consider the artwork proposal given in Figure 2.\n\nFigure 2: Another example of artwork proposal\n\nAn optimal installation of this proposal of artwork can be achieved with 13 cubes, as shown\nin the following figure, which can be obtained by exchanging the rightmost two columns of the\noptimal installation of the artwork of Figure 1.\n\nInput\n\nThe input is a sequence of datasets. The end of the input is indicated by a line containing two\nzeros separated by a space. Each dataset is formatted as follows.\n\nw d\n\nh1 h2 ... hw\n\nh'1 h'2 ... h'd\n\nThe integers w and d separated by a space are the numbers of columns and rows of the grid,\nrespectively. You may assume 1 ≤ w ≤ 10 and 1 ≤ d ≤ 10. The integers separated by a space\nin the second and third lines specify the shape of the artwork. The integers hi (1 ≤ hi ≤ 20,\n1 ≤ i ≤ w) in the second line give the front view, i.e., the maximum heights of cubes per each\ncolumn line, ordered from left to right (seen from the front). The integers hi (1 ≤ hi ≤ 20,\n1 ≤ i ≤ d) in the third line give the side view, i.e., the maximum heights of cubes per each row\nline, ordered from left to right (seen from the right-hand side).\n\nOutput\n\nFor each dataset, output a line containing the minimum number of cubes. The output should\nnot contain any other extra characters.\n\nYou can assume that, for each dataset, there is at least one way to install the artwork.\n\nSample Input\n\n5 5\n1 2 3 4 5\n1 2 3 4 5\n5 5\n2 5 4 1 3\n4 1 5 3 2\n5 5\n1 2 3 4 5\n3 3 3 4 5\n3 3\n7 7 7\n7 7 7\n3 3\n4 4 4\n4 3 4\n4 3\n4 2 2 4\n4 2 1\n4 4\n2 8 8 8\n2 3 8 3\n10 10\n9 9 9 9 9 9 9 9 9 9\n9 9 9 9 9 9 9 9 9 9\n10 9\n20 1 20 20 20 20 20 18 20 20\n20 20 20 20 7 20 20 20 20\n0 0\n\nOutput for the Sample Input\n\n15\n15\n21\n21\n15\n13\n32\n90\n186", "sample_input": "5 5\n1 2 3 4 5\n1 2 3 4 5\n5 5\n2 5 4 1 3\n4 1 5 3 2\n5 5\n1 2 3 4 5\n3 3 3 4 5\n3 3\n7 7 7\n7 7 7\n3 3\n4 4 4\n4 3 4\n4 3\n4 2 2 4\n4 2 1\n4 4\n2 8 8 8\n2 3 8 3\n10 10\n9 9 9 9 9 9 9 9 9 9\n9 9 9 9 9 9 9 9 9 9\n10 9\n20 1 20 20 20 20 20 18 20 20\n20 20 20 20 7 20 20 20 20\n0 0\n"}, "reference_outputs": ["15\n15\n21\n21\n15\n13\n32\n90\n186\n"], "source_document_id": "p00874", "source_text": "Problem A: Cubist Artwork\n\nInternational Center for Picassonian Cubism is a Spanish national museum of cubist artworks,\ndedicated to Pablo Picasso. The center held a competition for an artwork that will be displayed\nin front of the facade of the museum building. The artwork is a collection of cubes that are\npiled up on the ground and is intended to amuse visitors, who will be curious how the shape of\nthe collection of cubes changes when it is seen from the front and the sides.\n\nThe artwork is a collection of cubes with edges of one foot long and is built on a flat ground\nthat is divided into a grid of one foot by one foot squares. Due to some technical reasons, cubes\nof the artwork must be either put on the ground, fitting into a unit square in the grid, or put\non another cube in the way that the bottom face of the upper cube exactly meets the top face\nof the lower cube. No other way of putting cubes is possible.\n\nYou are a member of the judging committee responsible for selecting one out of a plenty of\nartwork proposals submitted to the competition. The decision is made primarily based on\nartistic quality but the cost for installing the artwork is another important factor. Your task is\nto investigate the installation cost for each proposal. The cost is proportional to the number of\ncubes, so you have to figure out the minimum number of cubes needed for installation.\n\nEach design proposal of an artwork consists of the front view and the side view (the view seen\nfrom the right-hand side), as shown in Figure 1.\n\nFigure 1: An example of an artwork proposal\n\nThe front view (resp., the side view) indicates the maximum heights of piles of cubes for each\ncolumn line (resp., row line) of the grid.\n\nThere are several ways to install this proposal of artwork, such as the following figures.\n\nIn these figures, the dotted lines on the ground indicate the grid lines. The left figure makes use\nof 16 cubes, which is not optimal. That is, the artwork can be installed with a fewer number\nof cubes. Actually, the right one is optimal and only uses 13 cubes. Note that, a single pile of\nheight three in the right figure plays the roles of two such piles in the left one.\n\nNotice that swapping columns of cubes does not change the side view. Similarly, swapping\nrows does not change the front view. Thus, such swaps do not change the costs of building the\nartworks.\n\nFor example, consider the artwork proposal given in Figure 2.\n\nFigure 2: Another example of artwork proposal\n\nAn optimal installation of this proposal of artwork can be achieved with 13 cubes, as shown\nin the following figure, which can be obtained by exchanging the rightmost two columns of the\noptimal installation of the artwork of Figure 1.\n\nInput\n\nThe input is a sequence of datasets. The end of the input is indicated by a line containing two\nzeros separated by a space. Each dataset is formatted as follows.\n\nw d\n\nh1 h2 ... hw\n\nh'1 h'2 ... h'd\n\nThe integers w and d separated by a space are the numbers of columns and rows of the grid,\nrespectively. You may assume 1 ≤ w ≤ 10 and 1 ≤ d ≤ 10. The integers separated by a space\nin the second and third lines specify the shape of the artwork. The integers hi (1 ≤ hi ≤ 20,\n1 ≤ i ≤ w) in the second line give the front view, i.e., the maximum heights of cubes per each\ncolumn line, ordered from left to right (seen from the front). The integers hi (1 ≤ hi ≤ 20,\n1 ≤ i ≤ d) in the third line give the side view, i.e., the maximum heights of cubes per each row\nline, ordered from left to right (seen from the right-hand side).\n\nOutput\n\nFor each dataset, output a line containing the minimum number of cubes. The output should\nnot contain any other extra characters.\n\nYou can assume that, for each dataset, there is at least one way to install the artwork.\n\nSample Input\n\n5 5\n1 2 3 4 5\n1 2 3 4 5\n5 5\n2 5 4 1 3\n4 1 5 3 2\n5 5\n1 2 3 4 5\n3 3 3 4 5\n3 3\n7 7 7\n7 7 7\n3 3\n4 4 4\n4 3 4\n4 3\n4 2 2 4\n4 2 1\n4 4\n2 8 8 8\n2 3 8 3\n10 10\n9 9 9 9 9 9 9 9 9 9\n9 9 9 9 9 9 9 9 9 9\n10 9\n20 1 20 20 20 20 20 18 20 20\n20 20 20 20 7 20 20 20 20\n0 0\n\nOutput for the Sample Input\n\n15\n15\n21\n21\n15\n13\n32\n90\n186", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 404, "cpu_time_ms": 20, "memory_kb": 6132}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s581566159", "group_id": "codeNet:p00875", "input_text": "def sed(p,g,d)\n return nil if g.length > d.length\n return 0 if g == d\n min = Float::INFINITY\n p.each do |pt|\n next if !g.include?(pt[0])\n r = sed(p,g.gsub(pt[0],pt[1]),d)\n next if !r\n min = r + 1 if r + 1 < min\n end\n return nil if min == Float::INFINITY\n return min\nend\nloop do\n n = gets.to_i\n break if n == 0\n p = n.times.map{gets.split}\n g = gets.chomp\n d = gets.chomp\n ret = sed(p,g,d)\n puts ret ? ret : -1\nend", "language": "Ruby", "metadata": {"date": 1423142946, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00875.html", "problem_id": "p00875", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00875/input.txt", "sample_output_relpath": "derived/input_output/data/p00875/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00875/Ruby/s581566159.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s581566159", "user_id": "u672005134"}, "prompt_components": {"gold_output": "3\n-1\n7\n4\n", "input_to_evaluate": "def sed(p,g,d)\n return nil if g.length > d.length\n return 0 if g == d\n min = Float::INFINITY\n p.each do |pt|\n next if !g.include?(pt[0])\n r = sed(p,g.gsub(pt[0],pt[1]),d)\n next if !r\n min = r + 1 if r + 1 < min\n end\n return nil if min == Float::INFINITY\n return min\nend\nloop do\n n = gets.to_i\n break if n == 0\n p = n.times.map{gets.split}\n g = gets.chomp\n d = gets.chomp\n ret = sed(p,g,d)\n puts ret ? ret : -1\nend", "problem_context": "Problem B: Repeated Substitution with Sed\n\nDo you know \"sed,\" a tool provided with Unix? Its most popular use is to substitute every\noccurrence of a string contained in the input string (actually each input line) with another\nstring β. More precisely, it proceeds as follows.\n\nWithin the input string, every non-overlapping (but possibly adjacent) occurrences of α are\nmarked. If there is more than one possibility for non-overlapping matching, the leftmost\none is chosen.\n\nEach of the marked occurrences is substituted with β to obtain the output string; other\nparts of the input string remain intact.\n\nFor example, when α is \"aa\" and β is \"bca\", an input string \"aaxaaa\" will produce \"bcaxbcaa\",\nbut not \"aaxbcaa\" nor \"bcaxabca\". Further application of the same substitution to the string\n\"bcaxbcaa\" will result in \"bcaxbcbca\", but this is another substitution, which is counted as the\nsecond one.\n\nIn this problem, a set of substitution pairs (αi, βi) (i = 1, 2, ... , n), an initial string γ, and a\nfinal string δ are given, and you must investigate how to produce δ from γ with a minimum\nnumber of substitutions. A single substitution (αi, βi) here means simultaneously substituting\nall the non-overlapping occurrences of αi, in the sense described above, with βi.\n\nYou may use a specific substitution (αi, βi ) multiple times, including zero times.\n\nInput\n\nThe input consists of multiple datasets, each in the following format.\n\nn\n\nα1 β1\n\nα2 β2\n\n.\n\n.\n\n.\n\nαn βn\n\nγ\n\nδ\n\nn is a positive integer indicating the number of pairs. αi and βi are separated by a single space.\nYou may assume that 1 ≤ |αi| < |βi| ≤ 10 for any i (|s| means the length of the string s),\n\nαi ≠ αj for any i ≠ j, n ≤ 10 and 1 ≤ |γ| < |δ| ≤ 10. All the strings consist solely of lowercase\nletters. The end of the input is indicated by a line containing a single zero.\n\nOutput\n\nFor each dataset, output the minimum number of substitutions to obtain δ from γ. If δ cannot\nbe produced from γ with the given set of substitutions, output -1.\n\nSample Input\n\n2\na bb\nb aa\na\nbbbbbbbb\n1\na aa\na\naaaaa\n3\nab aab\nabc aadc\nad dee\nabc\ndeeeeeeeec\n10\na abc\nb bai\nc acf\nd bed\ne abh\nf fag\ng abe\nh bag\ni aaj\nj bbb\na\nabacfaabe\n0\n\nOutput for the Sample Input\n\n3\n-1\n7\n4", "sample_input": "2\na bb\nb aa\na\nbbbbbbbb\n1\na aa\na\naaaaa\n3\nab aab\nabc aadc\nad dee\nabc\ndeeeeeeeec\n10\na abc\nb bai\nc acf\nd bed\ne abh\nf fag\ng abe\nh bag\ni aaj\nj bbb\na\nabacfaabe\n0\n"}, "reference_outputs": ["3\n-1\n7\n4\n"], "source_document_id": "p00875", "source_text": "Problem B: Repeated Substitution with Sed\n\nDo you know \"sed,\" a tool provided with Unix? Its most popular use is to substitute every\noccurrence of a string contained in the input string (actually each input line) with another\nstring β. More precisely, it proceeds as follows.\n\nWithin the input string, every non-overlapping (but possibly adjacent) occurrences of α are\nmarked. If there is more than one possibility for non-overlapping matching, the leftmost\none is chosen.\n\nEach of the marked occurrences is substituted with β to obtain the output string; other\nparts of the input string remain intact.\n\nFor example, when α is \"aa\" and β is \"bca\", an input string \"aaxaaa\" will produce \"bcaxbcaa\",\nbut not \"aaxbcaa\" nor \"bcaxabca\". Further application of the same substitution to the string\n\"bcaxbcaa\" will result in \"bcaxbcbca\", but this is another substitution, which is counted as the\nsecond one.\n\nIn this problem, a set of substitution pairs (αi, βi) (i = 1, 2, ... , n), an initial string γ, and a\nfinal string δ are given, and you must investigate how to produce δ from γ with a minimum\nnumber of substitutions. A single substitution (αi, βi) here means simultaneously substituting\nall the non-overlapping occurrences of αi, in the sense described above, with βi.\n\nYou may use a specific substitution (αi, βi ) multiple times, including zero times.\n\nInput\n\nThe input consists of multiple datasets, each in the following format.\n\nn\n\nα1 β1\n\nα2 β2\n\n.\n\n.\n\n.\n\nαn βn\n\nγ\n\nδ\n\nn is a positive integer indicating the number of pairs. αi and βi are separated by a single space.\nYou may assume that 1 ≤ |αi| < |βi| ≤ 10 for any i (|s| means the length of the string s),\n\nαi ≠ αj for any i ≠ j, n ≤ 10 and 1 ≤ |γ| < |δ| ≤ 10. All the strings consist solely of lowercase\nletters. The end of the input is indicated by a line containing a single zero.\n\nOutput\n\nFor each dataset, output the minimum number of substitutions to obtain δ from γ. If δ cannot\nbe produced from γ with the given set of substitutions, output -1.\n\nSample Input\n\n2\na bb\nb aa\na\nbbbbbbbb\n1\na aa\na\naaaaa\n3\nab aab\nabc aadc\nad dee\nabc\ndeeeeeeeec\n10\na abc\nb bai\nc acf\nd bed\ne abh\nf fag\ng abe\nh bag\ni aaj\nj bbb\na\nabacfaabe\n0\n\nOutput for the Sample Input\n\n3\n-1\n7\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": 483, "cpu_time_ms": 570, "memory_kb": 7408}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s458232749", "group_id": "codeNet:p00889", "input_text": "class Array\n\tdef accum\n\t\tac = Array.new(size + 1)\n\t\tac[0] = 0\n\t\t(1..size).each do |i|\n\t\t\tac[i] = ac[i-1] + self[i-1]\n\t\tend\n\t\tac\n\tend\nend\n\nloop do\n\tn, s, w, q = gets.split.map(&:to_i)\n\tbreak if n == 0\n\n\tg = s\n\ta = Array.new(n)\n\t(0..n-1).each do |i|\n\t\ta[i] = g / 7 % 10\n\t\tg = (g.even? ? g / 2 : (g / 2) ^ w)\n\tend\n\ta.reverse!\n\n\tk = 0\n\tif q == 2 || q == 5\n\t\tt = 0\n\t\ta.each_with_index do |x, i|\n\t\t\tif x % q == 0\n\t\t\t\tk += n - i \n\t\t\t\tt += 1\n\t\t\t\tk -= t if x == 0\n\t\t\tend\n\t\tend\n\t\tputs k\n\t\tnext\n\tend\n\n\tt = 1\n\tmod = a.map do |x|\n\t\ty = x * t % q\n\t\tt = t * 10 % q\n\t\ty\n\tend\n\tmod_accum = mod.accum.map {|x| x % q}\n\n\tcount = Hash.new(0)\n\t(0..n).each do |i|\n\t\tx = mod_accum[i]\n\t\tk += count[x] if i > 0 && a[i-1] > 0\n\t\tcount[x] += 1\n\tend\n\tp k\nend", "language": "Ruby", "metadata": {"date": 1465090205, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p00889.html", "problem_id": "p00889", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00889/input.txt", "sample_output_relpath": "derived/input_output/data/p00889/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00889/Ruby/s458232749.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s458232749", "user_id": "u797180951"}, "prompt_components": {"gold_output": "2\n4\n6\n3\n68530\n", "input_to_evaluate": "class Array\n\tdef accum\n\t\tac = Array.new(size + 1)\n\t\tac[0] = 0\n\t\t(1..size).each do |i|\n\t\t\tac[i] = ac[i-1] + self[i-1]\n\t\tend\n\t\tac\n\tend\nend\n\nloop do\n\tn, s, w, q = gets.split.map(&:to_i)\n\tbreak if n == 0\n\n\tg = s\n\ta = Array.new(n)\n\t(0..n-1).each do |i|\n\t\ta[i] = g / 7 % 10\n\t\tg = (g.even? ? g / 2 : (g / 2) ^ w)\n\tend\n\ta.reverse!\n\n\tk = 0\n\tif q == 2 || q == 5\n\t\tt = 0\n\t\ta.each_with_index do |x, i|\n\t\t\tif x % q == 0\n\t\t\t\tk += n - i \n\t\t\t\tt += 1\n\t\t\t\tk -= t if x == 0\n\t\t\tend\n\t\tend\n\t\tputs k\n\t\tnext\n\tend\n\n\tt = 1\n\tmod = a.map do |x|\n\t\ty = x * t % q\n\t\tt = t * 10 % q\n\t\ty\n\tend\n\tmod_accum = mod.accum.map {|x| x % q}\n\n\tcount = Hash.new(0)\n\t(0..n).each do |i|\n\t\tx = mod_accum[i]\n\t\tk += count[x] if i > 0 && a[i-1] > 0\n\t\tcount[x] += 1\n\tend\n\tp k\nend", "problem_context": "Problem F: Find the Multiples\n\nYou are given a sequence a0a1...aN-1 digits and a prime number Q. For each i ≤ j with ai ≠ 0, the subsequence aiai+1...aj can be read as a decimal representation of a positive integer. Subsequences with leading zeros are not considered. Your task is to count the number of pairs (i, j) such that the corresponding subsequence is a multiple of Q.\n\nInput\n\nThe input consists of at most 50 datasets. Each dataset is represented by a line containing four integers N, S, W, and Q, separated by spaces, where 1 ≤ N ≤ 105, 1 ≤ S ≤ 109, 1 ≤ W ≤ 109, and Q is a prime number less than 108. The sequence a0...aN-1 of length N is generated by the following code, in which ai is written as a[i].\n\nint g = S;\nfor(int i=0; i pair[1] ? pair[0] - pair[1] : 0}\n coin_values.zip(actual_coins).each do |zip|\n puts \"#{zip[0]} #{zip[1]}\" if zip[1] > 0\n end\nend", "language": "Ruby", "metadata": {"date": 1508164704, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p01132.html", "problem_id": "p01132", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p01132/input.txt", "sample_output_relpath": "derived/input_output/data/p01132/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01132/Ruby/s799898620.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s799898620", "user_id": "u285272839"}, "prompt_components": {"gold_output": "10 1\n50 1\n100 1\n\n10 1\n100 2\n", "input_to_evaluate": "first = true\nwhile true\n price = gets.to_i\n puts nil if !first\n first = false\n break if price == 0\n coin_numbers = gets.split.map(&:to_i)\n coin_values = [10, 50, 100, 500]\n coins_and_values = coin_numbers.zip(coin_values)\n total_price = coins_and_values.inject(0){ |sum, pair|\n sum += pair[0] * pair[1]\n }\n change = total_price - price\n change_coins = []\n coin_values.reverse.each do |value|\n coin = change / value\n change = change % value\n change_coins.insert(0, coin)\n end\n temp_pairs = coin_numbers.zip(change_coins)\n actual_coins = temp_pairs.map {|pair| pair[0] > pair[1] ? pair[0] - pair[1] : 0}\n coin_values.zip(actual_coins).each do |zip|\n puts \"#{zip[0]} #{zip[1]}\" if zip[1] > 0\n end\nend", "problem_context": "Problem B: Make Purse Light\n\nMr. Bill は店で買い物をしている。 彼の財布にはいくらかの硬貨(10 円玉、50 円玉、100 円玉、500 円玉)が入っているが、彼は今この小銭をできるだけ消費しようとしている。 つまり、適切な枚数の硬貨によって品物の代金を払うことで、釣り銭を受け取った後における硬貨の合計枚数を最小にしようとしている。\n\n幸いなことに、この店の店員はとても律儀かつ親切であるため、釣り銭は常に最適な方法で渡される。 したがって、例えば 1 枚の 500 円玉の代わりに 5 枚の 100 円玉が渡されるようなことはない。 また、例えば 10 円玉を 5 枚出して、50 円玉を釣り銭として受け取ることもできる。 ただし、出した硬貨と同じ種類の硬貨が釣り銭として戻ってくるような払いかたをしてはいけない。 例えば、10 円玉を支払いの際に出したにも関わらず、別の 10 円玉が釣り銭として戻されるようでは、完全に意味のないやりとりが発生してしまうからである。\n\nところが Mr. Bill は計算が苦手なため、実際に何枚の硬貨を使用すればよいかを彼自身で求めることができなかった。 そこで、彼はあなたに助けを求めてきた。 あなたの仕事は、彼の財布の中にある硬貨の枚数と支払い代金をもとに、使用すべき硬貨の種類と枚数を求めるプログラムを書くことである。なお、店員はお釣りに紙幣を使用することはない。\n\nInput\n\n入力にはいくつかのテストケースが含まれる。\n\nそれぞれのテストケースは 2 行から構成される。 1 行目には Mr. Bill の支払い金額を円単位で表した 1 つの整数が含まれている。 2 行目には 4 つの整数が含まれており、それらは順に財布の中にある 10 円玉、50 円玉、100 円玉、500 円玉の枚数をそれぞれ表す。\n\n支払い金額は常に 10 円単位である。 すなわち、支払い金額の一円の位は常に 0 である。 また財布の中に、同じ種類の硬貨は最大で 20 枚までしかないと仮定してよい。 支払いが不可能なケースが入力中に与えられることはない。\n\n入力の終了は単一の 0 を含む行によって表される。\n\nOutput\n\nそれぞれのテストケースについて、Mr. Bill が使用すべき硬貨の種類と枚数を出力せよ。\n\n出力の各行には 2 つの整数 ci 、ki が含まれる。これは支払いの際に ci 円玉を ki 枚使用することを意味している。\n複数種類の硬貨を使用する場合は、ci の小さいほうから順に、必要な行数だけ出力を行うこと。 下記の出力例を参考にせよ。\n\nなお、出力には余計なスペースを含めてはならない。 連続するテストケースの間は空行で区切ること。\n\nSample Input\n\n160\n1 1 2 0\n160\n1 0 2 10\n0\n\nOutput for the Sample Input\n\n10 1\n50 1\n100 1\n\n10 1\n100 2", "sample_input": "160\n1 1 2 0\n160\n1 0 2 10\n0\n"}, "reference_outputs": ["10 1\n50 1\n100 1\n\n10 1\n100 2\n"], "source_document_id": "p01132", "source_text": "Problem B: Make Purse Light\n\nMr. Bill は店で買い物をしている。 彼の財布にはいくらかの硬貨(10 円玉、50 円玉、100 円玉、500 円玉)が入っているが、彼は今この小銭をできるだけ消費しようとしている。 つまり、適切な枚数の硬貨によって品物の代金を払うことで、釣り銭を受け取った後における硬貨の合計枚数を最小にしようとしている。\n\n幸いなことに、この店の店員はとても律儀かつ親切であるため、釣り銭は常に最適な方法で渡される。 したがって、例えば 1 枚の 500 円玉の代わりに 5 枚の 100 円玉が渡されるようなことはない。 また、例えば 10 円玉を 5 枚出して、50 円玉を釣り銭として受け取ることもできる。 ただし、出した硬貨と同じ種類の硬貨が釣り銭として戻ってくるような払いかたをしてはいけない。 例えば、10 円玉を支払いの際に出したにも関わらず、別の 10 円玉が釣り銭として戻されるようでは、完全に意味のないやりとりが発生してしまうからである。\n\nところが Mr. Bill は計算が苦手なため、実際に何枚の硬貨を使用すればよいかを彼自身で求めることができなかった。 そこで、彼はあなたに助けを求めてきた。 あなたの仕事は、彼の財布の中にある硬貨の枚数と支払い代金をもとに、使用すべき硬貨の種類と枚数を求めるプログラムを書くことである。なお、店員はお釣りに紙幣を使用することはない。\n\nInput\n\n入力にはいくつかのテストケースが含まれる。\n\nそれぞれのテストケースは 2 行から構成される。 1 行目には Mr. Bill の支払い金額を円単位で表した 1 つの整数が含まれている。 2 行目には 4 つの整数が含まれており、それらは順に財布の中にある 10 円玉、50 円玉、100 円玉、500 円玉の枚数をそれぞれ表す。\n\n支払い金額は常に 10 円単位である。 すなわち、支払い金額の一円の位は常に 0 である。 また財布の中に、同じ種類の硬貨は最大で 20 枚までしかないと仮定してよい。 支払いが不可能なケースが入力中に与えられることはない。\n\n入力の終了は単一の 0 を含む行によって表される。\n\nOutput\n\nそれぞれのテストケースについて、Mr. Bill が使用すべき硬貨の種類と枚数を出力せよ。\n\n出力の各行には 2 つの整数 ci 、ki が含まれる。これは支払いの際に ci 円玉を ki 枚使用することを意味している。\n複数種類の硬貨を使用する場合は、ci の小さいほうから順に、必要な行数だけ出力を行うこと。 下記の出力例を参考にせよ。\n\nなお、出力には余計なスペースを含めてはならない。 連続するテストケースの間は空行で区切ること。\n\nSample Input\n\n160\n1 1 2 0\n160\n1 0 2 10\n0\n\nOutput for the Sample Input\n\n10 1\n50 1\n100 1\n\n10 1\n100 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": 729, "cpu_time_ms": 80, "memory_kb": 8932}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s411284226", "group_id": "codeNet:p01314", "input_text": "n = gets.to_i\nwhile n != 0\n\tcnt = 0\n\tsum = 0\n\tsum_cnt = 0\n\tn.times do |i|\n\t\tj = 1 + i\n\t\tloop do\n\t\t\tsum += j\n\t\t\tsum_cnt += 1\n\t\t\tj += 1\n\t\t\t#puts sum\n\t\t\tif sum == n && sum_cnt >= 2\n\t\t\t\tcnt += 1\n\t\t\t\t#print(\"sum = \",sum,\"\\n\")\n\t\t\t\tbreak\n\t\t\telsif sum > n\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\t\tsum = 0\n\t\tsum_cnt = 0\n\tend\n\tputs cnt\n\tn = gets.to_i \nend", "language": "Ruby", "metadata": {"date": 1501984008, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p01314.html", "problem_id": "p01314", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p01314/input.txt", "sample_output_relpath": "derived/input_output/data/p01314/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01314/Ruby/s411284226.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s411284226", "user_id": "u018580670"}, "prompt_components": {"gold_output": "2\n3\n", "input_to_evaluate": "n = gets.to_i\nwhile n != 0\n\tcnt = 0\n\tsum = 0\n\tsum_cnt = 0\n\tn.times do |i|\n\t\tj = 1 + i\n\t\tloop do\n\t\t\tsum += j\n\t\t\tsum_cnt += 1\n\t\t\tj += 1\n\t\t\t#puts sum\n\t\t\tif sum == n && sum_cnt >= 2\n\t\t\t\tcnt += 1\n\t\t\t\t#print(\"sum = \",sum,\"\\n\")\n\t\t\t\tbreak\n\t\t\telsif sum > n\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\t\tsum = 0\n\t\tsum_cnt = 0\n\tend\n\tputs cnt\n\tn = gets.to_i \nend", "problem_context": "Problem A: Sum of Consecutive Integers\n\nあなたは数か月に渡る受験戦争を勝ち抜き,晴れてICPC大学に入学することができた.入学手続きの日,大学のキャンパス内では熱狂的なサークルの勧誘活動が行われており,あなたは大量のパンフレットを受け取って帰ってきた.部屋に戻ってきたあなたは受け取ったパンフレットの中から気になる一枚を見つけた.そのパンフレットは大学の広報部から渡されたものだった.\n\nパンフレットには以下のような問題が記されていた.\n\n和が N となるような,連続する2つ以上の正の整数の組み合わせは,何組存在するでしょうか?例えば, 9 は 2+3+4 と 4+5 の 2通りの組み合わせがあります.\n\nこの問題の答えが気になったあなたは,プログラムを書いてその答えを調べることにした.したがって,あなたの仕事は,入力として与えられる正の整数 N に対して,問題の答えを出力するプログラムを書くことである.\n\nInput\n\n入力はデータセットの並びである.各データセットはひとつの整数 N からなる一行である.ここで 1 ≤ N ≤ 1000 である.\n\n入力の終りは,ひとつのゼロからなる一行で示される.\n\nOutput\n\n出力は,入力の各データセットの表す正の整数に対する問題の答えを,入力データセットの順序通りに並べたものである.それ以外の文字が出力にあってはならない.\n\nSample Input\n\n9\n500\n0\n\nOutput for the Sample Input\n\n2\n3", "sample_input": "9\n500\n0\n"}, "reference_outputs": ["2\n3\n"], "source_document_id": "p01314", "source_text": "Problem A: Sum of Consecutive Integers\n\nあなたは数か月に渡る受験戦争を勝ち抜き,晴れてICPC大学に入学することができた.入学手続きの日,大学のキャンパス内では熱狂的なサークルの勧誘活動が行われており,あなたは大量のパンフレットを受け取って帰ってきた.部屋に戻ってきたあなたは受け取ったパンフレットの中から気になる一枚を見つけた.そのパンフレットは大学の広報部から渡されたものだった.\n\nパンフレットには以下のような問題が記されていた.\n\n和が N となるような,連続する2つ以上の正の整数の組み合わせは,何組存在するでしょうか?例えば, 9 は 2+3+4 と 4+5 の 2通りの組み合わせがあります.\n\nこの問題の答えが気になったあなたは,プログラムを書いてその答えを調べることにした.したがって,あなたの仕事は,入力として与えられる正の整数 N に対して,問題の答えを出力するプログラムを書くことである.\n\nInput\n\n入力はデータセットの並びである.各データセットはひとつの整数 N からなる一行である.ここで 1 ≤ N ≤ 1000 である.\n\n入力の終りは,ひとつのゼロからなる一行で示される.\n\nOutput\n\n出力は,入力の各データセットの表す正の整数に対する問題の答えを,入力データセットの順序通りに並べたものである.それ以外の文字が出力にあってはならない.\n\nSample Input\n\n9\n500\n0\n\nOutput for the Sample Input\n\n2\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": 330, "cpu_time_ms": 90, "memory_kb": 8712}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s538569399", "group_id": "codeNet:p01359", "input_text": "loop {\n n, q = gets.split.map(&:to_i)\n break if n + q == 0\n d = Hash.new\n n.times do\n s, a, b = gets.split\n a, b = [a, b].map(&:to_i)\n d[(b - a + 1)..b] = s\n end\n q.times do\n a = gets.to_i\n flag = false\n d.each do |r, s|\n if r.include?(a)\n puts [s, a - r.begin + 1].join(' ')\n flag = true\n end\n end\n puts \"Unknown\" if !flag\n end\n}\n", "language": "Ruby", "metadata": {"date": 1586650989, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p01359.html", "problem_id": "p01359", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p01359/input.txt", "sample_output_relpath": "derived/input_output/data/p01359/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01359/Ruby/s538569399.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s538569399", "user_id": "u806257385"}, "prompt_components": {"gold_output": "meiji 1\ntaisho 6\nUnknown\nUnknown\n", "input_to_evaluate": "loop {\n n, q = gets.split.map(&:to_i)\n break if n + q == 0\n d = Hash.new\n n.times do\n s, a, b = gets.split\n a, b = [a, b].map(&:to_i)\n d[(b - a + 1)..b] = s\n end\n q.times do\n a = gets.to_i\n flag = false\n d.each do |r, s|\n if r.include?(a)\n puts [s, a - r.begin + 1].join(' ')\n flag = true\n end\n end\n puts \"Unknown\" if !flag\n end\n}\n", "problem_context": "Problem A: Era Name\n\nAs many of you know, we have two major calendar systems used in Japan today. One of them\nis Gregorian calendar which is widely used across the world. It is also known as “Western\ncalendar” in Japan.\n\nThe other calendar system is era-based calendar, or so-called “Japanese calendar.” This system\ncomes from ancient Chinese systems. Recently in Japan it has been a common way to associate\ndates with the Emperors. In the era-based system, we represent a year with an era name given\nat the time a new Emperor assumes the throne. If the era name is “A”, the first regnal year\nwill be “A 1”, the second year will be “A 2”, and so forth.\n\nSince we have two different calendar systems, it is often needed to convert the date in one\ncalendar system to the other. In this problem, you are asked to write a program that converts\nwestern year to era-based year, given a database that contains association between several\nwestern years and era-based years.\n\nFor the simplicity, you can assume the following:\n\nA new era always begins on January 1st of the corresponding Gregorian year.\n\nThe first year of an era is described as 1.\n\nThere is no year in which more than one era switch takes place.\n\nPlease note that, however, the database you will see may be incomplete. In other words, some\nera that existed in the history may be missing from your data. So you will also have to detect\nthe cases where you cannot determine exactly which era the given year belongs to.\n\nInput\n\nThe input contains multiple test cases. Each test case has the following format:\n\nN Q\n\nEraName1 EraBasedYear1 WesternYear1\n\n.\n\n.\n\n.\n\nEraNameN EraBasedYearN WesternYearN\n\nQuery1\n.\n\n.\n\n.\n\nQueryQ\n\nThe first line of the input contains two positive integers N and Q (1 ≤ N ≤ 1000, 1 ≤ Q ≤ 1000).\nN is the number of database entries, and Q is the number of queries.\n\nEach of the following N lines has three components: era name, era-based year number and the\ncorresponding western year (1 ≤ EraBasedYeari ≤ WesternYeari ≤ 109 ). Each of era names\nconsist of at most 16 Roman alphabet characters. Then the last Q lines of the input specifies\nqueries (1 ≤ Queryi ≤ 109 ), each of which is a western year to compute era-based representation.\n\nThe end of input is indicated by a line containing two zeros. This line is not part of any dataset\nand hence should not be processed.\n\nYou can assume that all the western year in the input is positive integers, and that there is no\ntwo entries that share the same era name.\n\nOutput\n\nFor each query, output in a line the era name and the era-based year number corresponding to\nthe western year given, separated with a single whitespace. In case you cannot determine the\nera, output “Unknown” without quotes.\n\nSample Input\n\n4 3\nmeiji 10 1877\ntaisho 6 1917\nshowa 62 1987\nheisei 22 2010\n1868\n1917\n1988\n1 1\nuniversalcentury 123 2168\n2010\n0 0\n\nOutput for the Sample Input\n\nmeiji 1\ntaisho 6\nUnknown\nUnknown", "sample_input": "4 3\nmeiji 10 1877\ntaisho 6 1917\nshowa 62 1987\nheisei 22 2010\n1868\n1917\n1988\n1 1\nuniversalcentury 123 2168\n2010\n0 0\n"}, "reference_outputs": ["meiji 1\ntaisho 6\nUnknown\nUnknown\n"], "source_document_id": "p01359", "source_text": "Problem A: Era Name\n\nAs many of you know, we have two major calendar systems used in Japan today. One of them\nis Gregorian calendar which is widely used across the world. It is also known as “Western\ncalendar” in Japan.\n\nThe other calendar system is era-based calendar, or so-called “Japanese calendar.” This system\ncomes from ancient Chinese systems. Recently in Japan it has been a common way to associate\ndates with the Emperors. In the era-based system, we represent a year with an era name given\nat the time a new Emperor assumes the throne. If the era name is “A”, the first regnal year\nwill be “A 1”, the second year will be “A 2”, and so forth.\n\nSince we have two different calendar systems, it is often needed to convert the date in one\ncalendar system to the other. In this problem, you are asked to write a program that converts\nwestern year to era-based year, given a database that contains association between several\nwestern years and era-based years.\n\nFor the simplicity, you can assume the following:\n\nA new era always begins on January 1st of the corresponding Gregorian year.\n\nThe first year of an era is described as 1.\n\nThere is no year in which more than one era switch takes place.\n\nPlease note that, however, the database you will see may be incomplete. In other words, some\nera that existed in the history may be missing from your data. So you will also have to detect\nthe cases where you cannot determine exactly which era the given year belongs to.\n\nInput\n\nThe input contains multiple test cases. Each test case has the following format:\n\nN Q\n\nEraName1 EraBasedYear1 WesternYear1\n\n.\n\n.\n\n.\n\nEraNameN EraBasedYearN WesternYearN\n\nQuery1\n.\n\n.\n\n.\n\nQueryQ\n\nThe first line of the input contains two positive integers N and Q (1 ≤ N ≤ 1000, 1 ≤ Q ≤ 1000).\nN is the number of database entries, and Q is the number of queries.\n\nEach of the following N lines has three components: era name, era-based year number and the\ncorresponding western year (1 ≤ EraBasedYeari ≤ WesternYeari ≤ 109 ). Each of era names\nconsist of at most 16 Roman alphabet characters. Then the last Q lines of the input specifies\nqueries (1 ≤ Queryi ≤ 109 ), each of which is a western year to compute era-based representation.\n\nThe end of input is indicated by a line containing two zeros. This line is not part of any dataset\nand hence should not be processed.\n\nYou can assume that all the western year in the input is positive integers, and that there is no\ntwo entries that share the same era name.\n\nOutput\n\nFor each query, output in a line the era name and the era-based year number corresponding to\nthe western year given, separated with a single whitespace. In case you cannot determine the\nera, output “Unknown” without quotes.\n\nSample Input\n\n4 3\nmeiji 10 1877\ntaisho 6 1917\nshowa 62 1987\nheisei 22 2010\n1868\n1917\n1988\n1 1\nuniversalcentury 123 2168\n2010\n0 0\n\nOutput for the Sample Input\n\nmeiji 1\ntaisho 6\nUnknown\nUnknown", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2210, "memory_kb": 6960}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s137235831", "group_id": "codeNet:p01417", "input_text": "def bitCount(i)\n res = 0\n\n while i > 0 do\n if i % 2 == 1\n res += 1\n end\n i /= 2\n end\n\n res\nend\n\nn, m = gets.chomp.split.map(&:to_i)\n\nl = Array.new(n)\na = Array.new(n)\nb = Array.new(n)\n\nn.times do |i|\n l[i], a[i], b[i] = gets.chomp.split.map(&:to_f)\nend\n\nans = 0.0\n\n(1 << n).times do |i|\n if bitCount(i) != m\n next\n end\n\n sum = 0.0\n \n n.times do |j|\n if (i >> j) % 2 == 0\n next\n end\n n.times do |k|\n if (i >> k) % 2 == 0 || j >= k\n next\n end\n sum += (l[j] - l[k]) ** 2\n sum += (a[j] - a[k]) ** 2\n sum += (b[j] - b[k]) ** 2\n end\n end\n\n if sum > ans\n ans = sum\n end\nend\n\nputs ans", "language": "Ruby", "metadata": {"date": 1421029684, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p01417.html", "problem_id": "p01417", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p01417/input.txt", "sample_output_relpath": "derived/input_output/data/p01417/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01417/Ruby/s137235831.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s137235831", "user_id": "u385322134"}, "prompt_components": {"gold_output": "30000.00000000000000000000\n", "input_to_evaluate": "def bitCount(i)\n res = 0\n\n while i > 0 do\n if i % 2 == 1\n res += 1\n end\n i /= 2\n end\n\n res\nend\n\nn, m = gets.chomp.split.map(&:to_i)\n\nl = Array.new(n)\na = Array.new(n)\nb = Array.new(n)\n\nn.times do |i|\n l[i], a[i], b[i] = gets.chomp.split.map(&:to_f)\nend\n\nans = 0.0\n\n(1 << n).times do |i|\n if bitCount(i) != m\n next\n end\n\n sum = 0.0\n \n n.times do |j|\n if (i >> j) % 2 == 0\n next\n end\n n.times do |k|\n if (i >> k) % 2 == 0 || j >= k\n next\n end\n sum += (l[j] - l[k]) ** 2\n sum += (a[j] - a[k]) ** 2\n sum += (b[j] - b[k]) ** 2\n end\n end\n\n if sum > ans\n ans = sum\n end\nend\n\nputs ans", "problem_context": "Calender Colors\n\nTaro is a member of a programming contest circle.\nIn this circle, the members manage their schedules in the system called Great Web Calender.\n\nTaro has just added some of his friends to his calendar so that he can browse their schedule on his calendar.\nThen he noticed that the system currently displays all the schedules in only one color, mixing the schedules for all his friends.\nThis is difficult to manage because it's hard to tell whose schedule each entry is.\n\nBut actually this calender system has the feature to change the color of schedule entries, based on the person who has the entries.\nSo Taro wants to use that feature to distinguish their plans by color.\n\nGiven the colors Taro can use and the number of members,\nyour task is to calculate the subset of colors to color all schedule entries.\nThe colors are given by \"Lab color space\".\n\nIn Lab color space,\nthe distance between two colors is defined by the square sum of the difference of each element.\nTaro has to pick up the subset of colors that maximizes the sum of distances of all color pairs in the set.\n\nInput\n\nThe input is like the following style.\n\nN M\n\nL_{0} a_{0} b_{0}\n\nL_{1} a_{1} b_{1}\n\n...\n\nL_{N-1} a_{N-1} b_{N-1}\n\nThe first line contains two integers N and M (0 \\leq M \\leq N \\leq 20), where N is the number of colors in the input, and M is the number of friends Taro wants to select the colors for.\nEach of the following N lines contains three decimal integers L(0.0 \\leq L \\leq 100.0), a(-134.0 \\leq a \\leq 220.0) and b(-140.0 \\leq b \\leq 122.0) which represents a single color in Lab color space.\n\nOutput\n\nOutput the maximal of the total distance.\nThe output should not contain an error greater than 10^{-5}.\n\nSample Input 1\n\n3 2\n0 0 0\n10 10 10\n100 100 100\n\nOutput for the Sample Input 1\n\n30000.00000000000000000000\n\nSample Input 2\n\n5 3\n12.0 15.0 9.0\n10.0 -3.0 2.2\n3.5 6.8 9.0\n2.1 4.4 5.9\n1.2 4.0 -5.4\n\nOutput for the Sample Input 2\n\n1003.44000000000005456968\n\nSample Input 3\n\n2 1\n1.0 1.0 1.0\n0.0 0.0 0.0\n\nOutput for the Sample Input 3\n\n0.00000000000000000000", "sample_input": "3 2\n0 0 0\n10 10 10\n100 100 100\n"}, "reference_outputs": ["30000.00000000000000000000\n"], "source_document_id": "p01417", "source_text": "Calender Colors\n\nTaro is a member of a programming contest circle.\nIn this circle, the members manage their schedules in the system called Great Web Calender.\n\nTaro has just added some of his friends to his calendar so that he can browse their schedule on his calendar.\nThen he noticed that the system currently displays all the schedules in only one color, mixing the schedules for all his friends.\nThis is difficult to manage because it's hard to tell whose schedule each entry is.\n\nBut actually this calender system has the feature to change the color of schedule entries, based on the person who has the entries.\nSo Taro wants to use that feature to distinguish their plans by color.\n\nGiven the colors Taro can use and the number of members,\nyour task is to calculate the subset of colors to color all schedule entries.\nThe colors are given by \"Lab color space\".\n\nIn Lab color space,\nthe distance between two colors is defined by the square sum of the difference of each element.\nTaro has to pick up the subset of colors that maximizes the sum of distances of all color pairs in the set.\n\nInput\n\nThe input is like the following style.\n\nN M\n\nL_{0} a_{0} b_{0}\n\nL_{1} a_{1} b_{1}\n\n...\n\nL_{N-1} a_{N-1} b_{N-1}\n\nThe first line contains two integers N and M (0 \\leq M \\leq N \\leq 20), where N is the number of colors in the input, and M is the number of friends Taro wants to select the colors for.\nEach of the following N lines contains three decimal integers L(0.0 \\leq L \\leq 100.0), a(-134.0 \\leq a \\leq 220.0) and b(-140.0 \\leq b \\leq 122.0) which represents a single color in Lab color space.\n\nOutput\n\nOutput the maximal of the total distance.\nThe output should not contain an error greater than 10^{-5}.\n\nSample Input 1\n\n3 2\n0 0 0\n10 10 10\n100 100 100\n\nOutput for the Sample Input 1\n\n30000.00000000000000000000\n\nSample Input 2\n\n5 3\n12.0 15.0 9.0\n10.0 -3.0 2.2\n3.5 6.8 9.0\n2.1 4.4 5.9\n1.2 4.0 -5.4\n\nOutput for the Sample Input 2\n\n1003.44000000000005456968\n\nSample Input 3\n\n2 1\n1.0 1.0 1.0\n0.0 0.0 0.0\n\nOutput for the Sample Input 3\n\n0.00000000000000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 659, "cpu_time_ms": 7040, "memory_kb": 6180}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s615413078", "group_id": "codeNet:p01540", "input_text": "def compress(used_x)\n\tx_map = {}\n\tused_x.to_a.sort.each_with_index{|x, i| x_map[x] = i}\n\tx_map\nend\n\nclass Array\n\tdef accum\n\t\tinject([0]){|a, x| a + [a[-1] + x]}\n\tend\n\n\tdef accum!\n\t\t(1..size-1).each{|i|\n\t\t\tself[i] += self[i-1]\n\t\t}\n\t\tself.unshift(0)\n\tend\n\n\tdef accum_2d\n\t\tac = map{|r| r.accum}\n\t\t(1..size-1).each{|i|\n\t\t\t(1..ac[0].size-1).each{|j|\n\t\t\t\tac[i][j] += ac[i-1][j]\n\t\t\t}\n\t\t}\n\t\tac.unshift([0] * ac[0].size)\n\t\tac\n\tend\n\n\tdef accum_2d!\n\t\teach{|r| r.accum!}\n\t\t(1..size-1).each{|i|\n\t\t\t(1..self[0].size-1).each{|j|\n\t\t\t\tself[i][j] += self[i-1][j]\n\t\t\t}\n\t\t}\n\t\tunshift([0] * self[0].size)\n\tend\n\t\t\n\tdef bsearch_first_index(l = 0, r = size - 1, &pred)\n\t\treturn nil if l > r\n\t\tc = (l + r) / 2 \n\t\tif pred[self[c]]\n\t\t\tbsearch_first_index(l, c-1, &pred) || c\n\t\telse\n\t\t\tbsearch_first_index(c+1, r, &pred)\n\t\tend\n\tend\n\n\tdef bsearch_first_item(l = 0, r = size - 1, &pred)\n\t\ti = bsearch_first_index(l, r, &pred)\n\t\ti ? self[i] : nil\n\tend\n\n\tdef bsearch_last_index(l = 0, r = size - 1, &pred)\n\t\treturn nil if l > r\n\t\tc = (l + r) / 2 \n\t\tif pred[self[c]]\n\t\t\tbsearch_last_index(c+1, r, &pred) || c\n\t\telse\n\t\t\tbsearch_last_index(l, c-1, &pred)\n\t\tend\n\tend\n\n\tdef bsearch_last_item(l = 0, r = size - 1, &pred)\n\t\ti = bsearch_last_index(l, r, &pred)\n\t\ti ? self[i] : nil\n\tend\nend\n\nrequire 'set'\n\nn, m = gets.split.map &:to_i\nused_x = Set.new\nused_y = Set.new\n\ntreasure = (1..n).map{\n\tx, y = gets.split.map &:to_i\n\tused_x << x\n\tused_y << y\n\t[x, y]\n}\n\nx_map = compress(used_x)\ny_map = compress(used_y)\na = (0..x_map.size-1).map { [0] * y_map.size }\ntreasure.each{|x, y|\n\ta[x_map[x]][y_map[y]] += 1\n}\n\na.accum_2d!\n\nused_x = used_x.to_a.sort\nused_y = used_y.to_a.sort\n\nqueries = (1..m).map {\n\tgets.split.map &:to_i\n}\n\nqueries.each{|x1, y1, x2, y2|\n\ti1 = used_x.bsearch_first_index{|x| x1 <= x}\n\tif !i1\n\t\tputs 0\n\t\tbreak\n\tend\n\tj1 = used_y.bsearch_first_index{|y| y1 <= y}\n\tif !j1\n\t\tputs 0\n\t\tbreak\n\tend\n\ti2 = used_x.bsearch_last_index(i1, used_x.size-1){|x| x <= x2}\n\tif !i2\n\t\tputs 0\n\t\tbreak\n\tend\n\tj2 = used_y.bsearch_last_index(j1, used_y.size-1){|y| y <= y2}\n\tif !j2\n\t\tputs 0\n\t\tbreak\n\tend\n\n\tp a[i2+1][j2+1] - a[i2+1][j1] - a[i1][j2+1] + a[i1][j1]\n}", "language": "Ruby", "metadata": {"date": 1439218562, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p01540.html", "problem_id": "p01540", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p01540/input.txt", "sample_output_relpath": "derived/input_output/data/p01540/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01540/Ruby/s615413078.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s615413078", "user_id": "u797180951"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "def compress(used_x)\n\tx_map = {}\n\tused_x.to_a.sort.each_with_index{|x, i| x_map[x] = i}\n\tx_map\nend\n\nclass Array\n\tdef accum\n\t\tinject([0]){|a, x| a + [a[-1] + x]}\n\tend\n\n\tdef accum!\n\t\t(1..size-1).each{|i|\n\t\t\tself[i] += self[i-1]\n\t\t}\n\t\tself.unshift(0)\n\tend\n\n\tdef accum_2d\n\t\tac = map{|r| r.accum}\n\t\t(1..size-1).each{|i|\n\t\t\t(1..ac[0].size-1).each{|j|\n\t\t\t\tac[i][j] += ac[i-1][j]\n\t\t\t}\n\t\t}\n\t\tac.unshift([0] * ac[0].size)\n\t\tac\n\tend\n\n\tdef accum_2d!\n\t\teach{|r| r.accum!}\n\t\t(1..size-1).each{|i|\n\t\t\t(1..self[0].size-1).each{|j|\n\t\t\t\tself[i][j] += self[i-1][j]\n\t\t\t}\n\t\t}\n\t\tunshift([0] * self[0].size)\n\tend\n\t\t\n\tdef bsearch_first_index(l = 0, r = size - 1, &pred)\n\t\treturn nil if l > r\n\t\tc = (l + r) / 2 \n\t\tif pred[self[c]]\n\t\t\tbsearch_first_index(l, c-1, &pred) || c\n\t\telse\n\t\t\tbsearch_first_index(c+1, r, &pred)\n\t\tend\n\tend\n\n\tdef bsearch_first_item(l = 0, r = size - 1, &pred)\n\t\ti = bsearch_first_index(l, r, &pred)\n\t\ti ? self[i] : nil\n\tend\n\n\tdef bsearch_last_index(l = 0, r = size - 1, &pred)\n\t\treturn nil if l > r\n\t\tc = (l + r) / 2 \n\t\tif pred[self[c]]\n\t\t\tbsearch_last_index(c+1, r, &pred) || c\n\t\telse\n\t\t\tbsearch_last_index(l, c-1, &pred)\n\t\tend\n\tend\n\n\tdef bsearch_last_item(l = 0, r = size - 1, &pred)\n\t\ti = bsearch_last_index(l, r, &pred)\n\t\ti ? self[i] : nil\n\tend\nend\n\nrequire 'set'\n\nn, m = gets.split.map &:to_i\nused_x = Set.new\nused_y = Set.new\n\ntreasure = (1..n).map{\n\tx, y = gets.split.map &:to_i\n\tused_x << x\n\tused_y << y\n\t[x, y]\n}\n\nx_map = compress(used_x)\ny_map = compress(used_y)\na = (0..x_map.size-1).map { [0] * y_map.size }\ntreasure.each{|x, y|\n\ta[x_map[x]][y_map[y]] += 1\n}\n\na.accum_2d!\n\nused_x = used_x.to_a.sort\nused_y = used_y.to_a.sort\n\nqueries = (1..m).map {\n\tgets.split.map &:to_i\n}\n\nqueries.each{|x1, y1, x2, y2|\n\ti1 = used_x.bsearch_first_index{|x| x1 <= x}\n\tif !i1\n\t\tputs 0\n\t\tbreak\n\tend\n\tj1 = used_y.bsearch_first_index{|y| y1 <= y}\n\tif !j1\n\t\tputs 0\n\t\tbreak\n\tend\n\ti2 = used_x.bsearch_last_index(i1, used_x.size-1){|x| x <= x2}\n\tif !i2\n\t\tputs 0\n\t\tbreak\n\tend\n\tj2 = used_y.bsearch_last_index(j1, used_y.size-1){|y| y <= y2}\n\tif !j2\n\t\tputs 0\n\t\tbreak\n\tend\n\n\tp a[i2+1][j2+1] - a[i2+1][j1] - a[i1][j2+1] + a[i1][j1]\n}", "problem_context": "宝探し\n\n太郎君はある広場にお宝を探しにやってきました。この広場にはたくさんのお宝が埋められていますが、太郎君は最新の機械を持っているので、どこにお宝が埋まっているかをすべて知っています。広場はとても広いので太郎君は領域を決めてお宝を探すことにしましたが、お宝はたくさんあるためどのお宝がその領域の中にあるかすぐにわかりません。そこで太郎君はその領域の中にあるお宝の数を数えることにしました。\n\nInput\n\nn m\nx1 y1\nx2 y2\n...\nxn yn\nx11 y11 x12 y12\nx21 y21 x22 y22\n...\nxm1 ym1 xm2 ym2\n\nnは広場に埋まっているお宝の数を表す\n\nmは調べる領域の数を表す\n\n2行目からn+1行目はそれぞれのお宝が埋まっている座標を表す\n\nn+2行目からn+m+1行目はそれぞれの調べる領域を表す\n\nx軸の正の方向が東、y軸の正の方向が北を表す\n\nそれぞれの領域は長方形であり、xi1とyi1は長方形の南西の頂点の座標、xi2とyi2は長方形の北東の頂点の座標を表す\n\nConstraints\n\n1 ≤ n ≤ 5000\n1 ≤ m ≤ 5×105\n|xi|, |yi| ≤ 109 (1 ≤ i ≤ n)\n|xi1|, |yi1|, |xi2|, |yi2| ≤ 109 (1 ≤ i ≤ m)\nxi1 ≤ xi2, yi1 ≤ yi2 (1 ≤ i ≤ m)\n\nすべての入力は整数で与えられる\n\nOutput\n\nC1\nC2\n...\nCm\n\nそれぞれの領域に含まれるお宝の数を各行に出力せよ\n\nSample Input 1\n\n3 1\n1 1\n2 4\n5 3\n0 0 5 5\n\nOutput for the Sample Input 1\n\n3\n\n領域の境界線上にあるお宝も領域に含まれるものとみなす\n\nSample Input 2\n\n4 2\n-1 1\n0 3\n4 0\n2 1\n-3 1 5 1\n4 0 4 0\n\nOutput for the Sample Input 2\n\n2\n1\n\n領域は直線や点のようになる場合もある\n\nSample Input 3\n\n2 3\n0 0\n0 0\n-1 -1 1 1\n0 0 2 2\n1 1 4 4\n\nOutput for the Sample Input 3\n\n2\n2\n0\n\n同じ場所に複数のお宝が存在する場合もある\n\nSample Input 4\n\n5 5\n10 5\n-3 -8\n2 11\n6 0\n-1 3\n-3 1 3 13\n-1 -1 9 5\n-3 -8 10 11\n0 0 5 5\n-10 -9 15 10\n\nOutput for the Sample Input 4\n\n2\n2\n5\n0\n4", "sample_input": "3 1\n1 1\n2 4\n5 3\n0 0 5 5\n"}, "reference_outputs": ["3\n"], "source_document_id": "p01540", "source_text": "宝探し\n\n太郎君はある広場にお宝を探しにやってきました。この広場にはたくさんのお宝が埋められていますが、太郎君は最新の機械を持っているので、どこにお宝が埋まっているかをすべて知っています。広場はとても広いので太郎君は領域を決めてお宝を探すことにしましたが、お宝はたくさんあるためどのお宝がその領域の中にあるかすぐにわかりません。そこで太郎君はその領域の中にあるお宝の数を数えることにしました。\n\nInput\n\nn m\nx1 y1\nx2 y2\n...\nxn yn\nx11 y11 x12 y12\nx21 y21 x22 y22\n...\nxm1 ym1 xm2 ym2\n\nnは広場に埋まっているお宝の数を表す\n\nmは調べる領域の数を表す\n\n2行目からn+1行目はそれぞれのお宝が埋まっている座標を表す\n\nn+2行目からn+m+1行目はそれぞれの調べる領域を表す\n\nx軸の正の方向が東、y軸の正の方向が北を表す\n\nそれぞれの領域は長方形であり、xi1とyi1は長方形の南西の頂点の座標、xi2とyi2は長方形の北東の頂点の座標を表す\n\nConstraints\n\n1 ≤ n ≤ 5000\n1 ≤ m ≤ 5×105\n|xi|, |yi| ≤ 109 (1 ≤ i ≤ n)\n|xi1|, |yi1|, |xi2|, |yi2| ≤ 109 (1 ≤ i ≤ m)\nxi1 ≤ xi2, yi1 ≤ yi2 (1 ≤ i ≤ m)\n\nすべての入力は整数で与えられる\n\nOutput\n\nC1\nC2\n...\nCm\n\nそれぞれの領域に含まれるお宝の数を各行に出力せよ\n\nSample Input 1\n\n3 1\n1 1\n2 4\n5 3\n0 0 5 5\n\nOutput for the Sample Input 1\n\n3\n\n領域の境界線上にあるお宝も領域に含まれるものとみなす\n\nSample Input 2\n\n4 2\n-1 1\n0 3\n4 0\n2 1\n-3 1 5 1\n4 0 4 0\n\nOutput for the Sample Input 2\n\n2\n1\n\n領域は直線や点のようになる場合もある\n\nSample Input 3\n\n2 3\n0 0\n0 0\n-1 -1 1 1\n0 0 2 2\n1 1 4 4\n\nOutput for the Sample Input 3\n\n2\n2\n0\n\n同じ場所に複数のお宝が存在する場合もある\n\nSample Input 4\n\n5 5\n10 5\n-3 -8\n2 11\n6 0\n-1 3\n-3 1 3 13\n-1 -1 9 5\n-3 -8 10 11\n0 0 5 5\n-10 -9 15 10\n\nOutput for the Sample Input 4\n\n2\n2\n5\n0\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2113, "cpu_time_ms": 17970, "memory_kb": 793612}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s698271684", "group_id": "codeNet:p01558", "input_text": "class String\n\tdef suffix_array\n\t\tbuckets = {}\n\t\t(0..size-1).each do |i|\n\t\t\t(buckets[self[i]] ||= []) << i\n\t\tend\t\n\t\tindex_table = []\n\t\tr = 0\n\t\trank = []\n\t\tbuckets.keys.sort.each do |c|\n\t\t\tbuckets[c].each do |i|\n\t\t\t\trank[i] = r + buckets[c].size - 1\n\t\t\tend\n\t\t\tr += buckets[c].size\n\t\t\tindex_table << buckets[c].pop until buckets[c].empty?\n\t\tend\n\n\t\td = 1\n\t\tloop do\n\t\t\ti = 0\n\t\t\tloop do\n\t\t\t\tj = index_table[i]\n\t\t\t\tr = rank[j]\n\t\t\t\tif i == r\n\t\t\t\t\ti += 1\n\t\t\t\telse\n\t\t\t\t\tindex_table.sa_sort!(i, r, rank, d)\n\t\t\t\t\ti = r + 1\n\t\t\t\tend\n\t\t\t\tbreak if i >= size\n\t\t\tend\n\t\t\td <<= 1\n\t\t\tbreak if d >= self.size\n\t\tend\n\n\t\tindex_table\n\tend\t\nend\n\nclass Array\n\tdef sa_sort!(l, r, rank, d)\n\t\tif r <= l\n\t\t\tif l == r\n\t\t\t\trank[self[l]] = l\n\t\t\tend\n\t\t\treturn\n\t\tend\n\t\tpivot_idx = self[rand(r-l+1) + l]\n\t\tpivot_rank = (rank[pivot_idx + d] || -1)\n\n\t\tlesser = l\n\t\tgreater = r\n\t\ti = l\n\t\tloop do\n\t\t\tbreak if i > greater\n\t\t\ttarget_rank = (rank[self[i] + d] || -1)\n\t\t\tif target_rank < pivot_rank\n\t\t\t\tself[i], self[lesser] = self[lesser], self[i]\n\t\t\t\tlesser += 1\n\t\t\t\ti += 1\n\t\t\telsif target_rank > pivot_rank\n\t\t \t\tself[i], self[greater] = self[greater], self[i]\n\t\t \t\tgreater -= 1\n\t\t\telse\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\n\n\t\traise if greater < 0\n\t\tsa_sort!(l, lesser-1, rank, d)\n\t\t(lesser..greater).each do |i|\n\t\t\trank[self[i]] = greater\n\t\tend\n\t\tsa_sort!(greater+1, r, rank, d)\n\tend\n\n\tdef bsearch_first_index(l = 0, r = size - 1, &pred)\n\t\treturn nil if l > r\n\t\tc = (l + r) / 2 \n\t\tif pred[self[c]]\n\t\t\tbsearch_first_index(l, c-1, &pred) || c\n\t\telse\n\t\t\tbsearch_first_index(c+1, r, &pred)\n\t\tend\n\tend\n\n\tdef bsearch_last_index(l = 0, r = size - 1, &pred)\n\t\treturn nil if l > r\n\t\tc = (l + r) / 2 \n\t\tif pred[self[c]]\n\t\t\tbsearch_last_index(c+1, r, &pred) || c\n\t\telse\n\t\t\tbsearch_last_index(l, c-1, &pred)\n\t\tend\n\tend\nend\n\nrequire 'set'\nn, m = gets.split.map(&:to_i)\nstr = gets.chomp\nsa = str.suffix_array\n\nsize_idx = {}\nl = r = 0\nm.times do\n\tquery = gets.chomp.downcase[0..-2] + \"=1\"\n\teval query\n\t(size_idx[r - l] ||= Set.new) << l\nend\n\nnum = 0\nsize_idx.each do |size, indices|\n\tused = Set.new\n\tindices.each do |l|\n\t\tnext if used.include?(l)\n\t\tnum += 1\n\t\tsubstr = str[l..l+size]\n\t\ti = sa.bsearch_first_index {|k| substr <= str[k..k+size]}\n\t\tj = sa.bsearch_last_index {|k| str[k..k+size] <= substr}\n\t\tsa[i..j].each {|x| used << x}\n\tend\nend\n\np num", "language": "Ruby", "metadata": {"date": 1462713380, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p01558.html", "problem_id": "p01558", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p01558/input.txt", "sample_output_relpath": "derived/input_output/data/p01558/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01558/Ruby/s698271684.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s698271684", "user_id": "u797180951"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "class String\n\tdef suffix_array\n\t\tbuckets = {}\n\t\t(0..size-1).each do |i|\n\t\t\t(buckets[self[i]] ||= []) << i\n\t\tend\t\n\t\tindex_table = []\n\t\tr = 0\n\t\trank = []\n\t\tbuckets.keys.sort.each do |c|\n\t\t\tbuckets[c].each do |i|\n\t\t\t\trank[i] = r + buckets[c].size - 1\n\t\t\tend\n\t\t\tr += buckets[c].size\n\t\t\tindex_table << buckets[c].pop until buckets[c].empty?\n\t\tend\n\n\t\td = 1\n\t\tloop do\n\t\t\ti = 0\n\t\t\tloop do\n\t\t\t\tj = index_table[i]\n\t\t\t\tr = rank[j]\n\t\t\t\tif i == r\n\t\t\t\t\ti += 1\n\t\t\t\telse\n\t\t\t\t\tindex_table.sa_sort!(i, r, rank, d)\n\t\t\t\t\ti = r + 1\n\t\t\t\tend\n\t\t\t\tbreak if i >= size\n\t\t\tend\n\t\t\td <<= 1\n\t\t\tbreak if d >= self.size\n\t\tend\n\n\t\tindex_table\n\tend\t\nend\n\nclass Array\n\tdef sa_sort!(l, r, rank, d)\n\t\tif r <= l\n\t\t\tif l == r\n\t\t\t\trank[self[l]] = l\n\t\t\tend\n\t\t\treturn\n\t\tend\n\t\tpivot_idx = self[rand(r-l+1) + l]\n\t\tpivot_rank = (rank[pivot_idx + d] || -1)\n\n\t\tlesser = l\n\t\tgreater = r\n\t\ti = l\n\t\tloop do\n\t\t\tbreak if i > greater\n\t\t\ttarget_rank = (rank[self[i] + d] || -1)\n\t\t\tif target_rank < pivot_rank\n\t\t\t\tself[i], self[lesser] = self[lesser], self[i]\n\t\t\t\tlesser += 1\n\t\t\t\ti += 1\n\t\t\telsif target_rank > pivot_rank\n\t\t \t\tself[i], self[greater] = self[greater], self[i]\n\t\t \t\tgreater -= 1\n\t\t\telse\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\n\n\t\traise if greater < 0\n\t\tsa_sort!(l, lesser-1, rank, d)\n\t\t(lesser..greater).each do |i|\n\t\t\trank[self[i]] = greater\n\t\tend\n\t\tsa_sort!(greater+1, r, rank, d)\n\tend\n\n\tdef bsearch_first_index(l = 0, r = size - 1, &pred)\n\t\treturn nil if l > r\n\t\tc = (l + r) / 2 \n\t\tif pred[self[c]]\n\t\t\tbsearch_first_index(l, c-1, &pred) || c\n\t\telse\n\t\t\tbsearch_first_index(c+1, r, &pred)\n\t\tend\n\tend\n\n\tdef bsearch_last_index(l = 0, r = size - 1, &pred)\n\t\treturn nil if l > r\n\t\tc = (l + r) / 2 \n\t\tif pred[self[c]]\n\t\t\tbsearch_last_index(c+1, r, &pred) || c\n\t\telse\n\t\t\tbsearch_last_index(l, c-1, &pred)\n\t\tend\n\tend\nend\n\nrequire 'set'\nn, m = gets.split.map(&:to_i)\nstr = gets.chomp\nsa = str.suffix_array\n\nsize_idx = {}\nl = r = 0\nm.times do\n\tquery = gets.chomp.downcase[0..-2] + \"=1\"\n\teval query\n\t(size_idx[r - l] ||= Set.new) << l\nend\n\nnum = 0\nsize_idx.each do |size, indices|\n\tused = Set.new\n\tindices.each do |l|\n\t\tnext if used.include?(l)\n\t\tnum += 1\n\t\tsubstr = str[l..l+size]\n\t\ti = sa.bsearch_first_index {|k| substr <= str[k..k+size]}\n\t\tj = sa.bsearch_last_index {|k| str[k..k+size] <= substr}\n\t\tsa[i..j].each {|x| used << x}\n\tend\nend\n\np num", "problem_context": "Substring\n\n長さnの文字列s=s1,s2,…,snおよびm個のクエリが与えられる。\n各クエリqk (1 ≤ k ≤ m)は、\"L++\", \"L--\", \"R++\", \"R--\"の4種類のいずれかであり、\nk番目のクエリqkに対してl[k]とr[k]を以下で定義する。\n\nL++:l[k]=l[k-1]+1,r[k]=r[k-1]\n\nL--:l[k]=l[k-1]-1,r[k]=r[k-1]\n\nR++:l[k]=l[k-1],r[k]=r[k-1]+1\n\nR--:l[k]=l[k-1],r[k]=r[k-1]-1\n\n但し、l[0]=r[0]=1である。\n\nこの時、m個の部分文字列\nsl[k], sl[k]+1, …, sr[k]-1, sr[k] (1 ≤ k ≤ m)\nについて、何種類の文字列が作られるかを答えよ。\n\nInput\n\n入力は以下の形式で与えられる\n\nn m\ns\nq1\nq2\n…\nqm\n\nConstraints\n\n文字列sは小文字アルファベットからなる\n\n1 ≤ n ≤ 3×105\n\n1 ≤ m ≤ 3×105\n\nqk(1 ≤ k ≤ m)は、\"L++\"、\"L--\"、\"R++\"、\"R--\"のいずれか\n\n1 ≤ l[k] ≤ r[k] ≤ n (1 ≤ k ≤ m)\n\nOutput\n\n問題の解を1行に出力せよ\n\nSample Input 1\n\n5 4\nabcde\nR++\nR++\nL++\nL--\n\nOutput for the Sample Input 1\n\n3\n\nl[1]=1, r[1]=2であり、部分文字列は\"ab\"である\n\nl[2]=1, r[2]=3であり、部分文字列は\"abc\"である\n\nl[3]=2, r[3]=3であり、部分文字列は\"bc\"である\n\nl[4]=1, r[4]=3であり、部分文字列は\"abc\"である\n\nよって、生成される文字列は{\"ab\",\"abc\",\"bc\"}の3種類である。\n\nSample Input 2\n\n4 6\nabab\nR++\nL++\nR++\nL++\nR++\nL++\n\nOutput for the Sample Input 2\n\n4\n\nl[1]=1, r[1]=2であり、部分文字列は\"ab\"である\n\nl[2]=2, r[2]=2であり、部分文字列は\"b\"である\n\nl[3]=2, r[3]=3であり、部分文字列は\"ba\"である\n\nl[4]=3, r[4]=3であり、部分文字列は\"a\"である\n\nl[5]=3, r[5]=4であり、部分文字列は\"ab\"である\n\nl[6]=4, r[6]=4であり、部分文字列は\"b\"である\n\nよって、生成される文字列は{\"a\",\"ab\",\"b\",\"ba\"}の4種類である。\n\nSample Input 3\n\n10 13\naacacbabac\nR++\nR++\nL++\nR++\nR++\nL++\nL++\nR++\nR++\nL--\nL--\nR--\nR--\n\nOutput for the Sample Input 3\n\n11", "sample_input": "5 4\nabcde\nR++\nR++\nL++\nL--\n"}, "reference_outputs": ["3\n"], "source_document_id": "p01558", "source_text": "Substring\n\n長さnの文字列s=s1,s2,…,snおよびm個のクエリが与えられる。\n各クエリqk (1 ≤ k ≤ m)は、\"L++\", \"L--\", \"R++\", \"R--\"の4種類のいずれかであり、\nk番目のクエリqkに対してl[k]とr[k]を以下で定義する。\n\nL++:l[k]=l[k-1]+1,r[k]=r[k-1]\n\nL--:l[k]=l[k-1]-1,r[k]=r[k-1]\n\nR++:l[k]=l[k-1],r[k]=r[k-1]+1\n\nR--:l[k]=l[k-1],r[k]=r[k-1]-1\n\n但し、l[0]=r[0]=1である。\n\nこの時、m個の部分文字列\nsl[k], sl[k]+1, …, sr[k]-1, sr[k] (1 ≤ k ≤ m)\nについて、何種類の文字列が作られるかを答えよ。\n\nInput\n\n入力は以下の形式で与えられる\n\nn m\ns\nq1\nq2\n…\nqm\n\nConstraints\n\n文字列sは小文字アルファベットからなる\n\n1 ≤ n ≤ 3×105\n\n1 ≤ m ≤ 3×105\n\nqk(1 ≤ k ≤ m)は、\"L++\"、\"L--\"、\"R++\"、\"R--\"のいずれか\n\n1 ≤ l[k] ≤ r[k] ≤ n (1 ≤ k ≤ m)\n\nOutput\n\n問題の解を1行に出力せよ\n\nSample Input 1\n\n5 4\nabcde\nR++\nR++\nL++\nL--\n\nOutput for the Sample Input 1\n\n3\n\nl[1]=1, r[1]=2であり、部分文字列は\"ab\"である\n\nl[2]=1, r[2]=3であり、部分文字列は\"abc\"である\n\nl[3]=2, r[3]=3であり、部分文字列は\"bc\"である\n\nl[4]=1, r[4]=3であり、部分文字列は\"abc\"である\n\nよって、生成される文字列は{\"ab\",\"abc\",\"bc\"}の3種類である。\n\nSample Input 2\n\n4 6\nabab\nR++\nL++\nR++\nL++\nR++\nL++\n\nOutput for the Sample Input 2\n\n4\n\nl[1]=1, r[1]=2であり、部分文字列は\"ab\"である\n\nl[2]=2, r[2]=2であり、部分文字列は\"b\"である\n\nl[3]=2, r[3]=3であり、部分文字列は\"ba\"である\n\nl[4]=3, r[4]=3であり、部分文字列は\"a\"である\n\nl[5]=3, r[5]=4であり、部分文字列は\"ab\"である\n\nl[6]=4, r[6]=4であり、部分文字列は\"b\"である\n\nよって、生成される文字列は{\"a\",\"ab\",\"b\",\"ba\"}の4種類である。\n\nSample Input 3\n\n10 13\naacacbabac\nR++\nR++\nL++\nR++\nR++\nL++\nL++\nR++\nR++\nL--\nL--\nR--\nR--\n\nOutput for the Sample Input 3\n\n11", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2279, "cpu_time_ms": 40000, "memory_kb": 191788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s294603153", "group_id": "codeNet:p01892", "input_text": "#!/usr/bin/ruby\na,b,n=gets.split.map(&:to_i)\nr=Float::INFINITY\n(1..n).each{|i|\n\tif b%i==0\n\t\t(1..n).each{|j|\n\t\t\tr=[r,(a-b/i*j).abs].min\n\t\t}\n\tend\n}\np r", "language": "Ruby", "metadata": {"date": 1474695840, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p01892.html", "problem_id": "p01892", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p01892/input.txt", "sample_output_relpath": "derived/input_output/data/p01892/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01892/Ruby/s294603153.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s294603153", "user_id": "u300645821"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#!/usr/bin/ruby\na,b,n=gets.split.map(&:to_i)\nr=Float::INFINITY\n(1..n).each{|i|\n\tif b%i==0\n\t\t(1..n).each{|j|\n\t\t\tr=[r,(a-b/i*j).abs].min\n\t\t}\n\tend\n}\np r", "problem_context": "MathJax.Hub.Config({\ntex2jax: {inlineMath: [['$','$'], ['\\\\(','\\\\)']]}\n});\n\nB: イカったー / SNS\n\n問題文\n\nAOR イカちゃんは最近少し機嫌が悪い。\nどうやら、”イカったー”のフォロー数とフォロワー数の比が気に入らないようだ\n。現在、AOR イカちゃんのフォロー数は $A$ 人、フォロワー数は $B$ 人であり、比は $A:B$ である。\n\nそこで、AOR イカちゃんはフォロー数とフォロワー数の比が気に入った整数比になるように、フォロー数を増減させることにした。\nなお気に入った整数比とは、比に含まれるどちらの値も $1$ 以上 $N$ 以下の整数となるように表せる比である。\n\nしかし、AOR イカちゃんはできるだけフォロー数を変更したくないので、変更前との差の絶対値をできるだけ小さくしたい。\nAOR イカちゃんの機嫌を良くするために、少なくともフォロー数をいくつ変更する必要があるかを求めるプログラムを作成せよ。\n\n入力\n\n$A \\ B \\ N$\n\n入力の制約\n\n$1 \\le A, \\ B \\le 10^{12}$\n\n$1 \\leq N \\leq 100 $\n\n出力\n\n気に入った整数比にできる、$A$ の変化量の絶対値の最小値を出力せよ。\n\nサンプル\n\nサンプル入力1\n\n19 30 3\n\nサンプル出力1\n\n1\n\nサンプル入力2\n\n3 7 7\n\nサンプル出力2\n\n0\n\nサンプル入力3\n\n3 7 1\n\nサンプル出力3\n\n4\n\nサンプル入力4\n\n102 30 3\n\nサンプル出力4\n\n12\n\nフォローを $12$ 人減らすことで $90:30 \\ (=3:1)$ になり、比の大きい方の数字が $3$ 以下となります。\n\nこのとき、変化量は $12$ です。\n\nサンプル入力5\n\n3 4 2\n\nサンプル出力5\n\n1\n\n一人フォローを外すと $2:4 \\ (=1:2)$ に、フォローすると $4:4 \\ (=1:1)$ になり、どちらも増減の絶対値は $1$ でそれが答えです。\n\nサンプル入力6\n\n1 100 2\n\nサンプル出力6\n\n49\n\n最低でも $1$ 人はフォローしていなければいけない事に注意してください。", "sample_input": "19 30 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p01892", "source_text": "MathJax.Hub.Config({\ntex2jax: {inlineMath: [['$','$'], ['\\\\(','\\\\)']]}\n});\n\nB: イカったー / SNS\n\n問題文\n\nAOR イカちゃんは最近少し機嫌が悪い。\nどうやら、”イカったー”のフォロー数とフォロワー数の比が気に入らないようだ\n。現在、AOR イカちゃんのフォロー数は $A$ 人、フォロワー数は $B$ 人であり、比は $A:B$ である。\n\nそこで、AOR イカちゃんはフォロー数とフォロワー数の比が気に入った整数比になるように、フォロー数を増減させることにした。\nなお気に入った整数比とは、比に含まれるどちらの値も $1$ 以上 $N$ 以下の整数となるように表せる比である。\n\nしかし、AOR イカちゃんはできるだけフォロー数を変更したくないので、変更前との差の絶対値をできるだけ小さくしたい。\nAOR イカちゃんの機嫌を良くするために、少なくともフォロー数をいくつ変更する必要があるかを求めるプログラムを作成せよ。\n\n入力\n\n$A \\ B \\ N$\n\n入力の制約\n\n$1 \\le A, \\ B \\le 10^{12}$\n\n$1 \\leq N \\leq 100 $\n\n出力\n\n気に入った整数比にできる、$A$ の変化量の絶対値の最小値を出力せよ。\n\nサンプル\n\nサンプル入力1\n\n19 30 3\n\nサンプル出力1\n\n1\n\nサンプル入力2\n\n3 7 7\n\nサンプル出力2\n\n0\n\nサンプル入力3\n\n3 7 1\n\nサンプル出力3\n\n4\n\nサンプル入力4\n\n102 30 3\n\nサンプル出力4\n\n12\n\nフォローを $12$ 人減らすことで $90:30 \\ (=3:1)$ になり、比の大きい方の数字が $3$ 以下となります。\n\nこのとき、変化量は $12$ です。\n\nサンプル入力5\n\n3 4 2\n\nサンプル出力5\n\n1\n\n一人フォローを外すと $2:4 \\ (=1:2)$ に、フォローすると $4:4 \\ (=1:1)$ になり、どちらも増減の絶対値は $1$ でそれが答えです。\n\nサンプル入力6\n\n1 100 2\n\nサンプル出力6\n\n49\n\n最低でも $1$ 人はフォローしていなければいけない事に注意してください。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 149, "cpu_time_ms": 60, "memory_kb": 8748}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s039777796", "group_id": "codeNet:p01965", "input_text": "class FarmVillage\n def initialize(number_of_houses:, carrying_costs:, growing_costs:)\n @number_of_houses = number_of_houses\n @carrying_costs = carrying_costs.dup\n @growing_costs = growing_costs.dup\n end\n\n def calc_total_cost\n total_cost = 0\n\n @fields_productions = Array.new(@number_of_houses, 0)\n @left_moves = Array.new(@number_of_houses-1, 0)\n @right_moves = Array.new(@number_of_houses-1, 0)\n\n # order houses index by growing cost\n houses = (0...@number_of_houses).zip(@growing_costs).sort {|a, b| b[1] <=> a[1]}.map {|t| t[0]}\n\n houses.each do |house|\n local_cost = @growing_costs[house] if @fields_productions[house] < 2\n left_cost, left_crop_house = calc_left_crop_cost(consumer_house: house)\n right_cost, right_crop_house = calc_right_crop_cost(consumer_house: house)\n\n costs = []\n costs << local_cost unless local_cost.nil?\n costs << left_cost unless left_cost.nil?\n costs << right_cost unless right_cost.nil?\n\n if local_cost == costs.min\n @fields_productions[house] += 1\n elsif left_cost == costs.min\n @fields_productions[left_crop_house] += 1\n change_moves_to_left(from: house, to: left_crop_house)\n elsif right_cost == costs.min\n @fields_productions[right_crop_house] += 1\n change_moves_to_right(from: house, to: right_crop_house)\n end\n end\n\n sum_prices\n end\n\n private\n\n def change_moves_to_left(from:, to:)\n (to...from).each do |road|\n if @right_moves[road] > 0\n @right_moves[road] -= 1\n else\n @left_moves[road] += 1\n end\n end\n end\n\n def change_moves_to_right(from:, to:)\n (from...to).each do |road|\n if @left_moves[road] > 0\n @left_moves[road] -= 1\n else\n @right_moves[road] += 1\n end\n end\n end\n\n def sum_prices\n total_cost = 0\n (0...@number_of_houses).each do |house|\n total_cost += @growing_costs[house] * @fields_productions[house]\n end\n @carrying_costs.each_with_index do |cost, index|\n total_cost += @left_moves[index] * cost\n total_cost += @right_moves[index] * cost\n end\n total_cost\n end\n\n def calc_left_crop_cost(consumer_house:)\n lower_cost = nil\n crop_house = nil\n\n road_cost = 0\n finish_first_discount_road = false\n (0...consumer_house).each do |house|\n aux_house = consumer_house - 1 - house\n if @right_moves[aux_house] > 0\n road_cost -= @carrying_costs[aux_house]\n else\n road_cost += @carrying_costs[aux_house]\n finish_first_discount_road = true\n end\n next unless @fields_productions[aux_house] < 2\n\n house_cost = road_cost + @growing_costs[aux_house]\n if lower_cost.nil? || house_cost < lower_cost\n lower_cost = house_cost\n crop_house = aux_house\n elsif finish_first_discount_road\n break\n end\n end\n\n [lower_cost, crop_house]\n end\n\n def calc_right_crop_cost(consumer_house:)\n lower_cost = nil\n crop_house = nil\n\n road_cost = 0\n finish_first_discount_road = false\n ((consumer_house+1)...@number_of_houses).each do |house|\n if @left_moves[house-1] > 0\n road_cost -= @carrying_costs[house-1]\n else\n road_cost += @carrying_costs[house-1]\n finish_first_discount_road = true\n end\n next unless @fields_productions[house] < 2\n\n house_cost = road_cost + @growing_costs[house]\n if lower_cost.nil? || house_cost < lower_cost\n lower_cost = house_cost\n crop_house = house\n elsif finish_first_discount_road\n break\n end\n end\n\n [lower_cost, crop_house]\n end\nend\n\nnumber_of_houses = gets.to_i\ncarrying_costs = gets.split.map(&:to_i)\ngrowing_costs = gets.split.map(&:to_i)\n\nfarm_village = FarmVillage.new(number_of_houses: number_of_houses,\n carrying_costs: carrying_costs,\n growing_costs: growing_costs)\n\nputs farm_village.calc_total_cost", "language": "Ruby", "metadata": {"date": 1512369812, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p01965.html", "problem_id": "p01965", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p01965/input.txt", "sample_output_relpath": "derived/input_output/data/p01965/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01965/Ruby/s039777796.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s039777796", "user_id": "u353395258"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "class FarmVillage\n def initialize(number_of_houses:, carrying_costs:, growing_costs:)\n @number_of_houses = number_of_houses\n @carrying_costs = carrying_costs.dup\n @growing_costs = growing_costs.dup\n end\n\n def calc_total_cost\n total_cost = 0\n\n @fields_productions = Array.new(@number_of_houses, 0)\n @left_moves = Array.new(@number_of_houses-1, 0)\n @right_moves = Array.new(@number_of_houses-1, 0)\n\n # order houses index by growing cost\n houses = (0...@number_of_houses).zip(@growing_costs).sort {|a, b| b[1] <=> a[1]}.map {|t| t[0]}\n\n houses.each do |house|\n local_cost = @growing_costs[house] if @fields_productions[house] < 2\n left_cost, left_crop_house = calc_left_crop_cost(consumer_house: house)\n right_cost, right_crop_house = calc_right_crop_cost(consumer_house: house)\n\n costs = []\n costs << local_cost unless local_cost.nil?\n costs << left_cost unless left_cost.nil?\n costs << right_cost unless right_cost.nil?\n\n if local_cost == costs.min\n @fields_productions[house] += 1\n elsif left_cost == costs.min\n @fields_productions[left_crop_house] += 1\n change_moves_to_left(from: house, to: left_crop_house)\n elsif right_cost == costs.min\n @fields_productions[right_crop_house] += 1\n change_moves_to_right(from: house, to: right_crop_house)\n end\n end\n\n sum_prices\n end\n\n private\n\n def change_moves_to_left(from:, to:)\n (to...from).each do |road|\n if @right_moves[road] > 0\n @right_moves[road] -= 1\n else\n @left_moves[road] += 1\n end\n end\n end\n\n def change_moves_to_right(from:, to:)\n (from...to).each do |road|\n if @left_moves[road] > 0\n @left_moves[road] -= 1\n else\n @right_moves[road] += 1\n end\n end\n end\n\n def sum_prices\n total_cost = 0\n (0...@number_of_houses).each do |house|\n total_cost += @growing_costs[house] * @fields_productions[house]\n end\n @carrying_costs.each_with_index do |cost, index|\n total_cost += @left_moves[index] * cost\n total_cost += @right_moves[index] * cost\n end\n total_cost\n end\n\n def calc_left_crop_cost(consumer_house:)\n lower_cost = nil\n crop_house = nil\n\n road_cost = 0\n finish_first_discount_road = false\n (0...consumer_house).each do |house|\n aux_house = consumer_house - 1 - house\n if @right_moves[aux_house] > 0\n road_cost -= @carrying_costs[aux_house]\n else\n road_cost += @carrying_costs[aux_house]\n finish_first_discount_road = true\n end\n next unless @fields_productions[aux_house] < 2\n\n house_cost = road_cost + @growing_costs[aux_house]\n if lower_cost.nil? || house_cost < lower_cost\n lower_cost = house_cost\n crop_house = aux_house\n elsif finish_first_discount_road\n break\n end\n end\n\n [lower_cost, crop_house]\n end\n\n def calc_right_crop_cost(consumer_house:)\n lower_cost = nil\n crop_house = nil\n\n road_cost = 0\n finish_first_discount_road = false\n ((consumer_house+1)...@number_of_houses).each do |house|\n if @left_moves[house-1] > 0\n road_cost -= @carrying_costs[house-1]\n else\n road_cost += @carrying_costs[house-1]\n finish_first_discount_road = true\n end\n next unless @fields_productions[house] < 2\n\n house_cost = road_cost + @growing_costs[house]\n if lower_cost.nil? || house_cost < lower_cost\n lower_cost = house_cost\n crop_house = house\n elsif finish_first_discount_road\n break\n end\n end\n\n [lower_cost, crop_house]\n end\nend\n\nnumber_of_houses = gets.to_i\ncarrying_costs = gets.split.map(&:to_i)\ngrowing_costs = gets.split.map(&:to_i)\n\nfarm_village = FarmVillage.new(number_of_houses: number_of_houses,\n carrying_costs: carrying_costs,\n growing_costs: growing_costs)\n\nputs farm_village.calc_total_cost", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"code\"], processEscapes: true }});\n\nFarm Village\n\nThere is a village along a road. This village has $N$ houses numbered $1$ to $N$ in order along the road. Each house has a field that can make up to two units of the crop and needs just one unit of the crop. The total cost to distribute one unit of the crop to each house is the summation of carrying costs and growing costs.\n\nThe carrying cost: The cost to carry one unit of the crop between the $i$-th house and the ($i+1$)-th house is $d_i$. It takes the same cost in either direction to carry.\n\nThe growing cost: The cost to grow one unit of the crop in the $i$-th house's field is $g_i$.\n\nYour task is to calculate the minimum total cost to supply one unit of the crop to each house.\n\nInput\n\nThe input consists of a single test case formatted as follows.\n\n$N$\n$d_1$ ... $d_{N-1}$\n$g_1$ ... $g_{N}$\n\nThe first line consists of an integer $N$ ($2 \\leq 200,000$), which is the number of the houses. The second line consists of $N-1$ integers separated by spaces. The $i$-th integer $d_i$ ($1 \\leq d_i \\leq 10^9$, $1 \\leq i \\leq N-1$)represents the carrying cost between the $i$-th and the ($i+1$)-th houses. The third line consists of $N$ integers separated by spaces. The $i$-th integer $g_i$ ($1 \\leq g_i \\leq 10^9$, $1 \\leq i \\leq N$) represents the growing cost of the $i$-th house's field.\n\nOutput\n\nPrint the minimum cost to supply one unit of the crop to each house.\n\nSample Input 1\n\n2\n3\n1 5\n\nOutput for Sample Input 1\n\n5\n\nSample Input 2\n\n3\n100 100\n1 2 3\n\nOutput for Sample Input 2\n\n6\n\nSample Input 3\n\n4\n1 2 3\n1 1 100 100\n\nOutput for Sample Input 3\n\n12", "sample_input": "2\n3\n1 5\n"}, "reference_outputs": ["5\n"], "source_document_id": "p01965", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"code\"], processEscapes: true }});\n\nFarm Village\n\nThere is a village along a road. This village has $N$ houses numbered $1$ to $N$ in order along the road. Each house has a field that can make up to two units of the crop and needs just one unit of the crop. The total cost to distribute one unit of the crop to each house is the summation of carrying costs and growing costs.\n\nThe carrying cost: The cost to carry one unit of the crop between the $i$-th house and the ($i+1$)-th house is $d_i$. It takes the same cost in either direction to carry.\n\nThe growing cost: The cost to grow one unit of the crop in the $i$-th house's field is $g_i$.\n\nYour task is to calculate the minimum total cost to supply one unit of the crop to each house.\n\nInput\n\nThe input consists of a single test case formatted as follows.\n\n$N$\n$d_1$ ... $d_{N-1}$\n$g_1$ ... $g_{N}$\n\nThe first line consists of an integer $N$ ($2 \\leq 200,000$), which is the number of the houses. The second line consists of $N-1$ integers separated by spaces. The $i$-th integer $d_i$ ($1 \\leq d_i \\leq 10^9$, $1 \\leq i \\leq N-1$)represents the carrying cost between the $i$-th and the ($i+1$)-th houses. The third line consists of $N$ integers separated by spaces. The $i$-th integer $g_i$ ($1 \\leq g_i \\leq 10^9$, $1 \\leq i \\leq N$) represents the growing cost of the $i$-th house's field.\n\nOutput\n\nPrint the minimum cost to supply one unit of the crop to each house.\n\nSample Input 1\n\n2\n3\n1 5\n\nOutput for Sample Input 1\n\n5\n\nSample Input 2\n\n3\n100 100\n1 2 3\n\nOutput for Sample Input 2\n\n6\n\nSample Input 3\n\n4\n1 2 3\n1 1 100 100\n\nOutput for Sample Input 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": 3963, "cpu_time_ms": 50, "memory_kb": 6968}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s588555709", "group_id": "codeNet:p02021", "input_text": "gets;a=gets.split.map &:to_i;p [*1..100].select{|t|s=0;a.all?{|p|0<=s+=p-t}}.max\n", "language": "Ruby", "metadata": {"date": 1545546774, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02021.html", "problem_id": "p02021", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02021/input.txt", "sample_output_relpath": "derived/input_output/data/p02021/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02021/Ruby/s588555709.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s588555709", "user_id": "u868447400"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "gets;a=gets.split.map &:to_i;p [*1..100].select{|t|s=0;a.all?{|p|0<=s+=p-t}}.max\n", "problem_context": "G: 労働 (Working)\n\nコウさんはこれから $N$ 日間、毎日同じ件数の仕事をすることにした。\n\n$N$ 日間のうち $i$ 日目には仕事が $A_i$ 件追加される。\n\nコウさんには今溜まっている仕事はなく、$N$ 日目までにすべての仕事が終わっている必要はない。\n\n一日で最大何件の仕事ができるか。\n\nただしコウさんは優秀なので、仕事が存在する限り何件でも仕事をすることができる。\n\n入力\n\n1 行目には $N$が与えられる。\n\n2 行目には $N$ 個の整数 $A_1, A_2, A_3, \\dots, A_N$ が空白区切りで与えられる。\n\n出力\n\n一日にできる仕事の最大の件数を出力せよ。最後には改行を入れること。\n\n制約\n\n$N$ は $1$ 以上 $100$ 以下の整数\n\n$A_1, A_2, A_3, \\dots, A_N$ は $1$ 以上 $100$ 以下の整数\n\n入力例1\n\n5\n4 2 5 3 1\n\n出力例1\n\n3\n\n一日 $4$ 件以上仕事することにすると、2 日目に仕事が尽きてしまいます。\n\n入力例2\n\n5\n9 9 1 9 9\n\n出力例2\n\n6", "sample_input": "5\n4 2 5 3 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02021", "source_text": "G: 労働 (Working)\n\nコウさんはこれから $N$ 日間、毎日同じ件数の仕事をすることにした。\n\n$N$ 日間のうち $i$ 日目には仕事が $A_i$ 件追加される。\n\nコウさんには今溜まっている仕事はなく、$N$ 日目までにすべての仕事が終わっている必要はない。\n\n一日で最大何件の仕事ができるか。\n\nただしコウさんは優秀なので、仕事が存在する限り何件でも仕事をすることができる。\n\n入力\n\n1 行目には $N$が与えられる。\n\n2 行目には $N$ 個の整数 $A_1, A_2, A_3, \\dots, A_N$ が空白区切りで与えられる。\n\n出力\n\n一日にできる仕事の最大の件数を出力せよ。最後には改行を入れること。\n\n制約\n\n$N$ は $1$ 以上 $100$ 以下の整数\n\n$A_1, A_2, A_3, \\dots, A_N$ は $1$ 以上 $100$ 以下の整数\n\n入力例1\n\n5\n4 2 5 3 1\n\n出力例1\n\n3\n\n一日 $4$ 件以上仕事することにすると、2 日目に仕事が尽きてしまいます。\n\n入力例2\n\n5\n9 9 1 9 9\n\n出力例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": 81, "cpu_time_ms": 40, "memory_kb": 8904}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s706769693", "group_id": "codeNet:p02116", "input_text": "n = gets.to_i\nif n.even?\n puts 1\nelsif n.to_s(2).count(?0) == 0\n puts n + 1\nelse\n x0 = n - 1\n y0 = 2\n k = 0\n loop do\n x = x0\n until x & 1 == 1\n k += 1\n x >>= 1\n end\n y = y0\n until y & 1 == 1\n k -= 1\n y >>= 1\n end\n break if k > 0\n x0 -= 2\n y0 += 2\n end\n puts y0\nend\n\n", "language": "Ruby", "metadata": {"date": 1530362326, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02116.html", "problem_id": "p02116", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02116/input.txt", "sample_output_relpath": "derived/input_output/data/p02116/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02116/Ruby/s706769693.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s706769693", "user_id": "u797180951"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n = gets.to_i\nif n.even?\n puts 1\nelsif n.to_s(2).count(?0) == 0\n puts n + 1\nelse\n x0 = n - 1\n y0 = 2\n k = 0\n loop do\n x = x0\n until x & 1 == 1\n k += 1\n x >>= 1\n end\n y = y0\n until y & 1 == 1\n k -= 1\n y >>= 1\n end\n break if k > 0\n x0 -= 2\n y0 += 2\n end\n puts y0\nend\n\n", "problem_context": "Problem F: nCm\n\nProblem\n\n整数nが与えられた時、nCm(異なるn個のものからm個を選ぶ組み合わせの数)が偶数となるような最小のmを出力せよ。\n\nInput\n\n入力は以下の形式で与えられる。\n\nn\n\nConstraints\n\n入力は以下の条件を満たす。\n\n1 ≤ n ≤ 1018\n\nOutput\n\nnCmが偶数となるような最小のmを1行に出力する。\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1\n\nSample Input 2\n\n111\n\nSample Output 2\n\n16\n\nSample Input 3\n\n3\n\nSample Output 3\n\n4", "sample_input": "2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02116", "source_text": "Problem F: nCm\n\nProblem\n\n整数nが与えられた時、nCm(異なるn個のものからm個を選ぶ組み合わせの数)が偶数となるような最小のmを出力せよ。\n\nInput\n\n入力は以下の形式で与えられる。\n\nn\n\nConstraints\n\n入力は以下の条件を満たす。\n\n1 ≤ n ≤ 1018\n\nOutput\n\nnCmが偶数となるような最小のmを1行に出力する。\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1\n\nSample Input 2\n\n111\n\nSample Output 2\n\n16\n\nSample Input 3\n\n3\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": 397, "cpu_time_ms": 9990, "memory_kb": 6888}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s964740145", "group_id": "codeNet:p02235", "input_text": "gets.to_i.times{\ns=gets.chop\nw=gets.chop\nl=Hash.new{|h,k|h[(i,j=k)]=s[i]&&w[j]?s[i]==w[j]?1+l[[i+1,j+1]]:([l[[i+1,j]],l[[i,j+1]]].max):0}\np l[[0,0]]\n}", "language": "Ruby", "metadata": {"date": 1412474466, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02235.html", "problem_id": "p02235", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02235/input.txt", "sample_output_relpath": "derived/input_output/data/p02235/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02235/Ruby/s964740145.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s964740145", "user_id": "u198069342"}, "prompt_components": {"gold_output": "4\n3\n2\n", "input_to_evaluate": "gets.to_i.times{\ns=gets.chop\nw=gets.chop\nl=Hash.new{|h,k|h[(i,j=k)]=s[i]&&w[j]?s[i]==w[j]?1+l[[i+1,j+1]]:([l[[i+1,j]],l[[i,j+1]]].max):0}\np l[[0,0]]\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nLongest Common Subsequence\n\nFor given two sequences $X$ and $Y$, a sequence $Z$ is a common subsequence of $X$ and $Y$ if $Z$ is a subsequence of both $X$ and $Y$. For example, if $X = \\{a,b,c,b,d,a,b\\}$ and $Y = \\{b,d,c,a,b,a\\}$, the sequence $\\{b,c,a\\}$ is a common subsequence of both $X$ and $Y$. On the other hand, the sequence $\\{b,c,a\\}$ is not a longest common subsequence (LCS) of $X$ and $Y$, since it has length 3 and the sequence $\\{b,c,b,a\\}$, which is also common to both $X$ and $Y$, has length 4. The sequence $\\{b,c,b,a\\}$ is an LCS of $X$ and $Y$, since there is no common subsequence of length 5 or greater.\n\nWrite a program which finds the length of LCS of given two sequences $X$ and $Y$. The sequence consists of alphabetical characters.\n\nInput\n\nThe input consists of multiple datasets. In the first line, an integer $q$ which is the number of datasets is given. In the following $2 \\times q$ lines, each dataset which consists of the two sequences $X$ and $Y$ are given.\n\nOutput\n\nFor each dataset, print the length of LCS of $X$ and $Y$ in a line.\n\nConstraints\n\n$1 \\leq q \\leq 150$\n\n$1 \\leq$ length of $X$ and $Y$ $\\leq 1,000$\n\n$q \\leq 20$ if the dataset includes a sequence whose length is more than 100\n\nSample Input 1\n\n3\nabcbdab\nbdcaba\nabc\nabc\nabc\nbc\n\nSample Output 1\n\n4\n3\n2\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "3\nabcbdab\nbdcaba\nabc\nabc\nabc\nbc\n"}, "reference_outputs": ["4\n3\n2\n"], "source_document_id": "p02235", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nLongest Common Subsequence\n\nFor given two sequences $X$ and $Y$, a sequence $Z$ is a common subsequence of $X$ and $Y$ if $Z$ is a subsequence of both $X$ and $Y$. For example, if $X = \\{a,b,c,b,d,a,b\\}$ and $Y = \\{b,d,c,a,b,a\\}$, the sequence $\\{b,c,a\\}$ is a common subsequence of both $X$ and $Y$. On the other hand, the sequence $\\{b,c,a\\}$ is not a longest common subsequence (LCS) of $X$ and $Y$, since it has length 3 and the sequence $\\{b,c,b,a\\}$, which is also common to both $X$ and $Y$, has length 4. The sequence $\\{b,c,b,a\\}$ is an LCS of $X$ and $Y$, since there is no common subsequence of length 5 or greater.\n\nWrite a program which finds the length of LCS of given two sequences $X$ and $Y$. The sequence consists of alphabetical characters.\n\nInput\n\nThe input consists of multiple datasets. In the first line, an integer $q$ which is the number of datasets is given. In the following $2 \\times q$ lines, each dataset which consists of the two sequences $X$ and $Y$ are given.\n\nOutput\n\nFor each dataset, print the length of LCS of $X$ and $Y$ in a line.\n\nConstraints\n\n$1 \\leq q \\leq 150$\n\n$1 \\leq$ length of $X$ and $Y$ $\\leq 1,000$\n\n$q \\leq 20$ if the dataset includes a sequence whose length is more than 100\n\nSample Input 1\n\n3\nabcbdab\nbdcaba\nabc\nabc\nabc\nbc\n\nSample Output 1\n\n4\n3\n2\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 150, "cpu_time_ms": 19930, "memory_kb": 229868}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s453674927", "group_id": "codeNet:p02242", "input_text": "module Color\n WHITE = 0\n GRAY = 1\n BLACK = 2\nend\n\ndef dijkstra(s)\n d = Array.new($n, Float::INFINITY)\n color = Array.new($n, Color::WHITE)\n \n d[s] = 0\n\n while true\n # puts d.join(' ')\n mincost = Float::INFINITY\n u = nil\n $n.times do |i|\n if color[i] != Color::BLACK && d[i] < mincost\n mincost = d[i]\n u = i\n end\n end\n\n if mincost == Float::INFINITY\n break\n end\n\n color[u] = Color::BLACK\n\n $n.times do |v|\n if color[v] != Color::BLACK && $m[u][v]\n if d[u] + $m[u][v] < d[v]\n d[v] = d[u] + $m[u][v]\n color[v] = Color::GRAY\n end\n end\n end\n end\n d\nend\n\n$n = gets.to_i\n$m = Array.new($n) { Array.new($n) }\n$n.times do |i|\n u, k, *arr = gets.split.map(&:to_i)\n arr.each_slice(2) do |v, c|\n $m[u][v] = c\n end\nend\n# puts \"=====\"\n# $m.each do |k|\n# puts k.join(' ')\n# end\n# puts \"=====\"\n\nd = dijkstra(0)\nd.each_with_index do | v, i |\n puts \"#{i} #{v}\"\nend\n\n", "language": "Ruby", "metadata": {"date": 1560931813, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02242.html", "problem_id": "p02242", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02242/input.txt", "sample_output_relpath": "derived/input_output/data/p02242/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02242/Ruby/s453674927.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s453674927", "user_id": "u966015027"}, "prompt_components": {"gold_output": "0 0\n1 2\n2 2\n3 1\n4 3\n", "input_to_evaluate": "module Color\n WHITE = 0\n GRAY = 1\n BLACK = 2\nend\n\ndef dijkstra(s)\n d = Array.new($n, Float::INFINITY)\n color = Array.new($n, Color::WHITE)\n \n d[s] = 0\n\n while true\n # puts d.join(' ')\n mincost = Float::INFINITY\n u = nil\n $n.times do |i|\n if color[i] != Color::BLACK && d[i] < mincost\n mincost = d[i]\n u = i\n end\n end\n\n if mincost == Float::INFINITY\n break\n end\n\n color[u] = Color::BLACK\n\n $n.times do |v|\n if color[v] != Color::BLACK && $m[u][v]\n if d[u] + $m[u][v] < d[v]\n d[v] = d[u] + $m[u][v]\n color[v] = Color::GRAY\n end\n end\n end\n end\n d\nend\n\n$n = gets.to_i\n$m = Array.new($n) { Array.new($n) }\n$n.times do |i|\n u, k, *arr = gets.split.map(&:to_i)\n arr.each_slice(2) do |v, c|\n $m[u][v] = c\n end\nend\n# puts \"=====\"\n# $m.each do |k|\n# puts k.join(' ')\n# end\n# puts \"=====\"\n\nd = dijkstra(0)\nd.each_with_index do | v, i |\n puts \"#{i} #{v}\"\nend\n\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nSingle Source Shortest Path\n\nFor a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$.\n\nInput\n\nIn the first line, an integer $n$ denoting the number of vertices in $G$ is given. In the following $n$ lines, adjacency lists for each vertex $u$ are respectively given in the following format:\n\n$u$ $k$ $v_1$ $c_1$ $v_2$ $c_2$ ... $v_k$ $c_k$\n\nVertices in $G$ are named with IDs $0, 1, ..., n-1$. $u$ is ID of the target vertex and $k$ denotes its degree. $v_i (i = 1, 2, ... k)$ denote IDs of vertices adjacent to $u$ and $c_i$ denotes the weight of a directed edge connecting $u$ and $v_i$ (from $u$ to $v_i$).\n\nOutput\n\nFor each vertex, print its ID and the distance separated by a space character in a line respectively. Print in order of vertex IDs.\n\nConstraints\n\n$1 \\leq n \\leq 100$\n\n$0 \\leq c_i \\leq 100,000$\n\n$|E| \\leq 10,000$\n\nAll vertices are reachable from vertex $0$\n\nSample Input 1\n\n5\n0 3 2 3 3 1 1 2\n1 2 0 2 3 4\n2 3 0 3 3 1 4 1\n3 4 2 1 0 1 1 4 4 3\n4 2 2 1 3 3\n\nSample Output 1\n\n0 0\n1 2\n2 2\n3 1\n4 3\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "5\n0 3 2 3 3 1 1 2\n1 2 0 2 3 4\n2 3 0 3 3 1 4 1\n3 4 2 1 0 1 1 4 4 3\n4 2 2 1 3 3\n"}, "reference_outputs": ["0 0\n1 2\n2 2\n3 1\n4 3\n"], "source_document_id": "p02242", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nSingle Source Shortest Path\n\nFor a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$.\n\nInput\n\nIn the first line, an integer $n$ denoting the number of vertices in $G$ is given. In the following $n$ lines, adjacency lists for each vertex $u$ are respectively given in the following format:\n\n$u$ $k$ $v_1$ $c_1$ $v_2$ $c_2$ ... $v_k$ $c_k$\n\nVertices in $G$ are named with IDs $0, 1, ..., n-1$. $u$ is ID of the target vertex and $k$ denotes its degree. $v_i (i = 1, 2, ... k)$ denote IDs of vertices adjacent to $u$ and $c_i$ denotes the weight of a directed edge connecting $u$ and $v_i$ (from $u$ to $v_i$).\n\nOutput\n\nFor each vertex, print its ID and the distance separated by a space character in a line respectively. Print in order of vertex IDs.\n\nConstraints\n\n$1 \\leq n \\leq 100$\n\n$0 \\leq c_i \\leq 100,000$\n\n$|E| \\leq 10,000$\n\nAll vertices are reachable from vertex $0$\n\nSample Input 1\n\n5\n0 3 2 3 3 1 1 2\n1 2 0 2 3 4\n2 3 0 3 3 1 4 1\n3 4 2 1 0 1 1 4 4 3\n4 2 2 1 3 3\n\nSample Output 1\n\n0 0\n1 2\n2 2\n3 1\n4 3\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 968, "cpu_time_ms": 50, "memory_kb": 7112}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s916288157", "group_id": "codeNet:p02243", "input_text": "# Algorithm from https://ja.wikipedia.org/wiki/%E3%83%80%E3%82%A4%E3%82%AF%E3%82%B9%E3%83%88%E3%83%A9%E6%B3%95?oldformat=true\n\n# NOTE: I would like to use pqueue as gem library\n# (from: https://github.com/rubyworks/pqueue)\n# Priority queue with array based heap.\n#\n# A priority queue is like a standard queue, except that each inserted\n# elements is given a certain priority, based on the result of the\n# comparison block given at instantiation time. Also, retrieving an element\n# from the queue will always return the one with the highest priority\n# (see #pop and #top).\n#\n# The default is to compare the elements in repect to their #<=> method.\n# For example, Numeric elements with higher values will have higher\n# priorities.\n#\n# Note that as of version 2.0 the internal queue is kept in the reverse order\n# from how it was kept in previous version. If you had used #to_a in the\n# past then be sure to adjust for the priorities to be ordered back-to-front\n# instead of the oterh way around.\n#\nclass PQueue\n\n #\n VERSION = \"2.1.0\" #:erb: VERSION = \"<%= version %>\"\n\n #\n # Returns a new priority queue.\n #\n # If elements are given, build the priority queue with these initial\n # values. The elements object must respond to #to_a.\n #\n # If a block is given, it will be used to determine the priority between\n # the elements. The block must must take two arguments and return `1`, `0`,\n # or `-1` or `true`, `nil` or `false. It should return `0` or `nil` if the\n # two arguments are considered equal, return `1` or `true` if the first\n # argument is considered greater than the later, and `-1` or `false` if\n # the later is considred to be greater than the first.\n #\n # By default, the priority queue retrieves maximum elements first\n # using the #<=> method.\n #\n def initialize(elements=nil, &block) # :yields: a, b\n @que = []\n @cmp = block || lambda{ |a,b| a <=> b }\n replace(elements) if elements\n end\n\n protected\n\n #\n # The underlying heap.\n #\n attr_reader :que #:nodoc:\n\n public\n\n #\n # Priority comparison procedure.\n #\n attr_reader :cmp\n\n #\n # Returns the size of the queue.\n #\n def size\n @que.size\n end\n\n #\n # Alias of size.\n #\n alias length size\n\n #\n # Add an element in the priority queue.\n #\n def push(v)\n @que << v\n reheap(@que.size-1)\n self\n end\n\n #\n # Traditional alias for #push.\n #\n alias enq push\n\n #\n # Alias of #push.\n #\n alias :<< :push\n\n #\n # Get the element with the highest priority and remove it from\n # the queue.\n #\n # The highest priority is determined by the block given at instantiation\n # time.\n #\n # The deletion time is O(log n), with n is the size of the queue.\n #\n # Return nil if the queue is empty.\n #\n def pop\n return nil if empty?\n @que.pop\n end\n\n #\n # Traditional alias for #pop.\n #\n alias deq pop\n\n # Get the element with the lowest priority and remove it from\n # the queue.\n #\n # The lowest priority is determined by the block given at instantiation\n # time.\n #\n # The deletion time is O(log n), with n is the size of the queue.\n #\n # Return nil if the queue is empty.\n #\n def shift\n return nil if empty?\n @que.shift\n end\n\n #\n # Returns the element with the highest priority, but\n # does not remove it from the queue.\n #\n def top\n return nil if empty?\n return @que.last\n end\n\n #\n # Traditional alias for #top.\n #\n alias peek top\n\n #\n # Returns the element with the lowest priority, but\n # does not remove it from the queue.\n #\n def bottom\n return nil if empty?\n return @que.first\n end\n\n #\n # Add more than one element at the same time. See #push.\n #\n # The elements object must respond to #to_a, or be a PQueue itself.\n #\n def concat(elements)\n if empty?\n if elements.kind_of?(PQueue)\n initialize_copy(elements)\n else\n replace(elements)\n end\n else\n if elements.kind_of?(PQueue)\n @que.concat(elements.que)\n sort!\n else\n @que.concat(elements.to_a)\n sort!\n end\n end\n return self\n end\n\n #\n # Alias for #concat.\n #\n alias :merge! :concat\n\n #\n # Return top n-element as a sorted array.\n #\n def take(n=@size)\n a = []\n n.times{a.push(pop)}\n a\n end\n\n #\n # Returns true if there is no more elements left in the queue.\n #\n def empty?\n @que.empty?\n end\n\n #\n # Remove all elements from the priority queue.\n #\n def clear\n @que.clear\n self\n end\n\n #\n # Replace the content of the heap by the new elements.\n #\n # The elements object must respond to #to_a, or to be\n # a PQueue itself.\n #\n def replace(elements)\n if elements.kind_of?(PQueue)\n initialize_copy(elements)\n else\n @que.replace(elements.to_a)\n sort!\n end\n self\n end\n\n #\n # Return a sorted array, with highest priority first.\n #\n def to_a\n @que.dup\n end\n\n #\n # Return true if the given object is present in the queue.\n #\n def include?(element)\n @que.include?(element)\n end\n\n #\n # Push element onto queue while popping off and returning the next element.\n # This is qquivalent to successively calling #pop and #push(v).\n #\n def swap(v)\n r = pop\n push(v)\n r\n end\n\n #\n # Iterate over the ordered elements, destructively.\n #\n def each_pop #:yields: popped\n until empty?\n yield pop\n end\n nil\n end\n\n #\n # Pretty inspection string.\n #\n def inspect\n \"<#{self.class}: size=#{size}, top=#{top || \"nil\"}>\"\n end\n\n #\n # Return true if the queues contain equal elements.\n #\n def ==(other)\n size == other.size && to_a == other.to_a\n end\n\n private\n\n #\n #\n #\n def initialize_copy(other)\n @cmp = other.cmp\n @que = other.que.dup\n sort!\n end\n\n #\n # The element at index k will be repositioned to its proper place.\n #\n # This, of course, assumes the queue is already sorted.\n #\n def reheap(k)\n return self if size <= 1\n\n que = @que.dup\n\n v = que.delete_at(k)\n i = binary_index(que, v)\n\n que.insert(i, v)\n\n @que = que\n\n return self\n end\n\n #\n # Sort the queue in accorance to the given comparison procedure.\n #\n def sort!\n @que.sort! do |a,b|\n case @cmp.call(a,b)\n when 0, nil then 0\n when 1, true then 1\n when -1, false then -1\n else\n warn \"bad comparison procedure in #{self.inspect}\"\n 0\n end\n end\n self\n end\n\n #\n # Alias of #sort!\n #\n alias heapify sort!\n\n #\n def binary_index(que, target)\n upper = que.size - 1\n lower = 0\n\n while(upper >= lower) do\n idx = lower + (upper - lower) / 2\n comp = @cmp.call(target, que[idx])\n\n case comp\n when 0, nil\n return idx\n when 1, true\n lower = idx + 1\n when -1, false\n upper = idx - 1\n else\n end\n end\n lower\n end\n\nend # class PQueue\n\n\n\n# ======== BEGIN ========\nrequire 'set'\n\nN = gets.to_i\n\n$graph = Hash.new{|h,k| h[k] = Hash.new(Float::INFINITY)}\n$q = PQueue.new([{id: 0, weight: 0}] + (1...N).each.map{|i| {id: i, weight: Float::INFINITY}}){|n1, n2|\n n1[:weight] < n2[:weight]\n}\n\n\nwhile (line = gets)\n node_id, _, *nodes = line.split(' ').map(&:to_i)\n nodes.each_slice(2){|id, weight|\n $graph[node_id][id] = weight\n }\nend\n\n$visited_nodes = []\n\n\n$start_node_id = 0\n# Min Distance '0' to `key`\n$weights = Hash.new(Float::INFINITY)\n$weights[$start_node_id] = 0\n$decided_nodes = Set.new\n\n$prev = {}\n\nwhile !$q.empty?\n min_node = $q.pop\n u = min_node[:id]\n if $decided_nodes.include?(u)\n next\n end\n nodes = $graph[u]\n nodes.each{|v, weight|\n alt = $weights[u] + weight\n if $weights[v] > alt\n $weights[v] = alt\n $q.push({id: v, weight: alt})\n $prev[v] = u\n end\n }\n $decided_nodes.add(u)\nend\n\n# For path\n# p $prev\n\n$weights\n .sort_by{|k, v| k}\n .each{|node, weight|\n puts(\"#{node} #{weight}\")\n }\n\n", "language": "Ruby", "metadata": {"date": 1528201355, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02243.html", "problem_id": "p02243", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02243/input.txt", "sample_output_relpath": "derived/input_output/data/p02243/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02243/Ruby/s916288157.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s916288157", "user_id": "u868937865"}, "prompt_components": {"gold_output": "0 0\n1 2\n2 2\n3 1\n4 3\n", "input_to_evaluate": "# Algorithm from https://ja.wikipedia.org/wiki/%E3%83%80%E3%82%A4%E3%82%AF%E3%82%B9%E3%83%88%E3%83%A9%E6%B3%95?oldformat=true\n\n# NOTE: I would like to use pqueue as gem library\n# (from: https://github.com/rubyworks/pqueue)\n# Priority queue with array based heap.\n#\n# A priority queue is like a standard queue, except that each inserted\n# elements is given a certain priority, based on the result of the\n# comparison block given at instantiation time. Also, retrieving an element\n# from the queue will always return the one with the highest priority\n# (see #pop and #top).\n#\n# The default is to compare the elements in repect to their #<=> method.\n# For example, Numeric elements with higher values will have higher\n# priorities.\n#\n# Note that as of version 2.0 the internal queue is kept in the reverse order\n# from how it was kept in previous version. If you had used #to_a in the\n# past then be sure to adjust for the priorities to be ordered back-to-front\n# instead of the oterh way around.\n#\nclass PQueue\n\n #\n VERSION = \"2.1.0\" #:erb: VERSION = \"<%= version %>\"\n\n #\n # Returns a new priority queue.\n #\n # If elements are given, build the priority queue with these initial\n # values. The elements object must respond to #to_a.\n #\n # If a block is given, it will be used to determine the priority between\n # the elements. The block must must take two arguments and return `1`, `0`,\n # or `-1` or `true`, `nil` or `false. It should return `0` or `nil` if the\n # two arguments are considered equal, return `1` or `true` if the first\n # argument is considered greater than the later, and `-1` or `false` if\n # the later is considred to be greater than the first.\n #\n # By default, the priority queue retrieves maximum elements first\n # using the #<=> method.\n #\n def initialize(elements=nil, &block) # :yields: a, b\n @que = []\n @cmp = block || lambda{ |a,b| a <=> b }\n replace(elements) if elements\n end\n\n protected\n\n #\n # The underlying heap.\n #\n attr_reader :que #:nodoc:\n\n public\n\n #\n # Priority comparison procedure.\n #\n attr_reader :cmp\n\n #\n # Returns the size of the queue.\n #\n def size\n @que.size\n end\n\n #\n # Alias of size.\n #\n alias length size\n\n #\n # Add an element in the priority queue.\n #\n def push(v)\n @que << v\n reheap(@que.size-1)\n self\n end\n\n #\n # Traditional alias for #push.\n #\n alias enq push\n\n #\n # Alias of #push.\n #\n alias :<< :push\n\n #\n # Get the element with the highest priority and remove it from\n # the queue.\n #\n # The highest priority is determined by the block given at instantiation\n # time.\n #\n # The deletion time is O(log n), with n is the size of the queue.\n #\n # Return nil if the queue is empty.\n #\n def pop\n return nil if empty?\n @que.pop\n end\n\n #\n # Traditional alias for #pop.\n #\n alias deq pop\n\n # Get the element with the lowest priority and remove it from\n # the queue.\n #\n # The lowest priority is determined by the block given at instantiation\n # time.\n #\n # The deletion time is O(log n), with n is the size of the queue.\n #\n # Return nil if the queue is empty.\n #\n def shift\n return nil if empty?\n @que.shift\n end\n\n #\n # Returns the element with the highest priority, but\n # does not remove it from the queue.\n #\n def top\n return nil if empty?\n return @que.last\n end\n\n #\n # Traditional alias for #top.\n #\n alias peek top\n\n #\n # Returns the element with the lowest priority, but\n # does not remove it from the queue.\n #\n def bottom\n return nil if empty?\n return @que.first\n end\n\n #\n # Add more than one element at the same time. See #push.\n #\n # The elements object must respond to #to_a, or be a PQueue itself.\n #\n def concat(elements)\n if empty?\n if elements.kind_of?(PQueue)\n initialize_copy(elements)\n else\n replace(elements)\n end\n else\n if elements.kind_of?(PQueue)\n @que.concat(elements.que)\n sort!\n else\n @que.concat(elements.to_a)\n sort!\n end\n end\n return self\n end\n\n #\n # Alias for #concat.\n #\n alias :merge! :concat\n\n #\n # Return top n-element as a sorted array.\n #\n def take(n=@size)\n a = []\n n.times{a.push(pop)}\n a\n end\n\n #\n # Returns true if there is no more elements left in the queue.\n #\n def empty?\n @que.empty?\n end\n\n #\n # Remove all elements from the priority queue.\n #\n def clear\n @que.clear\n self\n end\n\n #\n # Replace the content of the heap by the new elements.\n #\n # The elements object must respond to #to_a, or to be\n # a PQueue itself.\n #\n def replace(elements)\n if elements.kind_of?(PQueue)\n initialize_copy(elements)\n else\n @que.replace(elements.to_a)\n sort!\n end\n self\n end\n\n #\n # Return a sorted array, with highest priority first.\n #\n def to_a\n @que.dup\n end\n\n #\n # Return true if the given object is present in the queue.\n #\n def include?(element)\n @que.include?(element)\n end\n\n #\n # Push element onto queue while popping off and returning the next element.\n # This is qquivalent to successively calling #pop and #push(v).\n #\n def swap(v)\n r = pop\n push(v)\n r\n end\n\n #\n # Iterate over the ordered elements, destructively.\n #\n def each_pop #:yields: popped\n until empty?\n yield pop\n end\n nil\n end\n\n #\n # Pretty inspection string.\n #\n def inspect\n \"<#{self.class}: size=#{size}, top=#{top || \"nil\"}>\"\n end\n\n #\n # Return true if the queues contain equal elements.\n #\n def ==(other)\n size == other.size && to_a == other.to_a\n end\n\n private\n\n #\n #\n #\n def initialize_copy(other)\n @cmp = other.cmp\n @que = other.que.dup\n sort!\n end\n\n #\n # The element at index k will be repositioned to its proper place.\n #\n # This, of course, assumes the queue is already sorted.\n #\n def reheap(k)\n return self if size <= 1\n\n que = @que.dup\n\n v = que.delete_at(k)\n i = binary_index(que, v)\n\n que.insert(i, v)\n\n @que = que\n\n return self\n end\n\n #\n # Sort the queue in accorance to the given comparison procedure.\n #\n def sort!\n @que.sort! do |a,b|\n case @cmp.call(a,b)\n when 0, nil then 0\n when 1, true then 1\n when -1, false then -1\n else\n warn \"bad comparison procedure in #{self.inspect}\"\n 0\n end\n end\n self\n end\n\n #\n # Alias of #sort!\n #\n alias heapify sort!\n\n #\n def binary_index(que, target)\n upper = que.size - 1\n lower = 0\n\n while(upper >= lower) do\n idx = lower + (upper - lower) / 2\n comp = @cmp.call(target, que[idx])\n\n case comp\n when 0, nil\n return idx\n when 1, true\n lower = idx + 1\n when -1, false\n upper = idx - 1\n else\n end\n end\n lower\n end\n\nend # class PQueue\n\n\n\n# ======== BEGIN ========\nrequire 'set'\n\nN = gets.to_i\n\n$graph = Hash.new{|h,k| h[k] = Hash.new(Float::INFINITY)}\n$q = PQueue.new([{id: 0, weight: 0}] + (1...N).each.map{|i| {id: i, weight: Float::INFINITY}}){|n1, n2|\n n1[:weight] < n2[:weight]\n}\n\n\nwhile (line = gets)\n node_id, _, *nodes = line.split(' ').map(&:to_i)\n nodes.each_slice(2){|id, weight|\n $graph[node_id][id] = weight\n }\nend\n\n$visited_nodes = []\n\n\n$start_node_id = 0\n# Min Distance '0' to `key`\n$weights = Hash.new(Float::INFINITY)\n$weights[$start_node_id] = 0\n$decided_nodes = Set.new\n\n$prev = {}\n\nwhile !$q.empty?\n min_node = $q.pop\n u = min_node[:id]\n if $decided_nodes.include?(u)\n next\n end\n nodes = $graph[u]\n nodes.each{|v, weight|\n alt = $weights[u] + weight\n if $weights[v] > alt\n $weights[v] = alt\n $q.push({id: v, weight: alt})\n $prev[v] = u\n end\n }\n $decided_nodes.add(u)\nend\n\n# For path\n# p $prev\n\n$weights\n .sort_by{|k, v| k}\n .each{|node, weight|\n puts(\"#{node} #{weight}\")\n }\n\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nSingle Source Shortest Path II\n\nFor a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$.\n\nInput\n\nIn the first line, an integer $n$ denoting the number of vertices in $G$ is given. In the following $n$ lines, adjacency lists for each vertex $u$ are respectively given in the following format:\n\n$u$ $k$ $v_1$ $c_1$ $v_2$ $c_2$ ... $v_k$ $c_k$\n\nVertices in $G$ are named with IDs $0, 1, ..., n-1$. $u$ is ID of the target vertex and $k$ denotes its degree. $v_i (i = 1, 2, ... k)$ denote IDs of vertices adjacent to $u$ and $c_i$ denotes the weight of a directed edge connecting $u$ and $v_i$ (from $u$ to $v_i$).\n\nOutput\n\nFor each vertex, print its ID and the distance separated by a space character in a line respectively. Print in order of vertex IDs.\n\nConstraints\n\n$1 \\leq n \\leq 10,000$\n\n$0 \\leq c_i \\leq 100,000$\n\n$|E| < 500,000$\n\nAll vertices are reachable from vertex $0$\n\nSample Input 1\n\n5\n0 3 2 3 3 1 1 2\n1 2 0 2 3 4\n2 3 0 3 3 1 4 1\n3 4 2 1 0 1 1 4 4 3\n4 2 2 1 3 3\n\nSample Output 1\n\n0 0\n1 2\n2 2\n3 1\n4 3\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "5\n0 3 2 3 3 1 1 2\n1 2 0 2 3 4\n2 3 0 3 3 1 4 1\n3 4 2 1 0 1 1 4 4 3\n4 2 2 1 3 3\n"}, "reference_outputs": ["0 0\n1 2\n2 2\n3 1\n4 3\n"], "source_document_id": "p02243", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nSingle Source Shortest Path II\n\nFor a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$.\n\nInput\n\nIn the first line, an integer $n$ denoting the number of vertices in $G$ is given. In the following $n$ lines, adjacency lists for each vertex $u$ are respectively given in the following format:\n\n$u$ $k$ $v_1$ $c_1$ $v_2$ $c_2$ ... $v_k$ $c_k$\n\nVertices in $G$ are named with IDs $0, 1, ..., n-1$. $u$ is ID of the target vertex and $k$ denotes its degree. $v_i (i = 1, 2, ... k)$ denote IDs of vertices adjacent to $u$ and $c_i$ denotes the weight of a directed edge connecting $u$ and $v_i$ (from $u$ to $v_i$).\n\nOutput\n\nFor each vertex, print its ID and the distance separated by a space character in a line respectively. Print in order of vertex IDs.\n\nConstraints\n\n$1 \\leq n \\leq 10,000$\n\n$0 \\leq c_i \\leq 100,000$\n\n$|E| < 500,000$\n\nAll vertices are reachable from vertex $0$\n\nSample Input 1\n\n5\n0 3 2 3 3 1 1 2\n1 2 0 2 3 4\n2 3 0 3 3 1 4 1\n3 4 2 1 0 1 1 4 4 3\n4 2 2 1 3 3\n\nSample Output 1\n\n0 0\n1 2\n2 2\n3 1\n4 3\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7811, "cpu_time_ms": 1900, "memory_kb": 146380}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s693089775", "group_id": "codeNet:p02256", "input_text": "x, y = gets.chomp.split.map(&:to_i).sort\nmod = y % x\nary = Array.new\nif x == y\n\tputs x\nelse\n\tloop do\n\t\tif (y % x) % mod == 0\n\t\t\tif x % mod == 0\n\t\t\t\tputs mod\n\t\t\t\tbreak\n\t\t\tend\n\t\telse\n\t\t\tmod -= 1\n\t\tend\n\tend\nend", "language": "Ruby", "metadata": {"date": 1441214549, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s693089775.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s693089775", "user_id": "u045588362"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "x, y = gets.chomp.split.map(&:to_i).sort\nmod = y % x\nary = Array.new\nif x == y\n\tputs x\nelse\n\tloop do\n\t\tif (y % x) % mod == 0\n\t\t\tif x % mod == 0\n\t\t\t\tputs mod\n\t\t\t\tbreak\n\t\t\tend\n\t\telse\n\t\t\tmod -= 1\n\t\tend\n\tend\nend", "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": 207, "cpu_time_ms": 40000, "memory_kb": 8356}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s022989153", "group_id": "codeNet:p02256", "input_text": " x,y = gets.chomp.split(/\\s/).map{|x| x.to_i}\n puts x.gcd(y)\n\n", "language": "Ruby", "metadata": {"date": 1567312220, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s022989153.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s022989153", "user_id": "u101867310"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": " x,y = gets.chomp.split(/\\s/).map{|x| x.to_i}\n puts x.gcd(y)\n\n", "problem_context": "Greatest Common Divisor\n\nWrite a program which finds the greatest common divisor of two natural numbers a and b\n\nInput\n\na and b are given in a line sparated by a single space.\n\nOutput\n\nOutput the greatest common divisor of a and b.\n\nConstrants\n\n1 ≤ a, b ≤ 109\n\nHint\n\nYou can use the following observation:\n\nFor integers x and y, if x ≥ y, then gcd(x, y) = gcd(y, x%y)\n\nSample Input 1\n\n54 20\n\nSample Output 1\n\n2\n\nSample Input 2\n\n147 105\n\nSample Output 2\n\n21", "sample_input": "54 20\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02256", "source_text": "Greatest Common Divisor\n\nWrite a program which finds the greatest common divisor of two natural numbers a and b\n\nInput\n\na and b are given in a line sparated by a single space.\n\nOutput\n\nOutput the greatest common divisor of a and b.\n\nConstrants\n\n1 ≤ a, b ≤ 109\n\nHint\n\nYou can use the following observation:\n\nFor integers x and y, if x ≥ y, then gcd(x, y) = gcd(y, x%y)\n\nSample Input 1\n\n54 20\n\nSample Output 1\n\n2\n\nSample Input 2\n\n147 105\n\nSample Output 2\n\n21", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 68, "cpu_time_ms": 40, "memory_kb": 6876}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s075108923", "group_id": "codeNet:p02257", "input_text": "n=gets.to_i\nn.times do\n max=gets.to_i\n plist=Array.new(max+1, 1)\n plist[0..1]=[nil,nil]\n (2..max**(1/2.0)).each do |i|\n if plist[i]\n (2..max/i).each do |j|\n plist[i*j]=nil \n end\n end\n end\n puts plist.compact.size\nend", "language": "Ruby", "metadata": {"date": 1437289412, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s075108923.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s075108923", "user_id": "u352522848"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "n=gets.to_i\nn.times do\n max=gets.to_i\n plist=Array.new(max+1, 1)\n plist[0..1]=[nil,nil]\n (2..max**(1/2.0)).each do |i|\n if plist[i]\n (2..max/i).each do |j|\n plist[i*j]=nil \n end\n end\n end\n puts plist.compact.size\nend", "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": 245, "cpu_time_ms": 20, "memory_kb": 6192}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s596142647", "group_id": "codeNet:p02257", "input_text": "n = gets.to_i\ncount = 0\n\nn.times{|i|\n hit = false\n k = gets.to_i\n for j in 2..Math.sqrt(k)\n if k%j == 0\n hit = true \n break\n end\n \n end\n count += 1 if !hit \n}\n\nputs count\n", "language": "Ruby", "metadata": {"date": 1549205442, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s596142647.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s596142647", "user_id": "u894176337"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "n = gets.to_i\ncount = 0\n\nn.times{|i|\n hit = false\n k = gets.to_i\n for j in 2..Math.sqrt(k)\n if k%j == 0\n hit = true \n break\n end\n \n end\n count += 1 if !hit \n}\n\nputs count\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": 229, "cpu_time_ms": 650, "memory_kb": 6892}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s157563957", "group_id": "codeNet:p02258", "input_text": "n = gets.chomp.to_i\n\nnums = Array.new\nn.times do |i|\n nums.push gets.chomp.to_i\nend\n\nnums = nums.reverse\nmax = -999999999\nfor j in 0..(n-2) do\n\n k = j + 1\n\n for m in k..(n-1) do\n\n diff = nums[j] - nums[m]\n if diff > max\n max = diff\n end\n\n end\n\nend\n\nputs max", "language": "Ruby", "metadata": {"date": 1476368965, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s157563957.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s157563957", "user_id": "u854258289"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "n = gets.chomp.to_i\n\nnums = Array.new\nn.times do |i|\n nums.push gets.chomp.to_i\nend\n\nnums = nums.reverse\nmax = -999999999\nfor j in 0..(n-2) do\n\n k = j + 1\n\n for m in k..(n-1) do\n\n diff = nums[j] - nums[m]\n if diff > max\n max = diff\n end\n\n end\n\nend\n\nputs max", "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": 288, "cpu_time_ms": 40000, "memory_kb": 11904}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s782611023", "group_id": "codeNet:p02258", "input_text": "max = -20000000000\nri = 0\ncount = 0;\nSTDIN.each_line {|line|\n if count == 0\n count = 1\n next\n end\n \n now_value = line.to_i\n if ri == 0\n ri = now_value\n next\n end\n\n if max < (now_value - ri)\n max = now_value - ri\n end\n\n if ri > now_value\n ri = now_value\n end\n}\n\nprint max, \"\\n\"\n\n", "language": "Ruby", "metadata": {"date": 1516879897, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s782611023.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s782611023", "user_id": "u188708842"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "max = -20000000000\nri = 0\ncount = 0;\nSTDIN.each_line {|line|\n if count == 0\n count = 1\n next\n end\n \n now_value = line.to_i\n if ri == 0\n ri = now_value\n next\n end\n\n if max < (now_value - ri)\n max = now_value - ri\n end\n\n if ri > now_value\n ri = now_value\n end\n}\n\nprint max, \"\\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": 306, "cpu_time_ms": 110, "memory_kb": 6868}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s132549638", "group_id": "codeNet:p02259", "input_text": "def bubbleSort(arr)\n i = arr.size - 1\n x = 0\n n = 0\n while i >= x\n j = arr.size - 1\n while j >= 1\n if arr[j] < arr[j - 1] then\n x = arr[j]\n arr[j] = arr[j - 1]\n arr[j - 1] = x\n n = n + 1\n end\n j = j - 1\n end\n x = x + 1\n end\n puts arr.join(' ')\n puts n\nend\n\nn = STDIN.gets.to_i\narr = STDIN.gets.split(' ').map{|x| x.to_i}\nbubbleSort(arr)", "language": "Ruby", "metadata": {"date": 1447209106, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s132549638.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s132549638", "user_id": "u382730661"}, "prompt_components": {"gold_output": "1 2 3 4 5\n8\n", "input_to_evaluate": "def bubbleSort(arr)\n i = arr.size - 1\n x = 0\n n = 0\n while i >= x\n j = arr.size - 1\n while j >= 1\n if arr[j] < arr[j - 1] then\n x = arr[j]\n arr[j] = arr[j - 1]\n arr[j - 1] = x\n n = n + 1\n end\n j = j - 1\n end\n x = x + 1\n end\n puts arr.join(' ')\n puts n\nend\n\nn = STDIN.gets.to_i\narr = STDIN.gets.split(' ').map{|x| x.to_i}\nbubbleSort(arr)", "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": 398, "cpu_time_ms": 50, "memory_kb": 8628}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s738566304", "group_id": "codeNet:p02259", "input_text": "a = gets.chomp.to_i\nn = gets.chomp.split(\" \").map(&:to_i)\nflag = 1\ncount = 0\nwhile flag == 1 \n flag = 0\n (a-1).downto(1) do |j|\n if n[j] < n[j-1]\n n[j],n[j-1] = n[j-1],n[j]\n flag = 1\n count += 1\n end\n end\nend\nn[0,a-1].each do |d|\n print(\"#{d} \")\nend\nputs(\"#{n[a-1]}\")\nputs count", "language": "Ruby", "metadata": {"date": 1483174184, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s738566304.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s738566304", "user_id": "u838309182"}, "prompt_components": {"gold_output": "1 2 3 4 5\n8\n", "input_to_evaluate": "a = gets.chomp.to_i\nn = gets.chomp.split(\" \").map(&:to_i)\nflag = 1\ncount = 0\nwhile flag == 1 \n flag = 0\n (a-1).downto(1) do |j|\n if n[j] < n[j-1]\n n[j],n[j-1] = n[j-1],n[j]\n flag = 1\n count += 1\n end\n end\nend\nn[0,a-1].each do |d|\n print(\"#{d} \")\nend\nputs(\"#{n[a-1]}\")\nputs count", "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": 303, "cpu_time_ms": 40, "memory_kb": 8716}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s871664212", "group_id": "codeNet:p02261", "input_text": "def bubble_sort(data, test_proc = proc { |a, b| (a <=> b) > 0 } )\n n = data.size\n 0.upto(n - 2) { |i|\n (i + 1).upto(n - 1) { |j|\n if test_proc.call(data[i], data[j])\n tmp = data[j]\n data[j] = data[i]\n data[i] = tmp\n end\n }\n }\n data\nend\n\ndef selection_sort(data, test_proc = proc { |a, b| (a <=> b) > 0 } )\n n = data.size\n 0.upto(n - 2) { |i|\n swap_idx = i\n i.upto(n - 1) { |j|\n swap_idx = j if test_proc.call(data[swap_idx], data[j])\n }\n tmp = data[i]\n data[i] = data[swap_idx]\n data[swap_idx] = tmp\n }\n data\nend\n\ndef stable_sort?(original, sorted)\n 0.upto(sorted.size - 2) { |i|\n if sorted[i][1] == sorted[i + 1][1]\n is_not_stable = false\n original.each { |a|\n if a == sorted[i]\n break\n elsif a == sorted[i + 1]\n is_not_stable = true\n break\n end\n }\n if is_not_stable\n return false\n end\n end\n }\n true\nend\n\ndata = $stdin.read.lines[1].split(' ').each { |n| n.instance_eval { def <=>(other); self[1].to_i <=> other[1].to_i; end } }\n[bubble_sort(data.clone), selection_sort(data.clone)].each { |sorted|\n puts sorted.join(' ')\n puts stable_sort?(data, sorted) ? 'Stable' : 'Not stable'\n}", "language": "Ruby", "metadata": {"date": 1465055899, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s871664212.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s871664212", "user_id": "u275152649"}, "prompt_components": {"gold_output": "D2 C3 H4 S4 C9\nStable\nD2 C3 S4 H4 C9\nNot stable\n", "input_to_evaluate": "def bubble_sort(data, test_proc = proc { |a, b| (a <=> b) > 0 } )\n n = data.size\n 0.upto(n - 2) { |i|\n (i + 1).upto(n - 1) { |j|\n if test_proc.call(data[i], data[j])\n tmp = data[j]\n data[j] = data[i]\n data[i] = tmp\n end\n }\n }\n data\nend\n\ndef selection_sort(data, test_proc = proc { |a, b| (a <=> b) > 0 } )\n n = data.size\n 0.upto(n - 2) { |i|\n swap_idx = i\n i.upto(n - 1) { |j|\n swap_idx = j if test_proc.call(data[swap_idx], data[j])\n }\n tmp = data[i]\n data[i] = data[swap_idx]\n data[swap_idx] = tmp\n }\n data\nend\n\ndef stable_sort?(original, sorted)\n 0.upto(sorted.size - 2) { |i|\n if sorted[i][1] == sorted[i + 1][1]\n is_not_stable = false\n original.each { |a|\n if a == sorted[i]\n break\n elsif a == sorted[i + 1]\n is_not_stable = true\n break\n end\n }\n if is_not_stable\n return false\n end\n end\n }\n true\nend\n\ndata = $stdin.read.lines[1].split(' ').each { |n| n.instance_eval { def <=>(other); self[1].to_i <=> other[1].to_i; end } }\n[bubble_sort(data.clone), selection_sort(data.clone)].each { |sorted|\n puts sorted.join(' ')\n puts stable_sort?(data, sorted) ? 'Stable' : 'Not stable'\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": 1242, "cpu_time_ms": 40, "memory_kb": 8720}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s531935955", "group_id": "codeNet:p02263", "input_text": "s = gets.split\nstack = []\ns.each do |a|\n if a =~ /[\\+\\-\\*]/\n o1 = stack.pop\n o2 = stack.pop\n stack << eval(\"#{o2}#{a}#{o1}\")\n else\n stack << a\n end\nend\n\np stack[-1]\n\n", "language": "Ruby", "metadata": {"date": 1567586312, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02263.html", "problem_id": "p02263", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02263/input.txt", "sample_output_relpath": "derived/input_output/data/p02263/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02263/Ruby/s531935955.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s531935955", "user_id": "u994677204"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "s = gets.split\nstack = []\ns.each do |a|\n if a =~ /[\\+\\-\\*]/\n o1 = stack.pop\n o2 = stack.pop\n stack << eval(\"#{o2}#{a}#{o1}\")\n else\n stack << a\n end\nend\n\np stack[-1]\n\n", "problem_context": "Reverse Polish notation is a notation where every operator follows all of its operands. For example, an expression (1+2)*(5+4) in the conventional Polish notation can be represented as 1 2 + 5 4 + * in the Reverse Polish notation. One of advantages of the Reverse Polish notation is that it is parenthesis-free.\n\nWrite a program which reads an expression in the Reverse Polish notation and prints the computational result.\n\nAn expression in the Reverse Polish notation is calculated using a stack. To evaluate the expression, the program should read symbols in order. If the symbol is an operand, the corresponding value should be pushed into the stack. On the other hand, if the symbols is an operator, the program should pop two elements from the stack, perform the corresponding operations, then push the result in to the stack. The program should repeat this operations.\n\nInput\n\nAn expression is given in a line. Two consequtive symbols (operand or operator) are separated by a space character.\n\nYou can assume that +, - and * are given as the operator and an operand is a positive integer less than 106\n\nOutput\n\nPrint the computational result in a line.\n\nConstraints\n\n2 ≤ the number of operands in the expression ≤ 100\n\n1 ≤ the number of operators in the expression ≤ 99\n\n-1 × 109 ≤ values in the stack ≤ 109\n\nSample Input 1\n\n1 2 +\n\nSample Output 1\n\n3\n\nSample Input 2\n\n1 2 + 3 4 - *\n\nSample Output 2\n\n-3\n\nNotes\n\nTemplate in C", "sample_input": "1 2 +\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02263", "source_text": "Reverse Polish notation is a notation where every operator follows all of its operands. For example, an expression (1+2)*(5+4) in the conventional Polish notation can be represented as 1 2 + 5 4 + * in the Reverse Polish notation. One of advantages of the Reverse Polish notation is that it is parenthesis-free.\n\nWrite a program which reads an expression in the Reverse Polish notation and prints the computational result.\n\nAn expression in the Reverse Polish notation is calculated using a stack. To evaluate the expression, the program should read symbols in order. If the symbol is an operand, the corresponding value should be pushed into the stack. On the other hand, if the symbols is an operator, the program should pop two elements from the stack, perform the corresponding operations, then push the result in to the stack. The program should repeat this operations.\n\nInput\n\nAn expression is given in a line. Two consequtive symbols (operand or operator) are separated by a space character.\n\nYou can assume that +, - and * are given as the operator and an operand is a positive integer less than 106\n\nOutput\n\nPrint the computational result in a line.\n\nConstraints\n\n2 ≤ the number of operands in the expression ≤ 100\n\n1 ≤ the number of operators in the expression ≤ 99\n\n-1 × 109 ≤ values in the stack ≤ 109\n\nSample Input 1\n\n1 2 +\n\nSample Output 1\n\n3\n\nSample Input 2\n\n1 2 + 3 4 - *\n\nSample Output 2\n\n-3\n\nNotes\n\nTemplate in C", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 181, "cpu_time_ms": 40, "memory_kb": 6920}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s292565628", "group_id": "codeNet:p02266", "input_text": "def main(input = $stdin)\n str = input.gets.chomp.split(//)\n stack = Array.new\n lake_size = Array.new(1, 0)\n height = 0\n str.each{|char|\n case char\n when '\\\\'\n height += 1\n stack.push char\n when '/'\n if height != 0\n width = 1\n while case temp = stack.pop\n when '\\\\'\n stack.push width + 1\n lake_size.push(lake_size.pop + width)\n lake_size.push 0 \n false\n when Integer\n width += temp\n lake_size.push(lake_size.pop + lake_size.pop)\n else\n width += 1\n end\n end\n height -= 1\n end\n else\n stack.push char\n end\n }\n puts lake_size.reduce(&:+)\n lake_size.pop\n puts lake_size.size.to_s + \" \" + lake_size.join(\" \")\nend\nmain", "language": "Ruby", "metadata": {"date": 1426761662, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02266.html", "problem_id": "p02266", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02266/input.txt", "sample_output_relpath": "derived/input_output/data/p02266/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02266/Ruby/s292565628.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s292565628", "user_id": "u514597327"}, "prompt_components": {"gold_output": "4\n1 4\n", "input_to_evaluate": "def main(input = $stdin)\n str = input.gets.chomp.split(//)\n stack = Array.new\n lake_size = Array.new(1, 0)\n height = 0\n str.each{|char|\n case char\n when '\\\\'\n height += 1\n stack.push char\n when '/'\n if height != 0\n width = 1\n while case temp = stack.pop\n when '\\\\'\n stack.push width + 1\n lake_size.push(lake_size.pop + width)\n lake_size.push 0 \n false\n when Integer\n width += temp\n lake_size.push(lake_size.pop + lake_size.pop)\n else\n width += 1\n end\n end\n height -= 1\n end\n else\n stack.push char\n end\n }\n puts lake_size.reduce(&:+)\n lake_size.pop\n puts lake_size.size.to_s + \" \" + lake_size.join(\" \")\nend\nmain", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nAreas on the Cross-Section Diagram\n\nYour task is to simulate a flood damage.\n\nFor a given cross-section diagram, reports areas of flooded sections.\n\nAssume that rain is falling endlessly in the region and the water overflowing from the region is falling in the sea at the both sides.\nFor example, for the above cross-section diagram, the rain will create floods which have areas of 4, 2, 1, 19 and 9 respectively.\n\nInput\n\nA string, which represents slopes and flatlands by '/', '\\' and '_' respectively, is given in a line. For example, the region of the above example is given by a string \"\\\\///\\_/\\/\\\\\\\\/_/\\\\///__\\\\\\_\\\\/_\\/_/\\\".\n\noutput\n\nReport the areas of floods in the following format:\n\n$A$\n\n$k$ $L_1$ $L_2$ ... $L_k$\n\nIn the first line, print the total area $A$ of created floods.\n\nIn the second line, print the number of floods $k$ and areas $L_i (i = 1, 2, ..., k)$ for each flood from the left side of the cross-section diagram. Print a space character before $L_i$.\n\nConstraints\n\n$1 \\leq$ length of the string $\\leq 20,000$\n\nSample Input 1\n\n\\\\//\n\nSample Output 1\n\n4\n1 4\n\nSample Input 2\n\n\\\\///\\_/\\/\\\\\\\\/_/\\\\///__\\\\\\_\\\\/_\\/_/\\\n\nSample Output 2\n\n35\n5 4 2 1 19 9", "sample_input": "\\\\//\n"}, "reference_outputs": ["4\n1 4\n"], "source_document_id": "p02266", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nAreas on the Cross-Section Diagram\n\nYour task is to simulate a flood damage.\n\nFor a given cross-section diagram, reports areas of flooded sections.\n\nAssume that rain is falling endlessly in the region and the water overflowing from the region is falling in the sea at the both sides.\nFor example, for the above cross-section diagram, the rain will create floods which have areas of 4, 2, 1, 19 and 9 respectively.\n\nInput\n\nA string, which represents slopes and flatlands by '/', '\\' and '_' respectively, is given in a line. For example, the region of the above example is given by a string \"\\\\///\\_/\\/\\\\\\\\/_/\\\\///__\\\\\\_\\\\/_\\/_/\\\".\n\noutput\n\nReport the areas of floods in the following format:\n\n$A$\n\n$k$ $L_1$ $L_2$ ... $L_k$\n\nIn the first line, print the total area $A$ of created floods.\n\nIn the second line, print the number of floods $k$ and areas $L_i (i = 1, 2, ..., k)$ for each flood from the left side of the cross-section diagram. Print a space character before $L_i$.\n\nConstraints\n\n$1 \\leq$ length of the string $\\leq 20,000$\n\nSample Input 1\n\n\\\\//\n\nSample Output 1\n\n4\n1 4\n\nSample Input 2\n\n\\\\///\\_/\\/\\\\\\\\/_/\\\\///__\\\\\\_\\\\/_\\/_/\\\n\nSample Output 2\n\n35\n5 4 2 1 19 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": 859, "cpu_time_ms": 20, "memory_kb": 6100}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s635431431", "group_id": "codeNet:p02266", "input_text": "s1 = []\ns2 = []\n\nstr = gets\ni = 0\nsum = 0\nstr.chars do |c|\n\tif c == \"\\\\\"\n\t\ts1.push(i) \n\telsif c == \"/\" && s1.size > 0\n\t\tj = s1.pop\n\t\tsum += i - j\n\t\ta = i - j\n\t\twhile s2.size > 0 && s2.last[:pos] > j\n\t\t\tst = s2.pop\n\t\t\ta += st[:area]\n\t\tend\n\t\ts2.push({:pos => j, :area => a})\n\tend\n\ti += 1\nend\n\nputs sum\nprintf(\"%d %s\", s2.size, s2.map{|h|h[:area]}.join(\" \"))", "language": "Ruby", "metadata": {"date": 1443794139, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02266.html", "problem_id": "p02266", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02266/input.txt", "sample_output_relpath": "derived/input_output/data/p02266/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02266/Ruby/s635431431.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s635431431", "user_id": "u292533509"}, "prompt_components": {"gold_output": "4\n1 4\n", "input_to_evaluate": "s1 = []\ns2 = []\n\nstr = gets\ni = 0\nsum = 0\nstr.chars do |c|\n\tif c == \"\\\\\"\n\t\ts1.push(i) \n\telsif c == \"/\" && s1.size > 0\n\t\tj = s1.pop\n\t\tsum += i - j\n\t\ta = i - j\n\t\twhile s2.size > 0 && s2.last[:pos] > j\n\t\t\tst = s2.pop\n\t\t\ta += st[:area]\n\t\tend\n\t\ts2.push({:pos => j, :area => a})\n\tend\n\ti += 1\nend\n\nputs sum\nprintf(\"%d %s\", s2.size, s2.map{|h|h[:area]}.join(\" \"))", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nAreas on the Cross-Section Diagram\n\nYour task is to simulate a flood damage.\n\nFor a given cross-section diagram, reports areas of flooded sections.\n\nAssume that rain is falling endlessly in the region and the water overflowing from the region is falling in the sea at the both sides.\nFor example, for the above cross-section diagram, the rain will create floods which have areas of 4, 2, 1, 19 and 9 respectively.\n\nInput\n\nA string, which represents slopes and flatlands by '/', '\\' and '_' respectively, is given in a line. For example, the region of the above example is given by a string \"\\\\///\\_/\\/\\\\\\\\/_/\\\\///__\\\\\\_\\\\/_\\/_/\\\".\n\noutput\n\nReport the areas of floods in the following format:\n\n$A$\n\n$k$ $L_1$ $L_2$ ... $L_k$\n\nIn the first line, print the total area $A$ of created floods.\n\nIn the second line, print the number of floods $k$ and areas $L_i (i = 1, 2, ..., k)$ for each flood from the left side of the cross-section diagram. Print a space character before $L_i$.\n\nConstraints\n\n$1 \\leq$ length of the string $\\leq 20,000$\n\nSample Input 1\n\n\\\\//\n\nSample Output 1\n\n4\n1 4\n\nSample Input 2\n\n\\\\///\\_/\\/\\\\\\\\/_/\\\\///__\\\\\\_\\\\/_\\/_/\\\n\nSample Output 2\n\n35\n5 4 2 1 19 9", "sample_input": "\\\\//\n"}, "reference_outputs": ["4\n1 4\n"], "source_document_id": "p02266", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nAreas on the Cross-Section Diagram\n\nYour task is to simulate a flood damage.\n\nFor a given cross-section diagram, reports areas of flooded sections.\n\nAssume that rain is falling endlessly in the region and the water overflowing from the region is falling in the sea at the both sides.\nFor example, for the above cross-section diagram, the rain will create floods which have areas of 4, 2, 1, 19 and 9 respectively.\n\nInput\n\nA string, which represents slopes and flatlands by '/', '\\' and '_' respectively, is given in a line. For example, the region of the above example is given by a string \"\\\\///\\_/\\/\\\\\\\\/_/\\\\///__\\\\\\_\\\\/_\\/_/\\\".\n\noutput\n\nReport the areas of floods in the following format:\n\n$A$\n\n$k$ $L_1$ $L_2$ ... $L_k$\n\nIn the first line, print the total area $A$ of created floods.\n\nIn the second line, print the number of floods $k$ and areas $L_i (i = 1, 2, ..., k)$ for each flood from the left side of the cross-section diagram. Print a space character before $L_i$.\n\nConstraints\n\n$1 \\leq$ length of the string $\\leq 20,000$\n\nSample Input 1\n\n\\\\//\n\nSample Output 1\n\n4\n1 4\n\nSample Input 2\n\n\\\\///\\_/\\/\\\\\\\\/_/\\\\///__\\\\\\_\\\\/_\\/_/\\\n\nSample Output 2\n\n35\n5 4 2 1 19 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": 355, "cpu_time_ms": 30, "memory_kb": 8656}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s640302026", "group_id": "codeNet:p02268", "input_text": "n = gets.to_i\ns = gets.split.map(&:to_i)\nq = gets.to_i\nt = gets.split.map(&:to_i)\n\nsum = 0\n\nfor i in 0..(q-1)\n left = 0\n right = n-1\n key = t[i]\n while left < right\n mid = (right+left)/2\n if key == s[mid]\n sum += 1\n break\n elsif key < s[mid]\n right = mid\n else\n left = mid+1\n end\n end\nend\nputs sum", "language": "Ruby", "metadata": {"date": 1506831865, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s640302026.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s640302026", "user_id": "u451183907"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "n = gets.to_i\ns = gets.split.map(&:to_i)\nq = gets.to_i\nt = gets.split.map(&:to_i)\n\nsum = 0\n\nfor i in 0..(q-1)\n left = 0\n right = n-1\n key = t[i]\n while left < right\n mid = (right+left)/2\n if key == s[mid]\n sum += 1\n break\n elsif key < s[mid]\n right = mid\n else\n left = mid+1\n end\n end\nend\nputs sum", "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": 337, "cpu_time_ms": 40, "memory_kb": 8768}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s230348452", "group_id": "codeNet:p02268", "input_text": "require 'benchmark'\n\nn = gets.to_i\nS = gets.split.map(&:to_i)\nq = gets.to_i\nT = gets.split.map(&:to_i)\n\nBenchmark.measure do\n cnt = 0\n S.sort!\n T.each do |x|\n l = 0\n r = n\n while l < r\n m = (l + r) / 2\n if S[m] == x\n cnt += 1\n break\n elsif x < S[m]\n r = m\n else\n l = m + 1\n end\n end\n end\n puts cnt\nend\n\n", "language": "Ruby", "metadata": {"date": 1574674659, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s230348452.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s230348452", "user_id": "u016919094"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "require 'benchmark'\n\nn = gets.to_i\nS = gets.split.map(&:to_i)\nq = gets.to_i\nT = gets.split.map(&:to_i)\n\nBenchmark.measure do\n cnt = 0\n S.sort!\n T.each do |x|\n l = 0\n r = n\n while l < r\n m = (l + r) / 2\n if S[m] == x\n cnt += 1\n break\n elsif x < S[m]\n r = m\n else\n l = m + 1\n end\n end\n end\n puts cnt\nend\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": 373, "cpu_time_ms": 120, "memory_kb": 16252}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s575645484", "group_id": "codeNet:p02268", "input_text": "n=gets.to_i\ns=gets.split.map(&:to_i)\nq=gets.to_i\nt=gets.split.map(&:to_i).sort\nc=0\nq.times{|i|\n\tl=0\n\tr=n\n\twhile l n2 ? n1:n2\n\tend\n\n\tdef showparent\n\t\tif @parent == -1\n\t\t\treturn -1\n\t\telse\n\t\t\treturn @parent.key\n\t\tend\n\tend\n\n\tdef showsib\n\t\tif @sib == -1\n\t\t\treturn -1\n\t\telse\n\t\t\treturn @sib.key\n\t\tend\n\tend\n\n\tdef degree\n\t\tanswer = 0\n\t\tif @left != -1\n\t\t\tanswer+=1\n\t\tend\n\t\tif @right != -1\n\t\t\tanswer+=1\n\t\tend\n\t\tanswer\n\tend\nend\n\nn = gets.to_i\n\ntree = Hash.new\ncheck = Array.new(n){true}\nn.times do |i|\n\ttree[i] = Tree.new(i)\nend\n\nn.times do\n\tdata = gets.split.map(&:to_i)\n\tnum = data[0]\n\ttree[num].left = tree[data[1]] || -1\n\ttree[num].right = tree[data[2]] || -1\n\tif tree[data[1]]\n\t\ttree[data[1]].parent = tree[num]\n\t\ttree[data[1]].sib = tree[data[2]] || -1\n\t\tcheck[data[1]] = false\n\tend\n\tif tree[data[2]]\n\t\ttree[data[2]].parent = tree[num]\n\t\ttree[data[2]].sib = tree[data[1]] || -1\n\t\tcheck[data[2]] = false\n\tend\nend\nr = check.index(true)\ntree[r].depth(0,tree)\n\nn.times do |i|\n\tobj = tree[i]\n\ttype = nil\n\tif obj.parent == -1\n\t\ttype = \"root\"\n\telsif obj.left == -1 && obj.right == -1\n\t\ttype = \"leaf\"\n\telse\n\t\ttype = \"internal node\"\n\tend\n\n\tputs \"node #{i}: parent = #{obj.showparent}, sibling = #{obj.showsib}, degree = #{obj.degree}, depth = #{obj.dep}, height = #{obj.height(0)}, #{type}\"\n\n\nend", "language": "Ruby", "metadata": {"date": 1490093463, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02280.html", "problem_id": "p02280", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02280/input.txt", "sample_output_relpath": "derived/input_output/data/p02280/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02280/Ruby/s371211046.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s371211046", "user_id": "u723368439"}, "prompt_components": {"gold_output": "node 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root\nnode 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node\nnode 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf\nnode 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf\nnode 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node\nnode 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node\nnode 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf\nnode 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf\nnode 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf\n", "input_to_evaluate": "class Tree\n\tattr_accessor :parent, :root, :dep, :key, :left,:right, :sib\n \n\tdef initialize(key)\n\t\t@parent = -1\n\t\t@left = -1\n\t\t@right = -1\n\t\t@dep = -1\n\t\t@key = key\n\t\t@sib = -1\n\tend\n\n\tdef depth(answer,tree)\n\t\tif @left!=-1\n\t\t\t@left.depth(answer + 1,tree)\n\t\tend\n\n\t\tif @right != -1\n\t\t\t@right.depth(answer + 1,tree)\n\t\tend\n\t\t@dep = answer\n\tend\n\n\tdef height(h)\n\t\tn1 = h\n\t\tn2 = h\n\n\t\tif @left!=-1\n\t\t\tn1 = left.height(h + 1)\n\t\tend\n \n\t\tif @right!=-1\n\t\t\tn2 = right.height(h + 1)\n\t\tend\n\n\t\treturn n1 > n2 ? n1:n2\n\tend\n\n\tdef showparent\n\t\tif @parent == -1\n\t\t\treturn -1\n\t\telse\n\t\t\treturn @parent.key\n\t\tend\n\tend\n\n\tdef showsib\n\t\tif @sib == -1\n\t\t\treturn -1\n\t\telse\n\t\t\treturn @sib.key\n\t\tend\n\tend\n\n\tdef degree\n\t\tanswer = 0\n\t\tif @left != -1\n\t\t\tanswer+=1\n\t\tend\n\t\tif @right != -1\n\t\t\tanswer+=1\n\t\tend\n\t\tanswer\n\tend\nend\n\nn = gets.to_i\n\ntree = Hash.new\ncheck = Array.new(n){true}\nn.times do |i|\n\ttree[i] = Tree.new(i)\nend\n\nn.times do\n\tdata = gets.split.map(&:to_i)\n\tnum = data[0]\n\ttree[num].left = tree[data[1]] || -1\n\ttree[num].right = tree[data[2]] || -1\n\tif tree[data[1]]\n\t\ttree[data[1]].parent = tree[num]\n\t\ttree[data[1]].sib = tree[data[2]] || -1\n\t\tcheck[data[1]] = false\n\tend\n\tif tree[data[2]]\n\t\ttree[data[2]].parent = tree[num]\n\t\ttree[data[2]].sib = tree[data[1]] || -1\n\t\tcheck[data[2]] = false\n\tend\nend\nr = check.index(true)\ntree[r].depth(0,tree)\n\nn.times do |i|\n\tobj = tree[i]\n\ttype = nil\n\tif obj.parent == -1\n\t\ttype = \"root\"\n\telsif obj.left == -1 && obj.right == -1\n\t\ttype = \"leaf\"\n\telse\n\t\ttype = \"internal node\"\n\tend\n\n\tputs \"node #{i}: parent = #{obj.showparent}, sibling = #{obj.showsib}, degree = #{obj.degree}, depth = #{obj.dep}, height = #{obj.height(0)}, #{type}\"\n\n\nend", "problem_context": "Binary Tree\n\nA rooted binary tree is a tree with a root node in which every node has at most two children.\n\nYour task is to write a program which reads a rooted binary tree T and prints the following information for each node u of T:\n\nnode ID of u\n\nparent of u\n\nsibling of u\n\nthe number of children of u\n\ndepth of u\n\nheight of u\n\nnode type (root, internal node or leaf)\n\nIf two nodes have the same parent, they are siblings. Here, if u and v have the same parent, we say u is a sibling of v (vice versa).\n\nThe height of a node in a tree is the number of edges on the longest simple downward path from the node to a leaf.\n\nHere, the given binary tree consists of n nodes and evey node has a unique ID from 0 to n-1.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node is given in the following format:\n\nid left right\n\nid is the node ID, left is ID of the left child and right is ID of the right child. If the node does not have the left (right) child, the left(right) is indicated by -1.\n\nOutput\n\nPrint the information of each node in the following format:\n\nnode id: parent = p, sibling = s, degree = deg, depth = dep, height = h, type\n\np is ID of its parent. If the node does not have a parent, print -1.\n\ns is ID of its sibling. If the node does not have a sibling, print -1.\n\ndeg, dep and h are the number of children, depth and height of the node respectively.\n\ntype is a type of nodes represented by a string (root, internal node or leaf. If the root can be considered as a leaf or an internal node, print root.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 ≤ n ≤ 25\n\nSample Input 1\n\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1\n\nnode 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root\nnode 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node\nnode 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf\nnode 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf\nnode 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node\nnode 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node\nnode 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf\nnode 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf\nnode 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n"}, "reference_outputs": ["node 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root\nnode 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node\nnode 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf\nnode 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf\nnode 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node\nnode 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node\nnode 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf\nnode 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf\nnode 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf\n"], "source_document_id": "p02280", "source_text": "Binary Tree\n\nA rooted binary tree is a tree with a root node in which every node has at most two children.\n\nYour task is to write a program which reads a rooted binary tree T and prints the following information for each node u of T:\n\nnode ID of u\n\nparent of u\n\nsibling of u\n\nthe number of children of u\n\ndepth of u\n\nheight of u\n\nnode type (root, internal node or leaf)\n\nIf two nodes have the same parent, they are siblings. Here, if u and v have the same parent, we say u is a sibling of v (vice versa).\n\nThe height of a node in a tree is the number of edges on the longest simple downward path from the node to a leaf.\n\nHere, the given binary tree consists of n nodes and evey node has a unique ID from 0 to n-1.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node is given in the following format:\n\nid left right\n\nid is the node ID, left is ID of the left child and right is ID of the right child. If the node does not have the left (right) child, the left(right) is indicated by -1.\n\nOutput\n\nPrint the information of each node in the following format:\n\nnode id: parent = p, sibling = s, degree = deg, depth = dep, height = h, type\n\np is ID of its parent. If the node does not have a parent, print -1.\n\ns is ID of its sibling. If the node does not have a sibling, print -1.\n\ndeg, dep and h are the number of children, depth and height of the node respectively.\n\ntype is a type of nodes represented by a string (root, internal node or leaf. If the root can be considered as a leaf or an internal node, print root.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 ≤ n ≤ 25\n\nSample Input 1\n\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1\n\nnode 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root\nnode 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node\nnode 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf\nnode 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf\nnode 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node\nnode 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node\nnode 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf\nnode 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf\nnode 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1658, "cpu_time_ms": 30, "memory_kb": 8716}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s903801256", "group_id": "codeNet:p02281", "input_text": "n=*0...gets.to_i\ng=$<.map{|l|l.split.map &:to_i}.sort\nr=n.-g.map{|v|v[1,2]}.reduce:+\nx,y,*z=[],[]\nw=->f,i{i<0&&next\nx<f,i{i<0&&next\nx< @queue[i] then largest = l\n else largest = i end\n largest = r if r <= @queue.size && @queue[r] > @queue[largest]\n if largest != i then\n @queue[i],@queue[largest] = @queue[largest],@queue[i]\n max_heap_fy(largest)\n end\n end\nend\n\n\ndef max_heap_fy(i)\n l = 2 * i\n r = 2 * i + 1\n if l<= @h && @que[l] > @que[i] then largest = l\n else largest = i end\n largest = r if r <= @h && @que[r] > @que[largest]\n if largest != i then\n @que[i],@que[largest] = @que[largest],@que[i]\n max_heap_fy(largest)\n end\nend\n\n@h = gets.to_i\n@que = gets.split.map(&:to_i)\n@que.insert(0,-114514)\n(@h / 2).downto(1)do |i|\n max_heap_fy(i)\nend\nputs \" #{@que[1..@que.size - 1].join(\" \")}\"\n", "language": "Ruby", "metadata": {"date": 1495098569, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s798460067.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s798460067", "user_id": "u624226399"}, "prompt_components": {"gold_output": " 16 14 10 8 7 9 3 2 4 1\n", "input_to_evaluate": "class PriorityQueue\n #?????????\n def initialize\n @queue = Array.new\n end\n\n #???????????????????´??????????\n def top\n @queue[0]\n end\n\n #???????????????????´??????????????????????????´??????????\n def pop\n top = @queue[0]\n n = @queue.size - 1\n\n end\n\n #?????§?????´??°\n def max_heap_fy(i)\n l = 2 * i\n r = 2 * i + 1\n if l<= @queue.size && @queue[l] > @queue[i] then largest = l\n else largest = i end\n largest = r if r <= @queue.size && @queue[r] > @queue[largest]\n if largest != i then\n @queue[i],@queue[largest] = @queue[largest],@queue[i]\n max_heap_fy(largest)\n end\n end\nend\n\n\ndef max_heap_fy(i)\n l = 2 * i\n r = 2 * i + 1\n if l<= @h && @que[l] > @que[i] then largest = l\n else largest = i end\n largest = r if r <= @h && @que[r] > @que[largest]\n if largest != i then\n @que[i],@que[largest] = @que[largest],@que[i]\n max_heap_fy(largest)\n end\nend\n\n@h = gets.to_i\n@que = gets.split.map(&:to_i)\n@que.insert(0,-114514)\n(@h / 2).downto(1)do |i|\n max_heap_fy(i)\nend\nputs \" #{@que[1..@que.size - 1].join(\" \")}\"\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": 1074, "cpu_time_ms": 480, "memory_kb": 65936}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s681577238", "group_id": "codeNet:p02289", "input_text": "def extract(i)\n l = 2*i -1\n r = 2*i\n i -= 1\n\n if A[l] == nil\n return\n elsif A[r] == nil\n A[i], A[l] = A[l], A[i]\n elsif A[l] >= A[r] && A[l] > A[i]\n A[i], A[l] = A[l], A[i]\n extract(l+1)\n elsif A[l] < A[r] && A[r] > A[i]\n A[i], A[r] = A[r], A[i]\n extract(r+1)\n end\nend\n\ndef insert(i)\n if i == 1\n return\n end\n\n parent = i/2 -1\n i -= 1\n\n if A[i] > A[parent]\n A[i], A[parent] = A[parent], A[i]\n insert(parent+1)\n end\nend\n\nA = Array.new\n\nuntil (str=gets.chomp) == \"end\"\n if str == \"extract\"\n puts A.shift\n # A.shift\n A.unshift(A.pop)\n extract(1)\n else # insert\n str = str.split(\" \")\n A << str[1].to_i\n insert(A.length)\n end\n # p A\nend\n\n", "language": "Ruby", "metadata": {"date": 1531467569, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02289.html", "problem_id": "p02289", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02289/input.txt", "sample_output_relpath": "derived/input_output/data/p02289/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02289/Ruby/s681577238.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s681577238", "user_id": "u268784151"}, "prompt_components": {"gold_output": "8\n10\n11\n2\n", "input_to_evaluate": "def extract(i)\n l = 2*i -1\n r = 2*i\n i -= 1\n\n if A[l] == nil\n return\n elsif A[r] == nil\n A[i], A[l] = A[l], A[i]\n elsif A[l] >= A[r] && A[l] > A[i]\n A[i], A[l] = A[l], A[i]\n extract(l+1)\n elsif A[l] < A[r] && A[r] > A[i]\n A[i], A[r] = A[r], A[i]\n extract(r+1)\n end\nend\n\ndef insert(i)\n if i == 1\n return\n end\n\n parent = i/2 -1\n i -= 1\n\n if A[i] > A[parent]\n A[i], A[parent] = A[parent], A[i]\n insert(parent+1)\n end\nend\n\nA = Array.new\n\nuntil (str=gets.chomp) == \"end\"\n if str == \"extract\"\n puts A.shift\n # A.shift\n A.unshift(A.pop)\n extract(1)\n else # insert\n str = str.split(\" \")\n A << str[1].to_i\n insert(A.length)\n end\n # p A\nend\n\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nPriority Queue\n\nA priority queue is a data structure which maintains a set $S$ of elements, each of with an associated value (key), and supports the following operations:\n\n$insert(S, k)$: insert an element $k$ into the set $S$\n\n$extractMax(S)$: remove and return the element of $S$ with the largest key\n\nWrite a program which performs the $insert(S, k)$ and $extractMax(S)$ operations to a priority queue $S$.\nThe priority queue manages a set of integers, which are also keys for the priority.\n\nInput\n\nMultiple operations to the priority queue $S$ are given. Each operation is given by \"insert $k$\", \"extract\" or \"end\" in a line. Here, $k$ represents an integer element to be inserted to the priority queue.\n\nThe input ends with \"end\" operation.\n\nOutput\n\nFor each \"extract\" operation, print the element extracted from the priority queue $S$ in a line.\n\nConstraints\n\nThe number of operations $\\leq 2,000,000$\n\n$0 \\leq k \\leq 2,000,000,000$\n\nSample Input 1\n\ninsert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend\n\nSample Output 1\n\n8\n10\n11\n2", "sample_input": "insert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend\n"}, "reference_outputs": ["8\n10\n11\n2\n"], "source_document_id": "p02289", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nPriority Queue\n\nA priority queue is a data structure which maintains a set $S$ of elements, each of with an associated value (key), and supports the following operations:\n\n$insert(S, k)$: insert an element $k$ into the set $S$\n\n$extractMax(S)$: remove and return the element of $S$ with the largest key\n\nWrite a program which performs the $insert(S, k)$ and $extractMax(S)$ operations to a priority queue $S$.\nThe priority queue manages a set of integers, which are also keys for the priority.\n\nInput\n\nMultiple operations to the priority queue $S$ are given. Each operation is given by \"insert $k$\", \"extract\" or \"end\" in a line. Here, $k$ represents an integer element to be inserted to the priority queue.\n\nThe input ends with \"end\" operation.\n\nOutput\n\nFor each \"extract\" operation, print the element extracted from the priority queue $S$ in a line.\n\nConstraints\n\nThe number of operations $\\leq 2,000,000$\n\n$0 \\leq k \\leq 2,000,000,000$\n\nSample Input 1\n\ninsert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend\n\nSample Output 1\n\n8\n10\n11\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 699, "cpu_time_ms": 20000, "memory_kb": 18328}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s780235473", "group_id": "codeNet:p02289", "input_text": "class PriorityQueue\n def initialize\n @n = 0\n @heap = []\n end\n \n def maxHeapify x\n l = 2*x\n r = 2*x+1\n if l <= @n && @heap[l] > @heap[x]\n largest = l\n else\n largest = x\n end\n if r <= @n && @heap[r] > @heap[largest]\n largest = r\n end\n if largest != x\n @heap[x], @heap[largest] = @heap[largest], @heap[x]\n maxHeapify(largest)\n end\n end\n \n def extract\n key = @heap[1]\n @heap[1] = @heap[@n]\n @n -= 1\n maxHeapify(1)\n key\n end\n \n def insert key\n @n += 1\n @heap[@n] = key\n i = @n\n while i > 1 && @heap[i/2] < @heap[i]\n @heap[i], @heap[i/2] = @heap[i/2], @heap[i]\n i /= 2\n end\n end\nend\n\npq = PriorityQueue.new\nwhile l = gets\n break if l.chomp == \"end\"\n if l.chomp == \"extract\" then puts pq.extract\n else pq.insert(l.split[1].to_i)\n end\nend ", "language": "Ruby", "metadata": {"date": 1455690980, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02289.html", "problem_id": "p02289", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02289/input.txt", "sample_output_relpath": "derived/input_output/data/p02289/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02289/Ruby/s780235473.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s780235473", "user_id": "u811434779"}, "prompt_components": {"gold_output": "8\n10\n11\n2\n", "input_to_evaluate": "class PriorityQueue\n def initialize\n @n = 0\n @heap = []\n end\n \n def maxHeapify x\n l = 2*x\n r = 2*x+1\n if l <= @n && @heap[l] > @heap[x]\n largest = l\n else\n largest = x\n end\n if r <= @n && @heap[r] > @heap[largest]\n largest = r\n end\n if largest != x\n @heap[x], @heap[largest] = @heap[largest], @heap[x]\n maxHeapify(largest)\n end\n end\n \n def extract\n key = @heap[1]\n @heap[1] = @heap[@n]\n @n -= 1\n maxHeapify(1)\n key\n end\n \n def insert key\n @n += 1\n @heap[@n] = key\n i = @n\n while i > 1 && @heap[i/2] < @heap[i]\n @heap[i], @heap[i/2] = @heap[i/2], @heap[i]\n i /= 2\n end\n end\nend\n\npq = PriorityQueue.new\nwhile l = gets\n break if l.chomp == \"end\"\n if l.chomp == \"extract\" then puts pq.extract\n else pq.insert(l.split[1].to_i)\n end\nend ", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nPriority Queue\n\nA priority queue is a data structure which maintains a set $S$ of elements, each of with an associated value (key), and supports the following operations:\n\n$insert(S, k)$: insert an element $k$ into the set $S$\n\n$extractMax(S)$: remove and return the element of $S$ with the largest key\n\nWrite a program which performs the $insert(S, k)$ and $extractMax(S)$ operations to a priority queue $S$.\nThe priority queue manages a set of integers, which are also keys for the priority.\n\nInput\n\nMultiple operations to the priority queue $S$ are given. Each operation is given by \"insert $k$\", \"extract\" or \"end\" in a line. Here, $k$ represents an integer element to be inserted to the priority queue.\n\nThe input ends with \"end\" operation.\n\nOutput\n\nFor each \"extract\" operation, print the element extracted from the priority queue $S$ in a line.\n\nConstraints\n\nThe number of operations $\\leq 2,000,000$\n\n$0 \\leq k \\leq 2,000,000,000$\n\nSample Input 1\n\ninsert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend\n\nSample Output 1\n\n8\n10\n11\n2", "sample_input": "insert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend\n"}, "reference_outputs": ["8\n10\n11\n2\n"], "source_document_id": "p02289", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nPriority Queue\n\nA priority queue is a data structure which maintains a set $S$ of elements, each of with an associated value (key), and supports the following operations:\n\n$insert(S, k)$: insert an element $k$ into the set $S$\n\n$extractMax(S)$: remove and return the element of $S$ with the largest key\n\nWrite a program which performs the $insert(S, k)$ and $extractMax(S)$ operations to a priority queue $S$.\nThe priority queue manages a set of integers, which are also keys for the priority.\n\nInput\n\nMultiple operations to the priority queue $S$ are given. Each operation is given by \"insert $k$\", \"extract\" or \"end\" in a line. Here, $k$ represents an integer element to be inserted to the priority queue.\n\nThe input ends with \"end\" operation.\n\nOutput\n\nFor each \"extract\" operation, print the element extracted from the priority queue $S$ in a line.\n\nConstraints\n\nThe number of operations $\\leq 2,000,000$\n\n$0 \\leq k \\leq 2,000,000,000$\n\nSample Input 1\n\ninsert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend\n\nSample Output 1\n\n8\n10\n11\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 846, "cpu_time_ms": 6410, "memory_kb": 16704}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s943272818", "group_id": "codeNet:p02293", "input_text": "require 'matrix'\nq = gets.to_i\nq.times do\n x0, y0, x1, y1, x2, y2, x3, y3 = gets.split.map &:to_i\n s1 = Vector[ x1 - x0, y1 - y0, 0 ]\n s2 = Vector[ x3 - x2, y3 - y2, 0 ]\n if s1.inner_product(s1) == 0\n puts 1\n elsif s1.cross_product(s2).norm == 0\n puts 2\n else\n puts 0\n end\nend", "language": "Ruby", "metadata": {"date": 1455155211, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02293.html", "problem_id": "p02293", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02293/input.txt", "sample_output_relpath": "derived/input_output/data/p02293/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02293/Ruby/s943272818.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s943272818", "user_id": "u352522848"}, "prompt_components": {"gold_output": "2\n1\n0\n", "input_to_evaluate": "require 'matrix'\nq = gets.to_i\nq.times do\n x0, y0, x1, y1, x2, y2, x3, y3 = gets.split.map &:to_i\n s1 = Vector[ x1 - x0, y1 - y0, 0 ]\n s2 = Vector[ x3 - x2, y3 - y2, 0 ]\n if s1.inner_product(s1) == 0\n puts 1\n elsif s1.cross_product(s2).norm == 0\n puts 2\n else\n puts 0\n end\nend", "problem_context": "Parallel/Orthogonal\n\nFor given two lines s1 and s2, print \"2\" if they are parallel, \"1\" if they are orthogonal, or \"0\" otherwise.\n\ns1 crosses points p0 and p1, and\ns2 crosses 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 the points p0, p1, p2, p3 in the following format:\n\nxp0 yp0 xp1 yp1 xp2 yp2 xp3 yp3\n\nOutput\n\nFor each query, print \"2\", \"1\" or \"0\".\n\nConstraints\n\n1 ≤ q ≤ 1000\n\n-10000 ≤ xpi, ypi ≤ 10000\n\np0 ≠ p1 and\np2 ≠ p3.\n\nSample Input 1\n\n3\n0 0 3 0 0 2 3 2\n0 0 3 0 1 1 1 4\n0 0 3 0 1 1 2 2\n\nSample Output 1\n\n2\n1\n0", "sample_input": "3\n0 0 3 0 0 2 3 2\n0 0 3 0 1 1 1 4\n0 0 3 0 1 1 2 2\n"}, "reference_outputs": ["2\n1\n0\n"], "source_document_id": "p02293", "source_text": "Parallel/Orthogonal\n\nFor given two lines s1 and s2, print \"2\" if they are parallel, \"1\" if they are orthogonal, or \"0\" otherwise.\n\ns1 crosses points p0 and p1, and\ns2 crosses 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 the points p0, p1, p2, p3 in the following format:\n\nxp0 yp0 xp1 yp1 xp2 yp2 xp3 yp3\n\nOutput\n\nFor each query, print \"2\", \"1\" or \"0\".\n\nConstraints\n\n1 ≤ q ≤ 1000\n\n-10000 ≤ xpi, ypi ≤ 10000\n\np0 ≠ p1 and\np2 ≠ p3.\n\nSample Input 1\n\n3\n0 0 3 0 0 2 3 2\n0 0 3 0 1 1 1 4\n0 0 3 0 1 1 2 2\n\nSample Output 1\n\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": 292, "cpu_time_ms": 50, "memory_kb": 9196}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s079919169", "group_id": "codeNet:p02315", "input_text": "@data = '50\n5\n60,10\n100,20\n120,30\n210,45\n10,4\n20\n8\n10,7\n4,2\n5,9\n1,4\n7,9\n3,7\n6,4\n3,5\n0\n'.split(\"\\n\")\n\n# @data = readlines\n\nP_CROSS = 0.6\nP_MUTATION = 0.01\n\nItem = Struct.new(:value, :weight)\n\nProblem = []\n\ndef init(count = 0)\n if @data[0] != '0'\n Problem << {Max_weight: @data[0].to_i, N: @data[1].to_i, Items: Array.new(@data[1].to_i)}\n @data[1].to_i.times do |i|\n Problem[count][:Items][i] = Item.new(*@data[i+2].split(',').map(&:to_i))\n end\n# p Problem[count]\n @data = @data[(@data[1].to_i+2)...@data.length]\n init(count+1)\n end\nend\n\ndef aoj\n n,w = gets().chomp.split(' ').map(&:to_i)\n @data = []\n @data << w\n @data << n\n n.times do |i|\n @data << gets().chomp.split(' ').join(',')\n end\n\n Problem << {Max_weight: @data[0], N: @data[1], Items: Array.new(@data[1])}\n @data[1].times do |i|\n Problem[0][:Items][i] = Item.new(*@data[i+2].split(',').map(&:to_i))\n end\nend\n\nclass GA\n\n # 0: ??\\???????????? 1: ??\\?????????\n GENE = Struct.new(:score, :chromosome)\n\n def initialize(population, items, max)\n @generation = 1\n @population = population # ????????°\n @items = items\n @max = max # ??????????????????????????§??????\n @size = items.length # ????????????\n @genes = Array.new(@population) { GENE.new(0, Array.new(@items.length)) }\n start_time = Time.now\n# p @items\n\n# srand(start_time.sec)\n\n @genes.each do |gene|\n gene.chromosome.map! { |locas| locas = rand(2) }\n# puts gene\n end\n\n evaluate(@genes)\n\n sort_genes\n# puts @genes\n\n end\n\n def evaluate(genes)\n genes.each do |gene|\n value_sum = 0\n weight_sum = 0\n gene.chromosome.each_with_index do |locas, index|\n if locas == 1\n value_sum += @items[index].value\n weight_sum += @items[index].weight\n end\n end\n if weight_sum <= @max && weight_sum != 0\n gene.score = value_sum\n else\n gene.score = 1\n end\n end\n# puts genes\n end\n\n def sort_genes\n @genes.sort_by! { |gene| -gene.score }\n end\n\n\n def start\n prev = 0\n end_count = 0\n loop do\n yield(@generation, @genes[0, @population], @genes[0], avg)\n selection\n mutation\n\n evaluate(@genes)\n sort_genes\n# puts @genes\n\n if prev == @genes[0].score && prev != 1\n break if end_count > 100\n end_count += 1\n else\n end_count = 0\n end\n prev = @genes[0].score\n @generation += 1\n end\n\n value_sum = 0\n weight_sum = 0\n @genes[0].chromosome.each_with_index do |locas, index|\n if locas == 1\n value_sum += @items[index].value\n weight_sum += @items[index].weight\n end\n end\n# puts \"value_sum : \" + value_sum.to_s\n puts value_sum.to_s\n# puts \"weight_sum : \" + weight_sum.to_s\n\n\n yield(@generation, @genes[0,@population], @genes[0], avg)\n end\n\n\n def selection\n # ??¨???????????????\n # ??¨??????????????????????????????????????????\n # http://mikilab.doshisha.ac.jp/dia/research/person/jiro/reports/GAparams/GAparams03.html\n # ??????????????????????????????????????¶?????°?????????\"??????????????????\n # ?¬?????????£??§?????????????????????????????°???????????????\n\n # ??¨????????????????????????????????????????????? ???\n # @genes.first.chromosome = @parents.first.chromosome\n\n # @parents = Marshal.load(Marshal.dump(@genes))\n @parents = Array.new(@population)\n @elite = Marshal.load(Marshal.dump(@genes.first))\n @parents[0] = @elite\n\n# p @genes\n\n linear_scaling\n\n # ????????¬????????????\n # 1.upto((@size)/2) do |i|\n # ??????????????????????????????????????¬?????????????????????\n# p sum\n# p @genes\n 1.upto(@population-1) do |i|\n @parents[i] = Marshal.load(Marshal.dump(@genes[roulette(rand(sum))]))\n# crossover(roulette,roulette,@size-(i*2-1),@size-(i*2))\n end\n\n @genes = []\n\n # ????????????????????????????????????,?¬?????????£????????????????????? ? ???????????????????????????????????§?????¶ => N ~ 2N ???????\n # count = 0\n @population.times do |i|\n @population.times do |j|\n if rand < P_CROSS\n crossover(i, j) #, count, count+1)\n# count += 2\n# break if count > @population\n break\n else\n @genes << @parents[i]\n break\n end\n end\n end\n\n end\n\n\n # ?????¢?????±???????????°\n # ????????? fi ??? f'i ??????????????????\n # a = 1 , b = (fN - f1*N) / N -1 => f'i = a * fi + b\n def linear_scaling\n f_avg = avg\n f_max = @genes[0].score\n f_min = @genes[-1].score\n# p f_avg, f_min\n\n return if f_avg == f_min\n\n a = 0\n b = 0\n c = 2.0\n n = @parents.length\n\n# p f_min >= (c * f_avg - f_max)/(c - 1.0)\n\n if f_min >= (c * f_avg - f_max)/(c - 1.0)\n a = (c - 1.0) * f_avg / (f_max - f_avg)\n b = f_avg * (f_max - c*f_avg)/(f_max - f_avg)\n else\n a = f_avg / (f_avg - f_min)\n b = -f_min * f_avg / (f_avg - f_min)\n end\n @genes.each { |gene| gene.score = a * gene.score + b }\n end\n\n def roulette(prob)\n# puts \"sum : %d\" % sum\n @genes.each_with_index do |gene, index|\n prob -= gene.score\n return index if prob < 0\n end\n end\n\n # 2?????????\n def crossover(p1, p2) #, c1, c2)\n# p p1, p2\n parent1 = Marshal.load(Marshal.dump(@parents[p1]))\n parent2 = Marshal.load(Marshal.dump(@parents[p2]))\n\n start_id = rand(@size)\n cross_length = rand(@size - start_id)\n\n parent1.chromosome[start_id, cross_length], parent2.chromosome[start_id, cross_length] = parent2.chromosome[start_id, cross_length], parent1.chromosome[start_id, cross_length]\n @genes << parent1\n @genes << parent2\n#@genes[c1].chromosome = parent1\n#@genes[c2].chromosome = parent2\n# evaluate(@genes[-1])\n# evaluate(@genes[-2])\n end\n\n def mutation\n @genes.each_with_index do |gene, index|\n if rand < P_MUTATION\n i = rand(@size)\n gene.chromosome[i] = (gene.chromosome[i] - 1).abs\n end\n end\n end\n\n def sum\n# p @genes\n# p @genes.map{|item| item[:score]}\n @genes.map { |item| item[:score] }.inject(:+)\n end\n\n def avg\n sum / @genes.length\n #sum = @genes.select{|item| item[:score]>1}\n #sum.map{|item| item[:score]}.inject(:+)/sum.length\n # p sum.inject{|arr,item| arr + item[:score]}#/sum.length\n end\n\nend\n\n\nif __FILE__ == $0\n aoj\n# init\n# p Problem\n# p Problem[0][:Items][0].weight\n\n population = 100\n\n Problem.each do |problem|\n ga = GA.new(population, problem[:Items], problem[:Max_weight])\n ga.start do |generation, genes, max_score, average|\n# puts 'generation : ' + generation.to_s\n# puts 'elite : ' + genes[0].to_s\n# genes.each do |item|\n# p item\n# end\n# break if gets =~ /x/\n end\n\n end\n\n\nend", "language": "Ruby", "metadata": {"date": 1449215681, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02315.html", "problem_id": "p02315", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02315/input.txt", "sample_output_relpath": "derived/input_output/data/p02315/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02315/Ruby/s079919169.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s079919169", "user_id": "u983614091"}, "prompt_components": {"gold_output": "13\n", "input_to_evaluate": "@data = '50\n5\n60,10\n100,20\n120,30\n210,45\n10,4\n20\n8\n10,7\n4,2\n5,9\n1,4\n7,9\n3,7\n6,4\n3,5\n0\n'.split(\"\\n\")\n\n# @data = readlines\n\nP_CROSS = 0.6\nP_MUTATION = 0.01\n\nItem = Struct.new(:value, :weight)\n\nProblem = []\n\ndef init(count = 0)\n if @data[0] != '0'\n Problem << {Max_weight: @data[0].to_i, N: @data[1].to_i, Items: Array.new(@data[1].to_i)}\n @data[1].to_i.times do |i|\n Problem[count][:Items][i] = Item.new(*@data[i+2].split(',').map(&:to_i))\n end\n# p Problem[count]\n @data = @data[(@data[1].to_i+2)...@data.length]\n init(count+1)\n end\nend\n\ndef aoj\n n,w = gets().chomp.split(' ').map(&:to_i)\n @data = []\n @data << w\n @data << n\n n.times do |i|\n @data << gets().chomp.split(' ').join(',')\n end\n\n Problem << {Max_weight: @data[0], N: @data[1], Items: Array.new(@data[1])}\n @data[1].times do |i|\n Problem[0][:Items][i] = Item.new(*@data[i+2].split(',').map(&:to_i))\n end\nend\n\nclass GA\n\n # 0: ??\\???????????? 1: ??\\?????????\n GENE = Struct.new(:score, :chromosome)\n\n def initialize(population, items, max)\n @generation = 1\n @population = population # ????????°\n @items = items\n @max = max # ??????????????????????????§??????\n @size = items.length # ????????????\n @genes = Array.new(@population) { GENE.new(0, Array.new(@items.length)) }\n start_time = Time.now\n# p @items\n\n# srand(start_time.sec)\n\n @genes.each do |gene|\n gene.chromosome.map! { |locas| locas = rand(2) }\n# puts gene\n end\n\n evaluate(@genes)\n\n sort_genes\n# puts @genes\n\n end\n\n def evaluate(genes)\n genes.each do |gene|\n value_sum = 0\n weight_sum = 0\n gene.chromosome.each_with_index do |locas, index|\n if locas == 1\n value_sum += @items[index].value\n weight_sum += @items[index].weight\n end\n end\n if weight_sum <= @max && weight_sum != 0\n gene.score = value_sum\n else\n gene.score = 1\n end\n end\n# puts genes\n end\n\n def sort_genes\n @genes.sort_by! { |gene| -gene.score }\n end\n\n\n def start\n prev = 0\n end_count = 0\n loop do\n yield(@generation, @genes[0, @population], @genes[0], avg)\n selection\n mutation\n\n evaluate(@genes)\n sort_genes\n# puts @genes\n\n if prev == @genes[0].score && prev != 1\n break if end_count > 100\n end_count += 1\n else\n end_count = 0\n end\n prev = @genes[0].score\n @generation += 1\n end\n\n value_sum = 0\n weight_sum = 0\n @genes[0].chromosome.each_with_index do |locas, index|\n if locas == 1\n value_sum += @items[index].value\n weight_sum += @items[index].weight\n end\n end\n# puts \"value_sum : \" + value_sum.to_s\n puts value_sum.to_s\n# puts \"weight_sum : \" + weight_sum.to_s\n\n\n yield(@generation, @genes[0,@population], @genes[0], avg)\n end\n\n\n def selection\n # ??¨???????????????\n # ??¨??????????????????????????????????????????\n # http://mikilab.doshisha.ac.jp/dia/research/person/jiro/reports/GAparams/GAparams03.html\n # ??????????????????????????????????????¶?????°?????????\"??????????????????\n # ?¬?????????£??§?????????????????????????????°???????????????\n\n # ??¨????????????????????????????????????????????? ???\n # @genes.first.chromosome = @parents.first.chromosome\n\n # @parents = Marshal.load(Marshal.dump(@genes))\n @parents = Array.new(@population)\n @elite = Marshal.load(Marshal.dump(@genes.first))\n @parents[0] = @elite\n\n# p @genes\n\n linear_scaling\n\n # ????????¬????????????\n # 1.upto((@size)/2) do |i|\n # ??????????????????????????????????????¬?????????????????????\n# p sum\n# p @genes\n 1.upto(@population-1) do |i|\n @parents[i] = Marshal.load(Marshal.dump(@genes[roulette(rand(sum))]))\n# crossover(roulette,roulette,@size-(i*2-1),@size-(i*2))\n end\n\n @genes = []\n\n # ????????????????????????????????????,?¬?????????£????????????????????? ? ???????????????????????????????????§?????¶ => N ~ 2N ???????\n # count = 0\n @population.times do |i|\n @population.times do |j|\n if rand < P_CROSS\n crossover(i, j) #, count, count+1)\n# count += 2\n# break if count > @population\n break\n else\n @genes << @parents[i]\n break\n end\n end\n end\n\n end\n\n\n # ?????¢?????±???????????°\n # ????????? fi ??? f'i ??????????????????\n # a = 1 , b = (fN - f1*N) / N -1 => f'i = a * fi + b\n def linear_scaling\n f_avg = avg\n f_max = @genes[0].score\n f_min = @genes[-1].score\n# p f_avg, f_min\n\n return if f_avg == f_min\n\n a = 0\n b = 0\n c = 2.0\n n = @parents.length\n\n# p f_min >= (c * f_avg - f_max)/(c - 1.0)\n\n if f_min >= (c * f_avg - f_max)/(c - 1.0)\n a = (c - 1.0) * f_avg / (f_max - f_avg)\n b = f_avg * (f_max - c*f_avg)/(f_max - f_avg)\n else\n a = f_avg / (f_avg - f_min)\n b = -f_min * f_avg / (f_avg - f_min)\n end\n @genes.each { |gene| gene.score = a * gene.score + b }\n end\n\n def roulette(prob)\n# puts \"sum : %d\" % sum\n @genes.each_with_index do |gene, index|\n prob -= gene.score\n return index if prob < 0\n end\n end\n\n # 2?????????\n def crossover(p1, p2) #, c1, c2)\n# p p1, p2\n parent1 = Marshal.load(Marshal.dump(@parents[p1]))\n parent2 = Marshal.load(Marshal.dump(@parents[p2]))\n\n start_id = rand(@size)\n cross_length = rand(@size - start_id)\n\n parent1.chromosome[start_id, cross_length], parent2.chromosome[start_id, cross_length] = parent2.chromosome[start_id, cross_length], parent1.chromosome[start_id, cross_length]\n @genes << parent1\n @genes << parent2\n#@genes[c1].chromosome = parent1\n#@genes[c2].chromosome = parent2\n# evaluate(@genes[-1])\n# evaluate(@genes[-2])\n end\n\n def mutation\n @genes.each_with_index do |gene, index|\n if rand < P_MUTATION\n i = rand(@size)\n gene.chromosome[i] = (gene.chromosome[i] - 1).abs\n end\n end\n end\n\n def sum\n# p @genes\n# p @genes.map{|item| item[:score]}\n @genes.map { |item| item[:score] }.inject(:+)\n end\n\n def avg\n sum / @genes.length\n #sum = @genes.select{|item| item[:score]>1}\n #sum.map{|item| item[:score]}.inject(:+)/sum.length\n # p sum.inject{|arr,item| arr + item[:score]}#/sum.length\n end\n\nend\n\n\nif __FILE__ == $0\n aoj\n# init\n# p Problem\n# p Problem[0][:Items][0].weight\n\n population = 100\n\n Problem.each do |problem|\n ga = GA.new(population, problem[:Items], problem[:Max_weight])\n ga.start do |generation, genes, max_score, average|\n# puts 'generation : ' + generation.to_s\n# puts 'elite : ' + genes[0].to_s\n# genes.each do |item|\n# p item\n# end\n# break if gets =~ /x/\n end\n\n end\n\n\nend", "problem_context": "0-1 Knapsack Problem\n\nYou have N items that you want to put them into a knapsack. Item i has value vi and weight wi.\n\nYou want to find a subset of items to put such that:\n\nThe total value of the items is as large as possible.\n\nThe items have combined weight at most W, that is capacity of the knapsack.\n\nFind the maximum total value of items in the knapsack.\n\nInput\n\nN W\nv1 w1\nv2 w2\n:\nvN wN\n\nThe first line consists of the integers N and W. In the following lines, the value and weight of the i-th item are given.\n\nOutput\n\nPrint the maximum total values of the items in a line.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ vi ≤ 1000\n\n1 ≤ wi ≤ 1000\n\n1 ≤ W ≤ 10000\n\nSample Input 1\n\n4 5\n4 2\n5 2\n2 1\n8 3\n\nSample Output 1\n\n13\n\nSample Input 2\n\n2 20\n5 9\n4 10\n\nSample Output 2\n\n9", "sample_input": "4 5\n4 2\n5 2\n2 1\n8 3\n"}, "reference_outputs": ["13\n"], "source_document_id": "p02315", "source_text": "0-1 Knapsack Problem\n\nYou have N items that you want to put them into a knapsack. Item i has value vi and weight wi.\n\nYou want to find a subset of items to put such that:\n\nThe total value of the items is as large as possible.\n\nThe items have combined weight at most W, that is capacity of the knapsack.\n\nFind the maximum total value of items in the knapsack.\n\nInput\n\nN W\nv1 w1\nv2 w2\n:\nvN wN\n\nThe first line consists of the integers N and W. In the following lines, the value and weight of the i-th item are given.\n\nOutput\n\nPrint the maximum total values of the items in a line.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ vi ≤ 1000\n\n1 ≤ wi ≤ 1000\n\n1 ≤ W ≤ 10000\n\nSample Input 1\n\n4 5\n4 2\n5 2\n2 1\n8 3\n\nSample Output 1\n\n13\n\nSample Input 2\n\n2 20\n5 9\n4 10\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": 6760, "cpu_time_ms": 800, "memory_kb": 10584}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s073929063", "group_id": "codeNet:p02347", "input_text": "class Point\n attr_reader :id, :x, :y\n def initialize(id, x, y)\n @id = id\n @x = x\n @y = y\n end\nend\n\nclass Node\n attr_reader :point, :left, :right\n def initialize(point, left, right)\n @point = point\n @left = left\n @right = right\n end\nend\n\nclass XYRange\n attr_reader :sx, :tx, :sy, :ty\n def initialize(sx, tx, sy, ty)\n @sx, @tx, @sy, @ty = sx, tx, sy, ty\n end\n\n def member?(point)\n sx <= point.x && point.x <= tx &&\n sy <= point.y && point.y <= ty\n end\nend\n\nclass TDTree\n def initialize\n @points = []\n @nodes = []\n end\n\n def add_point(point)\n @points << point\n end\n\n def build(left = 0, right = @points.length, depth = 0)\n return if left >= right\n middle = (left + right) / 2\n\n method = depth.even? ? :x : :y\n @points[left...right] = @points[left...right].sort_by(&method)\n\n Node.new(\n @points[middle],\n build(left, middle, depth + 1),\n build(middle + 1, right, depth + 1)\n ).tap { |n| @nodes << n }\n end\n\n def search(range, node = root, depth = 0, results = [])\n point = node.point\n if range.member?(point)\n results << point\n end\n\n if depth.even?\n if node.left && range.sx <= point.x\n search(range, node.left, depth + 1, results)\n end\n if node.right && point.x <= range.tx\n search(range, node.right, depth + 1, results)\n end\n else\n if node.left && range.sy <= point.y\n search(range, node.left, depth + 1, results)\n end\n if node.right && point.y <= range.ty\n search(range, node.right, depth + 1, results)\n end\n end\n\n results.tap { |r| r.sort_by!(&:id) if depth == 0 }\n end\n\n def root\n @nodes.last\n end\nend\n\ntree = TDTree.new\n\nn = gets.to_i\nn.times do |i|\n tree.add_point(Point.new(i, *gets.split.map(&:to_i)))\nend\ntree.build\n\nq = gets.to_i\nq.times do\n range = XYRange.new(*gets.split.map(&:to_i))\n tree.search(range).each { |point| puts point.id }\n puts\nend\n\n", "language": "Ruby", "metadata": {"date": 1517750660, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02347.html", "problem_id": "p02347", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02347/input.txt", "sample_output_relpath": "derived/input_output/data/p02347/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02347/Ruby/s073929063.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s073929063", "user_id": "u531736422"}, "prompt_components": {"gold_output": "0\n1\n2\n4\n\n2\n3\n5\n", "input_to_evaluate": "class Point\n attr_reader :id, :x, :y\n def initialize(id, x, y)\n @id = id\n @x = x\n @y = y\n end\nend\n\nclass Node\n attr_reader :point, :left, :right\n def initialize(point, left, right)\n @point = point\n @left = left\n @right = right\n end\nend\n\nclass XYRange\n attr_reader :sx, :tx, :sy, :ty\n def initialize(sx, tx, sy, ty)\n @sx, @tx, @sy, @ty = sx, tx, sy, ty\n end\n\n def member?(point)\n sx <= point.x && point.x <= tx &&\n sy <= point.y && point.y <= ty\n end\nend\n\nclass TDTree\n def initialize\n @points = []\n @nodes = []\n end\n\n def add_point(point)\n @points << point\n end\n\n def build(left = 0, right = @points.length, depth = 0)\n return if left >= right\n middle = (left + right) / 2\n\n method = depth.even? ? :x : :y\n @points[left...right] = @points[left...right].sort_by(&method)\n\n Node.new(\n @points[middle],\n build(left, middle, depth + 1),\n build(middle + 1, right, depth + 1)\n ).tap { |n| @nodes << n }\n end\n\n def search(range, node = root, depth = 0, results = [])\n point = node.point\n if range.member?(point)\n results << point\n end\n\n if depth.even?\n if node.left && range.sx <= point.x\n search(range, node.left, depth + 1, results)\n end\n if node.right && point.x <= range.tx\n search(range, node.right, depth + 1, results)\n end\n else\n if node.left && range.sy <= point.y\n search(range, node.left, depth + 1, results)\n end\n if node.right && point.y <= range.ty\n search(range, node.right, depth + 1, results)\n end\n end\n\n results.tap { |r| r.sort_by!(&:id) if depth == 0 }\n end\n\n def root\n @nodes.last\n end\nend\n\ntree = TDTree.new\n\nn = gets.to_i\nn.times do |i|\n tree.add_point(Point.new(i, *gets.split.map(&:to_i)))\nend\ntree.build\n\nq = gets.to_i\nq.times do\n range = XYRange.new(*gets.split.map(&:to_i))\n tree.search(range).each { |point| puts point.id }\n puts\nend\n\n", "problem_context": "Range Search (kD Tree)\n\nThe range search problem consists of a set of attributed records S to determine which records from S intersect with a given range.\n\nFor n points on a plane, report a set of points which are within in a given range. Note that you do not need to consider insert and delete operations for the set.\n\nInput\n\nn\nx0 y0\nx1 y1\n:\nxn-1 yn-1\nq\nsx0 tx0 sy0 ty0\nsx1 tx1 sy1 ty1\n:\nsxq-1 txq-1 syq-1 tyq-1\n\nThe first integer n is the number of points. In the following n lines, the coordinate of the i-th point is given by two integers xi and yi.\n\nThe next integer q is the number of queries. In the following q lines, each query is given by four integers,\nsxi,\ntxi,\nsyi,\ntyi.\n\nOutput\n\nFor each query, report IDs of points such that\nsxi ≤ x ≤ txi and\nsyi ≤ y ≤ tyi.\nThe IDs should be reported in ascending order. Print an ID in a line, and print a blank line at the end of output for the each query.\n\nConstraints\n\n0 ≤ n ≤ 500,000\n\n0 ≤ q ≤ 20,000\n\n-1,000,000,000 ≤ x, y, sx, tx, sy, ty ≤ 1,000,000,000\n\nsx ≤ tx\n\nsy ≤ ty\n\nFor each query, the number of points which are within the range is less than or equal to 100.\n\nSample Input 1\n\n6\n2 1\n2 2\n4 2\n6 2\n3 3\n5 4\n2\n2 4 0 4\n4 10 2 5\n\nSample Output 1\n\n0\n1\n2\n4\n\n2\n3\n5", "sample_input": "6\n2 1\n2 2\n4 2\n6 2\n3 3\n5 4\n2\n2 4 0 4\n4 10 2 5\n"}, "reference_outputs": ["0\n1\n2\n4\n\n2\n3\n5\n"], "source_document_id": "p02347", "source_text": "Range Search (kD Tree)\n\nThe range search problem consists of a set of attributed records S to determine which records from S intersect with a given range.\n\nFor n points on a plane, report a set of points which are within in a given range. Note that you do not need to consider insert and delete operations for the set.\n\nInput\n\nn\nx0 y0\nx1 y1\n:\nxn-1 yn-1\nq\nsx0 tx0 sy0 ty0\nsx1 tx1 sy1 ty1\n:\nsxq-1 txq-1 syq-1 tyq-1\n\nThe first integer n is the number of points. In the following n lines, the coordinate of the i-th point is given by two integers xi and yi.\n\nThe next integer q is the number of queries. In the following q lines, each query is given by four integers,\nsxi,\ntxi,\nsyi,\ntyi.\n\nOutput\n\nFor each query, report IDs of points such that\nsxi ≤ x ≤ txi and\nsyi ≤ y ≤ tyi.\nThe IDs should be reported in ascending order. Print an ID in a line, and print a blank line at the end of output for the each query.\n\nConstraints\n\n0 ≤ n ≤ 500,000\n\n0 ≤ q ≤ 20,000\n\n-1,000,000,000 ≤ x, y, sx, tx, sy, ty ≤ 1,000,000,000\n\nsx ≤ tx\n\nsy ≤ ty\n\nFor each query, the number of points which are within the range is less than or equal to 100.\n\nSample Input 1\n\n6\n2 1\n2 2\n4 2\n6 2\n3 3\n5 4\n2\n2 4 0 4\n4 10 2 5\n\nSample Output 1\n\n0\n1\n2\n4\n\n2\n3\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": 1949, "cpu_time_ms": 5760, "memory_kb": 154172}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s023925924", "group_id": "codeNet:p02379", "input_text": "a, b, c, d = gets.split.map(&:to_f)\nputs '%.4f' % Math.sqrt((c - a)**2 + (d - b)**2)", "language": "Ruby", "metadata": {"date": 1507175129, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s023925924.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s023925924", "user_id": "u006169802"}, "prompt_components": {"gold_output": "1.41421356\n", "input_to_evaluate": "a, b, c, d = gets.split.map(&:to_f)\nputs '%.4f' % Math.sqrt((c - a)**2 + (d - b)**2)", "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": 84, "cpu_time_ms": 40, "memory_kb": 8764}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s141320980", "group_id": "codeNet:p02380", "input_text": "input = STDIN.gets.split(' ')\na = input[0].to_f\nb = input[1].to_f\nc = input[2].to_f * (Math::PI / 180.0)\n\ns = 0.5 * a * b * Math.sin(c)\nl = a + b + Math.sqrt(a*a + b*b - 2 * a * b * Math.cos(c))\nh = b * Math.sin(c)\n\nputs s\nputs l\nputs h", "language": "Ruby", "metadata": {"date": 1392563700, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02380.html", "problem_id": "p02380", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02380/input.txt", "sample_output_relpath": "derived/input_output/data/p02380/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02380/Ruby/s141320980.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s141320980", "user_id": "u924816735"}, "prompt_components": {"gold_output": "6.00000000\n12.00000000\n3.00000000\n", "input_to_evaluate": "input = STDIN.gets.split(' ')\na = input[0].to_f\nb = input[1].to_f\nc = input[2].to_f * (Math::PI / 180.0)\n\ns = 0.5 * a * b * Math.sin(c)\nl = a + b + Math.sqrt(a*a + b*b - 2 * a * b * Math.cos(c))\nh = b * Math.sin(c)\n\nputs s\nputs l\nputs h", "problem_context": "Triangle\n\nFor given two sides of a triangle a and b and the angle C between them, calculate the following properties:\n\nS: Area of the triangle\n\nL: The length of the circumference of the triangle\n\nh: The height of the triangle with side a as a bottom edge\n\nInput\n\nThe length of a, the length of b and the angle C are given in integers.\n\nOutput\n\nPrint S, L and h in a line respectively. The output should not contain an absolute error greater than 10-4.\n\nSample Input\n\n4 3 90\n\nSample Output\n\n6.00000000\n12.00000000\n3.00000000", "sample_input": "4 3 90\n"}, "reference_outputs": ["6.00000000\n12.00000000\n3.00000000\n"], "source_document_id": "p02380", "source_text": "Triangle\n\nFor given two sides of a triangle a and b and the angle C between them, calculate the following properties:\n\nS: Area of the triangle\n\nL: The length of the circumference of the triangle\n\nh: The height of the triangle with side a as a bottom edge\n\nInput\n\nThe length of a, the length of b and the angle C are given in integers.\n\nOutput\n\nPrint S, L and h in a line respectively. The output should not contain an absolute error greater than 10-4.\n\nSample Input\n\n4 3 90\n\nSample Output\n\n6.00000000\n12.00000000\n3.00000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 236, "cpu_time_ms": 20, "memory_kb": 6172}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s987969244", "group_id": "codeNet:p02381", "input_text": "# encoding: utf-8 \n\ndef main\n while n = gets.chomp.to_i and n != 0\n nums = gets.chomp.split(/\\s/).collect { |x| x.to_f}\n avg = nums.inject(0) { |s, e| s + e} / nums.size\n ans = 0.0\n nums.each do |num|\n ans += (num - avg) ** 2\n end\n puts (\"%.6f\" % Math.sqrt((ans / nums.size)))\n end\nend\n\nmain", "language": "Ruby", "metadata": {"date": 1379756989, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02381.html", "problem_id": "p02381", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02381/input.txt", "sample_output_relpath": "derived/input_output/data/p02381/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02381/Ruby/s987969244.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s987969244", "user_id": "u284474275"}, "prompt_components": {"gold_output": "27.85677655\n0.00000000\n", "input_to_evaluate": "# encoding: utf-8 \n\ndef main\n while n = gets.chomp.to_i and n != 0\n nums = gets.chomp.split(/\\s/).collect { |x| x.to_f}\n avg = nums.inject(0) { |s, e| s + e} / nums.size\n ans = 0.0\n nums.each do |num|\n ans += (num - avg) ** 2\n end\n puts (\"%.6f\" % Math.sqrt((ans / nums.size)))\n end\nend\n\nmain", "problem_context": "Standard Deviation\n\nYou have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn.\n\nThe variance α2 is defined by\n\nα2 = (∑ni=1(si - m)2)/n\n\nwhere m is an average of si.\n\nThe standard deviation of the scores is the square root of their variance.\n\nInput\n\nThe input consists of multiple datasets. Each dataset is given in the following format:\n\nn\ns1 s2 ... sn\n\nThe input ends with single zero for n.\n\nOutput\n\nFor each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4.\n\nConstraints\n\nn ≤ 1000\n\n0 ≤ si ≤ 100\n\nSample Input\n\n5\n70 80 100 90 20\n3\n80 80 80\n0\n\nSample Output\n\n27.85677655\n0.00000000", "sample_input": "5\n70 80 100 90 20\n3\n80 80 80\n0\n"}, "reference_outputs": ["27.85677655\n0.00000000\n"], "source_document_id": "p02381", "source_text": "Standard Deviation\n\nYou have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn.\n\nThe variance α2 is defined by\n\nα2 = (∑ni=1(si - m)2)/n\n\nwhere m is an average of si.\n\nThe standard deviation of the scores is the square root of their variance.\n\nInput\n\nThe input consists of multiple datasets. Each dataset is given in the following format:\n\nn\ns1 s2 ... sn\n\nThe input ends with single zero for n.\n\nOutput\n\nFor each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4.\n\nConstraints\n\nn ≤ 1000\n\n0 ≤ si ≤ 100\n\nSample Input\n\n5\n70 80 100 90 20\n3\n80 80 80\n0\n\nSample Output\n\n27.85677655\n0.00000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 386, "cpu_time_ms": 20, "memory_kb": 6184}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s926010176", "group_id": "codeNet:p02382", "input_text": "n = gets.to_i\nx = gets.split(\" \").map(&:to_f)\ny = gets.split(\" \").map(&:to_f)\n\nfor i in 0..n-1\n x[i] = (x[i] - y[i]).abs\nend\n\nputs x.reduce(:+)\nputs (x.map {|q| q*q}.reduce(:+))**0.5\nputs (x.map {|q| q*q*q}.reduce(:+))**(1.0/3)\nputs x.max\n\n", "language": "Ruby", "metadata": {"date": 1561026414, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02382.html", "problem_id": "p02382", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02382/input.txt", "sample_output_relpath": "derived/input_output/data/p02382/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02382/Ruby/s926010176.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s926010176", "user_id": "u842141906"}, "prompt_components": {"gold_output": "4.000000\n2.449490\n2.154435\n2.000000\n", "input_to_evaluate": "n = gets.to_i\nx = gets.split(\" \").map(&:to_f)\ny = gets.split(\" \").map(&:to_f)\n\nfor i in 0..n-1\n x[i] = (x[i] - y[i]).abs\nend\n\nputs x.reduce(:+)\nputs (x.map {|q| q*q}.reduce(:+))**0.5\nputs (x.map {|q| q*q*q}.reduce(:+))**(1.0/3)\nputs x.max\n\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDistance II\n\nYour task is to calculate the distance between two $n$ dimensional vectors $x = \\{x_1, x_2, ..., x_n\\}$ and $y = \\{y_1, y_2, ..., y_n\\}$.\n\nThe Minkowski's distance defined below is a metric which is a generalization of both the Manhattan distance and the Euclidean distance.\n\n\\[\nD_{xy} = (\\sum_{i=1}^n |x_i - y_i|^p)^{\\frac{1}{p}}\n\\]\n\nIt can be the Manhattan distance\n\n\\[\nD_{xy} = |x_1 - y_1| + |x_2 - y_2| + ... + |x_n - y_n|\n\\]\n\nwhere $p = 1 $.\n\nIt can be the Euclidean distance\n\n\\[\nD_{xy} = \\sqrt{(|x_1 - y_1|)^{2} + (|x_2 - y_2|)^{2} + ... + (|x_n - y_n|)^{2}}\n\\]\n\nwhere $p = 2 $.\n\nAlso, it can be the Chebyshev distance\n\n\\[\nD_{xy} = max_{i=1}^n (|x_i - y_i|)\n\\]\n\nwhere $p = \\infty$\n\nWrite a program which reads two $n$ dimensional vectors $x$ and $y$, and calculates Minkowski's distance where $p = 1, 2, 3, \\infty$ respectively.\n\nInput\n\nIn the first line, an integer $n$ is given. In the second and third line, $x = \\{x_1, x_2, ... x_n\\}$ and $y = \\{y_1, y_2, ... y_n\\}$ are given respectively. The elements in $x$ and $y$ are given in integers.\n\nOutput\n\nPrint the distance where $p = 1, 2, 3$ and $\\infty$ in a line respectively.\nThe output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n$1 \\leq n \\leq 100$\n\n$0 \\leq x_i, y_i \\leq 1000$\n\nSample Input\n\n3\n1 2 3\n2 0 4\n\nSample Output\n\n4.000000\n2.449490\n2.154435\n2.000000", "sample_input": "3\n1 2 3\n2 0 4\n"}, "reference_outputs": ["4.000000\n2.449490\n2.154435\n2.000000\n"], "source_document_id": "p02382", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDistance II\n\nYour task is to calculate the distance between two $n$ dimensional vectors $x = \\{x_1, x_2, ..., x_n\\}$ and $y = \\{y_1, y_2, ..., y_n\\}$.\n\nThe Minkowski's distance defined below is a metric which is a generalization of both the Manhattan distance and the Euclidean distance.\n\n\\[\nD_{xy} = (\\sum_{i=1}^n |x_i - y_i|^p)^{\\frac{1}{p}}\n\\]\n\nIt can be the Manhattan distance\n\n\\[\nD_{xy} = |x_1 - y_1| + |x_2 - y_2| + ... + |x_n - y_n|\n\\]\n\nwhere $p = 1 $.\n\nIt can be the Euclidean distance\n\n\\[\nD_{xy} = \\sqrt{(|x_1 - y_1|)^{2} + (|x_2 - y_2|)^{2} + ... + (|x_n - y_n|)^{2}}\n\\]\n\nwhere $p = 2 $.\n\nAlso, it can be the Chebyshev distance\n\n\\[\nD_{xy} = max_{i=1}^n (|x_i - y_i|)\n\\]\n\nwhere $p = \\infty$\n\nWrite a program which reads two $n$ dimensional vectors $x$ and $y$, and calculates Minkowski's distance where $p = 1, 2, 3, \\infty$ respectively.\n\nInput\n\nIn the first line, an integer $n$ is given. In the second and third line, $x = \\{x_1, x_2, ... x_n\\}$ and $y = \\{y_1, y_2, ... y_n\\}$ are given respectively. The elements in $x$ and $y$ are given in integers.\n\nOutput\n\nPrint the distance where $p = 1, 2, 3$ and $\\infty$ in a line respectively.\nThe output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n$1 \\leq n \\leq 100$\n\n$0 \\leq x_i, y_i \\leq 1000$\n\nSample Input\n\n3\n1 2 3\n2 0 4\n\nSample Output\n\n4.000000\n2.449490\n2.154435\n2.000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 241, "cpu_time_ms": 40, "memory_kb": 8944}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s799923273", "group_id": "codeNet:p02385", "input_text": "dice0 = STDIN.gets.chomp().split(\" \")\ndice1 = STDIN.gets.chomp().split(\" \")\n\ndef move(direction, dice)\n case direction\n when \"S\" then\n temp = dice[0]\n dice[0] = dice[4]\n dice[4] = dice[5]\n dice[5] = dice[1]\n dice[1] = temp\n when \"N\" then\n temp = dice[0]\n dice[0] = dice[1]\n dice[1] = dice[5]\n dice[5] = dice[4]\n dice[4] = temp\n when \"E\" then\n temp = dice[0]\n dice[0] = dice[3]\n dice[3] = dice[5]\n dice[5] = dice[2]\n dice[2] = temp\n when \"W\" then\n temp = dice[0]\n dice[0] = dice[2]\n dice[2] = dice[5]\n dice[5] = dice[3]\n dice[3] = temp\n end\n return dice\nend\n\ndef getDrection(ran)\n case ran\n when 0\n return \"S\"\n when 1\n return \"N\"\n when 2\n return \"E\"\n when 3\n return \"W\"\n end\nend\n\nwhile true\n direction = getDrection(rand(4))\n dice0 = move(direction, dice0)\n # p \"dice0 = #{dice0}\"\n # p \"dice1 = #{dice1}\"\n # p \"dice0.length = #{dice0.length}\"\n count = 0\n for i in 0..dice0.length - 1 do\n # p \"dice0[i] = #{dice0[i]}\"\n # p \"dice1[i] = #{dice1[i]}\"\n if dice0[i] == dice1[i] then count +=1 end\n # p \"count = #{count}\"\n end\n if count == 4 then \n puts \"No\"\n break\n elsif count == 6 then\n puts \"Yes\"\n break\n end\nend", "language": "Ruby", "metadata": {"date": 1431049224, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02385.html", "problem_id": "p02385", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02385/input.txt", "sample_output_relpath": "derived/input_output/data/p02385/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02385/Ruby/s799923273.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s799923273", "user_id": "u938745275"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "dice0 = STDIN.gets.chomp().split(\" \")\ndice1 = STDIN.gets.chomp().split(\" \")\n\ndef move(direction, dice)\n case direction\n when \"S\" then\n temp = dice[0]\n dice[0] = dice[4]\n dice[4] = dice[5]\n dice[5] = dice[1]\n dice[1] = temp\n when \"N\" then\n temp = dice[0]\n dice[0] = dice[1]\n dice[1] = dice[5]\n dice[5] = dice[4]\n dice[4] = temp\n when \"E\" then\n temp = dice[0]\n dice[0] = dice[3]\n dice[3] = dice[5]\n dice[5] = dice[2]\n dice[2] = temp\n when \"W\" then\n temp = dice[0]\n dice[0] = dice[2]\n dice[2] = dice[5]\n dice[5] = dice[3]\n dice[3] = temp\n end\n return dice\nend\n\ndef getDrection(ran)\n case ran\n when 0\n return \"S\"\n when 1\n return \"N\"\n when 2\n return \"E\"\n when 3\n return \"W\"\n end\nend\n\nwhile true\n direction = getDrection(rand(4))\n dice0 = move(direction, dice0)\n # p \"dice0 = #{dice0}\"\n # p \"dice1 = #{dice1}\"\n # p \"dice0.length = #{dice0.length}\"\n count = 0\n for i in 0..dice0.length - 1 do\n # p \"dice0[i] = #{dice0[i]}\"\n # p \"dice1[i] = #{dice1[i]}\"\n if dice0[i] == dice1[i] then count +=1 end\n # p \"count = #{count}\"\n end\n if count == 4 then \n puts \"No\"\n break\n elsif count == 6 then\n puts \"Yes\"\n break\n end\nend", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice III\n\nWrite a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical.\n\nInput\n\nIn the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels.\n\nIn the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels.\n\nOutput\n\nPrint \"Yes\" if two dices are identical, otherwise \"No\" in a line.\n\nConstraints\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\nSample Input 1\n\n1 2 3 4 5 6\n6 2 4 3 5 1\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n1 2 3 4 5 6\n6 5 4 3 2 1\n\nSample Output 2\n\nNo", "sample_input": "1 2 3 4 5 6\n6 2 4 3 5 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02385", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice III\n\nWrite a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical.\n\nInput\n\nIn the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels.\n\nIn the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels.\n\nOutput\n\nPrint \"Yes\" if two dices are identical, otherwise \"No\" in a line.\n\nConstraints\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\nSample Input 1\n\n1 2 3 4 5 6\n6 2 4 3 5 1\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n1 2 3 4 5 6\n6 5 4 3 2 1\n\nSample Output 2\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1228, "cpu_time_ms": 19930, "memory_kb": 6120}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s177195044", "group_id": "codeNet:p02385", "input_text": "class Dice\n\n def initialize(surfaces)\n @surfaces = surfaces.dup \n end\n\n def top\n @surfaces[0]\n end\n\n def front\n @surfaces[1]\n end\n\n def right\n @surfaces[2]\n end\n\n def N\n tmp = @surfaces[0]\n @surfaces[0] = @surfaces[1]\n @surfaces[1] = @surfaces[5]\n @surfaces[5] = @surfaces[4]\n @surfaces[4] = tmp\n self\n end\n\n def E\n tmp = @surfaces[0]\n @surfaces[0] = @surfaces[3]\n @surfaces[3] = @surfaces[5]\n @surfaces[5] = @surfaces[2]\n @surfaces[2] = tmp\n self\n end\n\n def S\n tmp = @surfaces[0]\n @surfaces[0] = @surfaces[4]\n @surfaces[4] = @surfaces[5]\n @surfaces[5] = @surfaces[1]\n @surfaces[1] = tmp\n self\n end\n\n def W\n tmp = @surfaces[0]\n @surfaces[0] = @surfaces[2]\n @surfaces[2] = @surfaces[5]\n @surfaces[5] = @surfaces[3]\n @surfaces[3] = tmp\n self\n end\n\n def adjust_front(front)\n 4.times do\n self.N\n return if self.front == front\n end\n\n self.E\n adjust_front(front)\n end\n\n def equal_surfaces(other)\n (0..5).all?{|n| surface_val(n) == other.surface_val(n) }\n end\n\n def surface_val(num)\n @surfaces[num]\n end\n\n def has_value?(v)\n @surfaces.include?(v)\n end\nend\n\ndice1 = Dice.new(gets.chomp.split.map(&:to_i))\ndice2 = Dice.new(gets.chomp.split.map(&:to_i))\n\nunless dice2.has_value?(dice1.front)\n puts 'No'\n exit\nend\n\ndice2.adjust_front(dice1.front)\n4.times do\n dice2.E\n\n if dice1.equal_surfaces(dice2)\n puts 'Yes'\n exit\n end\nend\n\nputs 'No'", "language": "Ruby", "metadata": {"date": 1505452499, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02385.html", "problem_id": "p02385", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02385/input.txt", "sample_output_relpath": "derived/input_output/data/p02385/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02385/Ruby/s177195044.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s177195044", "user_id": "u670581076"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "class Dice\n\n def initialize(surfaces)\n @surfaces = surfaces.dup \n end\n\n def top\n @surfaces[0]\n end\n\n def front\n @surfaces[1]\n end\n\n def right\n @surfaces[2]\n end\n\n def N\n tmp = @surfaces[0]\n @surfaces[0] = @surfaces[1]\n @surfaces[1] = @surfaces[5]\n @surfaces[5] = @surfaces[4]\n @surfaces[4] = tmp\n self\n end\n\n def E\n tmp = @surfaces[0]\n @surfaces[0] = @surfaces[3]\n @surfaces[3] = @surfaces[5]\n @surfaces[5] = @surfaces[2]\n @surfaces[2] = tmp\n self\n end\n\n def S\n tmp = @surfaces[0]\n @surfaces[0] = @surfaces[4]\n @surfaces[4] = @surfaces[5]\n @surfaces[5] = @surfaces[1]\n @surfaces[1] = tmp\n self\n end\n\n def W\n tmp = @surfaces[0]\n @surfaces[0] = @surfaces[2]\n @surfaces[2] = @surfaces[5]\n @surfaces[5] = @surfaces[3]\n @surfaces[3] = tmp\n self\n end\n\n def adjust_front(front)\n 4.times do\n self.N\n return if self.front == front\n end\n\n self.E\n adjust_front(front)\n end\n\n def equal_surfaces(other)\n (0..5).all?{|n| surface_val(n) == other.surface_val(n) }\n end\n\n def surface_val(num)\n @surfaces[num]\n end\n\n def has_value?(v)\n @surfaces.include?(v)\n end\nend\n\ndice1 = Dice.new(gets.chomp.split.map(&:to_i))\ndice2 = Dice.new(gets.chomp.split.map(&:to_i))\n\nunless dice2.has_value?(dice1.front)\n puts 'No'\n exit\nend\n\ndice2.adjust_front(dice1.front)\n4.times do\n dice2.E\n\n if dice1.equal_surfaces(dice2)\n puts 'Yes'\n exit\n end\nend\n\nputs 'No'", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice III\n\nWrite a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical.\n\nInput\n\nIn the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels.\n\nIn the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels.\n\nOutput\n\nPrint \"Yes\" if two dices are identical, otherwise \"No\" in a line.\n\nConstraints\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\nSample Input 1\n\n1 2 3 4 5 6\n6 2 4 3 5 1\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n1 2 3 4 5 6\n6 5 4 3 2 1\n\nSample Output 2\n\nNo", "sample_input": "1 2 3 4 5 6\n6 2 4 3 5 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02385", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice III\n\nWrite a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical.\n\nInput\n\nIn the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels.\n\nIn the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels.\n\nOutput\n\nPrint \"Yes\" if two dices are identical, otherwise \"No\" in a line.\n\nConstraints\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\nSample Input 1\n\n1 2 3 4 5 6\n6 2 4 3 5 1\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n1 2 3 4 5 6\n6 5 4 3 2 1\n\nSample Output 2\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1476, "cpu_time_ms": 40, "memory_kb": 8752}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s761549785", "group_id": "codeNet:p02386", "input_text": "def get_i() #空白区切の入力を数値(整数)の配列で返す\n return gets.chomp.split(\" \").map(&:to_i)\nend\ndef get_f() #空白区切の入力を数値(実数)の配列で返す\n return gets.chomp.split(\" \").map(&:to_f)\nend\ndef get() #空白区切の入力を文字列の配列で返す\n return gets.chomp.split(\" \")\nend\ndef get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す\n return gets.chomp.split(\"\")\nend\ndef yn_judge(bool,y=\"Yes\",n=\"No\") #boolに真偽を投げることで、trueならy、falseならnの値を出力する\n return bool ? y : n \nend\ndef array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す\n if n==1\n return Array.new(size){init}\n else\n return Array.new(n).map{Array.new(size){init}}\n end\nend\n\nclass Dice\n attr_accessor:node,:top,:s,:e,:num\n def initialize(arr)\n @node=Array.new(6){|i| i+1}\n @num=arr\n @top=1\n @s=2\n @e=3\n end\n\n def reverse_num(x)\n return 7-x\n end\n\n def S()\n top=@top\n s=@s\n e=@e\n @top=reverse_num(s)\n @s=top\n end\n\n def E()\n top=@top\n s=@s\n e=@e\n @top=reverse_num(e)\n @e=top\n end\n\n def W()\n top=@top\n s=@s\n e=@e\n @top=e\n @e=reverse_num(top)\n end\n\n def N()\n top=@top\n s=@s\n e=@e\n @top=s\n @s=reverse_num(top)\n end\nend\n\nn=gets.to_i\ndices=Array.new(n)\nn.times do|i|\n a=get_i\n dices[i]=Dice.new(a)\nend\nflag=false\n(n-1).times do|i|\n dice1=dices[i]\n (i+1).upto(n-1) do|j|\n dice2=dices[j] \n x=dice1.num.sort\n y=dice2.num.sort\n f=false\n 6.times do|k|\n f=true if x[i]!=y[i]\n end\n if f\n next\n end\n 4.times do\n 4.times do\n break if dice1.num[dice1.s-1]==dice2.num[dice2.s-1]\n dice2.S \n end\n 4.times do\n break if dice1.num[dice1.top-1]==dice2.num[dice2.top-1]\n dice2.W\n end\n\n break if dice1.num[dice1.s-1]==dice2.num[dice2.s-1] and dice1.num[dice1.top-1]==dice2.num[dice2.top-1]\n dice2.S\n dice2.W\n end\n\n if ((dice1.num[dice1.s-1]==dice2.num[dice2.s-1]) and (dice1.num[dice1.top-1]==dice2.num[dice2.top-1]) and (dice1.num[dice1.e-1]==dice2.num[dice2.e-1]) and (dice1.num[dice1.reverse_num(dice1.s)-1]==dice2.num[dice2.reverse_num(dice2.s)-1]) and (dice1.num[dice1.reverse_num(dice1.top)-1]==dice2.num[dice2.reverse_num(dice2.top)-1]) and (dice1.num[dice1.reverse_num(dice1.e)-1]==dice2.num[dice2.reverse_num(dice2.e)-1]))\n flag=true\n break\n end\n end\n if flag\n break\n end\nend\nif flag\n puts \"No\"\nelse\n puts \"Yes\"\nend\n", "language": "Ruby", "metadata": {"date": 1584005692, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02386.html", "problem_id": "p02386", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02386/input.txt", "sample_output_relpath": "derived/input_output/data/p02386/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02386/Ruby/s761549785.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s761549785", "user_id": "u733320087"}, "prompt_components": {"gold_output": "No\n", "input_to_evaluate": "def get_i() #空白区切の入力を数値(整数)の配列で返す\n return gets.chomp.split(\" \").map(&:to_i)\nend\ndef get_f() #空白区切の入力を数値(実数)の配列で返す\n return gets.chomp.split(\" \").map(&:to_f)\nend\ndef get() #空白区切の入力を文字列の配列で返す\n return gets.chomp.split(\" \")\nend\ndef get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す\n return gets.chomp.split(\"\")\nend\ndef yn_judge(bool,y=\"Yes\",n=\"No\") #boolに真偽を投げることで、trueならy、falseならnの値を出力する\n return bool ? y : n \nend\ndef array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す\n if n==1\n return Array.new(size){init}\n else\n return Array.new(n).map{Array.new(size){init}}\n end\nend\n\nclass Dice\n attr_accessor:node,:top,:s,:e,:num\n def initialize(arr)\n @node=Array.new(6){|i| i+1}\n @num=arr\n @top=1\n @s=2\n @e=3\n end\n\n def reverse_num(x)\n return 7-x\n end\n\n def S()\n top=@top\n s=@s\n e=@e\n @top=reverse_num(s)\n @s=top\n end\n\n def E()\n top=@top\n s=@s\n e=@e\n @top=reverse_num(e)\n @e=top\n end\n\n def W()\n top=@top\n s=@s\n e=@e\n @top=e\n @e=reverse_num(top)\n end\n\n def N()\n top=@top\n s=@s\n e=@e\n @top=s\n @s=reverse_num(top)\n end\nend\n\nn=gets.to_i\ndices=Array.new(n)\nn.times do|i|\n a=get_i\n dices[i]=Dice.new(a)\nend\nflag=false\n(n-1).times do|i|\n dice1=dices[i]\n (i+1).upto(n-1) do|j|\n dice2=dices[j] \n x=dice1.num.sort\n y=dice2.num.sort\n f=false\n 6.times do|k|\n f=true if x[i]!=y[i]\n end\n if f\n next\n end\n 4.times do\n 4.times do\n break if dice1.num[dice1.s-1]==dice2.num[dice2.s-1]\n dice2.S \n end\n 4.times do\n break if dice1.num[dice1.top-1]==dice2.num[dice2.top-1]\n dice2.W\n end\n\n break if dice1.num[dice1.s-1]==dice2.num[dice2.s-1] and dice1.num[dice1.top-1]==dice2.num[dice2.top-1]\n dice2.S\n dice2.W\n end\n\n if ((dice1.num[dice1.s-1]==dice2.num[dice2.s-1]) and (dice1.num[dice1.top-1]==dice2.num[dice2.top-1]) and (dice1.num[dice1.e-1]==dice2.num[dice2.e-1]) and (dice1.num[dice1.reverse_num(dice1.s)-1]==dice2.num[dice2.reverse_num(dice2.s)-1]) and (dice1.num[dice1.reverse_num(dice1.top)-1]==dice2.num[dice2.reverse_num(dice2.top)-1]) and (dice1.num[dice1.reverse_num(dice1.e)-1]==dice2.num[dice2.reverse_num(dice2.e)-1]))\n flag=true\n break\n end\n end\n if flag\n break\n end\nend\nif flag\n puts \"No\"\nelse\n puts \"Yes\"\nend\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice IV\n\nWrite a program which reads $n$ dices constructed in the same way as Dice I, and determines whether they are all different. For the determination, use the same way as Dice III.\n\nInput\n\nIn the first line, the number of dices $n$ is given. In the following $n$ lines, six integers assigned to the dice faces are given respectively in the same way as Dice III.\n\nOutput\n\nPrint \"Yes\" if given dices are all different, otherwise \"No\" in a line.\n\nConstraints\n\n$2 \\leq n \\leq 100$\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\nSample Input 1\n\n3\n1 2 3 4 5 6\n6 2 4 3 5 1\n6 5 4 3 2 1\n\nSample Output 1\n\nNo\n\nSample Input 2\n\n3\n1 2 3 4 5 6\n6 5 4 3 2 1\n5 4 3 2 1 6\n\nSample Output 2\n\nYes", "sample_input": "3\n1 2 3 4 5 6\n6 2 4 3 5 1\n6 5 4 3 2 1\n"}, "reference_outputs": ["No\n"], "source_document_id": "p02386", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice IV\n\nWrite a program which reads $n$ dices constructed in the same way as Dice I, and determines whether they are all different. For the determination, use the same way as Dice III.\n\nInput\n\nIn the first line, the number of dices $n$ is given. In the following $n$ lines, six integers assigned to the dice faces are given respectively in the same way as Dice III.\n\nOutput\n\nPrint \"Yes\" if given dices are all different, otherwise \"No\" in a line.\n\nConstraints\n\n$2 \\leq n \\leq 100$\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\nSample Input 1\n\n3\n1 2 3 4 5 6\n6 2 4 3 5 1\n6 5 4 3 2 1\n\nSample Output 1\n\nNo\n\nSample Input 2\n\n3\n1 2 3 4 5 6\n6 5 4 3 2 1\n5 4 3 2 1 6\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": 2609, "cpu_time_ms": 50, "memory_kb": 6992}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s909881509", "group_id": "codeNet:p02388", "input_text": "x = gets.strip.to_i\n\nputs (x ** 3)", "language": "Ruby", "metadata": {"date": 1420491282, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02388.html", "problem_id": "p02388", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02388/input.txt", "sample_output_relpath": "derived/input_output/data/p02388/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02388/Ruby/s909881509.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s909881509", "user_id": "u215060102"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "x = gets.strip.to_i\n\nputs (x ** 3)", "problem_context": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02388", "source_text": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 34, "cpu_time_ms": 20, "memory_kb": 6092}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s749624717", "group_id": "codeNet:p02388", "input_text": "x = gets.chomp.to_i\nputs x ** 3", "language": "Ruby", "metadata": {"date": 1460897749, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02388.html", "problem_id": "p02388", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02388/input.txt", "sample_output_relpath": "derived/input_output/data/p02388/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02388/Ruby/s749624717.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s749624717", "user_id": "u247371045"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "x = gets.chomp.to_i\nputs x ** 3", "problem_context": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02388", "source_text": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 31, "cpu_time_ms": 60, "memory_kb": 8604}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s964447235", "group_id": "codeNet:p02388", "input_text": "def deltaPush(x)\n\treturn x*x*x\nend\n\nx = gets.to_i\nputs deltaPush(x)", "language": "Ruby", "metadata": {"date": 1482054697, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02388.html", "problem_id": "p02388", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02388/input.txt", "sample_output_relpath": "derived/input_output/data/p02388/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02388/Ruby/s964447235.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s964447235", "user_id": "u791170614"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "def deltaPush(x)\n\treturn x*x*x\nend\n\nx = gets.to_i\nputs deltaPush(x)", "problem_context": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02388", "source_text": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 67, "cpu_time_ms": 40, "memory_kb": 8628}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s312984739", "group_id": "codeNet:p02390", "input_text": "time = ARGV[0].to_i\n\nh = time / 3600\nm = (time / 60) % 60\ns = time % 3600\n\nputs \"#{h}:#{m}:#{s}\"", "language": "Ruby", "metadata": {"date": 1415526899, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s312984739.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s312984739", "user_id": "u024069892"}, "prompt_components": {"gold_output": "13:2:59\n", "input_to_evaluate": "time = ARGV[0].to_i\n\nh = time / 3600\nm = (time / 60) % 60\ns = time % 3600\n\nputs \"#{h}:#{m}:#{s}\"", "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": 96, "cpu_time_ms": 20, "memory_kb": 6068}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s136019095", "group_id": "codeNet:p02390", "input_text": "s = gets.chomp.to_i\nh = s.div(3600)\nm = (s - h*3600).div(60)\nse = s - (h*3600 + m*60)\nputs #{h}:#{m}:#{se}", "language": "Ruby", "metadata": {"date": 1460680290, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s136019095.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s136019095", "user_id": "u734427071"}, "prompt_components": {"gold_output": "13:2:59\n", "input_to_evaluate": "s = gets.chomp.to_i\nh = s.div(3600)\nm = (s - h*3600).div(60)\nse = s - (h*3600 + m*60)\nputs #{h}:#{m}:#{se}", "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": 106, "cpu_time_ms": 70, "memory_kb": 8624}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s808126573", "group_id": "codeNet:p02390", "input_text": "time = gets.chomp.to_i\n\nh = time / 3600\nm = (time % 3600) / 60\ns = (time% 3600) % 60\n\nputs h.to_s + \":\" + m.to_s + \":\" + s.to_s", "language": "Ruby", "metadata": {"date": 1494228949, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s808126573.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s808126573", "user_id": "u407138207"}, "prompt_components": {"gold_output": "13:2:59\n", "input_to_evaluate": "time = gets.chomp.to_i\n\nh = time / 3600\nm = (time % 3600) / 60\ns = (time% 3600) % 60\n\nputs h.to_s + \":\" + m.to_s + \":\" + s.to_s", "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": 127, "cpu_time_ms": 40, "memory_kb": 8608}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s196374886", "group_id": "codeNet:p02390", "input_text": "s = gets.to_i\n\nputs \"#{s/3600}:#{s%3600/60}:#{s%60}\"\n", "language": "Ruby", "metadata": {"date": 1584993334, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s196374886.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s196374886", "user_id": "u795977375"}, "prompt_components": {"gold_output": "13:2:59\n", "input_to_evaluate": "s = gets.to_i\n\nputs \"#{s/3600}:#{s%3600/60}:#{s%60}\"\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nWatch\n\nWrite a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.\n\nInput\n\nAn integer $S$ is given in a line.\n\nOutput\n\nPrint $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.\n\nConstraints\n\n$0 \\leq S \\leq 86400$\n\nSample Input 1\n\n46979\n\nSample Output 1\n\n13:2:59", "sample_input": "46979\n"}, "reference_outputs": ["13:2:59\n"], "source_document_id": "p02390", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nWatch\n\nWrite a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.\n\nInput\n\nAn integer $S$ is given in a line.\n\nOutput\n\nPrint $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.\n\nConstraints\n\n$0 \\leq S \\leq 86400$\n\nSample Input 1\n\n46979\n\nSample Output 1\n\n13:2:59", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 53, "cpu_time_ms": 40, "memory_kb": 6856}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s319452067", "group_id": "codeNet:p02391", "input_text": "a = STDIN.gets.split\n\nputs \"a < b\" if a[0].to_i < a[1].to_i\nputs \"a == b\" if a[0].to_i == a[1].to_i\nputs \"a > b\" if a[0].to_i > a[1].to_i", "language": "Ruby", "metadata": {"date": 1422116174, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s319452067.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s319452067", "user_id": "u494858865"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "a = STDIN.gets.split\n\nputs \"a < b\" if a[0].to_i < a[1].to_i\nputs \"a == b\" if a[0].to_i == a[1].to_i\nputs \"a > b\" if a[0].to_i > a[1].to_i", "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": 141, "cpu_time_ms": 20, "memory_kb": 6092}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s976521952", "group_id": "codeNet:p02391", "input_text": "ab = gets()\nar = ab.split(\" \")\na = ar[0].to_i()\nb = ar[1].to_i()\nif a < b\n print \"a < b\"+\"\\n\"\nelse\n if a > b\n print \"a > b\"+\"\\n\"\n else\n print \"a == b\"+\"\\n\"\n end\nend", "language": "Ruby", "metadata": {"date": 1452742171, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s976521952.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s976521952", "user_id": "u425445183"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "ab = gets()\nar = ab.split(\" \")\na = ar[0].to_i()\nb = ar[1].to_i()\nif a < b\n print \"a < b\"+\"\\n\"\nelse\n if a > b\n print \"a > b\"+\"\\n\"\n else\n print \"a == b\"+\"\\n\"\n end\nend", "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": 174, "cpu_time_ms": 60, "memory_kb": 8552}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s297484254", "group_id": "codeNet:p02391", "input_text": "# -*- coding:utf-8 -*-\n\na, b = STDIN.gets.split.map(&:to_i)\n\nif a > b then\n c = '>'\nelsif a < b then\n c = '<'\nelse\n c = '='\nend\n\nprintf(\"%d %c %d\\n\", a, c, b)", "language": "Ruby", "metadata": {"date": 1467876167, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s297484254.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s297484254", "user_id": "u225502267"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "# -*- coding:utf-8 -*-\n\na, b = STDIN.gets.split.map(&:to_i)\n\nif a > b then\n c = '>'\nelsif a < b then\n c = '<'\nelse\n c = '='\nend\n\nprintf(\"%d %c %d\\n\", a, c, b)", "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": 167, "cpu_time_ms": 40, "memory_kb": 8548}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s314886882", "group_id": "codeNet:p02392", "input_text": "while str = STDIN.gets\n n = str.split(\" \")\n a = n[0].to_i\n b = n[1].to_i\n c = n[2].to_i\n if a < b && b < c\n print \"はい\"\n else\n print \"いいえ\"\n end\nend\n", "language": "Ruby", "metadata": {"date": 1523693570, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s314886882.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s314886882", "user_id": "u236620240"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "while str = STDIN.gets\n n = str.split(\" \")\n a = n[0].to_i\n b = n[1].to_i\n c = n[2].to_i\n if a < b && b < c\n print \"はい\"\n else\n print \"いいえ\"\n end\nend\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": 170, "cpu_time_ms": 40, "memory_kb": 6836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s561036048", "group_id": "codeNet:p02392", "input_text": "def max(a, b, c)\n if a < b && b < c\n puts \"Yes\"\n else\n puts \"No\"\n end\nend\n\np max(1, 3, 8)\np max(3, 8, 1)\n", "language": "Ruby", "metadata": {"date": 1530274603, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s561036048.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s561036048", "user_id": "u142551424"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "def max(a, b, c)\n if a < b && b < c\n puts \"Yes\"\n else\n puts \"No\"\n end\nend\n\np max(1, 3, 8)\np max(3, 8, 1)\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": 128, "cpu_time_ms": 50, "memory_kb": 6836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s846796296", "group_id": "codeNet:p02392", "input_text": "a, b, c = gets.split(\" \").map(&:to_i)\nif a < b && b < c\n puts \"Yes\"\nelse\n puts \"No\"\nend\n", "language": "Ruby", "metadata": {"date": 1508876917, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s846796296.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s846796296", "user_id": "u632594605"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a, b, c = gets.split(\" \").map(&:to_i)\nif a < b && b < c\n puts \"Yes\"\nelse\n puts \"No\"\nend\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": 90, "cpu_time_ms": 40, "memory_kb": 8708}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s142030346", "group_id": "codeNet:p02393", "input_text": "puts gets.split.sort*' '", "language": "Ruby", "metadata": {"date": 1413015635, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02393.html", "problem_id": "p02393", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02393/input.txt", "sample_output_relpath": "derived/input_output/data/p02393/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02393/Ruby/s142030346.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s142030346", "user_id": "u890794282"}, "prompt_components": {"gold_output": "1 3 8\n", "input_to_evaluate": "puts gets.split.sort*' '", "problem_context": "Sorting Three Numbers\n\nWrite a program which reads three integers, and prints them in ascending order.\n\nInput\n\nThree integers separated by a single space are given in a line.\n\nOutput\n\nPrint the given integers in ascending order in a line. Put a single space between two integers.\n\nConstraints\n\n1 ≤ the three integers ≤ 10000\n\nSample Input 1\n\n3 8 1\n\nSample Output 1\n\n1 3 8", "sample_input": "3 8 1\n"}, "reference_outputs": ["1 3 8\n"], "source_document_id": "p02393", "source_text": "Sorting Three Numbers\n\nWrite a program which reads three integers, and prints them in ascending order.\n\nInput\n\nThree integers separated by a single space are given in a line.\n\nOutput\n\nPrint the given integers in ascending order in a line. Put a single space between two integers.\n\nConstraints\n\n1 ≤ the three integers ≤ 10000\n\nSample Input 1\n\n3 8 1\n\nSample Output 1\n\n1 3 8", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 24, "cpu_time_ms": 20, "memory_kb": 6096}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s570256901", "group_id": "codeNet:p02394", "input_text": "W, H, X, Y, R = gets.split.map &:to_i\nC = R < X && X+R < W && R < Y && Y+R < H\nputs C ? :Yes : :No", "language": "Ruby", "metadata": {"date": 1450799480, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s570256901.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s570256901", "user_id": "u556326323"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "W, H, X, Y, R = gets.split.map &:to_i\nC = R < X && X+R < W && R < Y && Y+R < H\nputs C ? :Yes : :No", "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": 98, "cpu_time_ms": 40, "memory_kb": 8548}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s111631608", "group_id": "codeNet:p02394", "input_text": "w, h, x, y, r = gets.split.map(&:to_i)\nif x-r >= 0 && y-r >= 0 && x+r <= w && y+r <= h\n\tputs \"Yes\"\nelse\n\tputs \"No\"\nend\n\n", "language": "Ruby", "metadata": {"date": 1529939326, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s111631608.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s111631608", "user_id": "u047260394"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "w, h, x, y, r = gets.split.map(&:to_i)\nif x-r >= 0 && y-r >= 0 && x+r <= w && y+r <= h\n\tputs \"Yes\"\nelse\n\tputs \"No\"\nend\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": 120, "cpu_time_ms": 40, "memory_kb": 6864}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s495081545", "group_id": "codeNet:p02394", "input_text": "W, H, x, y, r = gets.split(' ').map{|item| item.to_i}\n\nif 0 <= x-r && x+r <= W && 0 <= y-r && y+r <= H\n puts \"Yes\"\nelse\n puts \"No\"\nend\n", "language": "Ruby", "metadata": {"date": 1572301313, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s495081545.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s495081545", "user_id": "u797431839"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "W, H, x, y, r = gets.split(' ').map{|item| item.to_i}\n\nif 0 <= x-r && x+r <= W && 0 <= y-r && y+r <= H\n puts \"Yes\"\nelse\n puts \"No\"\nend\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": 139, "cpu_time_ms": 50, "memory_kb": 6872}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s946871498", "group_id": "codeNet:p02396", "input_text": "a = gets.split.map(&:to_i)\na.each_with_index {\n |x,i|\n i += 1\n if x == 0 then\n break\n end\n puts \"Case #{i}: #{x}\"\n}\n", "language": "Ruby", "metadata": {"date": 1535386661, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s946871498.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s946871498", "user_id": "u809272156"}, "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": "a = gets.split.map(&:to_i)\na.each_with_index {\n |x,i|\n i += 1\n if x == 0 then\n break\n end\n puts \"Case #{i}: #{x}\"\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": 142, "cpu_time_ms": 40, "memory_kb": 6876}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s472536602", "group_id": "codeNet:p02396", "input_text": "x = []\nARGF.each_line do |line|\n x << line\nend\nx.each_with_index do |str, i|\n puts \"case:#{i} str\"\nend", "language": "Ruby", "metadata": {"date": 1417483182, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s472536602.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s472536602", "user_id": "u330842660"}, "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": "x = []\nARGF.each_line do |line|\n x << line\nend\nx.each_with_index do |str, i|\n puts \"case:#{i} str\"\nend", "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": 104, "cpu_time_ms": 20, "memory_kb": 7776}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s877325656", "group_id": "codeNet:p02396", "input_text": "cnt = 0\nwhile true\n line = gets.lines\n cnt += 1\n if line[0] == \"0\\n\"\n break\n end\n print \"Case \",cnt,\": \",line[0]\n \nend", "language": "Ruby", "metadata": {"date": 1454154136, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s877325656.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s877325656", "user_id": "u558430890"}, "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": "cnt = 0\nwhile true\n line = gets.lines\n cnt += 1\n if line[0] == \"0\\n\"\n break\n end\n print \"Case \",cnt,\": \",line[0]\n \nend", "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": 147, "cpu_time_ms": 60, "memory_kb": 8808}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s040270998", "group_id": "codeNet:p02396", "input_text": "i = 0\nwhile true do\n\tx = gets.to_i\n\tif x == 0\n break\n end\n i += 1\n puts \"Case #{i}: #{x}\"\nend", "language": "Ruby", "metadata": {"date": 1461285682, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s040270998.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s040270998", "user_id": "u734427071"}, "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": "i = 0\nwhile true do\n\tx = gets.to_i\n\tif x == 0\n break\n end\n i += 1\n puts \"Case #{i}: #{x}\"\nend", "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": 109, "cpu_time_ms": 80, "memory_kb": 8760}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s089164448", "group_id": "codeNet:p02396", "input_text": "i = 1\nloop{\n x = gets.chomp.to_i\n\n x == 0 && break\n\n puts \"Case #{i}: #{x}\"\n i += 1\n}", "language": "Ruby", "metadata": {"date": 1499411734, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s089164448.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s089164448", "user_id": "u216813029"}, "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": "i = 1\nloop{\n x = gets.chomp.to_i\n\n x == 0 && break\n\n puts \"Case #{i}: #{x}\"\n i += 1\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": 89, "cpu_time_ms": 60, "memory_kb": 8752}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s693653817", "group_id": "codeNet:p02396", "input_text": "i = 1\nwhile true\n x = gets.chomp.to_i\n if x == 0\n break\n end\n puts \"Case #{i}: #{x}\"\n i += 1\nend\n", "language": "Ruby", "metadata": {"date": 1578814936, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s693653817.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s693653817", "user_id": "u504245202"}, "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": "i = 1\nwhile true\n x = gets.chomp.to_i\n if x == 0\n break\n end\n puts \"Case #{i}: #{x}\"\n i += 1\nend\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": 105, "cpu_time_ms": 60, "memory_kb": 6860}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s745553625", "group_id": "codeNet:p02397", "input_text": "while true\n\tnums = gets.split.map(&:to_i)\n\n\tbreak if (nums[0]==0&&nums[1]==0)\n\n\tputs nums.sort.join(\" \")\nend", "language": "Ruby", "metadata": {"date": 1415241146, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s745553625.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s745553625", "user_id": "u729486845"}, "prompt_components": {"gold_output": "2 3\n2 2\n3 5\n", "input_to_evaluate": "while true\n\tnums = gets.split.map(&:to_i)\n\n\tbreak if (nums[0]==0&&nums[1]==0)\n\n\tputs nums.sort.join(\" \")\nend", "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": 108, "cpu_time_ms": 20, "memory_kb": 6092}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s140476300", "group_id": "codeNet:p02397", "input_text": "while true\n x,y = gets.split.map(&:to_i)\n if x == 0 && y == 0\n break\n elsif x < y\n puts \"#{x} #{y}\"\n else\n puts \"#{y} #{x}\"\n end\nend", "language": "Ruby", "metadata": {"date": 1483391190, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s140476300.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s140476300", "user_id": "u407138207"}, "prompt_components": {"gold_output": "2 3\n2 2\n3 5\n", "input_to_evaluate": "while true\n x,y = gets.split.map(&:to_i)\n if x == 0 && y == 0\n break\n elsif x < y\n puts \"#{x} #{y}\"\n else\n puts \"#{y} #{x}\"\n end\nend", "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": 141, "cpu_time_ms": 50, "memory_kb": 8780}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s007708597", "group_id": "codeNet:p02397", "input_text": "while true\n x, y = gets.chomp.split(\" \").map(&:to_i)\n break if (x == 0 && y == 0)\n if x >= y\n puts \"#{x} #{y}\"\n else\n puts \"#{y} #{x}\"\n end\nend", "language": "Ruby", "metadata": {"date": 1493795941, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s007708597.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s007708597", "user_id": "u802537549"}, "prompt_components": {"gold_output": "2 3\n2 2\n3 5\n", "input_to_evaluate": "while true\n x, y = gets.chomp.split(\" \").map(&:to_i)\n break if (x == 0 && y == 0)\n if x >= y\n puts \"#{x} #{y}\"\n else\n puts \"#{y} #{x}\"\n end\nend", "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": 154, "cpu_time_ms": 40, "memory_kb": 8752}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s253200735", "group_id": "codeNet:p02397", "input_text": "for i in 1..3000\n x, y = gets.split\n x = x.to_i;y = y.to_i;\n if x == 0 && y == 0\n break\n end\n if x <= y\n puts \"%d %d\" %[x, y]\n else\n puts \"%d %d\" %[y, x]\n end\nend\n", "language": "Ruby", "metadata": {"date": 1553014822, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s253200735.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s253200735", "user_id": "u984892564"}, "prompt_components": {"gold_output": "2 3\n2 2\n3 5\n", "input_to_evaluate": "for i in 1..3000\n x, y = gets.split\n x = x.to_i;y = y.to_i;\n if x == 0 && y == 0\n break\n end\n if x <= y\n puts \"%d %d\" %[x, y]\n else\n puts \"%d %d\" %[y, x]\n end\nend\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": 205, "cpu_time_ms": 50, "memory_kb": 6872}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s003435960", "group_id": "codeNet:p02399", "input_text": "a,b = gets.split.map(&:to_i)\nd = a/b\nr = a%b\nf = a.to_f/b\nputs \"#{d} #{r} #{f}\"\n", "language": "Ruby", "metadata": {"date": 1535958011, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s003435960.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s003435960", "user_id": "u809272156"}, "prompt_components": {"gold_output": "1 1 1.50000\n", "input_to_evaluate": "a,b = gets.split.map(&:to_i)\nd = a/b\nr = a%b\nf = a.to_f/b\nputs \"#{d} #{r} #{f}\"\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": 80, "cpu_time_ms": 40, "memory_kb": 6872}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s771485763", "group_id": "codeNet:p02399", "input_text": "a,b=STDIN.gets.split.map(&:to_i)\n\nprint a/b,' ', a%b,' ', a/b.to_f, \"\\n\"", "language": "Ruby", "metadata": {"date": 1465466439, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s771485763.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s771485763", "user_id": "u534407423"}, "prompt_components": {"gold_output": "1 1 1.50000\n", "input_to_evaluate": "a,b=STDIN.gets.split.map(&:to_i)\n\nprint a/b,' ', a%b,' ', a/b.to_f, \"\\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": 72, "cpu_time_ms": 40, "memory_kb": 8676}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s442287913", "group_id": "codeNet:p02399", "input_text": "a, b = STDIN.gets.split.map(&:to_i)\nd=a/b\nr=a%b\nf=a.to_f/b.to_f\n\nputs sprintf(\"%d %d %.5f\",d,r,f)", "language": "Ruby", "metadata": {"date": 1465468058, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s442287913.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s442287913", "user_id": "u908917838"}, "prompt_components": {"gold_output": "1 1 1.50000\n", "input_to_evaluate": "a, b = STDIN.gets.split.map(&:to_i)\nd=a/b\nr=a%b\nf=a.to_f/b.to_f\n\nputs sprintf(\"%d %d %.5f\",d,r,f)", "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": 97, "cpu_time_ms": 40, "memory_kb": 8696}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s809153398", "group_id": "codeNet:p02399", "input_text": "#?????????????????????????????????\ndef itp1_4a()\n num=STDIN.gets.chomp.split(/ /)\n a=num[0].to_i\n b=num[1].to_i\n print \"#{a/b} #{a%b} #{(a.to_r/b.to_r).to_f}\\n\"\nend\n\nitp1_4a()", "language": "Ruby", "metadata": {"date": 1476511553, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s809153398.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s809153398", "user_id": "u208203110"}, "prompt_components": {"gold_output": "1 1 1.50000\n", "input_to_evaluate": "#?????????????????????????????????\ndef itp1_4a()\n num=STDIN.gets.chomp.split(/ /)\n a=num[0].to_i\n b=num[1].to_i\n print \"#{a/b} #{a%b} #{(a.to_r/b.to_r).to_f}\\n\"\nend\n\nitp1_4a()", "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": 179, "cpu_time_ms": 60, "memory_kb": 8644}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s033452224", "group_id": "codeNet:p02399", "input_text": "init = gets.split.map(&:to_i)\na,b = init[0], init[1]\nputs \"#{a/b} #{(a % b)} #{(a/b).to_f.round(5)}\"\n", "language": "Ruby", "metadata": {"date": 1516702382, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s033452224.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s033452224", "user_id": "u350127362"}, "prompt_components": {"gold_output": "1 1 1.50000\n", "input_to_evaluate": "init = gets.split.map(&:to_i)\na,b = init[0], init[1]\nputs \"#{a/b} #{(a % b)} #{(a/b).to_f.round(5)}\"\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": 102, "cpu_time_ms": 40, "memory_kb": 6908}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s516400429", "group_id": "codeNet:p02399", "input_text": "a,b = gets.chomp.split(\" \").map(&:to_i)\nputs \"#{a/b} #{a%b} #{1.0*a/b}\"", "language": "Ruby", "metadata": {"date": 1398764129, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s516400429.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s516400429", "user_id": "u577850777"}, "prompt_components": {"gold_output": "1 1 1.50000\n", "input_to_evaluate": "a,b = gets.chomp.split(\" \").map(&:to_i)\nputs \"#{a/b} #{a%b} #{1.0*a/b}\"", "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": 71, "cpu_time_ms": 20, "memory_kb": 6120}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s242448319", "group_id": "codeNet:p02400", "input_text": "r = gets.to_i\npi = Math::PI\na = r ** 2 * pi\ns = r * 2 * pi\n\nputs a.to_s + \" \" + s.to_s\n\n", "language": "Ruby", "metadata": {"date": 1535542140, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02400.html", "problem_id": "p02400", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02400/input.txt", "sample_output_relpath": "derived/input_output/data/p02400/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02400/Ruby/s242448319.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s242448319", "user_id": "u587994751"}, "prompt_components": {"gold_output": "12.566371 12.566371\n", "input_to_evaluate": "r = gets.to_i\npi = Math::PI\na = r ** 2 * pi\ns = r * 2 * pi\n\nputs a.to_s + \" \" + s.to_s\n\n", "problem_context": "Circle\n\nWrite a program which calculates the area and circumference of a circle for given radius r.\n\nInput\n\nA real number r is given.\n\nOutput\n\nPrint the area and circumference of the circle in a line. Put a single space between them. The output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n0 < r < 10000\n\nSample Input 1\n\n2\n\nSample Output 1\n\n12.566371 12.566371\n\nSample Input 2\n\n3\n\nSample Output 2\n\n28.274334 18.849556", "sample_input": "2\n"}, "reference_outputs": ["12.566371 12.566371\n"], "source_document_id": "p02400", "source_text": "Circle\n\nWrite a program which calculates the area and circumference of a circle for given radius r.\n\nInput\n\nA real number r is given.\n\nOutput\n\nPrint the area and circumference of the circle in a line. Put a single space between them. The output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n0 < r < 10000\n\nSample Input 1\n\n2\n\nSample Output 1\n\n12.566371 12.566371\n\nSample Input 2\n\n3\n\nSample Output 2\n\n28.274334 18.849556", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 88, "cpu_time_ms": 40, "memory_kb": 6844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s838028272", "group_id": "codeNet:p02400", "input_text": "r = gets.to_f\ns = r * r * Math::PI\nc = 2 * Math::PI * r\nputs [s, c].join(' ')", "language": "Ruby", "metadata": {"date": 1414858586, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02400.html", "problem_id": "p02400", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02400/input.txt", "sample_output_relpath": "derived/input_output/data/p02400/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02400/Ruby/s838028272.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s838028272", "user_id": "u390149337"}, "prompt_components": {"gold_output": "12.566371 12.566371\n", "input_to_evaluate": "r = gets.to_f\ns = r * r * Math::PI\nc = 2 * Math::PI * r\nputs [s, c].join(' ')", "problem_context": "Circle\n\nWrite a program which calculates the area and circumference of a circle for given radius r.\n\nInput\n\nA real number r is given.\n\nOutput\n\nPrint the area and circumference of the circle in a line. Put a single space between them. The output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n0 < r < 10000\n\nSample Input 1\n\n2\n\nSample Output 1\n\n12.566371 12.566371\n\nSample Input 2\n\n3\n\nSample Output 2\n\n28.274334 18.849556", "sample_input": "2\n"}, "reference_outputs": ["12.566371 12.566371\n"], "source_document_id": "p02400", "source_text": "Circle\n\nWrite a program which calculates the area and circumference of a circle for given radius r.\n\nInput\n\nA real number r is given.\n\nOutput\n\nPrint the area and circumference of the circle in a line. Put a single space between them. The output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n0 < r < 10000\n\nSample Input 1\n\n2\n\nSample Output 1\n\n12.566371 12.566371\n\nSample Input 2\n\n3\n\nSample Output 2\n\n28.274334 18.849556", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 77, "cpu_time_ms": 20, "memory_kb": 6108}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s953873881", "group_id": "codeNet:p02400", "input_text": "r=gets.to_f\npi=Math::PI\nputs \"#{r*r*pi} #{2*r*pi}\"", "language": "Ruby", "metadata": {"date": 1435028662, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02400.html", "problem_id": "p02400", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02400/input.txt", "sample_output_relpath": "derived/input_output/data/p02400/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02400/Ruby/s953873881.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s953873881", "user_id": "u248712727"}, "prompt_components": {"gold_output": "12.566371 12.566371\n", "input_to_evaluate": "r=gets.to_f\npi=Math::PI\nputs \"#{r*r*pi} #{2*r*pi}\"", "problem_context": "Circle\n\nWrite a program which calculates the area and circumference of a circle for given radius r.\n\nInput\n\nA real number r is given.\n\nOutput\n\nPrint the area and circumference of the circle in a line. Put a single space between them. The output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n0 < r < 10000\n\nSample Input 1\n\n2\n\nSample Output 1\n\n12.566371 12.566371\n\nSample Input 2\n\n3\n\nSample Output 2\n\n28.274334 18.849556", "sample_input": "2\n"}, "reference_outputs": ["12.566371 12.566371\n"], "source_document_id": "p02400", "source_text": "Circle\n\nWrite a program which calculates the area and circumference of a circle for given radius r.\n\nInput\n\nA real number r is given.\n\nOutput\n\nPrint the area and circumference of the circle in a line. Put a single space between them. The output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n0 < r < 10000\n\nSample Input 1\n\n2\n\nSample Output 1\n\n12.566371 12.566371\n\nSample Input 2\n\n3\n\nSample Output 2\n\n28.274334 18.849556", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 50, "cpu_time_ms": 20, "memory_kb": 6112}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s227427114", "group_id": "codeNet:p02400", "input_text": "include Math\npi = Math::PI\nr=gets.chomp.to_f\nprintf \"%.6f %.6f\\n\", (pi*r*r), (2*pi*r)", "language": "Ruby", "metadata": {"date": 1439019221, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02400.html", "problem_id": "p02400", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02400/input.txt", "sample_output_relpath": "derived/input_output/data/p02400/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02400/Ruby/s227427114.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s227427114", "user_id": "u575763144"}, "prompt_components": {"gold_output": "12.566371 12.566371\n", "input_to_evaluate": "include Math\npi = Math::PI\nr=gets.chomp.to_f\nprintf \"%.6f %.6f\\n\", (pi*r*r), (2*pi*r)", "problem_context": "Circle\n\nWrite a program which calculates the area and circumference of a circle for given radius r.\n\nInput\n\nA real number r is given.\n\nOutput\n\nPrint the area and circumference of the circle in a line. Put a single space between them. The output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n0 < r < 10000\n\nSample Input 1\n\n2\n\nSample Output 1\n\n12.566371 12.566371\n\nSample Input 2\n\n3\n\nSample Output 2\n\n28.274334 18.849556", "sample_input": "2\n"}, "reference_outputs": ["12.566371 12.566371\n"], "source_document_id": "p02400", "source_text": "Circle\n\nWrite a program which calculates the area and circumference of a circle for given radius r.\n\nInput\n\nA real number r is given.\n\nOutput\n\nPrint the area and circumference of the circle in a line. Put a single space between them. The output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n0 < r < 10000\n\nSample Input 1\n\n2\n\nSample Output 1\n\n12.566371 12.566371\n\nSample Input 2\n\n3\n\nSample Output 2\n\n28.274334 18.849556", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 85, "cpu_time_ms": 20, "memory_kb": 6124}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s679923834", "group_id": "codeNet:p02401", "input_text": "while true\n a, op, b = gets.split(\" \")\n a = a.to_i; b = b.to_i\n case op\n when \"+\"\n puts \"#{a + b}\"\n when \"-\"\n puts \"#{a - b}\"\n when \"*\"\n puts \"#{a * b}\"\n when \"/\"\n puts \"#{a / b}\"\n when \"?\"\n break\n end\nend", "language": "Ruby", "metadata": {"date": 1443512309, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s679923834.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s679923834", "user_id": "u261074410"}, "prompt_components": {"gold_output": "3\n38\n26\n10\n108\n", "input_to_evaluate": "while true\n a, op, b = gets.split(\" \")\n a = a.to_i; b = b.to_i\n case op\n when \"+\"\n puts \"#{a + b}\"\n when \"-\"\n puts \"#{a - b}\"\n when \"*\"\n puts \"#{a * b}\"\n when \"/\"\n puts \"#{a / b}\"\n when \"?\"\n break\n end\nend", "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": 229, "cpu_time_ms": 40, "memory_kb": 8664}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s639253243", "group_id": "codeNet:p02401", "input_text": "loop do\n a,op,b = gets.split()\n case op\n when \"+\" then puts (a.to_i+b.to_i)\n when \"-\" then puts (a.to_i-b.to_i)\n when \"*\" then puts (a.to_i*b.to_i)\n when \"/\" then puts (a.to_i/b.to_i)\n when \"?\" then break\n end\nend", "language": "Ruby", "metadata": {"date": 1467213227, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s639253243.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s639253243", "user_id": "u294922877"}, "prompt_components": {"gold_output": "3\n38\n26\n10\n108\n", "input_to_evaluate": "loop do\n a,op,b = gets.split()\n case op\n when \"+\" then puts (a.to_i+b.to_i)\n when \"-\" then puts (a.to_i-b.to_i)\n when \"*\" then puts (a.to_i*b.to_i)\n when \"/\" then puts (a.to_i/b.to_i)\n when \"?\" then break\n end\nend", "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": 218, "cpu_time_ms": 50, "memory_kb": 8592}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s655825552", "group_id": "codeNet:p02401", "input_text": "x, op, y = gets.split\nif op != \"?\" then\n x, y = x.to_i, y.to_f\n puts x.method(op).(y) \nend", "language": "Ruby", "metadata": {"date": 1487829627, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s655825552.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s655825552", "user_id": "u166301467"}, "prompt_components": {"gold_output": "3\n38\n26\n10\n108\n", "input_to_evaluate": "x, op, y = gets.split\nif op != \"?\" then\n x, y = x.to_i, y.to_f\n puts x.method(op).(y) \nend", "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": 92, "cpu_time_ms": 30, "memory_kb": 8596}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s967317923", "group_id": "codeNet:p02402", "input_text": "x = gets\na = gets.split.map(&:to_i)\nputs [a.max, a.min, a.inject(:+)]", "language": "Ruby", "metadata": {"date": 1413631299, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s967317923.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s967317923", "user_id": "u818936038"}, "prompt_components": {"gold_output": "1 17 37\n", "input_to_evaluate": "x = gets\na = gets.split.map(&:to_i)\nputs [a.max, a.min, a.inject(:+)]", "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": 69, "cpu_time_ms": 20, "memory_kb": 6092}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s813884290", "group_id": "codeNet:p02402", "input_text": "gets\nnums = gets.split(' ').map(&:to_i)\nputs \"#{nums.min} #{nums.max} #{nums.sum}\"\n", "language": "Ruby", "metadata": {"date": 1570838336, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s813884290.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s813884290", "user_id": "u300970828"}, "prompt_components": {"gold_output": "1 17 37\n", "input_to_evaluate": "gets\nnums = gets.split(' ').map(&:to_i)\nputs \"#{nums.min} #{nums.max} #{nums.sum}\"\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMin, Max and Sum\n\nWrite a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.\n\nInput\n\nIn the first line, an integer $n$ is given. In the next line, $n$ integers $a_i$ are given in a line.\n\nOutput\n\nPrint the minimum value, maximum value and sum in a line. Put a single space between the values.\n\nConstraints\n\n$0 < n \\leq 10000$\n\n$-1000000 \\leq a_i \\leq 1000000$\n\nSample Input\n\n5\n10 1 5 4 17\n\nSample Output\n\n1 17 37", "sample_input": "5\n10 1 5 4 17\n"}, "reference_outputs": ["1 17 37\n"], "source_document_id": "p02402", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMin, Max and Sum\n\nWrite a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.\n\nInput\n\nIn the first line, an integer $n$ is given. In the next line, $n$ integers $a_i$ are given in a line.\n\nOutput\n\nPrint the minimum value, maximum value and sum in a line. Put a single space between the values.\n\nConstraints\n\n$0 < n \\leq 10000$\n\n$-1000000 \\leq a_i \\leq 1000000$\n\nSample Input\n\n5\n10 1 5 4 17\n\nSample Output\n\n1 17 37", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 83, "cpu_time_ms": 40, "memory_kb": 7168}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s391023523", "group_id": "codeNet:p02403", "input_text": "while true\n h,w=gets.split.map(&:to_i)\n break if h==0 && w==0\n\n h.times{puts \"#\"*w}\n puts\nend", "language": "Ruby", "metadata": {"date": 1428292164, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02403.html", "problem_id": "p02403", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02403/input.txt", "sample_output_relpath": "derived/input_output/data/p02403/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02403/Ruby/s391023523.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s391023523", "user_id": "u307525591"}, "prompt_components": {"gold_output": "####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##\n", "input_to_evaluate": "while true\n h,w=gets.split.map(&:to_i)\n break if h==0 && w==0\n\n h.times{puts \"#\"*w}\n puts\nend", "problem_context": "Print a Rectangle\n\nDraw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the rectangle made of H × W '#'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n2 2\n0 0\n\nSample Output\n\n####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##", "sample_input": "3 4\n5 6\n2 2\n0 0\n"}, "reference_outputs": ["####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##\n"], "source_document_id": "p02403", "source_text": "Print a Rectangle\n\nDraw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the rectangle made of H × W '#'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n2 2\n0 0\n\nSample Output\n\n####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 105, "cpu_time_ms": 20, "memory_kb": 6096}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s059284421", "group_id": "codeNet:p02403", "input_text": "inputs = []\nwhile str = STDIN.gets\n if str.chomp == \"0 0\" then break end\n inputs << str.chomp\nend\n\ndef describe_rectangle(h, w)\n # puts \"h = #{h}, w = #{w}\"\n output = \"\"\n for j in 1..h do\n for i in 1..w do\n output += \"#\"\n end\n output += \"\\n\"\n end\n puts output\nend\n\n# puts inputs\nfor num in 0..inputs.length - 1 do\n rec = inputs[num].split(\" \")\n # puts \"rec = #{rec}\"\n describe_rectangle(rec[0].to_i, rec[1].to_i)\n puts \"\\n\"\nend", "language": "Ruby", "metadata": {"date": 1430120846, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02403.html", "problem_id": "p02403", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02403/input.txt", "sample_output_relpath": "derived/input_output/data/p02403/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02403/Ruby/s059284421.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s059284421", "user_id": "u938745275"}, "prompt_components": {"gold_output": "####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##\n", "input_to_evaluate": "inputs = []\nwhile str = STDIN.gets\n if str.chomp == \"0 0\" then break end\n inputs << str.chomp\nend\n\ndef describe_rectangle(h, w)\n # puts \"h = #{h}, w = #{w}\"\n output = \"\"\n for j in 1..h do\n for i in 1..w do\n output += \"#\"\n end\n output += \"\\n\"\n end\n puts output\nend\n\n# puts inputs\nfor num in 0..inputs.length - 1 do\n rec = inputs[num].split(\" \")\n # puts \"rec = #{rec}\"\n describe_rectangle(rec[0].to_i, rec[1].to_i)\n puts \"\\n\"\nend", "problem_context": "Print a Rectangle\n\nDraw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the rectangle made of H × W '#'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n2 2\n0 0\n\nSample Output\n\n####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##", "sample_input": "3 4\n5 6\n2 2\n0 0\n"}, "reference_outputs": ["####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##\n"], "source_document_id": "p02403", "source_text": "Print a Rectangle\n\nDraw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the rectangle made of H × W '#'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n2 2\n0 0\n\nSample Output\n\n####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 452, "cpu_time_ms": 130, "memory_kb": 13960}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s602813844", "group_id": "codeNet:p02404", "input_text": "loop{\n h, w = gets.split.map &:to_i\n break if h == 0 && w == 0\n puts '#' * w\n (h-2).times{|i|\n print '#' if w > 1\n puts '.' * [w-2, 0].max + '#'\n }\n puts '#' * w\n puts\n}", "language": "Ruby", "metadata": {"date": 1450807221, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02404.html", "problem_id": "p02404", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02404/input.txt", "sample_output_relpath": "derived/input_output/data/p02404/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02404/Ruby/s602813844.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s602813844", "user_id": "u556326323"}, "prompt_components": {"gold_output": "####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###\n", "input_to_evaluate": "loop{\n h, w = gets.split.map &:to_i\n break if h == 0 && w == 0\n puts '#' * w\n (h-2).times{|i|\n print '#' if w > 1\n puts '.' * [w-2, 0].max + '#'\n }\n puts '#' * w\n puts\n}", "problem_context": "Print a Frame\n\nDraw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.\n\n##########\n#........#\n#........#\n#........#\n#........#\n##########\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the frame made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n3 ≤ H ≤ 300\n\n3 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n0 0\n\nSample Output\n\n####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###", "sample_input": "3 4\n5 6\n3 3\n0 0\n"}, "reference_outputs": ["####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###\n"], "source_document_id": "p02404", "source_text": "Print a Frame\n\nDraw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.\n\n##########\n#........#\n#........#\n#........#\n#........#\n##########\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the frame made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n3 ≤ H ≤ 300\n\n3 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n0 0\n\nSample Output\n\n####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 182, "cpu_time_ms": 40, "memory_kb": 8780}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s226383133", "group_id": "codeNet:p02405", "input_text": "while true\nh,w =gets.split.map(&:to_i)\nbreak if ( h==0 && w==0 )\n\nh.times{\n w.times{\n if (w%2 == 0 && h%2 == 1) then\n print \".\"\n elsif print \"#\"\n end}\nputs\n }\n\nend\n ", "language": "Ruby", "metadata": {"date": 1477219623, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s226383133.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s226383133", "user_id": "u232170203"}, "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": "while true\nh,w =gets.split.map(&:to_i)\nbreak if ( h==0 && w==0 )\n\nh.times{\n w.times{\n if (w%2 == 0 && h%2 == 1) then\n print \".\"\n elsif print \"#\"\n end}\nputs\n }\n\nend\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": 196, "cpu_time_ms": 40, "memory_kb": 8524}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s390786131", "group_id": "codeNet:p02405", "input_text": "loop{\nh,w = gets.split.map(&:to_i)\nif h == 0 && w == 0\n break\nend\ni = 0\nh.times{\n i += 1\n if i.odd?\n if w.odd?\n puts \"#.\" * (w / 2) + \"#\"\n elsif w.even?\n puts \"#.\" * (w / 2)\n end\n elsif i.even?\n if w.odd?\n puts \".#\" * (w / 2) + \".\"\n elsif w.even?\n puts \".#\" * (w / 2)\n end\n end\n}\nputs \"\"\n}\n", "language": "Ruby", "metadata": {"date": 1536878078, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s390786131.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s390786131", "user_id": "u809272156"}, "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": "loop{\nh,w = gets.split.map(&:to_i)\nif h == 0 && w == 0\n break\nend\ni = 0\nh.times{\n i += 1\n if i.odd?\n if w.odd?\n puts \"#.\" * (w / 2) + \"#\"\n elsif w.even?\n puts \"#.\" * (w / 2)\n end\n elsif i.even?\n if w.odd?\n puts \".#\" * (w / 2) + \".\"\n elsif w.even?\n puts \".#\" * (w / 2)\n end\n end\n}\nputs \"\"\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": 391, "cpu_time_ms": 50, "memory_kb": 6940}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s781173585", "group_id": "codeNet:p02406", "input_text": "x = gets.to_i\nfor i in 1..x do\n if i % 3 == 0 then\n print \" #{i}\"\n elsif i.to_s.include?('3')\n print \" #{i}\"\n end\nend\nputs\n\n", "language": "Ruby", "metadata": {"date": 1548938966, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s781173585.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s781173585", "user_id": "u894176337"}, "prompt_components": {"gold_output": " 3 6 9 12 13 15 18 21 23 24 27 30\n", "input_to_evaluate": "x = gets.to_i\nfor i in 1..x do\n if i % 3 == 0 then\n print \" #{i}\"\n elsif i.to_s.include?('3')\n print \" #{i}\"\n end\nend\nputs\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": 147, "cpu_time_ms": 40, "memory_kb": 8856}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s239826408", "group_id": "codeNet:p02407", "input_text": "n=gets.to_i\nmp=gets.split(' ').map(&:to_i).sort!\nn.downto(1){ |i|\n if i==1 then\n printf(\"%d\\n\",mp[i-1])\n else\n printf(\"%d \",mp[i-1])\n end\n}", "language": "Ruby", "metadata": {"date": 1480205369, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s239826408.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s239826408", "user_id": "u665389142"}, "prompt_components": {"gold_output": "5 4 3 2 1\n", "input_to_evaluate": "n=gets.to_i\nmp=gets.split(' ').map(&:to_i).sort!\nn.downto(1){ |i|\n if i==1 then\n printf(\"%d\\n\",mp[i-1])\n else\n printf(\"%d \",mp[i-1])\n end\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": 149, "cpu_time_ms": 40, "memory_kb": 8632}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s382656304", "group_id": "codeNet:p02407", "input_text": "x = gets.to_i\narr = gets.split.collect{|item| item.to_i}\n\nputs arr.reverse.join \" \"\n", "language": "Ruby", "metadata": {"date": 1525040460, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s382656304.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s382656304", "user_id": "u928503227"}, "prompt_components": {"gold_output": "5 4 3 2 1\n", "input_to_evaluate": "x = gets.to_i\narr = gets.split.collect{|item| item.to_i}\n\nputs arr.reverse.join \" \"\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": 84, "cpu_time_ms": 40, "memory_kb": 6864}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s851207614", "group_id": "codeNet:p02407", "input_text": "\nt = gets.chomp\n\na = gets.chomp.split\n\nputs a.reverse.join(\" \")\n", "language": "Ruby", "metadata": {"date": 1553654916, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s851207614.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s851207614", "user_id": "u286051940"}, "prompt_components": {"gold_output": "5 4 3 2 1\n", "input_to_evaluate": "\nt = gets.chomp\n\na = gets.chomp.split\n\nputs a.reverse.join(\" \")\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": 64, "cpu_time_ms": 40, "memory_kb": 6856}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s118353380", "group_id": "codeNet:p02408", "input_text": "gets\nary = []\n[\"S\", \"H\", \"C\", \"D\"].each do |a|\n 13.times{|i| ary << \"#{a} #{i+1}\"}\nend\n\nARGF.each_line do |line|\n data = line.chomp\n ary.delete(data) if ary.include?(data)\nend\nputs ary", "language": "Ruby", "metadata": {"date": 1421122929, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s118353380.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s118353380", "user_id": "u330842660"}, "prompt_components": {"gold_output": "S 1\nH 3\nH 7\nC 12\nD 8\n", "input_to_evaluate": "gets\nary = []\n[\"S\", \"H\", \"C\", \"D\"].each do |a|\n 13.times{|i| ary << \"#{a} #{i+1}\"}\nend\n\nARGF.each_line do |line|\n data = line.chomp\n ary.delete(data) if ary.include?(data)\nend\nputs ary", "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": 187, "cpu_time_ms": 20, "memory_kb": 6088}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s166239201", "group_id": "codeNet:p02408", "input_text": "S = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\", \"13\"]\nH = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\", \"13\"]\nC = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\", \"13\"]\nD = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\", \"13\"]\ngets.to_i.times do\n a = gets.split\n case a[0]\n when \"S\"\n S.delete(a[1])\n when \"H\"\n H.delete(a[1])\n when \"C\"\n C.delete(a[1])\n when \"D\"\n D.delete(a[1])\n end\nend\nS.length.times do |i|\n puts \"S #{S[i]}\"\nend\nH.length.times do |i|\n puts \"H #{H[i]}\"\nend\nC.length.times do |i|\n puts \"C #{C[i]}\"\nend\nD.length.times do |i|\n puts \"D #{D[i]}\"\nend", "language": "Ruby", "metadata": {"date": 1497101015, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s166239201.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s166239201", "user_id": "u060818581"}, "prompt_components": {"gold_output": "S 1\nH 3\nH 7\nC 12\nD 8\n", "input_to_evaluate": "S = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\", \"13\"]\nH = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\", \"13\"]\nC = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\", \"13\"]\nD = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\", \"13\"]\ngets.to_i.times do\n a = gets.split\n case a[0]\n when \"S\"\n S.delete(a[1])\n when \"H\"\n H.delete(a[1])\n when \"C\"\n C.delete(a[1])\n when \"D\"\n D.delete(a[1])\n end\nend\nS.length.times do |i|\n puts \"S #{S[i]}\"\nend\nH.length.times do |i|\n puts \"H #{H[i]}\"\nend\nC.length.times do |i|\n puts \"C #{C[i]}\"\nend\nD.length.times do |i|\n puts \"D #{D[i]}\"\nend", "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": 653, "cpu_time_ms": 30, "memory_kb": 8624}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s829431452", "group_id": "codeNet:p02409", "input_text": "# 4棟3階建て10フロアの配列\nbuilding = Array.new(4){ Array.new(3){ Array.new(10, 0)}}\n\nN = gets.chomp.to_i\n\nfor i in 1..N\n\timput = gets.chomp.split(\"\\s\")\n\t\n\t# imputされた文字列をintegerに変換\n\tfor k in 0..3\n\t\timput[k] = imput[k].to_i\n\tend\n\t\n\t# 数値の代入\n\tbuilding[imput[0] - 1][imput[1] - 1][imput[2] - 1] += imput[3]\nend\n\n# 出力\n\n# aa棟bb階の状態を出力する\nfor aa in 0..3\n\tfor bb in 0..2\n\t\n\t\t# 最終行だけは改行を加えない\n\t\tif aa == 3 && bb == 2\n\t\t\tprint(\"\\s\", building[aa][bb].join(\"\\s\"))\n\t\telse\n\t\t\tprint(\"\\s\", building[aa][bb].join(\"\\s\"), \"\\n\")\n\t\tend\n\tend\n\t\n\t# 最後の段以外は仕切りを入れる\n\tif aa != 3\n\t\tputs \"#\" * 20\n\tend\nend", "language": "Ruby", "metadata": {"date": 1438651439, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s829431452.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s829431452", "user_id": "u903969464"}, "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": "# 4棟3階建て10フロアの配列\nbuilding = Array.new(4){ Array.new(3){ Array.new(10, 0)}}\n\nN = gets.chomp.to_i\n\nfor i in 1..N\n\timput = gets.chomp.split(\"\\s\")\n\t\n\t# imputされた文字列をintegerに変換\n\tfor k in 0..3\n\t\timput[k] = imput[k].to_i\n\tend\n\t\n\t# 数値の代入\n\tbuilding[imput[0] - 1][imput[1] - 1][imput[2] - 1] += imput[3]\nend\n\n# 出力\n\n# aa棟bb階の状態を出力する\nfor aa in 0..3\n\tfor bb in 0..2\n\t\n\t\t# 最終行だけは改行を加えない\n\t\tif aa == 3 && bb == 2\n\t\t\tprint(\"\\s\", building[aa][bb].join(\"\\s\"))\n\t\telse\n\t\t\tprint(\"\\s\", building[aa][bb].join(\"\\s\"), \"\\n\")\n\t\tend\n\tend\n\t\n\t# 最後の段以外は仕切りを入れる\n\tif aa != 3\n\t\tputs \"#\" * 20\n\tend\nend", "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": 693, "cpu_time_ms": 10, "memory_kb": 6116}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s891072559", "group_id": "codeNet:p02410", "input_text": "A = Array.new\nb = Array.new\nn, m = gets.split.map(&:to_i)\nn.times {A << gets.split.map(&:to_i)}\nm.times {b << gets.to_i}\n \nA.each do |is|\n j = sum = 0\n is.each do |i|\n sum += i * b[j]\n j += 1\n end\n puts sum\nend", "language": "Ruby", "metadata": {"date": 1435542201, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02410.html", "problem_id": "p02410", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02410/input.txt", "sample_output_relpath": "derived/input_output/data/p02410/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02410/Ruby/s891072559.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s891072559", "user_id": "u043406421"}, "prompt_components": {"gold_output": "5\n6\n9\n", "input_to_evaluate": "A = Array.new\nb = Array.new\nn, m = gets.split.map(&:to_i)\nn.times {A << gets.split.map(&:to_i)}\nm.times {b << gets.to_i}\n \nA.each do |is|\n j = sum = 0\n is.each do |i|\n sum += i * b[j]\n j += 1\n end\n puts sum\nend", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMatrix Vector Multiplication\n\nWrite a program which reads a $ n \\times m$ matrix $A$ and a $m \\times 1$ vector $b$, and prints their product $Ab$.\n\nA column vector with m elements is represented by the following equation.\n\n\\[\nb = \\left(\n\\begin{array}{c}\nb_1 \\\\\nb_2 \\\\\n: \\\\\nb_m \\\\\n\\end{array}\n\\right)\n\\]\n\nA $n \\times m$ matrix with $m$ column vectors, each of which consists of $n$ elements, is represented by the following equation.\n\n\\[\nA = \\left(\n\\begin{array}{cccc}\na_{11} & a_{12} & ... & a_{1m} \\\\\na_{21} & a_{22} & ... & a_{2m} \\\\\n: & : & : & : \\\\\na_{n1} & a_{n2} & ... & a_{nm} \\\\\n\\end{array}\n\\right)\n\\]\n\n$i$-th element of a $m \\times 1$ column vector $b$ is represented by $b_i$ ($i = 1, 2, ..., m$), and the element in $i$-th row and $j$-th column of a matrix $A$ is represented by $a_{ij}$ ($i = 1, 2, ..., n,$ $j = 1, 2, ..., m$).\n\nThe product of a $n \\times m$ matrix $A$ and a $m \\times 1$ column vector $b$ is a $n \\times 1$ column vector $c$, and $c_i$ is obtained by the following formula:\n\n\\[\nc_i = \\sum_{j=1}^m a_{ij}b_j = a_{i1}b_1 + a_{i2}b_2 + ... + a_{im}b_m\n\\]\n\nInput\n\nIn the first line, two integers $n$ and $m$ are given. In the following $n$ lines, $a_{ij}$ are given separated by a single space character. In the next $m$ lines, $b_i$ is given in a line.\n\nOutput\n\nThe output consists of $n$ lines. Print $c_i$ in a line.\n\nConstraints\n\n$1 \\leq n, m \\leq 100$\n\n$0 \\leq b_i, a_{ij} \\leq 1000$\n\nSample Input\n\n3 4\n1 2 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0\n\nSample Output\n\n5\n6\n9", "sample_input": "3 4\n1 2 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0\n"}, "reference_outputs": ["5\n6\n9\n"], "source_document_id": "p02410", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMatrix Vector Multiplication\n\nWrite a program which reads a $ n \\times m$ matrix $A$ and a $m \\times 1$ vector $b$, and prints their product $Ab$.\n\nA column vector with m elements is represented by the following equation.\n\n\\[\nb = \\left(\n\\begin{array}{c}\nb_1 \\\\\nb_2 \\\\\n: \\\\\nb_m \\\\\n\\end{array}\n\\right)\n\\]\n\nA $n \\times m$ matrix with $m$ column vectors, each of which consists of $n$ elements, is represented by the following equation.\n\n\\[\nA = \\left(\n\\begin{array}{cccc}\na_{11} & a_{12} & ... & a_{1m} \\\\\na_{21} & a_{22} & ... & a_{2m} \\\\\n: & : & : & : \\\\\na_{n1} & a_{n2} & ... & a_{nm} \\\\\n\\end{array}\n\\right)\n\\]\n\n$i$-th element of a $m \\times 1$ column vector $b$ is represented by $b_i$ ($i = 1, 2, ..., m$), and the element in $i$-th row and $j$-th column of a matrix $A$ is represented by $a_{ij}$ ($i = 1, 2, ..., n,$ $j = 1, 2, ..., m$).\n\nThe product of a $n \\times m$ matrix $A$ and a $m \\times 1$ column vector $b$ is a $n \\times 1$ column vector $c$, and $c_i$ is obtained by the following formula:\n\n\\[\nc_i = \\sum_{j=1}^m a_{ij}b_j = a_{i1}b_1 + a_{i2}b_2 + ... + a_{im}b_m\n\\]\n\nInput\n\nIn the first line, two integers $n$ and $m$ are given. In the following $n$ lines, $a_{ij}$ are given separated by a single space character. In the next $m$ lines, $b_i$ is given in a line.\n\nOutput\n\nThe output consists of $n$ lines. Print $c_i$ in a line.\n\nConstraints\n\n$1 \\leq n, m \\leq 100$\n\n$0 \\leq b_i, a_{ij} \\leq 1000$\n\nSample Input\n\n3 4\n1 2 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0\n\nSample Output\n\n5\n6\n9", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 221, "cpu_time_ms": 20, "memory_kb": 6132}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s829412430", "group_id": "codeNet:p02410", "input_text": "n,m = gets.split.map(&:to_i)\na_vec = []\nn.times do\n a_vec << gets.split.map(&:to_i)\nend\n\nb_vec =[]\nm.times do\n b_vec << gets.to_i\nend\n\na_vec.each do |v|\n sum = 0\n m.times do |i|\n sum += (v[i] * b_vec[i])\n end\n puts sum\nend\n", "language": "Ruby", "metadata": {"date": 1583990722, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02410.html", "problem_id": "p02410", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02410/input.txt", "sample_output_relpath": "derived/input_output/data/p02410/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02410/Ruby/s829412430.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s829412430", "user_id": "u514142000"}, "prompt_components": {"gold_output": "5\n6\n9\n", "input_to_evaluate": "n,m = gets.split.map(&:to_i)\na_vec = []\nn.times do\n a_vec << gets.split.map(&:to_i)\nend\n\nb_vec =[]\nm.times do\n b_vec << gets.to_i\nend\n\na_vec.each do |v|\n sum = 0\n m.times do |i|\n sum += (v[i] * b_vec[i])\n end\n puts sum\nend\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMatrix Vector Multiplication\n\nWrite a program which reads a $ n \\times m$ matrix $A$ and a $m \\times 1$ vector $b$, and prints their product $Ab$.\n\nA column vector with m elements is represented by the following equation.\n\n\\[\nb = \\left(\n\\begin{array}{c}\nb_1 \\\\\nb_2 \\\\\n: \\\\\nb_m \\\\\n\\end{array}\n\\right)\n\\]\n\nA $n \\times m$ matrix with $m$ column vectors, each of which consists of $n$ elements, is represented by the following equation.\n\n\\[\nA = \\left(\n\\begin{array}{cccc}\na_{11} & a_{12} & ... & a_{1m} \\\\\na_{21} & a_{22} & ... & a_{2m} \\\\\n: & : & : & : \\\\\na_{n1} & a_{n2} & ... & a_{nm} \\\\\n\\end{array}\n\\right)\n\\]\n\n$i$-th element of a $m \\times 1$ column vector $b$ is represented by $b_i$ ($i = 1, 2, ..., m$), and the element in $i$-th row and $j$-th column of a matrix $A$ is represented by $a_{ij}$ ($i = 1, 2, ..., n,$ $j = 1, 2, ..., m$).\n\nThe product of a $n \\times m$ matrix $A$ and a $m \\times 1$ column vector $b$ is a $n \\times 1$ column vector $c$, and $c_i$ is obtained by the following formula:\n\n\\[\nc_i = \\sum_{j=1}^m a_{ij}b_j = a_{i1}b_1 + a_{i2}b_2 + ... + a_{im}b_m\n\\]\n\nInput\n\nIn the first line, two integers $n$ and $m$ are given. In the following $n$ lines, $a_{ij}$ are given separated by a single space character. In the next $m$ lines, $b_i$ is given in a line.\n\nOutput\n\nThe output consists of $n$ lines. Print $c_i$ in a line.\n\nConstraints\n\n$1 \\leq n, m \\leq 100$\n\n$0 \\leq b_i, a_{ij} \\leq 1000$\n\nSample Input\n\n3 4\n1 2 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0\n\nSample Output\n\n5\n6\n9", "sample_input": "3 4\n1 2 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0\n"}, "reference_outputs": ["5\n6\n9\n"], "source_document_id": "p02410", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMatrix Vector Multiplication\n\nWrite a program which reads a $ n \\times m$ matrix $A$ and a $m \\times 1$ vector $b$, and prints their product $Ab$.\n\nA column vector with m elements is represented by the following equation.\n\n\\[\nb = \\left(\n\\begin{array}{c}\nb_1 \\\\\nb_2 \\\\\n: \\\\\nb_m \\\\\n\\end{array}\n\\right)\n\\]\n\nA $n \\times m$ matrix with $m$ column vectors, each of which consists of $n$ elements, is represented by the following equation.\n\n\\[\nA = \\left(\n\\begin{array}{cccc}\na_{11} & a_{12} & ... & a_{1m} \\\\\na_{21} & a_{22} & ... & a_{2m} \\\\\n: & : & : & : \\\\\na_{n1} & a_{n2} & ... & a_{nm} \\\\\n\\end{array}\n\\right)\n\\]\n\n$i$-th element of a $m \\times 1$ column vector $b$ is represented by $b_i$ ($i = 1, 2, ..., m$), and the element in $i$-th row and $j$-th column of a matrix $A$ is represented by $a_{ij}$ ($i = 1, 2, ..., n,$ $j = 1, 2, ..., m$).\n\nThe product of a $n \\times m$ matrix $A$ and a $m \\times 1$ column vector $b$ is a $n \\times 1$ column vector $c$, and $c_i$ is obtained by the following formula:\n\n\\[\nc_i = \\sum_{j=1}^m a_{ij}b_j = a_{i1}b_1 + a_{i2}b_2 + ... + a_{im}b_m\n\\]\n\nInput\n\nIn the first line, two integers $n$ and $m$ are given. In the following $n$ lines, $a_{ij}$ are given separated by a single space character. In the next $m$ lines, $b_i$ is given in a line.\n\nOutput\n\nThe output consists of $n$ lines. Print $c_i$ in a line.\n\nConstraints\n\n$1 \\leq n, m \\leq 100$\n\n$0 \\leq b_i, a_{ij} \\leq 1000$\n\nSample Input\n\n3 4\n1 2 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0\n\nSample Output\n\n5\n6\n9", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 232, "cpu_time_ms": 40, "memory_kb": 6980}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s580263190", "group_id": "codeNet:p02411", "input_text": "loop do\n m, f, r = gets.split(\" \").map(&:to_i)\n exit if m == -1 and f == -1 and r == -1\n\n puts \"F\" if (m == -1 or f == -1 ) or (m + f < 30)\n puts \"A\" if 80 <= m + f\n puts \"B\" if 65 <= m + f and m + f < 80\n puts \"C\" if 50 <= m + f and m + f < 65\n if 30 <= m + f and m + f < 50\n puts r <= 50 ? \"C\" : \"D\"\n end\nend", "language": "Ruby", "metadata": {"date": 1418234568, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s580263190.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s580263190", "user_id": "u364560197"}, "prompt_components": {"gold_output": "A\nC\nF\n", "input_to_evaluate": "loop do\n m, f, r = gets.split(\" \").map(&:to_i)\n exit if m == -1 and f == -1 and r == -1\n\n puts \"F\" if (m == -1 or f == -1 ) or (m + f < 30)\n puts \"A\" if 80 <= m + f\n puts \"B\" if 65 <= m + f and m + f < 80\n puts \"C\" if 50 <= m + f and m + f < 65\n if 30 <= m + f and m + f < 50\n puts r <= 50 ? \"C\" : \"D\"\n end\nend", "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": 323, "cpu_time_ms": 20, "memory_kb": 6104}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s341788477", "group_id": "codeNet:p02413", "input_text": "num = []\nr, c = gets.split.map(&:to_i)\nsum_line = Array.new(c, 0)\nr.times do\n num << gets.split.map(&:to_i)\nend\n\nnum.each_with_index do |m, i|\n puts num[i].join(\" \") + \" \" + num[i].inject(:+).to_s\n sum_line.map!.with_index {|arr, j| arr + num[i][j]}\nend\n puts sum_line.join(\" \") + \" \" + sum_line.inject(:+).to_s", "language": "Ruby", "metadata": {"date": 1414846887, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02413.html", "problem_id": "p02413", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02413/input.txt", "sample_output_relpath": "derived/input_output/data/p02413/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02413/Ruby/s341788477.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s341788477", "user_id": "u818936038"}, "prompt_components": {"gold_output": "1 1 3 4 5 14\n2 2 2 4 5 15\n3 3 0 1 1 8\n2 3 4 4 6 19\n8 9 9 13 17 56\n", "input_to_evaluate": "num = []\nr, c = gets.split.map(&:to_i)\nsum_line = Array.new(c, 0)\nr.times do\n num << gets.split.map(&:to_i)\nend\n\nnum.each_with_index do |m, i|\n puts num[i].join(\" \") + \" \" + num[i].inject(:+).to_s\n sum_line.map!.with_index {|arr, j| arr + num[i][j]}\nend\n puts sum_line.join(\" \") + \" \" + sum_line.inject(:+).to_s", "problem_context": "Spreadsheet\n\nYour task is to perform a simple table calculation.\n\nWrite a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.\n\nInput\n\nIn the first line, two integers r and c are given. Next, the table is given by r lines, each of which consists of c integers separated by space characters.\n\nOutput\n\nPrint the new table of (r+1) × (c+1) elements. Put a single space character between adjacent elements. For each row, print the sum of it's elements in the last column. For each column, print the sum of it's elements in the last row. Print the total sum of the elements at the bottom right corner of the table.\n\nConstraints\n\n1 ≤ r, c ≤ 100\n\n0 ≤ an element of the table ≤ 100\n\nSample Input\n\n4 5\n1 1 3 4 5\n2 2 2 4 5\n3 3 0 1 1\n2 3 4 4 6\n\nSample Output\n\n1 1 3 4 5 14\n2 2 2 4 5 15\n3 3 0 1 1 8\n2 3 4 4 6 19\n8 9 9 13 17 56", "sample_input": "4 5\n1 1 3 4 5\n2 2 2 4 5\n3 3 0 1 1\n2 3 4 4 6\n"}, "reference_outputs": ["1 1 3 4 5 14\n2 2 2 4 5 15\n3 3 0 1 1 8\n2 3 4 4 6 19\n8 9 9 13 17 56\n"], "source_document_id": "p02413", "source_text": "Spreadsheet\n\nYour task is to perform a simple table calculation.\n\nWrite a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.\n\nInput\n\nIn the first line, two integers r and c are given. Next, the table is given by r lines, each of which consists of c integers separated by space characters.\n\nOutput\n\nPrint the new table of (r+1) × (c+1) elements. Put a single space character between adjacent elements. For each row, print the sum of it's elements in the last column. For each column, print the sum of it's elements in the last row. Print the total sum of the elements at the bottom right corner of the table.\n\nConstraints\n\n1 ≤ r, c ≤ 100\n\n0 ≤ an element of the table ≤ 100\n\nSample Input\n\n4 5\n1 1 3 4 5\n2 2 2 4 5\n3 3 0 1 1\n2 3 4 4 6\n\nSample Output\n\n1 1 3 4 5 14\n2 2 2 4 5 15\n3 3 0 1 1 8\n2 3 4 4 6 19\n8 9 9 13 17 56", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 314, "cpu_time_ms": 30, "memory_kb": 6144}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s502079104", "group_id": "codeNet:p02413", "input_text": "\nm,n = gets.split.map(&:to_i)\nmat = []\n\nfor i in 1..m\ntemp = gets.split.map(&:to_i)\ntemp.push(temp.inject(:+))\nmat.push(temp)\nputs temp.join(\" \")\nend\n\ntemp = []\nfor i in 0..n\n\nsum = 0\nfor j in 0..(m-1)\nsum += mat[j][i]\nend\n\ntemp.push(sum)\n\nend\n\nputs temp.join(\" \")\n\n\n", "language": "Ruby", "metadata": {"date": 1516926917, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02413.html", "problem_id": "p02413", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02413/input.txt", "sample_output_relpath": "derived/input_output/data/p02413/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02413/Ruby/s502079104.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s502079104", "user_id": "u350127362"}, "prompt_components": {"gold_output": "1 1 3 4 5 14\n2 2 2 4 5 15\n3 3 0 1 1 8\n2 3 4 4 6 19\n8 9 9 13 17 56\n", "input_to_evaluate": "\nm,n = gets.split.map(&:to_i)\nmat = []\n\nfor i in 1..m\ntemp = gets.split.map(&:to_i)\ntemp.push(temp.inject(:+))\nmat.push(temp)\nputs temp.join(\" \")\nend\n\ntemp = []\nfor i in 0..n\n\nsum = 0\nfor j in 0..(m-1)\nsum += mat[j][i]\nend\n\ntemp.push(sum)\n\nend\n\nputs temp.join(\" \")\n\n\n", "problem_context": "Spreadsheet\n\nYour task is to perform a simple table calculation.\n\nWrite a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.\n\nInput\n\nIn the first line, two integers r and c are given. Next, the table is given by r lines, each of which consists of c integers separated by space characters.\n\nOutput\n\nPrint the new table of (r+1) × (c+1) elements. Put a single space character between adjacent elements. For each row, print the sum of it's elements in the last column. For each column, print the sum of it's elements in the last row. Print the total sum of the elements at the bottom right corner of the table.\n\nConstraints\n\n1 ≤ r, c ≤ 100\n\n0 ≤ an element of the table ≤ 100\n\nSample Input\n\n4 5\n1 1 3 4 5\n2 2 2 4 5\n3 3 0 1 1\n2 3 4 4 6\n\nSample Output\n\n1 1 3 4 5 14\n2 2 2 4 5 15\n3 3 0 1 1 8\n2 3 4 4 6 19\n8 9 9 13 17 56", "sample_input": "4 5\n1 1 3 4 5\n2 2 2 4 5\n3 3 0 1 1\n2 3 4 4 6\n"}, "reference_outputs": ["1 1 3 4 5 14\n2 2 2 4 5 15\n3 3 0 1 1 8\n2 3 4 4 6 19\n8 9 9 13 17 56\n"], "source_document_id": "p02413", "source_text": "Spreadsheet\n\nYour task is to perform a simple table calculation.\n\nWrite a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.\n\nInput\n\nIn the first line, two integers r and c are given. Next, the table is given by r lines, each of which consists of c integers separated by space characters.\n\nOutput\n\nPrint the new table of (r+1) × (c+1) elements. Put a single space character between adjacent elements. For each row, print the sum of it's elements in the last column. For each column, print the sum of it's elements in the last row. Print the total sum of the elements at the bottom right corner of the table.\n\nConstraints\n\n1 ≤ r, c ≤ 100\n\n0 ≤ an element of the table ≤ 100\n\nSample Input\n\n4 5\n1 1 3 4 5\n2 2 2 4 5\n3 3 0 1 1\n2 3 4 4 6\n\nSample Output\n\n1 1 3 4 5 14\n2 2 2 4 5 15\n3 3 0 1 1 8\n2 3 4 4 6 19\n8 9 9 13 17 56", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 267, "cpu_time_ms": 50, "memory_kb": 7028}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s219768727", "group_id": "codeNet:p02415", "input_text": "puts gets.swapcase", "language": "Ruby", "metadata": {"date": 1424492274, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02415.html", "problem_id": "p02415", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02415/input.txt", "sample_output_relpath": "derived/input_output/data/p02415/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02415/Ruby/s219768727.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s219768727", "user_id": "u469420895"}, "prompt_components": {"gold_output": "Fair, later, occasionally cloudy.\n", "input_to_evaluate": "puts gets.swapcase", "problem_context": "Toggling Cases\n\nWrite a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.\n\nInput\n\nA string is given in a line.\n\nOutput\n\nPrint the converted string in a line. Note that you do not need to convert any characters other than alphabetical letters.\n\nConstraints\n\nThe length of the input string < 1200\n\nSample Input\n\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output\n\nFair, later, occasionally cloudy.", "sample_input": "fAIR, LATER, OCCASIONALLY CLOUDY.\n"}, "reference_outputs": ["Fair, later, occasionally cloudy.\n"], "source_document_id": "p02415", "source_text": "Toggling Cases\n\nWrite a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.\n\nInput\n\nA string is given in a line.\n\nOutput\n\nPrint the converted string in a line. Note that you do not need to convert any characters other than alphabetical letters.\n\nConstraints\n\nThe length of the input string < 1200\n\nSample Input\n\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output\n\nFair, later, occasionally cloudy.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 18, "cpu_time_ms": 20, "memory_kb": 6092}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s829214521", "group_id": "codeNet:p02415", "input_text": "s = gets.to_s\nputs s.swapcase\n", "language": "Ruby", "metadata": {"date": 1590640378, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02415.html", "problem_id": "p02415", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02415/input.txt", "sample_output_relpath": "derived/input_output/data/p02415/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02415/Ruby/s829214521.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s829214521", "user_id": "u436040876"}, "prompt_components": {"gold_output": "Fair, later, occasionally cloudy.\n", "input_to_evaluate": "s = gets.to_s\nputs s.swapcase\n", "problem_context": "Toggling Cases\n\nWrite a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.\n\nInput\n\nA string is given in a line.\n\nOutput\n\nPrint the converted string in a line. Note that you do not need to convert any characters other than alphabetical letters.\n\nConstraints\n\nThe length of the input string < 1200\n\nSample Input\n\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output\n\nFair, later, occasionally cloudy.", "sample_input": "fAIR, LATER, OCCASIONALLY CLOUDY.\n"}, "reference_outputs": ["Fair, later, occasionally cloudy.\n"], "source_document_id": "p02415", "source_text": "Toggling Cases\n\nWrite a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.\n\nInput\n\nA string is given in a line.\n\nOutput\n\nPrint the converted string in a line. Note that you do not need to convert any characters other than alphabetical letters.\n\nConstraints\n\nThe length of the input string < 1200\n\nSample Input\n\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output\n\nFair, later, occasionally cloudy.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 30, "cpu_time_ms": 40, "memory_kb": 6872}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s067418498", "group_id": "codeNet:p02416", "input_text": "while (n = gets.to_i) != 0\n c = 0\n while n > 0\n c += n%10\n n /= 10\n end\n puts c\nend\n\n", "language": "Ruby", "metadata": {"date": 1561003114, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02416.html", "problem_id": "p02416", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02416/input.txt", "sample_output_relpath": "derived/input_output/data/p02416/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02416/Ruby/s067418498.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s067418498", "user_id": "u842141906"}, "prompt_components": {"gold_output": "6\n10\n1\n", "input_to_evaluate": "while (n = gets.to_i) != 0\n c = 0\n while n > 0\n c += n%10\n n /= 10\n end\n puts c\nend\n\n", "problem_context": "Sum of Numbers\n\nWrite a program which reads an integer and prints sum of its digits.\n\nInput\n\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.\n\nThe input ends with a line including single zero. Your program should not process for this terminal symbol.\n\nOutput\n\nFor each dataset, print the sum of digits in x.\n\nSample Input\n\n123\n55\n1000\n0\n\nSample Output\n\n6\n10\n1", "sample_input": "123\n55\n1000\n0\n"}, "reference_outputs": ["6\n10\n1\n"], "source_document_id": "p02416", "source_text": "Sum of Numbers\n\nWrite a program which reads an integer and prints sum of its digits.\n\nInput\n\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.\n\nThe input ends with a line including single zero. Your program should not process for this terminal symbol.\n\nOutput\n\nFor each dataset, print the sum of digits in x.\n\nSample Input\n\n123\n55\n1000\n0\n\nSample Output\n\n6\n10\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 95, "cpu_time_ms": 50, "memory_kb": 7568}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s068872693", "group_id": "codeNet:p02417", "input_text": "#入力した文書の中にアルファベット数字をいくつはいっているかをわかるプログラム\ntext = gets(\"\").downcase #テキストに小文字をとる\n\nfor alphabet in \"a\"..\"z\" #sをA から Zまで26回繰り返す\n puts \"#{alphabet} : #{text.count(alphabet)}\" #まずAからZまで繰り返して テキストの中のアルファベットをカウントする\nend\n", "language": "Ruby", "metadata": {"date": 1559541810, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s068872693.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s068872693", "user_id": "u156659396"}, "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": "#入力した文書の中にアルファベット数字をいくつはいっているかをわかるプログラム\ntext = gets(\"\").downcase #テキストに小文字をとる\n\nfor alphabet in \"a\"..\"z\" #sをA から Zまで26回繰り返す\n puts \"#{alphabet} : #{text.count(alphabet)}\" #まずAからZまで繰り返して テキストの中のアルファベットをカウントする\nend\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": 419, "cpu_time_ms": 50, "memory_kb": 6876}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s501127659", "group_id": "codeNet:p02418", "input_text": "puts (gets.chop*2).include?(gets.chop)?\"Yes\":\"No\"", "language": "Ruby", "metadata": {"date": 1481191408, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s501127659.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s501127659", "user_id": "u712035986"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "puts (gets.chop*2).include?(gets.chop)?\"Yes\":\"No\"", "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": 49, "cpu_time_ms": 40, "memory_kb": 8600}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s476106991", "group_id": "codeNet:p02422", "input_text": "str = gets.chomp!\nn = gets.to_i\nn.times do \n p,a,b,c= gets.split\n a = a.to_i \n b = b.to_i\n if p == \"print\"\n puts str[a..b]\n elsif p == \"reverse\"\n str[a..b] = str[a..b].reverse\n else \n str[a..b] = c\n end\nend\n\n", "language": "Ruby", "metadata": {"date": 1567953337, "filename_ext": "rb", "original_language": "Ruby", "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/Ruby/s476106991.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s476106991", "user_id": "u442163409"}, "prompt_components": {"gold_output": "xaze\n", "input_to_evaluate": "str = gets.chomp!\nn = gets.to_i\nn.times do \n p,a,b,c= gets.split\n a = a.to_i \n b = b.to_i\n if p == \"print\"\n puts str[a..b]\n elsif p == \"reverse\"\n str[a..b] = str[a..b].reverse\n else \n str[a..b] = c\n end\nend\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": 251, "cpu_time_ms": 40, "memory_kb": 6916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s761959668", "group_id": "codeNet:p02464", "input_text": "n = gets.to_i\narray_1 = gets.split(\" \").map(&:to_i)\nm = gets.to_i\narray_2 = gets.split(\" \").map(&:to_i)\nputs (array_1 & array_2).sort.join(\"\\n\") if (array_1 & array_2).size > 0\n", "language": "Ruby", "metadata": {"date": 1553666243, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02464.html", "problem_id": "p02464", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02464/input.txt", "sample_output_relpath": "derived/input_output/data/p02464/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02464/Ruby/s761959668.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s761959668", "user_id": "u842341540"}, "prompt_components": {"gold_output": "2\n5\n", "input_to_evaluate": "n = gets.to_i\narray_1 = gets.split(\" \").map(&:to_i)\nm = gets.to_i\narray_2 = gets.split(\" \").map(&:to_i)\nputs (array_1 & array_2).sort.join(\"\\n\") if (array_1 & array_2).size > 0\n", "problem_context": "Set Intersection\n\nFind the intersection of two sets $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and $B = \\{b_0, b_1, ..., b_{m-1}\\}$.\n\nInput\n\nThe input is given in the following format.\n\n$n$\n$a_0 \\; a_1 \\; ... \\; a_{n-1}$\n$m$\n$b_0 \\; b_1 \\; ... \\; b_{m-1}$\n\nElements of $A$ and $B$ are given in ascending order respectively. There are no duplicate elements in each set.\n\nOutput\n\nPrint elements in the intersection in ascending order. Print an element in a line.\n\nConstraints\n\n$1 \\leq n, m \\leq 200,000$\n\n$0 \\leq a_0 < a_1 < ... < a_{n-1} \\leq 10^9$\n\n$0 \\leq b_0 < b_1 < ... < b_{m-1} \\leq 10^9$\n\nSample Input 1\n\n4\n1 2 5 8\n5\n2 3 5 9 11\n\nSample Output 1\n\n2\n5", "sample_input": "4\n1 2 5 8\n5\n2 3 5 9 11\n"}, "reference_outputs": ["2\n5\n"], "source_document_id": "p02464", "source_text": "Set Intersection\n\nFind the intersection of two sets $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and $B = \\{b_0, b_1, ..., b_{m-1}\\}$.\n\nInput\n\nThe input is given in the following format.\n\n$n$\n$a_0 \\; a_1 \\; ... \\; a_{n-1}$\n$m$\n$b_0 \\; b_1 \\; ... \\; b_{m-1}$\n\nElements of $A$ and $B$ are given in ascending order respectively. There are no duplicate elements in each set.\n\nOutput\n\nPrint elements in the intersection in ascending order. Print an element in a line.\n\nConstraints\n\n$1 \\leq n, m \\leq 200,000$\n\n$0 \\leq a_0 < a_1 < ... < a_{n-1} \\leq 10^9$\n\n$0 \\leq b_0 < b_1 < ... < b_{m-1} \\leq 10^9$\n\nSample Input 1\n\n4\n1 2 5 8\n5\n2 3 5 9 11\n\nSample Output 1\n\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": 177, "cpu_time_ms": 190, "memory_kb": 48384}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s303619173", "group_id": "codeNet:p02467", "input_text": "def is_prime?(num)\n $primes = []\n return true if num == 2\n return false if num % 2 == 0\n $primes.each do |n|\n return false if num % n == 0\n end\n $primes << num\n return true\nend\n\nn = gets.chomp.to_i\nnn = n\nsub_n = 2\nprime_factors = []\nwhile n > 1\n\tif n % sub_n == 0\n n /= sub_n\n\t prime_factors << sub_n\n\t next\n\telse\n break if sub_n * sub_n > n\n if sub_n == 2\n sub_n += 1\n else\n sub_n += 2\n while !is_prime?(sub_n)\n sub_n += 2\n end\n end\n\tend\nend\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \nstr = \"#{nn}:\"\nprime_factors.each do |k|\n\tstr += \" #{k}\"\nend\nif n == nn\n str << \" #{nn}\"\nend\nputs str", "language": "Ruby", "metadata": {"date": 1507283729, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02467.html", "problem_id": "p02467", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02467/input.txt", "sample_output_relpath": "derived/input_output/data/p02467/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02467/Ruby/s303619173.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s303619173", "user_id": "u720435069"}, "prompt_components": {"gold_output": "12: 2 2 3\n", "input_to_evaluate": "def is_prime?(num)\n $primes = []\n return true if num == 2\n return false if num % 2 == 0\n $primes.each do |n|\n return false if num % n == 0\n end\n $primes << num\n return true\nend\n\nn = gets.chomp.to_i\nnn = n\nsub_n = 2\nprime_factors = []\nwhile n > 1\n\tif n % sub_n == 0\n n /= sub_n\n\t prime_factors << sub_n\n\t next\n\telse\n break if sub_n * sub_n > n\n if sub_n == 2\n sub_n += 1\n else\n sub_n += 2\n while !is_prime?(sub_n)\n sub_n += 2\n end\n end\n\tend\nend\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \nstr = \"#{nn}:\"\nprime_factors.each do |k|\n\tstr += \" #{k}\"\nend\nif n == nn\n str << \" #{nn}\"\nend\nputs str", "problem_context": "Prime Factorization\n\nFactorize a given integer n.\n\nInput\n\nn\n\nAn integer n is given in a line.\n\nOutput\n\nPrint the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a space before each prime factor.\n\nConstraints\n\n2 ≤ n ≤ 109\n\nSample Input 1\n\n12\n\nSample Output 1\n\n12: 2 2 3\n\nSample Input 2\n\n126\n\nSample Output 2\n\n126: 2 3 3 7", "sample_input": "12\n"}, "reference_outputs": ["12: 2 2 3\n"], "source_document_id": "p02467", "source_text": "Prime Factorization\n\nFactorize a given integer n.\n\nInput\n\nn\n\nAn integer n is given in a line.\n\nOutput\n\nPrint the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a space before each prime factor.\n\nConstraints\n\n2 ≤ n ≤ 109\n\nSample Input 1\n\n12\n\nSample Output 1\n\n12: 2 2 3\n\nSample Input 2\n\n126\n\nSample Output 2\n\n126: 2 3 3 7", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 659, "cpu_time_ms": 40, "memory_kb": 8660}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s934550525", "group_id": "codeNet:p02472", "input_text": "require \"bigdecimal\"\na, b = gets.split.map { |x| BigDecimal(x) }\nputs (a + b).floor\n\n", "language": "Ruby", "metadata": {"date": 1552310344, "filename_ext": "rb", "original_language": "Ruby", "problem_description_relpath": "problem_descriptions/p02472.html", "problem_id": "p02472", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02472/input.txt", "sample_output_relpath": "derived/input_output/data/p02472/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02472/Ruby/s934550525.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s934550525", "user_id": "u931215000"}, "prompt_components": {"gold_output": "13\n", "input_to_evaluate": "require \"bigdecimal\"\na, b = gets.split.map { |x| BigDecimal(x) }\nputs (a + b).floor\n\n", "problem_context": "Addition of Big Integers\n\nGiven two integers $A$ and $B$, compute the sum, $A + B$.\n\nInput\n\nTwo integers $A$ and $B$ separated by a space character are given in a line.\n\nOutput\n\nPrint the sum in a line.\n\nConstraints\n\n$-1 \\times 10^{100000} \\leq A, B \\leq 10^{100000}$\n\nSample Input 1\n\n5 8\n\nSample Output 1\n\n13\n\nSample Input 2\n\n100 25\n\nSample Output 2\n\n125\n\nSample Input 3\n\n-1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n12 -3\n\nSample Output 4\n\n9", "sample_input": "5 8\n"}, "reference_outputs": ["13\n"], "source_document_id": "p02472", "source_text": "Addition of Big Integers\n\nGiven two integers $A$ and $B$, compute the sum, $A + B$.\n\nInput\n\nTwo integers $A$ and $B$ separated by a space character are given in a line.\n\nOutput\n\nPrint the sum in a line.\n\nConstraints\n\n$-1 \\times 10^{100000} \\leq A, B \\leq 10^{100000}$\n\nSample Input 1\n\n5 8\n\nSample Output 1\n\n13\n\nSample Input 2\n\n100 25\n\nSample Output 2\n\n125\n\nSample Input 3\n\n-1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n12 -3\n\nSample Output 4\n\n9", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 85, "cpu_time_ms": 40, "memory_kb": 8416}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s404321826", "group_id": "codeNet:p02547", "input_text": "n = gets.to_i\ni = 0\nn.times do\n a, b = gets.split(\" \").map(&:to_i)\n if a == b\n i += 1\n else\n i = 0\n end\n break if i == 3\nend\n\nputs (i == 3 ? \"Yes\" : \"No\")\n", "language": "Ruby", "metadata": {"date": 1600546414, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s404321826.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s404321826", "user_id": "u295003004"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "n = gets.to_i\ni = 0\nn.times do\n a, b = gets.split(\" \").map(&:to_i)\n if a == b\n i += 1\n else\n i = 0\n end\n break if i == 3\nend\n\nputs (i == 3 ? \"Yes\" : \"No\")\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTak performed the following action N times: rolling two dice.\nThe result of the i-th roll is D_{i,1} and D_{i,2}.\n\nCheck if doublets occurred at least three times in a row.\nSpecifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1\\leq D_{i,j} \\leq 6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_{1,1} D_{1,2}\n\\vdots\nD_{N,1} D_{N,2}\n\nOutput\n\nPrint Yes if doublets occurred at least three times in a row. Print No otherwise.\n\nSample Input 1\n\n5\n1 2\n6 6\n4 4\n3 3\n3 2\n\nSample Output 1\n\nYes\n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\nSample Input 2\n\n5\n1 1\n2 2\n3 4\n5 5\n6 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n\nSample Output 3\n\nYes", "sample_input": "5\n1 2\n6 6\n4 4\n3 3\n3 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02547", "source_text": "Score : 200 points\n\nProblem Statement\n\nTak performed the following action N times: rolling two dice.\nThe result of the i-th roll is D_{i,1} and D_{i,2}.\n\nCheck if doublets occurred at least three times in a row.\nSpecifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1\\leq D_{i,j} \\leq 6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_{1,1} D_{1,2}\n\\vdots\nD_{N,1} D_{N,2}\n\nOutput\n\nPrint Yes if doublets occurred at least three times in a row. Print No otherwise.\n\nSample Input 1\n\n5\n1 2\n6 6\n4 4\n3 3\n3 2\n\nSample Output 1\n\nYes\n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\nSample Input 2\n\n5\n1 1\n2 2\n3 4\n5 5\n6 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 166, "cpu_time_ms": 69, "memory_kb": 14256}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s234094973", "group_id": "codeNet:p02548", "input_text": "def divisor(num)\n result = []\n i = 1\n while (i*i) <= num do\n remainder = num % i\n if remainder == 0\n result << i\n if i*i!=num\n result<<(num/i)\n end\n end\n i += 1\n end\n return result\nend\n \n \n \n@n=gets.to_i\ncount=0\n\nfor i in 1..@n-1\n v=@n-i\n count+=divisor(v).length\nend\np count\n", "language": "Ruby", "metadata": {"date": 1600544796, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02548.html", "problem_id": "p02548", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02548/input.txt", "sample_output_relpath": "derived/input_output/data/p02548/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02548/Ruby/s234094973.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s234094973", "user_id": "u590472228"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "def divisor(num)\n result = []\n i = 1\n while (i*i) <= num do\n remainder = num % i\n if remainder == 0\n result << i\n if i*i!=num\n result<<(num/i)\n end\n end\n i += 1\n end\n return result\nend\n \n \n \n@n=gets.to_i\ncount=0\n\nfor i in 1..@n-1\n v=@n-i\n count+=divisor(v).length\nend\np count\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer N.\nHow many tuples (A,B,C) of positive integers satisfy A \\times B + C = N?\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3\n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1).\n\nSample Input 2\n\n100\n\nSample Output 2\n\n473\n\nSample Input 3\n\n1000000\n\nSample Output 3\n\n13969985", "sample_input": "3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02548", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer N.\nHow many tuples (A,B,C) of positive integers satisfy A \\times B + C = N?\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3\n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1).\n\nSample Input 2\n\n100\n\nSample Output 2\n\n473\n\nSample Input 3\n\n1000000\n\nSample Output 3\n\n13969985", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 326, "cpu_time_ms": 2206, "memory_kb": 15916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s120105197", "group_id": "codeNet:p02550", "input_text": "n, x, m = gets.split(' ').map{|i| i.to_i}\n \nz = 0\na = x\nn.times do |i|\n z += a\n a = a ** 2 % m\n break if a == 0\n# puts \"#{i} : #{z}\" if i % 100 == 0\nend\nputs z\n", "language": "Ruby", "metadata": {"date": 1600543424, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02550.html", "problem_id": "p02550", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02550/input.txt", "sample_output_relpath": "derived/input_output/data/p02550/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02550/Ruby/s120105197.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s120105197", "user_id": "u743280321"}, "prompt_components": {"gold_output": "1369\n", "input_to_evaluate": "n, x, m = gets.split(' ').map{|i| i.to_i}\n \nz = 0\na = x\nn.times do |i|\n z += a\n a = a ** 2 % m\n break if a == 0\n# puts \"#{i} : #{z}\" if i % 100 == 0\nend\nputs z\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nLet us denote by f(x, m) the remainder of the Euclidean division of x by m.\n\nLet A be the sequence that is defined by the initial value A_1=X and the recurrence relation A_{n+1} = f(A_n^2, M).\nFind \\displaystyle{\\sum_{i=1}^N A_i}.\n\nConstraints\n\n1 \\leq N \\leq 10^{10}\n\n0 \\leq X < M \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X M\n\nOutput\n\nPrint \\displaystyle{\\sum_{i=1}^N A_i}.\n\nSample Input 1\n\n6 2 1001\n\nSample Output 1\n\n1369\n\nThe sequence A begins 2,4,16,256,471,620,\\ldots Therefore, the answer is 2+4+16+256+471+620=1369.\n\nSample Input 2\n\n1000 2 16\n\nSample Output 2\n\n6\n\nThe sequence A begins 2,4,0,0,\\ldots Therefore, the answer is 6.\n\nSample Input 3\n\n10000000000 10 99959\n\nSample Output 3\n\n492443256176507", "sample_input": "6 2 1001\n"}, "reference_outputs": ["1369\n"], "source_document_id": "p02550", "source_text": "Score : 500 points\n\nProblem Statement\n\nLet us denote by f(x, m) the remainder of the Euclidean division of x by m.\n\nLet A be the sequence that is defined by the initial value A_1=X and the recurrence relation A_{n+1} = f(A_n^2, M).\nFind \\displaystyle{\\sum_{i=1}^N A_i}.\n\nConstraints\n\n1 \\leq N \\leq 10^{10}\n\n0 \\leq X < M \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X M\n\nOutput\n\nPrint \\displaystyle{\\sum_{i=1}^N A_i}.\n\nSample Input 1\n\n6 2 1001\n\nSample Output 1\n\n1369\n\nThe sequence A begins 2,4,16,256,471,620,\\ldots Therefore, the answer is 2+4+16+256+471+620=1369.\n\nSample Input 2\n\n1000 2 16\n\nSample Output 2\n\n6\n\nThe sequence A begins 2,4,0,0,\\ldots Therefore, the answer is 6.\n\nSample Input 3\n\n10000000000 10 99959\n\nSample Output 3\n\n492443256176507", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 164, "cpu_time_ms": 2206, "memory_kb": 14432}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s996202960", "group_id": "codeNet:p02552", "input_text": "X = gets.to_i\n\n# $stdout = File.open(File::NULL, \"w\")\n\ndef main\n return (X + 1) % 2\nend\n\nSTDOUT.puts main\n", "language": "Ruby", "metadata": {"date": 1600023690, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s996202960.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s996202960", "user_id": "u447268473"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "X = gets.to_i\n\n# $stdout = File.open(File::NULL, \"w\")\n\ndef main\n return (X + 1) % 2\nend\n\nSTDOUT.puts main\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": 107, "cpu_time_ms": 78, "memory_kb": 14380}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s664977306", "group_id": "codeNet:p02552", "input_text": "puts gets.to_i == 0 ? 1 : 0", "language": "Ruby", "metadata": {"date": 1600023642, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s664977306.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s664977306", "user_id": "u966810027"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "puts gets.to_i == 0 ? 1 : 0", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer x that is greater than or equal to 0, and less than or equal to 1.\nOutput 1 if x is equal to 0, or 0 if x is equal to 1.\n\nConstraints\n\n0 \\leq x \\leq 1\n\nx is an integer\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint 1 if x is equal to 0, or 0 if x is equal to 1.\n\nSample Input 1\n\n1\n\nSample Output 1\n\n0\n\nSample Input 2\n\n0\n\nSample Output 2\n\n1", "sample_input": "1\n"}, "reference_outputs": ["0\n"], "source_document_id": "p02552", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer x that is greater than or equal to 0, and less than or equal to 1.\nOutput 1 if x is equal to 0, or 0 if x is equal to 1.\n\nConstraints\n\n0 \\leq x \\leq 1\n\nx is an integer\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint 1 if x is equal to 0, or 0 if x is equal to 1.\n\nSample Input 1\n\n1\n\nSample Output 1\n\n0\n\nSample Input 2\n\n0\n\nSample Output 2\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 27, "cpu_time_ms": 74, "memory_kb": 14432}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s724937301", "group_id": "codeNet:p02554", "input_text": "n = gets.to_i\ndp = Array.new(1)\n\ndp[0] = (10**n-2*9**n+8**n)%1000000007\n\np dp[0]", "language": "Ruby", "metadata": {"date": 1600281100, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02554.html", "problem_id": "p02554", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02554/input.txt", "sample_output_relpath": "derived/input_output/data/p02554/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02554/Ruby/s724937301.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s724937301", "user_id": "u757598068"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n = gets.to_i\ndp = Array.new(1)\n\ndp[0] = (10**n-2*9**n+8**n)%1000000007\n\np dp[0]", "problem_context": "Score : 300 points\n\nProblem Statement\n\nHow many integer sequences A_1,A_2,\\ldots,A_N of length N satisfy all of the following conditions?\n\n0 \\leq A_i \\leq 9\n\nThere exists some i such that A_i=0 holds.\n\nThere exists some i such that A_i=9 holds.\n\nThe answer can be very large, so output it modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer modulo 10^9 + 7.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n2\n\nTwo sequences \\{0,9\\} and \\{9,0\\} satisfy all conditions.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n869121\n\nSample Output 3\n\n2511445", "sample_input": "2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02554", "source_text": "Score : 300 points\n\nProblem Statement\n\nHow many integer sequences A_1,A_2,\\ldots,A_N of length N satisfy all of the following conditions?\n\n0 \\leq A_i \\leq 9\n\nThere exists some i such that A_i=0 holds.\n\nThere exists some i such that A_i=9 holds.\n\nThe answer can be very large, so output it modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer modulo 10^9 + 7.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n2\n\nTwo sequences \\{0,9\\} and \\{9,0\\} satisfy all conditions.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n869121\n\nSample Output 3\n\n2511445", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 80, "cpu_time_ms": 96, "memory_kb": 21672}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s849290025", "group_id": "codeNet:p02567", "input_text": "class SegTree\n def update(k); @d[k] = @op.call(@d[2 * k], @d[2 * k + 1]); end\n\n def initialize(v, e, &op)\n @n = v.size\n @log = (@n - 1).bit_length\n @size = 1 << @log\n @op = op\n\n @d = Array.new(2 * @size, e) # vector\n\n @n.times{|i| @d[@size + i] = v[i]}\n (@size - 1).downto(1) {|i| update(i)}\n end\n\n def set(pos, x)\n pos += @size\n @d[pos] = x\n 1.upto(@log) {|i| update(pos >> i)}\n end\n\n def get(pos); @d[pos + @size]; end\n\n def prod(l, r)\n sml = smr = @d[0]\n l += @size\n r += @size\n\n while l < r\n (sml = @op.call(sml, @d[l]); l += 1) if l[0] == 1\n smr = @op.call(@d[r -= 1], smr) if r[0] == 1\n l >>= 1\n r >>= 1\n end\n @op.call(sml, smr)\n end\n\n def all_prod; @d[1]; end\n\n def max_right(l, &f)\n return @n if l == @n\n l += @size\n sm = @d[0]\n\n loop do\n l >>= 1 while l[0] == 0\n x = @op.call(sm, @d[l])\n if !f.call(x)\n while l < @size\n l <<= 1\n x = @op.call(sm, @d[l])\n if f.call(x)\n sm = x\n l += 1\n end\n end\n return l - @size\n end\n \n sm = x\n l += 1\n break if (l & -l) == l\n end\n\n @n\n end\n \n def min_left(r, &f)\n return 0 if r == 0\n r += @size\n sm = @d[0]\n\n loop do\n r -= 1\n r >>= 1 while r > 1 && r[0] == 1\n x = @op.call(@d[r], sm)\n if !f.call(x)\n while r < @size\n r = 2 * r + 1\n x = @op.call(@d[r], sm)\n if f.call(x)\n sm = x\n r -= 1\n end\n end\n return r + 1 - @size\n end\n sm = x\n break if (r & -r) == r\n end\n\n 0\n end\nend\n\nn, q = gets.split.map(&:to_i)\nst = SegTree.new(gets.split.map(&:to_i), -1) {|ch1, ch2| ch1 > ch2 ? ch1 : ch2}\n\nq.times do\n t, x, y = gets.split.map(&:to_i)\n \n if t == 1\n st.set(x-1, y)\n elsif t == 2\n puts st.prod(x-1, y)\n else\n puts st.max_right(x-1){|v| v < y} + 1\n end\nend", "language": "Ruby", "metadata": {"date": 1599827188, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02567.html", "problem_id": "p02567", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02567/input.txt", "sample_output_relpath": "derived/input_output/data/p02567/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02567/Ruby/s849290025.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s849290025", "user_id": "u692254521"}, "prompt_components": {"gold_output": "3\n3\n2\n6\n", "input_to_evaluate": "class SegTree\n def update(k); @d[k] = @op.call(@d[2 * k], @d[2 * k + 1]); end\n\n def initialize(v, e, &op)\n @n = v.size\n @log = (@n - 1).bit_length\n @size = 1 << @log\n @op = op\n\n @d = Array.new(2 * @size, e) # vector\n\n @n.times{|i| @d[@size + i] = v[i]}\n (@size - 1).downto(1) {|i| update(i)}\n end\n\n def set(pos, x)\n pos += @size\n @d[pos] = x\n 1.upto(@log) {|i| update(pos >> i)}\n end\n\n def get(pos); @d[pos + @size]; end\n\n def prod(l, r)\n sml = smr = @d[0]\n l += @size\n r += @size\n\n while l < r\n (sml = @op.call(sml, @d[l]); l += 1) if l[0] == 1\n smr = @op.call(@d[r -= 1], smr) if r[0] == 1\n l >>= 1\n r >>= 1\n end\n @op.call(sml, smr)\n end\n\n def all_prod; @d[1]; end\n\n def max_right(l, &f)\n return @n if l == @n\n l += @size\n sm = @d[0]\n\n loop do\n l >>= 1 while l[0] == 0\n x = @op.call(sm, @d[l])\n if !f.call(x)\n while l < @size\n l <<= 1\n x = @op.call(sm, @d[l])\n if f.call(x)\n sm = x\n l += 1\n end\n end\n return l - @size\n end\n \n sm = x\n l += 1\n break if (l & -l) == l\n end\n\n @n\n end\n \n def min_left(r, &f)\n return 0 if r == 0\n r += @size\n sm = @d[0]\n\n loop do\n r -= 1\n r >>= 1 while r > 1 && r[0] == 1\n x = @op.call(@d[r], sm)\n if !f.call(x)\n while r < @size\n r = 2 * r + 1\n x = @op.call(@d[r], sm)\n if f.call(x)\n sm = x\n r -= 1\n end\n end\n return r + 1 - @size\n end\n sm = x\n break if (r & -r) == r\n end\n\n 0\n end\nend\n\nn, q = gets.split.map(&:to_i)\nst = SegTree.new(gets.split.map(&:to_i), -1) {|ch1, ch2| ch1 > ch2 ? ch1 : ch2}\n\nq.times do\n t, x, y = gets.split.map(&:to_i)\n \n if t == 1\n st.set(x-1, y)\n elsif t == 2\n puts st.prod(x-1, y)\n else\n puts st.max_right(x-1){|v| v < y} + 1\n end\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given an array a_0, a_1, ..., a_{N-1} of length N. Process Q queries of the following types.\n\nThe type of i-th query is represented by T_i.\n\nT_i=1: You are given two integers X_i,V_i. Replace the value of A_{X_i} with V_i.\n\nT_i=2: You are given two integers L_i,R_i. Calculate the maximum value among A_{L_i},A_{L_i+1},\\cdots,A_{R_i}.\n\nT_i=3: You are given two integers X_i,V_i. Calculate the minimum j such that X_i \\leq j \\leq N, V_i \\leq A_j. If there is no such j, answer j=N+1 instead.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_i \\leq 10^9\n\n1 \\leq Q \\leq 2 \\times 10^5\n\n1 \\leq T_i \\leq 3\n\n1 \\leq X_i \\leq N, 0 \\leq V_i \\leq 10^9 (T_i=1,3)\n\n1 \\leq L_i \\leq R_i \\leq N (T_i=2)\n\nAll values in Input are integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nA_1 A_2 \\cdots A_N\nFirst query\nSecond query\n\\vdots\nQ-th query\n\nEach query is given in the following format:\n\nIf T_i=1,3,\n\nT_i X_i V_i\n\nIf T_i=2,\n\nT_i L_i R_i\n\nOutput\n\nFor each query with T_i=2, 3, print the answer.\n\nSample Input 1\n\n5 5\n1 2 3 2 1\n2 1 5\n3 2 3\n1 3 1\n2 2 4\n3 1 3\n\nSample Output 1\n\n3\n3\n2\n6\n\nFirst query: Print 3, which is the maximum of (A_1,A_2,A_3,A_4,A_5)=(1,2,3,2,1).\n\nSecond query: Since 3>A_2, j=2 does not satisfy the condition.Since 3 \\leq A_3, print j=3.\n\nThird query: Replace the value of A_3 with 1. It becomes A=(1,2,1,2,1).\n\nFourth query: Print 2, which is the maximum of (A_2,A_3,A_4)=(2,1,2).\n\nFifth query: Since there is no j that satisfies the condition, print j=N+1=6.", "sample_input": "5 5\n1 2 3 2 1\n2 1 5\n3 2 3\n1 3 1\n2 2 4\n3 1 3\n"}, "reference_outputs": ["3\n3\n2\n6\n"], "source_document_id": "p02567", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given an array a_0, a_1, ..., a_{N-1} of length N. Process Q queries of the following types.\n\nThe type of i-th query is represented by T_i.\n\nT_i=1: You are given two integers X_i,V_i. Replace the value of A_{X_i} with V_i.\n\nT_i=2: You are given two integers L_i,R_i. Calculate the maximum value among A_{L_i},A_{L_i+1},\\cdots,A_{R_i}.\n\nT_i=3: You are given two integers X_i,V_i. Calculate the minimum j such that X_i \\leq j \\leq N, V_i \\leq A_j. If there is no such j, answer j=N+1 instead.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_i \\leq 10^9\n\n1 \\leq Q \\leq 2 \\times 10^5\n\n1 \\leq T_i \\leq 3\n\n1 \\leq X_i \\leq N, 0 \\leq V_i \\leq 10^9 (T_i=1,3)\n\n1 \\leq L_i \\leq R_i \\leq N (T_i=2)\n\nAll values in Input are integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nA_1 A_2 \\cdots A_N\nFirst query\nSecond query\n\\vdots\nQ-th query\n\nEach query is given in the following format:\n\nIf T_i=1,3,\n\nT_i X_i V_i\n\nIf T_i=2,\n\nT_i L_i R_i\n\nOutput\n\nFor each query with T_i=2, 3, print the answer.\n\nSample Input 1\n\n5 5\n1 2 3 2 1\n2 1 5\n3 2 3\n1 3 1\n2 2 4\n3 1 3\n\nSample Output 1\n\n3\n3\n2\n6\n\nFirst query: Print 3, which is the maximum of (A_1,A_2,A_3,A_4,A_5)=(1,2,3,2,1).\n\nSecond query: Since 3>A_2, j=2 does not satisfy the condition.Since 3 \\leq A_3, print j=3.\n\nThird query: Replace the value of A_3 with 1. It becomes A=(1,2,1,2,1).\n\nFourth query: Print 2, which is the maximum of (A_2,A_3,A_4)=(2,1,2).\n\nFifth query: Since there is no j that satisfies the condition, print j=N+1=6.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2410, "cpu_time_ms": 901, "memory_kb": 36740}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s959230165", "group_id": "codeNet:p02570", "input_text": "D, T, S = gets.split.map(&:to_i)\n\nputs T*S >= D ? 'Yes' : 'No'", "language": "Ruby", "metadata": {"date": 1598860759, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s959230165.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s959230165", "user_id": "u304198114"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "D, T, S = gets.split.map(&:to_i)\n\nputs T*S >= D ? 'Yes' : 'No'", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "sample_input": "1000 15 80\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02570", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 62, "cpu_time_ms": 70, "memory_kb": 14248}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s804706644", "group_id": "codeNet:p02571", "input_text": "s = gets.chomp.split(\"\")\nt = gets.chomp.split(\"\")\n\nmin = Float::INFINITY\n\n(0 .. s.size - t.size).each{ |i|\n\tcount = 0\n\t\n\tt.each_with_index{ |tt, j|\n\t\tif tt != s[i, t.size][j] then\n\t\t\tcount += 1\n\t\tend\n\t}\n\t\n\tif min > count then\n\t\tmin = count\n\tend\n}\n\nputs min\n", "language": "Ruby", "metadata": {"date": 1598729058, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02571.html", "problem_id": "p02571", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02571/input.txt", "sample_output_relpath": "derived/input_output/data/p02571/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02571/Ruby/s804706644.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s804706644", "user_id": "u874414087"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "s = gets.chomp.split(\"\")\nt = gets.chomp.split(\"\")\n\nmin = Float::INFINITY\n\n(0 .. s.size - t.size).each{ |i|\n\tcount = 0\n\t\n\tt.each_with_index{ |tt, j|\n\t\tif tt != s[i, t.size][j] then\n\t\t\tcount += 1\n\t\tend\n\t}\n\t\n\tif min > count then\n\t\tmin = count\n\tend\n}\n\nputs min\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are two strings S and T.\n\nLet us change some of the characters in S so that T will be a substring of S.\n\nAt least how many characters do we need to change?\n\nHere, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.\n\nConstraints\n\nThe lengths of S and T are each at least 1 and at most 1000.\n\nThe length of T is at most that of S.\n\nS and T consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the minimum number of characters in S that need to be changed.\n\nSample Input 1\n\ncabacc\nabc\n\nSample Output 1\n\n1\n\nFor example, changing the fourth character a in S to c will match the second through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one - is the minimum needed.\n\nSample Input 2\n\ncodeforces\natcoder\n\nSample Output 2\n\n6", "sample_input": "cabacc\nabc\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02571", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are two strings S and T.\n\nLet us change some of the characters in S so that T will be a substring of S.\n\nAt least how many characters do we need to change?\n\nHere, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.\n\nConstraints\n\nThe lengths of S and T are each at least 1 and at most 1000.\n\nThe length of T is at most that of S.\n\nS and T consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the minimum number of characters in S that need to be changed.\n\nSample Input 1\n\ncabacc\nabc\n\nSample Output 1\n\n1\n\nFor example, changing the fourth character a in S to c will match the second through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one - is the minimum needed.\n\nSample Input 2\n\ncodeforces\natcoder\n\nSample Output 2\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 257, "cpu_time_ms": 103, "memory_kb": 14380}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s745365194", "group_id": "codeNet:p02573", "input_text": "require \"set\"\nn,m = gets.chomp.split(\" \").map(&:to_i)\n\nhash = {}\nm.times do\n a,b = gets.chomp.split(\" \").map(&:to_i)\n a,b = b,a if b < a\n hash[a] ||= Set.new\n hash[a] << a\n hash[b] = hash[a]\n hash[b] << b\nend\n\nresult = 0\nhash.each do |k, v|\n result = v.length if v.length > result\nend\nputs result\n", "language": "Ruby", "metadata": {"date": 1598728969, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02573.html", "problem_id": "p02573", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02573/input.txt", "sample_output_relpath": "derived/input_output/data/p02573/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02573/Ruby/s745365194.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s745365194", "user_id": "u257668305"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "require \"set\"\nn,m = gets.chomp.split(\" \").map(&:to_i)\n\nhash = {}\nm.times do\n a,b = gets.chomp.split(\" \").map(&:to_i)\n a,b = b,a if b < a\n hash[a] ||= Set.new\n hash[a] << a\n hash[b] = hash[a]\n hash[b] << b\nend\n\nresult = 0\nhash.each do |k, v|\n result = v.length if v.length > result\nend\nputs result\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N persons called Person 1 through Person N.\n\nYou are given M facts that \"Person A_i and Person B_i are friends.\" The same fact may be given multiple times.\n\nIf X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts.\n\nTakahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group.\n\nAt least how many groups does he need to make?\n\nConstraints\n\n2 \\leq N \\leq 2\\times 10^5\n\n0 \\leq M \\leq 2\\times 10^5\n\n1\\leq A_i,B_i\\leq N\n\nA_i \\neq B_i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n\\vdots\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5 3\n1 2\n3 4\n5 1\n\nSample Output 1\n\n3\n\nDividing them into three groups such as \\{1,3\\}, \\{2,4\\}, and \\{5\\} achieves the goal.\n\nSample Input 2\n\n4 10\n1 2\n2 1\n1 2\n2 1\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n\nSample Output 2\n\n4\n\nSample Input 3\n\n10 4\n3 1\n4 1\n5 9\n2 6\n\nSample Output 3\n\n3", "sample_input": "5 3\n1 2\n3 4\n5 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02573", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N persons called Person 1 through Person N.\n\nYou are given M facts that \"Person A_i and Person B_i are friends.\" The same fact may be given multiple times.\n\nIf X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts.\n\nTakahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group.\n\nAt least how many groups does he need to make?\n\nConstraints\n\n2 \\leq N \\leq 2\\times 10^5\n\n0 \\leq M \\leq 2\\times 10^5\n\n1\\leq A_i,B_i\\leq N\n\nA_i \\neq B_i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n\\vdots\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5 3\n1 2\n3 4\n5 1\n\nSample Output 1\n\n3\n\nDividing them into three groups such as \\{1,3\\}, \\{2,4\\}, and \\{5\\} achieves the goal.\n\nSample Input 2\n\n4 10\n1 2\n2 1\n1 2\n2 1\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n\nSample Output 2\n\n4\n\nSample Input 3\n\n10 4\n3 1\n4 1\n5 9\n2 6\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 304, "cpu_time_ms": 581, "memory_kb": 73564}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s787636644", "group_id": "codeNet:p02577", "input_text": "n = gets.split(\"\").map(&:to_i)\nsum = 0\nn.each do |i|\n sum+=i\nend\nputs sum % 9 == 0 ? \"Yes\" : \"No\"", "language": "Ruby", "metadata": {"date": 1598123279, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s787636644.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s787636644", "user_id": "u514143079"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "n = gets.split(\"\").map(&:to_i)\nsum = 0\nn.each do |i|\n sum+=i\nend\nputs sum % 9 == 0 ? \"Yes\" : \"No\"", "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": 98, "cpu_time_ms": 123, "memory_kb": 26284}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s615542167", "group_id": "codeNet:p02578", "input_text": "gets\nm=s=t = 0\ngets.split.each {\n s += a = _1.to_i\n t += (m= a[i]\n ans += h-a[i]\n else\n h = a[i]\n end\nend\nputs ans", "language": "Ruby", "metadata": {"date": 1598123352, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02578.html", "problem_id": "p02578", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02578/input.txt", "sample_output_relpath": "derived/input_output/data/p02578/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02578/Ruby/s437109503.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s437109503", "user_id": "u326891688"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "n = gets.to_i\na = gets.split.map(&:to_i)\n\nans = 0\nh = a[0]\nfor i in 1..(n-1)\n if h >= a[i]\n ans += h-a[i]\n else\n h = a[i]\n end\nend\nputs ans", "problem_context": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "sample_input": "5\n2 1 5 4 3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02578", "source_text": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 148, "cpu_time_ms": 131, "memory_kb": 27924}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s722951235", "group_id": "codeNet:p02579", "input_text": "(H, W), (Ch, Cw), (Dh, Dw) = 3.times.map{gets.split.map(&:to_i)}\nSs = [\"\"] + readlines.map{\" \" + _1.strip} # 1-indexed\n\nmv = [[1, 0], [-1, 0], [0, 1], [0, -1]]\nwp = [*-2 .. 2].repeated_permutation(2).to_a - [[0, 0]] - mv\nq1, q2, c = [Ch, Cw], [], 0\nd = Array.new(H + 1){Array.new(W + 1, -1)}\nuntil q1.empty? && q2.empty?\n while !q1.empty?\n h, w = q1.shift(2)\n q2.append(h, w)\n mv.map{[_1 + h, _2 + w]}.each do |x, y|\n next if x < 1 || H < x || y < 1 || W < y || Ss[x][y] == '#' || d[x][y] >= 0\n d[x][y] = c\n q1.append(x, y)\n end\n end\n c += 1\n while !q2.empty?\n h, w = q2.shift(2)\n wp.map{[_1 + h, _2 + w]}.each do |x, y|\n next if x < 1 || H < x || y < 1 || W < y || Ss[x][y] == '#' || d[x][y] >= 0\n d[x][y] = c\n q1.append(x, y)\n end\n end\nend\nputs d[Dh][Dw]", "language": "Ruby", "metadata": {"date": 1598521305, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02579.html", "problem_id": "p02579", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02579/input.txt", "sample_output_relpath": "derived/input_output/data/p02579/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02579/Ruby/s722951235.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s722951235", "user_id": "u304198114"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "(H, W), (Ch, Cw), (Dh, Dw) = 3.times.map{gets.split.map(&:to_i)}\nSs = [\"\"] + readlines.map{\" \" + _1.strip} # 1-indexed\n\nmv = [[1, 0], [-1, 0], [0, 1], [0, -1]]\nwp = [*-2 .. 2].repeated_permutation(2).to_a - [[0, 0]] - mv\nq1, q2, c = [Ch, Cw], [], 0\nd = Array.new(H + 1){Array.new(W + 1, -1)}\nuntil q1.empty? && q2.empty?\n while !q1.empty?\n h, w = q1.shift(2)\n q2.append(h, w)\n mv.map{[_1 + h, _2 + w]}.each do |x, y|\n next if x < 1 || H < x || y < 1 || W < y || Ss[x][y] == '#' || d[x][y] >= 0\n d[x][y] = c\n q1.append(x, y)\n end\n end\n c += 1\n while !q2.empty?\n h, w = q2.shift(2)\n wp.map{[_1 + h, _2 + w]}.each do |x, y|\n next if x < 1 || H < x || y < 1 || W < y || Ss[x][y] == '#' || d[x][y] >= 0\n d[x][y] = c\n q1.append(x, y)\n end\n end\nend\nputs d[Dh][Dw]", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 813, "cpu_time_ms": 2206, "memory_kb": 25252}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s558124484", "group_id": "codeNet:p02579", "input_text": "H,W = gets.split.map(&:to_i)\nSY,SX = gets.split.map { _1.to_i - 1 }\nGY,GX = gets.split.map { _1.to_i - 1 }\nS = readlines.map { _1.chomp.chars }\n\nMV = [[1,0],[-1,0],[0,1],[0,-1]]\nWP = [*-2..2].product([*-2..2]) - [*MV, [0,0]]\n\ndist = Array.new(H) { [-1]*W }\nque = []\nque2 = []\nque.push([SY,SX])\ndist[SY][SX] = 0\nwhile !que.empty?\n \n y,x = que.pop\n d = dist[y][x]\n\n MV.each do |dy,dx|\n yy,xx = y+dy,x+dx\n next if yy < 0 || xx < 0 || H <= yy || W <= xx\n next if S[yy][xx] == \"#\"\n next if 0 <= dist[yy][xx] && dist[yy][xx] <= d\n dist[yy][xx] = d\n que.push([yy,xx])\n end\n \n WP.each do |dy,dx|\n yy,xx = y+dy,x+dx\n next if yy < 0 || xx < 0 || H <= yy || W <= xx\n next if S[yy][xx] == \"#\"\n next if 0 <= dist[yy][xx] && dist[yy][xx] <= d + 1\n dist[yy][xx] = d + 1\n que2.push([yy,xx])\n end\n \n if que.empty?\n break if dist[GY][GX] != -1\n que = que2\n que2 = []\n end\nend\n\nputs dist[GY][GX]\n", "language": "Ruby", "metadata": {"date": 1598476933, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02579.html", "problem_id": "p02579", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02579/input.txt", "sample_output_relpath": "derived/input_output/data/p02579/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02579/Ruby/s558124484.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s558124484", "user_id": "u064100484"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "H,W = gets.split.map(&:to_i)\nSY,SX = gets.split.map { _1.to_i - 1 }\nGY,GX = gets.split.map { _1.to_i - 1 }\nS = readlines.map { _1.chomp.chars }\n\nMV = [[1,0],[-1,0],[0,1],[0,-1]]\nWP = [*-2..2].product([*-2..2]) - [*MV, [0,0]]\n\ndist = Array.new(H) { [-1]*W }\nque = []\nque2 = []\nque.push([SY,SX])\ndist[SY][SX] = 0\nwhile !que.empty?\n \n y,x = que.pop\n d = dist[y][x]\n\n MV.each do |dy,dx|\n yy,xx = y+dy,x+dx\n next if yy < 0 || xx < 0 || H <= yy || W <= xx\n next if S[yy][xx] == \"#\"\n next if 0 <= dist[yy][xx] && dist[yy][xx] <= d\n dist[yy][xx] = d\n que.push([yy,xx])\n end\n \n WP.each do |dy,dx|\n yy,xx = y+dy,x+dx\n next if yy < 0 || xx < 0 || H <= yy || W <= xx\n next if S[yy][xx] == \"#\"\n next if 0 <= dist[yy][xx] && dist[yy][xx] <= d + 1\n dist[yy][xx] = d + 1\n que2.push([yy,xx])\n end\n \n if que.empty?\n break if dist[GY][GX] != -1\n que = que2\n que2 = []\n end\nend\n\nputs dist[GY][GX]\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 933, "cpu_time_ms": 2209, "memory_kb": 99020}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s139896086", "group_id": "codeNet:p02579", "input_text": "DY = [-1, 0, 1, 0]\nDX = [0, 1, 0, -1]\n\nH, W = gets.split.map(&:to_i)\nCH, CW = gets.split.map(&:to_i)\nDH, DW = gets.split.map(&:to_i)\nMAP = H.times.map { gets.chomp.chars }\n\nvisited = Array.new(H) { Array.new(W, false) }\nqueue = []\nqueue << [CH - 1, CW - 1, 0]\n\nuntil queue.empty?\n y, x, cost = queue.shift\n\n next if MAP[y][x] == '#'\n next if visited[y][x]\n visited[y][x] = true\n\n if DH - 1 == y && DW - 1 == x\n puts cost\n exit\n end\n\n 4.times do |i|\n ny = y + DY[i]\n nx = x + DX[i]\n\n next if ny < 0 || nx < 0 || H <= ny || W <= nx\n next if visited[ny][nx]\n\n queue.unshift([ny, nx, cost])\n end\n\n -2.upto(2) do |dy|\n -2.upto(2) do |dx|\n ny = y + dy\n nx = x + dx\n\n next if ny < 0 || nx < 0 || H <= ny || W <= nx\n next if visited[ny][nx]\n\n queue.push([ny, nx, cost + 1])\n end\n end\nend\n\nputs -1\n", "language": "Ruby", "metadata": {"date": 1598139802, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02579.html", "problem_id": "p02579", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02579/input.txt", "sample_output_relpath": "derived/input_output/data/p02579/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02579/Ruby/s139896086.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s139896086", "user_id": "u740836226"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "DY = [-1, 0, 1, 0]\nDX = [0, 1, 0, -1]\n\nH, W = gets.split.map(&:to_i)\nCH, CW = gets.split.map(&:to_i)\nDH, DW = gets.split.map(&:to_i)\nMAP = H.times.map { gets.chomp.chars }\n\nvisited = Array.new(H) { Array.new(W, false) }\nqueue = []\nqueue << [CH - 1, CW - 1, 0]\n\nuntil queue.empty?\n y, x, cost = queue.shift\n\n next if MAP[y][x] == '#'\n next if visited[y][x]\n visited[y][x] = true\n\n if DH - 1 == y && DW - 1 == x\n puts cost\n exit\n end\n\n 4.times do |i|\n ny = y + DY[i]\n nx = x + DX[i]\n\n next if ny < 0 || nx < 0 || H <= ny || W <= nx\n next if visited[ny][nx]\n\n queue.unshift([ny, nx, cost])\n end\n\n -2.upto(2) do |dy|\n -2.upto(2) do |dx|\n ny = y + dy\n nx = x + dx\n\n next if ny < 0 || nx < 0 || H <= ny || W <= nx\n next if visited[ny][nx]\n\n queue.push([ny, nx, cost + 1])\n end\n end\nend\n\nputs -1\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 851, "cpu_time_ms": 2209, "memory_kb": 126288}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s380834681", "group_id": "codeNet:p02579", "input_text": "H, W = gets.split.map(&:to_i)\nCh, Cw = gets.split.map(&:to_i)\nDh, Dw = gets.split.map(&:to_i)\nS = Array.new H + 2\nS[0] = Array.new(W+2, \"$\")\nH.times do |i|\n S[i+1] = [\"$\", *gets.chomp.split(''), \"$\"]\nend\nS[H+1] = Array.new(W+2, \"$\")\n\nres = 0\n\nfillq = [[Ch, Cw, 0]]\nwarpq = []\n\nwhile fillq[0] || warpq[0] do\n while(fq = fillq.shift) do\n h, w, d = *fq\n next if S[h][w].class == Integer\n if h == Dh && w == Dw\n puts d\n exit\n end\n S[h][w] = d\n [\n [h-1,w],\n [h+1,w],\n [h,w-1],\n [h,w+1]\n ].each do |_h, _w|\n t = S[_h][_w]\n if t == '.'\n fillq.push([_h,_w,d])\n end\n end\n warpq.push([h,w,d])\n end\n\n while wq = warpq.shift\n h,w,d = *wq\n [\n [h-2,w-2],\n [h-2,w-1],\n [h-2,w],\n [h-2,w+1],\n [h-2,w+2],\n [h-1,w-2],\n [h-1,w-1],\n [h-1,w+1],\n [h-1,w+2],\n [h,w-2],\n [h,w+2],\n [h+1,w-2],\n [h+1,w-1],\n [h+1,w+1],\n [h+1,w+2],\n [h+2,w-2],\n [h+2,w-1],\n [h+2,w],\n [h+2,w+1],\n [h+2,w+2]\n ].each do |_h,_w|\n next if _h < 1 || _w < 1 || _h > H || _w > W\n next unless S[_h][_w] == \".\"\n S[_h][_w] == \"..\"\n fillq.push([_h,_w,d+1])\n end\n end\nend\n\nputs -1", "language": "Ruby", "metadata": {"date": 1598131176, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02579.html", "problem_id": "p02579", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02579/input.txt", "sample_output_relpath": "derived/input_output/data/p02579/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02579/Ruby/s380834681.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s380834681", "user_id": "u299761130"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "H, W = gets.split.map(&:to_i)\nCh, Cw = gets.split.map(&:to_i)\nDh, Dw = gets.split.map(&:to_i)\nS = Array.new H + 2\nS[0] = Array.new(W+2, \"$\")\nH.times do |i|\n S[i+1] = [\"$\", *gets.chomp.split(''), \"$\"]\nend\nS[H+1] = Array.new(W+2, \"$\")\n\nres = 0\n\nfillq = [[Ch, Cw, 0]]\nwarpq = []\n\nwhile fillq[0] || warpq[0] do\n while(fq = fillq.shift) do\n h, w, d = *fq\n next if S[h][w].class == Integer\n if h == Dh && w == Dw\n puts d\n exit\n end\n S[h][w] = d\n [\n [h-1,w],\n [h+1,w],\n [h,w-1],\n [h,w+1]\n ].each do |_h, _w|\n t = S[_h][_w]\n if t == '.'\n fillq.push([_h,_w,d])\n end\n end\n warpq.push([h,w,d])\n end\n\n while wq = warpq.shift\n h,w,d = *wq\n [\n [h-2,w-2],\n [h-2,w-1],\n [h-2,w],\n [h-2,w+1],\n [h-2,w+2],\n [h-1,w-2],\n [h-1,w-1],\n [h-1,w+1],\n [h-1,w+2],\n [h,w-2],\n [h,w+2],\n [h+1,w-2],\n [h+1,w-1],\n [h+1,w+1],\n [h+1,w+2],\n [h+2,w-2],\n [h+2,w-1],\n [h+2,w],\n [h+2,w+1],\n [h+2,w+2]\n ].each do |_h,_w|\n next if _h < 1 || _w < 1 || _h > H || _w > W\n next unless S[_h][_w] == \".\"\n S[_h][_w] == \"..\"\n fillq.push([_h,_w,d+1])\n end\n end\nend\n\nputs -1", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1505, "cpu_time_ms": 2209, "memory_kb": 104760}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s447180375", "group_id": "codeNet:p02579", "input_text": "h, w = gets.split(' ').map(&:to_i)\nwi, wj = gets.split(' ').map(&:to_i)\ndi, dj = gets.split(' ').map(&:to_i)\n\nwi -= 1\nwj -= 1\ndi -= 1\ndj -= 1\n\nm = h.times.map { gets.chomp! }\n\nDS = [[-1, 0], [1, 0], [0, -1], [0, 1]]\n\nqueue = [[wi, wj, 0]]\nseen = { wi => { wj => true } }\nuntil queue.empty?\n ci, cj, cd = queue.shift\n if ci == di && cj == dj\n puts cd\n exit\n end\n\n DS.each do |dir|\n ni = ci + dir[0]\n nj = cj + dir[1]\n next if (! ((0 <= ni && ni < h) && (0 <= nj && nj < w))) || m[ni][nj] == '#'\n seen[ni] ||= {}\n next if seen[ni][nj]\n seen[ni][nj] = true\n queue.unshift([ni, nj, cd])\n end\n\n (-2..2).each do |pi|\n (-2..2).each do |pj|\n ni = ci + pi\n nj = cj + pj\n next if ni == ci && nj == ci\n next if (! ((0 <= ni && ni < h) && (0 <= nj && nj < w))) || m[ni][nj] == '#'\n seen[ni] ||= {}\n next if seen[ni][nj]\n seen[ni][nj] = true\n queue.push([ni, nj, cd + 1])\n end\n end\n \nend\n\nputs -1\n", "language": "Ruby", "metadata": {"date": 1598131139, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02579.html", "problem_id": "p02579", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02579/input.txt", "sample_output_relpath": "derived/input_output/data/p02579/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02579/Ruby/s447180375.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s447180375", "user_id": "u130813824"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "h, w = gets.split(' ').map(&:to_i)\nwi, wj = gets.split(' ').map(&:to_i)\ndi, dj = gets.split(' ').map(&:to_i)\n\nwi -= 1\nwj -= 1\ndi -= 1\ndj -= 1\n\nm = h.times.map { gets.chomp! }\n\nDS = [[-1, 0], [1, 0], [0, -1], [0, 1]]\n\nqueue = [[wi, wj, 0]]\nseen = { wi => { wj => true } }\nuntil queue.empty?\n ci, cj, cd = queue.shift\n if ci == di && cj == dj\n puts cd\n exit\n end\n\n DS.each do |dir|\n ni = ci + dir[0]\n nj = cj + dir[1]\n next if (! ((0 <= ni && ni < h) && (0 <= nj && nj < w))) || m[ni][nj] == '#'\n seen[ni] ||= {}\n next if seen[ni][nj]\n seen[ni][nj] = true\n queue.unshift([ni, nj, cd])\n end\n\n (-2..2).each do |pi|\n (-2..2).each do |pj|\n ni = ci + pi\n nj = cj + pj\n next if ni == ci && nj == ci\n next if (! ((0 <= ni && ni < h) && (0 <= nj && nj < w))) || m[ni][nj] == '#'\n seen[ni] ||= {}\n next if seen[ni][nj]\n seen[ni][nj] = true\n queue.push([ni, nj, cd + 1])\n end\n end\n \nend\n\nputs -1\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 965, "cpu_time_ms": 2206, "memory_kb": 24780}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s662613093", "group_id": "codeNet:p02584", "input_text": "def input_n\n gets.to_i # 単一整数\nend\n\ndef input_s\n gets.chomp # 文字列。chompを付けないと改行文字がついてくる\nend\n\ndef input_a\n gets.split.map(&:to_i) # スペースで区切られた複数の整数\nend\n\ndef input_o(num)\n num.times.map { gets.to_i } # 縦に並んだ複数の整数。たまにある\nend\n\ndef output_f(num)\n puts sprintf(\"%.12f\", num)\nend\n\nx, k, d = input_a\nif x.abs >= d * k\n if x >= 0\n x = x - (k * d)\n else\n x = x + (k * d)\n end\n puts x.abs\n exit\nelse\n tmp = x.abs / d\n if x >= 0\n x = x - (tmp * d)\n else\n x = x + (tmp * d)\n end\n k = k - tmp\nend\n\nxx = -1\nk.times do |i|\n if xx == x.abs\n if (k - i) % 2 == 1\n if x >= 0\n x = x - d\n else\n x = x + d\n end\n end\n break\n end\n if i % 2 == 0\n xx = x.abs\n end\n if x >= 0\n x = x - d\n else\n x = x + d\n end\nend\nputs x.abs\n", "language": "Ruby", "metadata": {"date": 1597522929, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s662613093.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s662613093", "user_id": "u876846619"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "def input_n\n gets.to_i # 単一整数\nend\n\ndef input_s\n gets.chomp # 文字列。chompを付けないと改行文字がついてくる\nend\n\ndef input_a\n gets.split.map(&:to_i) # スペースで区切られた複数の整数\nend\n\ndef input_o(num)\n num.times.map { gets.to_i } # 縦に並んだ複数の整数。たまにある\nend\n\ndef output_f(num)\n puts sprintf(\"%.12f\", num)\nend\n\nx, k, d = input_a\nif x.abs >= d * k\n if x >= 0\n x = x - (k * d)\n else\n x = x + (k * d)\n end\n puts x.abs\n exit\nelse\n tmp = x.abs / d\n if x >= 0\n x = x - (tmp * d)\n else\n x = x + (tmp * d)\n end\n k = k - tmp\nend\n\nxx = -1\nk.times do |i|\n if xx == x.abs\n if (k - i) % 2 == 1\n if x >= 0\n x = x - d\n else\n x = x + d\n end\n end\n break\n end\n if i % 2 == 0\n xx = x.abs\n end\n if x >= 0\n x = x - d\n else\n x = x + d\n end\nend\nputs x.abs\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": 914, "cpu_time_ms": 66, "memory_kb": 14160}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s611581826", "group_id": "codeNet:p02584", "input_text": "x, k, d = gets.split(\" \").map(&:to_i)\nif x.abs >= k * d\n puts x.abs - (k * d)\n exit\nend\nxx=0\nyy=1\nflag=false\nbefore_0 = x / d \nif (k - before_0) % 2 == 0\n puts (x - (before_0 * d)).abs\n flag=true\n yy+=1\nelse (k - before_0) % 2 != 0\n puts (x - (before_0 * d) - d).abs\n flag=false\n xx+=1\nend ", "language": "Ruby", "metadata": {"date": 1597522606, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s611581826.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s611581826", "user_id": "u713767919"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "x, k, d = gets.split(\" \").map(&:to_i)\nif x.abs >= k * d\n puts x.abs - (k * d)\n exit\nend\nxx=0\nyy=1\nflag=false\nbefore_0 = x / d \nif (k - before_0) % 2 == 0\n puts (x - (before_0 * d)).abs\n flag=true\n yy+=1\nelse (k - before_0) % 2 != 0\n puts (x - (before_0 * d) - d).abs\n flag=false\n xx+=1\nend ", "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": 299, "cpu_time_ms": 65, "memory_kb": 14316}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s513389421", "group_id": "codeNet:p02584", "input_text": "x, k, d = gets.split(\" \").map(&:to_i)\n\nabsx = x.abs\nr = absx / d\nif r > k\n puts absx - k * d\nelse\n absx = absx - r * d - ((k - r) % 2) * d \n puts absx.abs\nend", "language": "Ruby", "metadata": {"date": 1597520071, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s513389421.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s513389421", "user_id": "u771770008"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "x, k, d = gets.split(\" \").map(&:to_i)\n\nabsx = x.abs\nr = absx / d\nif r > k\n puts absx - k * d\nelse\n absx = absx - r * d - ((k - r) % 2) * d \n puts absx.abs\nend", "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": 161, "cpu_time_ms": 76, "memory_kb": 14364}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s580702187", "group_id": "codeNet:p02585", "input_text": "n,k = gets.chomp.split(' ').map(&:to_i)\nps = gets.chomp.split(' ').map(&:to_i)\ncs = gets.chomp.split(' ').map(&:to_i)\nans = -Float::INFINITY\n \nn.times do |i|\n now = i\n score = []\n total = 0\n while true\n now = ps[now] - 1\n score << cs[now]\n total += cs[now]\n if now == i\n break\n end\n end\n t = 0\n score.size.times do |i|\n t += score[i]\n sum = t\n if(i+1>k)\n break\n end\n if(total > 0)\n e = (k-(i+1))/(score.size)\n sum += e*total\n end\n ans = [ans,sum].max\n end\n\nend\nputs ans", "language": "Ruby", "metadata": {"date": 1597645243, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s580702187.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s580702187", "user_id": "u710018917"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "n,k = gets.chomp.split(' ').map(&:to_i)\nps = gets.chomp.split(' ').map(&:to_i)\ncs = gets.chomp.split(' ').map(&:to_i)\nans = -Float::INFINITY\n \nn.times do |i|\n now = i\n score = []\n total = 0\n while true\n now = ps[now] - 1\n score << cs[now]\n total += cs[now]\n if now == i\n break\n end\n end\n t = 0\n score.size.times do |i|\n t += score[i]\n sum = t\n if(i+1>k)\n break\n end\n if(total > 0)\n e = (k-(i+1))/(score.size)\n sum += e*total\n end\n ans = [ans,sum].max\n end\n\nend\nputs ans", "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": 621, "cpu_time_ms": 3310, "memory_kb": 101144}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s139193724", "group_id": "codeNet:p02585", "input_text": "# 5 2 n k\n# 2 4 5 1 3 p\n# 3 4 -10 -8 8 c\nn, k = gets.split.map(&:to_i)\narray_p = gets.split.map(&:to_i)\narray_c = gets.split.map(&:to_i)\n\nscore = -10**9\nn.times do |i|\n score_temp = -10**9\n score_temp_temp = 0\n next_p = 0\n k.times do |j|\n if j == 0\n score_temp_temp = array_c[i]\n next_p = array_p[i] - 1\n else\n score_temp_temp += array_c[next_p]\n next_p = array_p[next_p] - 1\n end\n score_temp = [score_temp, score_temp_temp].max\n end\n score = [score, score_temp].max\nend\n\nputs score\n\n", "language": "Ruby", "metadata": {"date": 1597594355, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s139193724.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s139193724", "user_id": "u859196277"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "# 5 2 n k\n# 2 4 5 1 3 p\n# 3 4 -10 -8 8 c\nn, k = gets.split.map(&:to_i)\narray_p = gets.split.map(&:to_i)\narray_c = gets.split.map(&:to_i)\n\nscore = -10**9\nn.times do |i|\n score_temp = -10**9\n score_temp_temp = 0\n next_p = 0\n k.times do |j|\n if j == 0\n score_temp_temp = array_c[i]\n next_p = array_p[i] - 1\n else\n score_temp_temp += array_c[next_p]\n next_p = array_p[next_p] - 1\n end\n score_temp = [score_temp, score_temp_temp].max\n end\n score = [score, score_temp].max\nend\n\nputs score\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": 537, "cpu_time_ms": 3308, "memory_kb": 14592}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s027761649", "group_id": "codeNet:p02586", "input_text": "R,C,K = gets.chomp.split(\" \").map(&:to_i)\nr,c,v = K.times.map{gets.split.map(&:to_i)}.transpose\nvalue = Array.new(R){Array.new(C,0)}\nK.times do |i|\n value[r[i]-1][c[i]-1] = v[i]\nend\ndp0 = Array.new(R){Array.new(C,0)}\ndp1 = Array.new(R){Array.new(C,0)}\ndp2 = Array.new(R){Array.new(C,0)}\ndp3 = Array.new(R){Array.new(C,0)}\ndp0[0][0] = 0\ndp1[0][0] = value[0][0]\nR.times do |i|\n C.times do |j|\n if j != C-1\n v = value[i][j+1]\n dp0[i][j+1] = dp0[i][j] if dp0[i][j+1] < dp0[i][j]\n dp1[i][j+1] = dp1[i][j] if dp1[i][j+1] < dp1[i][j]\n dp2[i][j+1] = dp2[i][j] if dp2[i][j+1] < dp2[i][j]\n dp3[i][j+1] = dp3[i][j] if dp3[i][j+1] < dp3[i][j]\n if v\n dp1[i][j+1] = dp0[i][j]+v if dp1[i][j+1] < dp0[i][j]+v\n dp2[i][j+1] = dp1[i][j]+v if dp2[i][j+1] < dp1[i][j]+v\n dp3[i][j+1] = dp2[i][j]+v if dp3[i][j+1] < dp2[i][j]+v\n end\n end\n if i != R-1\n v = value[i+1][j]\n dp0[i+1][j] = dp0[i][j] if dp0[i+1][j] < dp0[i][j]\n dp0[i+1][j] = dp1[i][j] if dp0[i+1][j] < dp1[i][j]\n dp0[i+1][j] = dp2[i][j] if dp0[i+1][j] < dp2[i][j]\n dp0[i+1][j] = dp3[i][j] if dp0[i+1][j] < dp3[i][j]\n if v\n dp1[i+1][j] = dp0[i][j]+v if dp1[i+1][j] < dp0[i][j]+v\n dp1[i+1][j] = dp1[i][j]+v if dp1[i+1][j] < dp1[i][j]+v\n dp1[i+1][j] = dp2[i][j]+v if dp1[i+1][j] < dp2[i][j]+v\n dp1[i+1][j] = dp3[i][j]+v if dp1[i+1][j] < dp3[i][j]+v\n end\n end\n end\nend\nputs [dp0[R-1][C-1],dp1[R-1][C-1],dp2[R-1][C-1],dp3[R-1][C-1]].max", "language": "Ruby", "metadata": {"date": 1597826663, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02586.html", "problem_id": "p02586", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02586/input.txt", "sample_output_relpath": "derived/input_output/data/p02586/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02586/Ruby/s027761649.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s027761649", "user_id": "u265679940"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "R,C,K = gets.chomp.split(\" \").map(&:to_i)\nr,c,v = K.times.map{gets.split.map(&:to_i)}.transpose\nvalue = Array.new(R){Array.new(C,0)}\nK.times do |i|\n value[r[i]-1][c[i]-1] = v[i]\nend\ndp0 = Array.new(R){Array.new(C,0)}\ndp1 = Array.new(R){Array.new(C,0)}\ndp2 = Array.new(R){Array.new(C,0)}\ndp3 = Array.new(R){Array.new(C,0)}\ndp0[0][0] = 0\ndp1[0][0] = value[0][0]\nR.times do |i|\n C.times do |j|\n if j != C-1\n v = value[i][j+1]\n dp0[i][j+1] = dp0[i][j] if dp0[i][j+1] < dp0[i][j]\n dp1[i][j+1] = dp1[i][j] if dp1[i][j+1] < dp1[i][j]\n dp2[i][j+1] = dp2[i][j] if dp2[i][j+1] < dp2[i][j]\n dp3[i][j+1] = dp3[i][j] if dp3[i][j+1] < dp3[i][j]\n if v\n dp1[i][j+1] = dp0[i][j]+v if dp1[i][j+1] < dp0[i][j]+v\n dp2[i][j+1] = dp1[i][j]+v if dp2[i][j+1] < dp1[i][j]+v\n dp3[i][j+1] = dp2[i][j]+v if dp3[i][j+1] < dp2[i][j]+v\n end\n end\n if i != R-1\n v = value[i+1][j]\n dp0[i+1][j] = dp0[i][j] if dp0[i+1][j] < dp0[i][j]\n dp0[i+1][j] = dp1[i][j] if dp0[i+1][j] < dp1[i][j]\n dp0[i+1][j] = dp2[i][j] if dp0[i+1][j] < dp2[i][j]\n dp0[i+1][j] = dp3[i][j] if dp0[i+1][j] < dp3[i][j]\n if v\n dp1[i+1][j] = dp0[i][j]+v if dp1[i+1][j] < dp0[i][j]+v\n dp1[i+1][j] = dp1[i][j]+v if dp1[i+1][j] < dp1[i][j]+v\n dp1[i+1][j] = dp2[i][j]+v if dp1[i+1][j] < dp2[i][j]+v\n dp1[i+1][j] = dp3[i][j]+v if dp1[i+1][j] < dp3[i][j]+v\n end\n end\n end\nend\nputs [dp0[R-1][C-1],dp1[R-1][C-1],dp2[R-1][C-1],dp3[R-1][C-1]].max", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \\leq i \\leq R) and the j-th column (1 \\leq j \\leq C). The i-th item is at (r_i, c_i) and has the value v_i.\n\nTakahashi will begin at (1, 1), the start, and get to (R, C), the goal. When he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a non-existent square).\n\nHe can pick up items on the squares he visits, including the start and the goal, but at most three for each row. It is allowed to ignore the item on a square he visits.\n\nFind the maximum possible sum of the values of items he picks up.\n\nConstraints\n\n1 \\leq R, C \\leq 3000\n\n1 \\leq K \\leq \\min(2 \\times 10^5, R \\times C)\n\n1 \\leq r_i \\leq R\n\n1 \\leq c_i \\leq C\n\n(r_i, c_i) \\neq (r_j, c_j) (i \\neq j)\n\n1 \\leq v_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR C K\nr_1 c_1 v_1\nr_2 c_2 v_2\n:\nr_K c_K v_K\n\nOutput\n\nPrint the maximum possible sum of the values of items Takahashi picks up.\n\nSample Input 1\n\n2 2 3\n1 1 3\n2 1 4\n1 2 5\n\nSample Output 1\n\n8\n\nHe has two ways to get to the goal:\n\nVisit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n\nVisit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\nSample Input 2\n\n2 5 5\n1 1 3\n2 4 20\n1 2 1\n1 3 4\n1 4 2\n\nSample Output 2\n\n29\n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\nVisit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\nSample Input 3\n\n4 5 10\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10\n\nSample Output 3\n\n142", "sample_input": "2 2 3\n1 1 3\n2 1 4\n1 2 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02586", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \\leq i \\leq R) and the j-th column (1 \\leq j \\leq C). The i-th item is at (r_i, c_i) and has the value v_i.\n\nTakahashi will begin at (1, 1), the start, and get to (R, C), the goal. When he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a non-existent square).\n\nHe can pick up items on the squares he visits, including the start and the goal, but at most three for each row. It is allowed to ignore the item on a square he visits.\n\nFind the maximum possible sum of the values of items he picks up.\n\nConstraints\n\n1 \\leq R, C \\leq 3000\n\n1 \\leq K \\leq \\min(2 \\times 10^5, R \\times C)\n\n1 \\leq r_i \\leq R\n\n1 \\leq c_i \\leq C\n\n(r_i, c_i) \\neq (r_j, c_j) (i \\neq j)\n\n1 \\leq v_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR C K\nr_1 c_1 v_1\nr_2 c_2 v_2\n:\nr_K c_K v_K\n\nOutput\n\nPrint the maximum possible sum of the values of items Takahashi picks up.\n\nSample Input 1\n\n2 2 3\n1 1 3\n2 1 4\n1 2 5\n\nSample Output 1\n\n8\n\nHe has two ways to get to the goal:\n\nVisit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n\nVisit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\nSample Input 2\n\n2 5 5\n1 1 3\n2 4 20\n1 2 1\n1 3 4\n1 4 2\n\nSample Output 2\n\n29\n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\nVisit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\nSample Input 3\n\n4 5 10\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10\n\nSample Output 3\n\n142", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1504, "cpu_time_ms": 3317, "memory_kb": 385112}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s355623167", "group_id": "codeNet:p02594", "input_text": "x = gets.to_i\n\nif x >= 30\n puts 'Yes'\nelse\n puts 'No'\nend", "language": "Ruby", "metadata": {"date": 1596481542, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s355623167.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s355623167", "user_id": "u472143411"}, "prompt_components": {"gold_output": "No\n", "input_to_evaluate": "x = gets.to_i\n\nif x >= 30\n puts 'Yes'\nelse\n puts 'No'\nend", "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": 59, "cpu_time_ms": 67, "memory_kb": 14300}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s552353170", "group_id": "codeNet:p02594", "input_text": "x = gets.to_i\nputs x >= 30 ? \"Yes\" : \"No\"\n", "language": "Ruby", "metadata": {"date": 1596416459, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s552353170.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s552353170", "user_id": "u726523100"}, "prompt_components": {"gold_output": "No\n", "input_to_evaluate": "x = gets.to_i\nputs x >= 30 ? \"Yes\" : \"No\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above.\n\nThe current temperature of the room is X degrees Celsius. Will you turn on the air conditioner?\n\nConstraints\n\n-40 \\leq X \\leq 40\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint Yes if you will turn on the air conditioner; print No otherwise.\n\nSample Input 1\n\n25\n\nSample Output 1\n\nNo\n\nSample Input 2\n\n30\n\nSample Output 2\n\nYes", "sample_input": "25\n"}, "reference_outputs": ["No\n"], "source_document_id": "p02594", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above.\n\nThe current temperature of the room is X degrees Celsius. Will you turn on the air conditioner?\n\nConstraints\n\n-40 \\leq X \\leq 40\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint Yes if you will turn on the air conditioner; print No otherwise.\n\nSample Input 1\n\n25\n\nSample Output 1\n\nNo\n\nSample Input 2\n\n30\n\nSample Output 2\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 42, "cpu_time_ms": 64, "memory_kb": 14316}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s245049977", "group_id": "codeNet:p02595", "input_text": "a,b = gets\nn=a.to_i\nd=b.to_i\n\nfor i in 1..n\n m=i\n c,d=gets \n x=c.to_i\n y=d.to_i\n e=x**2 + y**2\n f=e**(1/2.0)\n num=0\n if d>=f\n num+=1\n end\nend\nputs num\n", "language": "Ruby", "metadata": {"date": 1596419156, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02595.html", "problem_id": "p02595", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02595/input.txt", "sample_output_relpath": "derived/input_output/data/p02595/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02595/Ruby/s245049977.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s245049977", "user_id": "u208060831"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "a,b = gets\nn=a.to_i\nd=b.to_i\n\nfor i in 1..n\n m=i\n c,d=gets \n x=c.to_i\n y=d.to_i\n e=x**2 + y**2\n f=e**(1/2.0)\n num=0\n if d>=f\n num+=1\n end\nend\nputs num\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, q) can be represented as \\sqrt{p^2+q^2}.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n0 \\leq D \\leq 2\\times 10^5\n\n|X_i|,|Y_i| \\leq 2\\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_1 Y_1\n\\vdots\nX_N Y_N\n\nOutput\n\nPrint an integer representing the number of points such that the distance from the origin is at most D.\n\nSample Input 1\n\n4 5\n0 5\n-2 4\n3 4\n4 -4\n\nSample Output 1\n\n3\n\nThe distance between the origin and each of the given points is as follows:\n\n\\sqrt{0^2+5^2}=5\n\n\\sqrt{(-2)^2+4^2}=4.472\\ldots\n\n\\sqrt{3^2+4^2}=5\n\n\\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most 5.\n\nSample Input 2\n\n12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n\nSample Output 2\n\n7\n\nMultiple points may exist at the same coordinates.\n\nSample Input 3\n\n20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n5901 -163796\n138819 -185986\n-69848 -96669\n\nSample Output 3\n\n6", "sample_input": "4 5\n0 5\n-2 4\n3 4\n4 -4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02595", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, q) can be represented as \\sqrt{p^2+q^2}.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n0 \\leq D \\leq 2\\times 10^5\n\n|X_i|,|Y_i| \\leq 2\\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_1 Y_1\n\\vdots\nX_N Y_N\n\nOutput\n\nPrint an integer representing the number of points such that the distance from the origin is at most D.\n\nSample Input 1\n\n4 5\n0 5\n-2 4\n3 4\n4 -4\n\nSample Output 1\n\n3\n\nThe distance between the origin and each of the given points is as follows:\n\n\\sqrt{0^2+5^2}=5\n\n\\sqrt{(-2)^2+4^2}=4.472\\ldots\n\n\\sqrt{3^2+4^2}=5\n\n\\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most 5.\n\nSample Input 2\n\n12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n\nSample Output 2\n\n7\n\nMultiple points may exist at the same coordinates.\n\nSample Input 3\n\n20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n5901 -163796\n138819 -185986\n-69848 -96669\n\nSample Output 3\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 163, "cpu_time_ms": 69, "memory_kb": 14772}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s669063202", "group_id": "codeNet:p02596", "input_text": "K = gets.to_i\n\nt = 7 % K\nans = -1\nK.times do |i|\n if t == 0 then\n ans = i+1\n break\n end\n\n t = (10*t + 7) % K\nend\n\np ans ", "language": "Ruby", "metadata": {"date": 1597004435, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s669063202.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s669063202", "user_id": "u009976559"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "K = gets.to_i\n\nt = 7 % K\nans = -1\nK.times do |i|\n if t == 0 then\n ans = i+1\n break\n end\n\n t = (10*t + 7) % K\nend\n\np ans ", "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": 143, "cpu_time_ms": 124, "memory_kb": 14236}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s760613497", "group_id": "codeNet:p02596", "input_text": "k = gets.chomp.to_i\n\ncount = 0\ni = 0\nprev = nil\nwhile true do\n i = i * 10 + 1\n i %= k\n count += 1\n if i == 0\n break\n elsif i == prev\n puts -1\n exit\n end\n prev = i\nend\n\nputs count\n", "language": "Ruby", "metadata": {"date": 1596420004, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s760613497.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s760613497", "user_id": "u257668305"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "k = gets.chomp.to_i\n\ncount = 0\ni = 0\nprev = nil\nwhile true do\n i = i * 10 + 1\n i %= k\n count += 1\n if i == 0\n break\n elsif i == prev\n puts -1\n exit\n end\n prev = i\nend\n\nputs count\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": 195, "cpu_time_ms": 2206, "memory_kb": 14400}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s033734570", "group_id": "codeNet:p02596", "input_text": "# 整数の入力\nX = gets.to_i\nsevens = 0\n\nif X % 2 == 0\n puts -1\nelse\n 1.step do |i|\n sevens += 7 * 10**i\n if sevens % X == 0\n puts i\n break\n end\n end\nend", "language": "Ruby", "metadata": {"date": 1596419473, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s033734570.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s033734570", "user_id": "u968803854"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "# 整数の入力\nX = gets.to_i\nsevens = 0\n\nif X % 2 == 0\n puts -1\nelse\n 1.step do |i|\n sevens += 7 * 10**i\n if sevens % X == 0\n puts i\n break\n end\n end\nend", "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": 178, "cpu_time_ms": 2207, "memory_kb": 36556}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s432381878", "group_id": "codeNet:p02597", "input_text": "_ = gets\nc = gets.chomp\nr = c.scan('R').length\n\nres = 0\nr.times do |i|\n if c[i] != \"R\"\n res += 1\n end\nend\nputs res", "language": "Ruby", "metadata": {"date": 1596653977, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02597.html", "problem_id": "p02597", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02597/input.txt", "sample_output_relpath": "derived/input_output/data/p02597/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02597/Ruby/s432381878.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s432381878", "user_id": "u482840940"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "_ = gets\nc = gets.chomp\nr = c.scan('R').length\n\nres = 0\nr.times do |i|\n if c[i] != \"R\"\n res += 1\n end\nend\nputs res", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAn altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \\leq i \\leq N) is given to you as a character c_i; R stands for red and W stands for white.\n\nYou can do the following two kinds of operations any number of times in any order:\n\nChoose two stones (not necessarily adjacent) and swap them.\n\nChoose one stone and change its color (from red to white and vice versa).\n\nAccording to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nc_i is R or W.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nc_{1}c_{2}...c_{N}\n\nOutput\n\nPrint an integer representing the minimum number of operations needed.\n\nSample Input 1\n\n4\nWWRR\n\nSample Output 1\n\n2\n\nFor example, the two operations below will achieve the objective.\n\nSwap the 1-st and 3-rd stones from the left, resulting in RWWR.\n\nChange the color of the 4-th stone from the left, resulting in RWWW.\n\nSample Input 2\n\n2\nRR\n\nSample Output 2\n\n0\n\nIt can be the case that no operation is needed.\n\nSample Input 3\n\n8\nWRWWRWRR\n\nSample Output 3\n\n3", "sample_input": "4\nWWRR\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02597", "source_text": "Score : 400 points\n\nProblem Statement\n\nAn altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \\leq i \\leq N) is given to you as a character c_i; R stands for red and W stands for white.\n\nYou can do the following two kinds of operations any number of times in any order:\n\nChoose two stones (not necessarily adjacent) and swap them.\n\nChoose one stone and change its color (from red to white and vice versa).\n\nAccording to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nc_i is R or W.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nc_{1}c_{2}...c_{N}\n\nOutput\n\nPrint an integer representing the minimum number of operations needed.\n\nSample Input 1\n\n4\nWWRR\n\nSample Output 1\n\n2\n\nFor example, the two operations below will achieve the objective.\n\nSwap the 1-st and 3-rd stones from the left, resulting in RWWR.\n\nChange the color of the 4-th stone from the left, resulting in RWWW.\n\nSample Input 2\n\n2\nRR\n\nSample Output 2\n\n0\n\nIt can be the case that no operation is needed.\n\nSample Input 3\n\n8\nWRWWRWRR\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 119, "cpu_time_ms": 125, "memory_kb": 30456}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s369040381", "group_id": "codeNet:p02598", "input_text": "N,K = gets.split.map &:to_i\nA = gets.split.map &:to_i\n\np (1..10**9).bsearch{|l| A.inject(0){|total,a| total+(a.to_r/l).ceil - 1} <= K }", "language": "Ruby", "metadata": {"date": 1597269339, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s369040381.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s369040381", "user_id": "u009976559"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "N,K = gets.split.map &:to_i\nA = gets.split.map &:to_i\n\np (1..10**9).bsearch{|l| A.inject(0){|total,a| total+(a.to_r/l).ceil - 1} <= K }", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have N logs of lengths A_1,A_2,\\cdots A_N.\n\nWe can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0= b\n b *= 2\n next\n elsif b >= c\n c *= 2\n next\n else\n break\n end\nend\n\nif a < b && b < c\n puts 'Yes'\nelse\n puts 'No'\nend\n", "language": "Ruby", "metadata": {"date": 1595725834, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s496876971.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s496876971", "user_id": "u979684411"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "A, B, C = gets.split.map(&:strip).map(&:to_i)\nK = gets.to_i\n\na, b, c = A, B, C\n\nK.times do\n if a >= b\n b *= 2\n next\n elsif b >= c\n c *= 2\n next\n else\n break\n end\nend\n\nif a < b && b < c\n puts 'Yes'\nelse\n puts 'No'\nend\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": 238, "cpu_time_ms": 71, "memory_kb": 14364}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s223463188", "group_id": "codeNet:p02603", "input_text": "n = gets.to_i\na = gets.split.map(&:to_i)\n\ns = 0\ne = 1\nb = 1000\nst = 0\n\nwhile s < n-1 do\n if a[s] < a[e]\n # 底値からスタートして高値まで待つ\n while e < n-1 && a[e] <= a[e+1] do\n e += 1\n end\n # buy min and sell max\n st, b = b.divmod a[s]\n b = b + st * a[e]\n st = 0\n s = e\n e += 1\n else\n # 底値まで待つ\n while e < n-1 && a[e] >= a[e+1] do\n e += 1\n end\n s = e\n e += 1\n end\nend\n\nputs b\n", "language": "Ruby", "metadata": {"date": 1595728973, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02603.html", "problem_id": "p02603", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02603/input.txt", "sample_output_relpath": "derived/input_output/data/p02603/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02603/Ruby/s223463188.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s223463188", "user_id": "u173515518"}, "prompt_components": {"gold_output": "1685\n", "input_to_evaluate": "n = gets.to_i\na = gets.split.map(&:to_i)\n\ns = 0\ne = 1\nb = 1000\nst = 0\n\nwhile s < n-1 do\n if a[s] < a[e]\n # 底値からスタートして高値まで待つ\n while e < n-1 && a[e] <= a[e+1] do\n e += 1\n end\n # buy min and sell max\n st, b = b.divmod a[s]\n b = b + st * a[e]\n st = 0\n s = e\n e += 1\n else\n # 底値まで待つ\n while e < n-1 && a[e] >= a[e+1] do\n e += 1\n end\n s = e\n e += 1\n end\nend\n\nputs b\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nTo become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives.\n\nHe is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows:\n\nA_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day.\n\nIn the i-th day, M-kun can make the following trade any number of times (possibly zero), within the amount of money and stocks that he has at the time.\n\nBuy stock: Pay A_i yen and receive one stock.\n\nSell stock: Sell one stock for A_i yen.\n\nWhat is the maximum possible amount of money that M-kun can have in the end by trading optimally?\n\nConstraints\n\n2 \\leq N \\leq 80\n\n100 \\leq A_i \\leq 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the maximum possible amount of money that M-kun can have in the end, as an integer.\n\nSample Input 1\n\n7\n100 130 130 130 115 115 150\n\nSample Output 1\n\n1685\n\nIn this sample input, M-kun has seven days of trading. One way to have 1685 yen in the end is as follows:\n\nInitially, he has 1000 yen and no stocks.\n\nDay 1: Buy 10 stocks for 1000 yen. Now he has 0 yen.\n\nDay 2: Sell 7 stocks for 910 yen. Now he has 910 yen.\n\nDay 3: Sell 3 stocks for 390 yen. Now he has 1300 yen.\n\nDay 4: Do nothing.\n\nDay 5: Buy 1 stock for 115 yen. Now he has 1185 yen.\n\nDay 6: Buy 10 stocks for 1150 yen. Now he has 35 yen.\n\nDay 7: Sell 11 stocks for 1650 yen. Now he has 1685 yen.\n\nThere is no way to have 1686 yen or more in the end, so the answer is 1685.\n\nSample Input 2\n\n6\n200 180 160 140 120 100\n\nSample Output 2\n\n1000\n\nIn this sample input, it is optimal to do nothing throughout the six days, after which we will have 1000 yen.\n\nSample Input 3\n\n2\n157 193\n\nSample Output 3\n\n1216\n\nIn this sample input, it is optimal to buy 6 stocks in Day 1 and sell them in Day 2, after which we will have 1216 yen.", "sample_input": "7\n100 130 130 130 115 115 150\n"}, "reference_outputs": ["1685\n"], "source_document_id": "p02603", "source_text": "Score: 400 points\n\nProblem Statement\n\nTo become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives.\n\nHe is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows:\n\nA_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day.\n\nIn the i-th day, M-kun can make the following trade any number of times (possibly zero), within the amount of money and stocks that he has at the time.\n\nBuy stock: Pay A_i yen and receive one stock.\n\nSell stock: Sell one stock for A_i yen.\n\nWhat is the maximum possible amount of money that M-kun can have in the end by trading optimally?\n\nConstraints\n\n2 \\leq N \\leq 80\n\n100 \\leq A_i \\leq 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the maximum possible amount of money that M-kun can have in the end, as an integer.\n\nSample Input 1\n\n7\n100 130 130 130 115 115 150\n\nSample Output 1\n\n1685\n\nIn this sample input, M-kun has seven days of trading. One way to have 1685 yen in the end is as follows:\n\nInitially, he has 1000 yen and no stocks.\n\nDay 1: Buy 10 stocks for 1000 yen. Now he has 0 yen.\n\nDay 2: Sell 7 stocks for 910 yen. Now he has 910 yen.\n\nDay 3: Sell 3 stocks for 390 yen. Now he has 1300 yen.\n\nDay 4: Do nothing.\n\nDay 5: Buy 1 stock for 115 yen. Now he has 1185 yen.\n\nDay 6: Buy 10 stocks for 1150 yen. Now he has 35 yen.\n\nDay 7: Sell 11 stocks for 1650 yen. Now he has 1685 yen.\n\nThere is no way to have 1686 yen or more in the end, so the answer is 1685.\n\nSample Input 2\n\n6\n200 180 160 140 120 100\n\nSample Output 2\n\n1000\n\nIn this sample input, it is optimal to do nothing throughout the six days, after which we will have 1000 yen.\n\nSample Input 3\n\n2\n157 193\n\nSample Output 3\n\n1216\n\nIn this sample input, it is optimal to buy 6 stocks in Day 1 and sell them in Day 2, after which we will have 1216 yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 458, "cpu_time_ms": 73, "memory_kb": 14212}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s837232650", "group_id": "codeNet:p02603", "input_text": "n = gets.to_i\na = gets.split.map(&:to_i)\n\ns = 0\ne = 1\nb = 1000\nst = 0\n\nwhile s < n-1 do\n if a[s] < a[e]\n # 底値からスタートして高値まで待つ\n while e < n-1 && a[e-1] < a[e] do\n e += 1\n end\n # buy min and sell max\n p [s,e,b,st]\n st, b = b.divmod a[s]\n b = b + st * a[e]\n st = 0\n s = e\n e += 1\n else\n # 底値まで待つ\n while e < n && a[e-1] > a[e] do\n e += 1\n end\n s = e\n e += 1\n p [s,e]\n end\nend\n\nputs b\n", "language": "Ruby", "metadata": {"date": 1595728432, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02603.html", "problem_id": "p02603", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02603/input.txt", "sample_output_relpath": "derived/input_output/data/p02603/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02603/Ruby/s837232650.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s837232650", "user_id": "u173515518"}, "prompt_components": {"gold_output": "1685\n", "input_to_evaluate": "n = gets.to_i\na = gets.split.map(&:to_i)\n\ns = 0\ne = 1\nb = 1000\nst = 0\n\nwhile s < n-1 do\n if a[s] < a[e]\n # 底値からスタートして高値まで待つ\n while e < n-1 && a[e-1] < a[e] do\n e += 1\n end\n # buy min and sell max\n p [s,e,b,st]\n st, b = b.divmod a[s]\n b = b + st * a[e]\n st = 0\n s = e\n e += 1\n else\n # 底値まで待つ\n while e < n && a[e-1] > a[e] do\n e += 1\n end\n s = e\n e += 1\n p [s,e]\n end\nend\n\nputs b\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nTo become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives.\n\nHe is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows:\n\nA_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day.\n\nIn the i-th day, M-kun can make the following trade any number of times (possibly zero), within the amount of money and stocks that he has at the time.\n\nBuy stock: Pay A_i yen and receive one stock.\n\nSell stock: Sell one stock for A_i yen.\n\nWhat is the maximum possible amount of money that M-kun can have in the end by trading optimally?\n\nConstraints\n\n2 \\leq N \\leq 80\n\n100 \\leq A_i \\leq 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the maximum possible amount of money that M-kun can have in the end, as an integer.\n\nSample Input 1\n\n7\n100 130 130 130 115 115 150\n\nSample Output 1\n\n1685\n\nIn this sample input, M-kun has seven days of trading. One way to have 1685 yen in the end is as follows:\n\nInitially, he has 1000 yen and no stocks.\n\nDay 1: Buy 10 stocks for 1000 yen. Now he has 0 yen.\n\nDay 2: Sell 7 stocks for 910 yen. Now he has 910 yen.\n\nDay 3: Sell 3 stocks for 390 yen. Now he has 1300 yen.\n\nDay 4: Do nothing.\n\nDay 5: Buy 1 stock for 115 yen. Now he has 1185 yen.\n\nDay 6: Buy 10 stocks for 1150 yen. Now he has 35 yen.\n\nDay 7: Sell 11 stocks for 1650 yen. Now he has 1685 yen.\n\nThere is no way to have 1686 yen or more in the end, so the answer is 1685.\n\nSample Input 2\n\n6\n200 180 160 140 120 100\n\nSample Output 2\n\n1000\n\nIn this sample input, it is optimal to do nothing throughout the six days, after which we will have 1000 yen.\n\nSample Input 3\n\n2\n157 193\n\nSample Output 3\n\n1216\n\nIn this sample input, it is optimal to buy 6 stocks in Day 1 and sell them in Day 2, after which we will have 1216 yen.", "sample_input": "7\n100 130 130 130 115 115 150\n"}, "reference_outputs": ["1685\n"], "source_document_id": "p02603", "source_text": "Score: 400 points\n\nProblem Statement\n\nTo become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives.\n\nHe is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows:\n\nA_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day.\n\nIn the i-th day, M-kun can make the following trade any number of times (possibly zero), within the amount of money and stocks that he has at the time.\n\nBuy stock: Pay A_i yen and receive one stock.\n\nSell stock: Sell one stock for A_i yen.\n\nWhat is the maximum possible amount of money that M-kun can have in the end by trading optimally?\n\nConstraints\n\n2 \\leq N \\leq 80\n\n100 \\leq A_i \\leq 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the maximum possible amount of money that M-kun can have in the end, as an integer.\n\nSample Input 1\n\n7\n100 130 130 130 115 115 150\n\nSample Output 1\n\n1685\n\nIn this sample input, M-kun has seven days of trading. One way to have 1685 yen in the end is as follows:\n\nInitially, he has 1000 yen and no stocks.\n\nDay 1: Buy 10 stocks for 1000 yen. Now he has 0 yen.\n\nDay 2: Sell 7 stocks for 910 yen. Now he has 910 yen.\n\nDay 3: Sell 3 stocks for 390 yen. Now he has 1300 yen.\n\nDay 4: Do nothing.\n\nDay 5: Buy 1 stock for 115 yen. Now he has 1185 yen.\n\nDay 6: Buy 10 stocks for 1150 yen. Now he has 35 yen.\n\nDay 7: Sell 11 stocks for 1650 yen. Now he has 1685 yen.\n\nThere is no way to have 1686 yen or more in the end, so the answer is 1685.\n\nSample Input 2\n\n6\n200 180 160 140 120 100\n\nSample Output 2\n\n1000\n\nIn this sample input, it is optimal to do nothing throughout the six days, after which we will have 1000 yen.\n\nSample Input 3\n\n2\n157 193\n\nSample Output 3\n\n1216\n\nIn this sample input, it is optimal to buy 6 stocks in Day 1 and sell them in Day 2, after which we will have 1216 yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 483, "cpu_time_ms": 71, "memory_kb": 14312}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s920964623", "group_id": "codeNet:p02608", "input_text": "N = gets.to_i\n \nx = 1\ny = 1\nz = 1\n \ncount = 0\n \n(1..N).each do |i|\n count = 0\n (x..10).each do |k|\n (y..11).each do |m|\n (z..12).each do |n|\n if k**2 + m**2 + n**2 + k * m + m * n + k * n == i\n count += 1\n end \n end\n end\n end\n puts count \nend", "language": "Ruby", "metadata": {"date": 1594519207, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s920964623.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s920964623", "user_id": "u684458716"}, "prompt_components": {"gold_output": "0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n", "input_to_evaluate": "N = gets.to_i\n \nx = 1\ny = 1\nz = 1\n \ncount = 0\n \n(1..N).each do |i|\n count = 0\n (x..10).each do |k|\n (y..11).each do |m|\n (z..12).each do |n|\n if k**2 + m**2 + n**2 + k * m + m * n + k * n == i\n count += 1\n end \n end\n end\n end\n puts count \nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nLet f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n1 \\leq x,y,z\n\nx^2 + y^2 + z^2 + xy + yz + zx = n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,f(N).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(i).\n\nSample Input 1\n\n20\n\nSample Output 1\n\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n\nFor n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n\nFor n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n\nFor n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n\nFor n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.", "sample_input": "20\n"}, "reference_outputs": ["0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n"], "source_document_id": "p02608", "source_text": "Score : 300 points\n\nProblem Statement\n\nLet f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n1 \\leq x,y,z\n\nx^2 + y^2 + z^2 + xy + yz + zx = n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,f(N).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(i).\n\nSample Input 1\n\n20\n\nSample Output 1\n\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n\nFor n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n\nFor n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n\nFor n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n\nFor n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1906, "memory_kb": 14372}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s577570424", "group_id": "codeNet:p02613", "input_text": "h=Hash.new 0\n$<.map{h[_1.chomp]+=1}\n%w(AC WA TLE RE).map{puts\"#{_1} x #{h[_1]}\"}", "language": "Ruby", "metadata": {"date": 1594003059, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02613.html", "problem_id": "p02613", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02613/input.txt", "sample_output_relpath": "derived/input_output/data/p02613/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02613/Ruby/s577570424.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s577570424", "user_id": "u019489252"}, "prompt_components": {"gold_output": "AC x 3\nWA x 1\nTLE x 2\nRE x 0\n", "input_to_evaluate": "h=Hash.new 0\n$<.map{h[_1.chomp]+=1}\n%w(AC WA TLE RE).map{puts\"#{_1} x #{h[_1]}\"}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.\n\nThe problem has N test cases.\n\nFor each test case i (1\\leq i \\leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSee the Output section for the output format.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i is AC, WA, TLE, or RE.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n\\vdots\nS_N\n\nOutput\n\nLet C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:\n\nAC x C_0\nWA x C_1\nTLE x C_2\nRE x C_3\n\nSample Input 1\n\n6\nAC\nTLE\nAC\nAC\nWA\nTLE\n\nSample Output 1\n\nAC x 3\nWA x 1\nTLE x 2\nRE x 0\n\nWe have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSample Input 2\n\n10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n\nSample Output 2\n\nAC x 10\nWA x 0\nTLE x 0\nRE x 0", "sample_input": "6\nAC\nTLE\nAC\nAC\nWA\nTLE\n"}, "reference_outputs": ["AC x 3\nWA x 1\nTLE x 2\nRE x 0\n"], "source_document_id": "p02613", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.\n\nThe problem has N test cases.\n\nFor each test case i (1\\leq i \\leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSee the Output section for the output format.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i is AC, WA, TLE, or RE.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n\\vdots\nS_N\n\nOutput\n\nLet C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:\n\nAC x C_0\nWA x C_1\nTLE x C_2\nRE x C_3\n\nSample Input 1\n\n6\nAC\nTLE\nAC\nAC\nWA\nTLE\n\nSample Output 1\n\nAC x 3\nWA x 1\nTLE x 2\nRE x 0\n\nWe have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSample Input 2\n\n10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n\nSample Output 2\n\nAC x 10\nWA x 0\nTLE x 0\nRE x 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 80, "cpu_time_ms": 110, "memory_kb": 15196}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s197204970", "group_id": "codeNet:p02613", "input_text": "def fmt(ac,wa,tle,re)\n puts \"AC x #{ac}\\nWA x #{wa}\\nTLE x #{tle}\\nRE x #{re}\"\nend\nN = gets.to_i\ns = []\nN.times do\n s.push(gets.chomp)\nend\na=b=c=d=0\ns.each do |val|\n case val\n when \"AC\"\n a += 1\n when \"WA\"\n b += 1\n when \"TLE\"\n c += 1\n when \"RE\"\n d += 1\n end\nend\nfmt(a,b,c,d)", "language": "Ruby", "metadata": {"date": 1593997880, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02613.html", "problem_id": "p02613", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02613/input.txt", "sample_output_relpath": "derived/input_output/data/p02613/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02613/Ruby/s197204970.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s197204970", "user_id": "u742129941"}, "prompt_components": {"gold_output": "AC x 3\nWA x 1\nTLE x 2\nRE x 0\n", "input_to_evaluate": "def fmt(ac,wa,tle,re)\n puts \"AC x #{ac}\\nWA x #{wa}\\nTLE x #{tle}\\nRE x #{re}\"\nend\nN = gets.to_i\ns = []\nN.times do\n s.push(gets.chomp)\nend\na=b=c=d=0\ns.each do |val|\n case val\n when \"AC\"\n a += 1\n when \"WA\"\n b += 1\n when \"TLE\"\n c += 1\n when \"RE\"\n d += 1\n end\nend\nfmt(a,b,c,d)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.\n\nThe problem has N test cases.\n\nFor each test case i (1\\leq i \\leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSee the Output section for the output format.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i is AC, WA, TLE, or RE.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n\\vdots\nS_N\n\nOutput\n\nLet C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:\n\nAC x C_0\nWA x C_1\nTLE x C_2\nRE x C_3\n\nSample Input 1\n\n6\nAC\nTLE\nAC\nAC\nWA\nTLE\n\nSample Output 1\n\nAC x 3\nWA x 1\nTLE x 2\nRE x 0\n\nWe have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSample Input 2\n\n10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n\nSample Output 2\n\nAC x 10\nWA x 0\nTLE x 0\nRE x 0", "sample_input": "6\nAC\nTLE\nAC\nAC\nWA\nTLE\n"}, "reference_outputs": ["AC x 3\nWA x 1\nTLE x 2\nRE x 0\n"], "source_document_id": "p02613", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.\n\nThe problem has N test cases.\n\nFor each test case i (1\\leq i \\leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSee the Output section for the output format.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i is AC, WA, TLE, or RE.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n\\vdots\nS_N\n\nOutput\n\nLet C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:\n\nAC x C_0\nWA x C_1\nTLE x C_2\nRE x C_3\n\nSample Input 1\n\n6\nAC\nTLE\nAC\nAC\nWA\nTLE\n\nSample Output 1\n\nAC x 3\nWA x 1\nTLE x 2\nRE x 0\n\nWe have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSample Input 2\n\n10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n\nSample Output 2\n\nAC x 10\nWA x 0\nTLE x 0\nRE x 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 309, "cpu_time_ms": 115, "memory_kb": 20732}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s514768439", "group_id": "codeNet:p02614", "input_text": "h,w,k = gets.split.map(&:to_i)\nc = h.times.map{gets.split('').map{|c|c=='#'}}\n\nans = 0\n(2**(h+w)).times{|i|\n s = 2**(h+w)+i\n s = s.to_s(2)[1..-1]\n #p s\n cnt = 0\n h.times{|j|\n w.times{|k|\n if s[j]!='0' && s[h+k]!='0'\n if c[j][k]\n cnt += 1\n end\n end\n }\n }\n #p cnt\n ans += 1 if cnt==k\n}\n\np ans\n", "language": "Ruby", "metadata": {"date": 1593997932, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02614.html", "problem_id": "p02614", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02614/input.txt", "sample_output_relpath": "derived/input_output/data/p02614/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02614/Ruby/s514768439.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s514768439", "user_id": "u397763977"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "h,w,k = gets.split.map(&:to_i)\nc = h.times.map{gets.split('').map{|c|c=='#'}}\n\nans = 0\n(2**(h+w)).times{|i|\n s = 2**(h+w)+i\n s = s.to_s(2)[1..-1]\n #p s\n cnt = 0\n h.times{|j|\n w.times{|k|\n if s[j]!='0' && s[h+k]!='0'\n if c[j][k]\n cnt += 1\n end\n end\n }\n }\n #p cnt\n ans += 1 if cnt==k\n}\n\np ans\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \\leq i \\leq H, 1 \\leq j \\leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is ., and black if c_{i,j} is #.\n\nConsider doing the following operation:\n\nChoose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.\n\nYou are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.\n\nConstraints\n\n1 \\leq H, W \\leq 6\n\n1 \\leq K \\leq HW\n\nc_{i,j} is . or #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nc_{1,1}c_{1,2}...c_{1,W}\nc_{2,1}c_{2,2}...c_{2,W}\n:\nc_{H,1}c_{H,2}...c_{H,W}\n\nOutput\n\nPrint an integer representing the number of choices of rows and columns satisfying the condition.\n\nSample Input 1\n\n2 3 2\n..#\n###\n\nSample Output 1\n\n5\n\nFive choices below satisfy the condition.\n\nThe 1-st row and 1-st column\n\nThe 1-st row and 2-nd column\n\nThe 1-st row and 3-rd column\n\nThe 1-st and 2-nd column\n\nThe 3-rd column\n\nSample Input 2\n\n2 3 4\n..#\n###\n\nSample Output 2\n\n1\n\nOne choice, which is choosing nothing, satisfies the condition.\n\nSample Input 3\n\n2 2 3\n##\n##\n\nSample Output 3\n\n0\n\nSample Input 4\n\n6 6 8\n..##..\n.#..#.\n#....#\n######\n#....#\n#....#\n\nSample Output 4\n\n208", "sample_input": "2 3 2\n..#\n###\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02614", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \\leq i \\leq H, 1 \\leq j \\leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is ., and black if c_{i,j} is #.\n\nConsider doing the following operation:\n\nChoose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.\n\nYou are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.\n\nConstraints\n\n1 \\leq H, W \\leq 6\n\n1 \\leq K \\leq HW\n\nc_{i,j} is . or #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nc_{1,1}c_{1,2}...c_{1,W}\nc_{2,1}c_{2,2}...c_{2,W}\n:\nc_{H,1}c_{H,2}...c_{H,W}\n\nOutput\n\nPrint an integer representing the number of choices of rows and columns satisfying the condition.\n\nSample Input 1\n\n2 3 2\n..#\n###\n\nSample Output 1\n\n5\n\nFive choices below satisfy the condition.\n\nThe 1-st row and 1-st column\n\nThe 1-st row and 2-nd column\n\nThe 1-st row and 3-rd column\n\nThe 1-st and 2-nd column\n\nThe 3-rd column\n\nSample Input 2\n\n2 3 4\n..#\n###\n\nSample Output 2\n\n1\n\nOne choice, which is choosing nothing, satisfies the condition.\n\nSample Input 3\n\n2 2 3\n##\n##\n\nSample Output 3\n\n0\n\nSample Input 4\n\n6 6 8\n..##..\n.#..#.\n#....#\n######\n#....#\n#....#\n\nSample Output 4\n\n208", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 338, "cpu_time_ms": 107, "memory_kb": 14368}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s391459224", "group_id": "codeNet:p02616", "input_text": "INF = 10 ** 9 + 7\n\nn, k = gets.chomp.split.map(&:to_i)\na = gets.chomp.split.map(&:to_i)\n\npos = []\nneg = []\na.each do |x|\n if x < 0\n neg << x\n else\n pos << x\n end\nend\n\npos.sort!\nneg.sort!\n\nif pos.empty? && k % 2 != 0\n res = 1\n while k > 0\n res *= neg[n - k]\n res %= INF\n k -= 1\n end\n puts res\n exit\nend\n\ni = pos.size\nj = - 1\nk.times do\n if i - 1 < 0\n j += 1 # 負の数を加える\n elsif j + 1 >= neg.size\n i -= 1 # 正の数を加える\n elsif pos[i - 1].abs >= neg[j + 1].abs\n i -= 1\n else\n j += 1\n end\nend\n\nif (j + 1) % 2 != 0 && !((i >= pos.size || j >= neg.size - 1) && (j <= -1 || i <= 0))\n if i >= pos.size || j >= neg.size - 1\n i -= 1 # (1)\n j -= 1\n elsif j <= -1 || i <= 0\n j += 1 # (2)\n i += 1\n elsif neg[j] * neg[j - 1] > pos[i] * pos[i + 1]\n i += 1\n j += 1\n else\n i -= 1\n j -= 1\n end\nend\n\nres = 1\nwhile i < pos.size\n res *= pos[i]\n res %= INF\n i += 1\nend\nwhile j > 0\n res *= (INF + neg[j])\n res %= INF\n j -= 1\nend\n\nputs res", "language": "Ruby", "metadata": {"date": 1593995189, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02616.html", "problem_id": "p02616", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02616/input.txt", "sample_output_relpath": "derived/input_output/data/p02616/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02616/Ruby/s391459224.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s391459224", "user_id": "u482840940"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "INF = 10 ** 9 + 7\n\nn, k = gets.chomp.split.map(&:to_i)\na = gets.chomp.split.map(&:to_i)\n\npos = []\nneg = []\na.each do |x|\n if x < 0\n neg << x\n else\n pos << x\n end\nend\n\npos.sort!\nneg.sort!\n\nif pos.empty? && k % 2 != 0\n res = 1\n while k > 0\n res *= neg[n - k]\n res %= INF\n k -= 1\n end\n puts res\n exit\nend\n\ni = pos.size\nj = - 1\nk.times do\n if i - 1 < 0\n j += 1 # 負の数を加える\n elsif j + 1 >= neg.size\n i -= 1 # 正の数を加える\n elsif pos[i - 1].abs >= neg[j + 1].abs\n i -= 1\n else\n j += 1\n end\nend\n\nif (j + 1) % 2 != 0 && !((i >= pos.size || j >= neg.size - 1) && (j <= -1 || i <= 0))\n if i >= pos.size || j >= neg.size - 1\n i -= 1 # (1)\n j -= 1\n elsif j <= -1 || i <= 0\n j += 1 # (2)\n i += 1\n elsif neg[j] * neg[j - 1] > pos[i] * pos[i + 1]\n i += 1\n j += 1\n else\n i -= 1\n j -= 1\n end\nend\n\nres = 1\nwhile i < pos.size\n res *= pos[i]\n res %= INF\n i += 1\nend\nwhile j > 0\n res *= (INF + neg[j])\n res %= INF\n j -= 1\nend\n\nputs res", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are N integers A_1,\\ldots,A_N.\n\nWe will choose exactly K of these elements. Find the maximum possible product of the chosen elements.\n\nThen, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2\\times 10^5\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 \\ldots A_N\n\nOutput\n\nPrint the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nSample Input 1\n\n4 2\n1 2 -3 -4\n\nSample Output 1\n\n12\n\nThe possible products of the two chosen elements are 2, -3, -4, -6, -8, and 12, so the maximum product is 12.\n\nSample Input 2\n\n4 3\n-1 -2 -3 -4\n\nSample Output 2\n\n1000000001\n\nThe possible products of the three chosen elements are -24, -12, -8, and -6, so the maximum product is -6.\n\nWe print this value modulo (10^9+7), that is, 1000000001.\n\nSample Input 3\n\n2 1\n-1 1000000000\n\nSample Output 3\n\n1000000000\n\nThe possible products of the one chosen element are -1 and 1000000000, so the maximum product is 1000000000.\n\nSample Input 4\n\n10 10\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\n\nSample Output 4\n\n999983200\n\nBe sure to print the product modulo (10^9+7).", "sample_input": "4 2\n1 2 -3 -4\n"}, "reference_outputs": ["12\n"], "source_document_id": "p02616", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are N integers A_1,\\ldots,A_N.\n\nWe will choose exactly K of these elements. Find the maximum possible product of the chosen elements.\n\nThen, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2\\times 10^5\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 \\ldots A_N\n\nOutput\n\nPrint the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nSample Input 1\n\n4 2\n1 2 -3 -4\n\nSample Output 1\n\n12\n\nThe possible products of the two chosen elements are 2, -3, -4, -6, -8, and 12, so the maximum product is 12.\n\nSample Input 2\n\n4 3\n-1 -2 -3 -4\n\nSample Output 2\n\n1000000001\n\nThe possible products of the three chosen elements are -24, -12, -8, and -6, so the maximum product is -6.\n\nWe print this value modulo (10^9+7), that is, 1000000001.\n\nSample Input 3\n\n2 1\n-1 1000000000\n\nSample Output 3\n\n1000000000\n\nThe possible products of the one chosen element are -1 and 1000000000, so the maximum product is 1000000000.\n\nSample Input 4\n\n10 10\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\n\nSample Output 4\n\n999983200\n\nBe sure to print the product modulo (10^9+7).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1010, "cpu_time_ms": 180, "memory_kb": 34372}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s091832879", "group_id": "codeNet:p02621", "input_text": "a = gets.to_i\n\nputs a + (a**2) + (a**3)", "language": "Ruby", "metadata": {"date": 1593306156, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s091832879.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s091832879", "user_id": "u689027433"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "a = gets.to_i\n\nputs a + (a**2) + (a**3)", "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": 39, "cpu_time_ms": 74, "memory_kb": 14364}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s030454320", "group_id": "codeNet:p02622", "input_text": "s=gets.chomp.split(\"\")\nt=gets.chomp.split(\"\")\ncount = 0\n(s.size).times do |index|\n count +=1 if s[index] != t[index]\nend\nputs count", "language": "Ruby", "metadata": {"date": 1596076403, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s030454320.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s030454320", "user_id": "u802371628"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "s=gets.chomp.split(\"\")\nt=gets.chomp.split(\"\")\ncount = 0\n(s.size).times do |index|\n count +=1 if s[index] != t[index]\nend\nputs count", "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": 132, "cpu_time_ms": 130, "memory_kb": 35216}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s666882255", "group_id": "codeNet:p02622", "input_text": "input = readlines()\ns = input.shift.chomp.split('')\nt = input.shift.chomp.split('')\n\ncnt = 0\ns.each_with_index do |c, i|\n cnt += 1 unless c == t[i]\nend\n\nputs cnt\n", "language": "Ruby", "metadata": {"date": 1593306471, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s666882255.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s666882255", "user_id": "u810199299"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "input = readlines()\ns = input.shift.chomp.split('')\nt = input.shift.chomp.split('')\n\ncnt = 0\ns.each_with_index do |c, i|\n cnt += 1 unless c == t[i]\nend\n\nputs cnt\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": 163, "cpu_time_ms": 139, "memory_kb": 35168}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s728068215", "group_id": "codeNet:p02627", "input_text": "x = gets\nif x == x.upcase\n puts \"A\"\nelse\n puts \"a\"\nend", "language": "Ruby", "metadata": {"date": 1592790163, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s728068215.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s728068215", "user_id": "u565580226"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "x = gets\nif x == x.upcase\n puts \"A\"\nelse\n puts \"a\"\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "sample_input": "B\n"}, "reference_outputs": ["A\n"], "source_document_id": "p02627", "source_text": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 56, "cpu_time_ms": 71, "memory_kb": 14424}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s165828587", "group_id": "codeNet:p02627", "input_text": "c = gets.chomp\n\nif \"QWERTYUIOPASDFGHJKLZXCVBNM\".include? c\n puts \"A\"\nelse\n puts \"a\"\nend", "language": "Ruby", "metadata": {"date": 1592787725, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s165828587.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s165828587", "user_id": "u644533034"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "c = gets.chomp\n\nif \"QWERTYUIOPASDFGHJKLZXCVBNM\".include? c\n puts \"A\"\nelse\n puts \"a\"\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "sample_input": "B\n"}, "reference_outputs": ["A\n"], "source_document_id": "p02627", "source_text": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 89, "cpu_time_ms": 70, "memory_kb": 14276}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s792428233", "group_id": "codeNet:p02629", "input_text": "n = gets.to_i\nalps = (\"a\"..\"z\").to_a \nans = []\ni = 10\nwhile true\n if n / (26**i) > 0\n ans << alps[n/(26**i) - 1]\n n -= n/(26**i) * (26**i)\n i = 10\n end\n if i <= 0\n break\n end\n i -= 1\nend\nputs ans.join\n", "language": "Ruby", "metadata": {"date": 1600796810, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s792428233.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s792428233", "user_id": "u059126963"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "n = gets.to_i\nalps = (\"a\"..\"z\").to_a \nans = []\ni = 10\nwhile true\n if n / (26**i) > 0\n ans << alps[n/(26**i) - 1]\n n -= n/(26**i) * (26**i)\n i = 10\n end\n if i <= 0\n break\n end\n i -= 1\nend\nputs ans.join\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": 218, "cpu_time_ms": 68, "memory_kb": 14308}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s595157056", "group_id": "codeNet:p02629", "input_text": "n = gets.to_i\nres = []\nwhile n > 0\n res << (\"a\".ord + (n % 26) - 1).chr\n n /= 26\nend\nputs res.join(\"\").reverse", "language": "Ruby", "metadata": {"date": 1592788109, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s595157056.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s595157056", "user_id": "u482840940"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "n = gets.to_i\nres = []\nwhile n > 0\n res << (\"a\".ord + (n % 26) - 1).chr\n n /= 26\nend\nputs res.join(\"\").reverse", "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": 112, "cpu_time_ms": 77, "memory_kb": 14360}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s355532143", "group_id": "codeNet:p02630", "input_text": "n = gets.to_i\na = gets.split(\" \").map(&:to_i)\nz = []\na.length.times{ |i|\n z[a[i]] ||= 0\n z[a[i]] += 1\n}\nsum = a.sum\nq = gets.to_i\nq.times{\n b, c = gets.split(\" \").map(&:to_i)\n if z[b] != nil && z[b] > 0\n sum += (c -b) * z[b]\n z[c] ||= 0\n z[c] += z[b]\n z[b] = 0\n end\n p sum\n}", "language": "Ruby", "metadata": {"date": 1600476788, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s355532143.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s355532143", "user_id": "u341702138"}, "prompt_components": {"gold_output": "11\n12\n16\n", "input_to_evaluate": "n = gets.to_i\na = gets.split(\" \").map(&:to_i)\nz = []\na.length.times{ |i|\n z[a[i]] ||= 0\n z[a[i]] += 1\n}\nsum = a.sum\nq = gets.to_i\nq.times{\n b, c = gets.split(\" \").map(&:to_i)\n if z[b] != nil && z[b] > 0\n sum += (c -b) * z[b]\n z[c] ||= 0\n z[c] += z[b]\n z[b] = 0\n end\n p sum\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": 292, "cpu_time_ms": 422, "memory_kb": 25416}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s003456024", "group_id": "codeNet:p02639", "input_text": "puts 15-gets.split(' ').map(&:to_i).sum", "language": "Ruby", "metadata": {"date": 1592959766, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02639.html", "problem_id": "p02639", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02639/input.txt", "sample_output_relpath": "derived/input_output/data/p02639/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02639/Ruby/s003456024.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s003456024", "user_id": "u841856382"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "puts 15-gets.split(' ').map(&:to_i).sum", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\n\nThe variable x_i was initially assigned a value of i.\n\nSnuke chose one of these variables and assigned it 0.\n\nYou are given the values of the five variables after this assignment.\n\nFind out which variable Snuke assigned 0.\n\nConstraints\n\nThe values of x_1, x_2, x_3, x_4, and x_5 given as input are a possible outcome of the assignment by Snuke.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 x_2 x_3 x_4 x_5\n\nOutput\n\nIf the variable Snuke assigned 0 was x_i, print the integer i.\n\nSample Input 1\n\n0 2 3 4 5\n\nSample Output 1\n\n1\n\nIn this case, Snuke assigned 0 to x_1, so we should print 1.\n\nSample Input 2\n\n1 2 0 4 5\n\nSample Output 2\n\n3", "sample_input": "0 2 3 4 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02639", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\n\nThe variable x_i was initially assigned a value of i.\n\nSnuke chose one of these variables and assigned it 0.\n\nYou are given the values of the five variables after this assignment.\n\nFind out which variable Snuke assigned 0.\n\nConstraints\n\nThe values of x_1, x_2, x_3, x_4, and x_5 given as input are a possible outcome of the assignment by Snuke.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 x_2 x_3 x_4 x_5\n\nOutput\n\nIf the variable Snuke assigned 0 was x_i, print the integer i.\n\nSample Input 1\n\n0 2 3 4 5\n\nSample Output 1\n\n1\n\nIn this case, Snuke assigned 0 to x_1, so we should print 1.\n\nSample Input 2\n\n1 2 0 4 5\n\nSample Output 2\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 39, "cpu_time_ms": 66, "memory_kb": 14092}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s068732799", "group_id": "codeNet:p02640", "input_text": "x,y = gets.split.map(&:to_i)\n\nif 2*x <= y && y <= 4*x && y % 2 == 0\n puts \"Yes\"\nelse\n puts \"No\"\nend", "language": "Ruby", "metadata": {"date": 1592183788, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s068732799.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s068732799", "user_id": "u523351024"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "x,y = gets.split.map(&:to_i)\n\nif 2*x <= y && y <= 4*x && y % 2 == 0\n puts \"Yes\"\nelse\n puts \"No\"\nend", "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": 101, "cpu_time_ms": 56, "memory_kb": 14392}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s390005447", "group_id": "codeNet:p02646", "input_text": "A = gets.chomp.split \" \"\nB = gets.chomp.split \" \"\na,v = A[0].to_i, A[1].to_i\nb,w = B[0].to_i, B[1].to_i\nRESULT = gets.chomp.to_i\n\ntime = 1\n\nwhile true\n now = (b + w*time) - (a + v*time)\n if time >= RESULT\n puts \"No\"\n return\n end\n\n if now <= 0\n puts \"Yes\"\n return;\n end\n time += 1;\nend\n", "language": "Ruby", "metadata": {"date": 1592098820, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s390005447.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s390005447", "user_id": "u556576186"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "A = gets.chomp.split \" \"\nB = gets.chomp.split \" \"\na,v = A[0].to_i, A[1].to_i\nb,w = B[0].to_i, B[1].to_i\nRESULT = gets.chomp.to_i\n\ntime = 1\n\nwhile true\n now = (b + w*time) - (a + v*time)\n if time >= RESULT\n puts \"No\"\n return\n end\n\n if now <= 0\n puts \"Yes\"\n return;\n end\n time += 1;\nend\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": 303, "cpu_time_ms": 2206, "memory_kb": 14372}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s164899539", "group_id": "codeNet:p02646", "input_text": "a, v = gets.split.map(&:to_i)\nb, w = gets.split.map(&:to_i)\nt = gets.to_i\n\nif (a == b)\n puts \"YES\"\n exit\nend\n\nif (v <= w)\n puts \"NO\"\n exit\nend\n\nd = (b - a).abs\ne = v - w\nif (d / e <= t)\n puts \"YES\"\nelse\n puts \"NO\"\nend\n", "language": "Ruby", "metadata": {"date": 1592098547, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s164899539.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s164899539", "user_id": "u315859894"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "a, v = gets.split.map(&:to_i)\nb, w = gets.split.map(&:to_i)\nt = gets.to_i\n\nif (a == b)\n puts \"YES\"\n exit\nend\n\nif (v <= w)\n puts \"NO\"\n exit\nend\n\nd = (b - a).abs\ne = v - w\nif (d / e <= t)\n puts \"YES\"\nelse\n puts \"NO\"\nend\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": 224, "cpu_time_ms": 61, "memory_kb": 14296}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s869988174", "group_id": "codeNet:p02657", "input_text": "a, b = gets.split(\" \").map(&:to_i)\nputs a * b", "language": "Ruby", "metadata": {"date": 1590973269, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s869988174.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s869988174", "user_id": "u748406041"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "a, b = gets.split(\" \").map(&:to_i)\nputs a * b", "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": 45, "cpu_time_ms": 56, "memory_kb": 14296}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s078248409", "group_id": "codeNet:p02660", "input_text": "require 'prime'\n\nn = gets.chomp.to_i\nhistories = []\ncount = 0\n\nif n == 1\n puts 0\nelsif Prime.prime?(n)\n puts 1\nelse\n loop do\n if Prime.prime?(n)\n puts count\n break\n end\n\n (2..n).each do |z|\n if !histories.include?(z) && n % z == 0\n n = n / z\n histories << z\n count += 1\n break\n end\n end\n\n if n == 1\n puts count\n break\n end\n end\nend", "language": "Ruby", "metadata": {"date": 1590978457, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s078248409.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s078248409", "user_id": "u265810213"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "require 'prime'\n\nn = gets.chomp.to_i\nhistories = []\ncount = 0\n\nif n == 1\n puts 0\nelsif Prime.prime?(n)\n puts 1\nelse\n loop do\n if Prime.prime?(n)\n puts count\n break\n end\n\n (2..n).each do |z|\n if !histories.include?(z) && n % z == 0\n n = n / z\n histories << z\n count += 1\n break\n end\n end\n\n if n == 1\n puts count\n break\n end\n end\nend", "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": 411, "cpu_time_ms": 2206, "memory_kb": 14484}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s763818116", "group_id": "codeNet:p02660", "input_text": "require 'prime'\n\nn = gets.to_i\n\ndiv = Prime.prime_division(n)\ndiv_map = div.to_h\n\nnum = div_map.keys\ncount = div_map.values.sum\n\nresult = 0\nbefore_result = 0\n\n(1..100).each{ |i|\n\tnum.repeated_combination(i).each{ |c|\n\t\tc_h = c.each_with_object(Hash.new(0)){ |x, h| h[x] += 1}\n\t\t\n\t\tflag = true\n\t\t\n\t\tc_h.each{ |k,v|\n\t\t\tif div_map[k] < v then\n\t\t\t\tflag = false\n\t\t\t\tbreak\n\t\t\tend\n\t\t}\n\t\t\n\t\tif flag then\n\t\t\tc_h.each{ |k,v|\n\t\t\t\tdiv_map[k] -= v\n\t\t\t}\n\t\t\t\n\t\t\tcount -= i\n\t\t\tresult += 1\n\t\t\t\n\t\t\tif count < i then\n\t\t\t\tputs result\n\t\t\t\texit\n\t\t\tend\n\t\tend\n\t}\n\n\tif before_result == result then\n\t\tbreak\n\telse\n\t\tbefore_result = result\n\tend\n\n\tnum = div_map.select{|k,v| v > 0}.keys\n}\n\nputs result\n", "language": "Ruby", "metadata": {"date": 1590977143, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s763818116.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s763818116", "user_id": "u874414087"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "require 'prime'\n\nn = gets.to_i\n\ndiv = Prime.prime_division(n)\ndiv_map = div.to_h\n\nnum = div_map.keys\ncount = div_map.values.sum\n\nresult = 0\nbefore_result = 0\n\n(1..100).each{ |i|\n\tnum.repeated_combination(i).each{ |c|\n\t\tc_h = c.each_with_object(Hash.new(0)){ |x, h| h[x] += 1}\n\t\t\n\t\tflag = true\n\t\t\n\t\tc_h.each{ |k,v|\n\t\t\tif div_map[k] < v then\n\t\t\t\tflag = false\n\t\t\t\tbreak\n\t\t\tend\n\t\t}\n\t\t\n\t\tif flag then\n\t\t\tc_h.each{ |k,v|\n\t\t\t\tdiv_map[k] -= v\n\t\t\t}\n\t\t\t\n\t\t\tcount -= i\n\t\t\tresult += 1\n\t\t\t\n\t\t\tif count < i then\n\t\t\t\tputs result\n\t\t\t\texit\n\t\t\tend\n\t\tend\n\t}\n\n\tif before_result == result then\n\t\tbreak\n\telse\n\t\tbefore_result = result\n\tend\n\n\tnum = div_map.select{|k,v| v > 0}.keys\n}\n\nputs result\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": 673, "cpu_time_ms": 330, "memory_kb": 14524}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s017101772", "group_id": "codeNet:p02661", "input_text": "n = gets.to_i\nx = n.times.map{gets.split.map(&:to_i)}\na = x.map{|a, b| a }.sort\nb = x.map{|a, b| b }.sort\nif n % 2 == 1\n ma = a[n/2]\n mb = b[n/2]\n puts mb - ma + 1\nelse\n ma1 = a[n/2]\n ma2 = a[n/2 - 1]\n mb1 = b[n/2]\n mb2 = b[n/2 - 1]\n puts (((mb1 + mb2) / 2.0 - (ma1 + ma2) / 2.0) * 2 + 1).to_i\nend", "language": "Ruby", "metadata": {"date": 1590975580, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02661.html", "problem_id": "p02661", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02661/input.txt", "sample_output_relpath": "derived/input_output/data/p02661/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02661/Ruby/s017101772.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s017101772", "user_id": "u374765295"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "n = gets.to_i\nx = n.times.map{gets.split.map(&:to_i)}\na = x.map{|a, b| a }.sort\nb = x.map{|a, b| b }.sort\nif n % 2 == 1\n ma = a[n/2]\n mb = b[n/2]\n puts mb - ma + 1\nelse\n ma1 = a[n/2]\n ma2 = a[n/2 - 1]\n mb1 = b[n/2]\n mb2 = b[n/2 - 1]\n puts (((mb1 + mb2) / 2.0 - (ma1 + ma2) / 2.0) * 2 + 1).to_i\nend", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N integers X_1, X_2, \\cdots, X_N, and we know that A_i \\leq X_i \\leq B_i.\nFind the number of different values that the median of X_1, X_2, \\cdots, X_N can take.\n\nNotes\n\nThe median of X_1, X_2, \\cdots, X_N is defined as follows. Let x_1, x_2, \\cdots, x_N be the result of sorting X_1, X_2, \\cdots, X_N in ascending order.\n\nIf N is odd, the median is x_{(N+1)/2};\n\nif N is even, the median is (x_{N/2} + x_{N/2+1}) / 2.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\nA_2 B_2\n:\nA_N B_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2\n1 2\n2 3\n\nSample Output 1\n\n3\n\nIf X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\nif X_1 = 1 and X_2 = 3, the median is 2;\n\nif X_1 = 2 and X_2 = 2, the median is 2;\n\nif X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\nSample Input 2\n\n3\n100 100\n10 10000\n1 1000000000\n\nSample Output 2\n\n9991", "sample_input": "2\n1 2\n2 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02661", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N integers X_1, X_2, \\cdots, X_N, and we know that A_i \\leq X_i \\leq B_i.\nFind the number of different values that the median of X_1, X_2, \\cdots, X_N can take.\n\nNotes\n\nThe median of X_1, X_2, \\cdots, X_N is defined as follows. Let x_1, x_2, \\cdots, x_N be the result of sorting X_1, X_2, \\cdots, X_N in ascending order.\n\nIf N is odd, the median is x_{(N+1)/2};\n\nif N is even, the median is (x_{N/2} + x_{N/2+1}) / 2.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\nA_2 B_2\n:\nA_N B_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2\n1 2\n2 3\n\nSample Output 1\n\n3\n\nIf X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\nif X_1 = 1 and X_2 = 3, the median is 2;\n\nif X_1 = 2 and X_2 = 2, the median is 2;\n\nif X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\nSample Input 2\n\n3\n100 100\n10 10000\n1 1000000000\n\nSample Output 2\n\n9991", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 321, "cpu_time_ms": 374, "memory_kb": 36092}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s783989629", "group_id": "codeNet:p02662", "input_text": "mod = 998244353\n\nn, s = gets.to_s.split.map{|e| e.to_i }\na = gets.to_s.split.map{|e| e.to_i }.sort\n\ndp = [0] * (s+1)\ndp[0] = 1\n\ns_max = 0\na.each do |t|\n s_max = s < s_max + t ? s : s_max + t\n s_max.downto(0) do |j|\n dp[j] *= 2\n dp[j] += dp[j-t] if j - t >= 0\n dp[j] %= mod if dp[j] >= mod\n end\nend\n\nputs dp[s]\n", "language": "Ruby", "metadata": {"date": 1591035222, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02662.html", "problem_id": "p02662", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02662/input.txt", "sample_output_relpath": "derived/input_output/data/p02662/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02662/Ruby/s783989629.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s783989629", "user_id": "u693378622"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "mod = 998244353\n\nn, s = gets.to_s.split.map{|e| e.to_i }\na = gets.to_s.split.map{|e| e.to_i }.sort\n\ndp = [0] * (s+1)\ndp[0] = 1\n\ns_max = 0\na.each do |t|\n s_max = s < s_max + t ? s : s_max + t\n s_max.downto(0) do |j|\n dp[j] *= 2\n dp[j] += dp[j-t] if j - t >= 0\n dp[j] %= mod if dp[j] >= mod\n end\nend\n\nputs dp[s]\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are a sequence of N positive integers A_1, A_2, \\ldots, A_N and another positive integer S.\n\nFor a non-empty subset T of the set \\{1, 2, \\ldots , N \\}, let us define f(T) as follows:\n\nf(T) is the number of different non-empty subsets \\{x_1, x_2, \\ldots , x_k \\} of T such that A_{x_1}+A_{x_2}+\\cdots +A_{x_k} = S.\n\nFind the sum of f(T) over all 2^N-1 subsets T of \\{1, 2, \\ldots , N \\}. Since the sum can be enormous, print it modulo 998244353.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 3000\n\n1 \\leq S \\leq 3000\n\n1 \\leq A_i \\leq 3000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN S\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the sum of f(T) modulo 998244353.\n\nSample Input 1\n\n3 4\n2 2 4\n\nSample Output 1\n\n6\n\nFor each T, the value of f(T) is shown below. The sum of these values is 6.\n\nf(\\{1\\}) = 0\n\nf(\\{2\\}) = 0\n\nf(\\{3\\}) = 1 (One subset \\{3\\} satisfies the condition.)\n\nf(\\{1, 2\\}) = 1 (\\{1, 2\\})\n\nf(\\{2, 3\\}) = 1 (\\{3\\})\n\nf(\\{1, 3\\}) = 1 (\\{3\\})\n\nf(\\{1, 2, 3\\}) = 2 (\\{1, 2\\}, \\{3\\})\n\nSample Input 2\n\n5 8\n9 9 9 9 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n10 10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n3296", "sample_input": "3 4\n2 2 4\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02662", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are a sequence of N positive integers A_1, A_2, \\ldots, A_N and another positive integer S.\n\nFor a non-empty subset T of the set \\{1, 2, \\ldots , N \\}, let us define f(T) as follows:\n\nf(T) is the number of different non-empty subsets \\{x_1, x_2, \\ldots , x_k \\} of T such that A_{x_1}+A_{x_2}+\\cdots +A_{x_k} = S.\n\nFind the sum of f(T) over all 2^N-1 subsets T of \\{1, 2, \\ldots , N \\}. Since the sum can be enormous, print it modulo 998244353.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 3000\n\n1 \\leq S \\leq 3000\n\n1 \\leq A_i \\leq 3000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN S\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the sum of f(T) modulo 998244353.\n\nSample Input 1\n\n3 4\n2 2 4\n\nSample Output 1\n\n6\n\nFor each T, the value of f(T) is shown below. The sum of these values is 6.\n\nf(\\{1\\}) = 0\n\nf(\\{2\\}) = 0\n\nf(\\{3\\}) = 1 (One subset \\{3\\} satisfies the condition.)\n\nf(\\{1, 2\\}) = 1 (\\{1, 2\\})\n\nf(\\{2, 3\\}) = 1 (\\{3\\})\n\nf(\\{1, 3\\}) = 1 (\\{3\\})\n\nf(\\{1, 2, 3\\}) = 2 (\\{1, 2\\}, \\{3\\})\n\nSample Input 2\n\n5 8\n9 9 9 9 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n10 10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n3296", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1332, "memory_kb": 14440}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s607896374", "group_id": "codeNet:p02662", "input_text": "n, s = gets.split(\" \").map(&:to_i)\nalist = gets.split(\" \").map(&:to_i)\nm = 998244353\n\ndp = Array.new(n+1) { Array.new(s+1, 0)}\ndp[0][0] = 1\n\nfor i in 0..n-1 do\n for j in 0..s do\n dp[i+1][j] a= (dp[i+1][j] + (dp[i][j] << 1)) % m\n if j + alist[i] <= s then \n dp[i+1][j + alist[i]] = (dp[i+1][j + alist[i]] + dp[i][j]) % m\n end \n end\nend\n\nprint dp[n][s]", "language": "Ruby", "metadata": {"date": 1590990282, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02662.html", "problem_id": "p02662", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02662/input.txt", "sample_output_relpath": "derived/input_output/data/p02662/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02662/Ruby/s607896374.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s607896374", "user_id": "u014800961"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "n, s = gets.split(\" \").map(&:to_i)\nalist = gets.split(\" \").map(&:to_i)\nm = 998244353\n\ndp = Array.new(n+1) { Array.new(s+1, 0)}\ndp[0][0] = 1\n\nfor i in 0..n-1 do\n for j in 0..s do\n dp[i+1][j] a= (dp[i+1][j] + (dp[i][j] << 1)) % m\n if j + alist[i] <= s then \n dp[i+1][j + alist[i]] = (dp[i+1][j + alist[i]] + dp[i][j]) % m\n end \n end\nend\n\nprint dp[n][s]", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are a sequence of N positive integers A_1, A_2, \\ldots, A_N and another positive integer S.\n\nFor a non-empty subset T of the set \\{1, 2, \\ldots , N \\}, let us define f(T) as follows:\n\nf(T) is the number of different non-empty subsets \\{x_1, x_2, \\ldots , x_k \\} of T such that A_{x_1}+A_{x_2}+\\cdots +A_{x_k} = S.\n\nFind the sum of f(T) over all 2^N-1 subsets T of \\{1, 2, \\ldots , N \\}. Since the sum can be enormous, print it modulo 998244353.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 3000\n\n1 \\leq S \\leq 3000\n\n1 \\leq A_i \\leq 3000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN S\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the sum of f(T) modulo 998244353.\n\nSample Input 1\n\n3 4\n2 2 4\n\nSample Output 1\n\n6\n\nFor each T, the value of f(T) is shown below. The sum of these values is 6.\n\nf(\\{1\\}) = 0\n\nf(\\{2\\}) = 0\n\nf(\\{3\\}) = 1 (One subset \\{3\\} satisfies the condition.)\n\nf(\\{1, 2\\}) = 1 (\\{1, 2\\})\n\nf(\\{2, 3\\}) = 1 (\\{3\\})\n\nf(\\{1, 3\\}) = 1 (\\{3\\})\n\nf(\\{1, 2, 3\\}) = 2 (\\{1, 2\\}, \\{3\\})\n\nSample Input 2\n\n5 8\n9 9 9 9 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n10 10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n3296", "sample_input": "3 4\n2 2 4\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02662", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are a sequence of N positive integers A_1, A_2, \\ldots, A_N and another positive integer S.\n\nFor a non-empty subset T of the set \\{1, 2, \\ldots , N \\}, let us define f(T) as follows:\n\nf(T) is the number of different non-empty subsets \\{x_1, x_2, \\ldots , x_k \\} of T such that A_{x_1}+A_{x_2}+\\cdots +A_{x_k} = S.\n\nFind the sum of f(T) over all 2^N-1 subsets T of \\{1, 2, \\ldots , N \\}. Since the sum can be enormous, print it modulo 998244353.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 3000\n\n1 \\leq S \\leq 3000\n\n1 \\leq A_i \\leq 3000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN S\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the sum of f(T) modulo 998244353.\n\nSample Input 1\n\n3 4\n2 2 4\n\nSample Output 1\n\n6\n\nFor each T, the value of f(T) is shown below. The sum of these values is 6.\n\nf(\\{1\\}) = 0\n\nf(\\{2\\}) = 0\n\nf(\\{3\\}) = 1 (One subset \\{3\\} satisfies the condition.)\n\nf(\\{1, 2\\}) = 1 (\\{1, 2\\})\n\nf(\\{2, 3\\}) = 1 (\\{3\\})\n\nf(\\{1, 3\\}) = 1 (\\{3\\})\n\nf(\\{1, 2, 3\\}) = 2 (\\{1, 2\\}, \\{3\\})\n\nSample Input 2\n\n5 8\n9 9 9 9 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n10 10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n3296", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 57, "memory_kb": 14364}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s960139105", "group_id": "codeNet:p02664", "input_text": "t = gets.chomp\nres = ''\nt.each_char do |s|\n if s != '?'\n res << s\n else\n res << 'D'\n end\nend\nputs res", "language": "Ruby", "metadata": {"date": 1590889890, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02664.html", "problem_id": "p02664", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02664/input.txt", "sample_output_relpath": "derived/input_output/data/p02664/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02664/Ruby/s960139105.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s960139105", "user_id": "u088221425"}, "prompt_components": {"gold_output": "PDPDPDP\n", "input_to_evaluate": "t = gets.chomp\nres = ''\nt.each_char do |s|\n if s != '?'\n res << s\n else\n res << 'D'\n end\nend\nputs res", "problem_context": "Score : 200 points\n\nProblem Statement\n\nFor a string S consisting of the uppercase English letters P and D, let the doctoral and postdoctoral quotient of S be the total number of occurrences of D and PD in S as contiguous substrings. For example, if S = PPDDP, it contains two occurrences of D and one occurrence of PD as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3.\n\nWe have a string T consisting of P, D, and ?.\n\nAmong the strings that can be obtained by replacing each ? in T with P or D, find one with the maximum possible doctoral and postdoctoral quotient.\n\nConstraints\n\n1 \\leq |T| \\leq 2 \\times 10^5\n\nT consists of P, D, and ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\n\nOutput\n\nPrint one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each ? in T with P or D.\nIf there are multiple such strings, you may print any of them.\n\nSample Input 1\n\nPD?D??P\n\nSample Output 1\n\nPDPDPDP\n\nThis string contains three occurrences of D and three occurrences of PD as contiguous substrings, so its doctoral and postdoctoral quotient is 6, which is the maximum doctoral and postdoctoral quotient of a string obtained by replacing each ? in T with P or D.\n\nSample Input 2\n\nP?P?\n\nSample Output 2\n\nPDPD", "sample_input": "PD?D??P\n"}, "reference_outputs": ["PDPDPDP\n"], "source_document_id": "p02664", "source_text": "Score : 200 points\n\nProblem Statement\n\nFor a string S consisting of the uppercase English letters P and D, let the doctoral and postdoctoral quotient of S be the total number of occurrences of D and PD in S as contiguous substrings. For example, if S = PPDDP, it contains two occurrences of D and one occurrence of PD as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3.\n\nWe have a string T consisting of P, D, and ?.\n\nAmong the strings that can be obtained by replacing each ? in T with P or D, find one with the maximum possible doctoral and postdoctoral quotient.\n\nConstraints\n\n1 \\leq |T| \\leq 2 \\times 10^5\n\nT consists of P, D, and ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\n\nOutput\n\nPrint one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each ? in T with P or D.\nIf there are multiple such strings, you may print any of them.\n\nSample Input 1\n\nPD?D??P\n\nSample Output 1\n\nPDPDPDP\n\nThis string contains three occurrences of D and three occurrences of PD as contiguous substrings, so its doctoral and postdoctoral quotient is 6, which is the maximum doctoral and postdoctoral quotient of a string obtained by replacing each ? in T with P or D.\n\nSample Input 2\n\nP?P?\n\nSample Output 2\n\nPDPD", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 110, "cpu_time_ms": 87, "memory_kb": 14868}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s558404998", "group_id": "codeNet:p02665", "input_text": "n = gets.to_i\na = gets.split.map(&:to_i).reverse\nd = a.length\nlimit_by_bottom = [a.first, a.first]\nq = []\na.each.with_index(1) do |ai, idx|\n di = d - idx\n # 下の深さからの制約(この階層のleaf数にプラスして下の階層のノード数が必要)\n bl = idx == 1 ? limit_by_bottom : [(limit_by_bottom[0]+ai).divmod(2).sum, limit_by_bottom[1]+ai]\n # この深さに対する制約\n cl = [idx == 1 ? ai : ai + 1, 2**di] # 存在可能なノード数の制約\n # 新制約\n nl = [[bl[0], cl[0]].max, [bl[1], cl[1]].min]\n\n # 制約が矛盾したら終了\n if nl[0] > nl[1]\n puts '-1'\n exit 0\n end\n\n # 矛盾しなければ上の深さに対する制約を設定して次へ\n q << [nl, ai]\n limit_by_bottom = nl\nend\ncount = 0\nlt = nil\nq.reverse.each do |qi|\n if lt\n n = [lt[1], qi[0][1]].min\n count += n\n lt = [n - qi[1], (n - qi[1]) * 2]\n else\n count += qi[0].max\n lt = [qi[0].max - qi[1], (qi[0].max - qi[1]) * 2]\n end\nend\nputs count", "language": "Ruby", "metadata": {"date": 1590893607, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02665.html", "problem_id": "p02665", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02665/input.txt", "sample_output_relpath": "derived/input_output/data/p02665/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02665/Ruby/s558404998.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s558404998", "user_id": "u604352408"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "n = gets.to_i\na = gets.split.map(&:to_i).reverse\nd = a.length\nlimit_by_bottom = [a.first, a.first]\nq = []\na.each.with_index(1) do |ai, idx|\n di = d - idx\n # 下の深さからの制約(この階層のleaf数にプラスして下の階層のノード数が必要)\n bl = idx == 1 ? limit_by_bottom : [(limit_by_bottom[0]+ai).divmod(2).sum, limit_by_bottom[1]+ai]\n # この深さに対する制約\n cl = [idx == 1 ? ai : ai + 1, 2**di] # 存在可能なノード数の制約\n # 新制約\n nl = [[bl[0], cl[0]].max, [bl[1], cl[1]].min]\n\n # 制約が矛盾したら終了\n if nl[0] > nl[1]\n puts '-1'\n exit 0\n end\n\n # 矛盾しなければ上の深さに対する制約を設定して次へ\n q << [nl, ai]\n limit_by_bottom = nl\nend\ncount = 0\nlt = nil\nq.reverse.each do |qi|\n if lt\n n = [lt[1], qi[0][1]].min\n count += n\n lt = [n - qi[1], (n - qi[1]) * 2]\n else\n count += qi[0].max\n lt = [qi[0].max - qi[1], (qi[0].max - qi[1]) * 2]\n end\nend\nputs count", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven is an integer sequence of length N+1: A_0, A_1, A_2, \\ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \\ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1.\n\nNotes\n\nA binary tree is a rooted tree such that each vertex has at most two direct children.\n\nA leaf in a binary tree is a vertex with zero children.\n\nThe depth of a vertex v in a binary tree is the distance from the tree's root to v. (The root has the depth of 0.)\n\nThe depth of a binary tree is the maximum depth of a vertex in the tree.\n\nConstraints\n\n0 \\leq N \\leq 10^5\n\n0 \\leq A_i \\leq 10^{8} (0 \\leq i \\leq N)\n\nA_N \\geq 1\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_0 A_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the answer as an integer.\n\nSample Input 1\n\n3\n0 1 1 2\n\nSample Output 1\n\n7\n\nBelow is the tree with the maximum possible number of vertices. It has seven vertices, so we should print 7.\n\nSample Input 2\n\n4\n0 0 1 0 2\n\nSample Output 2\n\n10\n\nSample Input 3\n\n2\n0 3 1\n\nSample Output 3\n\n-1\n\nSample Input 4\n\n1\n1 1\n\nSample Output 4\n\n-1\n\nSample Input 5\n\n10\n0 0 1 1 2 3 5 8 13 21 34\n\nSample Output 5\n\n264", "sample_input": "3\n0 1 1 2\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02665", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven is an integer sequence of length N+1: A_0, A_1, A_2, \\ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \\ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1.\n\nNotes\n\nA binary tree is a rooted tree such that each vertex has at most two direct children.\n\nA leaf in a binary tree is a vertex with zero children.\n\nThe depth of a vertex v in a binary tree is the distance from the tree's root to v. (The root has the depth of 0.)\n\nThe depth of a binary tree is the maximum depth of a vertex in the tree.\n\nConstraints\n\n0 \\leq N \\leq 10^5\n\n0 \\leq A_i \\leq 10^{8} (0 \\leq i \\leq N)\n\nA_N \\geq 1\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_0 A_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the answer as an integer.\n\nSample Input 1\n\n3\n0 1 1 2\n\nSample Output 1\n\n7\n\nBelow is the tree with the maximum possible number of vertices. It has seven vertices, so we should print 7.\n\nSample Input 2\n\n4\n0 0 1 0 2\n\nSample Output 2\n\n10\n\nSample Input 3\n\n2\n0 3 1\n\nSample Output 3\n\n-1\n\nSample Input 4\n\n1\n1 1\n\nSample Output 4\n\n-1\n\nSample Input 5\n\n10\n0 0 1 1 2 3 5 8 13 21 34\n\nSample Output 5\n\n264", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 987, "cpu_time_ms": 2209, "memory_kb": 99256}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s961310005", "group_id": "codeNet:p02675", "input_text": "n = gets.split('').map(&:to_i)\n\nif [2,4,5,7,9].include?(n[-1])\n puts 'hon'\nelsif [0,1,6,8].include?(n[-1])\n puts 'pon'\nelsif [3].include?(n[-1])\n puts 'bon'\nend\n\n", "language": "Ruby", "metadata": {"date": 1589763733, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s961310005.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s961310005", "user_id": "u238956837"}, "prompt_components": {"gold_output": "pon\n", "input_to_evaluate": "n = gets.split('').map(&:to_i)\n\nif [2,4,5,7,9].include?(n[-1])\n puts 'hon'\nelsif [0,1,6,8].include?(n[-1])\n puts 'pon'\nelsif [3].include?(n[-1])\n puts 'bon'\nend\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": 165, "cpu_time_ms": 55, "memory_kb": 14392}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s077627398", "group_id": "codeNet:p02676", "input_text": "\n#標準入力\n#整数一文字の場合\nn = gets.to_i\n\ns = gets.to_s\n\nif s.length <= n then \n\tputs s\nelse\n\ts = s.slice(0..n-1) + \"...\"\n\tputs s\nend\n\n", "language": "Ruby", "metadata": {"date": 1597591464, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02676.html", "problem_id": "p02676", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02676/input.txt", "sample_output_relpath": "derived/input_output/data/p02676/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02676/Ruby/s077627398.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s077627398", "user_id": "u663882298"}, "prompt_components": {"gold_output": "nikoand...\n", "input_to_evaluate": "\n#標準入力\n#整数一文字の場合\nn = gets.to_i\n\ns = gets.to_s\n\nif s.length <= n then \n\tputs s\nelse\n\ts = s.slice(0..n-1) + \"...\"\n\tputs s\nend\n\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nWe have a string S consisting of lowercase English letters.\n\nIf the length of S is at most K, print S without change.\n\nIf the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and print the result.\n\nConstraints\n\nK is an integer between 1 and 100 (inclusive).\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nS\n\nOutput\n\nPrint a string as stated in Problem Statement.\n\nSample Input 1\n\n7\nnikoandsolstice\n\nSample Output 1\n\nnikoand...\n\nnikoandsolstice has a length of 15, which exceeds K=7.\n\nWe should extract the first 7 characters in this string, append ... to the end of them, and print the result nikoand....\n\nSample Input 2\n\n40\nferelibenterhominesidquodvoluntcredunt\n\nSample Output 2\n\nferelibenterhominesidquodvoluntcredunt\n\nThe famous quote from Gaius Julius Caesar.", "sample_input": "7\nnikoandsolstice\n"}, "reference_outputs": ["nikoand...\n"], "source_document_id": "p02676", "source_text": "Score: 200 points\n\nProblem Statement\n\nWe have a string S consisting of lowercase English letters.\n\nIf the length of S is at most K, print S without change.\n\nIf the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and print the result.\n\nConstraints\n\nK is an integer between 1 and 100 (inclusive).\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nS\n\nOutput\n\nPrint a string as stated in Problem Statement.\n\nSample Input 1\n\n7\nnikoandsolstice\n\nSample Output 1\n\nnikoand...\n\nnikoandsolstice has a length of 15, which exceeds K=7.\n\nWe should extract the first 7 characters in this string, append ... to the end of them, and print the result nikoand....\n\nSample Input 2\n\n40\nferelibenterhominesidquodvoluntcredunt\n\nSample Output 2\n\nferelibenterhominesidquodvoluntcredunt\n\nThe famous quote from Gaius Julius Caesar.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 149, "cpu_time_ms": 68, "memory_kb": 14280}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s407407396", "group_id": "codeNet:p02676", "input_text": "K = gets.split.map(&:to_i)\nS = gets.split.map(&:to_s)\n\nif S.size <= K\n puts(\"S\")\nelse\n ans = S.shift(K)\n puts(\"ans\")\nend\n", "language": "Ruby", "metadata": {"date": 1592422231, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02676.html", "problem_id": "p02676", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02676/input.txt", "sample_output_relpath": "derived/input_output/data/p02676/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02676/Ruby/s407407396.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s407407396", "user_id": "u246530341"}, "prompt_components": {"gold_output": "nikoand...\n", "input_to_evaluate": "K = gets.split.map(&:to_i)\nS = gets.split.map(&:to_s)\n\nif S.size <= K\n puts(\"S\")\nelse\n ans = S.shift(K)\n puts(\"ans\")\nend\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nWe have a string S consisting of lowercase English letters.\n\nIf the length of S is at most K, print S without change.\n\nIf the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and print the result.\n\nConstraints\n\nK is an integer between 1 and 100 (inclusive).\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nS\n\nOutput\n\nPrint a string as stated in Problem Statement.\n\nSample Input 1\n\n7\nnikoandsolstice\n\nSample Output 1\n\nnikoand...\n\nnikoandsolstice has a length of 15, which exceeds K=7.\n\nWe should extract the first 7 characters in this string, append ... to the end of them, and print the result nikoand....\n\nSample Input 2\n\n40\nferelibenterhominesidquodvoluntcredunt\n\nSample Output 2\n\nferelibenterhominesidquodvoluntcredunt\n\nThe famous quote from Gaius Julius Caesar.", "sample_input": "7\nnikoandsolstice\n"}, "reference_outputs": ["nikoand...\n"], "source_document_id": "p02676", "source_text": "Score: 200 points\n\nProblem Statement\n\nWe have a string S consisting of lowercase English letters.\n\nIf the length of S is at most K, print S without change.\n\nIf the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and print the result.\n\nConstraints\n\nK is an integer between 1 and 100 (inclusive).\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nS\n\nOutput\n\nPrint a string as stated in Problem Statement.\n\nSample Input 1\n\n7\nnikoandsolstice\n\nSample Output 1\n\nnikoand...\n\nnikoandsolstice has a length of 15, which exceeds K=7.\n\nWe should extract the first 7 characters in this string, append ... to the end of them, and print the result nikoand....\n\nSample Input 2\n\n40\nferelibenterhominesidquodvoluntcredunt\n\nSample Output 2\n\nferelibenterhominesidquodvoluntcredunt\n\nThe famous quote from Gaius Julius Caesar.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 124, "cpu_time_ms": 63, "memory_kb": 14368}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s316157573", "group_id": "codeNet:p02677", "input_text": "a, b, h, m = gets.chomp.split(\" \").map(&:to_f)\n\ni = Math::PI * 2 * (h + m / 60 ) / 12\nj = Math::PI * 2 * m / 60\n\n\nputs Math.sqrt( a**2 + b**2 - 2 * a * b * Math.cos( ( i - j ).abs ) ) \n", "language": "Ruby", "metadata": {"date": 1591451556, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s316157573.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s316157573", "user_id": "u867104501"}, "prompt_components": {"gold_output": "5.00000000000000000000\n", "input_to_evaluate": "a, b, h, m = gets.chomp.split(\" \").map(&:to_f)\n\ni = Math::PI * 2 * (h + m / 60 ) / 12\nj = Math::PI * 2 * m / 60\n\n\nputs Math.sqrt( a**2 + b**2 - 2 * a * b * Math.cos( ( i - j ).abs ) ) \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": 185, "cpu_time_ms": 56, "memory_kb": 14692}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s974804621", "group_id": "codeNet:p02677", "input_text": "require 'bigdecimal'\nrequire 'bigdecimal/util'\nrequire \"bigdecimal/math\"\ninclude BigMath\n\nA, B, H, M = gets.chomp.split.map(&:to_i)\n\ndigA = (30.0 * H).modulo(360) + 0.5 * M\ndigB = 6.0 * M\ntheta = (digA - digB).abs.modulo(180) * BigMath::PI(12) / 180.0\n\nif digA == digB then\n puts (A - B).abs\nelsif (digA - digB).abs.modulo(180) == 0 then\n puts (A + B).abs\nelse\n puts BigMath::sqrt(( A**2 + B**2 - (2 * A * B * BigMath::cos(theta,12)) ).abs, 12)\nend", "language": "Ruby", "metadata": {"date": 1589768149, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s974804621.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s974804621", "user_id": "u226855113"}, "prompt_components": {"gold_output": "5.00000000000000000000\n", "input_to_evaluate": "require 'bigdecimal'\nrequire 'bigdecimal/util'\nrequire \"bigdecimal/math\"\ninclude BigMath\n\nA, B, H, M = gets.chomp.split.map(&:to_i)\n\ndigA = (30.0 * H).modulo(360) + 0.5 * M\ndigB = 6.0 * M\ntheta = (digA - digB).abs.modulo(180) * BigMath::PI(12) / 180.0\n\nif digA == digB then\n puts (A - B).abs\nelsif (digA - digB).abs.modulo(180) == 0 then\n puts (A + B).abs\nelse\n puts BigMath::sqrt(( A**2 + B**2 - (2 * A * B * BigMath::cos(theta,12)) ).abs, 12)\nend", "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": 451, "cpu_time_ms": 62, "memory_kb": 14628}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s468672193", "group_id": "codeNet:p02678", "input_text": "n, m = gets.chomp.split.map(&:to_i)\n\nmap = []\nm.times do\n a, b = gets.chomp.split.map(&:to_i)\n map[a] = map[a] || []\n map[a] << b\n map[b] = map[b] || []\n map[b] << a\nend\n\ndp = []\ndp[1] = 1\n\nqueue = Queue.new\nqueue << 1\n\nloop do\n break if queue.empty?\n a = queue.pop\n bs = map[a]\n bs.each do |b|\n if dp[b].nil?\n dp[b] = a\n queue << b\n end\n end\nend\n\nresult = dp[(2..n)]\n\nif result.include?(nil)\n puts 'No'\nelse\n puts 'Yes'\n result.each do |r|\n puts r\n end\nend\n", "language": "Ruby", "metadata": {"date": 1589767703, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s468672193.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s468672193", "user_id": "u757358412"}, "prompt_components": {"gold_output": "Yes\n1\n2\n2\n", "input_to_evaluate": "n, m = gets.chomp.split.map(&:to_i)\n\nmap = []\nm.times do\n a, b = gets.chomp.split.map(&:to_i)\n map[a] = map[a] || []\n map[a] << b\n map[b] = map[b] || []\n map[b] << a\nend\n\ndp = []\ndp[1] = 1\n\nqueue = Queue.new\nqueue << 1\n\nloop do\n break if queue.empty?\n a = queue.pop\n bs = map[a]\n bs.each do |b|\n if dp[b].nil?\n dp[b] = a\n queue << b\n end\n end\nend\n\nresult = dp[(2..n)]\n\nif result.include?(nil)\n puts 'No'\nelse\n puts 'Yes'\n result.each do |r|\n puts r\n end\nend\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nThere is a cave.\n\nThe cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.\n\nIt is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.\n\nSince it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.\n\nIf you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.\n\nDetermine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq N\\ (1 \\leq i \\leq M)\n\nA_i \\neq B_i\\ (1 \\leq i \\leq M)\n\nOne can travel between any two rooms by traversing passages.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nIf there is no way to place signposts satisfying the objective, print No.\n\nOtherwise, print N lines. The first line should contain Yes, and the i-th line (2 \\leq i \\leq N) should contain the integer representing the room indicated by the signpost in Room i.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 2\n\nSample Output 1\n\nYes\n1\n2\n2\n\nIf we place the signposts as described in the sample output, the following happens:\n\nStarting in Room 2, you will reach Room 1 after traversing one passage: (2) \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 3, you will reach Room 1 after traversing two passages: (3) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 4, you will reach Room 1 after traversing two passages: (4) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nThus, the objective is satisfied.\n\nSample Input 2\n\n6 9\n3 4\n6 1\n2 4\n5 3\n4 6\n1 5\n6 2\n4 5\n5 6\n\nSample Output 2\n\nYes\n6\n5\n5\n1\n1\n\nIf there are multiple solutions, any of them will be accepted.", "sample_input": "4 4\n1 2\n2 3\n3 4\n4 2\n"}, "reference_outputs": ["Yes\n1\n2\n2\n"], "source_document_id": "p02678", "source_text": "Score: 400 points\n\nProblem Statement\n\nThere is a cave.\n\nThe cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.\n\nIt is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.\n\nSince it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.\n\nIf you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.\n\nDetermine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq N\\ (1 \\leq i \\leq M)\n\nA_i \\neq B_i\\ (1 \\leq i \\leq M)\n\nOne can travel between any two rooms by traversing passages.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nIf there is no way to place signposts satisfying the objective, print No.\n\nOtherwise, print N lines. The first line should contain Yes, and the i-th line (2 \\leq i \\leq N) should contain the integer representing the room indicated by the signpost in Room i.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 2\n\nSample Output 1\n\nYes\n1\n2\n2\n\nIf we place the signposts as described in the sample output, the following happens:\n\nStarting in Room 2, you will reach Room 1 after traversing one passage: (2) \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 3, you will reach Room 1 after traversing two passages: (3) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 4, you will reach Room 1 after traversing two passages: (4) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nThus, the objective is satisfied.\n\nSample Input 2\n\n6 9\n3 4\n6 1\n2 4\n5 3\n4 6\n1 5\n6 2\n4 5\n5 6\n\nSample Output 2\n\nYes\n6\n5\n5\n1\n1\n\nIf there are multiple solutions, any of them will be accepted.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 543, "cpu_time_ms": 516, "memory_kb": 31660}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s653379238", "group_id": "codeNet:p02679", "input_text": "n = gets.to_i\na, b = Array.new(n) { gets.split.map(&:to_i) }.transpose\nmod = 10**9 + 7\nh = Hash.new(0)\narr = []\nans = 0\n\na.zip(b).each do |i, j|\n if i == 0 && j == 0\n ans += 1\n elsif i == 0\n h[0, 1] += 1\n elsif j == 0\n h[-1, 0] += 1\n else\n gcd = i.gcd(j)\n i *= -1 if j < 0\n h[[i / gcd, j.abs / gcd]] += 1\n end\nend\n\nh.each do |(i, j), v|\n if i > 0\n arr << 2**v + 2**h[[-j, i]] - 1\n h.delete([-j, i])\n elsif i < 0\n arr << 2**v + 2**h[[j, -i]] - 1\n h.delete([j, -i])\n else\n arr << 2**v\n end\nend\n\nans = (ans + arr.inject { |i, j| i * j % mod }) % mod - 1\n\nputs ans < 0 ? ans + mod : ans", "language": "Ruby", "metadata": {"date": 1593200716, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02679.html", "problem_id": "p02679", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02679/input.txt", "sample_output_relpath": "derived/input_output/data/p02679/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02679/Ruby/s653379238.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s653379238", "user_id": "u104886851"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "n = gets.to_i\na, b = Array.new(n) { gets.split.map(&:to_i) }.transpose\nmod = 10**9 + 7\nh = Hash.new(0)\narr = []\nans = 0\n\na.zip(b).each do |i, j|\n if i == 0 && j == 0\n ans += 1\n elsif i == 0\n h[0, 1] += 1\n elsif j == 0\n h[-1, 0] += 1\n else\n gcd = i.gcd(j)\n i *= -1 if j < 0\n h[[i / gcd, j.abs / gcd]] += 1\n end\nend\n\nh.each do |(i, j), v|\n if i > 0\n arr << 2**v + 2**h[[-j, i]] - 1\n h.delete([-j, i])\n elsif i < 0\n arr << 2**v + 2**h[[j, -i]] - 1\n h.delete([j, -i])\n else\n arr << 2**v\n end\nend\n\nans = (ans + arr.inject { |i, j| i * j % mod }) % mod - 1\n\nputs ans < 0 ? ans + mod : ans", "problem_context": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "sample_input": "3\n1 2\n-1 1\n2 -1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02679", "source_text": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 624, "cpu_time_ms": 1023, "memory_kb": 57796}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s530732078", "group_id": "codeNet:p02679", "input_text": "P = 1000000007\ndef pow(a,n)\n\tr = 1\n\twhile n > 0\n\t\tif n % 2 == 1\n\t\t\tr *= a\n\t\t\tr %= P\n\t\tend\n\t\ta *= 2\n\t\ta %= P\n\t\tn /= 2\n\tend\n\tr\nend\nN = gets.to_i\nA = Hash.new{0}\nN.times{|n|\n\ta, b = gets.split.map(&:to_i)\n\tA[Rational(a, b)] += 1\n}\nkeys = A.keys\nr = 1\nkeys.each{|k|\n\tnext unless A[k]\n\tif A[-1 / k]\n\t\ta = pow(2, A[k]) - 1\n\t\tb = pow(2, A[-1 / k]) - 1\n\t\tr *= a + b + 1\n\t\tr %= P\n\t\tA[-1 / k] = nil\n\telse\n\t\tr *= pow(2, A[k])\n\t\tr %= P\n\tend\n}\nputs (r - 1) % P\n", "language": "Ruby", "metadata": {"date": 1589768475, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02679.html", "problem_id": "p02679", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02679/input.txt", "sample_output_relpath": "derived/input_output/data/p02679/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02679/Ruby/s530732078.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s530732078", "user_id": "u488526012"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "P = 1000000007\ndef pow(a,n)\n\tr = 1\n\twhile n > 0\n\t\tif n % 2 == 1\n\t\t\tr *= a\n\t\t\tr %= P\n\t\tend\n\t\ta *= 2\n\t\ta %= P\n\t\tn /= 2\n\tend\n\tr\nend\nN = gets.to_i\nA = Hash.new{0}\nN.times{|n|\n\ta, b = gets.split.map(&:to_i)\n\tA[Rational(a, b)] += 1\n}\nkeys = A.keys\nr = 1\nkeys.each{|k|\n\tnext unless A[k]\n\tif A[-1 / k]\n\t\ta = pow(2, A[k]) - 1\n\t\tb = pow(2, A[-1 / k]) - 1\n\t\tr *= a + b + 1\n\t\tr %= P\n\t\tA[-1 / k] = nil\n\telse\n\t\tr *= pow(2, A[k])\n\t\tr %= P\n\tend\n}\nputs (r - 1) % P\n", "problem_context": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "sample_input": "3\n1 2\n-1 1\n2 -1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02679", "source_text": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 448, "cpu_time_ms": 1998, "memory_kb": 55136}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s660526795", "group_id": "codeNet:p02681", "input_text": "S=gets.chop\nT=gets.chop\nif(S==T.chop)\n print(\"Yes\\n\")\nelse\n print(\"No\\n\")\nend\n", "language": "Ruby", "metadata": {"date": 1589159082, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02681.html", "problem_id": "p02681", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02681/input.txt", "sample_output_relpath": "derived/input_output/data/p02681/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02681/Ruby/s660526795.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s660526795", "user_id": "u628268449"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "S=gets.chop\nT=gets.chop\nif(S==T.chop)\n print(\"Yes\\n\")\nelse\n print(\"No\\n\")\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "sample_input": "chokudai\nchokudaiz\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02681", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 80, "cpu_time_ms": 57, "memory_kb": 14336}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s928435733", "group_id": "codeNet:p02682", "input_text": "a,b,c,k=`dd`.split.map &:to_i\nif k<=a\n p k\nelsif a 0\nputs cnt", "language": "Ruby", "metadata": {"date": 1589160821, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s624819492.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s624819492", "user_id": "u525844030"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "a,b,c,k = gets.chomp.split.map(&:to_i)\n\ncnt = 0\ncnt = a\ncnt += (k - a - b) * -1 if (k - a - b) > 0\nputs cnt", "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": 107, "cpu_time_ms": 55, "memory_kb": 14272}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s653911291", "group_id": "codeNet:p02682", "input_text": "A, B, C, K = gets.chomp.split.map(&:to_i)\n\nans = 0\nif K <= A + B then\n ans = A\nelse\n ans = A - (K - A - B)\nend\n\nputs ans\n", "language": "Ruby", "metadata": {"date": 1589159923, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s653911291.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s653911291", "user_id": "u394640249"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "A, B, C, K = gets.chomp.split.map(&:to_i)\n\nans = 0\nif K <= A + B then\n ans = A\nelse\n ans = A - (K - A - B)\nend\n\nputs ans\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "sample_input": "2 1 1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02682", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 127, "cpu_time_ms": 55, "memory_kb": 14332}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s882963568", "group_id": "codeNet:p02683", "input_text": "N,M,X = gets.chomp.split.map(&:to_i)\nC = N.times.map{gets.chomp.split.map(&:to_i)}\n\nD = C.transpose\ncount = 0\n(1..M).each do |i|\n if D[i].sum < X\n count += 1\n end\nend\nif count != 0\n puts \"-1\"\n exit\nend\n\nbits = [0, 1].repeated_permutation(N).to_a\nans = (10 ** 5) * 12\n\nbits.each do |bit|\n rikaido = [0] * (M + 1) \n (0..N-1).each do |j|\n if bit[j] == 1\n (0..M).each do |k|\n rikaido[k] += C[j][k]\n if rikaido[1..M].all? { |n| n >= X }\n ans = rikaido[0] if ans >= rikaido[0]\n end\n end\n end\n end\nend\n\nputs ans", "language": "Ruby", "metadata": {"date": 1589343264, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s882963568.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s882963568", "user_id": "u088211391"}, "prompt_components": {"gold_output": "120\n", "input_to_evaluate": "N,M,X = gets.chomp.split.map(&:to_i)\nC = N.times.map{gets.chomp.split.map(&:to_i)}\n\nD = C.transpose\ncount = 0\n(1..M).each do |i|\n if D[i].sum < X\n count += 1\n end\nend\nif count != 0\n puts \"-1\"\n exit\nend\n\nbits = [0, 1].repeated_permutation(N).to_a\nans = (10 ** 5) * 12\n\nbits.each do |bit|\n rikaido = [0] * (M + 1) \n (0..N-1).each do |j|\n if bit[j] == 1\n (0..M).each do |k|\n rikaido[k] += C[j][k]\n if rikaido[1..M].all? { |n| n >= X }\n ans = rikaido[0] if ans >= rikaido[0]\n end\n end\n end\n end\nend\n\nputs ans", "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": 560, "cpu_time_ms": 255, "memory_kb": 15708}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s388457383", "group_id": "codeNet:p02686", "input_text": "N, *Ss = readlines.map(&:chomp)\n\nas, os, cs = [], 0, 0\nSs.each do |s|\n o, c = 0, 0\n s.chars.each do |x|\n if x == ')'\n o == 0 ? c += 1 : o -= 1\n else\n o += 1\n end\n end\n if o == 0\n cs += c\n elsif c == 0\n os += o\n else\n as << [c, o]\n end\nend\n\nas.sort_by{|c, o| c - o}.each do |c, o|\n os -= c\n break if os < 0\n os += o\nend\nputs os == cs ? 'Yes' : 'No'", "language": "Ruby", "metadata": {"date": 1589554063, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02686.html", "problem_id": "p02686", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02686/input.txt", "sample_output_relpath": "derived/input_output/data/p02686/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02686/Ruby/s388457383.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s388457383", "user_id": "u304198114"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "N, *Ss = readlines.map(&:chomp)\n\nas, os, cs = [], 0, 0\nSs.each do |s|\n o, c = 0, 0\n s.chars.each do |x|\n if x == ')'\n o == 0 ? c += 1 : o -= 1\n else\n o += 1\n end\n end\n if o == 0\n cs += c\n elsif c == 0\n os += o\n else\n as << [c, o]\n end\nend\n\nas.sort_by{|c, o| c - o}.each do |c, o|\n os -= c\n break if os < 0\n os += o\nend\nputs os == cs ? 'Yes' : 'No'", "problem_context": "Score : 600 points\n\nProblem Statement\n\nA bracket sequence is a string that is one of the following:\n\nAn empty string;\n\nThe concatenation of (, A, and ) in this order, for some bracket sequence A ;\n\nThe concatenation of A and B in this order, for some non-empty bracket sequences A and B /\n\nGiven are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nThe total length of the strings S_i is at most 10^6.\n\nS_i is a non-empty string consisting of ( and ).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nIf a bracket sequence can be formed by concatenating all the N strings in some order, print Yes; otherwise, print No.\n\nSample Input 1\n\n2\n)\n(()\n\nSample Output 1\n\nYes\n\nConcatenating (() and ) in this order forms a bracket sequence.\n\nSample Input 2\n\n2\n)(\n()\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n4\n((()))\n((((((\n))))))\n()()()\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n3\n(((\n)\n)\n\nSample Output 4\n\nNo", "sample_input": "2\n)\n(()\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02686", "source_text": "Score : 600 points\n\nProblem Statement\n\nA bracket sequence is a string that is one of the following:\n\nAn empty string;\n\nThe concatenation of (, A, and ) in this order, for some bracket sequence A ;\n\nThe concatenation of A and B in this order, for some non-empty bracket sequences A and B /\n\nGiven are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nThe total length of the strings S_i is at most 10^6.\n\nS_i is a non-empty string consisting of ( and ).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nIf a bracket sequence can be formed by concatenating all the N strings in some order, print Yes; otherwise, print No.\n\nSample Input 1\n\n2\n)\n(()\n\nSample Output 1\n\nYes\n\nConcatenating (() and ) in this order forms a bracket sequence.\n\nSample Input 2\n\n2\n)(\n()\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n4\n((()))\n((((((\n))))))\n()()()\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n3\n(((\n)\n)\n\nSample Output 4\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 385, "cpu_time_ms": 737, "memory_kb": 162572}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s902576631", "group_id": "codeNet:p02686", "input_text": "# (()(())) level\n# ( ) -- 0\n# ()( ) -- -1\n# () -- -2\n# 変化を計算して、\n# - 最後0で終わる\n# - 途中で0より大きくなることがない\n# 変化量の合計は並べる順番に依存しない。\n# 0より大きくならないようにするには、できるだけ深く潜るようにすればいい。\n\nN = gets.to_i\nLevelInfo = N.times.map do\n s = gets.chomp\n level = 0\n highest = 0\n s.each_char do |c|\n if c == '('\n level -= 1\n else\n level += 1\n highest = level if level > highest\n end\n end\n [level, highest]\nend\n\n# 変化の合計量のチェック\nlevel_sum = LevelInfo.map{|level, highest| level}.sum()\nif level_sum != 0\n puts 'No'\n exit(0)\nend\n\n# できるだけ0より大きくならないように並べ替える\ndowns = LevelInfo.select{|level, highest| level < 0}.sort_by{|level, highest| highest}\nequals = LevelInfo.select{|level, highest| level == 0}\nups = LevelInfo.select{|level, highest| level > 0}.sort_by{|level, highest| - highest + level}\n\nlevel_sum = 0\n[downs, equals, ups].each do |sub|\n sub.each do |level, highest|\n if level_sum + highest > 0\n puts 'No'\n exit(0)\n end\n level_sum += level\n end\nend\n\nputs 'Yes'\n", "language": "Ruby", "metadata": {"date": 1589165513, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02686.html", "problem_id": "p02686", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02686/input.txt", "sample_output_relpath": "derived/input_output/data/p02686/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02686/Ruby/s902576631.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s902576631", "user_id": "u539215429"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "# (()(())) level\n# ( ) -- 0\n# ()( ) -- -1\n# () -- -2\n# 変化を計算して、\n# - 最後0で終わる\n# - 途中で0より大きくなることがない\n# 変化量の合計は並べる順番に依存しない。\n# 0より大きくならないようにするには、できるだけ深く潜るようにすればいい。\n\nN = gets.to_i\nLevelInfo = N.times.map do\n s = gets.chomp\n level = 0\n highest = 0\n s.each_char do |c|\n if c == '('\n level -= 1\n else\n level += 1\n highest = level if level > highest\n end\n end\n [level, highest]\nend\n\n# 変化の合計量のチェック\nlevel_sum = LevelInfo.map{|level, highest| level}.sum()\nif level_sum != 0\n puts 'No'\n exit(0)\nend\n\n# できるだけ0より大きくならないように並べ替える\ndowns = LevelInfo.select{|level, highest| level < 0}.sort_by{|level, highest| highest}\nequals = LevelInfo.select{|level, highest| level == 0}\nups = LevelInfo.select{|level, highest| level > 0}.sort_by{|level, highest| - highest + level}\n\nlevel_sum = 0\n[downs, equals, ups].each do |sub|\n sub.each do |level, highest|\n if level_sum + highest > 0\n puts 'No'\n exit(0)\n end\n level_sum += level\n end\nend\n\nputs 'Yes'\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nA bracket sequence is a string that is one of the following:\n\nAn empty string;\n\nThe concatenation of (, A, and ) in this order, for some bracket sequence A ;\n\nThe concatenation of A and B in this order, for some non-empty bracket sequences A and B /\n\nGiven are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nThe total length of the strings S_i is at most 10^6.\n\nS_i is a non-empty string consisting of ( and ).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nIf a bracket sequence can be formed by concatenating all the N strings in some order, print Yes; otherwise, print No.\n\nSample Input 1\n\n2\n)\n(()\n\nSample Output 1\n\nYes\n\nConcatenating (() and ) in this order forms a bracket sequence.\n\nSample Input 2\n\n2\n)(\n()\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n4\n((()))\n((((((\n))))))\n()()()\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n3\n(((\n)\n)\n\nSample Output 4\n\nNo", "sample_input": "2\n)\n(()\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02686", "source_text": "Score : 600 points\n\nProblem Statement\n\nA bracket sequence is a string that is one of the following:\n\nAn empty string;\n\nThe concatenation of (, A, and ) in this order, for some bracket sequence A ;\n\nThe concatenation of A and B in this order, for some non-empty bracket sequences A and B /\n\nGiven are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nThe total length of the strings S_i is at most 10^6.\n\nS_i is a non-empty string consisting of ( and ).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nIf a bracket sequence can be formed by concatenating all the N strings in some order, print Yes; otherwise, print No.\n\nSample Input 1\n\n2\n)\n(()\n\nSample Output 1\n\nYes\n\nConcatenating (() and ) in this order forms a bracket sequence.\n\nSample Input 2\n\n2\n)(\n()\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n4\n((()))\n((((((\n))))))\n()()()\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n3\n(((\n)\n)\n\nSample Output 4\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1223, "cpu_time_ms": 2210, "memory_kb": 106796}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s971043959", "group_id": "codeNet:p02687", "input_text": "s = gets.chomp\n\ncase s\nwhen \"ABC\"\n puts \"ARC\"\nwhen \"ARC\"\n puts \"ABC\"\nend", "language": "Ruby", "metadata": {"date": 1598320399, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s971043959.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s971043959", "user_id": "u358554431"}, "prompt_components": {"gold_output": "ARC\n", "input_to_evaluate": "s = gets.chomp\n\ncase s\nwhen \"ABC\"\n puts \"ARC\"\nwhen \"ARC\"\n puts \"ABC\"\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoder Inc. holds a contest every Saturday.\n\nThere are two types of contests called ABC and ARC, and just one of them is held at a time.\n\nThe company holds these two types of contests alternately: an ARC follows an ABC and vice versa.\n\nGiven a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.\n\nConstraints\n\nS is ABC or ARC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the string representing the type of the contest held this week.\n\nSample Input 1\n\nABC\n\nSample Output 1\n\nARC\n\nThey held an ABC last week, so they will hold an ARC this week.", "sample_input": "ABC\n"}, "reference_outputs": ["ARC\n"], "source_document_id": "p02687", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoder Inc. holds a contest every Saturday.\n\nThere are two types of contests called ABC and ARC, and just one of them is held at a time.\n\nThe company holds these two types of contests alternately: an ARC follows an ABC and vice versa.\n\nGiven a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.\n\nConstraints\n\nS is ABC or ARC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the string representing the type of the contest held this week.\n\nSample Input 1\n\nABC\n\nSample Output 1\n\nARC\n\nThey held an ABC last week, so they will hold an ARC this week.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 74, "cpu_time_ms": 66, "memory_kb": 14360}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s096106387", "group_id": "codeNet:p02688", "input_text": "# abc166 B\nn, k = gets.split.map(&:to_i)\na = []\n\nsn = Array.new(n, 0)\n\nk.times {\n d = gets.to_i\n a << gets.split.map(&:to_i)\n}\n\n\na.each do |aa|\n aa.each do |x|\n sn[x-1] += 1\n end\nend\n\np sn.count(&:zero?)\n", "language": "Ruby", "metadata": {"date": 1588609986, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s096106387.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s096106387", "user_id": "u315597999"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "# abc166 B\nn, k = gets.split.map(&:to_i)\na = []\n\nsn = Array.new(n, 0)\n\nk.times {\n d = gets.to_i\n a << gets.split.map(&:to_i)\n}\n\n\na.each do |aa|\n aa.each do |x|\n sn[x-1] += 1\n end\nend\n\np sn.count(&:zero?)\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": 212, "cpu_time_ms": 56, "memory_kb": 14428}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s073718641", "group_id": "codeNet:p02688", "input_text": "n, k = gets.split.map(&:to_i)\nd = []\nk.times {\n du = gets.to_i\n d << gets.split.map(&:to_i)\n}\nd = d.uniq.flatten!\nans = 0\n1.upto(n) {|i|\n unless d.include?(i) then ans += 1 end \n}\np ans\n", "language": "Ruby", "metadata": {"date": 1588554847, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s073718641.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s073718641", "user_id": "u329977093"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n, k = gets.split.map(&:to_i)\nd = []\nk.times {\n du = gets.to_i\n d << gets.split.map(&:to_i)\n}\nd = d.uniq.flatten!\nans = 0\n1.upto(n) {|i|\n unless d.include?(i) then ans += 1 end \n}\np ans\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": 189, "cpu_time_ms": 56, "memory_kb": 14332}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s305276075", "group_id": "codeNet:p02688", "input_text": "N, K = gets.split(' ').map(&:to_i)\nd = []\na = []\n\nK.times do\n d << gets.to_i\n a += gets.split(' ').map(&:to_i)\nend\n\nputs N - a.uniq.size", "language": "Ruby", "metadata": {"date": 1588554492, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s305276075.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s305276075", "user_id": "u857555436"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N, K = gets.split(' ').map(&:to_i)\nd = []\na = []\n\nK.times do\n d << gets.to_i\n a += gets.split(' ').map(&:to_i)\nend\n\nputs N - a.uniq.size", "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": 138, "cpu_time_ms": 55, "memory_kb": 17748}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s800703824", "group_id": "codeNet:p02689", "input_text": "n, m = gets.split(\" \").map(&:to_i)\nh_arr = [0] + gets.split(\" \").map(&:to_i)\n\npath_arr = []\nm.times do\n a, b = gets.split(\" \").map(&:to_i)\n\n path_arr[a] ||= []\n path_arr[a] << b\n path_arr[b] ||= []\n path_arr[b] << a\nend\npath_arr[n] ||= []\n\ncount = 0\npath_arr.each_with_index do |arr, i|\n next if i == 0\n\n good = true\n height = h_arr[i]\n arr&.each do |ind|\n if height <= h_arr[ind]\n good = false \n break\n end\n end\n\n count += 1 if good\nend\nputs count\n \n", "language": "Ruby", "metadata": {"date": 1598052950, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s800703824.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s800703824", "user_id": "u771770008"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n, m = gets.split(\" \").map(&:to_i)\nh_arr = [0] + gets.split(\" \").map(&:to_i)\n\npath_arr = []\nm.times do\n a, b = gets.split(\" \").map(&:to_i)\n\n path_arr[a] ||= []\n path_arr[a] << b\n path_arr[b] ||= []\n path_arr[b] << a\nend\npath_arr[n] ||= []\n\ncount = 0\npath_arr.each_with_index do |arr, i|\n next if i == 0\n\n good = true\n height = h_arr[i]\n arr&.each do |ind|\n if height <= h_arr[ind]\n good = false \n break\n end\n end\n\n count += 1 if good\nend\nputs count\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": 479, "cpu_time_ms": 233, "memory_kb": 30260}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s217012229", "group_id": "codeNet:p02689", "input_text": "# https://atcoder.jp/contests/abc166/tasks/abc166_c\n# at_coder_friends test-all C.rb\n# require 'pry'\n\nN, M = gets.split.map(&:to_i)\nHs = gets.split.map(&:to_i)\nAs = Array.new(M)\nBs = Array.new(M)\nm_h = Hash.new{|h,k| h[k] = []}\nM.times do |i|\n As[i], Bs[i] = gets.split.map(&:to_i)\n m_h[As[i]] << Bs[i]\n m_h[Bs[i]] << As[i]\nend\n\n#p \"m_h=#{m_h}\"\n\nfond_indexes = []\nN.times do |i|\n hs = m_h[i+1]\n myh = Hs[i]\n if hs.size > 0\n myh_is_highest = hs.all? do |h|\n myh >= Hs[h-1]\n end\n if myh_is_highest\n fond_indexes << i\n end\n end\n #p \"i=#{i}, myh=#{myh}, hs=#{hs},fond_indexes=#{fond_indexes}\"\nend\n#p fond_indexes\n\nans = fond_indexes.size\n\nputs ans\n", "language": "Ruby", "metadata": {"date": 1592167941, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s217012229.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s217012229", "user_id": "u329083941"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "# https://atcoder.jp/contests/abc166/tasks/abc166_c\n# at_coder_friends test-all C.rb\n# require 'pry'\n\nN, M = gets.split.map(&:to_i)\nHs = gets.split.map(&:to_i)\nAs = Array.new(M)\nBs = Array.new(M)\nm_h = Hash.new{|h,k| h[k] = []}\nM.times do |i|\n As[i], Bs[i] = gets.split.map(&:to_i)\n m_h[As[i]] << Bs[i]\n m_h[Bs[i]] << As[i]\nend\n\n#p \"m_h=#{m_h}\"\n\nfond_indexes = []\nN.times do |i|\n hs = m_h[i+1]\n myh = Hs[i]\n if hs.size > 0\n myh_is_highest = hs.all? do |h|\n myh >= Hs[h-1]\n end\n if myh_is_highest\n fond_indexes << i\n end\n end\n #p \"i=#{i}, myh=#{myh}, hs=#{hs},fond_indexes=#{fond_indexes}\"\nend\n#p fond_indexes\n\nans = fond_indexes.size\n\nputs ans\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": 674, "cpu_time_ms": 286, "memory_kb": 28620}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s976700357", "group_id": "codeNet:p02689", "input_text": "N, M = gets.split.map(&:to_i)\nh = []\nh = gets.split.map(&:to_i)\na = []\nb = []\nma = []\nma = ma.fill(0,0..N-1)\nM.times do |i|\n a[i], b[i] = gets.split.map(&:to_i)\n ma[a[i]-1] = [ h[b[i]-1], ma[a[i]-1] ].max\n ma[b[i]-1] = [ h[a[i]-1], ma[b[i]-1] ].max\nend\nans = 0\nN.times do |i|\n if ma[i] < h[i]\n ans += 1\n end\nend\nputs ans", "language": "Ruby", "metadata": {"date": 1588560638, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s976700357.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s976700357", "user_id": "u326288614"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "N, M = gets.split.map(&:to_i)\nh = []\nh = gets.split.map(&:to_i)\na = []\nb = []\nma = []\nma = ma.fill(0,0..N-1)\nM.times do |i|\n a[i], b[i] = gets.split.map(&:to_i)\n ma[a[i]-1] = [ h[b[i]-1], ma[a[i]-1] ].max\n ma[b[i]-1] = [ h[a[i]-1], ma[b[i]-1] ].max\nend\nans = 0\nN.times do |i|\n if ma[i] < h[i]\n ans += 1\n end\nend\nputs ans", "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": 328, "cpu_time_ms": 171, "memory_kb": 23192}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s953436108", "group_id": "codeNet:p02689", "input_text": "n, m = gets.split(\" \").map(&:to_i)\nhh = gets.split(\" \").map(&:to_i)\n\nedges = Array.new(n) { Array.new}\n\nm.times do |_|\n a, b = gets.split(\" \").map(&:to_i)\n a -= 1\n b -= 1\n edges[a] << b\n edges[b] << a\nend\n\nans=0\n\nn.times do |i|\n ans += 1 if edges[i].all? { |j| hh[i] > hh[j] }\nend\n\nputs ans", "language": "Ruby", "metadata": {"date": 1588559355, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s953436108.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s953436108", "user_id": "u944470046"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n, m = gets.split(\" \").map(&:to_i)\nhh = gets.split(\" \").map(&:to_i)\n\nedges = Array.new(n) { Array.new}\n\nm.times do |_|\n a, b = gets.split(\" \").map(&:to_i)\n a -= 1\n b -= 1\n edges[a] << b\n edges[b] << a\nend\n\nans=0\n\nn.times do |i|\n ans += 1 if edges[i].all? { |j| hh[i] > hh[j] }\nend\n\nputs ans", "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": 296, "cpu_time_ms": 214, "memory_kb": 26524}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s511026090", "group_id": "codeNet:p02689", "input_text": "arr = Array.new\nwhile line = $stdin.gets\narr << line.chomp.split(\" \").map(&:to_i)\nend\npeak = arr[1]\nmaps=Array.new(arr[0][0]).fill(0)\n(arr[2..-1]).each{|i|\n if peak[i[0]-1] == peak[i[1]-1] then\n maps[i[0]-1] = -1\n maps[i[1]-1] = -1\n elsif peak[i[0]-1] > peak[i[1]-1]\n maps[i[1]-1] = -1\n else\n maps[i[0]-1] = -1\n end\n}\nputs maps.count(0)", "language": "Ruby", "metadata": {"date": 1588555802, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s511026090.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s511026090", "user_id": "u312004378"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "arr = Array.new\nwhile line = $stdin.gets\narr << line.chomp.split(\" \").map(&:to_i)\nend\npeak = arr[1]\nmaps=Array.new(arr[0][0]).fill(0)\n(arr[2..-1]).each{|i|\n if peak[i[0]-1] == peak[i[1]-1] then\n maps[i[0]-1] = -1\n maps[i[1]-1] = -1\n elsif peak[i[0]-1] > peak[i[1]-1]\n maps[i[1]-1] = -1\n else\n maps[i[0]-1] = -1\n end\n}\nputs maps.count(0)", "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": 376, "cpu_time_ms": 187, "memory_kb": 23556}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s786752015", "group_id": "codeNet:p02690", "input_text": "require 'set'; require 'prime'; require 'pp'\nINF=Float::INFINITY; MOD=10**9+7\nx = gets.chomp.to_i\n\ndef divisors(n)\n n.prime_division.inject([1]) do |ary, (p, e)|\n (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }\n end.sort\nend\n\ndef uhen(a, b)\n a2 = a*a\n b2 = b*b\n (a2 * a2) + (a2 * a * b) + (a2 * b2) + (a * b * b2) + (b2 * b2)\nend\n\nupper = 10**9\ndivs = divisors(x)\nde = false\ndivs.each do |div|\n p '-----------------------------------------------' if de\n # p div\n a = div\n b = 0\n while true\n a5b5 = a**5 - b**5 # (a-b) * uhen(a,b)\n p [a,b,a5b5] if de\n if a5b5 == x\n puts [a,b].join(' ')\n exit\n elsif upper < a5b5\n break\n else\n a += 1\n b += 1\n end\n end\n\n a = div\n b = 0\n while true\n a5b5 = a**5 - b**5 # (a-b) * uhen(a,b)\n p [a,b,a5b5] if de\n if a5b5 == x\n puts [a,b].join(' ')\n exit\n elsif upper < a5b5\n break\n else\n a -= 1\n b -= 1\n end\n end\nend", "language": "Ruby", "metadata": {"date": 1588557284, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02690.html", "problem_id": "p02690", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02690/input.txt", "sample_output_relpath": "derived/input_output/data/p02690/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02690/Ruby/s786752015.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s786752015", "user_id": "u524019694"}, "prompt_components": {"gold_output": "2 -1\n", "input_to_evaluate": "require 'set'; require 'prime'; require 'pp'\nINF=Float::INFINITY; MOD=10**9+7\nx = gets.chomp.to_i\n\ndef divisors(n)\n n.prime_division.inject([1]) do |ary, (p, e)|\n (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }\n end.sort\nend\n\ndef uhen(a, b)\n a2 = a*a\n b2 = b*b\n (a2 * a2) + (a2 * a * b) + (a2 * b2) + (a * b * b2) + (b2 * b2)\nend\n\nupper = 10**9\ndivs = divisors(x)\nde = false\ndivs.each do |div|\n p '-----------------------------------------------' if de\n # p div\n a = div\n b = 0\n while true\n a5b5 = a**5 - b**5 # (a-b) * uhen(a,b)\n p [a,b,a5b5] if de\n if a5b5 == x\n puts [a,b].join(' ')\n exit\n elsif upper < a5b5\n break\n else\n a += 1\n b += 1\n end\n end\n\n a = div\n b = 0\n while true\n a5b5 = a**5 - b**5 # (a-b) * uhen(a,b)\n p [a,b,a5b5] if de\n if a5b5 == x\n puts [a,b].join(' ')\n exit\n elsif upper < a5b5\n break\n else\n a -= 1\n b -= 1\n end\n end\nend", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGive a pair of integers (A, B) such that A^5-B^5 = X.\nIt is guaranteed that there exists such a pair for the given integer X.\n\nConstraints\n\n1 \\leq X \\leq 10^9\n\nX is an integer.\n\nThere exists a pair of integers (A, B) satisfying the condition in Problem Statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint A and B, with space in between.\nIf there are multiple pairs of integers (A, B) satisfying the condition, you may print any of them.\n\nA B\n\nSample Input 1\n\n33\n\nSample Output 1\n\n2 -1\n\nFor A=2 and B=-1, A^5-B^5 = 33.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0 -1", "sample_input": "33\n"}, "reference_outputs": ["2 -1\n"], "source_document_id": "p02690", "source_text": "Score : 400 points\n\nProblem Statement\n\nGive a pair of integers (A, B) such that A^5-B^5 = X.\nIt is guaranteed that there exists such a pair for the given integer X.\n\nConstraints\n\n1 \\leq X \\leq 10^9\n\nX is an integer.\n\nThere exists a pair of integers (A, B) satisfying the condition in Problem Statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint A and B, with space in between.\nIf there are multiple pairs of integers (A, B) satisfying the condition, you may print any of them.\n\nA B\n\nSample Input 1\n\n33\n\nSample Output 1\n\n2 -1\n\nFor A=2 and B=-1, A^5-B^5 = 33.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0 -1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 960, "cpu_time_ms": 137, "memory_kb": 14756}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s897613426", "group_id": "codeNet:p02694", "input_text": "m=100\nx=gets.to_i\nc=0\nwhile x>m do\nm+=(m/100)\nc+=1\nend\np c", "language": "Ruby", "metadata": {"date": 1598397648, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02694.html", "problem_id": "p02694", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02694/input.txt", "sample_output_relpath": "derived/input_output/data/p02694/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02694/Ruby/s897613426.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s897613426", "user_id": "u492991702"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "m=100\nx=gets.to_i\nc=0\nwhile x>m do\nm+=(m/100)\nc+=1\nend\np c", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.\n\nThe bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)\n\nAssuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?\n\nConstraints\n\n101 \\le X \\le 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of years it takes for Takahashi's balance to reach X yen or above for the first time.\n\nSample Input 1\n\n103\n\nSample Output 1\n\n3\n\nThe balance after one year is 101 yen.\n\nThe balance after two years is 102 yen.\n\nThe balance after three years is 103 yen.\n\nThus, it takes three years for the balance to reach 103 yen or above.\n\nSample Input 2\n\n1000000000000000000\n\nSample Output 2\n\n3760\n\nSample Input 3\n\n1333333333\n\nSample Output 3\n\n1706", "sample_input": "103\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02694", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.\n\nThe bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)\n\nAssuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?\n\nConstraints\n\n101 \\le X \\le 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of years it takes for Takahashi's balance to reach X yen or above for the first time.\n\nSample Input 1\n\n103\n\nSample Output 1\n\n3\n\nThe balance after one year is 101 yen.\n\nThe balance after two years is 102 yen.\n\nThe balance after three years is 103 yen.\n\nThus, it takes three years for the balance to reach 103 yen or above.\n\nSample Input 2\n\n1000000000000000000\n\nSample Output 2\n\n3760\n\nSample Input 3\n\n1333333333\n\nSample Output 3\n\n1706", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 58, "cpu_time_ms": 66, "memory_kb": 14340}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s863925842", "group_id": "codeNet:p02694", "input_text": "x = gets.to_i\ndeposit = 100\nyear = 0\n(x-100).times do\n deposit += (deposit * 0.01).truncate\n year += 1\nend\nprint year", "language": "Ruby", "metadata": {"date": 1590700678, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02694.html", "problem_id": "p02694", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02694/input.txt", "sample_output_relpath": "derived/input_output/data/p02694/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02694/Ruby/s863925842.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s863925842", "user_id": "u011809316"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "x = gets.to_i\ndeposit = 100\nyear = 0\n(x-100).times do\n deposit += (deposit * 0.01).truncate\n year += 1\nend\nprint year", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.\n\nThe bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)\n\nAssuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?\n\nConstraints\n\n101 \\le X \\le 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of years it takes for Takahashi's balance to reach X yen or above for the first time.\n\nSample Input 1\n\n103\n\nSample Output 1\n\n3\n\nThe balance after one year is 101 yen.\n\nThe balance after two years is 102 yen.\n\nThe balance after three years is 103 yen.\n\nThus, it takes three years for the balance to reach 103 yen or above.\n\nSample Input 2\n\n1000000000000000000\n\nSample Output 2\n\n3760\n\nSample Input 3\n\n1333333333\n\nSample Output 3\n\n1706", "sample_input": "103\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02694", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.\n\nThe bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)\n\nAssuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?\n\nConstraints\n\n101 \\le X \\le 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of years it takes for Takahashi's balance to reach X yen or above for the first time.\n\nSample Input 1\n\n103\n\nSample Output 1\n\n3\n\nThe balance after one year is 101 yen.\n\nThe balance after two years is 102 yen.\n\nThe balance after three years is 103 yen.\n\nThus, it takes three years for the balance to reach 103 yen or above.\n\nSample Input 2\n\n1000000000000000000\n\nSample Output 2\n\n3760\n\nSample Input 3\n\n1333333333\n\nSample Output 3\n\n1706", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 119, "cpu_time_ms": 87, "memory_kb": 14896}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s531226819", "group_id": "codeNet:p02694", "input_text": "$x = gets.chop.to_i\n\ndef rec(y, c)\n c += 1\n y = (y * 1.01).floor\n\n if y >= $x\n puts c\n else\n rec(y, c)\n end\nend\n\nrec(100, 0)\n", "language": "Ruby", "metadata": {"date": 1588468958, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02694.html", "problem_id": "p02694", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02694/input.txt", "sample_output_relpath": "derived/input_output/data/p02694/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02694/Ruby/s531226819.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s531226819", "user_id": "u450617345"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "$x = gets.chop.to_i\n\ndef rec(y, c)\n c += 1\n y = (y * 1.01).floor\n\n if y >= $x\n puts c\n else\n rec(y, c)\n end\nend\n\nrec(100, 0)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.\n\nThe bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)\n\nAssuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?\n\nConstraints\n\n101 \\le X \\le 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of years it takes for Takahashi's balance to reach X yen or above for the first time.\n\nSample Input 1\n\n103\n\nSample Output 1\n\n3\n\nThe balance after one year is 101 yen.\n\nThe balance after two years is 102 yen.\n\nThe balance after three years is 103 yen.\n\nThus, it takes three years for the balance to reach 103 yen or above.\n\nSample Input 2\n\n1000000000000000000\n\nSample Output 2\n\n3760\n\nSample Input 3\n\n1333333333\n\nSample Output 3\n\n1706", "sample_input": "103\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02694", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.\n\nThe bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)\n\nAssuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?\n\nConstraints\n\n101 \\le X \\le 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of years it takes for Takahashi's balance to reach X yen or above for the first time.\n\nSample Input 1\n\n103\n\nSample Output 1\n\n3\n\nThe balance after one year is 101 yen.\n\nThe balance after two years is 102 yen.\n\nThe balance after three years is 103 yen.\n\nThus, it takes three years for the balance to reach 103 yen or above.\n\nSample Input 2\n\n1000000000000000000\n\nSample Output 2\n\n3760\n\nSample Input 3\n\n1333333333\n\nSample Output 3\n\n1706", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 136, "cpu_time_ms": 57, "memory_kb": 14612}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s461371582", "group_id": "codeNet:p02696", "input_text": "a,b,n = gets.split(\" \").map(&:to_i)\ni = 1\nm = 0\n\nuntil i > n || i > a\n o = (a*i/b) - a*(i/b)\n p o\n if o > m\n m = o\n end\n i += 1\nend\n\nprint(m)", "language": "Ruby", "metadata": {"date": 1588470668, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s461371582.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s461371582", "user_id": "u590322956"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "a,b,n = gets.split(\" \").map(&:to_i)\ni = 1\nm = 0\n\nuntil i > n || i > a\n o = (a*i/b) - a*(i/b)\n p o\n if o > m\n m = o\n end\n i += 1\nend\n\nprint(m)", "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": 149, "cpu_time_ms": 1983, "memory_kb": 14580}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s484812960", "group_id": "codeNet:p02706", "input_text": "n,m=gets.split.map(&:to_i)\na=gets.split.map(&:to_i)\nputs n-a.sum>0 ? n-a.sum : -1\n", "language": "Ruby", "metadata": {"date": 1587344555, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02706.html", "problem_id": "p02706", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02706/input.txt", "sample_output_relpath": "derived/input_output/data/p02706/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02706/Ruby/s484812960.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s484812960", "user_id": "u744908753"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "n,m=gets.split.map(&:to_i)\na=gets.split.map(&:to_i)\nputs n-a.sum>0 ? n-a.sum : -1\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N days of summer vacation.\n\nHis teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.\n\nHe cannot do multiple assignments on the same day, or hang out on a day he does an assignment.\n\nWhat is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?\n\nIf Takahashi cannot finish all the assignments during the vacation, print -1 instead.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\n1 \\leq M \\leq 10^4\n\n1 \\leq A_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 ... A_M\n\nOutput\n\nPrint the maximum number of days Takahashi can hang out during the vacation, or -1.\n\nSample Input 1\n\n41 2\n5 6\n\nSample Output 1\n\n30\n\nFor example, he can do the first assignment on the first 5 days, hang out on the next 30 days, and do the second assignment on the last 6 days of the vacation. In this way, he can safely spend 30 days hanging out.\n\nSample Input 2\n\n10 2\n5 6\n\nSample Output 2\n\n-1\n\nHe cannot finish his assignments.\n\nSample Input 3\n\n11 2\n5 6\n\nSample Output 3\n\n0\n\nHe can finish his assignments, but he will have no time to hang out.\n\nSample Input 4\n\n314 15\n9 26 5 35 8 9 79 3 23 8 46 2 6 43 3\n\nSample Output 4\n\n9", "sample_input": "41 2\n5 6\n"}, "reference_outputs": ["30\n"], "source_document_id": "p02706", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N days of summer vacation.\n\nHis teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.\n\nHe cannot do multiple assignments on the same day, or hang out on a day he does an assignment.\n\nWhat is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?\n\nIf Takahashi cannot finish all the assignments during the vacation, print -1 instead.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\n1 \\leq M \\leq 10^4\n\n1 \\leq A_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 ... A_M\n\nOutput\n\nPrint the maximum number of days Takahashi can hang out during the vacation, or -1.\n\nSample Input 1\n\n41 2\n5 6\n\nSample Output 1\n\n30\n\nFor example, he can do the first assignment on the first 5 days, hang out on the next 30 days, and do the second assignment on the last 6 days of the vacation. In this way, he can safely spend 30 days hanging out.\n\nSample Input 2\n\n10 2\n5 6\n\nSample Output 2\n\n-1\n\nHe cannot finish his assignments.\n\nSample Input 3\n\n11 2\n5 6\n\nSample Output 3\n\n0\n\nHe can finish his assignments, but he will have no time to hang out.\n\nSample Input 4\n\n314 15\n9 26 5 35 8 9 79 3 23 8 46 2 6 43 3\n\nSample Output 4\n\n9", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 82, "cpu_time_ms": 58, "memory_kb": 14716}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s555394713", "group_id": "codeNet:p02707", "input_text": "N = gets.to_i\nA = gets.split.map(&:to_i)\n\narr = Array.new(N, 0)\n\nA.each do |n|\n arr[n-1] += 1\nend\n\narr.each do |a|\n puts a\nend", "language": "Ruby", "metadata": {"date": 1587344746, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s555394713.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s555394713", "user_id": "u846185950"}, "prompt_components": {"gold_output": "2\n2\n0\n0\n0\n", "input_to_evaluate": "N = gets.to_i\nA = gets.split.map(&:to_i)\n\narr = Array.new(N, 0)\n\nA.each do |n|\n arr[n-1] += 1\nend\n\narr.each do |a|\n puts a\nend", "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": 132, "cpu_time_ms": 213, "memory_kb": 34428}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s789398415", "group_id": "codeNet:p02708", "input_text": "mod = 10 ** 9 + 7\n\nn, k = gets.to_s.split.map{|e|e.to_i}\n\n# ans = (k..n+1).map{|i| i * (n + n - i + 1) / 2 - i * ( i - 1 ) / 2 + 1 }.sum % mod\nans = n - k + 2\n(k..n+1).each do |i|\n \n ans += i * (n - i + 1) \n ans %= mod if ans >= mod\nend\n\nputs ans", "language": "Ruby", "metadata": {"date": 1587459946, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02708.html", "problem_id": "p02708", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02708/input.txt", "sample_output_relpath": "derived/input_output/data/p02708/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02708/Ruby/s789398415.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s789398415", "user_id": "u693378622"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "mod = 10 ** 9 + 7\n\nn, k = gets.to_s.split.map{|e|e.to_i}\n\n# ans = (k..n+1).map{|i| i * (n + n - i + 1) / 2 - i * ( i - 1 ) / 2 + 1 }.sum % mod\nans = n - k + 2\n(k..n+1).each do |i|\n \n ans += i * (n - i + 1) \n ans %= mod if ans >= mod\nend\n\nputs ans", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.\n\nWe will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq K \\leq N+1\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of possible values of the sum, modulo (10^9+7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n10\n\nThe sum can take 10 values, as follows:\n\n(10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n\n(10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n\n(10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n\n(10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n\n(10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n\n(10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n\n(10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n\n(10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n\n(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n\n(10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\nSample Input 2\n\n200000 200001\n\nSample Output 2\n\n1\n\nWe must choose all of the integers, so the sum can take just 1 value.\n\nSample Input 3\n\n141421 35623\n\nSample Output 3\n\n220280457", "sample_input": "3 2\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02708", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.\n\nWe will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq K \\leq N+1\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of possible values of the sum, modulo (10^9+7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n10\n\nThe sum can take 10 values, as follows:\n\n(10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n\n(10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n\n(10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n\n(10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n\n(10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n\n(10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n\n(10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n\n(10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n\n(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n\n(10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\nSample Input 2\n\n200000 200001\n\nSample Output 2\n\n1\n\nWe must choose all of the integers, so the sum can take just 1 value.\n\nSample Input 3\n\n141421 35623\n\nSample Output 3\n\n220280457", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 249, "cpu_time_ms": 69, "memory_kb": 14412}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s819917499", "group_id": "codeNet:p02709", "input_text": "N = gets.to_i\nA = gets.chomp.split.map(&:to_i)\nleft = 0\nright = N-1\nresult = 0\n\nB = A.map.with_index { |elem, index| [elem, index]}\nC = B.each do |b|\n b << [b[0] * (b[1]-left), b[0] * (right-b[1])].max\nend\nC = B.sort_by { |b| b[2] }.reverse\nC.each do |c|\n if c[1] - left >= right - c[1]\n result += c[0] * (c[1]-left)\n left += 1\n else\n result += c[0] * (right - c[1])\n right -= 1\n end\nend\n\np result", "language": "Ruby", "metadata": {"date": 1588196448, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02709.html", "problem_id": "p02709", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02709/input.txt", "sample_output_relpath": "derived/input_output/data/p02709/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02709/Ruby/s819917499.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s819917499", "user_id": "u412989489"}, "prompt_components": {"gold_output": "20\n", "input_to_evaluate": "N = gets.to_i\nA = gets.chomp.split.map(&:to_i)\nleft = 0\nright = N-1\nresult = 0\n\nB = A.map.with_index { |elem, index| [elem, index]}\nC = B.each do |b|\n b << [b[0] * (b[1]-left), b[0] * (right-b[1])].max\nend\nC = B.sort_by { |b| b[2] }.reverse\nC.each do |c|\n if c[1] - left >= right - c[1]\n result += c[0] * (c[1]-left)\n left += 1\n else\n result += c[0] * (right - c[1])\n right -= 1\n end\nend\n\np result", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i.\n\nYou can rearrange these children just one time in any order you like.\n\nWhen a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \\times |x-y| happiness points.\n\nFind the maximum total happiness points the children can earn.\n\nConstraints\n\n2 \\leq N \\leq 2000\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum total happiness points the children can earn.\n\nSample Input 1\n\n4\n1 3 4 2\n\nSample Output 1\n\n20\n\nIf we move the 1-st child from the left to the 3-rd position from the left, the 2-nd child to the 4-th position, the 3-rd child to the 1-st position, and the 4-th child to the 2-nd position, the children earns 1 \\times |1-3|+3 \\times |2-4|+4 \\times |3-1|+2 \\times |4-2|=20 happiness points in total.\n\nSample Input 2\n\n6\n5 5 6 1 1 1\n\nSample Output 2\n\n58\n\nSample Input 3\n\n6\n8 6 9 1 2 1\n\nSample Output 3\n\n85", "sample_input": "4\n1 3 4 2\n"}, "reference_outputs": ["20\n"], "source_document_id": "p02709", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i.\n\nYou can rearrange these children just one time in any order you like.\n\nWhen a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \\times |x-y| happiness points.\n\nFind the maximum total happiness points the children can earn.\n\nConstraints\n\n2 \\leq N \\leq 2000\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum total happiness points the children can earn.\n\nSample Input 1\n\n4\n1 3 4 2\n\nSample Output 1\n\n20\n\nIf we move the 1-st child from the left to the 3-rd position from the left, the 2-nd child to the 4-th position, the 3-rd child to the 1-st position, and the 4-th child to the 2-nd position, the children earns 1 \\times |1-3|+3 \\times |2-4|+4 \\times |3-1|+2 \\times |4-2|=20 happiness points in total.\n\nSample Input 2\n\n6\n5 5 6 1 1 1\n\nSample Output 2\n\n58\n\nSample Input 3\n\n6\n8 6 9 1 2 1\n\nSample Output 3\n\n85", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 413, "cpu_time_ms": 55, "memory_kb": 14384}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s244787219", "group_id": "codeNet:p02709", "input_text": "n=gets.to_i\narray=gets.split.map(&:to_i)\nans=0\nansArray=Array.new(n,0)\nleftsumArray=Array.new(n,0)\nrightsumArray=Array.new(n,0)\narrayreverse=array.reverse\nhash={}\n\narray.map.with_index{|value,index|\n if hash[value]\n hash[value] = hash[value].push(index)\n else\n hash[value] = [index]\n end\n}\n\nleftsum=0\narray.map.with_index{|value,index|\n leftsum+=value\n leftsumArray[index]=leftsum\n}\n\nrightsum=0\narrayreverse.map.with_index{|value,index|\n rightsum+=value\n rightsumArray[index]=rightsum\n}\n\nrightsumArray=rightsumArray.reverse\nhash=hash.sort.reverse\n\nleftnow=0\nrightnow=n-1\n\nhash.map{|value|\n uresisa=value[0]\n array2=value[1]\n \n array2.map{|place|\n leftdis=(place-leftnow).abs\n rightdis=(place-rightnow).abs\n \n # leftsum=leftsumArray[place-1] ? leftsumArray[place-1] : 0\n # rightsum=rightsumArray[place+1] ? rightsumArray[place+1] : 0\n \n if place==0\n leftsum=0\n else\n leftsum=array[0...place].select{|n| n leftsum + rightdis*uresisa\n ansArray[leftnow]=uresisa\n ans+=leftdis*uresisa\n leftnow+=1\n else\n ansArray[rightnow]=uresisa\n ans+=rightdis*uresisa\n rightnow-=1\n end\n\n }\n \n}\n\nputs ans\n\n\n\n", "language": "Ruby", "metadata": {"date": 1587350257, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02709.html", "problem_id": "p02709", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02709/input.txt", "sample_output_relpath": "derived/input_output/data/p02709/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02709/Ruby/s244787219.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s244787219", "user_id": "u614375729"}, "prompt_components": {"gold_output": "20\n", "input_to_evaluate": "n=gets.to_i\narray=gets.split.map(&:to_i)\nans=0\nansArray=Array.new(n,0)\nleftsumArray=Array.new(n,0)\nrightsumArray=Array.new(n,0)\narrayreverse=array.reverse\nhash={}\n\narray.map.with_index{|value,index|\n if hash[value]\n hash[value] = hash[value].push(index)\n else\n hash[value] = [index]\n end\n}\n\nleftsum=0\narray.map.with_index{|value,index|\n leftsum+=value\n leftsumArray[index]=leftsum\n}\n\nrightsum=0\narrayreverse.map.with_index{|value,index|\n rightsum+=value\n rightsumArray[index]=rightsum\n}\n\nrightsumArray=rightsumArray.reverse\nhash=hash.sort.reverse\n\nleftnow=0\nrightnow=n-1\n\nhash.map{|value|\n uresisa=value[0]\n array2=value[1]\n \n array2.map{|place|\n leftdis=(place-leftnow).abs\n rightdis=(place-rightnow).abs\n \n # leftsum=leftsumArray[place-1] ? leftsumArray[place-1] : 0\n # rightsum=rightsumArray[place+1] ? rightsumArray[place+1] : 0\n \n if place==0\n leftsum=0\n else\n leftsum=array[0...place].select{|n| n leftsum + rightdis*uresisa\n ansArray[leftnow]=uresisa\n ans+=leftdis*uresisa\n leftnow+=1\n else\n ansArray[rightnow]=uresisa\n ans+=rightdis*uresisa\n rightnow-=1\n end\n\n }\n \n}\n\nputs ans\n\n\n\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i.\n\nYou can rearrange these children just one time in any order you like.\n\nWhen a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \\times |x-y| happiness points.\n\nFind the maximum total happiness points the children can earn.\n\nConstraints\n\n2 \\leq N \\leq 2000\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum total happiness points the children can earn.\n\nSample Input 1\n\n4\n1 3 4 2\n\nSample Output 1\n\n20\n\nIf we move the 1-st child from the left to the 3-rd position from the left, the 2-nd child to the 4-th position, the 3-rd child to the 1-st position, and the 4-th child to the 2-nd position, the children earns 1 \\times |1-3|+3 \\times |2-4|+4 \\times |3-1|+2 \\times |4-2|=20 happiness points in total.\n\nSample Input 2\n\n6\n5 5 6 1 1 1\n\nSample Output 2\n\n58\n\nSample Input 3\n\n6\n8 6 9 1 2 1\n\nSample Output 3\n\n85", "sample_input": "4\n1 3 4 2\n"}, "reference_outputs": ["20\n"], "source_document_id": "p02709", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i.\n\nYou can rearrange these children just one time in any order you like.\n\nWhen a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \\times |x-y| happiness points.\n\nFind the maximum total happiness points the children can earn.\n\nConstraints\n\n2 \\leq N \\leq 2000\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum total happiness points the children can earn.\n\nSample Input 1\n\n4\n1 3 4 2\n\nSample Output 1\n\n20\n\nIf we move the 1-st child from the left to the 3-rd position from the left, the 2-nd child to the 4-th position, the 3-rd child to the 1-st position, and the 4-th child to the 2-nd position, the children earns 1 \\times |1-3|+3 \\times |2-4|+4 \\times |3-1|+2 \\times |4-2|=20 happiness points in total.\n\nSample Input 2\n\n6\n5 5 6 1 1 1\n\nSample Output 2\n\n58\n\nSample Input 3\n\n6\n8 6 9 1 2 1\n\nSample Output 3\n\n85", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1610, "cpu_time_ms": 449, "memory_kb": 30100}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s686142510", "group_id": "codeNet:p02712", "input_text": "n = gets.chomp.to_i\n\ncount = 0\n1.step(n, 1) do |i|\n if i % 3 != 0 && i % 5 != 0\n count = count + i\n end\nend\n\nputs count\n", "language": "Ruby", "metadata": {"date": 1586739998, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02712.html", "problem_id": "p02712", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02712/input.txt", "sample_output_relpath": "derived/input_output/data/p02712/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02712/Ruby/s686142510.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s686142510", "user_id": "u776820541"}, "prompt_components": {"gold_output": "60\n", "input_to_evaluate": "n = gets.chomp.to_i\n\ncount = 0\n1.step(n, 1) do |i|\n if i % 3 != 0 && i % 5 != 0\n count = count + i\n end\nend\n\nputs count\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLet us define the FizzBuzz sequence a_1,a_2,... as follows:\n\nIf both 3 and 5 divides i, a_i=\\mbox{FizzBuzz}.\n\nIf the above does not hold but 3 divides i, a_i=\\mbox{Fizz}.\n\nIf none of the above holds but 5 divides i, a_i=\\mbox{Buzz}.\n\nIf none of the above holds, a_i=i.\n\nFind the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n60\n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\nSample Input 2\n\n1000000\n\nSample Output 2\n\n266666333332\n\nWatch out for overflow.", "sample_input": "15\n"}, "reference_outputs": ["60\n"], "source_document_id": "p02712", "source_text": "Score : 200 points\n\nProblem Statement\n\nLet us define the FizzBuzz sequence a_1,a_2,... as follows:\n\nIf both 3 and 5 divides i, a_i=\\mbox{FizzBuzz}.\n\nIf the above does not hold but 3 divides i, a_i=\\mbox{Fizz}.\n\nIf none of the above holds but 5 divides i, a_i=\\mbox{Buzz}.\n\nIf none of the above holds, a_i=i.\n\nFind the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n60\n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\nSample Input 2\n\n1000000\n\nSample Output 2\n\n266666333332\n\nWatch out for overflow.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 125, "cpu_time_ms": 135, "memory_kb": 14288}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s613880406", "group_id": "codeNet:p02712", "input_text": "p (1..gets.to_i).select{|i|i%3>0&&i%5>0}.sum", "language": "Ruby", "metadata": {"date": 1586739729, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02712.html", "problem_id": "p02712", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02712/input.txt", "sample_output_relpath": "derived/input_output/data/p02712/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02712/Ruby/s613880406.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s613880406", "user_id": "u019489252"}, "prompt_components": {"gold_output": "60\n", "input_to_evaluate": "p (1..gets.to_i).select{|i|i%3>0&&i%5>0}.sum", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLet us define the FizzBuzz sequence a_1,a_2,... as follows:\n\nIf both 3 and 5 divides i, a_i=\\mbox{FizzBuzz}.\n\nIf the above does not hold but 3 divides i, a_i=\\mbox{Fizz}.\n\nIf none of the above holds but 5 divides i, a_i=\\mbox{Buzz}.\n\nIf none of the above holds, a_i=i.\n\nFind the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n60\n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\nSample Input 2\n\n1000000\n\nSample Output 2\n\n266666333332\n\nWatch out for overflow.", "sample_input": "15\n"}, "reference_outputs": ["60\n"], "source_document_id": "p02712", "source_text": "Score : 200 points\n\nProblem Statement\n\nLet us define the FizzBuzz sequence a_1,a_2,... as follows:\n\nIf both 3 and 5 divides i, a_i=\\mbox{FizzBuzz}.\n\nIf the above does not hold but 3 divides i, a_i=\\mbox{Fizz}.\n\nIf none of the above holds but 5 divides i, a_i=\\mbox{Buzz}.\n\nIf none of the above holds, a_i=i.\n\nFind the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n60\n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\nSample Input 2\n\n1000000\n\nSample Output 2\n\n266666333332\n\nWatch out for overflow.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 44, "cpu_time_ms": 148, "memory_kb": 18452}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s543889648", "group_id": "codeNet:p02716", "input_text": "INF = 10**15\nn = gets.to_i\na = gets.split.map(&:to_i)\n\nif n % 2 == 0\n evn = Array.new(n+1,0)\n odd = Array.new(n+1,0)\n for i in 0..(n-1)\n evp = odp = 0\n (i % 2 == 0) ? (evp = a[i]):(odp = a[i])\n evn[i+1] = evn[i] + evp\n odd[i+1] = odd[i] + odp\n end\n ans = -INF\n for i in 0..(n-1)\n if i % 2 == 0\n ans = [ans, evn[i]+odd[n]-odd[i]].max\n end\n end\n ans = [ans, evn[i]].max\n puts ans\nelse\n dp = Array.new(n).map{Array.new(3).map{Array.new(2,-INF)}}\n ans = -INF\n for i in 0..2\n dp[i][i][0] = a[i]\n dp[i][i][1] = 1\n end\n for i in 0..(n-1)\n for j in 0..2\n if i > j && (i % 2 == j % 2) && dp[i-2][j][1] < n/2\n for k in 0..j\n dp[i][j][0] = [dp[i][j][0], dp[i-2-k][j-k][0]+a[i]].max\n end\n dp[i][j][1] = dp[i-2][j][1] + 1\n end\n ans = [ans, dp[i][j][0]].max if dp[i][j][1] == n/2\n end\n end\n puts ans\nend", "language": "Ruby", "metadata": {"date": 1586887128, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02716.html", "problem_id": "p02716", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02716/input.txt", "sample_output_relpath": "derived/input_output/data/p02716/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02716/Ruby/s543889648.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s543889648", "user_id": "u326891688"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "INF = 10**15\nn = gets.to_i\na = gets.split.map(&:to_i)\n\nif n % 2 == 0\n evn = Array.new(n+1,0)\n odd = Array.new(n+1,0)\n for i in 0..(n-1)\n evp = odp = 0\n (i % 2 == 0) ? (evp = a[i]):(odp = a[i])\n evn[i+1] = evn[i] + evp\n odd[i+1] = odd[i] + odp\n end\n ans = -INF\n for i in 0..(n-1)\n if i % 2 == 0\n ans = [ans, evn[i]+odd[n]-odd[i]].max\n end\n end\n ans = [ans, evn[i]].max\n puts ans\nelse\n dp = Array.new(n).map{Array.new(3).map{Array.new(2,-INF)}}\n ans = -INF\n for i in 0..2\n dp[i][i][0] = a[i]\n dp[i][i][1] = 1\n end\n for i in 0..(n-1)\n for j in 0..2\n if i > j && (i % 2 == j % 2) && dp[i-2][j][1] < n/2\n for k in 0..j\n dp[i][j][0] = [dp[i][j][0], dp[i-2-k][j-k][0]+a[i]].max\n end\n dp[i][j][1] = dp[i-2][j][1] + 1\n end\n ans = [ans, dp[i][j][0]].max if dp[i][j][1] == n/2\n end\n end\n puts ans\nend", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven is an integer sequence A_1, ..., A_N of length N.\n\nWe will choose exactly \\left\\lfloor \\frac{N}{2} \\right\\rfloor elements from this sequence so that no two adjacent elements are chosen.\n\nFind the maximum possible sum of the chosen elements.\n\nHere \\lfloor x \\rfloor denotes the greatest integer not greater than x.\n\nConstraints\n\n2 \\leq N \\leq 2\\times 10^5\n\n|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_N\n\nOutput\n\nPrint the maximum possible sum of the chosen elements.\n\nSample Input 1\n\n6\n1 2 3 4 5 6\n\nSample Output 1\n\n12\n\nChoosing 2, 4, and 6 makes the sum 12, which is the maximum possible value.\n\nSample Input 2\n\n5\n-1000 -100 -10 0 10\n\nSample Output 2\n\n0\n\nChoosing -10 and 10 makes the sum 0, which is the maximum possible value.\n\nSample Input 3\n\n10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 3\n\n5000000000\n\nWatch out for overflow.\n\nSample Input 4\n\n27\n18 -28 18 28 -45 90 -45 23 -53 60 28 -74 -71 35 -26 -62 49 -77 57 24 -70 -93 69 -99 59 57 -49\n\nSample Output 4\n\n295", "sample_input": "6\n1 2 3 4 5 6\n"}, "reference_outputs": ["12\n"], "source_document_id": "p02716", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven is an integer sequence A_1, ..., A_N of length N.\n\nWe will choose exactly \\left\\lfloor \\frac{N}{2} \\right\\rfloor elements from this sequence so that no two adjacent elements are chosen.\n\nFind the maximum possible sum of the chosen elements.\n\nHere \\lfloor x \\rfloor denotes the greatest integer not greater than x.\n\nConstraints\n\n2 \\leq N \\leq 2\\times 10^5\n\n|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_N\n\nOutput\n\nPrint the maximum possible sum of the chosen elements.\n\nSample Input 1\n\n6\n1 2 3 4 5 6\n\nSample Output 1\n\n12\n\nChoosing 2, 4, and 6 makes the sum 12, which is the maximum possible value.\n\nSample Input 2\n\n5\n-1000 -100 -10 0 10\n\nSample Output 2\n\n0\n\nChoosing -10 and 10 makes the sum 0, which is the maximum possible value.\n\nSample Input 3\n\n10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 3\n\n5000000000\n\nWatch out for overflow.\n\nSample Input 4\n\n27\n18 -28 18 28 -45 90 -45 23 -53 60 28 -74 -71 35 -26 -62 49 -77 57 24 -70 -93 69 -99 59 57 -49\n\nSample Output 4\n\n295", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 885, "cpu_time_ms": 521, "memory_kb": 66656}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s294007623", "group_id": "codeNet:p02723", "input_text": "input = gets.split(\"\")\nif input[2] == input[3] && input[4] == input[5]\n puts \"Yes\"\nelse\n puts \"No\"\nend", "language": "Ruby", "metadata": {"date": 1585685350, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02723.html", "problem_id": "p02723", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02723/input.txt", "sample_output_relpath": "derived/input_output/data/p02723/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02723/Ruby/s294007623.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s294007623", "user_id": "u417892119"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "input = gets.split(\"\")\nif input[2] == input[3] && input[4] == input[5]\n puts \"Yes\"\nelse\n puts \"No\"\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal.\n\nGiven a string S, determine whether it is coffee-like.\n\nConstraints\n\nS is a string of length 6 consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is coffee-like, print Yes; otherwise, print No.\n\nSample Input 1\n\nsippuu\n\nSample Output 1\n\nYes\n\nIn sippuu, the 3-rd and 4-th characters are equal, and the 5-th and 6-th characters are also equal.\n\nSample Input 2\n\niphone\n\nSample Output 2\n\nNo\n\nSample Input 3\n\ncoffee\n\nSample Output 3\n\nYes", "sample_input": "sippuu\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02723", "source_text": "Score : 100 points\n\nProblem Statement\n\nA string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal.\n\nGiven a string S, determine whether it is coffee-like.\n\nConstraints\n\nS is a string of length 6 consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is coffee-like, print Yes; otherwise, print No.\n\nSample Input 1\n\nsippuu\n\nSample Output 1\n\nYes\n\nIn sippuu, the 3-rd and 4-th characters are equal, and the 5-th and 6-th characters are also equal.\n\nSample Input 2\n\niphone\n\nSample Output 2\n\nNo\n\nSample Input 3\n\ncoffee\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 108, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s794065961", "group_id": "codeNet:p02724", "input_text": "x=gets.to_i\na=0\nuntil x<500\na+=1000\nx-=500\nend\nuntil x<5\na+=5\nx-=5\nend\np a", "language": "Ruby", "metadata": {"date": 1598777684, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s794065961.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s794065961", "user_id": "u647875062"}, "prompt_components": {"gold_output": "2020\n", "input_to_evaluate": "x=gets.to_i\na=0\nuntil x<500\na+=1000\nx-=500\nend\nuntil x<5\na+=5\nx-=5\nend\np a", "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": 74, "cpu_time_ms": 105, "memory_kb": 14288}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s759430127", "group_id": "codeNet:p02725", "input_text": "# frozen_string_literal: true\n\nk, n = gets.split.map(&:to_i)\na = gets.split.map(&:to_i)\na.push k + a[0]\nb = []\n(1..n).each do |i|\n b.push a[i] - a[i - 1]\nend\n\nm = b.index(b.max)\n\nb.delete_at(m)\nputs b.reduce(:+)\n", "language": "Ruby", "metadata": {"date": 1585445069, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s759430127.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s759430127", "user_id": "u434509016"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "# frozen_string_literal: true\n\nk, n = gets.split.map(&:to_i)\na = gets.split.map(&:to_i)\na.push k + a[0]\nb = []\n(1..n).each do |i|\n b.push a[i] - a[i - 1]\nend\n\nm = b.index(b.max)\n\nb.delete_at(m)\nputs b.reduce(:+)\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": 213, "cpu_time_ms": 136, "memory_kb": 19076}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s603421965", "group_id": "codeNet:p02729", "input_text": "i = 0\nif N > 1\n nums = N - 1\n nums.times do\n i += nums\n nums -= 1\n end\nend\nif M > 1\n i += M\nend\np i", "language": "Ruby", "metadata": {"date": 1585282168, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s603421965.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s603421965", "user_id": "u539465520"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "i = 0\nif N > 1\n nums = N - 1\n nums.times do\n i += nums\n nums -= 1\n end\nend\nif M > 1\n i += M\nend\np i", "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": 109, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s925764666", "group_id": "codeNet:p02729", "input_text": "a=gets.chomp.split.map(&:to_i)\nb=[*2..a[0]]\n\nc=b.combination(2).to_a\nd=[*1..a[1]].combination(2).to_a.length\nputs c.length+d", "language": "Ruby", "metadata": {"date": 1584938381, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s925764666.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s925764666", "user_id": "u175113369"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "a=gets.chomp.split.map(&:to_i)\nb=[*2..a[0]]\n\nc=b.combination(2).to_a\nd=[*1..a[1]].combination(2).to_a.length\nputs c.length+d", "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": 124, "cpu_time_ms": 9, "memory_kb": 2172}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s040752117", "group_id": "codeNet:p02729", "input_text": "# frozen_string_literal: true\n\nN, M = gets.split.map(&:to_i)\n\nputs((N * (N - 1) + M * (M - 1)) / 2)", "language": "Ruby", "metadata": {"date": 1584925511, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s040752117.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s040752117", "user_id": "u104886851"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "# frozen_string_literal: true\n\nN, M = gets.split.map(&:to_i)\n\nputs((N * (N - 1) + M * (M - 1)) / 2)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have N+M balls, each of which has an integer written on it.\n\nIt is known that:\n\nThe numbers written on N of the balls are even.\n\nThe numbers written on M of the balls are odd.\n\nFind the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.\n\nIt can be shown that this count does not depend on the actual values written on the balls.\n\nConstraints\n\n0 \\leq N,M \\leq 100\n\n2 \\leq N+M\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 1\n\nSample Output 1\n\n1\n\nFor example, let us assume that the numbers written on the three balls are 1,2,4.\n\nIf we choose the two balls with 1 and 2, the sum is odd;\n\nIf we choose the two balls with 1 and 4, the sum is odd;\n\nIf we choose the two balls with 2 and 4, the sum is even.\n\nThus, the answer is 1.\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\n9\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n13 3\n\nSample Output 4\n\n81\n\nSample Input 5\n\n0 3\n\nSample Output 5\n\n3", "sample_input": "2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02729", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have N+M balls, each of which has an integer written on it.\n\nIt is known that:\n\nThe numbers written on N of the balls are even.\n\nThe numbers written on M of the balls are odd.\n\nFind the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.\n\nIt can be shown that this count does not depend on the actual values written on the balls.\n\nConstraints\n\n0 \\leq N,M \\leq 100\n\n2 \\leq N+M\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 1\n\nSample Output 1\n\n1\n\nFor example, let us assume that the numbers written on the three balls are 1,2,4.\n\nIf we choose the two balls with 1 and 2, the sum is odd;\n\nIf we choose the two balls with 1 and 4, the sum is odd;\n\nIf we choose the two balls with 2 and 4, the sum is even.\n\nThus, the answer is 1.\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\n9\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n13 3\n\nSample Output 4\n\n81\n\nSample Input 5\n\n0 3\n\nSample Output 5\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 99, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s804281764", "group_id": "codeNet:p02730", "input_text": "s = gets.chomp\nn = s.length\nnum1 = ((n-1)/2)\nnum2 = ((n+3)/2)-1\n\nstr1 = s[0,num1]\nstr2 = s[num2,n]\n\np s == s.reverse && str1 == str1.reverse && str2 == str2.reverse ? 'Yes' : 'No'", "language": "Ruby", "metadata": {"date": 1585011136, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02730.html", "problem_id": "p02730", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02730/input.txt", "sample_output_relpath": "derived/input_output/data/p02730/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02730/Ruby/s804281764.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s804281764", "user_id": "u433171793"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "s = gets.chomp\nn = s.length\nnum1 = ((n-1)/2)\nnum2 = ((n+3)/2)-1\n\nstr1 = s[0,num1]\nstr2 = s[num2,n]\n\np s == s.reverse && str1 == str1.reverse && str2 == str2.reverse ? 'Yes' : 'No'", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "sample_input": "akasaka\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02730", "source_text": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 179, "cpu_time_ms": 8, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s449466468", "group_id": "codeNet:p02731", "input_text": "l = (gets.to_i/3).floor(6)\nputs (l**3).floor(6) \n", "language": "Ruby", "metadata": {"date": 1590122576, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s449466468.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s449466468", "user_id": "u932417742"}, "prompt_components": {"gold_output": "1.000000000000\n", "input_to_evaluate": "l = (gets.to_i/3).floor(6)\nputs (l**3).floor(6) \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": 49, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s466416427", "group_id": "codeNet:p02732", "input_text": "N = gets.chomp.to_i\narray = gets.chomp.split.map(&:to_i)\n\ndef count(num)\n return 0 if num <= 1\n return (num - 1) + count(num - 1)\nend\n\n(1..N).each do |k|\n duped_array = array.dup\n duped_array.slice!(k - 1)\n banned_array = duped_array\n counter = 0\n banned_array.uniq.each do |num|\n tmp_array = banned_array.dup\n tmp_array.delete(num)\n num_count = banned_array.size - tmp_array.size\n # p num\n if num_count == 0\n next\n end\n\n counter += count(num_count)\n end\n puts counter\nend\n", "language": "Ruby", "metadata": {"date": 1586136871, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s466416427.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s466416427", "user_id": "u727437745"}, "prompt_components": {"gold_output": "2\n2\n3\n2\n3\n", "input_to_evaluate": "N = gets.chomp.to_i\narray = gets.chomp.split.map(&:to_i)\n\ndef count(num)\n return 0 if num <= 1\n return (num - 1) + count(num - 1)\nend\n\n(1..N).each do |k|\n duped_array = array.dup\n duped_array.slice!(k - 1)\n banned_array = duped_array\n counter = 0\n banned_array.uniq.each do |num|\n tmp_array = banned_array.dup\n tmp_array.delete(num)\n num_count = banned_array.size - tmp_array.size\n # p num\n if num_count == 0\n next\n end\n\n counter += count(num_count)\n end\n puts counter\nend\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": 508, "cpu_time_ms": 2112, "memory_kb": 88564}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s043215791", "group_id": "codeNet:p02732", "input_text": "# ABC 159 D\n# https://atcoder.jp/contests/abc159/tasks/abc159_d\n\nn = gets.to_i\na = gets.split(/ /).map(&:to_i)\n\na_uniq_size = a.uniq.size\n\nclass Pattern\n def initialize(i)\n @i = i\n @count = 0\n end\n\n def increment\n @count = @count + 1\n end\n\n attr_reader :count\n\n def calc\n @calc ||= count * (count - 1) / 2\n end\nend\n\nh = {}\n\na.each do |ai|\n h[ai] ||= Pattern.new(ai)\n h[ai].increment\nend\n\nbase = h.values.map(&:calc).sum\n\nh2 = {}\n\na.each_with_index do |ai, i|\n pattern = h[ai]\n if h2[ai].nil?\n result = base - (pattern.count - 1)\n h2[ai] = result\n else\n result = h2[ai]\n end\n puts result\nend\n", "language": "Ruby", "metadata": {"date": 1584927521, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s043215791.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s043215791", "user_id": "u094532861"}, "prompt_components": {"gold_output": "2\n2\n3\n2\n3\n", "input_to_evaluate": "# ABC 159 D\n# https://atcoder.jp/contests/abc159/tasks/abc159_d\n\nn = gets.to_i\na = gets.split(/ /).map(&:to_i)\n\na_uniq_size = a.uniq.size\n\nclass Pattern\n def initialize(i)\n @i = i\n @count = 0\n end\n\n def increment\n @count = @count + 1\n end\n\n attr_reader :count\n\n def calc\n @calc ||= count * (count - 1) / 2\n end\nend\n\nh = {}\n\na.each do |ai|\n h[ai] ||= Pattern.new(ai)\n h[ai].increment\nend\n\nbase = h.values.map(&:calc).sum\n\nh2 = {}\n\na.each_with_index do |ai, i|\n pattern = h[ai]\n if h2[ai].nil?\n result = base - (pattern.count - 1)\n h2[ai] = result\n else\n result = h2[ai]\n end\n puts result\nend\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": 626, "cpu_time_ms": 368, "memory_kb": 36000}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s524430629", "group_id": "codeNet:p02735", "input_text": "H,W=gets.split.map &:to_i\nFIELD=H.times.map{gets.chomp.chars}\n\n# 選ぶ進行方向は何通り\nS=['r','l'].repeated_permutation(H+W-2).to_a\n#puts S.inspect\n\narr=[]\nS.each do |s|\n i=0\n j=0\n res=0\n flg=false\n s.each do |m|\n if m=='r'\n i+=1\n elsif m=='l'\n\t j+=1\n end\n if i>H-1 || j>W-1\n flg=true\n break\n end\n res+=1 if FIELD[i][j]=='#'\n if !arr.empty? && arr.min<=res\n flg=true\n break\n end\n end\n next if flg==true\n arr << res\nend\nres = arr.min\n#puts arr.inspect\nres+=1 if FIELD[0][0]=='#' \n#res+=1 if FIELD[H-1][W-1]=='#' \nputs res", "language": "Ruby", "metadata": {"date": 1584844458, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s524430629.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s524430629", "user_id": "u630043039"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "H,W=gets.split.map &:to_i\nFIELD=H.times.map{gets.chomp.chars}\n\n# 選ぶ進行方向は何通り\nS=['r','l'].repeated_permutation(H+W-2).to_a\n#puts S.inspect\n\narr=[]\nS.each do |s|\n i=0\n j=0\n res=0\n flg=false\n s.each do |m|\n if m=='r'\n i+=1\n elsif m=='l'\n\t j+=1\n end\n if i>H-1 || j>W-1\n flg=true\n break\n end\n res+=1 if FIELD[i][j]=='#'\n if !arr.empty? && arr.min<=res\n flg=true\n break\n end\n end\n next if flg==true\n arr << res\nend\nres = arr.min\n#puts arr.inspect\nres+=1 if FIELD[0][0]=='#' \n#res+=1 if FIELD[H-1][W-1]=='#' \nputs res", "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": 587, "cpu_time_ms": 2127, "memory_kb": 318844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s298554814", "group_id": "codeNet:p02735", "input_text": "#!/usr/bin/ruby\n\nHH, WW = ARGF.gets.chomp.split.collect {|el| el.to_i}\n\n$dp = Array.new(HH + 1) {Array.new(WW + 1)}\n\nss = [\"-\" * (WW + 1)]\nHH.times do\n ss << (\"-\" + ARGF.gets.chomp)\nend\n\n$dp[0][1] = 0\n$dp[1][0] = 0\n\nfor hh in 2..HH\n $dp[hh][0] = HH + WW + 1\nend\n\nfor ww in 2..WW\n $dp[0][ww] = HH + WW + 1\nend\n\nfor hh in 1..HH\n for ww in 1..WW\n if ss[hh][ww] == \".\"\n $dp[hh][ww] = [$dp[hh - 1][ww], $dp[hh][ww - 1]].min\n else\n if ss[hh - 1][ww] == \".\"\n uu = $dp[hh - 1][ww] + 1\n else\n uu = $dp[hh - 1][ww]\n end\n if ss[hh][ww - 1] == \".\"\n rr = $dp[hh][ww - 1] + 1\n else\n rr = $dp[hh][ww - 1]\n end\n #p uu, rr\n $dp[hh][ww] = [uu, rr].min\n end\n #p $dp\n end\nend\n\n\nputs $dp[HH][WW]\n", "language": "Ruby", "metadata": {"date": 1584843251, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s298554814.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s298554814", "user_id": "u838869513"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#!/usr/bin/ruby\n\nHH, WW = ARGF.gets.chomp.split.collect {|el| el.to_i}\n\n$dp = Array.new(HH + 1) {Array.new(WW + 1)}\n\nss = [\"-\" * (WW + 1)]\nHH.times do\n ss << (\"-\" + ARGF.gets.chomp)\nend\n\n$dp[0][1] = 0\n$dp[1][0] = 0\n\nfor hh in 2..HH\n $dp[hh][0] = HH + WW + 1\nend\n\nfor ww in 2..WW\n $dp[0][ww] = HH + WW + 1\nend\n\nfor hh in 1..HH\n for ww in 1..WW\n if ss[hh][ww] == \".\"\n $dp[hh][ww] = [$dp[hh - 1][ww], $dp[hh][ww - 1]].min\n else\n if ss[hh - 1][ww] == \".\"\n uu = $dp[hh - 1][ww] + 1\n else\n uu = $dp[hh - 1][ww]\n end\n if ss[hh][ww - 1] == \".\"\n rr = $dp[hh][ww - 1] + 1\n else\n rr = $dp[hh][ww - 1]\n end\n #p uu, rr\n $dp[hh][ww] = [uu, rr].min\n end\n #p $dp\n end\nend\n\n\nputs $dp[HH][WW]\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": 765, "cpu_time_ms": 20, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s622920134", "group_id": "codeNet:p02742", "input_text": "h, w = gets.chomp.split(\" \").map(&:to_i)\nif h.even? then\n\tputs h * w / 2\nelse\n\tputs h * w / 2 + 1\nend", "language": "Ruby", "metadata": {"date": 1587697739, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s622920134.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s622920134", "user_id": "u409390792"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "h, w = gets.chomp.split(\" \").map(&:to_i)\nif h.even? then\n\tputs h * w / 2\nelse\n\tputs h * w / 2 + 1\nend", "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": 102, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s136172553", "group_id": "codeNet:p02742", "input_text": "a,b = gets.split.map(&:to_i)\nrem = a * b % 2\nputs a * b / 2 + rem", "language": "Ruby", "metadata": {"date": 1584240480, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s136172553.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s136172553", "user_id": "u329977093"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "a,b = gets.split.map(&:to_i)\nrem = a * b % 2\nputs a * b / 2 + rem", "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": 65, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s810438952", "group_id": "codeNet:p02742", "input_text": "h,w=gets.split.map &:to_i\n\nif w % 2 == 0 then\n p (w/2).floor * h\nelse\n p ((w+1)/2).floor * ((h+1)/2).floor + (w/2).floor * (h/2).floor\nend\n", "language": "Ruby", "metadata": {"date": 1584234328, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s810438952.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s810438952", "user_id": "u025592199"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "h,w=gets.split.map &:to_i\n\nif w % 2 == 0 then\n p (w/2).floor * h\nelse\n p ((w+1)/2).floor * ((h+1)/2).floor + (w/2).floor * (h/2).floor\nend\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "sample_input": "4 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02742", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 141, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s471414028", "group_id": "codeNet:p02744", "input_text": "N = gets.chomp.to_i\na = \"abcdefghij\"\nb = Array.new(N,0)\nc = Array.new(N,0)\nn = 1\nif N == 1\n puts \"a\"\n exit\nend\nwhile b[0] == 0\n m = 0\n while m < N\n x = b[m]\n print a[x]\n m += 1\n end\n puts\n b[-1] += 1\n if b[-1] > c[-1] + 1\n b[-1] = 0\n b[-2] += 1\n c[-1] = b[-2] > c[-1] ? b[-2] : c[-1]\n n = 2\n while b[-n] > c[-n] + 1\n l = n+1\n b[-n] = 0\n b[-l] += 1\n c[-n] = b[-l] > c[-n] ? b[-l] : c[-n]\n n += 1\n end\n n -= 2\n while n >= 1\n c[-n] = c[-n-1]\n n -= 1\n end\n end\nend", "language": "Ruby", "metadata": {"date": 1584239489, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s471414028.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s471414028", "user_id": "u349832549"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "N = gets.chomp.to_i\na = \"abcdefghij\"\nb = Array.new(N,0)\nc = Array.new(N,0)\nn = 1\nif N == 1\n puts \"a\"\n exit\nend\nwhile b[0] == 0\n m = 0\n while m < N\n x = b[m]\n print a[x]\n m += 1\n end\n puts\n b[-1] += 1\n if b[-1] > c[-1] + 1\n b[-1] = 0\n b[-2] += 1\n c[-1] = b[-2] > c[-1] ? b[-2] : c[-1]\n n = 2\n while b[-n] > c[-n] + 1\n l = n+1\n b[-n] = 0\n b[-l] += 1\n c[-n] = b[-l] > c[-n] ? b[-l] : c[-n]\n n += 1\n end\n n -= 2\n while n >= 1\n c[-n] = c[-n-1]\n n -= 1\n end\n end\nend", "problem_context": "Score : 400 points\n\nProblem Statement\n\nIn this problem, we only consider strings consisting of lowercase English letters.\n\nStrings s and t are said to be isomorphic when the following conditions are satisfied:\n\n|s| = |t| holds.\n\nFor every pair i, j, one of the following holds:\n\ns_i = s_j and t_i = t_j.\n\ns_i \\neq s_j and t_i \\neq t_j.\n\nFor example, abcac and zyxzx are isomorphic, while abcac and ppppp are not.\n\nA string s is said to be in normal form when the following condition is satisfied:\n\nFor every string t that is isomorphic to s, s \\leq t holds. Here \\leq denotes lexicographic comparison.\n\nFor example, abcac is in normal form, but zyxzx is not since it is isomorphic to abcac, which is lexicographically smaller than zyxzx.\n\nYou are given an integer N.\nPrint all strings of length N that are in normal form, in lexicographically ascending order.\n\nConstraints\n\n1 \\leq N \\leq 10\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nAssume that there are K strings of length N that are in normal form: w_1, \\ldots, w_K in lexicographical order.\nOutput should be in the following format:\n\nw_1\n:\nw_K\n\nSample Input 1\n\n1\n\nSample Output 1\n\na\n\nSample Input 2\n\n2\n\nSample Output 2\n\naa\nab", "sample_input": "1\n"}, "reference_outputs": ["a\n"], "source_document_id": "p02744", "source_text": "Score : 400 points\n\nProblem Statement\n\nIn this problem, we only consider strings consisting of lowercase English letters.\n\nStrings s and t are said to be isomorphic when the following conditions are satisfied:\n\n|s| = |t| holds.\n\nFor every pair i, j, one of the following holds:\n\ns_i = s_j and t_i = t_j.\n\ns_i \\neq s_j and t_i \\neq t_j.\n\nFor example, abcac and zyxzx are isomorphic, while abcac and ppppp are not.\n\nA string s is said to be in normal form when the following condition is satisfied:\n\nFor every string t that is isomorphic to s, s \\leq t holds. Here \\leq denotes lexicographic comparison.\n\nFor example, abcac is in normal form, but zyxzx is not since it is isomorphic to abcac, which is lexicographically smaller than zyxzx.\n\nYou are given an integer N.\nPrint all strings of length N that are in normal form, in lexicographically ascending order.\n\nConstraints\n\n1 \\leq N \\leq 10\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nAssume that there are K strings of length N that are in normal form: w_1, \\ldots, w_K in lexicographical order.\nOutput should be in the following format:\n\nw_1\n:\nw_K\n\nSample Input 1\n\n1\n\nSample Output 1\n\na\n\nSample Input 2\n\n2\n\nSample Output 2\n\naa\nab", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 422, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s419543309", "group_id": "codeNet:p02747", "input_text": "# 文字列 hi が 1 個以上繋がってできる文字列を、 hitachi文字列 と定義します。\n# 例えば、 hi や hihi などは hitachi文字列 であり、 ha や hii は hitachi文字列 ではありません。\n# 文字列 S が与えられるので、 S が hitachi文字列 かどうかを判定してください。\n\ns = gets.chomp\nresult = true\n\ni = 0\nwhile i < s.length\n if !(s[i] == \"h\" && s[i+1] == \"i\")\n result = false\n break\n end\n i += 2\nend\n\nif result\n puts \"Yes\"\nelse\n puts \"No\"\nend", "language": "Ruby", "metadata": {"date": 1583719320, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s419543309.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s419543309", "user_id": "u139850627"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "# 文字列 hi が 1 個以上繋がってできる文字列を、 hitachi文字列 と定義します。\n# 例えば、 hi や hihi などは hitachi文字列 であり、 ha や hii は hitachi文字列 ではありません。\n# 文字列 S が与えられるので、 S が hitachi文字列 かどうかを判定してください。\n\ns = gets.chomp\nresult = true\n\ni = 0\nwhile i < s.length\n if !(s[i] == \"h\" && s[i+1] == \"i\")\n result = false\n break\n end\n i += 2\nend\n\nif result\n puts \"Yes\"\nelse\n puts \"No\"\nend", "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": 541, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s607954631", "group_id": "codeNet:p02747", "input_text": "s = gets.chomp\ns = s.gsub(/hi/, '')\nif s.length == 0\n puts \"Yes\"\nelse\n puts \"No\"\nend", "language": "Ruby", "metadata": {"date": 1583716030, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s607954631.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s607954631", "user_id": "u244401500"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "s = gets.chomp\ns = s.gsub(/hi/, '')\nif s.length == 0\n puts \"Yes\"\nelse\n puts \"No\"\nend", "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": 86, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s404082081", "group_id": "codeNet:p02753", "input_text": "S = gets.chomp.split(//)\n\nputs S.uniq.length == 1 ? 'No' : 'Yes'", "language": "Ruby", "metadata": {"date": 1583634201, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02753.html", "problem_id": "p02753", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02753/input.txt", "sample_output_relpath": "derived/input_output/data/p02753/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02753/Ruby/s404082081.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s404082081", "user_id": "u039293076"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "S = gets.chomp.split(//)\n\nputs S.uniq.length == 1 ? 'No' : 'Yes'", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn AtCoder City, there are three stations numbered 1, 2, and 3.\n\nEach of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Station i; if S_i is B, Company B operates Station i.\n\nTo improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.\n\nDetermine if there is a pair of stations that will be connected by a bus service.\n\nConstraints\n\nEach character of S is A or B.\n\n|S| = 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.\n\nSample Input 1\n\nABA\n\nSample Output 1\n\nYes\n\nCompany A operates Station 1 and 3, while Company B operates Station 2.\n\nThere will be a bus service between Station 1 and 2, and between Station 2 and 3, so print Yes.\n\nSample Input 2\n\nBBA\n\nSample Output 2\n\nYes\n\nCompany B operates Station 1 and 2, while Company A operates Station 3.\n\nThere will be a bus service between Station 1 and 3, and between Station 2 and 3, so print Yes.\n\nSample Input 3\n\nBBB\n\nSample Output 3\n\nNo\n\nCompany B operates all the stations. Thus, there will be no bus service, so print No.", "sample_input": "ABA\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02753", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn AtCoder City, there are three stations numbered 1, 2, and 3.\n\nEach of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Station i; if S_i is B, Company B operates Station i.\n\nTo improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.\n\nDetermine if there is a pair of stations that will be connected by a bus service.\n\nConstraints\n\nEach character of S is A or B.\n\n|S| = 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.\n\nSample Input 1\n\nABA\n\nSample Output 1\n\nYes\n\nCompany A operates Station 1 and 3, while Company B operates Station 2.\n\nThere will be a bus service between Station 1 and 2, and between Station 2 and 3, so print Yes.\n\nSample Input 2\n\nBBA\n\nSample Output 2\n\nYes\n\nCompany B operates Station 1 and 2, while Company A operates Station 3.\n\nThere will be a bus service between Station 1 and 3, and between Station 2 and 3, so print Yes.\n\nSample Input 3\n\nBBB\n\nSample Output 3\n\nNo\n\nCompany B operates all the stations. Thus, there will be no bus service, so print No.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 64, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s619585894", "group_id": "codeNet:p02754", "input_text": "n,a,b = gets.split.map(&:to_i)\nx = (n / (a+b) * a)\ny = (n % (a+b))\n\nif a < y \n x += a\nelse\n x += y\nend\n\nputs x", "language": "Ruby", "metadata": {"date": 1589502826, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s619585894.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s619585894", "user_id": "u781354194"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "n,a,b = gets.split.map(&:to_i)\nx = (n / (a+b) * a)\ny = (n % (a+b))\n\nif a < y \n x += a\nelse\n x += y\nend\n\nputs x", "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": 112, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s608517676", "group_id": "codeNet:p02754", "input_text": "n,a,b = gets.split.map(&:to_i)\nans = []\nblue = []\nred = []\na.times do\n blue << \"b\"\nend\nb.times do\n red << \"r\"\nend\nuntil ans.length == n\n ans << blue\n ans << red\nend\nputs ans.slice(0..n-1).count('b')", "language": "Ruby", "metadata": {"date": 1583637450, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s608517676.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s608517676", "user_id": "u523351024"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "n,a,b = gets.split.map(&:to_i)\nans = []\nblue = []\nred = []\na.times do\n blue << \"b\"\nend\nb.times do\n red << \"r\"\nend\nuntil ans.length == n\n ans << blue\n ans << red\nend\nputs ans.slice(0..n-1).count('b')", "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": 202, "cpu_time_ms": 2143, "memory_kb": 540796}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s674893748", "group_id": "codeNet:p02756", "input_text": "attrs = Array.new\nwhile line = $stdin.gets\n attrs << line.chomp.split\nend\n\ns = attrs[0][0]\nQ = attrs[1][0].to_i\nis_reverse = false\nQ.times do |i|\n t, f, c = attrs[2+i].map{|a| a}\n if t == '1' then\n is_reverse = !is_reverse\n else\n if f == '1' then\n if is_reverse then\n s = s + c\n else\n s = c + s\n end\n else\n if is_reverse then\n s = c + s\n else\n s = s + c\n end\n end\n end\nend\nputs is_reverse ? s.reverse : s", "language": "Ruby", "metadata": {"date": 1590272957, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s674893748.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s674893748", "user_id": "u244257825"}, "prompt_components": {"gold_output": "cpa\n", "input_to_evaluate": "attrs = Array.new\nwhile line = $stdin.gets\n attrs << line.chomp.split\nend\n\ns = attrs[0][0]\nQ = attrs[1][0].to_i\nis_reverse = false\nQ.times do |i|\n t, f, c = attrs[2+i].map{|a| a}\n if t == '1' then\n is_reverse = !is_reverse\n else\n if f == '1' then\n if is_reverse then\n s = s + c\n else\n s = c + s\n end\n else\n if is_reverse then\n s = c + s\n else\n s = s + c\n end\n end\n end\nend\nputs is_reverse ? s.reverse : s", "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": 479, "cpu_time_ms": 2115, "memory_kb": 123792}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s300491579", "group_id": "codeNet:p02756", "input_text": "s=gets.chomp\ns0=\"\"\ns1=\"\"\nfl=false\nq=gets.to_i\nq.times do\n qu=gets.chomp\n if qu==\"1\"\n fl=!fl\n else\n if fl&&qu[2]==\"1\"||!fl&&qu[2]==\"0\"\n s1+=qu[4]\n else\n s0+=qu[4]\n end\n end\nend\nif !fl\n puts s0.reverse+s+s1\nelse\n puts s1.reverse+s.reverse+s0\nend\n\n", "language": "Ruby", "metadata": {"date": 1583635450, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s300491579.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s300491579", "user_id": "u744908753"}, "prompt_components": {"gold_output": "cpa\n", "input_to_evaluate": "s=gets.chomp\ns0=\"\"\ns1=\"\"\nfl=false\nq=gets.to_i\nq.times do\n qu=gets.chomp\n if qu==\"1\"\n fl=!fl\n else\n if fl&&qu[2]==\"1\"||!fl&&qu[2]==\"0\"\n s1+=qu[4]\n else\n s0+=qu[4]\n end\n end\nend\nif !fl\n puts s0.reverse+s+s1\nelse\n puts s1.reverse+s.reverse+s0\nend\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": 273, "cpu_time_ms": 2113, "memory_kb": 98784}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s277254851", "group_id": "codeNet:p02759", "input_text": "n=gets.to_i\nans=((n+0.5)/2).to_i\nputs ans\n", "language": "Ruby", "metadata": {"date": 1597070865, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s277254851.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s277254851", "user_id": "u977506075"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "n=gets.to_i\nans=((n+0.5)/2).to_i\nputs ans\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": 42, "cpu_time_ms": 68, "memory_kb": 14320}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s634468343", "group_id": "codeNet:p02760", "input_text": "A1 = gets.chop.split.map(&:to_i)\nA2 = gets.chop.split.map(&:to_i)\nA3 = gets.chop.split.map(&:to_i)\nN = gets.to_i\nb = []\nN.times { b << gets.to_i }\nA1_bng= ['D','D','D']\nA2_bng= ['D','D','D']\nA3_bng= ['D','D','D']\n\nfor n in 0..N-1 do\n\tbs = b[n]\n \t#puts bs\n for num in 0..2 do\n if bs == A1[num] then\n A1_bng[num] = bs\n #puts A1_bng\n elsif bs == A2[num] then\n A2_bng[num] = bs\n #puts A2_bng\n elsif bs == A3[num] then\n A3_bng[num] = bs\n \t#puts A2_bng\n end\n \tend\nend\n#puts A1_bng\n#puts A2_bng\n#puts A3_bng\n\n# A1[0]\nif A1_bng[0]!='D' && A1_bng[1]!='D' && A1_bng[2]!='D' then\n puts 'Yes'\nelsif A1_bng[0]!='D' && A2_bng[0]!='D' && A3_bng[0]!='D' then\n puts 'Yes'\nelsif A1_bng[0]!='D' && A2_bng[1]!='D' && A3_bng[2]!='D' then\n puts 'Yes'\n\n# A1[2]\nelsif A1_bng[2]!='D' && A2_bng[1]!='D' && A3_bng[0]!='D' then\n puts 'Yes'\nelsif A1_bng[2]!='D' && A2_bng[2]!='D' && A3_bng[2]!='D' then\n puts 'Yes'\n\n# A3[2]\nelsif A3_bng[0]!='D' && A3_bng[1]!='D' && A3_bng[2]!='D' then\n puts 'Yes'\n\n# 縦線中央\nelsif A1_bng[1]!='D' && A2_bng[1]!='D' && A3_bng[1]!='D' then\n puts 'Yes'\n\n# 横線中央\nelsif A2_bng[0]!='D' && A2_bng[1]!='D' && A2_bng[2]!='D' then\n puts 'Yes' \n\nelse \n puts 'No'\nend", "language": "Ruby", "metadata": {"date": 1583118814, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02760.html", "problem_id": "p02760", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02760/input.txt", "sample_output_relpath": "derived/input_output/data/p02760/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02760/Ruby/s634468343.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s634468343", "user_id": "u915092081"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "A1 = gets.chop.split.map(&:to_i)\nA2 = gets.chop.split.map(&:to_i)\nA3 = gets.chop.split.map(&:to_i)\nN = gets.to_i\nb = []\nN.times { b << gets.to_i }\nA1_bng= ['D','D','D']\nA2_bng= ['D','D','D']\nA3_bng= ['D','D','D']\n\nfor n in 0..N-1 do\n\tbs = b[n]\n \t#puts bs\n for num in 0..2 do\n if bs == A1[num] then\n A1_bng[num] = bs\n #puts A1_bng\n elsif bs == A2[num] then\n A2_bng[num] = bs\n #puts A2_bng\n elsif bs == A3[num] then\n A3_bng[num] = bs\n \t#puts A2_bng\n end\n \tend\nend\n#puts A1_bng\n#puts A2_bng\n#puts A3_bng\n\n# A1[0]\nif A1_bng[0]!='D' && A1_bng[1]!='D' && A1_bng[2]!='D' then\n puts 'Yes'\nelsif A1_bng[0]!='D' && A2_bng[0]!='D' && A3_bng[0]!='D' then\n puts 'Yes'\nelsif A1_bng[0]!='D' && A2_bng[1]!='D' && A3_bng[2]!='D' then\n puts 'Yes'\n\n# A1[2]\nelsif A1_bng[2]!='D' && A2_bng[1]!='D' && A3_bng[0]!='D' then\n puts 'Yes'\nelsif A1_bng[2]!='D' && A2_bng[2]!='D' && A3_bng[2]!='D' then\n puts 'Yes'\n\n# A3[2]\nelsif A3_bng[0]!='D' && A3_bng[1]!='D' && A3_bng[2]!='D' then\n puts 'Yes'\n\n# 縦線中央\nelsif A1_bng[1]!='D' && A2_bng[1]!='D' && A3_bng[1]!='D' then\n puts 'Yes'\n\n# 横線中央\nelsif A2_bng[0]!='D' && A2_bng[1]!='D' && A2_bng[2]!='D' then\n puts 'Yes' \n\nelse \n puts 'No'\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "sample_input": "84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02760", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1266, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s558567871", "group_id": "codeNet:p02760", "input_text": "sheet = []\n3.times do |i|\n sheet << gets.split.map(&:to_i)\nend\nN = gets.to_i\n#=begin\nN.times do |n|\n num = gets.to_i\n 3.times do |i|\n pos = sheet[i].index(num)\n unless pos.nil?\n sheet[i][pos] = \"*\"\n end\n end\nend\n\n# 縦\nbingo = false\n3.times do |pos|\n if (sheet[pos][0] == \"*\") && (sheet[pos][1] == \"*\") && (sheet[pos][2] == \"*\")\n puts \"Yes\"\n exit\n end\n if (sheet[0][pos] == \"*\") && (sheet[1][pos] == \"*\") && (sheet[2][pos] == \"*\")\n puts \"Yes\"\n exit\n end\nend\n\nif (sheet[0][0] == \"*\") && (sheet[1][1] == \"*\") && (sheet[2][2] == \"*\")\n puts \"Yes\"\n exit\nend\nif (sheet[0][2] == \"*\") && (sheet[1][1] == \"*\") && (sheet[2][0] == \"*\")\n puts \"Yes\"\n exit\nend\n\nputs \"No\"\n#=end", "language": "Ruby", "metadata": {"date": 1583116270, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02760.html", "problem_id": "p02760", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02760/input.txt", "sample_output_relpath": "derived/input_output/data/p02760/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02760/Ruby/s558567871.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s558567871", "user_id": "u645787471"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "sheet = []\n3.times do |i|\n sheet << gets.split.map(&:to_i)\nend\nN = gets.to_i\n#=begin\nN.times do |n|\n num = gets.to_i\n 3.times do |i|\n pos = sheet[i].index(num)\n unless pos.nil?\n sheet[i][pos] = \"*\"\n end\n end\nend\n\n# 縦\nbingo = false\n3.times do |pos|\n if (sheet[pos][0] == \"*\") && (sheet[pos][1] == \"*\") && (sheet[pos][2] == \"*\")\n puts \"Yes\"\n exit\n end\n if (sheet[0][pos] == \"*\") && (sheet[1][pos] == \"*\") && (sheet[2][pos] == \"*\")\n puts \"Yes\"\n exit\n end\nend\n\nif (sheet[0][0] == \"*\") && (sheet[1][1] == \"*\") && (sheet[2][2] == \"*\")\n puts \"Yes\"\n exit\nend\nif (sheet[0][2] == \"*\") && (sheet[1][1] == \"*\") && (sheet[2][0] == \"*\")\n puts \"Yes\"\n exit\nend\n\nputs \"No\"\n#=end", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "sample_input": "84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02760", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 701, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s997301644", "group_id": "codeNet:p02760", "input_text": "a=[]\n3.times do |i|\n a[i]=gets.split.map(&:to_i)\nend\nn=gets.to_i\nn.times do\n b=gets.to_i\n 3.times do |i|\n 3.times do |j|\n if a[i][j]==b\n a[i][j]=0\n end\n end\n end\nend\n3.times do |i|\n if a[i][0]==0&&a[i][1]==0&&a[i][2]==0\n puts \"Yes\"\n exit\n end\nend\n3.times do |i|\n if a[0][i]==0&&a[1][i]==0&&a[2][i]==0\n puts \"Yes\"\n exit\n end\nend\nif a[0][0]==0&&a[1][1]==0&&a[2][2]==0\n puts \"Yes\"\n exit\nend\nif a[0][2]==0&&a[1][1]==0&&a[2][0]==0\n puts \"Yes\"\n exit\nend\nputs \"No\"\n\n", "language": "Ruby", "metadata": {"date": 1583114963, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02760.html", "problem_id": "p02760", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02760/input.txt", "sample_output_relpath": "derived/input_output/data/p02760/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02760/Ruby/s997301644.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s997301644", "user_id": "u744908753"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a=[]\n3.times do |i|\n a[i]=gets.split.map(&:to_i)\nend\nn=gets.to_i\nn.times do\n b=gets.to_i\n 3.times do |i|\n 3.times do |j|\n if a[i][j]==b\n a[i][j]=0\n end\n end\n end\nend\n3.times do |i|\n if a[i][0]==0&&a[i][1]==0&&a[i][2]==0\n puts \"Yes\"\n exit\n end\nend\n3.times do |i|\n if a[0][i]==0&&a[1][i]==0&&a[2][i]==0\n puts \"Yes\"\n exit\n end\nend\nif a[0][0]==0&&a[1][1]==0&&a[2][2]==0\n puts \"Yes\"\n exit\nend\nif a[0][2]==0&&a[1][1]==0&&a[2][0]==0\n puts \"Yes\"\n exit\nend\nputs \"No\"\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "sample_input": "84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02760", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 506, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s468301156", "group_id": "codeNet:p02763", "input_text": "N = gets.to_i\nS = gets.chomp\nQ = gets.to_i\nQuery = []\n\nQ.times {\n Query << gets.chomp.split(\" \")\n}\n\ns = Hash.new{|h, k| h[k] = []}\n(0...N).each {|i|\n s[S[i]] << (i + 1)\n}\n\nQuery.each {|f, a, b|\n if f == \"1\"\n a_i = a.to_i\n if S[a_i - 1] != b the\n idx = s[S[a_i - 1]].bsearch_index{|x| x >= a_i}\n s[S[a_i - 1]].delete_at(idx)\n S[a_i - 1] = b\n idx = s[b].bsearch_index{|x| x >= a_i}\n idx.nil? ? s[b] << a_i : s[b].insert(idx, a_i)\n end\n else\n l = a.to_i\n r = b.to_i\n ans = 0\n (0..25).each {|i|\n sl = s[(97 + i).chr].bsearch{|x| x >= l}\n ans += 1 if(not sl.nil?) && sl <= r\n }\n puts ans\n end\n}", "language": "Ruby", "metadata": {"date": 1584041952, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02763.html", "problem_id": "p02763", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02763/input.txt", "sample_output_relpath": "derived/input_output/data/p02763/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02763/Ruby/s468301156.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s468301156", "user_id": "u729911058"}, "prompt_components": {"gold_output": "3\n1\n5\n", "input_to_evaluate": "N = gets.to_i\nS = gets.chomp\nQ = gets.to_i\nQuery = []\n\nQ.times {\n Query << gets.chomp.split(\" \")\n}\n\ns = Hash.new{|h, k| h[k] = []}\n(0...N).each {|i|\n s[S[i]] << (i + 1)\n}\n\nQuery.each {|f, a, b|\n if f == \"1\"\n a_i = a.to_i\n if S[a_i - 1] != b the\n idx = s[S[a_i - 1]].bsearch_index{|x| x >= a_i}\n s[S[a_i - 1]].delete_at(idx)\n S[a_i - 1] = b\n idx = s[b].bsearch_index{|x| x >= a_i}\n idx.nil? ? s[b] << a_i : s[b].insert(idx, a_i)\n end\n else\n l = a.to_i\n r = b.to_i\n ans = 0\n (0..25).each {|i|\n sl = s[(97 + i).chr].bsearch{|x| x >= l}\n ans += 1 if(not sl.nil?) && sl <= r\n }\n puts ans\n end\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\n\nProcess Q queries of the following two types:\n\nType 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.)\n\nType 2: answer the number of different characters occurring in the substring of S between the l_q-th and r_q-th characters (inclusive).\n\nConstraints\n\nN, Q, i_q, l_q, and r_q are integers.\n\nS is a string consisting of lowercase English letters.\n\nc_q is a lowercase English letter.\n\n1 \\leq N \\leq 500000\n\n1 \\leq Q \\leq 20000\n\n|S| = N\n\n1 \\leq i_q \\leq N\n\n1 \\leq l_q \\leq r_q \\leq N\n\nThere is at least one query of type 2 in each testcase.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nQuery_1\n\\vdots\nQuery_Q\n\nHere, Query_i in the 4-th through (Q+3)-th lines is one of the following:\n\n1 i_q c_q\n\n2 l_q r_q\n\nOutput\n\nFor each query of type 2, print a line containing the answer.\n\nSample Input 1\n\n7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n\nSample Output 1\n\n3\n1\n5\n\nIn the first query, cdbb contains three kinds of letters: b , c , and d, so we print 3.\n\nIn the second query, S is modified to abcdzbd.\n\nIn the third query, a contains one kind of letter: a, so we print 1.\n\nIn the fourth query, S is modified to abcazbd.\n\nIn the fifth query, S does not change and is still abcazbd.\n\nIn the sixth query, abcazbd contains five kinds of letters: a, b, c, d, and z, so we print 5.", "sample_input": "7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n"}, "reference_outputs": ["3\n1\n5\n"], "source_document_id": "p02763", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\n\nProcess Q queries of the following two types:\n\nType 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.)\n\nType 2: answer the number of different characters occurring in the substring of S between the l_q-th and r_q-th characters (inclusive).\n\nConstraints\n\nN, Q, i_q, l_q, and r_q are integers.\n\nS is a string consisting of lowercase English letters.\n\nc_q is a lowercase English letter.\n\n1 \\leq N \\leq 500000\n\n1 \\leq Q \\leq 20000\n\n|S| = N\n\n1 \\leq i_q \\leq N\n\n1 \\leq l_q \\leq r_q \\leq N\n\nThere is at least one query of type 2 in each testcase.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nQuery_1\n\\vdots\nQuery_Q\n\nHere, Query_i in the 4-th through (Q+3)-th lines is one of the following:\n\n1 i_q c_q\n\n2 l_q r_q\n\nOutput\n\nFor each query of type 2, print a line containing the answer.\n\nSample Input 1\n\n7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n\nSample Output 1\n\n3\n1\n5\n\nIn the first query, cdbb contains three kinds of letters: b , c , and d, so we print 3.\n\nIn the second query, S is modified to abcdzbd.\n\nIn the third query, a contains one kind of letter: a, so we print 1.\n\nIn the fourth query, S is modified to abcazbd.\n\nIn the fifth query, S does not change and is still abcazbd.\n\nIn the sixth query, abcazbd contains five kinds of letters: a, b, c, d, and z, so we print 5.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 744, "cpu_time_ms": 7, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s135942966", "group_id": "codeNet:p02763", "input_text": "def get_i() #空白区切の入力を数値(整数)の配列で返す\n return gets.chomp.split(\" \").map(&:to_i)\nend\ndef get_f() #空白区切の入力を数値(実数)の配列で返す\n return gets.chomp.split(\" \").map(&:to_f)\nend\ndef get() #空白区切の入力を文字列の配列で返す\n return gets.chomp.split(\" \")\nend\ndef get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す\n return gets.chomp.split(\"\")\nend\ndef yn_judge(bool,y=\"Yes\",n=\"No\") #boolに真偽を投げることで、trueならy、falseならnの値を出力する\n return bool ? y : n \nend\ndef array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す\n if n==1\n return Array.new(size){init}\n else\n return Array.new(n).map{Array.new(size){init}}\n end\nend\n\nclass SegTree\n attr_accessor:node,:n\n def initialize(n)\n @n=1\n @n*=2 while @n0\n i=(i-1)/2\n @node[i]=@node[i*2+1]+@node[i*2+2]\n end\n end\n\n def getSum(s,t,i,l,r)\n return 0 if r<=s or t<=l\n return @node[i] if s<=l and r<=t\n mid=(l+r)/2\n leaf_l=getSum(s,t,i*2+1,l,mid)\n leaf_r=getSum(s,t,i*2+2,mid,r)\n return leaf_l+leaf_r\n end\nend\n$exchange={}\n(\"a\"..\"z\").to_a.each_with_index do|c,i|\n $exchange[c]=i\nend\nn=gets.to_i\ns=get_nsp\nq=gets.to_i\nst=array(26,1)\n26.times do|i|\n st[i]=SegTree.new(n)\nend\nn.times do|i|\n st[$exchange[s[i]]].update(i,1)\nend\nq.times do\n que=get\n if que[0].to_i==1\n next if s[que[1].to_i-1]==que[2]\n st[$exchange[s[que[1].to_i-1]]].update(que[1].to_i-1,0)\n st[$exchange[que[2]]].update(que[1].to_i-1,1)\n else\n ans=0\n 26.times do|i|\n val=st[i].getSum(que[1].to_i-1,que[2].to_i,0,0,st[i].n)\n ans+=1 if val.nonzero?\n end\n puts ans\n end\nend", "language": "Ruby", "metadata": {"date": 1583160605, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02763.html", "problem_id": "p02763", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02763/input.txt", "sample_output_relpath": "derived/input_output/data/p02763/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02763/Ruby/s135942966.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s135942966", "user_id": "u415400221"}, "prompt_components": {"gold_output": "3\n1\n5\n", "input_to_evaluate": "def get_i() #空白区切の入力を数値(整数)の配列で返す\n return gets.chomp.split(\" \").map(&:to_i)\nend\ndef get_f() #空白区切の入力を数値(実数)の配列で返す\n return gets.chomp.split(\" \").map(&:to_f)\nend\ndef get() #空白区切の入力を文字列の配列で返す\n return gets.chomp.split(\" \")\nend\ndef get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す\n return gets.chomp.split(\"\")\nend\ndef yn_judge(bool,y=\"Yes\",n=\"No\") #boolに真偽を投げることで、trueならy、falseならnの値を出力する\n return bool ? y : n \nend\ndef array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す\n if n==1\n return Array.new(size){init}\n else\n return Array.new(n).map{Array.new(size){init}}\n end\nend\n\nclass SegTree\n attr_accessor:node,:n\n def initialize(n)\n @n=1\n @n*=2 while @n0\n i=(i-1)/2\n @node[i]=@node[i*2+1]+@node[i*2+2]\n end\n end\n\n def getSum(s,t,i,l,r)\n return 0 if r<=s or t<=l\n return @node[i] if s<=l and r<=t\n mid=(l+r)/2\n leaf_l=getSum(s,t,i*2+1,l,mid)\n leaf_r=getSum(s,t,i*2+2,mid,r)\n return leaf_l+leaf_r\n end\nend\n$exchange={}\n(\"a\"..\"z\").to_a.each_with_index do|c,i|\n $exchange[c]=i\nend\nn=gets.to_i\ns=get_nsp\nq=gets.to_i\nst=array(26,1)\n26.times do|i|\n st[i]=SegTree.new(n)\nend\nn.times do|i|\n st[$exchange[s[i]]].update(i,1)\nend\nq.times do\n que=get\n if que[0].to_i==1\n next if s[que[1].to_i-1]==que[2]\n st[$exchange[s[que[1].to_i-1]]].update(que[1].to_i-1,0)\n st[$exchange[que[2]]].update(que[1].to_i-1,1)\n else\n ans=0\n 26.times do|i|\n val=st[i].getSum(que[1].to_i-1,que[2].to_i,0,0,st[i].n)\n ans+=1 if val.nonzero?\n end\n puts ans\n end\nend", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\n\nProcess Q queries of the following two types:\n\nType 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.)\n\nType 2: answer the number of different characters occurring in the substring of S between the l_q-th and r_q-th characters (inclusive).\n\nConstraints\n\nN, Q, i_q, l_q, and r_q are integers.\n\nS is a string consisting of lowercase English letters.\n\nc_q is a lowercase English letter.\n\n1 \\leq N \\leq 500000\n\n1 \\leq Q \\leq 20000\n\n|S| = N\n\n1 \\leq i_q \\leq N\n\n1 \\leq l_q \\leq r_q \\leq N\n\nThere is at least one query of type 2 in each testcase.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nQuery_1\n\\vdots\nQuery_Q\n\nHere, Query_i in the 4-th through (Q+3)-th lines is one of the following:\n\n1 i_q c_q\n\n2 l_q r_q\n\nOutput\n\nFor each query of type 2, print a line containing the answer.\n\nSample Input 1\n\n7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n\nSample Output 1\n\n3\n1\n5\n\nIn the first query, cdbb contains three kinds of letters: b , c , and d, so we print 3.\n\nIn the second query, S is modified to abcdzbd.\n\nIn the third query, a contains one kind of letter: a, so we print 1.\n\nIn the fourth query, S is modified to abcazbd.\n\nIn the fifth query, S does not change and is still abcazbd.\n\nIn the sixth query, abcazbd contains five kinds of letters: a, b, c, d, and z, so we print 5.", "sample_input": "7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n"}, "reference_outputs": ["3\n1\n5\n"], "source_document_id": "p02763", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\n\nProcess Q queries of the following two types:\n\nType 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.)\n\nType 2: answer the number of different characters occurring in the substring of S between the l_q-th and r_q-th characters (inclusive).\n\nConstraints\n\nN, Q, i_q, l_q, and r_q are integers.\n\nS is a string consisting of lowercase English letters.\n\nc_q is a lowercase English letter.\n\n1 \\leq N \\leq 500000\n\n1 \\leq Q \\leq 20000\n\n|S| = N\n\n1 \\leq i_q \\leq N\n\n1 \\leq l_q \\leq r_q \\leq N\n\nThere is at least one query of type 2 in each testcase.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nQuery_1\n\\vdots\nQuery_Q\n\nHere, Query_i in the 4-th through (Q+3)-th lines is one of the following:\n\n1 i_q c_q\n\n2 l_q r_q\n\nOutput\n\nFor each query of type 2, print a line containing the answer.\n\nSample Input 1\n\n7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n\nSample Output 1\n\n3\n1\n5\n\nIn the first query, cdbb contains three kinds of letters: b , c , and d, so we print 3.\n\nIn the second query, S is modified to abcdzbd.\n\nIn the third query, a contains one kind of letter: a, so we print 1.\n\nIn the fourth query, S is modified to abcazbd.\n\nIn the fifth query, S does not change and is still abcazbd.\n\nIn the sixth query, abcazbd contains five kinds of letters: a, b, c, d, and z, so we print 5.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1891, "cpu_time_ms": 2113, "memory_kb": 243120}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s426901621", "group_id": "codeNet:p02763", "input_text": "def get_i() #空白区切の入力を数値(整数)の配列で返す\n return gets.chomp.split(\" \").map(&:to_i)\nend\ndef get_f() #空白区切の入力を数値(実数)の配列で返す\n return gets.chomp.split(\" \").map(&:to_f)\nend\ndef get() #空白区切の入力を文字列の配列で返す\n return gets.chomp.split(\" \")\nend\ndef get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す\n return gets.chomp.split(\"\")\nend\ndef yn_judge(bool,y=\"Yes\",n=\"No\") #boolに真偽を投げることで、trueならy、falseならnの値を出力する\n return bool ? y : n \nend\ndef array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す\n if n==1\n return Array.new(size){init}\n else\n return Array.new(n).map{Array.new(size){init}}\n end\nend\n\nclass BIT\n attr_accessor:node,:n\n def initialize(n)\n @n=n\n @node=array(@n+1,1,0)\n end\n\n def update(i,x)\n while i<=@n\n @node[i]+=x\n i+=i&-i\n end\n end\n\n def sum(i)\n s=0\n while i>0\n s+=@node[i]\n i-=i&-i\n end\n return s\n end\n def getSum(s,t)\n return sum(t)-sum(s)\n end\nend\n$exchange={}\n(\"a\"..\"z\").to_a.each_with_index do|c,i|\n $exchange[c]=i\nend\nn=gets.to_i\ns=get_nsp\nq=gets.to_i\nbit=array(26,1)\n26.times do|i|\n bit[i]=BIT.new(n)\nend\nn.times do|i|\n bit[$exchange[s[i]]].update(i+1,1)\nend\nq.times do\n que=get\n if que[0].to_i==1\n next if s[que[1].to_i-1]==que[2]\n bit[$exchange[s[que[1].to_i-1]]].update(que[1].to_i,-1)\n bit[$exchange[que[2]]].update(que[1].to_i,1)\n else\n ans=0\n 26.times do|i|\n val=bit[i].getSum(que[1].to_i-1,que[2].to_i)\n ans+=1 if val.nonzero?\n end\n puts ans\n end\nend", "language": "Ruby", "metadata": {"date": 1583160164, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02763.html", "problem_id": "p02763", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02763/input.txt", "sample_output_relpath": "derived/input_output/data/p02763/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02763/Ruby/s426901621.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s426901621", "user_id": "u415400221"}, "prompt_components": {"gold_output": "3\n1\n5\n", "input_to_evaluate": "def get_i() #空白区切の入力を数値(整数)の配列で返す\n return gets.chomp.split(\" \").map(&:to_i)\nend\ndef get_f() #空白区切の入力を数値(実数)の配列で返す\n return gets.chomp.split(\" \").map(&:to_f)\nend\ndef get() #空白区切の入力を文字列の配列で返す\n return gets.chomp.split(\" \")\nend\ndef get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す\n return gets.chomp.split(\"\")\nend\ndef yn_judge(bool,y=\"Yes\",n=\"No\") #boolに真偽を投げることで、trueならy、falseならnの値を出力する\n return bool ? y : n \nend\ndef array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す\n if n==1\n return Array.new(size){init}\n else\n return Array.new(n).map{Array.new(size){init}}\n end\nend\n\nclass BIT\n attr_accessor:node,:n\n def initialize(n)\n @n=n\n @node=array(@n+1,1,0)\n end\n\n def update(i,x)\n while i<=@n\n @node[i]+=x\n i+=i&-i\n end\n end\n\n def sum(i)\n s=0\n while i>0\n s+=@node[i]\n i-=i&-i\n end\n return s\n end\n def getSum(s,t)\n return sum(t)-sum(s)\n end\nend\n$exchange={}\n(\"a\"..\"z\").to_a.each_with_index do|c,i|\n $exchange[c]=i\nend\nn=gets.to_i\ns=get_nsp\nq=gets.to_i\nbit=array(26,1)\n26.times do|i|\n bit[i]=BIT.new(n)\nend\nn.times do|i|\n bit[$exchange[s[i]]].update(i+1,1)\nend\nq.times do\n que=get\n if que[0].to_i==1\n next if s[que[1].to_i-1]==que[2]\n bit[$exchange[s[que[1].to_i-1]]].update(que[1].to_i,-1)\n bit[$exchange[que[2]]].update(que[1].to_i,1)\n else\n ans=0\n 26.times do|i|\n val=bit[i].getSum(que[1].to_i-1,que[2].to_i)\n ans+=1 if val.nonzero?\n end\n puts ans\n end\nend", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\n\nProcess Q queries of the following two types:\n\nType 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.)\n\nType 2: answer the number of different characters occurring in the substring of S between the l_q-th and r_q-th characters (inclusive).\n\nConstraints\n\nN, Q, i_q, l_q, and r_q are integers.\n\nS is a string consisting of lowercase English letters.\n\nc_q is a lowercase English letter.\n\n1 \\leq N \\leq 500000\n\n1 \\leq Q \\leq 20000\n\n|S| = N\n\n1 \\leq i_q \\leq N\n\n1 \\leq l_q \\leq r_q \\leq N\n\nThere is at least one query of type 2 in each testcase.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nQuery_1\n\\vdots\nQuery_Q\n\nHere, Query_i in the 4-th through (Q+3)-th lines is one of the following:\n\n1 i_q c_q\n\n2 l_q r_q\n\nOutput\n\nFor each query of type 2, print a line containing the answer.\n\nSample Input 1\n\n7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n\nSample Output 1\n\n3\n1\n5\n\nIn the first query, cdbb contains three kinds of letters: b , c , and d, so we print 3.\n\nIn the second query, S is modified to abcdzbd.\n\nIn the third query, a contains one kind of letter: a, so we print 1.\n\nIn the fourth query, S is modified to abcazbd.\n\nIn the fifth query, S does not change and is still abcazbd.\n\nIn the sixth query, abcazbd contains five kinds of letters: a, b, c, d, and z, so we print 5.", "sample_input": "7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n"}, "reference_outputs": ["3\n1\n5\n"], "source_document_id": "p02763", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\n\nProcess Q queries of the following two types:\n\nType 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.)\n\nType 2: answer the number of different characters occurring in the substring of S between the l_q-th and r_q-th characters (inclusive).\n\nConstraints\n\nN, Q, i_q, l_q, and r_q are integers.\n\nS is a string consisting of lowercase English letters.\n\nc_q is a lowercase English letter.\n\n1 \\leq N \\leq 500000\n\n1 \\leq Q \\leq 20000\n\n|S| = N\n\n1 \\leq i_q \\leq N\n\n1 \\leq l_q \\leq r_q \\leq N\n\nThere is at least one query of type 2 in each testcase.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nQuery_1\n\\vdots\nQuery_Q\n\nHere, Query_i in the 4-th through (Q+3)-th lines is one of the following:\n\n1 i_q c_q\n\n2 l_q r_q\n\nOutput\n\nFor each query of type 2, print a line containing the answer.\n\nSample Input 1\n\n7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n\nSample Output 1\n\n3\n1\n5\n\nIn the first query, cdbb contains three kinds of letters: b , c , and d, so we print 3.\n\nIn the second query, S is modified to abcdzbd.\n\nIn the third query, a contains one kind of letter: a, so we print 1.\n\nIn the fourth query, S is modified to abcazbd.\n\nIn the fifth query, S does not change and is still abcazbd.\n\nIn the sixth query, abcazbd contains five kinds of letters: a, b, c, d, and z, so we print 5.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1739, "cpu_time_ms": 2113, "memory_kb": 138800}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s753298066", "group_id": "codeNet:p02765", "input_text": "line = gets.split(' ').map(&:to_i)\n\nN = line[0]\nR = line[1]\n\nif N < 10 then\n print R + 100 * (10 - K)\nelse\n print R\nend", "language": "Ruby", "metadata": {"date": 1590007241, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s753298066.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s753298066", "user_id": "u569559028"}, "prompt_components": {"gold_output": "3719\n", "input_to_evaluate": "line = gets.split(' ').map(&:to_i)\n\nN = line[0]\nR = line[1]\n\nif N < 10 then\n print R + 100 * (10 - K)\nelse\n print R\nend", "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": 121, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s077588315", "group_id": "codeNet:p02765", "input_text": "n, r = gets.chomp.split.map(&:to_i)\nif n >= 10\n puts r \nelse\n puts r + (100 * (10 - n ))\nend", "language": "Ruby", "metadata": {"date": 1582424031, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s077588315.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s077588315", "user_id": "u585539930"}, "prompt_components": {"gold_output": "3719\n", "input_to_evaluate": "n, r = gets.chomp.split.map(&:to_i)\nif n >= 10\n puts r \nelse\n puts r + (100 * (10 - n ))\nend", "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": 94, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s381631006", "group_id": "codeNet:p02766", "input_text": "N, K = gets.chomp.split(\" \").map(&:to_i)\nputs N.to_s(K).size\n", "language": "Ruby", "metadata": {"date": 1582423421, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s381631006.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s381631006", "user_id": "u443924743"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "N, K = gets.chomp.split(\" \").map(&:to_i)\nputs N.to_s(K).size\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": 61, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s473540870", "group_id": "codeNet:p02767", "input_text": "N = gets.to_i\nXs = gets.split.map(&:to_i)\n\na = Xs.inject(0) {|result, item|\n result + item**2\n }\nb = Xs.inject(&:+)\n\nc = (b.to_f / N)\n\np [c.floor, c.ceil].map{|n| N*(n**2) - 2*b*n + a}.min\n", "language": "Ruby", "metadata": {"date": 1582425134, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02767.html", "problem_id": "p02767", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02767/input.txt", "sample_output_relpath": "derived/input_output/data/p02767/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02767/Ruby/s473540870.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s473540870", "user_id": "u716826907"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "N = gets.to_i\nXs = gets.split.map(&:to_i)\n\na = Xs.inject(0) {|result, item|\n result + item**2\n }\nb = Xs.inject(&:+)\n\nc = (b.to_f / N)\n\np [c.floor, c.ceil].map{|n| N*(n**2) - 2*b*n + a}.min\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people living on a number line.\n\nThe i-th person lives at coordinate X_i.\n\nYou are going to hold a meeting that all N people have to attend.\n\nThe meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.\n\nFind the minimum total points of stamina the N people have to spend.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq X_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint the minimum total stamina the N people have to spend.\n\nSample Input 1\n\n2\n1 4\n\nSample Output 1\n\n5\n\nAssume the meeting is held at coordinate 2. In this case, the first person will spend (1 - 2)^2 points of stamina, and the second person will spend (4 - 2)^2 = 4 points of stamina, for a total of 5 points of stamina. This is the minimum total stamina that the 2 people have to spend.\n\nNote that you can hold the meeting only at an integer coordinate.\n\nSample Input 2\n\n7\n14 14 2 13 56 2 37\n\nSample Output 2\n\n2354", "sample_input": "2\n1 4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02767", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people living on a number line.\n\nThe i-th person lives at coordinate X_i.\n\nYou are going to hold a meeting that all N people have to attend.\n\nThe meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.\n\nFind the minimum total points of stamina the N people have to spend.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq X_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint the minimum total stamina the N people have to spend.\n\nSample Input 1\n\n2\n1 4\n\nSample Output 1\n\n5\n\nAssume the meeting is held at coordinate 2. In this case, the first person will spend (1 - 2)^2 points of stamina, and the second person will spend (4 - 2)^2 = 4 points of stamina, for a total of 5 points of stamina. This is the minimum total stamina that the 2 people have to spend.\n\nNote that you can hold the meeting only at an integer coordinate.\n\nSample Input 2\n\n7\n14 14 2 13 56 2 37\n\nSample Output 2\n\n2354", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 193, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s762102227", "group_id": "codeNet:p02767", "input_text": "n = gets.to_i\nx = gets.split.map &:to_i\n\nans = 1_000_000_000\n1.upto(100) do |i|\n sum = 0\n x.map do |x|\n sum += (x - i) ** 2\n end\n ans = sum if sum < ans\nend\n\nputs ans\n", "language": "Ruby", "metadata": {"date": 1582424064, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02767.html", "problem_id": "p02767", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02767/input.txt", "sample_output_relpath": "derived/input_output/data/p02767/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02767/Ruby/s762102227.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s762102227", "user_id": "u106964380"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "n = gets.to_i\nx = gets.split.map &:to_i\n\nans = 1_000_000_000\n1.upto(100) do |i|\n sum = 0\n x.map do |x|\n sum += (x - i) ** 2\n end\n ans = sum if sum < ans\nend\n\nputs ans\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people living on a number line.\n\nThe i-th person lives at coordinate X_i.\n\nYou are going to hold a meeting that all N people have to attend.\n\nThe meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.\n\nFind the minimum total points of stamina the N people have to spend.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq X_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint the minimum total stamina the N people have to spend.\n\nSample Input 1\n\n2\n1 4\n\nSample Output 1\n\n5\n\nAssume the meeting is held at coordinate 2. In this case, the first person will spend (1 - 2)^2 points of stamina, and the second person will spend (4 - 2)^2 = 4 points of stamina, for a total of 5 points of stamina. This is the minimum total stamina that the 2 people have to spend.\n\nNote that you can hold the meeting only at an integer coordinate.\n\nSample Input 2\n\n7\n14 14 2 13 56 2 37\n\nSample Output 2\n\n2354", "sample_input": "2\n1 4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02767", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people living on a number line.\n\nThe i-th person lives at coordinate X_i.\n\nYou are going to hold a meeting that all N people have to attend.\n\nThe meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.\n\nFind the minimum total points of stamina the N people have to spend.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq X_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint the minimum total stamina the N people have to spend.\n\nSample Input 1\n\n2\n1 4\n\nSample Output 1\n\n5\n\nAssume the meeting is held at coordinate 2. In this case, the first person will spend (1 - 2)^2 points of stamina, and the second person will spend (4 - 2)^2 = 4 points of stamina, for a total of 5 points of stamina. This is the minimum total stamina that the 2 people have to spend.\n\nNote that you can hold the meeting only at an integer coordinate.\n\nSample Input 2\n\n7\n14 14 2 13 56 2 37\n\nSample Output 2\n\n2354", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 174, "cpu_time_ms": 8, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s461242511", "group_id": "codeNet:p02768", "input_text": "MOD = 1000000007\n\ndef conv(a,b)\n if b > a/2\n b = a - b\n end\n ans = 1\n div = 1\n b.times do |i|\n ans *= a - i\n ans %= MOD\n div *= (i+1)\n div %= MOD\n end\n ans = ans * pow(div, MOD-2)\n ans % MOD\nend\n\ndef pow(x,n)\n if n == 0\n 1\n elsif n % 2 == 0\n pow(x*x%MOD, n/2) % MOD\n else\n x * pow(x, n-1) % MOD\n end\nend\n\nn,a,b=gets.chomp.split(\" \").map(&:to_i)\n\nall = (pow(2,n) - 1) % MOD\nif a > n/2\n a = n - a\nend\nif b > n/2\n b = n - b\nend\n\nall = all - conv(n,a) - conv(n,b)\nall %= MOD\n\nputs all", "language": "Ruby", "metadata": {"date": 1583111754, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02768.html", "problem_id": "p02768", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02768/input.txt", "sample_output_relpath": "derived/input_output/data/p02768/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02768/Ruby/s461242511.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s461242511", "user_id": "u265679940"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "MOD = 1000000007\n\ndef conv(a,b)\n if b > a/2\n b = a - b\n end\n ans = 1\n div = 1\n b.times do |i|\n ans *= a - i\n ans %= MOD\n div *= (i+1)\n div %= MOD\n end\n ans = ans * pow(div, MOD-2)\n ans % MOD\nend\n\ndef pow(x,n)\n if n == 0\n 1\n elsif n % 2 == 0\n pow(x*x%MOD, n/2) % MOD\n else\n x * pow(x, n-1) % MOD\n end\nend\n\nn,a,b=gets.chomp.split(\" \").map(&:to_i)\n\nall = (pow(2,n) - 1) % MOD\nif a > n/2\n a = n - a\nend\nif b > n/2\n b = n - b\nend\n\nall = all - conv(n,a) - conv(n,b)\nall %= MOD\n\nputs all", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAkari has n kinds of flowers, one of each kind.\n\nShe is going to choose one or more of these flowers to make a bouquet.\n\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\n\nHow many different bouquets are there that Akari can make?\n\nFind the count modulo (10^9 + 7).\n\nHere, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq n \\leq 10^9\n\n1 \\leq a < b \\leq \\textrm{min}(n, 2 \\times 10^5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn a b\n\nOutput\n\nPrint the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)\n\nSample Input 1\n\n4 1 3\n\nSample Output 1\n\n7\n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.\n\nSample Input 2\n\n1000000000 141421 173205\n\nSample Output 2\n\n34076506\n\nPrint the count modulo (10^9 + 7).", "sample_input": "4 1 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02768", "source_text": "Score : 400 points\n\nProblem Statement\n\nAkari has n kinds of flowers, one of each kind.\n\nShe is going to choose one or more of these flowers to make a bouquet.\n\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\n\nHow many different bouquets are there that Akari can make?\n\nFind the count modulo (10^9 + 7).\n\nHere, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq n \\leq 10^9\n\n1 \\leq a < b \\leq \\textrm{min}(n, 2 \\times 10^5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn a b\n\nOutput\n\nPrint the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)\n\nSample Input 1\n\n4 1 3\n\nSample Output 1\n\n7\n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.\n\nSample Input 2\n\n1000000000 141421 173205\n\nSample Output 2\n\n34076506\n\nPrint the count modulo (10^9 + 7).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 518, "cpu_time_ms": 65, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s692023291", "group_id": "codeNet:p02771", "input_text": "list = gets.chomp.split(\" \")\n\nlist = list.uniq\n\nif list.length == 2\n puts \"Yes\"\nelse\n puts \"No\"\nend", "language": "Ruby", "metadata": {"date": 1588443944, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02771.html", "problem_id": "p02771", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02771/input.txt", "sample_output_relpath": "derived/input_output/data/p02771/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02771/Ruby/s692023291.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s692023291", "user_id": "u644533034"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "list = gets.chomp.split(\" \")\n\nlist = list.uniq\n\nif list.length == 2\n puts \"Yes\"\nelse\n puts \"No\"\nend", "problem_context": "Score: 100 points\n\nProblem Statement\n\nA triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\n\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.\n\nConstraints\n\nA, B, and C are all integers between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the given triple is poor, print Yes; otherwise, print No.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\nYes\n\nA and C are equal, but B is different from those two numbers, so this triple is poor.\n\nSample Input 2\n\n4 4 4\n\nSample Output 2\n\nNo\n\nA, B, and C are all equal, so this triple is not poor.\n\nSample Input 3\n\n4 9 6\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3 3 4\n\nSample Output 4\n\nYes", "sample_input": "5 7 5\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02771", "source_text": "Score: 100 points\n\nProblem Statement\n\nA triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\n\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.\n\nConstraints\n\nA, B, and C are all integers between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the given triple is poor, print Yes; otherwise, print No.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\nYes\n\nA and C are equal, but B is different from those two numbers, so this triple is poor.\n\nSample Input 2\n\n4 4 4\n\nSample Output 2\n\nNo\n\nA, B, and C are all equal, so this triple is not poor.\n\nSample Input 3\n\n4 9 6\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3 3 4\n\nSample Output 4\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 101, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s914943522", "group_id": "codeNet:p02771", "input_text": "a, b, c = gets.split.map(&:to_i)\nif (a==b && b==c) || (a!=b&&b!=c&&a!=c)\n puts 'No'\nelse\n puts 'Yes'\nend", "language": "Ruby", "metadata": {"date": 1583696795, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02771.html", "problem_id": "p02771", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02771/input.txt", "sample_output_relpath": "derived/input_output/data/p02771/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02771/Ruby/s914943522.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s914943522", "user_id": "u413815532"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a, b, c = gets.split.map(&:to_i)\nif (a==b && b==c) || (a!=b&&b!=c&&a!=c)\n puts 'No'\nelse\n puts 'Yes'\nend", "problem_context": "Score: 100 points\n\nProblem Statement\n\nA triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\n\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.\n\nConstraints\n\nA, B, and C are all integers between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the given triple is poor, print Yes; otherwise, print No.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\nYes\n\nA and C are equal, but B is different from those two numbers, so this triple is poor.\n\nSample Input 2\n\n4 4 4\n\nSample Output 2\n\nNo\n\nA, B, and C are all equal, so this triple is not poor.\n\nSample Input 3\n\n4 9 6\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3 3 4\n\nSample Output 4\n\nYes", "sample_input": "5 7 5\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02771", "source_text": "Score: 100 points\n\nProblem Statement\n\nA triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\n\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.\n\nConstraints\n\nA, B, and C are all integers between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the given triple is poor, print Yes; otherwise, print No.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\nYes\n\nA and C are equal, but B is different from those two numbers, so this triple is poor.\n\nSample Input 2\n\n4 4 4\n\nSample Output 2\n\nNo\n\nA, B, and C are all equal, so this triple is not poor.\n\nSample Input 3\n\n4 9 6\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3 3 4\n\nSample Output 4\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 106, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s887879404", "group_id": "codeNet:p02771", "input_text": "S = {}\n(gets.to_i).times do \n key = gets.chomp\n if S.key?(key)\n S[key] += 1 \n else \n S.store(key, 1)\n end\nend\n\nmax = S.values.max\nputs S.keep_if {|_, v| v == max}\nputs S.keys.sort", "language": "Ruby", "metadata": {"date": 1583423792, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02771.html", "problem_id": "p02771", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02771/input.txt", "sample_output_relpath": "derived/input_output/data/p02771/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02771/Ruby/s887879404.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s887879404", "user_id": "u729911058"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "S = {}\n(gets.to_i).times do \n key = gets.chomp\n if S.key?(key)\n S[key] += 1 \n else \n S.store(key, 1)\n end\nend\n\nmax = S.values.max\nputs S.keep_if {|_, v| v == max}\nputs S.keys.sort", "problem_context": "Score: 100 points\n\nProblem Statement\n\nA triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\n\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.\n\nConstraints\n\nA, B, and C are all integers between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the given triple is poor, print Yes; otherwise, print No.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\nYes\n\nA and C are equal, but B is different from those two numbers, so this triple is poor.\n\nSample Input 2\n\n4 4 4\n\nSample Output 2\n\nNo\n\nA, B, and C are all equal, so this triple is not poor.\n\nSample Input 3\n\n4 9 6\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3 3 4\n\nSample Output 4\n\nYes", "sample_input": "5 7 5\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02771", "source_text": "Score: 100 points\n\nProblem Statement\n\nA triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\n\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.\n\nConstraints\n\nA, B, and C are all integers between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the given triple is poor, print Yes; otherwise, print No.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\nYes\n\nA and C are equal, but B is different from those two numbers, so this triple is poor.\n\nSample Input 2\n\n4 4 4\n\nSample Output 2\n\nNo\n\nA, B, and C are all equal, so this triple is not poor.\n\nSample Input 3\n\n4 9 6\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3 3 4\n\nSample Output 4\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 203, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s227639597", "group_id": "codeNet:p02771", "input_text": "N = gets.chomp.split(' ').map(&:to_i)\n\nif N.uniq.size == 2\n puts 'Yes'\nelse\n puts 'No'\nend", "language": "Ruby", "metadata": {"date": 1581883891, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02771.html", "problem_id": "p02771", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02771/input.txt", "sample_output_relpath": "derived/input_output/data/p02771/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02771/Ruby/s227639597.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s227639597", "user_id": "u830913928"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "N = gets.chomp.split(' ').map(&:to_i)\n\nif N.uniq.size == 2\n puts 'Yes'\nelse\n puts 'No'\nend", "problem_context": "Score: 100 points\n\nProblem Statement\n\nA triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\n\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.\n\nConstraints\n\nA, B, and C are all integers between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the given triple is poor, print Yes; otherwise, print No.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\nYes\n\nA and C are equal, but B is different from those two numbers, so this triple is poor.\n\nSample Input 2\n\n4 4 4\n\nSample Output 2\n\nNo\n\nA, B, and C are all equal, so this triple is not poor.\n\nSample Input 3\n\n4 9 6\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3 3 4\n\nSample Output 4\n\nYes", "sample_input": "5 7 5\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02771", "source_text": "Score: 100 points\n\nProblem Statement\n\nA triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\n\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.\n\nConstraints\n\nA, B, and C are all integers between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the given triple is poor, print Yes; otherwise, print No.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\nYes\n\nA and C are equal, but B is different from those two numbers, so this triple is poor.\n\nSample Input 2\n\n4 4 4\n\nSample Output 2\n\nNo\n\nA, B, and C are all equal, so this triple is not poor.\n\nSample Input 3\n\n4 9 6\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3 3 4\n\nSample Output 4\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 92, "cpu_time_ms": 7, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s948119715", "group_id": "codeNet:p02772", "input_text": "N = gets.to_i\nA = gets.split.map(&:to_i).select{|a|a.even?}\nans = A.inject(true) do |q, a|\n q &= (a % 3).zero? || (a % 5).zero?\nend\nif ans\n puts 'APPROVED'\nelse\n puts 'DENIED'\nend", "language": "Ruby", "metadata": {"date": 1591270973, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s948119715.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s948119715", "user_id": "u984479733"}, "prompt_components": {"gold_output": "APPROVED\n", "input_to_evaluate": "N = gets.to_i\nA = gets.split.map(&:to_i).select{|a|a.even?}\nans = A.inject(true) do |q, a|\n q &= (a % 3).zero? || (a % 5).zero?\nend\nif ans\n puts 'APPROVED'\nelse\n puts 'DENIED'\nend", "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": 182, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s702833539", "group_id": "codeNet:p02772", "input_text": "n = gets.to_i\nary = []\nwhile a = gets\n ary.push(a)\nend\n\nflag = \"DENIED\"\n\nary.each do |a|\n a = a.to_i\n if a % 2 == 0\n if a % 3 == 0 or a % 5 == 0\n flag = \"APPROVED\"\n else\n flag = \"DENIED\"\n end\n end\nend\nputs flag", "language": "Ruby", "metadata": {"date": 1588621182, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s702833539.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s702833539", "user_id": "u944733909"}, "prompt_components": {"gold_output": "APPROVED\n", "input_to_evaluate": "n = gets.to_i\nary = []\nwhile a = gets\n ary.push(a)\nend\n\nflag = \"DENIED\"\n\nary.each do |a|\n a = a.to_i\n if a % 2 == 0\n if a % 3 == 0 or a % 5 == 0\n flag = \"APPROVED\"\n else\n flag = \"DENIED\"\n end\n end\nend\nputs flag", "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": 265, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s975460980", "group_id": "codeNet:p02772", "input_text": "n = gets.to_i\na = gets.split(' ').map(&:to_i)\n\nresult = 'APPROVED'\n\na.each do |doc|\n result = 'DENIED' if (doc.even? && (doc%3 != 0 && doc%5 != 0))\nend\n\nputs result\n", "language": "Ruby", "metadata": {"date": 1583782911, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s975460980.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s975460980", "user_id": "u546441021"}, "prompt_components": {"gold_output": "APPROVED\n", "input_to_evaluate": "n = gets.to_i\na = gets.split(' ').map(&:to_i)\n\nresult = 'APPROVED'\n\na.each do |doc|\n result = 'DENIED' if (doc.even? && (doc%3 != 0 && doc%5 != 0))\nend\n\nputs result\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": 166, "cpu_time_ms": 8, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s194742380", "group_id": "codeNet:p02773", "input_text": "N=gets.to_i\nss=$<.read.split\nh={}\nss.each do |s|\n h[s] ||= 0\n h[s] += 1\nend\n\narr = h.sort\nmax = arr[-1][1]\nret = arr.select {|k,v|max == v}.map(&:first).sort\n\nputs ret.join(\"\\n\")\n", "language": "Ruby", "metadata": {"date": 1586808222, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02773.html", "problem_id": "p02773", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02773/input.txt", "sample_output_relpath": "derived/input_output/data/p02773/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02773/Ruby/s194742380.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s194742380", "user_id": "u852974293"}, "prompt_components": {"gold_output": "beet\nvet\n", "input_to_evaluate": "N=gets.to_i\nss=$<.read.split\nh={}\nss.each do |s|\n h[s] ||= 0\n h[s] += 1\nend\n\narr = h.sort\nmax = arr[-1][1]\nret = arr.select {|k,v|max == v}.map(&:first).sort\n\nputs ret.join(\"\\n\")\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "sample_input": "7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n"}, "reference_outputs": ["beet\nvet\n"], "source_document_id": "p02773", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 181, "cpu_time_ms": 1353, "memory_kb": 56040}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s790632908", "group_id": "codeNet:p02773", "input_text": "count = gets.to_i\nstrs = Hash.new(0)\ncount.times do\n strs[gets.chomp] += 1\nend\nstrs = strs.sort_by{ | k, v | v }.reverse\nmax = strs[0][1]\nstrs.each do |str|\n if max == str[1]\n print(str[0] + \"\\r\\n\") \n end\nend", "language": "Ruby", "metadata": {"date": 1582370572, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02773.html", "problem_id": "p02773", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02773/input.txt", "sample_output_relpath": "derived/input_output/data/p02773/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02773/Ruby/s790632908.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s790632908", "user_id": "u463397049"}, "prompt_components": {"gold_output": "beet\nvet\n", "input_to_evaluate": "count = gets.to_i\nstrs = Hash.new(0)\ncount.times do\n strs[gets.chomp] += 1\nend\nstrs = strs.sort_by{ | k, v | v }.reverse\nmax = strs[0][1]\nstrs.each do |str|\n if max == str[1]\n print(str[0] + \"\\r\\n\") \n end\nend", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "sample_input": "7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n"}, "reference_outputs": ["beet\nvet\n"], "source_document_id": "p02773", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 217, "cpu_time_ms": 516, "memory_kb": 45968}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s443444961", "group_id": "codeNet:p02780", "input_text": "require 'pp'\n\n# 空白区切の入力値を数値の配列で返却する\ndef gets_i_list()\n gets.chomp.split(\" \").map(&:to_i)\nend\n\nN, K = gets_i_list\np_list = gets_i_list\n\ne_list = p_list.map do |p|\n (p + 1) * 0.5\nend\n\nsum_list = [0]\n(0...N).each do |i|\n sum_list[i+1] = sum_list[i] + e_list[i]\nend\n\nmax = 0\n0.upto(N - K) do |i|\n total = sum_list[i+K] - sum_list[i]\n max = [max, total].max\nend\nputs sprintf(\"%.12f\", max)\n", "language": "Ruby", "metadata": {"date": 1587503053, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s443444961.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s443444961", "user_id": "u370977023"}, "prompt_components": {"gold_output": "7.000000000000\n", "input_to_evaluate": "require 'pp'\n\n# 空白区切の入力値を数値の配列で返却する\ndef gets_i_list()\n gets.chomp.split(\" \").map(&:to_i)\nend\n\nN, K = gets_i_list\np_list = gets_i_list\n\ne_list = p_list.map do |p|\n (p + 1) * 0.5\nend\n\nsum_list = [0]\n(0...N).each do |i|\n sum_list[i+1] = sum_list[i] + e_list[i]\nend\n\nmax = 0\n0.upto(N - K) do |i|\n total = sum_list[i+K] - sum_list[i]\n max = [max, total].max\nend\nputs sprintf(\"%.12f\", max)\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": 428, "cpu_time_ms": 214, "memory_kb": 23108}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s886287973", "group_id": "codeNet:p02780", "input_text": "n, k = gets.chomp.split(' ').map(&:to_i)\narr = gets.chomp.split(' ').map(&:to_i)\n\nmax_num = -1\nmax_arr = []\nfor i in 0..n-k do\n i_arr = arr[i...i+k]\n i_num = i_arr.reduce(:+)\n if i_num > max_num\n max_num = i_num\n max_arr = i_arr\n end\nend\nmax_arr = max_arr.reduce(0){|res, i| res + (i.to_f + 1)/2}\nprintf(\"%.12f\", max_arr)", "language": "Ruby", "metadata": {"date": 1585866792, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s886287973.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s886287973", "user_id": "u882179152"}, "prompt_components": {"gold_output": "7.000000000000\n", "input_to_evaluate": "n, k = gets.chomp.split(' ').map(&:to_i)\narr = gets.chomp.split(' ').map(&:to_i)\n\nmax_num = -1\nmax_arr = []\nfor i in 0..n-k do\n i_arr = arr[i...i+k]\n i_num = i_arr.reduce(:+)\n if i_num > max_num\n max_num = i_num\n max_arr = i_arr\n end\nend\nmax_arr = max_arr.reduce(0){|res, i| res + (i.to_f + 1)/2}\nprintf(\"%.12f\", max_arr)", "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": 331, "cpu_time_ms": 2108, "memory_kb": 19460}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s343093258", "group_id": "codeNet:p02783", "input_text": "H,A = gets.split.map(&:to_f)\nputs (H / A).ceil", "language": "Ruby", "metadata": {"date": 1580068912, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s343093258.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s343093258", "user_id": "u064100484"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "H,A = gets.split.map(&:to_f)\nputs (H / A).ceil", "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": 46, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s340193941", "group_id": "codeNet:p02784", "input_text": "h, n = gets.split(\" \").map(&:to_i)\nls = []\n\nls = gets.split(\" \").map(&:to_i)\n\nif ls.inject(:+) >= h\n print(\"Yes\\n\")\nelse\n print(\"No\\n\")\nend\n", "language": "Ruby", "metadata": {"date": 1580069597, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s340193941.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s340193941", "user_id": "u911815052"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "h, n = gets.split(\" \").map(&:to_i)\nls = []\n\nls = gets.split(\" \").map(&:to_i)\n\nif ls.inject(:+) >= h\n print(\"Yes\\n\")\nelse\n print(\"No\\n\")\nend\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": 142, "cpu_time_ms": 51, "memory_kb": 8068}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s159308823", "group_id": "codeNet:p02785", "input_text": "_,k,*h=`dd`.split.map(&:to_i)\nk.times{h.pop}\np h.sum", "language": "Ruby", "metadata": {"date": 1600721092, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02785.html", "problem_id": "p02785", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02785/input.txt", "sample_output_relpath": "derived/input_output/data/p02785/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02785/Ruby/s159308823.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s159308823", "user_id": "u966810027"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "_,k,*h=`dd`.split.map(&:to_i)\nk.times{h.pop}\np h.sum", "problem_context": "Score : 300 points\n\nProblem Statement\n\nFennec is fighting with N monsters.\n\nThe health of the i-th monster is H_i.\n\nFennec can do the following two actions:\n\nAttack: Fennec chooses one monster. That monster's health will decrease by 1.\n\nSpecial Move: Fennec chooses one monster. That monster's health will become 0.\n\nThere is no way other than Attack and Special Move to decrease the monsters' health.\n\nFennec wins when all the monsters' healths become 0 or below.\n\nFind the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning when she can use Special Move at most K times.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq K \\leq 2 \\times 10^5\n\n1 \\leq H_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nH_1 ... H_N\n\nOutput\n\nPrint the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning.\n\nSample Input 1\n\n3 1\n4 1 5\n\nSample Output 1\n\n5\n\nBy using Special Move on the third monster, and doing Attack four times on the first monster and once on the second monster, Fennec can win with five Attacks.\n\nSample Input 2\n\n8 9\n7 9 3 2 3 8 4 6\n\nSample Output 2\n\n0\n\nShe can use Special Move on all the monsters.\n\nSample Input 3\n\n3 0\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n3000000000\n\nWatch out for overflow.", "sample_input": "3 1\n4 1 5\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02785", "source_text": "Score : 300 points\n\nProblem Statement\n\nFennec is fighting with N monsters.\n\nThe health of the i-th monster is H_i.\n\nFennec can do the following two actions:\n\nAttack: Fennec chooses one monster. That monster's health will decrease by 1.\n\nSpecial Move: Fennec chooses one monster. That monster's health will become 0.\n\nThere is no way other than Attack and Special Move to decrease the monsters' health.\n\nFennec wins when all the monsters' healths become 0 or below.\n\nFind the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning when she can use Special Move at most K times.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq K \\leq 2 \\times 10^5\n\n1 \\leq H_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nH_1 ... H_N\n\nOutput\n\nPrint the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning.\n\nSample Input 1\n\n3 1\n4 1 5\n\nSample Output 1\n\n5\n\nBy using Special Move on the third monster, and doing Attack four times on the first monster and once on the second monster, Fennec can win with five Attacks.\n\nSample Input 2\n\n8 9\n7 9 3 2 3 8 4 6\n\nSample Output 2\n\n0\n\nShe can use Special Move on all the monsters.\n\nSample Input 3\n\n3 0\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n3000000000\n\nWatch out for overflow.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 52, "cpu_time_ms": 142, "memory_kb": 29744}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s198056545", "group_id": "codeNet:p02787", "input_text": "h,n=gets.split.map(&:to_i)\nINF=10**9+1\ndp=[INF]*(h+1)\ndp[0]=0\nn.times do\n a,b=gets.split.map(&:to_i)\n (h+1).times do |i|\n j= i+a>h ? h:i+a\n dp[j]=dp[i]+b if dp[i]!=INF and dp[j]>dp[i]+b\n end\nend\np dp[h]\n", "language": "Ruby", "metadata": {"date": 1580590421, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02787.html", "problem_id": "p02787", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02787/input.txt", "sample_output_relpath": "derived/input_output/data/p02787/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02787/Ruby/s198056545.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s198056545", "user_id": "u712322283"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "h,n=gets.split.map(&:to_i)\nINF=10**9+1\ndp=[INF]*(h+1)\ndp[0]=0\nn.times do\n a,b=gets.split.map(&:to_i)\n (h+1).times do |i|\n j= i+a>h ? h:i+a\n dp[j]=dp[i]+b if dp[i]!=INF and dp[j]>dp[i]+b\n end\nend\np dp[h]\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nIbis is fighting with a monster.\n\nThe health of the monster is H.\n\nIbis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points.\n\nThe same spell can be cast multiple times. There is no way other than spells to decrease the monster's health.\n\nIbis wins when the health of the monster becomes 0 or below.\n\nFind the minimum total Magic Points that have to be consumed before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^4\n\n1 \\leq N \\leq 10^3\n\n1 \\leq A_i \\leq 10^4\n\n1 \\leq B_i \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH N\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the minimum total Magic Points that have to be consumed before winning.\n\nSample Input 1\n\n9 3\n8 3\n4 2\n2 1\n\nSample Output 1\n\n4\n\nFirst, let us cast the first spell to decrease the monster's health by 8, at the cost of 3 Magic Points. The monster's health is now 1.\n\nThen, cast the third spell to decrease the monster's health by 2, at the cost of 1 Magic Point. The monster's health is now -1.\n\nIn this way, we can win at the total cost of 4 Magic Points.\n\nSample Input 2\n\n100 6\n1 1\n2 3\n3 9\n4 27\n5 81\n6 243\n\nSample Output 2\n\n100\n\nIt is optimal to cast the first spell 100 times.\n\nSample Input 3\n\n9999 10\n540 7550\n691 9680\n700 9790\n510 7150\n415 5818\n551 7712\n587 8227\n619 8671\n588 8228\n176 2461\n\nSample Output 3\n\n139815", "sample_input": "9 3\n8 3\n4 2\n2 1\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02787", "source_text": "Score : 500 points\n\nProblem Statement\n\nIbis is fighting with a monster.\n\nThe health of the monster is H.\n\nIbis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points.\n\nThe same spell can be cast multiple times. There is no way other than spells to decrease the monster's health.\n\nIbis wins when the health of the monster becomes 0 or below.\n\nFind the minimum total Magic Points that have to be consumed before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^4\n\n1 \\leq N \\leq 10^3\n\n1 \\leq A_i \\leq 10^4\n\n1 \\leq B_i \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH N\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the minimum total Magic Points that have to be consumed before winning.\n\nSample Input 1\n\n9 3\n8 3\n4 2\n2 1\n\nSample Output 1\n\n4\n\nFirst, let us cast the first spell to decrease the monster's health by 8, at the cost of 3 Magic Points. The monster's health is now 1.\n\nThen, cast the third spell to decrease the monster's health by 2, at the cost of 1 Magic Point. The monster's health is now -1.\n\nIn this way, we can win at the total cost of 4 Magic Points.\n\nSample Input 2\n\n100 6\n1 1\n2 3\n3 9\n4 27\n5 81\n6 243\n\nSample Output 2\n\n100\n\nIt is optimal to cast the first spell 100 times.\n\nSample Input 3\n\n9999 10\n540 7550\n691 9680\n700 9790\n510 7150\n415 5818\n551 7712\n587 8227\n619 8671\n588 8228\n176 2461\n\nSample Output 3\n\n139815", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 226, "cpu_time_ms": 1465, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s035816110", "group_id": "codeNet:p02789", "input_text": "a, b = gets.split.map(&:to_i)\nputs a==b ? \"Yes\" : \"No\"", "language": "Ruby", "metadata": {"date": 1598295883, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s035816110.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s035816110", "user_id": "u358554431"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a, b = gets.split.map(&:to_i)\nputs a==b ? \"Yes\" : \"No\"", "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": 54, "cpu_time_ms": 64, "memory_kb": 14332}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s697912416", "group_id": "codeNet:p02790", "input_text": "MOD=10**9+7\ncnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)\ndef gs() gets.chomp end\ndef gi() gets.chomp.to_i end\ndef gsmi() gets.chomp.split.map(&:to_i) end\n\ndef desc(ar) ar.sort!{|x,y| y<=>x} end\ndef min(a,b) a<=b ? a : b end\ndef max(a,b) a>=b ? a : b end\ndef sum(ar) ar.inject(:+) end\n\ndef C(a,b) b==0||a==b ? 1 : (b=a-b if a/2x} end\ndef min(a,b) a<=b ? a : b end\ndef max(a,b) a>=b ? a : b end\ndef sum(ar) ar.inject(:+) end\n\ndef C(a,b) b==0||a==b ? 1 : (b=a-b if a/2= P_arr[i]\n counter += 1\n P_max = P_arr[i]\n end\nend\n\np counter\n", "language": "Ruby", "metadata": {"date": 1579474811, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02791.html", "problem_id": "p02791", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02791/input.txt", "sample_output_relpath": "derived/input_output/data/p02791/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02791/Ruby/s430326676.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s430326676", "user_id": "u012110567"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "n = gets.to_i\nP_arr = gets.chomp.split.map(&:to_i)\ncounter = 0\nP_max = P_arr.max\n\nn.times do |i|\n if P_max >= P_arr[i]\n counter += 1\n P_max = P_arr[i]\n end\nend\n\np counter\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "sample_input": "5\n4 2 5 1 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02791", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 181, "cpu_time_ms": 807, "memory_kb": 31236}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s744924189", "group_id": "codeNet:p02791", "input_text": "N = gets.to_i\nnums = gets.split.map(&:to_i)\nmin = Float::INFINITY\nans = 0\nnums.each do |ai|\n if ai < min\n min = ai\n ans += 1\n end\nend\np ans", "language": "Ruby", "metadata": {"date": 1579470564, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02791.html", "problem_id": "p02791", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02791/input.txt", "sample_output_relpath": "derived/input_output/data/p02791/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02791/Ruby/s744924189.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s744924189", "user_id": "u645787471"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "N = gets.to_i\nnums = gets.split.map(&:to_i)\nmin = Float::INFINITY\nans = 0\nnums.each do |ai|\n if ai < min\n min = ai\n ans += 1\n end\nend\np ans", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "sample_input": "5\n4 2 5 1 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02791", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 147, "cpu_time_ms": 97, "memory_kb": 15236}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s378565029", "group_id": "codeNet:p02791", "input_text": "n = gets.to_i\narray = gets.split(\" \").map(&:to_i)\n\ncount = 0\nminimal = array.first\n(1...n).each do |y|\n if minimal < array[y]\n count += 1\n else\n minimal = array[y]\n end\nend\n\nputs n - count\n", "language": "Ruby", "metadata": {"date": 1579467574, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02791.html", "problem_id": "p02791", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02791/input.txt", "sample_output_relpath": "derived/input_output/data/p02791/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02791/Ruby/s378565029.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s378565029", "user_id": "u393913844"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "n = gets.to_i\narray = gets.split(\" \").map(&:to_i)\n\ncount = 0\nminimal = array.first\n(1...n).each do |y|\n if minimal < array[y]\n count += 1\n else\n minimal = array[y]\n end\nend\n\nputs n - count\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "sample_input": "5\n4 2 5 1 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02791", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 198, "cpu_time_ms": 102, "memory_kb": 15236}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s230327982", "group_id": "codeNet:p02791", "input_text": "io = STDIN\nn=io.gets.to_i\nP=io.gets.split.map(&:to_i)\ncnt=0\nn.times do |i|\n cnt +=1 if (0..i).all?{|j|P[i]<=P[j]}\nend\nputs cnt\n", "language": "Ruby", "metadata": {"date": 1579464477, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02791.html", "problem_id": "p02791", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02791/input.txt", "sample_output_relpath": "derived/input_output/data/p02791/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02791/Ruby/s230327982.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s230327982", "user_id": "u132360211"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "io = STDIN\nn=io.gets.to_i\nP=io.gets.split.map(&:to_i)\ncnt=0\nn.times do |i|\n cnt +=1 if (0..i).all?{|j|P[i]<=P[j]}\nend\nputs cnt\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "sample_input": "5\n4 2 5 1 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02791", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 128, "cpu_time_ms": 2108, "memory_kb": 19204}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s297658615", "group_id": "codeNet:p02791", "input_text": "n = gets.chomp.to_i\nps = gets.chomp.split(\" \").map(&:to_i);\n\nmin = 10**6 + 1\ncount = 0\n\nps.each do |p|\n if min > p\n min = p\n count += 1\n end\nend\n\nputs count", "language": "Ruby", "metadata": {"date": 1579463931, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02791.html", "problem_id": "p02791", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02791/input.txt", "sample_output_relpath": "derived/input_output/data/p02791/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02791/Ruby/s297658615.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s297658615", "user_id": "u650620788"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "n = gets.chomp.to_i\nps = gets.chomp.split(\" \").map(&:to_i);\n\nmin = 10**6 + 1\ncount = 0\n\nps.each do |p|\n if min > p\n min = p\n count += 1\n end\nend\n\nputs count", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "sample_input": "5\n4 2 5 1 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02791", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 164, "cpu_time_ms": 97, "memory_kb": 16516}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s276906344", "group_id": "codeNet:p02797", "input_text": "# frozen_string_literal: true\n\nn, k, s = gets.split.map(&:to_i)\nresult = []\n\nif n == k\n n.times do\n result << s\n end\n\n puts result.join(' ')\n exit\n\nend\n\nif s.even?\n if k > 0\n (k + 1).times do\n result << s / 2\n end\n\n (n - (k + 1)).times do\n result << s / 2 + 2\n end\n else\n n.times do\n result << s / 2 + 2\n end\n end\nend\n\nif s.odd?\n if k > 0\n flag = false\n (k + 1).times do\n tmp = flag ? s / 2 : s / 2 + 1\n result << tmp\n flag = !flag\n end\n\n (n - (k + 1)).times do\n result << s / 2 + 2\n end\n else\n n.times do\n result << s / 2 + 2\n end\n end\nend\n\nputs result.join(' ')\n", "language": "Ruby", "metadata": {"date": 1587818244, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s276906344.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s276906344", "user_id": "u393913844"}, "prompt_components": {"gold_output": "1 2 3 4\n", "input_to_evaluate": "# frozen_string_literal: true\n\nn, k, s = gets.split.map(&:to_i)\nresult = []\n\nif n == k\n n.times do\n result << s\n end\n\n puts result.join(' ')\n exit\n\nend\n\nif s.even?\n if k > 0\n (k + 1).times do\n result << s / 2\n end\n\n (n - (k + 1)).times do\n result << s / 2 + 2\n end\n else\n n.times do\n result << s / 2 + 2\n end\n end\nend\n\nif s.odd?\n if k > 0\n flag = false\n (k + 1).times do\n tmp = flag ? s / 2 : s / 2 + 1\n result << tmp\n flag = !flag\n end\n\n (n - (k + 1)).times do\n result << s / 2 + 2\n end\n else\n n.times do\n result << s / 2 + 2\n end\n end\nend\n\nputs result.join(' ')\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": 656, "cpu_time_ms": 66, "memory_kb": 4860}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s431178163", "group_id": "codeNet:p02797", "input_text": "n, k, s = gets.split.map(&:to_i)\na = Array.new(n,1000000000)\n(k).times do |i|\n a[i] = s\nend\nputs a.join(\" \")", "language": "Ruby", "metadata": {"date": 1579379631, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s431178163.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s431178163", "user_id": "u960706641"}, "prompt_components": {"gold_output": "1 2 3 4\n", "input_to_evaluate": "n, k, s = gets.split.map(&:to_i)\na = Array.new(n,1000000000)\n(k).times do |i|\n a[i] = s\nend\nputs a.join(\" \")", "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": 109, "cpu_time_ms": 66, "memory_kb": 4732}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s887235336", "group_id": "codeNet:p02801", "input_text": "C = gets.chomp\nalf = 'abcdefghijklmnopqrstuvwxyz'.to_s\nalf.size.times do |i|\n puts alf[i+1] if alf[i] == C\nend", "language": "Ruby", "metadata": {"date": 1579996592, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02801.html", "problem_id": "p02801", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02801/input.txt", "sample_output_relpath": "derived/input_output/data/p02801/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02801/Ruby/s887235336.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s887235336", "user_id": "u884511822"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "C = gets.chomp\nalf = 'abcdefghijklmnopqrstuvwxyz'.to_s\nalf.size.times do |i|\n puts alf[i+1] if alf[i] == C\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is a lowercase English letter C that is not z. Print the letter that follows C in alphabetical order.\n\nConstraints\n\nC is a lowercase English letter that is not z.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nC\n\nOutput\n\nPrint the letter that follows C in alphabetical order.\n\nSample Input 1\n\na\n\nSample Output 1\n\nb\n\na is followed by b.\n\nSample Input 2\n\ny\n\nSample Output 2\n\nz\n\ny is followed by z.", "sample_input": "a\n"}, "reference_outputs": ["b\n"], "source_document_id": "p02801", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is a lowercase English letter C that is not z. Print the letter that follows C in alphabetical order.\n\nConstraints\n\nC is a lowercase English letter that is not z.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nC\n\nOutput\n\nPrint the letter that follows C in alphabetical order.\n\nSample Input 1\n\na\n\nSample Output 1\n\nb\n\na is followed by b.\n\nSample Input 2\n\ny\n\nSample Output 2\n\nz\n\ny is followed by z.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 111, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s801930191", "group_id": "codeNet:p02801", "input_text": "c=gets.chomp.to_s\na=(\"a\"..\"z\").to_a\nputs a[a.index(c)+1]", "language": "Ruby", "metadata": {"date": 1578859528, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02801.html", "problem_id": "p02801", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02801/input.txt", "sample_output_relpath": "derived/input_output/data/p02801/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02801/Ruby/s801930191.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s801930191", "user_id": "u630043039"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "c=gets.chomp.to_s\na=(\"a\"..\"z\").to_a\nputs a[a.index(c)+1]", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is a lowercase English letter C that is not z. Print the letter that follows C in alphabetical order.\n\nConstraints\n\nC is a lowercase English letter that is not z.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nC\n\nOutput\n\nPrint the letter that follows C in alphabetical order.\n\nSample Input 1\n\na\n\nSample Output 1\n\nb\n\na is followed by b.\n\nSample Input 2\n\ny\n\nSample Output 2\n\nz\n\ny is followed by z.", "sample_input": "a\n"}, "reference_outputs": ["b\n"], "source_document_id": "p02801", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is a lowercase English letter C that is not z. Print the letter that follows C in alphabetical order.\n\nConstraints\n\nC is a lowercase English letter that is not z.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nC\n\nOutput\n\nPrint the letter that follows C in alphabetical order.\n\nSample Input 1\n\na\n\nSample Output 1\n\nb\n\na is followed by b.\n\nSample Input 2\n\ny\n\nSample Output 2\n\nz\n\ny is followed by z.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 56, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s718159982", "group_id": "codeNet:p02802", "input_text": "n,m = gets.split(' ').map(&:to_i)\na = []\nt1, t2 = 0, 0\nm.times { a << gets.split(' ') }\na = a.group_by { |a| a[0] }\na.each do |b|\n tmp = b[1].transpose[1]\n if tmp.include?('AC')\n t1 += 1\n tmp.slice!(tmp.index('AC')..-1)\n t2 += tmp.count('WA')\n end\nend\nprintf(\"%i %i\\n\", t1, t2)", "language": "Ruby", "metadata": {"date": 1578895201, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s718159982.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s718159982", "user_id": "u088221425"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "n,m = gets.split(' ').map(&:to_i)\na = []\nt1, t2 = 0, 0\nm.times { a << gets.split(' ') }\na = a.group_by { |a| a[0] }\na.each do |b|\n tmp = b[1].transpose[1]\n if tmp.include?('AC')\n t1 += 1\n tmp.slice!(tmp.index('AC')..-1)\n t2 += tmp.count('WA')\n end\nend\nprintf(\"%i %i\\n\", t1, t2)", "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": 289, "cpu_time_ms": 319, "memory_kb": 48508}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s775971240", "group_id": "codeNet:p02802", "input_text": "n, m = gets.split.map(&:to_i)\nresults = m.times.map{ gets.split }\n\nca = 0\npenalty = 0\nnum = 0\n\nresults.each do |result|\n next if result[0].to_i <= num\n if result[1] == 'AC'\n ca += 1\n num = result[0].to_i\n else\n next if num >= n\n penalty += 1\n end\nend\n\nputs \"#{ca} #{penalty}\"", "language": "Ruby", "metadata": {"date": 1578883668, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s775971240.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s775971240", "user_id": "u397533457"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "n, m = gets.split.map(&:to_i)\nresults = m.times.map{ gets.split }\n\nca = 0\npenalty = 0\nnum = 0\n\nresults.each do |result|\n next if result[0].to_i <= num\n if result[1] == 'AC'\n ca += 1\n num = result[0].to_i\n else\n next if num >= n\n penalty += 1\n end\nend\n\nputs \"#{ca} #{penalty}\"", "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": 291, "cpu_time_ms": 127, "memory_kb": 19708}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s522130333", "group_id": "codeNet:p02802", "input_text": "n,m = gets.split(' ').map(&:to_i)\n\nflag = {}\nac_c = 0\nwa_c = 0\nm.times do\n p, s = gets.split(' ')\n next if flag[p] == 'AC'\n\n if s == 'AC'\n flag[p] = 'AC'\n ac_c += 1\n else\n wa_c += 1\n end\nend\n\nputs \"#{ac_c} #{wa_c}\"", "language": "Ruby", "metadata": {"date": 1578883131, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s522130333.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s522130333", "user_id": "u634482428"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "n,m = gets.split(' ').map(&:to_i)\n\nflag = {}\nac_c = 0\nwa_c = 0\nm.times do\n p, s = gets.split(' ')\n next if flag[p] == 'AC'\n\n if s == 'AC'\n flag[p] = 'AC'\n ac_c += 1\n else\n wa_c += 1\n end\nend\n\nputs \"#{ac_c} #{wa_c}\"", "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": 228, "cpu_time_ms": 209, "memory_kb": 21116}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s559737080", "group_id": "codeNet:p02802", "input_text": "lines = readlines.map{|line| line.split(' ')}\nd=0\nc=[]\nfor j in 1..lines[0][1].to_i do\n if lines[j][1]==\"WA\" && !c.include?(lines[j][0].to_i) then\n d=d+1\n elsif lines[j][1]==\"AC\" && !c.include?(lines[j][0].to_i) then\n c.push(lines[j][0].to_i)\n end\nend\nputs c.length.to_s+\" \"+d.to_s", "language": "Ruby", "metadata": {"date": 1578882588, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s559737080.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s559737080", "user_id": "u413184068"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "lines = readlines.map{|line| line.split(' ')}\nd=0\nc=[]\nfor j in 1..lines[0][1].to_i do\n if lines[j][1]==\"WA\" && !c.include?(lines[j][0].to_i) then\n d=d+1\n elsif lines[j][1]==\"AC\" && !c.include?(lines[j][0].to_i) then\n c.push(lines[j][0].to_i)\n end\nend\nputs c.length.to_s+\" \"+d.to_s", "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": 290, "cpu_time_ms": 2109, "memory_kb": 27260}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s816259582", "group_id": "codeNet:p02803", "input_text": "$h, $w = gets.split.map(&:to_i)\n$s = []\n$h.times do\n $s << gets.chomp\nend\n$d = [[0, 1], [0, -1], [1, 0], [-1, 0]]\n\ndef bfs(sx, sy)\n bfs_map = Array.new($h) { Array.new($w, Float::INFINITY) }\n bfs_map[sy][sx] = 0\n q = []\n q << [sy, sx, 0]\n res = 0\n\n until q.empty?\n y, x, dist = q.shift\n $d.each do |dy, dx|\n ny = y + dy\n nx = x + dx\n next unless nx >= 0 && nx < $w && ny >= 0 && ny < $h && $s[ny][nx] != \"#\"\n if bfs_map[ny][nx] > dist + 1\n bfs_map[ny][nx] = dist + 1\n res = dist + 1 if dist + 1 != Float::INFINITY && dist + 1 > res\n q << [ny, nx, dist + 1]\n end\n end\n end\n # res = 0\n # bfs_map.each do |row|\n # row.each do |c|\n # if c != Float::INFINITY && c > res\n # res = c\n # end\n # end\n # end\n return res\nend\n\nans = -1\n$h.times do |sy|\n $w.times do |sx|\n t = bfs(sx, sy)\n ans = t if t > ans\n end\nend\np ans\n", "language": "Ruby", "metadata": {"date": 1578885661, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s816259582.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s816259582", "user_id": "u706695185"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "$h, $w = gets.split.map(&:to_i)\n$s = []\n$h.times do\n $s << gets.chomp\nend\n$d = [[0, 1], [0, -1], [1, 0], [-1, 0]]\n\ndef bfs(sx, sy)\n bfs_map = Array.new($h) { Array.new($w, Float::INFINITY) }\n bfs_map[sy][sx] = 0\n q = []\n q << [sy, sx, 0]\n res = 0\n\n until q.empty?\n y, x, dist = q.shift\n $d.each do |dy, dx|\n ny = y + dy\n nx = x + dx\n next unless nx >= 0 && nx < $w && ny >= 0 && ny < $h && $s[ny][nx] != \"#\"\n if bfs_map[ny][nx] > dist + 1\n bfs_map[ny][nx] = dist + 1\n res = dist + 1 if dist + 1 != Float::INFINITY && dist + 1 > res\n q << [ny, nx, dist + 1]\n end\n end\n end\n # res = 0\n # bfs_map.each do |row|\n # row.each do |c|\n # if c != Float::INFINITY && c > res\n # res = c\n # end\n # end\n # end\n return res\nend\n\nans = -1\n$h.times do |sy|\n $w.times do |sx|\n t = bfs(sx, sy)\n ans = t if t > ans\n end\nend\np ans\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": 908, "cpu_time_ms": 318, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s442256940", "group_id": "codeNet:p02803", "input_text": "h,w = gets.chomp.split().map(&:to_i)\ns= []\nh.times do\n s.push gets.chomp.split(//)\nend\n\ndef solve(grid,yy,xx, h,w)\n dy = [0, 1, 0, -1]; dx = [1, 0, -1, 0]\n\n visited = Array.new(h){Array.new(w, 0)}\n visited[yy][xx] = true\n q = [[yy,xx,0]]\n\n ans = 0\n until q.empty?\n y,x,cost = q.shift\n 4.times do |i|\n ny = y + dy[i]; nx = x + dx[i]\n if (0 <= ny && ny < h) && (0 <= nx && nx < w) && grid[ny][nx] != '#' && visited[ny][nx] == 0\n visited[ny][nx] = 1\n q.push [ny, nx, cost+1]\n ans = cost+1 if ans < cost+1\n end\n end\n end\n ans\nend\n\nans = 0\nh.times do |i|\n w.times do |j|\n if s[i][j] != '#'\n solved = solve(s,i,j, h,w)\n ans = solved if ans < solved\n end\n end\nend\n\nputs ans\n\n\n", "language": "Ruby", "metadata": {"date": 1578882503, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s442256940.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s442256940", "user_id": "u524019694"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "h,w = gets.chomp.split().map(&:to_i)\ns= []\nh.times do\n s.push gets.chomp.split(//)\nend\n\ndef solve(grid,yy,xx, h,w)\n dy = [0, 1, 0, -1]; dx = [1, 0, -1, 0]\n\n visited = Array.new(h){Array.new(w, 0)}\n visited[yy][xx] = true\n q = [[yy,xx,0]]\n\n ans = 0\n until q.empty?\n y,x,cost = q.shift\n 4.times do |i|\n ny = y + dy[i]; nx = x + dx[i]\n if (0 <= ny && ny < h) && (0 <= nx && nx < w) && grid[ny][nx] != '#' && visited[ny][nx] == 0\n visited[ny][nx] = 1\n q.push [ny, nx, cost+1]\n ans = cost+1 if ans < cost+1\n end\n end\n end\n ans\nend\n\nans = 0\nh.times do |i|\n w.times do |j|\n if s[i][j] != '#'\n solved = solve(s,i,j, h,w)\n ans = solved if ans < solved\n end\n end\nend\n\nputs ans\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": 741, "cpu_time_ms": 248, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s147831975", "group_id": "codeNet:p02804", "input_text": "class ModComb\n def initialize(max, mod)\n @mod = mod\n @fac = Array.new(max + 1)\n @finv = Array.new(max + 1)\n @inv = Array.new(max + 1)\n @fac[0] = @fac[1] = 1\n @finv[0] = @finv[1] = 1\n @inv[1] = 1\n (2..max).each do |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 end\n end\n\n def comb(n, k)\n return 0 if n < k\n return 0 if n < 0 || k < 0\n @fac[n] * (@finv[k] * @finv[n - k] % @mod) % @mod\n end\nend\n\nN, K = gets.split.map(&:to_i)\nA = gets.split.map(&:to_i)\n\nMOD = 10 ** 9 + 7\nsorted = A.sort\ncomb = ModComb.new(N, MOD)\nans = 0\nN.times do |i|\n a = sorted[i]\n max_count = comb.comb(i, K - 1)\n min_count = comb.comb(N - i - 1, K - 1)\n ans = (ans + (a * max_count % MOD) - (a * min_count % MOD)) % MOD\nend\nputs ans", "language": "Ruby", "metadata": {"date": 1580845666, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02804.html", "problem_id": "p02804", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02804/input.txt", "sample_output_relpath": "derived/input_output/data/p02804/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02804/Ruby/s147831975.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s147831975", "user_id": "u012133968"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "class ModComb\n def initialize(max, mod)\n @mod = mod\n @fac = Array.new(max + 1)\n @finv = Array.new(max + 1)\n @inv = Array.new(max + 1)\n @fac[0] = @fac[1] = 1\n @finv[0] = @finv[1] = 1\n @inv[1] = 1\n (2..max).each do |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 end\n end\n\n def comb(n, k)\n return 0 if n < k\n return 0 if n < 0 || k < 0\n @fac[n] * (@finv[k] * @finv[n - k] % @mod) % @mod\n end\nend\n\nN, K = gets.split.map(&:to_i)\nA = gets.split.map(&:to_i)\n\nMOD = 10 ** 9 + 7\nsorted = A.sort\ncomb = ModComb.new(N, MOD)\nans = 0\nN.times do |i|\n a = sorted[i]\n max_count = comb.comb(i, K - 1)\n min_count = comb.comb(N - i - 1, K - 1)\n ans = (ans + (a * max_count % MOD) - (a * min_count % MOD)) % MOD\nend\nputs ans", "problem_context": "Score : 500 points\n\nProblem Statement\n\nFor a finite set of integers X, let f(X)=\\max X - \\min X.\n\nGiven are N integers A_1,...,A_N.\n\nWe will choose K of them and let S be the set of the integers chosen. If we distinguish elements with different indices even when their values are the same, there are {}_N C_K ways to make this choice. Find the sum of f(S) over all those ways.\n\nSince the answer can be enormous, print it \\bmod (10^9+7).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 ... A_N\n\nOutput\n\nPrint the answer \\bmod (10^9+7).\n\nSample Input 1\n\n4 2\n1 1 3 4\n\nSample Output 1\n\n11\n\nThere are six ways to choose S: \\{1,1\\},\\{1,3\\},\\{1,4\\},\\{1,3\\},\\{1,4\\}, \\{3,4\\} (we distinguish the two 1s). The value of f(S) for these choices are 0,2,3,2,3,1, respectively, for the total of 11.\n\nSample Input 2\n\n6 3\n10 10 10 -10 -10 -10\n\nSample Output 2\n\n360\n\nThere are 20 ways to choose S. In 18 of them, f(S)=20, and in 2 of them, f(S)=0.\n\nSample Input 3\n\n3 1\n1 1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n10 6\n1000000000 1000000000 1000000000 1000000000 1000000000 0 0 0 0 0\n\nSample Output 4\n\n999998537\n\nPrint the sum \\bmod (10^9+7).", "sample_input": "4 2\n1 1 3 4\n"}, "reference_outputs": ["11\n"], "source_document_id": "p02804", "source_text": "Score : 500 points\n\nProblem Statement\n\nFor a finite set of integers X, let f(X)=\\max X - \\min X.\n\nGiven are N integers A_1,...,A_N.\n\nWe will choose K of them and let S be the set of the integers chosen. If we distinguish elements with different indices even when their values are the same, there are {}_N C_K ways to make this choice. Find the sum of f(S) over all those ways.\n\nSince the answer can be enormous, print it \\bmod (10^9+7).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 ... A_N\n\nOutput\n\nPrint the answer \\bmod (10^9+7).\n\nSample Input 1\n\n4 2\n1 1 3 4\n\nSample Output 1\n\n11\n\nThere are six ways to choose S: \\{1,1\\},\\{1,3\\},\\{1,4\\},\\{1,3\\},\\{1,4\\}, \\{3,4\\} (we distinguish the two 1s). The value of f(S) for these choices are 0,2,3,2,3,1, respectively, for the total of 11.\n\nSample Input 2\n\n6 3\n10 10 10 -10 -10 -10\n\nSample Output 2\n\n360\n\nThere are 20 ways to choose S. In 18 of them, f(S)=20, and in 2 of them, f(S)=0.\n\nSample Input 3\n\n3 1\n1 1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n10 6\n1000000000 1000000000 1000000000 1000000000 1000000000 0 0 0 0 0\n\nSample Output 4\n\n999998537\n\nPrint the sum \\bmod (10^9+7).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 850, "cpu_time_ms": 156, "memory_kb": 11772}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s668512922", "group_id": "codeNet:p02811", "input_text": "k,x = gets.split.map(&:to_i)\nputs 500 * k >= x ? \"Yes\" : \"No\"", "language": "Ruby", "metadata": {"date": 1578708317, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s668512922.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s668512922", "user_id": "u692254521"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "k,x = gets.split.map(&:to_i)\nputs 500 * k >= x ? \"Yes\" : \"No\"", "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": 61, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s496567660", "group_id": "codeNet:p02812", "input_text": "gets\np gets.scan(\"ABC\").size", "language": "Ruby", "metadata": {"date": 1578716553, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02812.html", "problem_id": "p02812", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02812/input.txt", "sample_output_relpath": "derived/input_output/data/p02812/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02812/Ruby/s496567660.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s496567660", "user_id": "u744908753"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "gets\np gets.scan(\"ABC\").size", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a string S of length N consisting of uppercase English letters.\n\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\nConstraints\n\n3 \\leq N \\leq 50\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint number of occurrences of ABC in S as contiguous subsequences.\n\nSample Input 1\n\n10\nZABCDBABCQ\n\nSample Output 1\n\n2\n\nTwo contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.\n\nSample Input 2\n\n19\nTHREEONEFOURONEFIVE\n\nSample Output 2\n\n0\n\nNo contiguous subsequences of S are equal to ABC.\n\nSample Input 3\n\n33\nABCCABCBABCCABACBCBBABCBCBCBCABCB\n\nSample Output 3\n\n5", "sample_input": "10\nZABCDBABCQ\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02812", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a string S of length N consisting of uppercase English letters.\n\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\nConstraints\n\n3 \\leq N \\leq 50\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint number of occurrences of ABC in S as contiguous subsequences.\n\nSample Input 1\n\n10\nZABCDBABCQ\n\nSample Output 1\n\n2\n\nTwo contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.\n\nSample Input 2\n\n19\nTHREEONEFOURONEFIVE\n\nSample Output 2\n\n0\n\nNo contiguous subsequences of S are equal to ABC.\n\nSample Input 3\n\n33\nABCCABCBABCCABACBCBBABCBCBCBCABCB\n\nSample Output 3\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 28, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s987628776", "group_id": "codeNet:p02812", "input_text": "n = gets.to_i # n <= 50\na = gets.chars.take(n)\n\nresult = 0\n\n(n - 2).times do |i|\n next unless a[i] == 'A'\n next unless a[i+1] == 'B'\n next unless a[i+2] == 'C'\n result += 1\nend\n\nputs result", "language": "Ruby", "metadata": {"date": 1578708322, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02812.html", "problem_id": "p02812", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02812/input.txt", "sample_output_relpath": "derived/input_output/data/p02812/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02812/Ruby/s987628776.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s987628776", "user_id": "u776649162"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n = gets.to_i # n <= 50\na = gets.chars.take(n)\n\nresult = 0\n\n(n - 2).times do |i|\n next unless a[i] == 'A'\n next unless a[i+1] == 'B'\n next unless a[i+2] == 'C'\n result += 1\nend\n\nputs result", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a string S of length N consisting of uppercase English letters.\n\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\nConstraints\n\n3 \\leq N \\leq 50\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint number of occurrences of ABC in S as contiguous subsequences.\n\nSample Input 1\n\n10\nZABCDBABCQ\n\nSample Output 1\n\n2\n\nTwo contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.\n\nSample Input 2\n\n19\nTHREEONEFOURONEFIVE\n\nSample Output 2\n\n0\n\nNo contiguous subsequences of S are equal to ABC.\n\nSample Input 3\n\n33\nABCCABCBABCCABACBCBBABCBCBCBCABCB\n\nSample Output 3\n\n5", "sample_input": "10\nZABCDBABCQ\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02812", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a string S of length N consisting of uppercase English letters.\n\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\nConstraints\n\n3 \\leq N \\leq 50\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint number of occurrences of ABC in S as contiguous subsequences.\n\nSample Input 1\n\n10\nZABCDBABCQ\n\nSample Output 1\n\n2\n\nTwo contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.\n\nSample Input 2\n\n19\nTHREEONEFOURONEFIVE\n\nSample Output 2\n\n0\n\nNo contiguous subsequences of S are equal to ABC.\n\nSample Input 3\n\n33\nABCCABCBABCCABACBCBBABCBCBCBCABCB\n\nSample Output 3\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 193, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s682004753", "group_id": "codeNet:p02814", "input_text": "n, m = gets.split.map(&:to_i)\na = gets.split.map(&:to_i)\nq = 2\ncnt = [0] * 30\na.each do |i|\n q = i.lcm(q)\n c = 0\n until i % 2 != 0\n i /= 2\n c += 1\n end\n cnt[c] += 1\nend\nputs cnt.uniq.size == 2 ? (m + q/2) / q : 0\n\n", "language": "Ruby", "metadata": {"date": 1599892068, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s682004753.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s682004753", "user_id": "u016444909"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n, m = gets.split.map(&:to_i)\na = gets.split.map(&:to_i)\nq = 2\ncnt = [0] * 30\na.each do |i|\n q = i.lcm(q)\n c = 0\n until i % 2 != 0\n i /= 2\n c += 1\n end\n cnt[c] += 1\nend\nputs cnt.uniq.size == 2 ? (m + q/2) / q : 0\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": 225, "cpu_time_ms": 227, "memory_kb": 23384}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s644479920", "group_id": "codeNet:p02817", "input_text": "S,T = gets.split.map(&:to_i)\nputs(str=T+S)\n", "language": "Ruby", "metadata": {"date": 1588139237, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s644479920.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s644479920", "user_id": "u868091387"}, "prompt_components": {"gold_output": "atcoder\n", "input_to_evaluate": "S,T = gets.split.map(&:to_i)\nputs(str=T+S)\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\nThe lengths of S and T are between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\noder atc\n\nSample Output 1\n\natcoder\n\nWhen S = oder and T = atc, concatenating T and S in this order results in atcoder.\n\nSample Input 2\n\nhumu humu\n\nSample Output 2\n\nhumuhumu", "sample_input": "oder atc\n"}, "reference_outputs": ["atcoder\n"], "source_document_id": "p02817", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\nThe lengths of S and T are between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\noder atc\n\nSample Output 1\n\natcoder\n\nWhen S = oder and T = atc, concatenating T and S in this order results in atcoder.\n\nSample Input 2\n\nhumu humu\n\nSample Output 2\n\nhumuhumu", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 43, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s152365450", "group_id": "codeNet:p02817", "input_text": "s,t = gets.chomp.split(' ')\nputs \"#{t}#{s}\"", "language": "Ruby", "metadata": {"date": 1584494720, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s152365450.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s152365450", "user_id": "u546441021"}, "prompt_components": {"gold_output": "atcoder\n", "input_to_evaluate": "s,t = gets.chomp.split(' ')\nputs \"#{t}#{s}\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\nThe lengths of S and T are between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\noder atc\n\nSample Output 1\n\natcoder\n\nWhen S = oder and T = atc, concatenating T and S in this order results in atcoder.\n\nSample Input 2\n\nhumu humu\n\nSample Output 2\n\nhumuhumu", "sample_input": "oder atc\n"}, "reference_outputs": ["atcoder\n"], "source_document_id": "p02817", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\nThe lengths of S and T are between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\noder atc\n\nSample Output 1\n\natcoder\n\nWhen S = oder and T = atc, concatenating T and S in this order results in atcoder.\n\nSample Input 2\n\nhumu humu\n\nSample Output 2\n\nhumuhumu", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 43, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s818865172", "group_id": "codeNet:p02817", "input_text": "a = gets.split\nputs \"#{a[1]}#{a[0]}\"", "language": "Ruby", "metadata": {"date": 1582302853, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s818865172.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s818865172", "user_id": "u301362135"}, "prompt_components": {"gold_output": "atcoder\n", "input_to_evaluate": "a = gets.split\nputs \"#{a[1]}#{a[0]}\"", "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": 36, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s862041787", "group_id": "codeNet:p02817", "input_text": "s,t = gets.chomp.split\nputs s + t", "language": "Ruby", "metadata": {"date": 1581787129, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s862041787.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s862041787", "user_id": "u895926909"}, "prompt_components": {"gold_output": "atcoder\n", "input_to_evaluate": "s,t = gets.chomp.split\nputs s + t", "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": 33, "cpu_time_ms": 9, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s386418507", "group_id": "codeNet:p02818", "input_text": "a, b, k = gets.chomp.split.map(&:to_i)\n\nk.times do\n if a >= 1\n a -= 1\n elsif b >= 1\n b -= 1\n elsif a == 0 && b == 0\n # do nothing\n end\nend\n\nprint(\"#{a} #{b}\")", "language": "Ruby", "metadata": {"date": 1577670863, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s386418507.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s386418507", "user_id": "u588739641"}, "prompt_components": {"gold_output": "0 2\n", "input_to_evaluate": "a, b, k = gets.chomp.split.map(&:to_i)\n\nk.times do\n if a >= 1\n a -= 1\n elsif b >= 1\n b -= 1\n elsif a == 0 && b == 0\n # do nothing\n end\nend\n\nprint(\"#{a} #{b}\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A cookies, and Aoki has B cookies.\nTakahashi will do the following action K times:\n\nIf Takahashi has one or more cookies, eat one of his cookies.\n\nOtherwise, if Aoki has one or more cookies, eat one of Aoki's cookies.\n\nIf they both have no cookies, do nothing.\n\nIn the end, how many cookies will Takahashi and Aoki have, respectively?\n\nConstraints\n\n0 \\leq A \\leq 10^{12}\n\n0 \\leq B \\leq 10^{12}\n\n0 \\leq K \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the numbers of Takahashi's and Aoki's cookies after K actions.\n\nSample Input 1\n\n2 3 3\n\nSample Output 1\n\n0 2\n\nTakahashi will do the following:\n\nHe has two cookies, so he eats one of them.\n\nNow he has one cookie left, and he eats it.\n\nNow he has no cookies left, but Aoki has three, so Takahashi eats one of them.\n\nThus, in the end, Takahashi will have 0 cookies, and Aoki will have 2.\n\nSample Input 2\n\n500000000000 500000000000 1000000000000\n\nSample Output 2\n\n0 0\n\nWatch out for overflows.", "sample_input": "2 3 3\n"}, "reference_outputs": ["0 2\n"], "source_document_id": "p02818", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A cookies, and Aoki has B cookies.\nTakahashi will do the following action K times:\n\nIf Takahashi has one or more cookies, eat one of his cookies.\n\nOtherwise, if Aoki has one or more cookies, eat one of Aoki's cookies.\n\nIf they both have no cookies, do nothing.\n\nIn the end, how many cookies will Takahashi and Aoki have, respectively?\n\nConstraints\n\n0 \\leq A \\leq 10^{12}\n\n0 \\leq B \\leq 10^{12}\n\n0 \\leq K \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the numbers of Takahashi's and Aoki's cookies after K actions.\n\nSample Input 1\n\n2 3 3\n\nSample Output 1\n\n0 2\n\nTakahashi will do the following:\n\nHe has two cookies, so he eats one of them.\n\nNow he has one cookie left, and he eats it.\n\nNow he has no cookies left, but Aoki has three, so Takahashi eats one of them.\n\nThus, in the end, Takahashi will have 0 cookies, and Aoki will have 2.\n\nSample Input 2\n\n500000000000 500000000000 1000000000000\n\nSample Output 2\n\n0 0\n\nWatch out for overflows.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 171, "cpu_time_ms": 2107, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s936223645", "group_id": "codeNet:p02819", "input_text": "x = gets.to_i\n\n\ndef prime (n)\n return true if n == 2\n (2..(Integer.sqrt(n)+1)).each do |i|\n return false if n % i == 0\n end\n true\nend\n\nif x == 2\n puts \"2\"\n exit 0\nend\n\nx += 1 if x % 2 == 0\nwhile true do\n break if prime (x)\n x +=2\nend\n\nputs x", "language": "Ruby", "metadata": {"date": 1577732156, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02819.html", "problem_id": "p02819", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02819/input.txt", "sample_output_relpath": "derived/input_output/data/p02819/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02819/Ruby/s936223645.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s936223645", "user_id": "u650620788"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "x = gets.to_i\n\n\ndef prime (n)\n return true if n == 2\n (2..(Integer.sqrt(n)+1)).each do |i|\n return false if n % i == 0\n end\n true\nend\n\nif x == 2\n puts \"2\"\n exit 0\nend\n\nx += 1 if x % 2 == 0\nwhile true do\n break if prime (x)\n x +=2\nend\n\nputs x", "problem_context": "Score: 300 points\n\nProblem Statement\n\nFind the minimum prime number greater than or equal to X.\n\nNotes\n\nA prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself.\n\nFor example, 2, 3, and 5 are prime numbers, while 4 and 6 are not.\n\nConstraints\n\n2 \\le X \\le 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the minimum prime number greater than or equal to X.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n23\n\nThe minimum prime number greater than or equal to 20 is 23.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n2\n\nX itself can be a prime number.\n\nSample Input 3\n\n99992\n\nSample Output 3\n\n100003", "sample_input": "20\n"}, "reference_outputs": ["23\n"], "source_document_id": "p02819", "source_text": "Score: 300 points\n\nProblem Statement\n\nFind the minimum prime number greater than or equal to X.\n\nNotes\n\nA prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself.\n\nFor example, 2, 3, and 5 are prime numbers, while 4 and 6 are not.\n\nConstraints\n\n2 \\le X \\le 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the minimum prime number greater than or equal to X.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n23\n\nThe minimum prime number greater than or equal to 20 is 23.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n2\n\nX itself can be a prime number.\n\nSample Input 3\n\n99992\n\nSample Output 3\n\n100003", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 252, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s164438563", "group_id": "codeNet:p02821", "input_text": "def max(a,b); a > b ? a : b; end\n \nA_MAX = 100000\n\nN, M = gets.split.map(&:to_i)\nA = gets.split.map(&:to_i)\nC = Array.new(A_MAX + 10, 0) # C[x] := A.count{|a| a >= x }; C[x] - C[x + 1] := A.count{|a| a == x }\nS = Array.new(A_MAX + 10, 0) # S[x] := A.select{|a| a >= x }.sum\n\nA.each{|a| C[a] += 1 }\nA_MAX.downto(0) do |i| \n S[i] = C[i] * i + S[i + 1]\n C[i] += C[i + 1]\nend\n\nANS = {}\n\nxy_ = (1 .. 2 * A_MAX + 1).bsearch do |xy|\n m = 0\n s = 0\n A.each do |x|\n next if xy - x > A_MAX\n y = max(xy - x, 0)\n m += C[y]\n s += S[y] + C[y] * x\n end\n \n ANS[xy] = s + (M - m) * (xy - 1) if m <= M\n\n m <= M\nend\nputs ANS[xy_]\n", "language": "Ruby", "metadata": {"date": 1578424604, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02821.html", "problem_id": "p02821", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02821/input.txt", "sample_output_relpath": "derived/input_output/data/p02821/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02821/Ruby/s164438563.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s164438563", "user_id": "u627981707"}, "prompt_components": {"gold_output": "202\n", "input_to_evaluate": "def max(a,b); a > b ? a : b; end\n \nA_MAX = 100000\n\nN, M = gets.split.map(&:to_i)\nA = gets.split.map(&:to_i)\nC = Array.new(A_MAX + 10, 0) # C[x] := A.count{|a| a >= x }; C[x] - C[x + 1] := A.count{|a| a == x }\nS = Array.new(A_MAX + 10, 0) # S[x] := A.select{|a| a >= x }.sum\n\nA.each{|a| C[a] += 1 }\nA_MAX.downto(0) do |i| \n S[i] = C[i] * i + S[i + 1]\n C[i] += C[i + 1]\nend\n\nANS = {}\n\nxy_ = (1 .. 2 * A_MAX + 1).bsearch do |xy|\n m = 0\n s = 0\n A.each do |x|\n next if xy - x > A_MAX\n y = max(xy - x, 0)\n m += C[y]\n s += S[y] + C[y] * x\n end\n \n ANS[xy] = s + (M - m) * (xy - 1) if m <= M\n\n m <= M\nend\nputs ANS[xy_]\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi has come to a party as a special guest.\nThere are N ordinary guests at the party. The i-th ordinary guest has a power of A_i.\n\nTakahashi has decided to perform M handshakes to increase the happiness of the party (let the current happiness be 0).\nA handshake will be performed as follows:\n\nTakahashi chooses one (ordinary) guest x for his left hand and another guest y for his right hand (x and y can be the same).\n\nThen, he shakes the left hand of Guest x and the right hand of Guest y simultaneously to increase the happiness by A_x+A_y.\n\nHowever, Takahashi should not perform the same handshake more than once. Formally, the following condition must hold:\n\nAssume that, in the k-th handshake, Takahashi shakes the left hand of Guest x_k and the right hand of Guest y_k. Then, there is no pair p, q (1 \\leq p < q \\leq M) such that (x_p,y_p)=(x_q,y_q).\n\nWhat is the maximum possible happiness after M handshakes?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq N^2\n\n1 \\leq A_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible happiness after M handshakes.\n\nSample Input 1\n\n5 3\n10 14 19 34 33\n\nSample Output 1\n\n202\n\nLet us say that Takahashi performs the following handshakes:\n\nIn the first handshake, Takahashi shakes the left hand of Guest 4 and the right hand of Guest 4.\n\nIn the second handshake, Takahashi shakes the left hand of Guest 4 and the right hand of Guest 5.\n\nIn the third handshake, Takahashi shakes the left hand of Guest 5 and the right hand of Guest 4.\n\nThen, we will have the happiness of (34+34)+(34+33)+(33+34)=202.\n\nWe cannot achieve the happiness of 203 or greater, so the answer is 202.\n\nSample Input 2\n\n9 14\n1 3 5 110 24 21 34 5 3\n\nSample Output 2\n\n1837\n\nSample Input 3\n\n9 73\n67597 52981 5828 66249 75177 64141 40773 79105 16076\n\nSample Output 3\n\n8128170", "sample_input": "5 3\n10 14 19 34 33\n"}, "reference_outputs": ["202\n"], "source_document_id": "p02821", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi has come to a party as a special guest.\nThere are N ordinary guests at the party. The i-th ordinary guest has a power of A_i.\n\nTakahashi has decided to perform M handshakes to increase the happiness of the party (let the current happiness be 0).\nA handshake will be performed as follows:\n\nTakahashi chooses one (ordinary) guest x for his left hand and another guest y for his right hand (x and y can be the same).\n\nThen, he shakes the left hand of Guest x and the right hand of Guest y simultaneously to increase the happiness by A_x+A_y.\n\nHowever, Takahashi should not perform the same handshake more than once. Formally, the following condition must hold:\n\nAssume that, in the k-th handshake, Takahashi shakes the left hand of Guest x_k and the right hand of Guest y_k. Then, there is no pair p, q (1 \\leq p < q \\leq M) such that (x_p,y_p)=(x_q,y_q).\n\nWhat is the maximum possible happiness after M handshakes?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq N^2\n\n1 \\leq A_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible happiness after M handshakes.\n\nSample Input 1\n\n5 3\n10 14 19 34 33\n\nSample Output 1\n\n202\n\nLet us say that Takahashi performs the following handshakes:\n\nIn the first handshake, Takahashi shakes the left hand of Guest 4 and the right hand of Guest 4.\n\nIn the second handshake, Takahashi shakes the left hand of Guest 4 and the right hand of Guest 5.\n\nIn the third handshake, Takahashi shakes the left hand of Guest 5 and the right hand of Guest 4.\n\nThen, we will have the happiness of (34+34)+(34+33)+(33+34)=202.\n\nWe cannot achieve the happiness of 203 or greater, so the answer is 202.\n\nSample Input 2\n\n9 14\n1 3 5 110 24 21 34 5 3\n\nSample Output 2\n\n1837\n\nSample Input 3\n\n9 73\n67597 52981 5828 66249 75177 64141 40773 79105 16076\n\nSample Output 3\n\n8128170", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 632, "cpu_time_ms": 497, "memory_kb": 11660}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s449955287", "group_id": "codeNet:p02823", "input_text": "N, A, B = gets.chomp.split(\" \").map{|s| s.to_i }\n\nif (B - A) % 2 == 0\n puts (B - A) / 2\nelse\n diff = (B - A - 1) / 2\n puts [A, N-B+1].min + diff\nend", "language": "Ruby", "metadata": {"date": 1577588735, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s449955287.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s449955287", "user_id": "u771770008"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N, A, B = gets.chomp.split(\" \").map{|s| s.to_i }\n\nif (B - A) % 2 == 0\n puts (B - A) / 2\nelse\n diff = (B - A - 1) / 2\n puts [A, N-B+1].min + diff\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\n2N players are running a competitive table tennis training on N tables numbered from 1 to N.\n\nThe training consists of rounds.\nIn each round, the players form N pairs, one pair per table.\nIn each pair, competitors play a match against each other.\nAs a result, one of them wins and the other one loses.\n\nThe winner of the match on table X plays on table X-1 in the next round,\nexcept for the winner of the match on table 1 who stays at table 1.\n\nSimilarly, the loser of the match on table X plays on table X+1 in the next round,\nexcept for the loser of the match on table N who stays at table N.\n\nTwo friends are playing their first round matches on distinct tables A and B.\nLet's assume that the friends are strong enough to win or lose any match at will.\nWhat is the smallest number of rounds after which the friends can get to play a match against each other?\n\nConstraints\n\n2 \\leq N \\leq 10^{18}\n\n1 \\leq A < B \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the smallest number of rounds after which the friends can get to play a match against each other.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n1\n\nIf the first friend loses their match and the second friend wins their match, they will both move to table 3 and play each other in the next round.\n\nSample Input 2\n\n5 2 3\n\nSample Output 2\n\n2\n\nIf both friends win two matches in a row, they will both move to table 1.", "sample_input": "5 2 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02823", "source_text": "Score : 300 points\n\nProblem Statement\n\n2N players are running a competitive table tennis training on N tables numbered from 1 to N.\n\nThe training consists of rounds.\nIn each round, the players form N pairs, one pair per table.\nIn each pair, competitors play a match against each other.\nAs a result, one of them wins and the other one loses.\n\nThe winner of the match on table X plays on table X-1 in the next round,\nexcept for the winner of the match on table 1 who stays at table 1.\n\nSimilarly, the loser of the match on table X plays on table X+1 in the next round,\nexcept for the loser of the match on table N who stays at table N.\n\nTwo friends are playing their first round matches on distinct tables A and B.\nLet's assume that the friends are strong enough to win or lose any match at will.\nWhat is the smallest number of rounds after which the friends can get to play a match against each other?\n\nConstraints\n\n2 \\leq N \\leq 10^{18}\n\n1 \\leq A < B \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the smallest number of rounds after which the friends can get to play a match against each other.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n1\n\nIf the first friend loses their match and the second friend wins their match, they will both move to table 3 and play each other in the next round.\n\nSample Input 2\n\n5 2 3\n\nSample Output 2\n\n2\n\nIf both friends win two matches in a row, they will both move to table 1.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 151, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s870376979", "group_id": "codeNet:p02824", "input_text": "N,M,V,P = gets.split(' ').map(&:to_i)\nA = gets.split(' ').map(&:to_i).sort\n\nrequire 'pp'\nPP.pp [N,M,V,P], STDERR\nPP.pp A, STDERR\ndef check a\n return true if a >= A[-P]\n return false if A[-P] > a + M\n if V <= P\n return A[-P] <= a + M\n end\n\n point = (V-P) * M\n skip_self = false\n A[0,A.size - P].each do |aa|\n if aa == a && !skip_self\n skip_self = true\n next\n end\n if aa <= a\n point -= M\n elsif aa > a && (a+M) > aa\n point -= (a+M-aa)\n end\n return true if point <= 0\n end\n return true if point <= 0\n return point <= 0\nend\nline = A.bsearch{|a| check a }\nputs A.find_all{|a| a >= line}.size", "language": "Ruby", "metadata": {"date": 1577743217, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02824.html", "problem_id": "p02824", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02824/input.txt", "sample_output_relpath": "derived/input_output/data/p02824/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02824/Ruby/s870376979.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s870376979", "user_id": "u299761130"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "N,M,V,P = gets.split(' ').map(&:to_i)\nA = gets.split(' ').map(&:to_i).sort\n\nrequire 'pp'\nPP.pp [N,M,V,P], STDERR\nPP.pp A, STDERR\ndef check a\n return true if a >= A[-P]\n return false if A[-P] > a + M\n if V <= P\n return A[-P] <= a + M\n end\n\n point = (V-P) * M\n skip_self = false\n A[0,A.size - P].each do |aa|\n if aa == a && !skip_self\n skip_self = true\n next\n end\n if aa <= a\n point -= M\n elsif aa > a && (a+M) > aa\n point -= (a+M-aa)\n end\n return true if point <= 0\n end\n return true if point <= 0\n return point <= 0\nend\nline = A.bsearch{|a| check a }\nputs A.find_all{|a| a >= line}.size", "problem_context": "Score : 700 points\n\nProblem Statement\n\nN problems are proposed for an upcoming contest. Problem i has an initial integer score of A_i points.\n\nM judges are about to vote for problems they like. Each judge will choose exactly V problems, independently from the other judges,\nand increase the score of each chosen problem by 1.\n\nAfter all M judges cast their vote, the problems will be sorted in non-increasing order of score, and the first P problems will be chosen for the problemset.\nProblems with the same score can be ordered arbitrarily, this order is decided by the chief judge.\n\nHow many problems out of the given N have a chance to be chosen for the problemset?\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le M \\le 10^9\n\n1 \\le V \\le N - 1\n\n1 \\le P \\le N - 1\n\n0 \\le A_i \\le 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M V P\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of problems that have a chance to be chosen for the problemset.\n\nSample Input 1\n\n6 1 2 2\n2 1 1 3 0 2\n\nSample Output 1\n\n5\n\nIf the only judge votes for problems 2 and 5, the scores will be 2 2 1 3 1 2.\nThe problemset will consist of problem 4 and one of problems 1, 2, or 6.\n\nIf the only judge votes for problems 3 and 4, the scores will be 2 1 2 4 0 2.\nThe problemset will consist of problem 4 and one of problems 1, 3, or 6.\n\nThus, problems 1, 2, 3, 4, and 6 have a chance to be chosen for the problemset. On the contrary, there is no way for problem 5 to be chosen.\n\nSample Input 2\n\n6 1 5 2\n2 1 1 3 0 2\n\nSample Output 2\n\n3\n\nOnly problems 1, 4, and 6 have a chance to be chosen.\n\nSample Input 3\n\n10 4 8 5\n7 2 3 6 1 6 5 4 6 5\n\nSample Output 3\n\n8", "sample_input": "6 1 2 2\n2 1 1 3 0 2\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02824", "source_text": "Score : 700 points\n\nProblem Statement\n\nN problems are proposed for an upcoming contest. Problem i has an initial integer score of A_i points.\n\nM judges are about to vote for problems they like. Each judge will choose exactly V problems, independently from the other judges,\nand increase the score of each chosen problem by 1.\n\nAfter all M judges cast their vote, the problems will be sorted in non-increasing order of score, and the first P problems will be chosen for the problemset.\nProblems with the same score can be ordered arbitrarily, this order is decided by the chief judge.\n\nHow many problems out of the given N have a chance to be chosen for the problemset?\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le M \\le 10^9\n\n1 \\le V \\le N - 1\n\n1 \\le P \\le N - 1\n\n0 \\le A_i \\le 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M V P\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of problems that have a chance to be chosen for the problemset.\n\nSample Input 1\n\n6 1 2 2\n2 1 1 3 0 2\n\nSample Output 1\n\n5\n\nIf the only judge votes for problems 2 and 5, the scores will be 2 2 1 3 1 2.\nThe problemset will consist of problem 4 and one of problems 1, 2, or 6.\n\nIf the only judge votes for problems 3 and 4, the scores will be 2 1 2 4 0 2.\nThe problemset will consist of problem 4 and one of problems 1, 3, or 6.\n\nThus, problems 1, 2, 3, 4, and 6 have a chance to be chosen for the problemset. On the contrary, there is no way for problem 5 to be chosen.\n\nSample Input 2\n\n6 1 5 2\n2 1 1 3 0 2\n\nSample Output 2\n\n3\n\nOnly problems 1, 4, and 6 have a chance to be chosen.\n\nSample Input 3\n\n10 4 8 5\n7 2 3 6 1 6 5 4 6 5\n\nSample Output 3\n\n8", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1205, "memory_kb": 13456}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s795720220", "group_id": "codeNet:p02830", "input_text": "len = gets.to_i\ns, t = gets.chomp.split\n\nnew_s = \"\"\nlen.times do |i|\n new_s << s[i] << t[i]\nend\nputs new_s\n", "language": "Ruby", "metadata": {"date": 1577289219, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s795720220.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s795720220", "user_id": "u917013605"}, "prompt_components": {"gold_output": "icpc\n", "input_to_evaluate": "len = gets.to_i\ns, t = gets.chomp.split\n\nnew_s = \"\"\nlen.times do |i|\n new_s << s[i] << t[i]\nend\nputs new_s\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": 110, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s296595255", "group_id": "codeNet:p02831", "input_text": "a, b = gets.chomp.split(' ').map(&:to_i)\nputs a.lcm(b)", "language": "Ruby", "metadata": {"date": 1586400886, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s296595255.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s296595255", "user_id": "u882179152"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "a, b = gets.chomp.split(' ').map(&:to_i)\nputs a.lcm(b)", "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": 54, "cpu_time_ms": 7, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s063987855", "group_id": "codeNet:p02832", "input_text": "n = gets.to_i\nlist = gets.split.map(&:to_i)\n\ncount = 0\nlist.each do |a|\n count += 1 if a == count+1\nend\n\nif count == 0\n count = -1\nend\n\nputs n-count\n", "language": "Ruby", "metadata": {"date": 1585629622, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02832.html", "problem_id": "p02832", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02832/input.txt", "sample_output_relpath": "derived/input_output/data/p02832/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02832/Ruby/s063987855.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s063987855", "user_id": "u487252913"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n = gets.to_i\nlist = gets.split.map(&:to_i)\n\ncount = 0\nlist.each do |a|\n count += 1 if a == count+1\nend\n\nif count == 0\n count = -1\nend\n\nputs n-count\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N bricks arranged in a row from left to right.\n\nThe i-th brick from the left (1 \\leq i \\leq N) has an integer a_i written on it.\n\nAmong them, you can break at most N-1 bricks of your choice.\n\nLet us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \\leq i \\leq K), the i-th of those brick from the left has the integer i written on it.\n\nFind the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print -1 instead.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 200000\n\n1 \\leq a_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print -1 if his desire is unsatisfiable.\n\nSample Input 1\n\n3\n2 1 2\n\nSample Output 1\n\n1\n\nIf we break the leftmost brick, the remaining bricks have integers 1 and 2 written on them from left to right, in which case Snuke will be satisfied.\n\nSample Input 2\n\n3\n2 2 2\n\nSample Output 2\n\n-1\n\nIn this case, there is no way to break some of the bricks to satisfy Snuke's desire.\n\nSample Input 3\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n7\n\nSample Input 4\n\n1\n1\n\nSample Output 4\n\n0\n\nThere may be no need to break the bricks at all.", "sample_input": "3\n2 1 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02832", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N bricks arranged in a row from left to right.\n\nThe i-th brick from the left (1 \\leq i \\leq N) has an integer a_i written on it.\n\nAmong them, you can break at most N-1 bricks of your choice.\n\nLet us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \\leq i \\leq K), the i-th of those brick from the left has the integer i written on it.\n\nFind the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print -1 instead.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 200000\n\n1 \\leq a_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print -1 if his desire is unsatisfiable.\n\nSample Input 1\n\n3\n2 1 2\n\nSample Output 1\n\n1\n\nIf we break the leftmost brick, the remaining bricks have integers 1 and 2 written on them from left to right, in which case Snuke will be satisfied.\n\nSample Input 2\n\n3\n2 2 2\n\nSample Output 2\n\n-1\n\nIn this case, there is no way to break some of the bricks to satisfy Snuke's desire.\n\nSample Input 3\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n7\n\nSample Input 4\n\n1\n1\n\nSample Output 4\n\n0\n\nThere may be no need to break the bricks at all.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 151, "cpu_time_ms": 97, "memory_kb": 15364}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s187751327", "group_id": "codeNet:p02832", "input_text": "N = gets.to_i\na = gets.split.map(&:to_i)\n\ni = 1\na.each do |j|\n i += 1 if j == i\nend\n\nputs i == 1 ? -1 : N - i + 1", "language": "Ruby", "metadata": {"date": 1583884001, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02832.html", "problem_id": "p02832", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02832/input.txt", "sample_output_relpath": "derived/input_output/data/p02832/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02832/Ruby/s187751327.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s187751327", "user_id": "u104886851"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N = gets.to_i\na = gets.split.map(&:to_i)\n\ni = 1\na.each do |j|\n i += 1 if j == i\nend\n\nputs i == 1 ? -1 : N - i + 1", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N bricks arranged in a row from left to right.\n\nThe i-th brick from the left (1 \\leq i \\leq N) has an integer a_i written on it.\n\nAmong them, you can break at most N-1 bricks of your choice.\n\nLet us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \\leq i \\leq K), the i-th of those brick from the left has the integer i written on it.\n\nFind the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print -1 instead.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 200000\n\n1 \\leq a_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print -1 if his desire is unsatisfiable.\n\nSample Input 1\n\n3\n2 1 2\n\nSample Output 1\n\n1\n\nIf we break the leftmost brick, the remaining bricks have integers 1 and 2 written on them from left to right, in which case Snuke will be satisfied.\n\nSample Input 2\n\n3\n2 2 2\n\nSample Output 2\n\n-1\n\nIn this case, there is no way to break some of the bricks to satisfy Snuke's desire.\n\nSample Input 3\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n7\n\nSample Input 4\n\n1\n1\n\nSample Output 4\n\n0\n\nThere may be no need to break the bricks at all.", "sample_input": "3\n2 1 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02832", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N bricks arranged in a row from left to right.\n\nThe i-th brick from the left (1 \\leq i \\leq N) has an integer a_i written on it.\n\nAmong them, you can break at most N-1 bricks of your choice.\n\nLet us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \\leq i \\leq K), the i-th of those brick from the left has the integer i written on it.\n\nFind the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print -1 instead.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 200000\n\n1 \\leq a_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print -1 if his desire is unsatisfiable.\n\nSample Input 1\n\n3\n2 1 2\n\nSample Output 1\n\n1\n\nIf we break the leftmost brick, the remaining bricks have integers 1 and 2 written on them from left to right, in which case Snuke will be satisfied.\n\nSample Input 2\n\n3\n2 2 2\n\nSample Output 2\n\n-1\n\nIn this case, there is no way to break some of the bricks to satisfy Snuke's desire.\n\nSample Input 3\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n7\n\nSample Input 4\n\n1\n1\n\nSample Output 4\n\n0\n\nThere may be no need to break the bricks at all.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 114, "cpu_time_ms": 97, "memory_kb": 17284}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s607147630", "group_id": "codeNet:p02832", "input_text": "n = gets.to_i\nlist = gets.split.map(&:to_i)\ncount = 0\ni = 1\nwhile list.length > 0 do\n pos = list.index(i)\n if i == 1 && pos.nil?\n count = -1\n break\n end\n break if pos.nil?\n if pos == 0\n i += 1\n next\n else\n break if list.length < pos + 1\n list.shift(pos + 1)\n count += pos\n i += 1\n end\n\nend\n\nputs count\n", "language": "Ruby", "metadata": {"date": 1577072361, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02832.html", "problem_id": "p02832", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02832/input.txt", "sample_output_relpath": "derived/input_output/data/p02832/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02832/Ruby/s607147630.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s607147630", "user_id": "u751934765"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n = gets.to_i\nlist = gets.split.map(&:to_i)\ncount = 0\ni = 1\nwhile list.length > 0 do\n pos = list.index(i)\n if i == 1 && pos.nil?\n count = -1\n break\n end\n break if pos.nil?\n if pos == 0\n i += 1\n next\n else\n break if list.length < pos + 1\n list.shift(pos + 1)\n count += pos\n i += 1\n end\n\nend\n\nputs count\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N bricks arranged in a row from left to right.\n\nThe i-th brick from the left (1 \\leq i \\leq N) has an integer a_i written on it.\n\nAmong them, you can break at most N-1 bricks of your choice.\n\nLet us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \\leq i \\leq K), the i-th of those brick from the left has the integer i written on it.\n\nFind the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print -1 instead.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 200000\n\n1 \\leq a_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print -1 if his desire is unsatisfiable.\n\nSample Input 1\n\n3\n2 1 2\n\nSample Output 1\n\n1\n\nIf we break the leftmost brick, the remaining bricks have integers 1 and 2 written on them from left to right, in which case Snuke will be satisfied.\n\nSample Input 2\n\n3\n2 2 2\n\nSample Output 2\n\n-1\n\nIn this case, there is no way to break some of the bricks to satisfy Snuke's desire.\n\nSample Input 3\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n7\n\nSample Input 4\n\n1\n1\n\nSample Output 4\n\n0\n\nThere may be no need to break the bricks at all.", "sample_input": "3\n2 1 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02832", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N bricks arranged in a row from left to right.\n\nThe i-th brick from the left (1 \\leq i \\leq N) has an integer a_i written on it.\n\nAmong them, you can break at most N-1 bricks of your choice.\n\nLet us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \\leq i \\leq K), the i-th of those brick from the left has the integer i written on it.\n\nFind the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print -1 instead.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 200000\n\n1 \\leq a_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print -1 if his desire is unsatisfiable.\n\nSample Input 1\n\n3\n2 1 2\n\nSample Output 1\n\n1\n\nIf we break the leftmost brick, the remaining bricks have integers 1 and 2 written on them from left to right, in which case Snuke will be satisfied.\n\nSample Input 2\n\n3\n2 2 2\n\nSample Output 2\n\n-1\n\nIn this case, there is no way to break some of the bricks to satisfy Snuke's desire.\n\nSample Input 3\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n7\n\nSample Input 4\n\n1\n1\n\nSample Output 4\n\n0\n\nThere may be no need to break the bricks at all.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 333, "cpu_time_ms": 130, "memory_kb": 19212}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s220918597", "group_id": "codeNet:p02835", "input_text": "a1, a2, a3 = gets.split.map(&:to_i)\n\nif a1+a2+a3 >= 22\n puts \"bust\"\nelse\n puts \"win\"\nend\n", "language": "Ruby", "metadata": {"date": 1585727949, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s220918597.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s220918597", "user_id": "u487252913"}, "prompt_components": {"gold_output": "win\n", "input_to_evaluate": "a1, a2, a3 = gets.split.map(&:to_i)\n\nif a1+a2+a3 >= 22\n puts \"bust\"\nelse\n puts \"win\"\nend\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": 91, "cpu_time_ms": 7, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s609910025", "group_id": "codeNet:p02835", "input_text": "a=gets.chomp.split.map(&:to_i).inject(:+)\nputs a >= 22 ? 'bust' : 'win'", "language": "Ruby", "metadata": {"date": 1575858169, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s609910025.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s609910025", "user_id": "u525844030"}, "prompt_components": {"gold_output": "win\n", "input_to_evaluate": "a=gets.chomp.split.map(&:to_i).inject(:+)\nputs a >= 22 ? 'bust' : 'win'", "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": 71, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s227794651", "group_id": "codeNet:p02835", "input_text": "a, b, c = STDIN.read.each_line.first.split(' ').map(&:to_i)\n\nputs(a + b + c >= 22 ? 'bust' : 'win')\n", "language": "Ruby", "metadata": {"date": 1575857138, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s227794651.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s227794651", "user_id": "u931677214"}, "prompt_components": {"gold_output": "win\n", "input_to_evaluate": "a, b, c = STDIN.read.each_line.first.split(' ').map(&:to_i)\n\nputs(a + b + c >= 22 ? 'bust' : 'win')\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven are three integers A_1, A_2, and A_3.\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nConstraints\n\n1 \\leq A_i \\leq 13 \\ \\ (i=1,2,3)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nSample Input 1\n\n5 7 9\n\nSample Output 1\n\nwin\n\n5+7+9=21, so print win.\n\nSample Input 2\n\n13 7 2\n\nSample Output 2\n\nbust\n\n13+7+2=22, so print bust.", "sample_input": "5 7 9\n"}, "reference_outputs": ["win\n"], "source_document_id": "p02835", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven are three integers A_1, A_2, and A_3.\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nConstraints\n\n1 \\leq A_i \\leq 13 \\ \\ (i=1,2,3)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nSample Input 1\n\n5 7 9\n\nSample Output 1\n\nwin\n\n5+7+9=21, so print win.\n\nSample Input 2\n\n13 7 2\n\nSample Output 2\n\nbust\n\n13+7+2=22, so print bust.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 100, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s004917089", "group_id": "codeNet:p02835", "input_text": "a = gets.split.map(&:to_i).inject(:+)\nputs (a > 21 ? \"bust\" : \"win\")", "language": "Ruby", "metadata": {"date": 1575856923, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s004917089.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s004917089", "user_id": "u506255180"}, "prompt_components": {"gold_output": "win\n", "input_to_evaluate": "a = gets.split.map(&:to_i).inject(:+)\nputs (a > 21 ? \"bust\" : \"win\")", "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": 68, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s141982258", "group_id": "codeNet:p02836", "input_text": "s = gets.chomp.split(\"\")\nsize = s.size\ncount = 0\nif size % 2 == 0\n until s == []\n if s.pop != s.shift\n count += 1\n end\n end\nelse\n until s.size == 1\n if s.pop != s.shift\n count += 1\n end\n end \nend\nputs count", "language": "Ruby", "metadata": {"date": 1594312347, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s141982258.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s141982258", "user_id": "u412789323"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "s = gets.chomp.split(\"\")\nsize = s.size\ncount = 0\nif size % 2 == 0\n until s == []\n if s.pop != s.shift\n count += 1\n end\n end\nelse\n until s.size == 1\n if s.pop != s.shift\n count += 1\n end\n end \nend\nputs count", "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": 268, "cpu_time_ms": 69, "memory_kb": 14308}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s949408496", "group_id": "codeNet:p02837", "input_text": "require 'set'\nN = gets.to_i\n\ntuples = N.times.flat_map.with_index(1) { |_, id|\n gets.to_i.times.map {\n other, b = gets.chomp.split(' ').map(&:to_i)\n [id, other, b]\n }\n}\n\nliars = Set.new\nsemi_liars = {}\n\ntuples.each do |(id, other, b)|\n if b == 1 && tuples.include?([other, id, 0])\n liars << id\n end\nend\n\ntuples.each do |(id, other, b)|\n if b == 0 && !tuples.include?([other, id, 1])\n unless liars.include?(other)\n semi_liars[id] ||= Set.new\n semi_liars[id] << other\n end\n\n unless liars.include?(id)\n semi_liars[other] ||= Set.new\n semi_liars[other] << id\n end\n end\nend\n\nsemi_liars.sort_by { |_, v| v.size }.reverse.each do |id, others|\n next unless semi_liars.has_key?(id)\n\n layers << id\n semi_liars.delete(id)\n\n others.each do |other|\n semi_liars.delete(other)\n end\nend\n\nputs N - liars.size\n", "language": "Ruby", "metadata": {"date": 1576093486, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02837.html", "problem_id": "p02837", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02837/input.txt", "sample_output_relpath": "derived/input_output/data/p02837/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02837/Ruby/s949408496.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s949408496", "user_id": "u765478029"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "require 'set'\nN = gets.to_i\n\ntuples = N.times.flat_map.with_index(1) { |_, id|\n gets.to_i.times.map {\n other, b = gets.chomp.split(' ').map(&:to_i)\n [id, other, b]\n }\n}\n\nliars = Set.new\nsemi_liars = {}\n\ntuples.each do |(id, other, b)|\n if b == 1 && tuples.include?([other, id, 0])\n liars << id\n end\nend\n\ntuples.each do |(id, other, b)|\n if b == 0 && !tuples.include?([other, id, 1])\n unless liars.include?(other)\n semi_liars[id] ||= Set.new\n semi_liars[id] << other\n end\n\n unless liars.include?(id)\n semi_liars[other] ||= Set.new\n semi_liars[other] << id\n end\n end\nend\n\nsemi_liars.sort_by { |_, v| v.size }.reverse.each do |id, others|\n next unless semi_liars.has_key?(id)\n\n layers << id\n semi_liars.delete(id)\n\n others.each do |other|\n semi_liars.delete(other)\n end\nend\n\nputs N - liars.size\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each of them is either an honest person whose testimonies are always correct or an unkind person whose testimonies may be correct or not.\n\nPerson i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.\n\nHow many honest persons can be among those N people at most?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 15\n\n0 \\leq A_i \\leq N - 1\n\n1 \\leq x_{ij} \\leq N\n\nx_{ij} \\neq i\n\nx_{ij_1} \\neq x_{ij_2} (j_1 \\neq j_2)\n\ny_{ij} = 0, 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\nx_{11} y_{11}\nx_{12} y_{12}\n:\nx_{1A_1} y_{1A_1}\nA_2\nx_{21} y_{21}\nx_{22} y_{22}\n:\nx_{2A_2} y_{2A_2}\n:\nA_N\nx_{N1} y_{N1}\nx_{N2} y_{N2}\n:\nx_{NA_N} y_{NA_N}\n\nOutput\n\nPrint the maximum possible number of honest persons among the N people.\n\nSample Input 1\n\n3\n1\n2 1\n1\n1 1\n1\n2 0\n\nSample Output 1\n\n2\n\nIf Person 1 and Person 2 are honest and Person 3 is unkind, we have two honest persons without inconsistencies, which is the maximum possible number of honest persons.\n\nSample Input 2\n\n3\n2\n2 1\n3 0\n2\n3 1\n1 0\n2\n1 1\n2 0\n\nSample Output 2\n\n0\n\nAssuming that one or more of them are honest immediately leads to a contradiction.\n\nSample Input 3\n\n2\n1\n2 0\n1\n1 0\n\nSample Output 3\n\n1", "sample_input": "3\n1\n2 1\n1\n1 1\n1\n2 0\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02837", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each of them is either an honest person whose testimonies are always correct or an unkind person whose testimonies may be correct or not.\n\nPerson i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.\n\nHow many honest persons can be among those N people at most?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 15\n\n0 \\leq A_i \\leq N - 1\n\n1 \\leq x_{ij} \\leq N\n\nx_{ij} \\neq i\n\nx_{ij_1} \\neq x_{ij_2} (j_1 \\neq j_2)\n\ny_{ij} = 0, 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\nx_{11} y_{11}\nx_{12} y_{12}\n:\nx_{1A_1} y_{1A_1}\nA_2\nx_{21} y_{21}\nx_{22} y_{22}\n:\nx_{2A_2} y_{2A_2}\n:\nA_N\nx_{N1} y_{N1}\nx_{N2} y_{N2}\n:\nx_{NA_N} y_{NA_N}\n\nOutput\n\nPrint the maximum possible number of honest persons among the N people.\n\nSample Input 1\n\n3\n1\n2 1\n1\n1 1\n1\n2 0\n\nSample Output 1\n\n2\n\nIf Person 1 and Person 2 are honest and Person 3 is unkind, we have two honest persons without inconsistencies, which is the maximum possible number of honest persons.\n\nSample Input 2\n\n3\n2\n2 1\n3 0\n2\n3 1\n1 0\n2\n1 1\n2 0\n\nSample Output 2\n\n0\n\nAssuming that one or more of them are honest immediately leads to a contradiction.\n\nSample Input 3\n\n2\n1\n2 0\n1\n1 0\n\nSample Output 3\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 847, "cpu_time_ms": 23, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s463894069", "group_id": "codeNet:p02837", "input_text": "N=gets.to_i\nas=Array.new(N)\nds=Array.new(N){Array.new(N,false)}\nN.times do |i|\n as[i]=gets.to_i\n as[i].times do |j|\n e,f=gets.split.map(&:to_i)\n ds[i][e-1]=f\n end\nend\n\nans=0\n(1< 1\n s.slice!(0)\n end\n new += s\nend\nputs new\n", "language": "Ruby", "metadata": {"date": 1574649218, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02848.html", "problem_id": "p02848", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02848/input.txt", "sample_output_relpath": "derived/input_output/data/p02848/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02848/Ruby/s364915787.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s364915787", "user_id": "u751934765"}, "prompt_components": {"gold_output": "CDEZAB\n", "input_to_evaluate": "n = gets.to_i\ninputs = gets.chomp.split('')\nnew = ''\ninputs.each do |s|\n i = 0\n while i < n do\n s = s.next\n i += 1\n end\n if s.length > 1\n s.slice!(0)\n end\n new += s\nend\nputs new\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a string S consisting of uppercase English letters. Additionally, an integer N will be given.\n\nShift each character of S by N in alphabetical order (see below), and print the resulting string.\n\nWe assume that A follows Z. For example, shifting A by 2 results in C (A \\to B \\to C), and shifting Y by 3 results in B (Y \\to Z \\to A \\to B).\n\nConstraints\n\n0 \\leq N \\leq 26\n\n1 \\leq |S| \\leq 10^4\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the string resulting from shifting each character of S by N in alphabetical order.\n\nSample Input 1\n\n2\nABCXYZ\n\nSample Output 1\n\nCDEZAB\n\nNote that A follows Z.\n\nSample Input 2\n\n0\nABCXYZ\n\nSample Output 2\n\nABCXYZ\n\nSample Input 3\n\n13\nABCDEFGHIJKLMNOPQRSTUVWXYZ\n\nSample Output 3\n\nNOPQRSTUVWXYZABCDEFGHIJKLM", "sample_input": "2\nABCXYZ\n"}, "reference_outputs": ["CDEZAB\n"], "source_document_id": "p02848", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a string S consisting of uppercase English letters. Additionally, an integer N will be given.\n\nShift each character of S by N in alphabetical order (see below), and print the resulting string.\n\nWe assume that A follows Z. For example, shifting A by 2 results in C (A \\to B \\to C), and shifting Y by 3 results in B (Y \\to Z \\to A \\to B).\n\nConstraints\n\n0 \\leq N \\leq 26\n\n1 \\leq |S| \\leq 10^4\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the string resulting from shifting each character of S by N in alphabetical order.\n\nSample Input 1\n\n2\nABCXYZ\n\nSample Output 1\n\nCDEZAB\n\nNote that A follows Z.\n\nSample Input 2\n\n0\nABCXYZ\n\nSample Output 2\n\nABCXYZ\n\nSample Input 3\n\n13\nABCDEFGHIJKLMNOPQRSTUVWXYZ\n\nSample Output 3\n\nNOPQRSTUVWXYZABCDEFGHIJKLM", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 193, "cpu_time_ms": 72, "memory_kb": 19196}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s007697914", "group_id": "codeNet:p02848", "input_text": "def lscan; gets.split.map(&:to_i); end\naa = ('A'..'Z').to_a\nn = gets.to_i\nputs gets.chomp.chars.map{|c| aa[aa.index(c)-26+n]}*''", "language": "Ruby", "metadata": {"date": 1574647536, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02848.html", "problem_id": "p02848", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02848/input.txt", "sample_output_relpath": "derived/input_output/data/p02848/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02848/Ruby/s007697914.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s007697914", "user_id": "u079330987"}, "prompt_components": {"gold_output": "CDEZAB\n", "input_to_evaluate": "def lscan; gets.split.map(&:to_i); end\naa = ('A'..'Z').to_a\nn = gets.to_i\nputs gets.chomp.chars.map{|c| aa[aa.index(c)-26+n]}*''", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a string S consisting of uppercase English letters. Additionally, an integer N will be given.\n\nShift each character of S by N in alphabetical order (see below), and print the resulting string.\n\nWe assume that A follows Z. For example, shifting A by 2 results in C (A \\to B \\to C), and shifting Y by 3 results in B (Y \\to Z \\to A \\to B).\n\nConstraints\n\n0 \\leq N \\leq 26\n\n1 \\leq |S| \\leq 10^4\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the string resulting from shifting each character of S by N in alphabetical order.\n\nSample Input 1\n\n2\nABCXYZ\n\nSample Output 1\n\nCDEZAB\n\nNote that A follows Z.\n\nSample Input 2\n\n0\nABCXYZ\n\nSample Output 2\n\nABCXYZ\n\nSample Input 3\n\n13\nABCDEFGHIJKLMNOPQRSTUVWXYZ\n\nSample Output 3\n\nNOPQRSTUVWXYZABCDEFGHIJKLM", "sample_input": "2\nABCXYZ\n"}, "reference_outputs": ["CDEZAB\n"], "source_document_id": "p02848", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a string S consisting of uppercase English letters. Additionally, an integer N will be given.\n\nShift each character of S by N in alphabetical order (see below), and print the resulting string.\n\nWe assume that A follows Z. For example, shifting A by 2 results in C (A \\to B \\to C), and shifting Y by 3 results in B (Y \\to Z \\to A \\to B).\n\nConstraints\n\n0 \\leq N \\leq 26\n\n1 \\leq |S| \\leq 10^4\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the string resulting from shifting each character of S by N in alphabetical order.\n\nSample Input 1\n\n2\nABCXYZ\n\nSample Output 1\n\nCDEZAB\n\nNote that A follows Z.\n\nSample Input 2\n\n0\nABCXYZ\n\nSample Output 2\n\nABCXYZ\n\nSample Input 3\n\n13\nABCDEFGHIJKLMNOPQRSTUVWXYZ\n\nSample Output 3\n\nNOPQRSTUVWXYZABCDEFGHIJKLM", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 128, "cpu_time_ms": 14, "memory_kb": 2172}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s379148057", "group_id": "codeNet:p02852", "input_text": "N, M = gets.split.map(&:to_i)\nS = gets.chomp\nANS = []\n\nN.times.inject(N) do |pos,c|\n break if pos == 0\n k_ = M.downto(1).find do |k|\n pos - k >= 0 && S[pos - k] == '0'\n end\n if k_.nil?\n puts -1\n exit\n end\n ANS << k_\n pos - k_\nend\nputs ANS.reverse * ' '\n\n", "language": "Ruby", "metadata": {"date": 1574788487, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s379148057.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s379148057", "user_id": "u627981707"}, "prompt_components": {"gold_output": "1 3 2 3\n", "input_to_evaluate": "N, M = gets.split.map(&:to_i)\nS = gets.chomp\nANS = []\n\nN.times.inject(N) do |pos,c|\n break if pos == 0\n k_ = M.downto(1).find do |k|\n pos - k >= 0 && S[pos - k] == '0'\n end\n if k_.nil?\n puts -1\n exit\n end\n ANS << k_\n pos - k_\nend\nputs ANS.reverse * ' '\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": 270, "cpu_time_ms": 165, "memory_kb": 4092}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s023044586", "group_id": "codeNet:p02854", "input_text": "require 'pp'\n\nn = gets.chomp!.to_i\na_n = gets.chomp!.split(\" \").map(&:to_i)\n\nsum = a_n.inject(&:+)\n\nleft = [a_n[0]]\nright = [sum - a_n[0]]\nsum\n0.upto(n-2) do |i|\n left[i+1] = left[i] + a_n[i+1]\n right[i+1] = sum - left[i+1]\nend\n\nans = 10 ** 20\nleft.length.times do |i|\n t = (left[i] - right[i]).abs\n if t < ans\n ans = t\n end\nend\n\nputs ans\n", "language": "Ruby", "metadata": {"date": 1574561691, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02854.html", "problem_id": "p02854", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02854/input.txt", "sample_output_relpath": "derived/input_output/data/p02854/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02854/Ruby/s023044586.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s023044586", "user_id": "u754375546"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "require 'pp'\n\nn = gets.chomp!.to_i\na_n = gets.chomp!.split(\" \").map(&:to_i)\n\nsum = a_n.inject(&:+)\n\nleft = [a_n[0]]\nright = [sum - a_n[0]]\nsum\n0.upto(n-2) do |i|\n left[i+1] = left[i] + a_n[i+1]\n right[i+1] = sum - left[i+1]\nend\n\nans = 10 ** 20\nleft.length.times do |i|\n t = (left[i] - right[i]).abs\n if t < ans\n ans = t\n end\nend\n\nputs ans\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nTakahashi, who works at DISCO, is standing before an iron bar.\nThe bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters.\n\nTakahashi wanted to choose a notch and cut the bar at that point into two parts with the same length.\nHowever, this may not be possible as is, so he will do the following operations some number of times before he does the cut:\n\nChoose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan).\n\nChoose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen.\n\nFind the minimum amount of money needed before cutting the bar into two parts with the same length.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 2020202020\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 A_3 ... A_N\n\nOutput\n\nPrint an integer representing the minimum amount of money needed before cutting the bar into two parts with the same length.\n\nSample Input 1\n\n3\n2 4 3\n\nSample Output 1\n\n3\n\nThe initial lengths of the sections are [2, 4, 3] (in millimeters). Takahashi can cut the bar equally after doing the following operations for 3 yen:\n\nShrink the second section from the left. The lengths of the sections are now [2, 3, 3].\n\nShrink the first section from the left. The lengths of the sections are now [1, 3, 3].\n\nShrink the second section from the left. The lengths of the sections are now [1, 2, 3], and we can cut the bar at the second notch from the left into two parts of length 3 each.\n\nSample Input 2\n\n12\n100 104 102 105 103 103 101 105 104 102 104 101\n\nSample Output 2\n\n0", "sample_input": "3\n2 4 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02854", "source_text": "Score: 200 points\n\nProblem Statement\n\nTakahashi, who works at DISCO, is standing before an iron bar.\nThe bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters.\n\nTakahashi wanted to choose a notch and cut the bar at that point into two parts with the same length.\nHowever, this may not be possible as is, so he will do the following operations some number of times before he does the cut:\n\nChoose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan).\n\nChoose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen.\n\nFind the minimum amount of money needed before cutting the bar into two parts with the same length.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 2020202020\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 A_3 ... A_N\n\nOutput\n\nPrint an integer representing the minimum amount of money needed before cutting the bar into two parts with the same length.\n\nSample Input 1\n\n3\n2 4 3\n\nSample Output 1\n\n3\n\nThe initial lengths of the sections are [2, 4, 3] (in millimeters). Takahashi can cut the bar equally after doing the following operations for 3 yen:\n\nShrink the second section from the left. The lengths of the sections are now [2, 3, 3].\n\nShrink the first section from the left. The lengths of the sections are now [1, 3, 3].\n\nShrink the second section from the left. The lengths of the sections are now [1, 2, 3], and we can cut the bar at the second notch from the left into two parts of length 3 each.\n\nSample Input 2\n\n12\n100 104 102 105 103 103 101 105 104 102 104 101\n\nSample Output 2\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 361, "cpu_time_ms": 178, "memory_kb": 19656}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s667562046", "group_id": "codeNet:p02859", "input_text": "r = gets.to_i\nputs r ** 2", "language": "Ruby", "metadata": {"date": 1597782130, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s667562046.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s667562046", "user_id": "u295003004"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "r = gets.to_i\nputs r ** 2", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "sample_input": "2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02859", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 25, "cpu_time_ms": 66, "memory_kb": 14368}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s202340035", "group_id": "codeNet:p02860", "input_text": "n=gets.to_i\ns=gets.chomp\nif n.even? && s[0..n/2-1]==s[n/2..n-1]\n puts \"Yes\"\nelse\n puts \"No\"\nend\n", "language": "Ruby", "metadata": {"date": 1583387512, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s202340035.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s202340035", "user_id": "u602591412"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "n=gets.to_i\ns=gets.chomp\nif n.even? && s[0..n/2-1]==s[n/2..n-1]\n puts \"Yes\"\nelse\n puts \"No\"\nend\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": 98, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s439783714", "group_id": "codeNet:p02860", "input_text": "a = gets.to_i\nb = gets.to_s\n\n\nif a%2 == 0\n c = b.scan(/.{1,#{a/2}}/)\n if c[0] == c[1]\n answer = 'Yes'\n else\n answer = 'No'\n end\nelse\n answer = 'No'\nend\n\nputs answer\n", "language": "Ruby", "metadata": {"date": 1573956763, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s439783714.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s439783714", "user_id": "u973744316"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a = gets.to_i\nb = gets.to_s\n\n\nif a%2 == 0\n c = b.scan(/.{1,#{a/2}}/)\n if c[0] == c[1]\n answer = 'Yes'\n else\n answer = 'No'\n end\nelse\n answer = 'No'\nend\n\nputs answer\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": 176, "cpu_time_ms": 7, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s434183855", "group_id": "codeNet:p02861", "input_text": "n = gets.to_i\npoints = readlines.map{|s| s.split.map(&:to_i)}\n\ndef d(p1, p2)\n Math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2)\nend\n\ng = Array.new(n) {Array.new(n){0}}\n\n(0...n).each do |i|\n (0...n).each do |j|\n next if i == j\n g[i][j] = d(points[i], points[j])\n end\nend\n\nputs g.flatten.reduce(:+) / n", "language": "Ruby", "metadata": {"date": 1589256138, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02861.html", "problem_id": "p02861", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02861/input.txt", "sample_output_relpath": "derived/input_output/data/p02861/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02861/Ruby/s434183855.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s434183855", "user_id": "u173515518"}, "prompt_components": {"gold_output": "2.2761423749\n", "input_to_evaluate": "n = gets.to_i\npoints = readlines.map{|s| s.split.map(&:to_i)}\n\ndef d(p1, p2)\n Math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2)\nend\n\ng = Array.new(n) {Array.new(n){0}}\n\n(0...n).each do |i|\n (0...n).each do |j|\n next if i == j\n g[i][j] = d(points[i], points[j])\n end\nend\n\nputs g.flatten.reduce(:+) / n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N towns in a coordinate plane. Town i is located at coordinates (x_i, y_i). The distance between Town i and Town j is \\sqrt{\\left(x_i-x_j\\right)^2+\\left(y_i-y_j\\right)^2}.\n\nThere are N! possible paths to visit all of these towns once. Let the length of a path be the distance covered when we start at the first town in the path, visit the second, third, \\dots, towns, and arrive at the last town (assume that we travel in a straight line from a town to another). Compute the average length of these N! paths.\n\nConstraints\n\n2 \\leq N \\leq 8\n\n-1000 \\leq x_i \\leq 1000\n\n-1000 \\leq y_i \\leq 1000\n\n\\left(x_i, y_i\\right) \\neq \\left(x_j, y_j\\right) (if i \\neq j)\n\n(Added 21:12 JST) All values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint the average length of the paths.\nYour output will be judges as correct when the absolute difference from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n3\n0 0\n1 0\n0 1\n\nSample Output 1\n\n2.2761423749\n\nThere are six paths to visit the towns: 1 → 2 → 3, 1 → 3 → 2, 2 → 1 → 3, 2 → 3 → 1, 3 → 1 → 2, and 3 → 2 → 1.\n\nThe length of the path 1 → 2 → 3 is \\sqrt{\\left(0-1\\right)^2+\\left(0-0\\right)^2} + \\sqrt{\\left(1-0\\right)^2+\\left(0-1\\right)^2} = 1+\\sqrt{2}.\n\nBy calculating the lengths of the other paths in this way, we see that the average length of all routes is:\n\n\\frac{\\left(1+\\sqrt{2}\\right)+\\left(1+\\sqrt{2}\\right)+\\left(2\\right)+\\left(1+\\sqrt{2}\\right)+\\left(2\\right)+\\left(1+\\sqrt{2}\\right)}{6} = 2.276142...\n\nSample Input 2\n\n2\n-879 981\n-866 890\n\nSample Output 2\n\n91.9238815543\n\nThere are two paths to visit the towns: 1 → 2 and 2 → 1. These paths have the same length.\n\nSample Input 3\n\n8\n-406 10\n512 859\n494 362\n-955 -475\n128 553\n-986 -885\n763 77\n449 310\n\nSample Output 3\n\n7641.9817824387", "sample_input": "3\n0 0\n1 0\n0 1\n"}, "reference_outputs": ["2.2761423749\n"], "source_document_id": "p02861", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N towns in a coordinate plane. Town i is located at coordinates (x_i, y_i). The distance between Town i and Town j is \\sqrt{\\left(x_i-x_j\\right)^2+\\left(y_i-y_j\\right)^2}.\n\nThere are N! possible paths to visit all of these towns once. Let the length of a path be the distance covered when we start at the first town in the path, visit the second, third, \\dots, towns, and arrive at the last town (assume that we travel in a straight line from a town to another). Compute the average length of these N! paths.\n\nConstraints\n\n2 \\leq N \\leq 8\n\n-1000 \\leq x_i \\leq 1000\n\n-1000 \\leq y_i \\leq 1000\n\n\\left(x_i, y_i\\right) \\neq \\left(x_j, y_j\\right) (if i \\neq j)\n\n(Added 21:12 JST) All values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint the average length of the paths.\nYour output will be judges as correct when the absolute difference from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n3\n0 0\n1 0\n0 1\n\nSample Output 1\n\n2.2761423749\n\nThere are six paths to visit the towns: 1 → 2 → 3, 1 → 3 → 2, 2 → 1 → 3, 2 → 3 → 1, 3 → 1 → 2, and 3 → 2 → 1.\n\nThe length of the path 1 → 2 → 3 is \\sqrt{\\left(0-1\\right)^2+\\left(0-0\\right)^2} + \\sqrt{\\left(1-0\\right)^2+\\left(0-1\\right)^2} = 1+\\sqrt{2}.\n\nBy calculating the lengths of the other paths in this way, we see that the average length of all routes is:\n\n\\frac{\\left(1+\\sqrt{2}\\right)+\\left(1+\\sqrt{2}\\right)+\\left(2\\right)+\\left(1+\\sqrt{2}\\right)+\\left(2\\right)+\\left(1+\\sqrt{2}\\right)}{6} = 2.276142...\n\nSample Input 2\n\n2\n-879 981\n-866 890\n\nSample Output 2\n\n91.9238815543\n\nThere are two paths to visit the towns: 1 → 2 and 2 → 1. These paths have the same length.\n\nSample Input 3\n\n8\n-406 10\n512 859\n494 362\n-955 -475\n128 553\n-986 -885\n763 77\n449 310\n\nSample Output 3\n\n7641.9817824387", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 314, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s421453718", "group_id": "codeNet:p02862", "input_text": "MOD = (10**9) + 7\nONE = '1'.freeze\n \ndef nCk(n, k)\n (fact(k + 1, n) * inv(fact(1, n - k) % MOD)) % MOD\nend\n \ndef fact(s, e)\n (s..e).reduce(1) { |r, i| (r * i) % MOD }\nend\n \ndef inv(x)\n res = 1\n beki = x\n (MOD - 2).to_s(2).reverse.chars do |digest|\n res = (beki * res) % MOD if digest == ONE\n beki = (beki * beki) % MOD\n end\n res\nend\n\nX, Y = gets.split.map(&:to_i)\n\nif (X + Y) % 3 != 0\n puts 0\n exit\nend\n\nm = (2 * X - Y) / 3\nn = X - 2 * m\n\nif m < 0 || n < 0\n puts 0\n exit\nend\nputs nCk(n + m, n)", "language": "Ruby", "metadata": {"date": 1580699104, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02862.html", "problem_id": "p02862", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02862/input.txt", "sample_output_relpath": "derived/input_output/data/p02862/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02862/Ruby/s421453718.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s421453718", "user_id": "u562148988"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "MOD = (10**9) + 7\nONE = '1'.freeze\n \ndef nCk(n, k)\n (fact(k + 1, n) * inv(fact(1, n - k) % MOD)) % MOD\nend\n \ndef fact(s, e)\n (s..e).reduce(1) { |r, i| (r * i) % MOD }\nend\n \ndef inv(x)\n res = 1\n beki = x\n (MOD - 2).to_s(2).reverse.chars do |digest|\n res = (beki * res) % MOD if digest == ONE\n beki = (beki * beki) % MOD\n end\n res\nend\n\nX, Y = gets.split.map(&:to_i)\n\nif (X + Y) % 3 != 0\n puts 0\n exit\nend\n\nm = (2 * X - Y) / 3\nn = X - 2 * m\n\nif m < 0 || n < 0\n puts 0\n exit\nend\nputs nCk(n + m, n)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.\n\nWhen the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).\n\nIn how many ways can the knight reach the square (X, Y)?\n\nFind the number of ways modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq X \\leq 10^6\n\n1 \\leq Y \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\n2\n\nThere are two ways: (0,0) \\to (1,2) \\to (3,3) and (0,0) \\to (2,1) \\to (3,3).\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n0\n\nThe knight cannot reach (2,2).\n\nSample Input 3\n\n999999 999999\n\nSample Output 3\n\n151840682\n\nPrint the number of ways modulo 10^9 + 7.", "sample_input": "3 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02862", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.\n\nWhen the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).\n\nIn how many ways can the knight reach the square (X, Y)?\n\nFind the number of ways modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq X \\leq 10^6\n\n1 \\leq Y \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\n2\n\nThere are two ways: (0,0) \\to (1,2) \\to (3,3) and (0,0) \\to (2,1) \\to (3,3).\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n0\n\nThe knight cannot reach (2,2).\n\nSample Input 3\n\n999999 999999\n\nSample Output 3\n\n151840682\n\nPrint the number of ways modulo 10^9 + 7.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 510, "cpu_time_ms": 75, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s597575787", "group_id": "codeNet:p02862", "input_text": "MOD=10**9+7\ncnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)\ndef gs() gets.chomp end\ndef gi() gets.to_i end\ndef gsmi() gets.chomp.split.map(&:to_i) end\n\ndef desc(ar) ar.sort!{|x,y|y<=>x} end\ndef min(a,b) a<=b ? a : b end\ndef max(a,b) a>=b ? a : b end\ndef sum(ar) ar.inject(:+) end\n\n#def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2x} end\ndef min(a,b) a<=b ? a : b end\ndef max(a,b) a>=b ? a : b end\ndef sum(ar) ar.inject(:+) end\n\n#def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2a,b{b>0?a**b[0]*f[a,b/2]**2%m:1}\nD.map{|d|A[d]+=1}\ns=q=1\nA.map{|a|s=s*f[q,q=a]%m}\np A[0]==1&&D[0]==0?s:0", "language": "Ruby", "metadata": {"date": 1573358006, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s187625915.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s187625915", "user_id": "u657913472"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "eval\"N,*D=\"+`dd`.split*?,\nA=[0]*N\nm=998244353\nf=->a,b{b>0?a**b[0]*f[a,b/2]**2%m:1}\nD.map{|d|A[d]+=1}\ns=q=1\nA.map{|a|s=s*f[q,q=a]%m}\np A[0]==1&&D[0]==0?s:0", "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": 154, "cpu_time_ms": 131, "memory_kb": 22620}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s867897502", "group_id": "codeNet:p02866", "input_text": "n = gets.chomp.to_i\nd = gets.chomp.split(' ').map(&:to_i)\n\nunless d[0].zero?\n puts 0\n exit\nend\n\ncounts = Array.new(d.max + 1, 0)\nd.each do |di|\n counts[di] += 1\nend\n\nsum = 1\ncounts.each_cons(2) do |ai, aj|\n if ai.zero? && !aj.zero?\n puts 0\n exit\n elsif !aj.zero?\n sum = (sum * ai ** aj) % 998244353\n end\nend\nputs sum\n", "language": "Ruby", "metadata": {"date": 1573353670, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s867897502.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s867897502", "user_id": "u484832756"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n = gets.chomp.to_i\nd = gets.chomp.split(' ').map(&:to_i)\n\nunless d[0].zero?\n puts 0\n exit\nend\n\ncounts = Array.new(d.max + 1, 0)\nd.each do |di|\n counts[di] += 1\nend\n\nsum = 1\ncounts.each_cons(2) do |ai, aj|\n if ai.zero? && !aj.zero?\n puts 0\n exit\n elsif !aj.zero?\n sum = (sum * ai ** aj) % 998244353\n end\nend\nputs sum\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": 332, "cpu_time_ms": 80, "memory_kb": 9476}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s147121391", "group_id": "codeNet:p02874", "input_text": "io = STDIN\nN=io.gets.to_i\nar=N.times.map do\n io.gets.split.map(&:to_i)\nend.sort_by{|l,r|l}\ndef add(ar)\n min1=ar[0][1]\n N.times do |i|\n ar[i]<<[min1,ar[i][1]].min\n end\n min2=ar[-1][1]\n N.times do |i|\n ar[-1-i]<<[min2,ar[-1-i][1]].min\n end\nend\nadd(ar)\ndef calc(ar,i)\n l1=ar[i][0]\n r1=ar[i][2]\n l2=ar[-1][0]\n r2=ar[i+1][3]\n r1-l1+r2-l2+2\nend\nans=0\n(N-1).times do |i|\n ans=[ans,calc(ar,i)].max\nend\np ans\n", "language": "Ruby", "metadata": {"date": 1572850961, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02874.html", "problem_id": "p02874", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02874/input.txt", "sample_output_relpath": "derived/input_output/data/p02874/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02874/Ruby/s147121391.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s147121391", "user_id": "u132360211"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "io = STDIN\nN=io.gets.to_i\nar=N.times.map do\n io.gets.split.map(&:to_i)\nend.sort_by{|l,r|l}\ndef add(ar)\n min1=ar[0][1]\n N.times do |i|\n ar[i]<<[min1,ar[i][1]].min\n end\n min2=ar[-1][1]\n N.times do |i|\n ar[-1-i]<<[min2,ar[-1-i][1]].min\n end\nend\nadd(ar)\ndef calc(ar,i)\n l1=ar[i][0]\n r1=ar[i][2]\n l2=ar[-1][0]\n r2=ar[i+1][3]\n r1-l1+r2-l2+2\nend\nans=0\n(N-1).times do |i|\n ans=[ans,calc(ar,i)].max\nend\np ans\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\n10^9 contestants, numbered 1 to 10^9, will compete in a competition.\nThere will be two contests in this competition.\n\nThe organizer prepared N problems, numbered 1 to N, to use in these contests.\nWhen Problem i is presented in a contest, it will be solved by all contestants from Contestant L_i to Contestant R_i (inclusive), and will not be solved by any other contestants.\n\nThe organizer will use these N problems in the two contests.\nEach problem must be used in exactly one of the contests, and each contest must have at least one problem.\n\nThe joyfulness of each contest is the number of contestants who will solve all the problems in the contest.\nFind the maximum possible total joyfulness of the two contests.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 R_1\nL_2 R_2\n\\vdots\nL_N R_N\n\nOutput\n\nPrint the maximum possible total joyfulness of the two contests.\n\nSample Input 1\n\n4\n4 7\n1 4\n5 8\n2 5\n\nSample Output 1\n\n6\n\nThe optimal choice is:\n\nUse Problem 1 and 3 in the first contest. Contestant 5, 6, and 7 will solve both of them, so the joyfulness of this contest is 3.\n\nUse Problem 2 and 4 in the second contest. Contestant 2, 3, and 4 will solve both of them, so the joyfulness of this contest is 3.\n\nThe total joyfulness of these two contests is 6. We cannot make the total joyfulness greater than 6.\n\nSample Input 2\n\n4\n1 20\n2 19\n3 18\n4 17\n\nSample Output 2\n\n34\n\nSample Input 3\n\n10\n457835016 996058008\n456475528 529149798\n455108441 512701454\n455817105 523506955\n457368248 814532746\n455073228 459494089\n456651538 774276744\n457667152 974637457\n457293701 800549465\n456580262 636471526\n\nSample Output 3\n\n540049931", "sample_input": "4\n4 7\n1 4\n5 8\n2 5\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02874", "source_text": "Score : 600 points\n\nProblem Statement\n\n10^9 contestants, numbered 1 to 10^9, will compete in a competition.\nThere will be two contests in this competition.\n\nThe organizer prepared N problems, numbered 1 to N, to use in these contests.\nWhen Problem i is presented in a contest, it will be solved by all contestants from Contestant L_i to Contestant R_i (inclusive), and will not be solved by any other contestants.\n\nThe organizer will use these N problems in the two contests.\nEach problem must be used in exactly one of the contests, and each contest must have at least one problem.\n\nThe joyfulness of each contest is the number of contestants who will solve all the problems in the contest.\nFind the maximum possible total joyfulness of the two contests.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 R_1\nL_2 R_2\n\\vdots\nL_N R_N\n\nOutput\n\nPrint the maximum possible total joyfulness of the two contests.\n\nSample Input 1\n\n4\n4 7\n1 4\n5 8\n2 5\n\nSample Output 1\n\n6\n\nThe optimal choice is:\n\nUse Problem 1 and 3 in the first contest. Contestant 5, 6, and 7 will solve both of them, so the joyfulness of this contest is 3.\n\nUse Problem 2 and 4 in the second contest. Contestant 2, 3, and 4 will solve both of them, so the joyfulness of this contest is 3.\n\nThe total joyfulness of these two contests is 6. We cannot make the total joyfulness greater than 6.\n\nSample Input 2\n\n4\n1 20\n2 19\n3 18\n4 17\n\nSample Output 2\n\n34\n\nSample Input 3\n\n10\n457835016 996058008\n456475528 529149798\n455108441 512701454\n455817105 523506955\n457368248 814532746\n455073228 459494089\n456651538 774276744\n457667152 974637457\n457293701 800549465\n456580262 636471526\n\nSample Output 3\n\n540049931", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 400, "memory_kb": 27856}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s436269720", "group_id": "codeNet:p02880", "input_text": "n = gets.to_i\n$l = 0\n\nputs \"No\" if n >= 82\ncatch(:break_loop) do\n 10.times do |uhen|\n $i = uhen\n 10.times do |sahen|\n puts \"Yes\" if $i * sahen == n\n throw :break_loop if $i * sahen == n\n end\n $l = $l + 1\n end\nend\n\nputs \"No\" if $l == 10", "language": "Ruby", "metadata": {"date": 1576038434, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s436269720.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s436269720", "user_id": "u944733909"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "n = gets.to_i\n$l = 0\n\nputs \"No\" if n >= 82\ncatch(:break_loop) do\n 10.times do |uhen|\n $i = uhen\n 10.times do |sahen|\n puts \"Yes\" if $i * sahen == n\n throw :break_loop if $i * sahen == n\n end\n $l = $l + 1\n end\nend\n\nputs \"No\" if $l == 10", "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": 291, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s308009263", "group_id": "codeNet:p02880", "input_text": "a=gets.to_i\n9.times do |i|\nc=a/(i+1)\nif c>=1 and c<=9and a%(i+1)==0 \n print(\"Yes\")\n exit\nelse\n #print(\"No\") \nend\nend\nprint(\"No\")", "language": "Ruby", "metadata": {"date": 1576018869, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s308009263.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s308009263", "user_id": "u678700651"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a=gets.to_i\n9.times do |i|\nc=a/(i+1)\nif c>=1 and c<=9and a%(i+1)==0 \n print(\"Yes\")\n exit\nelse\n #print(\"No\") \nend\nend\nprint(\"No\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\nHaving learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.\n\nGiven an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print Yes; if it cannot, print No.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N can be represented as the product of two integers between 1 and 9 (inclusive), print Yes; if it cannot, print No.\n\nSample Input 1\n\n10\n\nSample Output 1\n\nYes\n\n10 can be represented as, for example, 2 \\times 5.\n\nSample Input 2\n\n50\n\nSample Output 2\n\nNo\n\n50 cannot be represented as the product of two integers between 1 and 9.\n\nSample Input 3\n\n81\n\nSample Output 3\n\nYes", "sample_input": "10\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02880", "source_text": "Score : 200 points\n\nProblem Statement\n\nHaving learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.\n\nGiven an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print Yes; if it cannot, print No.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N can be represented as the product of two integers between 1 and 9 (inclusive), print Yes; if it cannot, print No.\n\nSample Input 1\n\n10\n\nSample Output 1\n\nYes\n\n10 can be represented as, for example, 2 \\times 5.\n\nSample Input 2\n\n50\n\nSample Output 2\n\nNo\n\n50 cannot be represented as the product of two integers between 1 and 9.\n\nSample Input 3\n\n81\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 128, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s686559252", "group_id": "codeNet:p02880", "input_text": "n = gets.to_i\nans = \"No\"\n(1..9).each do |i|\n if n % i == 0 && n / i < 10\n ans = \"Yes\"\n end\nend\n\nputs ans", "language": "Ruby", "metadata": {"date": 1573245015, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s686559252.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s686559252", "user_id": "u191196346"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "n = gets.to_i\nans = \"No\"\n(1..9).each do |i|\n if n % i == 0 && n / i < 10\n ans = \"Yes\"\n end\nend\n\nputs ans", "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": 109, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s408185933", "group_id": "codeNet:p02881", "input_text": "N = gets.to_i\n\ndiv1 = []\ndiv2 = []\nfor i in 1..(N ** 0.5 + 1) do\n if N % i == 0 then\n div1.push(i)\n div2.push(N/i)\n end\nend\n \nmin = 10 ** 13\nfor i in 1..div1.length do\n s = div1[i-1] + div2[i-1] - 2\n if s < min then\n min = s\n end\nend\n \nprint min", "language": "Ruby", "metadata": {"date": 1591136775, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s408185933.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s408185933", "user_id": "u569559028"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "N = gets.to_i\n\ndiv1 = []\ndiv2 = []\nfor i in 1..(N ** 0.5 + 1) do\n if N % i == 0 then\n div1.push(i)\n div2.push(N/i)\n end\nend\n \nmin = 10 ** 13\nfor i in 1..div1.length do\n s = div1[i-1] + div2[i-1] - 2\n if s < min then\n min = s\n end\nend\n \nprint min", "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": 261, "cpu_time_ms": 162, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s956553961", "group_id": "codeNet:p02881", "input_text": "N = gets.chomp.to_i\n \nanswer = 10**12\n \n (1..N).each do |i|\n if N % i != 0\n next\n else\n j = N / i\n answer_candidate = i + j - 2\n if answer_candidate < answer\n answer = answer_candidate\n end\n end\n \n end\n\n \np answer", "language": "Ruby", "metadata": {"date": 1572230975, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s956553961.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s956553961", "user_id": "u060633673"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "N = gets.chomp.to_i\n \nanswer = 10**12\n \n (1..N).each do |i|\n if N % i != 0\n next\n else\n j = N / i\n answer_candidate = i + j - 2\n if answer_candidate < answer\n answer = answer_candidate\n end\n end\n \n end\n\n \np answer", "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": 256, "cpu_time_ms": 2107, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s963618186", "group_id": "codeNet:p02881", "input_text": "n = gets.to_i\nm = n\ndivs = []\nwhile m % 2 == 0 do\n divs.push(2)\n m /= 2\nend\nd = 3\nwhile d * d <= m do\n if m % d == 0\n divs.push(d)\n m /= d\n else\n d += 2\n end\nend\ndivs.push(m) if m > 1\nmin_move = n - 1\nfor i in 0...(2 ** divs.size) do\n a = 1\n b = 1\n for j in 0...divs.size do\n if (i >> j) & 1 == 0\n a *= divs[j]\n else\n b *= divs[j]\n end\n end\n move = (a - 1) + (b - 1)\n min_move = move if min_move > move\nend\nputs min_move\n", "language": "Ruby", "metadata": {"date": 1572229966, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s963618186.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s963618186", "user_id": "u726523100"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "n = gets.to_i\nm = n\ndivs = []\nwhile m % 2 == 0 do\n divs.push(2)\n m /= 2\nend\nd = 3\nwhile d * d <= m do\n if m % d == 0\n divs.push(d)\n m /= d\n else\n d += 2\n end\nend\ndivs.push(m) if m > 1\nmin_move = n - 1\nfor i in 0...(2 ** divs.size) do\n a = 1\n b = 1\n for j in 0...divs.size do\n if (i >> j) & 1 == 0\n a *= divs[j]\n else\n b *= divs[j]\n end\n end\n move = (a - 1) + (b - 1)\n min_move = move if min_move > move\nend\nputs min_move\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": 460, "cpu_time_ms": 2107, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s940232691", "group_id": "codeNet:p02881", "input_text": "a = gets.chomp.to_i\n\nMAX = 10**12\n\ndef solve(a)\n i = 1\n\n minStep = MAX\n\n while i <= Math.sqrt(a)\n if a % i == 0\n j = a / i\n step = (i-1) + (j-1)\n minStep = [minStep, step].min\n end\n i += 1\n end\n\n return minStep\nend\n\nputs solve(a)", "language": "Ruby", "metadata": {"date": 1572228429, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s940232691.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s940232691", "user_id": "u882807753"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "a = gets.chomp.to_i\n\nMAX = 10**12\n\ndef solve(a)\n i = 1\n\n minStep = MAX\n\n while i <= Math.sqrt(a)\n if a % i == 0\n j = a / i\n step = (i-1) + (j-1)\n minStep = [minStep, step].min\n end\n i += 1\n end\n\n return minStep\nend\n\nputs solve(a)", "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": 298, "cpu_time_ms": 114, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s918603274", "group_id": "codeNet:p02881", "input_text": "n = gets.to_i\nt = (n**0.5).to_i\n(t+1).downto(1) do |i|\n if n % i == 0\n p i + n/i - 2\n break\n end\nend\n", "language": "Ruby", "metadata": {"date": 1572224731, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s918603274.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s918603274", "user_id": "u123276241"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "n = gets.to_i\nt = (n**0.5).to_i\n(t+1).downto(1) do |i|\n if n % i == 0\n p i + n/i - 2\n break\n end\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is standing on a multiplication table with infinitely many rows and columns.\n\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\n\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\n\nGiven an integer N, find the minimum number of moves needed to reach a square that contains N.\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum number of moves needed to reach a square that contains the integer N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n5\n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10 in less than five moves.\n\nSample Input 2\n\n50\n\nSample Output 2\n\n13\n\n(5, 10) can be reached in 13 moves.\n\nSample Input 3\n\n10000000019\n\nSample Output 3\n\n10000000018\n\nBoth input and output may be enormous.", "sample_input": "10\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02881", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is standing on a multiplication table with infinitely many rows and columns.\n\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\n\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\n\nGiven an integer N, find the minimum number of moves needed to reach a square that contains N.\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum number of moves needed to reach a square that contains the integer N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n5\n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10 in less than five moves.\n\nSample Input 2\n\n50\n\nSample Output 2\n\n13\n\n(5, 10) can be reached in 13 moves.\n\nSample Input 3\n\n10000000019\n\nSample Output 3\n\n10000000018\n\nBoth input and output may be enormous.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 109, "cpu_time_ms": 71, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s803918448", "group_id": "codeNet:p02882", "input_text": "include Math\n\na,b,x = gets.split.map(&:to_f)\n\ns = x / a\n\nif s >= a*b/2\n h = (a*b - s)*2/a\n rad = atan2(h, a)\nelse\n w = s*2/b\n rad = atan2(b, w)\nend\n\ndeg = rad * 180 / PI\n\nputs deg\n", "language": "Ruby", "metadata": {"date": 1572268926, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02882.html", "problem_id": "p02882", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02882/input.txt", "sample_output_relpath": "derived/input_output/data/p02882/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02882/Ruby/s803918448.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s803918448", "user_id": "u843127718"}, "prompt_components": {"gold_output": "45.0000000000\n", "input_to_evaluate": "include Math\n\na,b,x = gets.split.map(&:to_f)\n\ns = x / a\n\nif s >= a*b/2\n h = (a*b - s)*2/a\n rad = atan2(h, a)\nelse\n w = s*2/b\n rad = atan2(b, w)\nend\n\ndeg = rad * 180 / PI\n\nputs deg\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\\mathrm{cm} and whose height is b~\\mathrm{cm}. (The thickness of the bottle can be ignored.)\n\nWe will pour x~\\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base.\n\nWhen will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq a \\leq 100\n\n1 \\leq b \\leq 100\n\n1 \\leq x \\leq a^2b\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b x\n\nOutput\n\nPrint the maximum angle in which we can tilt the bottle without spilling any water, in degrees.\nYour output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n2 2 4\n\nSample Output 1\n\n45.0000000000\n\nThis bottle has a cubic shape, and it is half-full. The water gets spilled when we tilt the bottle more than 45 degrees.\n\nSample Input 2\n\n12 21 10\n\nSample Output 2\n\n89.7834636934\n\nThis bottle is almost empty. When the water gets spilled, the bottle is nearly horizontal.\n\nSample Input 3\n\n3 1 8\n\nSample Output 3\n\n4.2363947991\n\nThis bottle is almost full. When the water gets spilled, the bottle is still nearly vertical.", "sample_input": "2 2 4\n"}, "reference_outputs": ["45.0000000000\n"], "source_document_id": "p02882", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\\mathrm{cm} and whose height is b~\\mathrm{cm}. (The thickness of the bottle can be ignored.)\n\nWe will pour x~\\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base.\n\nWhen will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq a \\leq 100\n\n1 \\leq b \\leq 100\n\n1 \\leq x \\leq a^2b\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b x\n\nOutput\n\nPrint the maximum angle in which we can tilt the bottle without spilling any water, in degrees.\nYour output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n2 2 4\n\nSample Output 1\n\n45.0000000000\n\nThis bottle has a cubic shape, and it is half-full. The water gets spilled when we tilt the bottle more than 45 degrees.\n\nSample Input 2\n\n12 21 10\n\nSample Output 2\n\n89.7834636934\n\nThis bottle is almost empty. When the water gets spilled, the bottle is nearly horizontal.\n\nSample Input 3\n\n3 1 8\n\nSample Output 3\n\n4.2363947991\n\nThis bottle is almost full. When the water gets spilled, the bottle is still nearly vertical.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 192, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s967199294", "group_id": "codeNet:p02885", "input_text": "a, b = gets.chomp.split(' ').map(&:to_i)\n\nputs (c = a - 2 * b) > 0 ? c : 0\n", "language": "Ruby", "metadata": {"date": 1572223721, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s967199294.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s967199294", "user_id": "u484832756"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "a, b = gets.chomp.split(' ').map(&:to_i)\n\nputs (c = a - 2 * b) > 0 ? c : 0\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": 75, "cpu_time_ms": 8, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s368339918", "group_id": "codeNet:p02886", "input_text": "N = gets.to_i\nD = gets.split.map(&:to_i)\n\nans = 0\n\nN.times do |i|\n (i+1..N-1).each do |j|\n ans += D[i] * D[j] if i != j\n end\nend\n\nputs ans\n", "language": "Ruby", "metadata": {"date": 1582412051, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s368339918.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s368339918", "user_id": "u846185950"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "N = gets.to_i\nD = gets.split.map(&:to_i)\n\nans = 0\n\nN.times do |i|\n (i+1..N-1).each do |j|\n ans += D[i] * D[j] if i != j\n end\nend\n\nputs ans\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": 152, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s840481302", "group_id": "codeNet:p02887", "input_text": "gets\ns = gets.chars\n\nres = 0\nbefore = nil\ns.each() do |a|\n res += 1 if a != before\n before = a\nend\n\np res", "language": "Ruby", "metadata": {"date": 1571534301, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02887.html", "problem_id": "p02887", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02887/input.txt", "sample_output_relpath": "derived/input_output/data/p02887/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02887/Ruby/s840481302.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s840481302", "user_id": "u631543593"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "gets\ns = gets.chars\n\nres = 0\nbefore = nil\ns.each() do |a|\n res += 1 if a != before\n before = a\nend\n\np res", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.\n\nAdjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.\n\nUltimately, how many slimes will be there?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the final number of slimes.\n\nSample Input 1\n\n10\naabbbbaaca\n\nSample Output 1\n\n5\n\nUltimately, these slimes will fuse into abaca.\n\nSample Input 2\n\n5\naaaaa\n\nSample Output 2\n\n1\n\nAll the slimes will fuse into one.\n\nSample Input 3\n\n20\nxxzaffeeeeddfkkkkllq\n\nSample Output 3\n\n10", "sample_input": "10\naabbbbaaca\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02887", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.\n\nAdjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.\n\nUltimately, how many slimes will be there?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the final number of slimes.\n\nSample Input 1\n\n10\naabbbbaaca\n\nSample Output 1\n\n5\n\nUltimately, these slimes will fuse into abaca.\n\nSample Input 2\n\n5\naaaaa\n\nSample Output 2\n\n1\n\nAll the slimes will fuse into one.\n\nSample Input 3\n\n20\nxxzaffeeeeddfkkkkllq\n\nSample Output 3\n\n10", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 107, "cpu_time_ms": 34, "memory_kb": 6780}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s878143190", "group_id": "codeNet:p02888", "input_text": "N = gets.to_i\nL = gets.split.map(&:to_i).sort\nans = 0\n1.upto(N-1) do |l2|\n (l2+1).upto(N-1) do |l1|\n len1 = L[l1]\n len2 = L[l2]\n a = L.bsearch_index{|l| l > len1 - len2}\n ans += l2 - a if !a.nil? && l2 - a > 0\n end\nend\np ans", "language": "Ruby", "metadata": {"date": 1575671562, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s878143190.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s878143190", "user_id": "u655122274"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N = gets.to_i\nL = gets.split.map(&:to_i).sort\nans = 0\n1.upto(N-1) do |l2|\n (l2+1).upto(N-1) do |l1|\n len1 = L[l1]\n len2 = L[l2]\n a = L.bsearch_index{|l| l > len1 - len2}\n ans += l2 - a if !a.nil? && l2 - a > 0\n end\nend\np ans", "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": 258, "cpu_time_ms": 1612, "memory_kb": 1912}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s892353249", "group_id": "codeNet:p02888", "input_text": "n = gets.to_i\nl = gets.split(\" \")\nl.map!(&:to_i)\nl.sort!.reverse!\n\nanswer = 0\n\nfor i in 0..n-1\n for j in i+1..n-1\n b = l[i] - l[j]\n for k in j+1..n-1\n if l[k] > b\n answer += 1\n else\n break\n end\n end\n end\nend\n\nputs answer", "language": "Ruby", "metadata": {"date": 1572224035, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s892353249.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s892353249", "user_id": "u825165559"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n = gets.to_i\nl = gets.split(\" \")\nl.map!(&:to_i)\nl.sort!.reverse!\n\nanswer = 0\n\nfor i in 0..n-1\n for j in i+1..n-1\n b = l[i] - l[j]\n for k in j+1..n-1\n if l[k] > b\n answer += 1\n else\n break\n end\n end\n end\nend\n\nputs answer", "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": 260, "cpu_time_ms": 2107, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s979784988", "group_id": "codeNet:p02888", "input_text": "N = gets.to_i\nhen = gets.split(' ').map(&:to_i)\n\ntriangle_total = 0\na = 0\n\nwhile a < N - 2 do\n b = a + 1\n while b < N - 1 do \n c = b + 1\n while c < N do\n if hen[a] + hen[b] > hen[c] && hen[a] + hen[c] > hen[b] && hen[b] + hen[c] > hen[a]\n triangle_total = triangle_total + 1\n end\n c = c + 1\n end\n b = b + 1\n end\n a = a + 1\nend\n\np triangle_total", "language": "Ruby", "metadata": {"date": 1571538479, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s979784988.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s979784988", "user_id": "u729372946"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N = gets.to_i\nhen = gets.split(' ').map(&:to_i)\n\ntriangle_total = 0\na = 0\n\nwhile a < N - 2 do\n b = a + 1\n while b < N - 1 do \n c = b + 1\n while c < N do\n if hen[a] + hen[b] > hen[c] && hen[a] + hen[c] > hen[b] && hen[b] + hen[c] > hen[a]\n triangle_total = triangle_total + 1\n end\n c = c + 1\n end\n b = b + 1\n end\n a = a + 1\nend\n\np triangle_total", "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": 434, "cpu_time_ms": 2107, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s647788949", "group_id": "codeNet:p02888", "input_text": "n = gets.to_i\nln = gets.split.map(&:to_i)\nln.sort!{|a,b| b<=> a}\n\ncnt = 0\nfor tar in 0..(n-3)\n lid = tar+1\n rid = n-1\n while lid < n-1 && lid < rid\n if ln[tar] >= ln[lid]+ln[rid]\n rid -= 1\n else\n cnt += rid-lid\n lid += 1\n end\n end\nend\nputs cnt", "language": "Ruby", "metadata": {"date": 1571535470, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s647788949.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s647788949", "user_id": "u326891688"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n = gets.to_i\nln = gets.split.map(&:to_i)\nln.sort!{|a,b| b<=> a}\n\ncnt = 0\nfor tar in 0..(n-3)\n lid = tar+1\n rid = n-1\n while lid < n-1 && lid < rid\n if ln[tar] >= ln[lid]+ln[rid]\n rid -= 1\n else\n cnt += rid-lid\n lid += 1\n end\n end\nend\nputs cnt", "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": 271, "cpu_time_ms": 235, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s047054723", "group_id": "codeNet:p02897", "input_text": "N = gets.to_i\n\nif N % 2 == 0\n puts 0.5\nelse\n puts 2/3\nend", "language": "Ruby", "metadata": {"date": 1569806027, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s047054723.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s047054723", "user_id": "u958578969"}, "prompt_components": {"gold_output": "0.5000000000\n", "input_to_evaluate": "N = gets.to_i\n\nif N % 2 == 0\n puts 0.5\nelse\n puts 2/3\nend", "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": 59, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s160254913", "group_id": "codeNet:p02898", "input_text": "N,K=gets.split.map(&:to_i)\nH=gets.split.map(&:to_i)\nans = 0\nH.each do |h|\n if h >= K\n ans += 1\n end\nend\np ans", "language": "Ruby", "metadata": {"date": 1583789332, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s160254913.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s160254913", "user_id": "u799910874"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "N,K=gets.split.map(&:to_i)\nH=gets.split.map(&:to_i)\nans = 0\nH.each do |h|\n if h >= K\n ans += 1\n end\nend\np ans", "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": 114, "cpu_time_ms": 49, "memory_kb": 9476}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s683160458", "group_id": "codeNet:p02898", "input_text": "n, k = gets.chomp.split(' ').map{|s| s.to_i}\nhs = gets.chomp.split(' ').map{|s| s.to_i}\n\np hs.select{|h| h >=k}.length\n", "language": "Ruby", "metadata": {"date": 1569724214, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s683160458.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s683160458", "user_id": "u894128391"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n, k = gets.chomp.split(' ').map{|s| s.to_i}\nhs = gets.chomp.split(' ').map{|s| s.to_i}\n\np hs.select{|h| h >=k}.length\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": 119, "cpu_time_ms": 48, "memory_kb": 8708}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s155636235", "group_id": "codeNet:p02899", "input_text": "n = gets.to_i\na = gets.split(' ').map &:to_i\nar = []\n(1..n).each do |i|\n ar << a.index(i)+1\nend\nputs ar.join(' ')\n", "language": "Ruby", "metadata": {"date": 1579730920, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02899.html", "problem_id": "p02899", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02899/input.txt", "sample_output_relpath": "derived/input_output/data/p02899/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02899/Ruby/s155636235.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s155636235", "user_id": "u437368899"}, "prompt_components": {"gold_output": "3 1 2\n", "input_to_evaluate": "n = gets.to_i\na = gets.split(' ').map &:to_i\nar = []\n(1..n).each do |i|\n ar << a.index(i)+1\nend\nputs ar.join(' ')\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is a teacher responsible for a class of N students.\n\nThe students are given distinct student numbers from 1 to N.\n\nToday, all the students entered the classroom at different times.\n\nAccording to Takahashi's record, there were A_i students in the classroom when student number i entered the classroom (including student number i).\n\nFrom these records, reconstruct the order in which the students entered the classroom.\n\nConstraints\n\n1 \\le N \\le 10^5\n\n1 \\le A_i \\le N\n\nA_i \\neq A_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint the student numbers of the students in the order the students entered the classroom.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n3 1 2\n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 2 3 4 5\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n8 2 4 5 6 7 3 1", "sample_input": "3\n2 3 1\n"}, "reference_outputs": ["3 1 2\n"], "source_document_id": "p02899", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is a teacher responsible for a class of N students.\n\nThe students are given distinct student numbers from 1 to N.\n\nToday, all the students entered the classroom at different times.\n\nAccording to Takahashi's record, there were A_i students in the classroom when student number i entered the classroom (including student number i).\n\nFrom these records, reconstruct the order in which the students entered the classroom.\n\nConstraints\n\n1 \\le N \\le 10^5\n\n1 \\le A_i \\le N\n\nA_i \\neq A_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint the student numbers of the students in the order the students entered the classroom.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n3 1 2\n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 2 3 4 5\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n8 2 4 5 6 7 3 1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 115, "cpu_time_ms": 2108, "memory_kb": 10012}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s038832782", "group_id": "codeNet:p02899", "input_text": "n = gets.to_i\n\nd = gets.chomp.split.map(&:to_i)\n\nres = []\n\n(1..n).each do |i|\n\tres << d.index(i)+1\nend\n\nputs res.join(\" \")", "language": "Ruby", "metadata": {"date": 1579724739, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02899.html", "problem_id": "p02899", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02899/input.txt", "sample_output_relpath": "derived/input_output/data/p02899/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02899/Ruby/s038832782.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s038832782", "user_id": "u411203878"}, "prompt_components": {"gold_output": "3 1 2\n", "input_to_evaluate": "n = gets.to_i\n\nd = gets.chomp.split.map(&:to_i)\n\nres = []\n\n(1..n).each do |i|\n\tres << d.index(i)+1\nend\n\nputs res.join(\" \")", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is a teacher responsible for a class of N students.\n\nThe students are given distinct student numbers from 1 to N.\n\nToday, all the students entered the classroom at different times.\n\nAccording to Takahashi's record, there were A_i students in the classroom when student number i entered the classroom (including student number i).\n\nFrom these records, reconstruct the order in which the students entered the classroom.\n\nConstraints\n\n1 \\le N \\le 10^5\n\n1 \\le A_i \\le N\n\nA_i \\neq A_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint the student numbers of the students in the order the students entered the classroom.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n3 1 2\n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 2 3 4 5\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n8 2 4 5 6 7 3 1", "sample_input": "3\n2 3 1\n"}, "reference_outputs": ["3 1 2\n"], "source_document_id": "p02899", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is a teacher responsible for a class of N students.\n\nThe students are given distinct student numbers from 1 to N.\n\nToday, all the students entered the classroom at different times.\n\nAccording to Takahashi's record, there were A_i students in the classroom when student number i entered the classroom (including student number i).\n\nFrom these records, reconstruct the order in which the students entered the classroom.\n\nConstraints\n\n1 \\le N \\le 10^5\n\n1 \\le A_i \\le N\n\nA_i \\neq A_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint the student numbers of the students in the order the students entered the classroom.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n3 1 2\n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 2 3 4 5\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n8 2 4 5 6 7 3 1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 122, "cpu_time_ms": 2108, "memory_kb": 10756}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s741381500", "group_id": "codeNet:p02900", "input_text": "require 'prime'\n# n = gets.chomp.to_i\na, b = gets.chomp.split().map(&:to_i)\n\nnums = []\n1.upto(10**6).each do |i|\n if a%i==0 && b%i ==0\n nums.push i\n end\nend\n\nans = 0\nd = nums.size\n(2**d).times do |i|\n bits = i.to_s(2).split(//)\n (d - bits.length).times{bits.unshift('0')}\n\n selected = []\n bits.each_with_index do |bit, i|\n if bit == '1'\n selected.push nums[i]\n end\n end\n\n if selected.combination(2).all?{|x,y| x.gcd(y) == 1}\n # p ['selected', selected]\n ans = [ans, selected.count].max\n end\n\nend\n\nputs ans", "language": "Ruby", "metadata": {"date": 1576623220, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s741381500.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s741381500", "user_id": "u524019694"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "require 'prime'\n# n = gets.chomp.to_i\na, b = gets.chomp.split().map(&:to_i)\n\nnums = []\n1.upto(10**6).each do |i|\n if a%i==0 && b%i ==0\n nums.push i\n end\nend\n\nans = 0\nd = nums.size\n(2**d).times do |i|\n bits = i.to_s(2).split(//)\n (d - bits.length).times{bits.unshift('0')}\n\n selected = []\n bits.each_with_index do |bit, i|\n if bit == '1'\n selected.push nums[i]\n end\n end\n\n if selected.combination(2).all?{|x,y| x.gcd(y) == 1}\n # p ['selected', selected]\n ans = [ans, selected.count].max\n end\n\nend\n\nputs ans", "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": 534, "cpu_time_ms": 2107, "memory_kb": 2428}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s515810993", "group_id": "codeNet:p02909", "input_text": "s = gets.to_s\n\nif s == 'Sunny'\n puts 'Cloudy'\nelsif s == 'Cloudy'\n puts 'Rainy'\nelse\n puts 'Sunny'\nend", "language": "Ruby", "metadata": {"date": 1576299516, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s515810993.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s515810993", "user_id": "u944733909"}, "prompt_components": {"gold_output": "Cloudy\n", "input_to_evaluate": "s = gets.to_s\n\nif s == 'Sunny'\n puts 'Cloudy'\nelsif s == 'Cloudy'\n puts 'Rainy'\nelse\n puts 'Sunny'\nend", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "sample_input": "Sunny\n"}, "reference_outputs": ["Cloudy\n"], "source_document_id": "p02909", "source_text": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 111, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s644093720", "group_id": "codeNet:p02909", "input_text": "str = gets.chomp\n\nif str == 'Sunny'\n puts 'Cloudy'\nelsif str == 'Cloudy'\n puts 'Rainy'\nelse\n puts 'Sunny'\nend", "language": "Ruby", "metadata": {"date": 1575731374, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s644093720.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s644093720", "user_id": "u417892119"}, "prompt_components": {"gold_output": "Cloudy\n", "input_to_evaluate": "str = gets.chomp\n\nif str == 'Sunny'\n puts 'Cloudy'\nelsif str == 'Cloudy'\n puts 'Rainy'\nelse\n puts 'Sunny'\nend", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "sample_input": "Sunny\n"}, "reference_outputs": ["Cloudy\n"], "source_document_id": "p02909", "source_text": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 118, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s876433791", "group_id": "codeNet:p02909", "input_text": "Weather = ['Sunny', 'Cloudy', 'Rainy']\n\ndef main(argv)\n s = gets.chomp\n \n n = Weather.find_index(s)\n \n puts Weather[(n + 1) % 3]\nend\n\nif self.to_s == 'main' then\n main(ARGV)\nend", "language": "Ruby", "metadata": {"date": 1568595806, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s876433791.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s876433791", "user_id": "u198355306"}, "prompt_components": {"gold_output": "Cloudy\n", "input_to_evaluate": "Weather = ['Sunny', 'Cloudy', 'Rainy']\n\ndef main(argv)\n s = gets.chomp\n \n n = Weather.find_index(s)\n \n puts Weather[(n + 1) % 3]\nend\n\nif self.to_s == 'main' then\n main(ARGV)\nend", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "sample_input": "Sunny\n"}, "reference_outputs": ["Cloudy\n"], "source_document_id": "p02909", "source_text": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 183, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s839890401", "group_id": "codeNet:p02909", "input_text": "s = gets.chop.to_s\n\narr = ['Sunny', 'Cloudy', 'Windy']\nind = arr.find_index(s)\nif ind == 2\n next = 0\nelse\n next = ind + 1\np arr[next]", "language": "Ruby", "metadata": {"date": 1568595787, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s839890401.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s839890401", "user_id": "u860790033"}, "prompt_components": {"gold_output": "Cloudy\n", "input_to_evaluate": "s = gets.chop.to_s\n\narr = ['Sunny', 'Cloudy', 'Windy']\nind = arr.find_index(s)\nif ind == 2\n next = 0\nelse\n next = ind + 1\np arr[next]", "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": 135, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s547783558", "group_id": "codeNet:p02910", "input_text": "s = gets.chop\nflag=true\ns.each_char.with_index{|c,i| flag=false if c==\"L\" && i.even? || c==\"R\" && i.odd?}\nputs flag ? \"Yes\" : \"No\"", "language": "Ruby", "metadata": {"date": 1579361026, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02910.html", "problem_id": "p02910", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02910/input.txt", "sample_output_relpath": "derived/input_output/data/p02910/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02910/Ruby/s547783558.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s547783558", "user_id": "u712322283"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "s = gets.chop\nflag=true\ns.each_char.with_index{|c,i| flag=false if c==\"L\" && i.even? || c==\"R\" && i.odd?}\nputs flag ? \"Yes\" : \"No\"", "problem_context": "Score: 200 points\n\nProblem Statement\n\nTakahashi will do a tap dance. The dance is described by a string S where each character is L, R, U, or D. These characters indicate the positions on which Takahashi should step. He will follow these instructions one by one in order, starting with the first character.\n\nS is said to be easily playable if and only if it satisfies both of the following conditions:\n\nEvery character in an odd position (1-st, 3-rd, 5-th, \\ldots) is R, U, or D.\n\nEvery character in an even position (2-nd, 4-th, 6-th, \\ldots) is L, U, or D.\n\nYour task is to print Yes if S is easily playable, and No otherwise.\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nEach character of S is L, R, U, or D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Yes if S is easily playable, and No otherwise.\n\nSample Input 1\n\nRUDLUDR\n\nSample Output 1\n\nYes\n\nEvery character in an odd position (1-st, 3-rd, 5-th, 7-th) is R, U, or D.\n\nEvery character in an even position (2-nd, 4-th, 6-th) is L, U, or D.\n\nThus, S is easily playable.\n\nSample Input 2\n\nDULL\n\nSample Output 2\n\nNo\n\nThe 3-rd character is not R, U, nor D, so S is not easily playable.\n\nSample Input 3\n\nUUUUUUUUUUUUUUU\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nULURU\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nRDULULDURURLRDULRLR\n\nSample Output 5\n\nYes", "sample_input": "RUDLUDR\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02910", "source_text": "Score: 200 points\n\nProblem Statement\n\nTakahashi will do a tap dance. The dance is described by a string S where each character is L, R, U, or D. These characters indicate the positions on which Takahashi should step. He will follow these instructions one by one in order, starting with the first character.\n\nS is said to be easily playable if and only if it satisfies both of the following conditions:\n\nEvery character in an odd position (1-st, 3-rd, 5-th, \\ldots) is R, U, or D.\n\nEvery character in an even position (2-nd, 4-th, 6-th, \\ldots) is L, U, or D.\n\nYour task is to print Yes if S is easily playable, and No otherwise.\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nEach character of S is L, R, U, or D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Yes if S is easily playable, and No otherwise.\n\nSample Input 1\n\nRUDLUDR\n\nSample Output 1\n\nYes\n\nEvery character in an odd position (1-st, 3-rd, 5-th, 7-th) is R, U, or D.\n\nEvery character in an even position (2-nd, 4-th, 6-th) is L, U, or D.\n\nThus, S is easily playable.\n\nSample Input 2\n\nDULL\n\nSample Output 2\n\nNo\n\nThe 3-rd character is not R, U, nor D, so S is not easily playable.\n\nSample Input 3\n\nUUUUUUUUUUUUUUU\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nULURU\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nRDULULDURURLRDULRLR\n\nSample Output 5\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 130, "cpu_time_ms": 8, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s712515980", "group_id": "codeNet:p02911", "input_text": "N,K,Q=gets.split.map(&:to_i)\nA=Q.times.map{gets.to_i}\n\npati = Array.new(N, K-Q)\nA.each do |n|\n pati[n-1] += 1\nend\n\nN.times do |i|\n if pati[i] > 0\n puts \"Yes\"\n else\n puts \"No\"\n end\nend", "language": "Ruby", "metadata": {"date": 1583806581, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s712515980.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s712515980", "user_id": "u799910874"}, "prompt_components": {"gold_output": "No\nNo\nYes\nNo\nNo\nNo\n", "input_to_evaluate": "N,K,Q=gets.split.map(&:to_i)\nA=Q.times.map{gets.to_i}\n\npati = Array.new(N, K-Q)\nA.each do |n|\n pati[n-1] += 1\nend\n\nN.times do |i|\n if pati[i] > 0\n puts \"Yes\"\n else\n puts \"No\"\n end\nend", "problem_context": "Score: 300 points\n\nProblem Statement\n\nTakahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows.\n\nA game is played by N players, numbered 1 to N. At the beginning of a game, each player has K points.\n\nWhen a player correctly answers a question, each of the other N-1 players receives minus one (-1) point. There is no other factor that affects the players' scores.\n\nAt the end of a game, the players with 0 points or lower are eliminated, and the remaining players survive.\n\nIn the last game, the players gave a total of Q correct answers, the i-th of which was given by Player A_i.\nFor Kizahashi, write a program that determines whether each of the N players survived this game.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^9\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq A_i \\leq N\\ (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K Q\nA_1\nA_2\n.\n.\n.\nA_Q\n\nOutput\n\nPrint N lines. The i-th line should contain Yes if Player i survived the game, and No otherwise.\n\nSample Input 1\n\n6 3 4\n3\n1\n3\n2\n\nSample Output 1\n\nNo\nNo\nYes\nNo\nNo\nNo\n\nIn the beginning, the players' scores are (3, 3, 3, 3, 3, 3).\n\nPlayer 3 correctly answers a question. The players' scores are now (2, 2, 3, 2, 2, 2).\n\nPlayer 1 correctly answers a question. The players' scores are now (2, 1, 2, 1, 1, 1).\n\nPlayer 3 correctly answers a question. The players' scores are now (1, 0, 2, 0, 0, 0).\n\nPlayer 2 correctly answers a question. The players' scores are now (0, 0, 1, -1, -1, -1).\n\nPlayers 1, 2, 4, 5 and 6, who have 0 points or lower, are eliminated, and Player 3 survives this game.\n\nSample Input 2\n\n6 5 4\n3\n1\n3\n2\n\nSample Output 2\n\nYes\nYes\nYes\nYes\nYes\nYes\n\nSample Input 3\n\n10 13 15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n\nSample Output 3\n\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nNo\nYes\nNo", "sample_input": "6 3 4\n3\n1\n3\n2\n"}, "reference_outputs": ["No\nNo\nYes\nNo\nNo\nNo\n"], "source_document_id": "p02911", "source_text": "Score: 300 points\n\nProblem Statement\n\nTakahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows.\n\nA game is played by N players, numbered 1 to N. At the beginning of a game, each player has K points.\n\nWhen a player correctly answers a question, each of the other N-1 players receives minus one (-1) point. There is no other factor that affects the players' scores.\n\nAt the end of a game, the players with 0 points or lower are eliminated, and the remaining players survive.\n\nIn the last game, the players gave a total of Q correct answers, the i-th of which was given by Player A_i.\nFor Kizahashi, write a program that determines whether each of the N players survived this game.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^9\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq A_i \\leq N\\ (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K Q\nA_1\nA_2\n.\n.\n.\nA_Q\n\nOutput\n\nPrint N lines. The i-th line should contain Yes if Player i survived the game, and No otherwise.\n\nSample Input 1\n\n6 3 4\n3\n1\n3\n2\n\nSample Output 1\n\nNo\nNo\nYes\nNo\nNo\nNo\n\nIn the beginning, the players' scores are (3, 3, 3, 3, 3, 3).\n\nPlayer 3 correctly answers a question. The players' scores are now (2, 2, 3, 2, 2, 2).\n\nPlayer 1 correctly answers a question. The players' scores are now (2, 1, 2, 1, 1, 1).\n\nPlayer 3 correctly answers a question. The players' scores are now (1, 0, 2, 0, 0, 0).\n\nPlayer 2 correctly answers a question. The players' scores are now (0, 0, 1, -1, -1, -1).\n\nPlayers 1, 2, 4, 5 and 6, who have 0 points or lower, are eliminated, and Player 3 survives this game.\n\nSample Input 2\n\n6 5 4\n3\n1\n3\n2\n\nSample Output 2\n\nYes\nYes\nYes\nYes\nYes\nYes\n\nSample Input 3\n\n10 13 15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n\nSample Output 3\n\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nNo\nYes\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 104, "memory_kb": 4148}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s517724570", "group_id": "codeNet:p02917", "input_text": "n = gets.to_i\nb = gets.split.map(&:to_i)\na = []\na << b.first\n(n-1).times do |i|\n a << b[i,2].min\nend\nputs a.sum\n", "language": "Ruby", "metadata": {"date": 1594419662, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s517724570.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s517724570", "user_id": "u503270460"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "n = gets.to_i\nb = gets.split.map(&:to_i)\na = []\na << b.first\n(n-1).times do |i|\n a << b[i,2].min\nend\nputs a.sum\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is an integer sequence A of length N whose values are unknown.\n\nGiven is an integer sequence B of length N-1 which is known to satisfy the following:\n\nB_i \\geq \\max(A_i, A_{i+1})\n\nFind the maximum possible sum of the elements of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n0 \\leq B_i \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nB_1 B_2 ... B_{N-1}\n\nOutput\n\nPrint the maximum possible sum of the elements of A.\n\nSample Input 1\n\n3\n2 5\n\nSample Output 1\n\n9\n\nA can be, for example, ( 2 , 1 , 5 ), ( -1 , -2 , -3 ), or ( 2 , 2 , 5 ). Among those candidates, A = ( 2 , 2 , 5 ) has the maximum possible sum.\n\nSample Input 2\n\n2\n3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n6\n0 153 10 10 23\n\nSample Output 3\n\n53", "sample_input": "3\n2 5\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02917", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is an integer sequence A of length N whose values are unknown.\n\nGiven is an integer sequence B of length N-1 which is known to satisfy the following:\n\nB_i \\geq \\max(A_i, A_{i+1})\n\nFind the maximum possible sum of the elements of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n0 \\leq B_i \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nB_1 B_2 ... B_{N-1}\n\nOutput\n\nPrint the maximum possible sum of the elements of A.\n\nSample Input 1\n\n3\n2 5\n\nSample Output 1\n\n9\n\nA can be, for example, ( 2 , 1 , 5 ), ( -1 , -2 , -3 ), or ( 2 , 2 , 5 ). Among those candidates, A = ( 2 , 2 , 5 ) has the maximum possible sum.\n\nSample Input 2\n\n2\n3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n6\n0 153 10 10 23\n\nSample Output 3\n\n53", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 113, "cpu_time_ms": 67, "memory_kb": 14260}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s915260219", "group_id": "codeNet:p02917", "input_text": "n = gets.chomp.to_i\nt_b = gets.chomp\nb = t_b.split(' ').map{|v| v.to_i}\n\na = Array.new(n, 0)\n\nb.each_with_index do |v, i|\n if i >= 1 && v > a[i]\n a[i+1] = v\n else\n a[i] = v\n a[i+1] = v\n end\nend\n\np a.sum", "language": "Ruby", "metadata": {"date": 1567908118, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s915260219.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s915260219", "user_id": "u455366471"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "n = gets.chomp.to_i\nt_b = gets.chomp\nb = t_b.split(' ').map{|v| v.to_i}\n\na = Array.new(n, 0)\n\nb.each_with_index do |v, i|\n if i >= 1 && v > a[i]\n a[i+1] = v\n else\n a[i] = v\n a[i+1] = v\n end\nend\n\np a.sum", "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": 214, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s090001482", "group_id": "codeNet:p02918", "input_text": "n, k = gets.split.map(&:to_i)\ns = gets.chomp.chars\n\nfirst = 1\nwhile first < n && k > 0\n if s[first - 1] != s[first] then\n last = first\n while last < n - 1\n if s[last] == s[first] && s[last + 1] == s[first - 1] then\n break\n end\n last += 1\n end\n for i in first.upto(last)\n if s[i] == 'L' then\n s[i] = 'R'\n else\n s[i] = 'L'\n end\n end\n k -= 1\n end\n first += 1\nend\n\ncount = 0\nfor i in 1.upto(n - 1)\n if s[i - 1] != s[i] then\n count += 1\n end\nend\n\nputs n - 1 - count\n", "language": "Ruby", "metadata": {"date": 1567909958, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02918.html", "problem_id": "p02918", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02918/input.txt", "sample_output_relpath": "derived/input_output/data/p02918/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02918/Ruby/s090001482.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s090001482", "user_id": "u420267469"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "n, k = gets.split.map(&:to_i)\ns = gets.chomp.chars\n\nfirst = 1\nwhile first < n && k > 0\n if s[first - 1] != s[first] then\n last = first\n while last < n - 1\n if s[last] == s[first] && s[last + 1] == s[first - 1] then\n break\n end\n last += 1\n end\n for i in first.upto(last)\n if s[i] == 'L' then\n s[i] = 'R'\n else\n s[i] = 'L'\n end\n end\n k -= 1\n end\n first += 1\nend\n\ncount = 0\nfor i in 1.upto(n - 1)\n if s[i - 1] != s[i] then\n count += 1\n end\nend\n\nputs n - 1 - count\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N people standing in a queue from west to east.\n\nGiven is a string S of length N representing the directions of the people.\nThe i-th person from the west is facing west if the i-th character of S is L, and east if that character of S is R.\n\nA person is happy if the person in front of him/her is facing the same direction.\nIf no person is standing in front of a person, however, he/she is not happy.\n\nYou can perform the following operation any number of times between 0 and K (inclusive):\n\nOperation: Choose integers l and r such that 1 \\leq l \\leq r \\leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.\n\nWhat is the maximum possible number of happy people you can have?\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^5.\n\nK is an integer satisfying 1 \\leq K \\leq 10^5.\n\n|S| = N\n\nEach character of S is L or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the maximum possible number of happy people after at most K operations.\n\nSample Input 1\n\n6 1\nLRLRRL\n\nSample Output 1\n\n3\n\nIf we choose (l, r) = (2, 5), we have LLLRLL, where the 2-nd, 3-rd, and 6-th persons from the west are happy.\n\nSample Input 2\n\n13 3\nLRRLRLRRLRLLR\n\nSample Output 2\n\n9\n\nSample Input 3\n\n10 1\nLLLLLRRRRR\n\nSample Output 3\n\n9\n\nSample Input 4\n\n9 2\nRRRLRLRLL\n\nSample Output 4\n\n7", "sample_input": "6 1\nLRLRRL\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02918", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N people standing in a queue from west to east.\n\nGiven is a string S of length N representing the directions of the people.\nThe i-th person from the west is facing west if the i-th character of S is L, and east if that character of S is R.\n\nA person is happy if the person in front of him/her is facing the same direction.\nIf no person is standing in front of a person, however, he/she is not happy.\n\nYou can perform the following operation any number of times between 0 and K (inclusive):\n\nOperation: Choose integers l and r such that 1 \\leq l \\leq r \\leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.\n\nWhat is the maximum possible number of happy people you can have?\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^5.\n\nK is an integer satisfying 1 \\leq K \\leq 10^5.\n\n|S| = N\n\nEach character of S is L or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the maximum possible number of happy people after at most K operations.\n\nSample Input 1\n\n6 1\nLRLRRL\n\nSample Output 1\n\n3\n\nIf we choose (l, r) = (2, 5), we have LLLRLL, where the 2-nd, 3-rd, and 6-th persons from the west are happy.\n\nSample Input 2\n\n13 3\nLRRLRLRRLRLLR\n\nSample Output 2\n\n9\n\nSample Input 3\n\n10 1\nLLLLLRRRRR\n\nSample Output 3\n\n9\n\nSample Input 4\n\n9 2\nRRRLRLRLL\n\nSample Output 4\n\n7", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 636, "cpu_time_ms": 96, "memory_kb": 11772}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s330387451", "group_id": "codeNet:p02921", "input_text": "s = gets.chomp\nt = gets.chomp\n\nresult = 0\n\n3.times {|i| result += 1 if s[i] == t[i]}\n\nputs result", "language": "Ruby", "metadata": {"date": 1568193520, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s330387451.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s330387451", "user_id": "u622469330"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "s = gets.chomp\nt = gets.chomp\n\nresult = 0\n\n3.times {|i| result += 1 if s[i] == t[i]}\n\nputs result", "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": 97, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s934768745", "group_id": "codeNet:p02921", "input_text": "S = gets.chomp.chars\nT = gets.chomp.chars\ncnt = 0\n\n3.times do |i|\n cnt += 1 if S[i] == T[i]\nend\n\nputs cnt\n", "language": "Ruby", "metadata": {"date": 1567364612, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s934768745.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s934768745", "user_id": "u776649162"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "S = gets.chomp.chars\nT = gets.chomp.chars\ncnt = 0\n\n3.times do |i|\n cnt += 1 if S[i] == T[i]\nend\n\nputs cnt\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": 107, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s990979485", "group_id": "codeNet:p02922", "input_text": "a,b = gets.split(\" \")\na = a.to_i\nb = b.to_i\n\nif a > b\n puts 1\nelsif b % a > 0\n puts b / a + 1\nelse\n puts b / a\nend\n", "language": "Ruby", "metadata": {"date": 1576515705, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s990979485.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s990979485", "user_id": "u944733909"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "a,b = gets.split(\" \")\na = a.to_i\nb = b.to_i\n\nif a > b\n puts 1\nelsif b % a > 0\n puts b / a + 1\nelse\n puts b / a\nend\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": 124, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s830967084", "group_id": "codeNet:p02922", "input_text": "a,b=gets.strip.split.map(&:to_i)\nx = 1;\nwhile a*x max\n cnt = 0\n end\nend\nmax = cnt if cnt > max\nputs max", "language": "Ruby", "metadata": {"date": 1599976289, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s556697230.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s556697230", "user_id": "u138026316"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "N = gets.to_i\nH = gets.split.map &:to_i\n\ncnt = 0\nmax = 0\n(1..N-1).each do |i|\n if H[i] - H[i-1] <= 0\n cnt += 1\n else\n max = cnt if cnt > max\n cnt = 0\n end\nend\nmax = cnt if cnt > max\nputs max", "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": 202, "cpu_time_ms": 93, "memory_kb": 20716}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s624025796", "group_id": "codeNet:p02923", "input_text": "n = gets.chomp.to_i\nh = gets.chomp.split(\" \").map(&:to_i)\nmax = 0\ncount = 0\ni = 0\n\nwhile true\n if h.size == 1\n puts max\n break\n end\n if h[i] >= h[i+1]\n count += 1\n #p count\n else\n \n count = 0\n end\n max = [max,count].max\n i += 1\n if i == n-1\n puts max\n break\n end\n \nend\n", "language": "Ruby", "metadata": {"date": 1595121033, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s624025796.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s624025796", "user_id": "u412789323"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n = gets.chomp.to_i\nh = gets.chomp.split(\" \").map(&:to_i)\nmax = 0\ncount = 0\ni = 0\n\nwhile true\n if h.size == 1\n puts max\n break\n end\n if h[i] >= h[i+1]\n count += 1\n #p count\n else\n \n count = 0\n end\n max = [max,count].max\n i += 1\n if i == n-1\n puts max\n break\n end\n \nend\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": 355, "cpu_time_ms": 88, "memory_kb": 21908}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s316159529", "group_id": "codeNet:p02923", "input_text": "n = gets.to_i\nh = gets.split.map(&:to_i)\n\nmovables = Array.new(n, 0)\n(n - 1).times do |i|\n movables[i + 1] = 1 if h[i] >= h[i + 1]\nend\n\nans = 0\nn.times do |nn|\n if movables[nn] == 1\n ans += 1\n else\n ans = 0\n end\nend\n\nputs ans", "language": "Ruby", "metadata": {"date": 1583869310, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s316159529.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s316159529", "user_id": "u889326464"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n = gets.to_i\nh = gets.split.map(&:to_i)\n\nmovables = Array.new(n, 0)\n(n - 1).times do |i|\n movables[i + 1] = 1 if h[i] >= h[i + 1]\nend\n\nans = 0\nn.times do |nn|\n if movables[nn] == 1\n ans += 1\n else\n ans = 0\n end\nend\n\nputs ans", "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": 235, "cpu_time_ms": 68, "memory_kb": 9348}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s859765018", "group_id": "codeNet:p02923", "input_text": "n = gets.to_i\nh = gets.split(' ').map(&:to_i)\ncount = 0\ncounts = []\nif n ==1\n puts 0\nelse\n (n-1).times do |a|\n if h[a] >= h[a+1]\n count +=1 \n else\n count = 0\n end\n counts << count\n end\n \n puts counts.max\nend", "language": "Ruby", "metadata": {"date": 1573421356, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s859765018.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s859765018", "user_id": "u932417742"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n = gets.to_i\nh = gets.split(' ').map(&:to_i)\ncount = 0\ncounts = []\nif n ==1\n puts 0\nelse\n (n-1).times do |a|\n if h[a] >= h[a+1]\n count +=1 \n else\n count = 0\n end\n counts << count\n end\n \n puts counts.max\nend", "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": 272, "cpu_time_ms": 67, "memory_kb": 9476}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s586785854", "group_id": "codeNet:p02923", "input_text": "# your code goes here\n\nsize = gets.to_i;\ninput = gets.split(\" \").map(&:to_i).reverse;\n\ncanmove = Array.new();\n\nfor i in 0..size-2 do\n\tif (input[i] > input[i+1])\n\t\tcanmove.push(0)\n\telse\n\t\tcanmove.push(1)\n\tend\nend\ncanmove.reverse!\n\nmaxmove = 0\nmove = 0\ncanmove.each { |i|\n\tif (i==1)\n\t\tmove = move + 1\n\telse\n\t\tif move > maxmove\n\t\t\tmaxmove = move\n\t\tend\n\t\tmove = 0\n\tend\n}\n\nif move > maxmove\n\tmaxmove = move\nend\n\nputs maxmove\n", "language": "Ruby", "metadata": {"date": 1567367074, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s586785854.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s586785854", "user_id": "u739733485"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "# your code goes here\n\nsize = gets.to_i;\ninput = gets.split(\" \").map(&:to_i).reverse;\n\ncanmove = Array.new();\n\nfor i in 0..size-2 do\n\tif (input[i] > input[i+1])\n\t\tcanmove.push(0)\n\telse\n\t\tcanmove.push(1)\n\tend\nend\ncanmove.reverse!\n\nmaxmove = 0\nmove = 0\ncanmove.each { |i|\n\tif (i==1)\n\t\tmove = move + 1\n\telse\n\t\tif move > maxmove\n\t\t\tmaxmove = move\n\t\tend\n\t\tmove = 0\n\tend\n}\n\nif move > maxmove\n\tmaxmove = move\nend\n\nputs maxmove\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": 420, "cpu_time_ms": 70, "memory_kb": 10404}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s682307107", "group_id": "codeNet:p02924", "input_text": "(0..(gets.to_i-1)).inject(:+)", "language": "Ruby", "metadata": {"date": 1591728453, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02924.html", "problem_id": "p02924", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02924/input.txt", "sample_output_relpath": "derived/input_output/data/p02924/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02924/Ruby/s682307107.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s682307107", "user_id": "u600153083"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "(0..(gets.to_i-1)).inject(:+)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFor an integer N, we will choose a permutation \\{P_1, P_2, ..., P_N\\} of \\{1, 2, ..., N\\}.\n\nThen, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.\n\nFind the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1\n\nWhen the permutation \\{P_1, P_2\\} = \\{2, 1\\} is chosen, M_1 + M_2 = 1 + 0 = 1.\n\nSample Input 2\n\n13\n\nSample Output 2\n\n78\n\nSample Input 3\n\n1\n\nSample Output 3\n\n0", "sample_input": "2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02924", "source_text": "Score : 400 points\n\nProblem Statement\n\nFor an integer N, we will choose a permutation \\{P_1, P_2, ..., P_N\\} of \\{1, 2, ..., N\\}.\n\nThen, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.\n\nFind the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1\n\nWhen the permutation \\{P_1, P_2\\} = \\{2, 1\\} is chosen, M_1 + M_2 = 1 + 0 = 1.\n\nSample Input 2\n\n13\n\nSample Output 2\n\n78\n\nSample Input 3\n\n1\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 29, "cpu_time_ms": 2107, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s439933612", "group_id": "codeNet:p02924", "input_text": "N = gets.to_i\n\nputs (1..(N-1)).inject(0,:+)\n", "language": "Ruby", "metadata": {"date": 1568550003, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02924.html", "problem_id": "p02924", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02924/input.txt", "sample_output_relpath": "derived/input_output/data/p02924/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02924/Ruby/s439933612.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s439933612", "user_id": "u947517859"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N = gets.to_i\n\nputs (1..(N-1)).inject(0,:+)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFor an integer N, we will choose a permutation \\{P_1, P_2, ..., P_N\\} of \\{1, 2, ..., N\\}.\n\nThen, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.\n\nFind the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1\n\nWhen the permutation \\{P_1, P_2\\} = \\{2, 1\\} is chosen, M_1 + M_2 = 1 + 0 = 1.\n\nSample Input 2\n\n13\n\nSample Output 2\n\n78\n\nSample Input 3\n\n1\n\nSample Output 3\n\n0", "sample_input": "2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02924", "source_text": "Score : 400 points\n\nProblem Statement\n\nFor an integer N, we will choose a permutation \\{P_1, P_2, ..., P_N\\} of \\{1, 2, ..., N\\}.\n\nThen, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.\n\nFind the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1\n\nWhen the permutation \\{P_1, P_2\\} = \\{2, 1\\} is chosen, M_1 + M_2 = 1 + 0 = 1.\n\nSample Input 2\n\n13\n\nSample Output 2\n\n78\n\nSample Input 3\n\n1\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 44, "cpu_time_ms": 2107, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s282575686", "group_id": "codeNet:p02925", "input_text": "def toid(i, j)\n # 頂点番号を返す\n i, j = j, i if i > j\n return $id[[i, j].inspect]\nend\n\ndef dfs(v)\n if $visited[v]\n return -1 if !$calc[v]\n return $dp[v]\n end\n $visited[v] = true\n $dp[v] = 1\n $to[v].each do |u|\n res = dfs(u)\n return -1 if res == -1\n $dp[v] = [$dp[v], res + 1].max\n end\n $calc[v] = true\n return $dp[v]\nend\n\nn = gets.to_i\n$visited = Array.new(n)\n$calc = Array.new(n)\n$dp = Array.new(n, 0)\n$a = n.times.map { gets.split.map { |x| x.to_i - 1 } }\nv = 0\n$id = Hash.new(0)\n$to = Array.new(n * (n - 1)) { [] }\nn.times do |i|\n n.times do |j|\n if i < j\n $id[[i, j].inspect] = v + 1\n v += 1\n end\n end\nend\n\nn.times do |i|\n (n - 1).times do |j|\n $a[i][j] = toid(i, $a[i][j])\n end\n (n - 2).times do |j|\n $to[$a[i][j + 1]] << $a[i][j]\n end\nend\nans = 0\nv.times do |i|\n res = dfs(i)\n if res == -1\n p -1\n exit\n end\n ans = [ans, res].max\nend\np ans\n", "language": "Ruby", "metadata": {"date": 1567435193, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s282575686.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s282575686", "user_id": "u706695185"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "def toid(i, j)\n # 頂点番号を返す\n i, j = j, i if i > j\n return $id[[i, j].inspect]\nend\n\ndef dfs(v)\n if $visited[v]\n return -1 if !$calc[v]\n return $dp[v]\n end\n $visited[v] = true\n $dp[v] = 1\n $to[v].each do |u|\n res = dfs(u)\n return -1 if res == -1\n $dp[v] = [$dp[v], res + 1].max\n end\n $calc[v] = true\n return $dp[v]\nend\n\nn = gets.to_i\n$visited = Array.new(n)\n$calc = Array.new(n)\n$dp = Array.new(n, 0)\n$a = n.times.map { gets.split.map { |x| x.to_i - 1 } }\nv = 0\n$id = Hash.new(0)\n$to = Array.new(n * (n - 1)) { [] }\nn.times do |i|\n n.times do |j|\n if i < j\n $id[[i, j].inspect] = v + 1\n v += 1\n end\n end\nend\n\nn.times do |i|\n (n - 1).times do |j|\n $a[i][j] = toid(i, $a[i][j])\n end\n (n - 2).times do |j|\n $to[$a[i][j + 1]] << $a[i][j]\n end\nend\nans = 0\nv.times do |i|\n res = dfs(i)\n if res == -1\n p -1\n exit\n end\n ans = [ans, res].max\nend\np ans\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": 917, "cpu_time_ms": 2119, "memory_kb": 197244}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s654862523", "group_id": "codeNet:p02925", "input_text": "n = gets.to_i\na = Array.new(n+1)\nfor i in 1..n\n a[i] = gets.split.map(&:to_i)\nend\n\nids = Array.new(n+1, 0)\ndays = 0\ncnt = 0\nflag = 0\nwhile cnt < n*(n-1)\n flag = 0\n incid = Array.new(n)\n inccnt = 0\n for i in 1..n\n if ids[i] <= n-2\n if a[a[i][ids[i]]][ids[a[i][ids[i]]]] == i\n flag = 1\n cnt += 1\n incid[inccnt] = i\n inccnt += 1\n end\n end\n end\n days += 1\n if flag == 0\n break\n else\n for i in 0..(inccnt-1)\n ids[incid[i]] += 1\n end\n end\nend\n\nif flag == 0\n puts -1\nelse\n puts days\nend", "language": "Ruby", "metadata": {"date": 1567373552, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s654862523.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s654862523", "user_id": "u326891688"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "n = gets.to_i\na = Array.new(n+1)\nfor i in 1..n\n a[i] = gets.split.map(&:to_i)\nend\n\nids = Array.new(n+1, 0)\ndays = 0\ncnt = 0\nflag = 0\nwhile cnt < n*(n-1)\n flag = 0\n incid = Array.new(n)\n inccnt = 0\n for i in 1..n\n if ids[i] <= n-2\n if a[a[i][ids[i]]][ids[a[i][ids[i]]]] == i\n flag = 1\n cnt += 1\n incid[inccnt] = i\n inccnt += 1\n end\n end\n end\n days += 1\n if flag == 0\n break\n else\n for i in 0..(inccnt-1)\n ids[incid[i]] += 1\n end\n end\nend\n\nif flag == 0\n puts -1\nelse\n puts days\nend", "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": 549, "cpu_time_ms": 2110, "memory_kb": 35348}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s993742642", "group_id": "codeNet:p02926", "input_text": "p [*0...gets.to_i**2].product([*$<].map{|x|\n\tComplex(*x.split.map(&:to_i))\n}.sort_by(&:arg)).group_by(&:first).map{|x|\n\t[*x[0]/x[1].size..x[0]/x[1].size+x[0]%x[1].size].map{|y|x[1][y%x[1].size][1]}.inject(:+).abs\n}.max", "language": "Ruby", "metadata": {"date": 1567714338, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02926.html", "problem_id": "p02926", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02926/input.txt", "sample_output_relpath": "derived/input_output/data/p02926/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02926/Ruby/s993742642.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s993742642", "user_id": "u656771711"}, "prompt_components": {"gold_output": "10.000000000000000000000000000000000000000000000000\n", "input_to_evaluate": "p [*0...gets.to_i**2].product([*$<].map{|x|\n\tComplex(*x.split.map(&:to_i))\n}.sort_by(&:arg)).group_by(&:first).map{|x|\n\t[*x[0]/x[1].size..x[0]/x[1].size+x[0]%x[1].size].map{|y|x[1][y%x[1].size][1]}.inject(:+).abs\n}.max", "problem_context": "Score: 600 points\n\nProblem Statement\n\nE869120 is initially standing at the origin (0, 0) in a two-dimensional plane.\n\nHe has N engines, which can be used as follows:\n\nWhen E869120 uses the i-th engine, his X- and Y-coordinate change by x_i and y_i, respectively. In other words, if E869120 uses the i-th engine from coordinates (X, Y), he will move to the coordinates (X + x_i, Y + y_i).\n\nE869120 can use these engines in any order, but each engine can be used at most once. He may also choose not to use some of the engines.\n\nHe wants to go as far as possible from the origin.\nLet (X, Y) be his final coordinates. Find the maximum possible value of \\sqrt{X^2 + Y^2}, the distance from the origin.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n-1 \\ 000 \\ 000 \\leq x_i \\leq 1 \\ 000 \\ 000\n\n-1 \\ 000 \\ 000 \\leq y_i \\leq 1 \\ 000 \\ 000\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 maximum possible final distance from the origin, as a real value.\nYour output is considered correct when the relative or absolute error from the true answer is at most 10^{-10}.\n\nSample Input 1\n\n3\n0 10\n5 -5\n-5 -5\n\nSample Output 1\n\n10.000000000000000000000000000000000000000000000000\n\nThe final distance from the origin can be 10 if we use the engines in one of the following three ways:\n\nUse Engine 1 to move to (0, 10).\n\nUse Engine 2 to move to (5, -5), and then use Engine 3 to move to (0, -10).\n\nUse Engine 3 to move to (-5, -5), and then use Engine 2 to move to (0, -10).\n\nThe distance cannot be greater than 10, so the maximum possible distance is 10.\n\nSample Input 2\n\n5\n1 1\n1 0\n0 1\n-1 0\n0 -1\n\nSample Output 2\n\n2.828427124746190097603377448419396157139343750753\n\nThe maximum possible final distance is 2 \\sqrt{2} = 2.82842....\nOne of the ways to achieve it is:\n\nUse Engine 1 to move to (1, 1), and then use Engine 2 to move to (2, 1), and finally use Engine 3 to move to (2, 2).\n\nSample Input 3\n\n5\n1 1\n2 2\n3 3\n4 4\n5 5\n\nSample Output 3\n\n21.213203435596425732025330863145471178545078130654\n\nIf we use all the engines in the order 1 \\rightarrow 2 \\rightarrow 3 \\rightarrow 4 \\rightarrow 5, we will end up at (15, 15), with the distance 15 \\sqrt{2} = 21.2132... from the origin.\n\nSample Input 4\n\n3\n0 0\n0 1\n1 0\n\nSample Output 4\n\n1.414213562373095048801688724209698078569671875376\n\nThere can be useless engines with (x_i, y_i) = (0, 0).\n\nSample Input 5\n\n1\n90447 91000\n\nSample Output 5\n\n128303.000000000000000000000000000000000000000000000000\n\nNote that there can be only one engine.\n\nSample Input 6\n\n2\n96000 -72000\n-72000 54000\n\nSample Output 6\n\n120000.000000000000000000000000000000000000000000000000\n\nThere can be only two engines, too.\n\nSample Input 7\n\n10\n1 2\n3 4\n5 6\n7 8\n9 10\n11 12\n13 14\n15 16\n17 18\n19 20\n\nSample Output 7\n\n148.660687473185055226120082139313966514489855137208", "sample_input": "3\n0 10\n5 -5\n-5 -5\n"}, "reference_outputs": ["10.000000000000000000000000000000000000000000000000\n"], "source_document_id": "p02926", "source_text": "Score: 600 points\n\nProblem Statement\n\nE869120 is initially standing at the origin (0, 0) in a two-dimensional plane.\n\nHe has N engines, which can be used as follows:\n\nWhen E869120 uses the i-th engine, his X- and Y-coordinate change by x_i and y_i, respectively. In other words, if E869120 uses the i-th engine from coordinates (X, Y), he will move to the coordinates (X + x_i, Y + y_i).\n\nE869120 can use these engines in any order, but each engine can be used at most once. He may also choose not to use some of the engines.\n\nHe wants to go as far as possible from the origin.\nLet (X, Y) be his final coordinates. Find the maximum possible value of \\sqrt{X^2 + Y^2}, the distance from the origin.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n-1 \\ 000 \\ 000 \\leq x_i \\leq 1 \\ 000 \\ 000\n\n-1 \\ 000 \\ 000 \\leq y_i \\leq 1 \\ 000 \\ 000\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 maximum possible final distance from the origin, as a real value.\nYour output is considered correct when the relative or absolute error from the true answer is at most 10^{-10}.\n\nSample Input 1\n\n3\n0 10\n5 -5\n-5 -5\n\nSample Output 1\n\n10.000000000000000000000000000000000000000000000000\n\nThe final distance from the origin can be 10 if we use the engines in one of the following three ways:\n\nUse Engine 1 to move to (0, 10).\n\nUse Engine 2 to move to (5, -5), and then use Engine 3 to move to (0, -10).\n\nUse Engine 3 to move to (-5, -5), and then use Engine 2 to move to (0, -10).\n\nThe distance cannot be greater than 10, so the maximum possible distance is 10.\n\nSample Input 2\n\n5\n1 1\n1 0\n0 1\n-1 0\n0 -1\n\nSample Output 2\n\n2.828427124746190097603377448419396157139343750753\n\nThe maximum possible final distance is 2 \\sqrt{2} = 2.82842....\nOne of the ways to achieve it is:\n\nUse Engine 1 to move to (1, 1), and then use Engine 2 to move to (2, 1), and finally use Engine 3 to move to (2, 2).\n\nSample Input 3\n\n5\n1 1\n2 2\n3 3\n4 4\n5 5\n\nSample Output 3\n\n21.213203435596425732025330863145471178545078130654\n\nIf we use all the engines in the order 1 \\rightarrow 2 \\rightarrow 3 \\rightarrow 4 \\rightarrow 5, we will end up at (15, 15), with the distance 15 \\sqrt{2} = 21.2132... from the origin.\n\nSample Input 4\n\n3\n0 0\n0 1\n1 0\n\nSample Output 4\n\n1.414213562373095048801688724209698078569671875376\n\nThere can be useless engines with (x_i, y_i) = (0, 0).\n\nSample Input 5\n\n1\n90447 91000\n\nSample Output 5\n\n128303.000000000000000000000000000000000000000000000000\n\nNote that there can be only one engine.\n\nSample Input 6\n\n2\n96000 -72000\n-72000 54000\n\nSample Output 6\n\n120000.000000000000000000000000000000000000000000000000\n\nThere can be only two engines, too.\n\nSample Input 7\n\n10\n1 2\n3 4\n5 6\n7 8\n9 10\n11 12\n13 14\n15 16\n17 18\n19 20\n\nSample Output 7\n\n148.660687473185055226120082139313966514489855137208", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 218, "cpu_time_ms": 696, "memory_kb": 89848}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s614402680", "group_id": "codeNet:p02927", "input_text": "m,d = gets.split.map(&:to_i)\nans = 0\n(2..m).each do |i|\n (22..d).each do |j|\n next if j%10 < 2\n if i == j.to_s.split(\"\").map(&:to_i).inject(:*)\n ans += 1\n end\n end\nend\nputs ans", "language": "Ruby", "metadata": {"date": 1566695091, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02927.html", "problem_id": "p02927", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02927/input.txt", "sample_output_relpath": "derived/input_output/data/p02927/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02927/Ruby/s614402680.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s614402680", "user_id": "u506255180"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "m,d = gets.split.map(&:to_i)\nans = 0\n(2..m).each do |i|\n (22..d).each do |j|\n next if j%10 < 2\n if i == j.to_s.split(\"\").map(&:to_i).inject(:*)\n ans += 1\n end\n end\nend\nputs ans", "problem_context": "Score : 200 points\n\nProblem Statement\n\nToday is August 24, one of the five Product Days in a year.\n\nA date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day):\n\nd_1 \\geq 2\n\nd_{10} \\geq 2\n\nd_1 \\times d_{10} = m\n\nTakahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D.\n\nIn Takahashi Calendar, how many Product Days does a year have?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq M \\leq 100\n\n1 \\leq D \\leq 99\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM D\n\nOutput\n\nPrint the number of Product Days in a year in Takahashi Calender.\n\nSample Input 1\n\n15 40\n\nSample Output 1\n\n10\n\nThere are 10 Product Days in a year, as follows (m-d denotes Month m, Day d):\n\n4-22\n\n6-23\n\n6-32\n\n8-24\n\n9-33\n\n10-25\n\n12-26\n\n12-34\n\n14-27\n\n15-35\n\nSample Input 2\n\n12 31\n\nSample Output 2\n\n5\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "sample_input": "15 40\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02927", "source_text": "Score : 200 points\n\nProblem Statement\n\nToday is August 24, one of the five Product Days in a year.\n\nA date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day):\n\nd_1 \\geq 2\n\nd_{10} \\geq 2\n\nd_1 \\times d_{10} = m\n\nTakahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D.\n\nIn Takahashi Calendar, how many Product Days does a year have?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq M \\leq 100\n\n1 \\leq D \\leq 99\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM D\n\nOutput\n\nPrint the number of Product Days in a year in Takahashi Calender.\n\nSample Input 1\n\n15 40\n\nSample Output 1\n\n10\n\nThere are 10 Product Days in a year, as follows (m-d denotes Month m, Day d):\n\n4-22\n\n6-23\n\n6-32\n\n8-24\n\n9-33\n\n10-25\n\n12-26\n\n12-34\n\n14-27\n\n15-35\n\nSample Input 2\n\n12 31\n\nSample Output 2\n\n5\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 214, "cpu_time_ms": 40, "memory_kb": 2044}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s801510873", "group_id": "codeNet:p02928", "input_text": "mod = 1000000007\n_, k = gets.chomp.split(' ').map(&:to_i)\narr = gets.chomp.split(' ').map(&:to_i)\ncount1, count2 = 0, 0\narr.each_with_index do |v, i|\n tmp_count1, tmp_count2 = 0, 0\n arr.each_with_index do |vv, ii|\n tmp_count1 += 1 if vv > v && ii < i\n tmp_count2 += 1 if vv > v\n end\n count1 += tmp_count1\n count2 += tmp_count2\nend\nans = (count1 * k) % mod\nans = (ans + k * (k - 1) * count2 / 2) % mod\nputs ans", "language": "Ruby", "metadata": {"date": 1567481984, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02928.html", "problem_id": "p02928", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02928/input.txt", "sample_output_relpath": "derived/input_output/data/p02928/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02928/Ruby/s801510873.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s801510873", "user_id": "u857510905"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "mod = 1000000007\n_, k = gets.chomp.split(' ').map(&:to_i)\narr = gets.chomp.split(' ').map(&:to_i)\ncount1, count2 = 0, 0\narr.each_with_index do |v, i|\n tmp_count1, tmp_count2 = 0, 0\n arr.each_with_index do |vv, ii|\n tmp_count1 += 1 if vv > v && ii < i\n tmp_count2 += 1 if vv > v\n end\n count1 += tmp_count1\n count2 += tmp_count2\nend\nans = (count1 * k) % mod\nans = (ans + k * (k - 1) * count2 / 2) % mod\nputs ans", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}.\n\nLet B be a sequence of K \\times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2.\n\nFind the inversion number of B, modulo 10^9 + 7.\n\nHere the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \\leq i < j \\leq K \\times N - 1) such that B_i > B_j.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2000\n\n1 \\leq K \\leq 10^9\n\n1 \\leq A_i \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_0 A_1 ... A_{N - 1}\n\nOutput\n\nPrint the inversion number of B, modulo 10^9 + 7.\n\nSample Input 1\n\n2 2\n2 1\n\nSample Output 1\n\n3\n\nIn this case, B~=~2,~1,~2,~1. We have:\n\nB_0 > B_1\n\nB_0 > B_3\n\nB_2 > B_3\n\nThus, the inversion number of B is 3.\n\nSample Input 2\n\n3 5\n1 1 1\n\nSample Output 2\n\n0\n\nA may contain multiple occurrences of the same number.\n\nSample Input 3\n\n10 998244353\n10 9 8 7 5 6 3 4 2 1\n\nSample Output 3\n\n185297239\n\nBe sure to print the output modulo 10^9 + 7.", "sample_input": "2 2\n2 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02928", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}.\n\nLet B be a sequence of K \\times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2.\n\nFind the inversion number of B, modulo 10^9 + 7.\n\nHere the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \\leq i < j \\leq K \\times N - 1) such that B_i > B_j.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2000\n\n1 \\leq K \\leq 10^9\n\n1 \\leq A_i \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_0 A_1 ... A_{N - 1}\n\nOutput\n\nPrint the inversion number of B, modulo 10^9 + 7.\n\nSample Input 1\n\n2 2\n2 1\n\nSample Output 1\n\n3\n\nIn this case, B~=~2,~1,~2,~1. We have:\n\nB_0 > B_1\n\nB_0 > B_3\n\nB_2 > B_3\n\nThus, the inversion number of B is 3.\n\nSample Input 2\n\n3 5\n1 1 1\n\nSample Output 2\n\n0\n\nA may contain multiple occurrences of the same number.\n\nSample Input 3\n\n10 998244353\n10 9 8 7 5 6 3 4 2 1\n\nSample Output 3\n\n185297239\n\nBe sure to print the output modulo 10^9 + 7.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 420, "cpu_time_ms": 400, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s478023982", "group_id": "codeNet:p02934", "input_text": "n = $stdin.gets.chomp.to_i\narr = $stdin.gets.chomp.split(\" \")\narr.map! do |a_j|\na_j.to_f\nend\n\ncount = 1/arr[0]\n\nfor i in 1..n-1\n count += 1/arr[i]\nend\n\nputs 1/count", "language": "Ruby", "metadata": {"date": 1567125803, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s478023982.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s478023982", "user_id": "u294388467"}, "prompt_components": {"gold_output": "7.5\n", "input_to_evaluate": "n = $stdin.gets.chomp.to_i\narr = $stdin.gets.chomp.split(\" \")\narr.map! do |a_j|\na_j.to_f\nend\n\ncount = 1/arr[0]\n\nfor i in 1..n-1\n count += 1/arr[i]\nend\n\nputs 1/count", "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": 165, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s602790192", "group_id": "codeNet:p02945", "input_text": "a, b = gets.strip.split.map(&:to_i)\ncaluc = [a + b, a - b, a * b]\nprint(caluc.max)", "language": "Ruby", "metadata": {"date": 1574391800, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02945.html", "problem_id": "p02945", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02945/input.txt", "sample_output_relpath": "derived/input_output/data/p02945/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02945/Ruby/s602790192.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s602790192", "user_id": "u291303244"}, "prompt_components": {"gold_output": "-10\n", "input_to_evaluate": "a, b = gets.strip.split.map(&:to_i)\ncaluc = [a + b, a - b, a * b]\nprint(caluc.max)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have two integers: A and B.\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nConstraints\n\nAll values in input are integers.\n\n-100 \\leq A,\\ B \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nSample Input 1\n\n-13 3\n\nSample Output 1\n\n-10\n\nThe largest number among A + B = -10, A - B = -16, and A \\times B = -39 is -10.\n\nSample Input 2\n\n1 -33\n\nSample Output 2\n\n34\n\nThe largest number among A + B = -32, A - B = 34, and A \\times B = -33 is 34.\n\nSample Input 3\n\n13 3\n\nSample Output 3\n\n39\n\nThe largest number among A + B = 16, A - B = 10, and A \\times B = 39 is 39.", "sample_input": "-13 3\n"}, "reference_outputs": ["-10\n"], "source_document_id": "p02945", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have two integers: A and B.\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nConstraints\n\nAll values in input are integers.\n\n-100 \\leq A,\\ B \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nSample Input 1\n\n-13 3\n\nSample Output 1\n\n-10\n\nThe largest number among A + B = -10, A - B = -16, and A \\times B = -39 is -10.\n\nSample Input 2\n\n1 -33\n\nSample Output 2\n\n34\n\nThe largest number among A + B = -32, A - B = 34, and A \\times B = -33 is 34.\n\nSample Input 3\n\n13 3\n\nSample Output 3\n\n39\n\nThe largest number among A + B = 16, A - B = 10, and A \\times B = 39 is 39.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 82, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s127524048", "group_id": "codeNet:p02946", "input_text": "k,x=gets.chomp.split(\" \").map(&:to_i)\n\na1=((x-k+1)..(x-1)).to_a\na2=(x..(x+k-1)).to_a\n\nputs (a1+a2).select{|e| -1000000<=e && e<=1000000}.join(\" \")\n", "language": "Ruby", "metadata": {"date": 1565844455, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s127524048.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s127524048", "user_id": "u058568575"}, "prompt_components": {"gold_output": "5 6 7 8 9\n", "input_to_evaluate": "k,x=gets.chomp.split(\" \").map(&:to_i)\n\na1=((x-k+1)..(x-1)).to_a\na2=(x..(x+k-1)).to_a\n\nputs (a1+a2).select{|e| -1000000<=e && e<=1000000}.join(\" \")\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": 147, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s743274534", "group_id": "codeNet:p02947", "input_text": "n = gets.to_i\ns = Array.new(n){ gets.chomp.bytes.sort }.sort\n\nans = 0\ncnt = 0\nn.times do |i|\n \n if i == n - 1 or s[i] != s[i+1]\n ans += (cnt+1)*cnt/2\n cnt = 0\n else\n cnt += 1\n end\nend\n\nputs ans", "language": "Ruby", "metadata": {"date": 1587634304, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s743274534.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s743274534", "user_id": "u693378622"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n = gets.to_i\ns = Array.new(n){ gets.chomp.bytes.sort }.sort\n\nans = 0\ncnt = 0\nn.times do |i|\n \n if i == n - 1 or s[i] != s[i+1]\n ans += (cnt+1)*cnt/2\n cnt = 0\n else\n cnt += 1\n end\nend\n\nputs ans", "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": 226, "cpu_time_ms": 1049, "memory_kb": 21752}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s476430233", "group_id": "codeNet:p02947", "input_text": "def r;gets.split.map &:to_i;end\ndef rr(n);n.times.map{gets.chomp.chars.sort.join};end\nN = gets.to_i\nS = rr(N)\nS.sort!\n\nkey = nil\nans = 0\ncount = 1\nS.each do |s|\n if s == key\n count += 1\n else\n ans += count * (count + 1) / 2\n count = 0\n key = s\n end\nend\n\nputs ans", "language": "Ruby", "metadata": {"date": 1574990308, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s476430233.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s476430233", "user_id": "u106964380"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "def r;gets.split.map &:to_i;end\ndef rr(n);n.times.map{gets.chomp.chars.sort.join};end\nN = gets.to_i\nS = rr(N)\nS.sort!\n\nkey = nil\nans = 0\ncount = 1\nS.each do |s|\n if s == key\n count += 1\n else\n ans += count * (count + 1) / 2\n count = 0\n key = s\n end\nend\n\nputs ans", "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": 277, "cpu_time_ms": 515, "memory_kb": 25592}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s574391915", "group_id": "codeNet:p02947", "input_text": "#!/usr/bin/env ruby\nn, = ARGF.gets.split.map {|x| x.to_i}\nhash1 = Hash.new(0)\n(1..n).map do\n hash2 = Hash.new(0)\n ARGF.gets.chomp.each_codepoint do |ch|\n hash2[ch] += 1\n end\n hash1[hash2.hash] += 1\nend\nputs hash1.values.map{|v|(v-1)*v/2}.sum\n", "language": "Ruby", "metadata": {"date": 1565743321, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s574391915.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s574391915", "user_id": "u346077300"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#!/usr/bin/env ruby\nn, = ARGF.gets.split.map {|x| x.to_i}\nhash1 = Hash.new(0)\n(1..n).map do\n hash2 = Hash.new(0)\n ARGF.gets.chomp.each_codepoint do |ch|\n hash2[ch] += 1\n end\n hash1[hash2.hash] += 1\nend\nputs hash1.values.map{|v|(v-1)*v/2}.sum\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\n\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\n\nGiven are N strings s_1, s_2, \\ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\ns_i is a string of length 10.\n\nEach character in s_i is a lowercase English letter.\n\ns_1, s_2, \\ldots, s_N are all distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nSample Input 1\n\n3\nacornistnt\npeanutbomb\nconstraint\n\nSample Output 1\n\n1\n\ns_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.\n\nSample Input 2\n\n2\noneplustwo\nninemodsix\n\nSample Output 2\n\n0\n\nIf there is no pair i, j such that s_i is an anagram of s_j, print 0.\n\nSample Input 3\n\n5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa\n\nSample Output 3\n\n4\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "sample_input": "3\nacornistnt\npeanutbomb\nconstraint\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02947", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\n\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\n\nGiven are N strings s_1, s_2, \\ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\ns_i is a string of length 10.\n\nEach character in s_i is a lowercase English letter.\n\ns_1, s_2, \\ldots, s_N are all distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nSample Input 1\n\n3\nacornistnt\npeanutbomb\nconstraint\n\nSample Output 1\n\n1\n\ns_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.\n\nSample Input 2\n\n2\noneplustwo\nninemodsix\n\nSample Output 2\n\n0\n\nIf there is no pair i, j such that s_i is an anagram of s_j, print 0.\n\nSample Input 3\n\n5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa\n\nSample Output 3\n\n4\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 249, "cpu_time_ms": 963, "memory_kb": 11796}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s814997172", "group_id": "codeNet:p02947", "input_text": "#!/usr/bin/env ruby\nn, = ARGF.gets.split.map {|x| x.to_i}\nhash1 = Hash.new(0)\ns = (1..n).map do\n hash2 = Hash.new(0)\n ARGF.gets.chomp.each_codepoint do |ch|\n hash2[ch] += 1\n end\n hash1[hash2] += 1\nend\nputs hash1.values.map{|v|(v-1)*v/2}.sum\n", "language": "Ruby", "metadata": {"date": 1565743027, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s814997172.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s814997172", "user_id": "u346077300"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#!/usr/bin/env ruby\nn, = ARGF.gets.split.map {|x| x.to_i}\nhash1 = Hash.new(0)\ns = (1..n).map do\n hash2 = Hash.new(0)\n ARGF.gets.chomp.each_codepoint do |ch|\n hash2[ch] += 1\n end\n hash1[hash2] += 1\nend\nputs hash1.values.map{|v|(v-1)*v/2}.sum\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\n\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\n\nGiven are N strings s_1, s_2, \\ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\ns_i is a string of length 10.\n\nEach character in s_i is a lowercase English letter.\n\ns_1, s_2, \\ldots, s_N are all distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nSample Input 1\n\n3\nacornistnt\npeanutbomb\nconstraint\n\nSample Output 1\n\n1\n\ns_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.\n\nSample Input 2\n\n2\noneplustwo\nninemodsix\n\nSample Output 2\n\n0\n\nIf there is no pair i, j such that s_i is an anagram of s_j, print 0.\n\nSample Input 3\n\n5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa\n\nSample Output 3\n\n4\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "sample_input": "3\nacornistnt\npeanutbomb\nconstraint\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02947", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\n\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\n\nGiven are N strings s_1, s_2, \\ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\ns_i is a string of length 10.\n\nEach character in s_i is a lowercase English letter.\n\ns_1, s_2, \\ldots, s_N are all distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nSample Input 1\n\n3\nacornistnt\npeanutbomb\nconstraint\n\nSample Output 1\n\n1\n\ns_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.\n\nSample Input 2\n\n2\noneplustwo\nninemodsix\n\nSample Output 2\n\n0\n\nIf there is no pair i, j such that s_i is an anagram of s_j, print 0.\n\nSample Input 3\n\n5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa\n\nSample Output 3\n\n4\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 248, "cpu_time_ms": 1519, "memory_kb": 93820}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s322639501", "group_id": "codeNet:p02947", "input_text": "lines = readlines\nn = lines[0].chomp.to_i\n\narr = []\nfor i in 1..n do\n arr << lines[i].chomp.chars.sort.join\nend\n\ncount_hash = Hash.new(0)\n\narr.each do |a|\n count_hash[a] += 1\nend\n\nresult = 0\ncount_hash.each_value do |culc|\n result += culc*(culc-1) / 2\nend\n\np result", "language": "Ruby", "metadata": {"date": 1565491689, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s322639501.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s322639501", "user_id": "u589892111"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "lines = readlines\nn = lines[0].chomp.to_i\n\narr = []\nfor i in 1..n do\n arr << lines[i].chomp.chars.sort.join\nend\n\ncount_hash = Hash.new(0)\n\narr.each do |a|\n count_hash[a] += 1\nend\n\nresult = 0\ncount_hash.each_value do |culc|\n result += culc*(culc-1) / 2\nend\n\np result", "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": 268, "cpu_time_ms": 525, "memory_kb": 36844}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s300378513", "group_id": "codeNet:p02947", "input_text": "def signature(word)\n word.chars.sort.join.intern\nend\n\ndef factorial(number)\n (1..number).inject(1,:*)\nend\n\nn = gets.chomp.to_i\n\nstrs = (1..n).map{ gets.chomp }\n\nsigs = strs.map { |word| signature word }\n\ngraph = {}\nsigs.each do |sig|\n graph[sig] = 0 if graph[sig].nil?\n graph[sig] += 1\nend\n\nres = 0\ngraph.each do |g|\n res += (factorial g[1]) / 2 if g[1] >= 2\nend\n\nputs res\n", "language": "Ruby", "metadata": {"date": 1565491035, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s300378513.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s300378513", "user_id": "u675497468"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "def signature(word)\n word.chars.sort.join.intern\nend\n\ndef factorial(number)\n (1..number).inject(1,:*)\nend\n\nn = gets.chomp.to_i\n\nstrs = (1..n).map{ gets.chomp }\n\nsigs = strs.map { |word| signature word }\n\ngraph = {}\nsigs.each do |sig|\n graph[sig] = 0 if graph[sig].nil?\n graph[sig] += 1\nend\n\nres = 0\ngraph.each do |g|\n res += (factorial g[1]) / 2 if g[1] >= 2\nend\n\nputs res\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\n\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\n\nGiven are N strings s_1, s_2, \\ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\ns_i is a string of length 10.\n\nEach character in s_i is a lowercase English letter.\n\ns_1, s_2, \\ldots, s_N are all distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nSample Input 1\n\n3\nacornistnt\npeanutbomb\nconstraint\n\nSample Output 1\n\n1\n\ns_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.\n\nSample Input 2\n\n2\noneplustwo\nninemodsix\n\nSample Output 2\n\n0\n\nIf there is no pair i, j such that s_i is an anagram of s_j, print 0.\n\nSample Input 3\n\n5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa\n\nSample Output 3\n\n4\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "sample_input": "3\nacornistnt\npeanutbomb\nconstraint\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02947", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\n\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\n\nGiven are N strings s_1, s_2, \\ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\ns_i is a string of length 10.\n\nEach character in s_i is a lowercase English letter.\n\ns_1, s_2, \\ldots, s_N are all distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nSample Input 1\n\n3\nacornistnt\npeanutbomb\nconstraint\n\nSample Output 1\n\n1\n\ns_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.\n\nSample Input 2\n\n2\noneplustwo\nninemodsix\n\nSample Output 2\n\n0\n\nIf there is no pair i, j such that s_i is an anagram of s_j, print 0.\n\nSample Input 3\n\n5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa\n\nSample Output 3\n\n4\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 378, "cpu_time_ms": 2115, "memory_kb": 146080}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s790568022", "group_id": "codeNet:p02947", "input_text": "$cc_val = Array.new(100000+1,nil)\n$cc_val[0] = 0\n$cc_val[1] = 0\ndef cc_calc\n for i in 2..100000\n $cc_val[i] = $cc_val[i-1] + i-1\n end\nend\ncc_calc\n\ndef cc\n n = gets.chomp.to_i\n dic = {}\n n.times do\n st = gets.chomp.scan(/./).sort.join\n if dic.has_key?(st)\n dic[st] += 1\n else\n dic[st] = 1\n end\n end\n\n cnt = 0\n dic.each_pair {|k, v|\n cnt += $cc_val[v]\n }\n puts cnt\nend\n\ncc\n", "language": "Ruby", "metadata": {"date": 1565488791, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s790568022.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s790568022", "user_id": "u510887956"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "$cc_val = Array.new(100000+1,nil)\n$cc_val[0] = 0\n$cc_val[1] = 0\ndef cc_calc\n for i in 2..100000\n $cc_val[i] = $cc_val[i-1] + i-1\n end\nend\ncc_calc\n\ndef cc\n n = gets.chomp.to_i\n dic = {}\n n.times do\n st = gets.chomp.scan(/./).sort.join\n if dic.has_key?(st)\n dic[st] += 1\n else\n dic[st] = 1\n end\n end\n\n cnt = 0\n dic.each_pair {|k, v|\n cnt += $cc_val[v]\n }\n puts cnt\nend\n\ncc\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\n\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\n\nGiven are N strings s_1, s_2, \\ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\ns_i is a string of length 10.\n\nEach character in s_i is a lowercase English letter.\n\ns_1, s_2, \\ldots, s_N are all distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nSample Input 1\n\n3\nacornistnt\npeanutbomb\nconstraint\n\nSample Output 1\n\n1\n\ns_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.\n\nSample Input 2\n\n2\noneplustwo\nninemodsix\n\nSample Output 2\n\n0\n\nIf there is no pair i, j such that s_i is an anagram of s_j, print 0.\n\nSample Input 3\n\n5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa\n\nSample Output 3\n\n4\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "sample_input": "3\nacornistnt\npeanutbomb\nconstraint\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02947", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\n\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\n\nGiven are N strings s_1, s_2, \\ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\ns_i is a string of length 10.\n\nEach character in s_i is a lowercase English letter.\n\ns_1, s_2, \\ldots, s_N are all distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the number of pairs of integers i, j (1 \\leq i < j \\leq N) such that s_i is an anagram of s_j.\n\nSample Input 1\n\n3\nacornistnt\npeanutbomb\nconstraint\n\nSample Output 1\n\n1\n\ns_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.\n\nSample Input 2\n\n2\noneplustwo\nninemodsix\n\nSample Output 2\n\n0\n\nIf there is no pair i, j such that s_i is an anagram of s_j, print 0.\n\nSample Input 3\n\n5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa\n\nSample Output 3\n\n4\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 465, "cpu_time_ms": 1111, "memory_kb": 18428}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s677538979", "group_id": "codeNet:p02951", "input_text": "n = gets.split(\" \").map {|e| e.to_i}\na = n[0]\nb = n[1]\nc = n[2]\np(n)\nans = b+c-a\nif ans<0 then ans = 0 end \n\nprint(ans)", "language": "Ruby", "metadata": {"date": 1567224302, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s677538979.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s677538979", "user_id": "u849186626"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n = gets.split(\" \").map {|e| e.to_i}\na = n[0]\nb = n[1]\nc = n[2]\np(n)\nans = b+c-a\nif ans<0 then ans = 0 end \n\nprint(ans)", "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": 119, "cpu_time_ms": 7, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s175607638", "group_id": "codeNet:p02951", "input_text": "a, b, c = gets.chomp.split.map(&:to_i)\nif c - (a - b) < 0\n puts 0\nelse\n puts c - (a - b)\nend\n", "language": "Ruby", "metadata": {"date": 1564966932, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s175607638.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s175607638", "user_id": "u744908753"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "a, b, c = gets.chomp.split.map(&:to_i)\nif c - (a - b) < 0\n puts 0\nelse\n puts c - (a - b)\nend\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": 95, "cpu_time_ms": 7, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s220106634", "group_id": "codeNet:p02952", "input_text": "n = gets.to_i\nans = 0\n\n(1..n).each do |i|\n ans += 1 if i.to_s.size.odd?\nend\n\nputs ans", "language": "Ruby", "metadata": {"date": 1575387276, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s220106634.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s220106634", "user_id": "u147964866"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "n = gets.to_i\nans = 0\n\n(1..n).each do |i|\n ans += 1 if i.to_s.size.odd?\nend\n\nputs ans", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of positive integers less than or equal to N that have an odd number of digits.\n\nSample Input 1\n\n11\n\nSample Output 1\n\n9\n\nAmong the positive integers less than or equal to 11, nine integers have an odd number of digits: 1, 2, \\ldots, 9.\n\nSample Input 2\n\n136\n\nSample Output 2\n\n46\n\nIn addition to 1, 2, \\ldots, 9, another 37 integers also have an odd number of digits: 100, 101, \\ldots, 136.\n\nSample Input 3\n\n100000\n\nSample Output 3\n\n90909", "sample_input": "11\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02952", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of positive integers less than or equal to N that have an odd number of digits.\n\nSample Input 1\n\n11\n\nSample Output 1\n\n9\n\nAmong the positive integers less than or equal to 11, nine integers have an odd number of digits: 1, 2, \\ldots, 9.\n\nSample Input 2\n\n136\n\nSample Output 2\n\n46\n\nIn addition to 1, 2, \\ldots, 9, another 37 integers also have an odd number of digits: 100, 101, \\ldots, 136.\n\nSample Input 3\n\n100000\n\nSample Output 3\n\n90909", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 86, "cpu_time_ms": 28, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s359165450", "group_id": "codeNet:p02952", "input_text": "N = gets.chomp.to_i\n\nif N == 100000\n p 90000 + 900 + 9\nelsif N <= 99999 && N > 10000\n p (N - 10000) + 900 + 9 + 1\nelsif N <= 9999 && N > 1000\n p 900 + 9\nelsif N <= 999 && N > 100\n p (N - 100) + 9 + 1\nelsif N <= 99 && N > 10\n p 9\nelse\n p N\nend\n", "language": "Ruby", "metadata": {"date": 1564968308, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s359165450.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s359165450", "user_id": "u339791405"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "N = gets.chomp.to_i\n\nif N == 100000\n p 90000 + 900 + 9\nelsif N <= 99999 && N > 10000\n p (N - 10000) + 900 + 9 + 1\nelsif N <= 9999 && N > 1000\n p 900 + 9\nelsif N <= 999 && N > 100\n p (N - 100) + 9 + 1\nelsif N <= 99 && N > 10\n p 9\nelse\n p N\nend\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": 249, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s417127579", "group_id": "codeNet:p02954", "input_text": "s = gets.chomp\n\nn = s.length\ncounts = Array.new(n, 1)\n\n(n-2).times do |i|\n if s[i] == 'R' && s[i+1] == 'R'\n counts[i+2] += counts[i]\n counts[i] = 0\n end\nend\n\n(n-2).times do |i|\n if s[-1-i] == 'L' && s[-1-(i+1)] == 'L'\n counts[-1-(i+2)] += counts[-1-i]\n counts[-1-i] = 0\n end\nend\n\nputs(counts.join(' '))", "language": "Ruby", "metadata": {"date": 1566423354, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s417127579.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s417127579", "user_id": "u913444337"}, "prompt_components": {"gold_output": "0 1 2 1 1\n", "input_to_evaluate": "s = gets.chomp\n\nn = s.length\ncounts = Array.new(n, 1)\n\n(n-2).times do |i|\n if s[i] == 'R' && s[i+1] == 'R'\n counts[i+2] += counts[i]\n counts[i] = 0\n end\nend\n\n(n-2).times do |i|\n if s[-1-i] == 'L' && s[-1-(i+1)] == 'L'\n counts[-1-(i+2)] += counts[-1-i]\n counts[-1-i] = 0\n end\nend\n\nputs(counts.join(' '))", "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": 318, "cpu_time_ms": 121, "memory_kb": 3196}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s103053513", "group_id": "codeNet:p02957", "input_text": "a, b = gets.chomp.split.map(&:to_i)\nif a.even? != b.even?\n\tputs \"IMPOSSIBLE\"\n\texit\nend\n\nputs (a + b) / 2\n", "language": "Ruby", "metadata": {"date": 1592963456, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s103053513.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s103053513", "user_id": "u409390792"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "a, b = gets.chomp.split.map(&:to_i)\nif a.even? != b.even?\n\tputs \"IMPOSSIBLE\"\n\texit\nend\n\nputs (a + b) / 2\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nWe have two distinct integers A and B.\n\nPrint the integer K such that |A - K| = |B - K|.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A,\\ B \\leq 10^9\n\nA and B are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the integer K satisfying the condition.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nSample Input 1\n\n2 16\n\nSample Output 1\n\n9\n\n|2 - 9| = 7 and |16 - 9| = 7, so 9 satisfies the condition.\n\nSample Input 2\n\n0 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nNo integer satisfies the condition.\n\nSample Input 3\n\n998244353 99824435\n\nSample Output 3\n\n549034394", "sample_input": "2 16\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02957", "source_text": "Score: 100 points\n\nProblem Statement\n\nWe have two distinct integers A and B.\n\nPrint the integer K such that |A - K| = |B - K|.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A,\\ B \\leq 10^9\n\nA and B are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the integer K satisfying the condition.\n\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\nSample Input 1\n\n2 16\n\nSample Output 1\n\n9\n\n|2 - 9| = 7 and |16 - 9| = 7, so 9 satisfies the condition.\n\nSample Input 2\n\n0 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nNo integer satisfies the condition.\n\nSample Input 3\n\n998244353 99824435\n\nSample Output 3\n\n549034394", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 105, "cpu_time_ms": 67, "memory_kb": 14324}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s853215661", "group_id": "codeNet:p02957", "input_text": "A,B = gets.split.map &:to_i\nputs (A+B) % 2 == 0 ? (A+B)/2 : \"IMPOSSIBLE\"", "language": "Ruby", "metadata": {"date": 1564350091, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s853215661.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s853215661", "user_id": "u670503797"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "A,B = gets.split.map &:to_i\nputs (A+B) % 2 == 0 ? (A+B)/2 : \"IMPOSSIBLE\"", "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": 72, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s615566775", "group_id": "codeNet:p02957", "input_text": "A, B = gets.split(' ').map(&:to_i).sort\nputs (B - A).even? ? B - ((B - A).abs / 2) : 'IMPOSSIBLE'", "language": "Ruby", "metadata": {"date": 1564276359, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s615566775.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s615566775", "user_id": "u857555436"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "A, B = gets.split(' ').map(&:to_i).sort\nputs (B - A).even? ? B - ((B - A).abs / 2) : 'IMPOSSIBLE'", "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": 97, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s518264219", "group_id": "codeNet:p02958", "input_text": "n = gets.to_i\na = gets.split.map(&:to_i)\n \ncount = 0\n(1..n).each do |i|\n count += 1 if i != a[i-1]\nend\n \nif count == 0 || count == 2\n print \"YES\"\nelse\n print \"NO\"\nend", "language": "Ruby", "metadata": {"date": 1572915238, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s518264219.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s518264219", "user_id": "u106964380"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "n = gets.to_i\na = gets.split.map(&:to_i)\n \ncount = 0\n(1..n).each do |i|\n count += 1 if i != a[i-1]\nend\n \nif count == 0 || count == 2\n print \"YES\"\nelse\n print \"NO\"\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a sequence p = {p_1,\\ p_2,\\ ...,\\ p_N} which is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nYou can perform the following operation at most once: choose integers i and j (1 \\leq i < j \\leq N), and swap p_i and p_j. Note that you can also choose not to perform it.\n\nPrint YES if you can sort p in ascending order in this way, and NO otherwise.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\np is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 ... p_N\n\nOutput\n\nPrint YES if you can sort p in ascending order in the way stated in the problem statement, and NO otherwise.\n\nSample Input 1\n\n5\n5 2 3 4 1\n\nSample Output 1\n\nYES\n\nYou can sort p in ascending order by swapping p_1 and p_5.\n\nSample Input 2\n\n5\n2 4 3 5 1\n\nSample Output 2\n\nNO\n\nIn this case, swapping any two elements does not sort p in ascending order.\n\nSample Input 3\n\n7\n1 2 3 4 5 6 7\n\nSample Output 3\n\nYES\n\np is already sorted in ascending order, so no operation is needed.", "sample_input": "5\n5 2 3 4 1\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02958", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a sequence p = {p_1,\\ p_2,\\ ...,\\ p_N} which is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nYou can perform the following operation at most once: choose integers i and j (1 \\leq i < j \\leq N), and swap p_i and p_j. Note that you can also choose not to perform it.\n\nPrint YES if you can sort p in ascending order in this way, and NO otherwise.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\np is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 ... p_N\n\nOutput\n\nPrint YES if you can sort p in ascending order in the way stated in the problem statement, and NO otherwise.\n\nSample Input 1\n\n5\n5 2 3 4 1\n\nSample Output 1\n\nYES\n\nYou can sort p in ascending order by swapping p_1 and p_5.\n\nSample Input 2\n\n5\n2 4 3 5 1\n\nSample Output 2\n\nNO\n\nIn this case, swapping any two elements does not sort p in ascending order.\n\nSample Input 3\n\n7\n1 2 3 4 5 6 7\n\nSample Output 3\n\nYES\n\np is already sorted in ascending order, so no operation is needed.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 169, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s853935241", "group_id": "codeNet:p02959", "input_text": "# frozen_string_literal: true\n\n_ = gets\na = gets.split.map(&:to_i)\nb = gets.split.map(&:to_i)\ncount = 0\n\nb.each_with_index do |i, idx|\n if i > a[idx]\n rest = i - a[idx]\n\n if rest > a[idx + 1]\n count += a[idx] + a[idx + 1]\n a[idx + 1] = 0\n else\n a[idx + 1] -= rest\n count += i\n end\n else\n count += i\n end\nend\n\nputs count", "language": "Ruby", "metadata": {"date": 1585784243, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s853935241.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s853935241", "user_id": "u104886851"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "# frozen_string_literal: true\n\n_ = gets\na = gets.split.map(&:to_i)\nb = gets.split.map(&:to_i)\ncount = 0\n\nb.each_with_index do |i, idx|\n if i > a[idx]\n rest = i - a[idx]\n\n if rest > a[idx + 1]\n count += a[idx] + a[idx + 1]\n a[idx + 1] = 0\n else\n a[idx + 1] -= rest\n count += i\n end\n else\n count += i\n end\nend\n\nputs count", "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": 357, "cpu_time_ms": 105, "memory_kb": 15372}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s690775638", "group_id": "codeNet:p02959", "input_text": "N = gets.to_i\nA = gets.split.map(&:to_i)\nB = gets.split.map(&:to_i)\n\nans = 0\n\nB.each_with_index do |b, idx|\n n = [A[idx], b].min\n b -= n\n\n m = [A[idx + 1], b].min\n A[idx + 1] -= m\n\n ans += n + m\nend\n\nputs ans\n", "language": "Ruby", "metadata": {"date": 1564520592, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s690775638.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s690775638", "user_id": "u740836226"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "N = gets.to_i\nA = gets.split.map(&:to_i)\nB = gets.split.map(&:to_i)\n\nans = 0\n\nB.each_with_index do |b, idx|\n n = [A[idx], b].min\n b -= n\n\n m = [A[idx + 1], b].min\n A[idx + 1] -= m\n\n ans += n + m\nend\n\nputs ans\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "sample_input": "2\n3 5 2\n4 5\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02959", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 214, "cpu_time_ms": 171, "memory_kb": 19356}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s382142837", "group_id": "codeNet:p02959", "input_text": "N = gets.to_i\nA = gets.split.map(&:to_i)\nB = gets.split.map(&:to_i)\n\nc = 0\nN.times do |i|\n b = B[i]\n n = [b, A[i]].min\n b -= n\n c += n\n b = [b, A[i+1]].min\n A[i+1] -= b\n c += b\nend\nputs c\n", "language": "Ruby", "metadata": {"date": 1564277466, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s382142837.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s382142837", "user_id": "u064100484"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "N = gets.to_i\nA = gets.split.map(&:to_i)\nB = gets.split.map(&:to_i)\n\nc = 0\nN.times do |i|\n b = B[i]\n n = [b, A[i]].min\n b -= n\n c += n\n b = [b, A[i+1]].min\n A[i+1] -= b\n c += b\nend\nputs c\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": 195, "cpu_time_ms": 175, "memory_kb": 19596}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s691811644", "group_id": "codeNet:p02960", "input_text": "# 桁DP 最適化もうむり\n\nMOD = 10 ** 9 + 7\ns = gets.chomp.split(\"\")\nquestion = s.map { |c| c == \"?\" }\nlength = s.length\n# dp[上から i 桁まで][13 で割ったあまり]の出現回数\n# 桁の自由度(smaller)は本問では不要\ndp = (length + 1).times.map { Array.new(13, 0) }\n# 初期化\n# dp[0 桁目まで][13 で割ったあまりが 0]の出現回数は 1\ndp[0][0] = 1\n# (右から見た)桁数 % 6\nmod_memo = [4, 1, 10, 9, 12, 3]\nall_nums = (0..9).to_a\n\n# 桁数分ループする(i は遷移元の桁)\nlength.times do |i|\n # 13 で割ったあまりの増加分を求める\n addition = mod_memo[(length - i) % 6]\n # 桁の数字が \"?\" の場合は 10 回ループ、それ以外の場合はその数字のみ\n nums = question[i] ? all_nums : [s[i].to_i]\n dp_current = dp[i]\n # 最適化のため、事前に 1 行分だけ浅いコピーをする\n # dp_next と dp[i + 1] の object_id は同じ\n dp_next = dp[i + 1]\n # 13 で割ったあまりごとに確認する\n 13.times do |mod|\n current_count = dp_current[mod] % MOD\n nums.each do |d|\n # 次の桁に遷移する\n dp_next[(mod + addition * d) % 13] += current_count\n end\n end\nend\n\nputs dp[length][5] %= MOD\n", "language": "Ruby", "metadata": {"date": 1584151180, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02960.html", "problem_id": "p02960", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02960/input.txt", "sample_output_relpath": "derived/input_output/data/p02960/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02960/Ruby/s691811644.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s691811644", "user_id": "u653737129"}, "prompt_components": {"gold_output": "768\n", "input_to_evaluate": "# 桁DP 最適化もうむり\n\nMOD = 10 ** 9 + 7\ns = gets.chomp.split(\"\")\nquestion = s.map { |c| c == \"?\" }\nlength = s.length\n# dp[上から i 桁まで][13 で割ったあまり]の出現回数\n# 桁の自由度(smaller)は本問では不要\ndp = (length + 1).times.map { Array.new(13, 0) }\n# 初期化\n# dp[0 桁目まで][13 で割ったあまりが 0]の出現回数は 1\ndp[0][0] = 1\n# (右から見た)桁数 % 6\nmod_memo = [4, 1, 10, 9, 12, 3]\nall_nums = (0..9).to_a\n\n# 桁数分ループする(i は遷移元の桁)\nlength.times do |i|\n # 13 で割ったあまりの増加分を求める\n addition = mod_memo[(length - i) % 6]\n # 桁の数字が \"?\" の場合は 10 回ループ、それ以外の場合はその数字のみ\n nums = question[i] ? all_nums : [s[i].to_i]\n dp_current = dp[i]\n # 最適化のため、事前に 1 行分だけ浅いコピーをする\n # dp_next と dp[i + 1] の object_id は同じ\n dp_next = dp[i + 1]\n # 13 で割ったあまりごとに確認する\n 13.times do |mod|\n current_count = dp_current[mod] % MOD\n nums.each do |d|\n # 次の桁に遷移する\n dp_next[(mod + addition * d) % 13] += current_count\n end\n end\nend\n\nputs dp[length][5] %= MOD\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a string S. Each character in S is either a digit (0, ..., 9) or ?.\n\nAmong the integers obtained by replacing each occurrence of ? with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.\n\nSince the answer can be enormous, print the count modulo 10^9+7.\n\nConstraints\n\nS is a string consisting of digits (0, ..., 9) and ?.\n\n1 \\leq |S| \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of integers satisfying the condition, modulo 10^9+7.\n\nSample Input 1\n\n??2??5\n\nSample Output 1\n\n768\n\nFor example, 482305, 002865, and 972665 satisfy the condition.\n\nSample Input 2\n\n?44\n\nSample Output 2\n\n1\n\nOnly 044 satisfies the condition.\n\nSample Input 3\n\n7?4\n\nSample Output 3\n\n0\n\nWe may not be able to produce an integer satisfying the condition.\n\nSample Input 4\n\n?6?42???8??2??06243????9??3???7258??5??7???????774????4?1??17???9?5?70???76???\n\nSample Output 4\n\n153716888", "sample_input": "??2??5\n"}, "reference_outputs": ["768\n"], "source_document_id": "p02960", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a string S. Each character in S is either a digit (0, ..., 9) or ?.\n\nAmong the integers obtained by replacing each occurrence of ? with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.\n\nSince the answer can be enormous, print the count modulo 10^9+7.\n\nConstraints\n\nS is a string consisting of digits (0, ..., 9) and ?.\n\n1 \\leq |S| \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of integers satisfying the condition, modulo 10^9+7.\n\nSample Input 1\n\n??2??5\n\nSample Output 1\n\n768\n\nFor example, 482305, 002865, and 972665 satisfy the condition.\n\nSample Input 2\n\n?44\n\nSample Output 2\n\n1\n\nOnly 044 satisfies the condition.\n\nSample Input 3\n\n7?4\n\nSample Output 3\n\n0\n\nWe may not be able to produce an integer satisfying the condition.\n\nSample Input 4\n\n?6?42???8??2??06243????9??3???7258??5??7???????774????4?1??17???9?5?70???76???\n\nSample Output 4\n\n153716888", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1225, "cpu_time_ms": 1841, "memory_kb": 28028}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s589834536", "group_id": "codeNet:p02963", "input_text": "require 'prime'\ns = gets.to_i\nprimes = Prime.prime_division(s)\na = primes.first.first\nb = s.div(a)\nanswer = [0, 0, a, 0, 0, b]\nputs answer.join(' ')", "language": "Ruby", "metadata": {"date": 1599609490, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02963.html", "problem_id": "p02963", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02963/input.txt", "sample_output_relpath": "derived/input_output/data/p02963/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02963/Ruby/s589834536.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s589834536", "user_id": "u464387808"}, "prompt_components": {"gold_output": "1 0 2 2 0 1\n", "input_to_evaluate": "require 'prime'\ns = gets.to_i\nprimes = Prime.prime_division(s)\na = primes.first.first\nb = s.div(a)\nanswer = [0, 0, a, 0, 0, b]\nputs answer.join(' ')", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions:\n\n0 \\leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \\leq 10^9\n\nThe area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.\n\nWe can prove that there always exist six integers that satisfy the conditions under the constraints of this problem.\n\nConstraints\n\n1 \\leq S \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions, in this order, with spaces in between.\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1 0 2 2 0 1\n\nThe area of the triangle in a two-dimensional plane whose vertices are (1,0),(2,2), and (0,1) is 3/2.\nPrinting 3 0 3 1 0 1 or 1 0 0 1 2 2 will also be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n0 0 10 0 0 10\n\nSample Input 3\n\n311114770564041497\n\nSample Output 3\n\n314159265 358979323 846264338 327950288 419716939 937510582", "sample_input": "3\n"}, "reference_outputs": ["1 0 2 2 0 1\n"], "source_document_id": "p02963", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions:\n\n0 \\leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \\leq 10^9\n\nThe area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.\n\nWe can prove that there always exist six integers that satisfy the conditions under the constraints of this problem.\n\nConstraints\n\n1 \\leq S \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions, in this order, with spaces in between.\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1 0 2 2 0 1\n\nThe area of the triangle in a two-dimensional plane whose vertices are (1,0),(2,2), and (0,1) is 3/2.\nPrinting 3 0 3 1 0 1 or 1 0 0 1 2 2 will also be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n0 0 10 0 0 10\n\nSample Input 3\n\n311114770564041497\n\nSample Output 3\n\n314159265 358979323 846264338 327950288 419716939 937510582", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 148, "cpu_time_ms": 2206, "memory_kb": 14468}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s649937030", "group_id": "codeNet:p02971", "input_text": "n=gets.to_i\naNs=[]\nn.times do\n aNs << gets.to_i\nend\nn.times do |index|\n temp = aNs[0...index] + aNs[(index+1)...n]\n puts temp.max\nend", "language": "Ruby", "metadata": {"date": 1572571636, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02971.html", "problem_id": "p02971", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02971/input.txt", "sample_output_relpath": "derived/input_output/data/p02971/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02971/Ruby/s649937030.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s649937030", "user_id": "u802371628"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "n=gets.to_i\naNs=[]\nn.times do\n aNs << gets.to_i\nend\nn.times do |index|\n temp = aNs[0...index] + aNs[(index+1)...n]\n puts temp.max\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "sample_input": "3\n1\n4\n3\n"}, "reference_outputs": ["4\n3\n4\n"], "source_document_id": "p02971", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 136, "cpu_time_ms": 2112, "memory_kb": 77852}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s534858011", "group_id": "codeNet:p02971", "input_text": "n=gets.to_i\na=[]\nmax=0\n(0..n-1).each do |i|\n a[i]=gets.to_i\nend\nmax=a.max\nidx=a.index(max)\na.sort!\n(0..n-1).each do |i|\n if a[-2]==a[-1]\n puts a[-1]\n elsif i == idx\n puts a[-2]\n else\n puts a[-1]\n end\nend", "language": "Ruby", "metadata": {"date": 1563674983, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02971.html", "problem_id": "p02971", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02971/input.txt", "sample_output_relpath": "derived/input_output/data/p02971/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02971/Ruby/s534858011.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s534858011", "user_id": "u135201316"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "n=gets.to_i\na=[]\nmax=0\n(0..n-1).each do |i|\n a[i]=gets.to_i\nend\nmax=a.max\nidx=a.index(max)\na.sort!\n(0..n-1).each do |i|\n if a[-2]==a[-1]\n puts a[-1]\n elsif i == idx\n puts a[-2]\n else\n puts a[-1]\n end\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "sample_input": "3\n1\n4\n3\n"}, "reference_outputs": ["4\n3\n4\n"], "source_document_id": "p02971", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 217, "cpu_time_ms": 311, "memory_kb": 7092}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s158069848", "group_id": "codeNet:p02971", "input_text": "n=gets.to_i\na=[]\nmax=0\nmax_idx=0\nn.times do|i|\n\ta[i]=gets.to_i\n\tif(a[i]>max)\n\t\tmax=a[i]\n\t\tmax_idx=i\n\tend\nend\nfor i in 0..n-1\n\tif(i==max_idx)\n\t\ta.delete_at(max_idx)\n\t\tputs(a.max)\n\t\ti-=1\n\telse\n\t\tputs(max)\n\tend\nend", "language": "Ruby", "metadata": {"date": 1563671611, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02971.html", "problem_id": "p02971", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02971/input.txt", "sample_output_relpath": "derived/input_output/data/p02971/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02971/Ruby/s158069848.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s158069848", "user_id": "u415400221"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "n=gets.to_i\na=[]\nmax=0\nmax_idx=0\nn.times do|i|\n\ta[i]=gets.to_i\n\tif(a[i]>max)\n\t\tmax=a[i]\n\t\tmax_idx=i\n\tend\nend\nfor i in 0..n-1\n\tif(i==max_idx)\n\t\ta.delete_at(max_idx)\n\t\tputs(a.max)\n\t\ti-=1\n\telse\n\t\tputs(max)\n\tend\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "sample_input": "3\n1\n4\n3\n"}, "reference_outputs": ["4\n3\n4\n"], "source_document_id": "p02971", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 211, "cpu_time_ms": 271, "memory_kb": 5192}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s404063902", "group_id": "codeNet:p02972", "input_text": "N = gets.to_i\nas = gets.split \" \"\n\nbs = Array.new(N, 0)\n\ni = N\nwhile (i > 0)\n\ti -= 1\n\tif (as[i] == \"1\")\n\t\tj = i\n\t\tsum = 0\n\t\twhile (j < N)\n\t\t\tsum += bs[j].to_i\n\t\t\tj += (i + 1)\n\t\tend\n\t\tbs[i] = 1 - (sum % 2)\n\tend\nend\n\nans = []\n(0...N).each do |i|\n\tans << (i + 1) if (bs[i] == 1)\nend\n\nputs ans.size\nputs ans.join \" \"\n", "language": "Ruby", "metadata": {"date": 1583864672, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02972.html", "problem_id": "p02972", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02972/input.txt", "sample_output_relpath": "derived/input_output/data/p02972/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02972/Ruby/s404063902.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s404063902", "user_id": "u305384049"}, "prompt_components": {"gold_output": "1\n1\n", "input_to_evaluate": "N = gets.to_i\nas = gets.split \" \"\n\nbs = Array.new(N, 0)\n\ni = N\nwhile (i > 0)\n\ti -= 1\n\tif (as[i] == \"1\")\n\t\tj = i\n\t\tsum = 0\n\t\twhile (j < N)\n\t\t\tsum += bs[j].to_i\n\t\t\tj += (i + 1)\n\t\tend\n\t\tbs[i] = 1 - (sum % 2)\n\tend\nend\n\nans = []\n(0...N).each do |i|\n\tans << (i + 1) if (bs[i] == 1)\nend\n\nputs ans.size\nputs ans.join \" \"\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N empty boxes arranged in a row from left to right.\nThe integer i is written on the i-th box from the left (1 \\leq i \\leq N).\n\nFor each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.\n\nWe say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:\n\nFor every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.\n\nDoes there exist a good set of choices? If the answer is yes, find one good set of choices.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\na_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf a good set of choices does not exist, print -1.\n\nIf a good set of choices exists, print one such set of choices in the following format:\n\nM\nb_1 b_2 ... b_M\n\nwhere M denotes the number of boxes that will contain a ball, and b_1,\\ b_2,\\ ...,\\ b_M are the integers written on these boxes, in any order.\n\nSample Input 1\n\n3\n1 0 0\n\nSample Output 1\n\n1\n1\n\nConsider putting a ball only in the box with 1 written on it.\n\nThere are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.\n\nThere is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.\n\nThere is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.\n\nThus, the condition is satisfied, so this set of choices is good.\n\nSample Input 2\n\n5\n0 0 0 0 0\n\nSample Output 2\n\n0\n\nPutting nothing in the boxes can be a good set of choices.", "sample_input": "3\n1 0 0\n"}, "reference_outputs": ["1\n1\n"], "source_document_id": "p02972", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N empty boxes arranged in a row from left to right.\nThe integer i is written on the i-th box from the left (1 \\leq i \\leq N).\n\nFor each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.\n\nWe say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:\n\nFor every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.\n\nDoes there exist a good set of choices? If the answer is yes, find one good set of choices.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\na_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf a good set of choices does not exist, print -1.\n\nIf a good set of choices exists, print one such set of choices in the following format:\n\nM\nb_1 b_2 ... b_M\n\nwhere M denotes the number of boxes that will contain a ball, and b_1,\\ b_2,\\ ...,\\ b_M are the integers written on these boxes, in any order.\n\nSample Input 1\n\n3\n1 0 0\n\nSample Output 1\n\n1\n1\n\nConsider putting a ball only in the box with 1 written on it.\n\nThere are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.\n\nThere is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.\n\nThere is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.\n\nThus, the condition is satisfied, so this set of choices is good.\n\nSample Input 2\n\n5\n0 0 0 0 0\n\nSample Output 2\n\n0\n\nPutting nothing in the boxes can be a good set of choices.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 313, "cpu_time_ms": 289, "memory_kb": 20748}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s760405623", "group_id": "codeNet:p02972", "input_text": "n = gets.chomp.to_i\na = gets.chomp.split.map(&:to_i)\nb = []\nn.downto(1) do |i|\n s = 0\n 2.upto(n) do |j|\n if i * j > n then\n break\n end\n s += a[i * j - 1] \n end\n b[i-1] = (a[i-1] + s) % 2\nend\nputs b.sum\nr = ''\n1.upto(n) do |i|\n if b[i-1] > 0 then\n r << i.to_s << ' '\n end\nend\nputs r.chop unless r == ''", "language": "Ruby", "metadata": {"date": 1563675008, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02972.html", "problem_id": "p02972", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02972/input.txt", "sample_output_relpath": "derived/input_output/data/p02972/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02972/Ruby/s760405623.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s760405623", "user_id": "u938270657"}, "prompt_components": {"gold_output": "1\n1\n", "input_to_evaluate": "n = gets.chomp.to_i\na = gets.chomp.split.map(&:to_i)\nb = []\nn.downto(1) do |i|\n s = 0\n 2.upto(n) do |j|\n if i * j > n then\n break\n end\n s += a[i * j - 1] \n end\n b[i-1] = (a[i-1] + s) % 2\nend\nputs b.sum\nr = ''\n1.upto(n) do |i|\n if b[i-1] > 0 then\n r << i.to_s << ' '\n end\nend\nputs r.chop unless r == ''", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N empty boxes arranged in a row from left to right.\nThe integer i is written on the i-th box from the left (1 \\leq i \\leq N).\n\nFor each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.\n\nWe say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:\n\nFor every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.\n\nDoes there exist a good set of choices? If the answer is yes, find one good set of choices.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\na_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf a good set of choices does not exist, print -1.\n\nIf a good set of choices exists, print one such set of choices in the following format:\n\nM\nb_1 b_2 ... b_M\n\nwhere M denotes the number of boxes that will contain a ball, and b_1,\\ b_2,\\ ...,\\ b_M are the integers written on these boxes, in any order.\n\nSample Input 1\n\n3\n1 0 0\n\nSample Output 1\n\n1\n1\n\nConsider putting a ball only in the box with 1 written on it.\n\nThere are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.\n\nThere is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.\n\nThere is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.\n\nThus, the condition is satisfied, so this set of choices is good.\n\nSample Input 2\n\n5\n0 0 0 0 0\n\nSample Output 2\n\n0\n\nPutting nothing in the boxes can be a good set of choices.", "sample_input": "3\n1 0 0\n"}, "reference_outputs": ["1\n1\n"], "source_document_id": "p02972", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N empty boxes arranged in a row from left to right.\nThe integer i is written on the i-th box from the left (1 \\leq i \\leq N).\n\nFor each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.\n\nWe say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:\n\nFor every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.\n\nDoes there exist a good set of choices? If the answer is yes, find one good set of choices.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\na_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf a good set of choices does not exist, print -1.\n\nIf a good set of choices exists, print one such set of choices in the following format:\n\nM\nb_1 b_2 ... b_M\n\nwhere M denotes the number of boxes that will contain a ball, and b_1,\\ b_2,\\ ...,\\ b_M are the integers written on these boxes, in any order.\n\nSample Input 1\n\n3\n1 0 0\n\nSample Output 1\n\n1\n1\n\nConsider putting a ball only in the box with 1 written on it.\n\nThere are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.\n\nThere is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.\n\nThere is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.\n\nThus, the condition is satisfied, so this set of choices is good.\n\nSample Input 2\n\n5\n0 0 0 0 0\n\nSample Output 2\n\n0\n\nPutting nothing in the boxes can be a good set of choices.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 324, "cpu_time_ms": 432, "memory_kb": 22300}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s432933997", "group_id": "codeNet:p02973", "input_text": "`sed 1d`.lines{|x|x=x.to_i\n$*[$*.bsearch_index{|y|y c ? c : a * b\n", "language": "Ruby", "metadata": {"date": 1562547685, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02981.html", "problem_id": "p02981", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02981/input.txt", "sample_output_relpath": "derived/input_output/data/p02981/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02981/Ruby/s561722622.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s561722622", "user_id": "u819939299"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "#a = gets.to_i\na,b,c = gets.split.map(&:to_i)\nputs a * b > c ? c : a * b\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nN of us are going on a trip, by train or taxi.\n\nThe train will cost each of us A yen (the currency of Japan).\n\nThe taxi will cost us a total of B yen.\n\nHow much is our minimum total travel expense?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq A \\leq 50\n\n1 \\leq B \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint an integer representing the minimum total travel expense.\n\nSample Input 1\n\n4 2 9\n\nSample Output 1\n\n8\n\nThe train will cost us 4 \\times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.\n\nSample Input 2\n\n4 2 7\n\nSample Output 2\n\n7\n\nSample Input 3\n\n4 2 8\n\nSample Output 3\n\n8", "sample_input": "4 2 9\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02981", "source_text": "Score : 100 points\n\nProblem Statement\n\nN of us are going on a trip, by train or taxi.\n\nThe train will cost each of us A yen (the currency of Japan).\n\nThe taxi will cost us a total of B yen.\n\nHow much is our minimum total travel expense?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq A \\leq 50\n\n1 \\leq B \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint an integer representing the minimum total travel expense.\n\nSample Input 1\n\n4 2 9\n\nSample Output 1\n\n8\n\nThe train will cost us 4 \\times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.\n\nSample Input 2\n\n4 2 7\n\nSample Output 2\n\n7\n\nSample Input 3\n\n4 2 8\n\nSample Output 3\n\n8", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 73, "cpu_time_ms": 7, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s276313166", "group_id": "codeNet:p02982", "input_text": "require \"complex\"\n\nN, D = gets.chomp.split.map(&:to_i)\nX = N.times.map { gets.chomp.split.map(&:to_f) }\n\nans = 0\nX.combination(2) { |y, z|\n sum = 0\n for i in 0..D - 1\n sum += (y[i] - z[i]) ** 2\n end\n n = 1\n while n ** 2 <= sum\n if n ** 2 == sum\n ans += 1\n break\n end\n n += 1\n end\n}\n\nputs ans\n", "language": "Ruby", "metadata": {"date": 1585410585, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02982.html", "problem_id": "p02982", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02982/input.txt", "sample_output_relpath": "derived/input_output/data/p02982/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02982/Ruby/s276313166.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s276313166", "user_id": "u080348635"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "require \"complex\"\n\nN, D = gets.chomp.split.map(&:to_i)\nX = N.times.map { gets.chomp.split.map(&:to_f) }\n\nans = 0\nX.combination(2) { |y, z|\n sum = 0\n for i in 0..D - 1\n sum += (y[i] - z[i]) ** 2\n end\n n = 1\n while n ** 2 <= sum\n if n ** 2 == sum\n ans += 1\n break\n end\n n += 1\n end\n}\n\nputs ans\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N points in a D-dimensional space.\n\nThe coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).\n\nThe distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.\n\nHow many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10\n\n1 \\leq D \\leq 10\n\n-20 \\leq X_{ij} \\leq 20\n\nNo two given points have the same coordinates. That is, if i \\neq j, there exists k such that X_{ik} \\neq X_{jk}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_{11} X_{12} ... X_{1D}\nX_{21} X_{22} ... X_{2D}\n\\vdots\nX_{N1} X_{N2} ... X_{ND}\n\nOutput\n\nPrint the number of pairs (i, j) (i < j) such that the distance between the i-th point and the j-th point is an integer.\n\nSample Input 1\n\n3 2\n1 2\n5 5\n-2 8\n\nSample Output 1\n\n1\n\nThe number of pairs with an integer distance is one, as follows:\n\nThe distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n\nThe distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n\nThe distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\nSample Input 2\n\n3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 1\n1\n2\n3\n4\n5\n\nSample Output 3\n\n10", "sample_input": "3 2\n1 2\n5 5\n-2 8\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02982", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N points in a D-dimensional space.\n\nThe coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).\n\nThe distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.\n\nHow many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10\n\n1 \\leq D \\leq 10\n\n-20 \\leq X_{ij} \\leq 20\n\nNo two given points have the same coordinates. That is, if i \\neq j, there exists k such that X_{ik} \\neq X_{jk}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_{11} X_{12} ... X_{1D}\nX_{21} X_{22} ... X_{2D}\n\\vdots\nX_{N1} X_{N2} ... X_{ND}\n\nOutput\n\nPrint the number of pairs (i, j) (i < j) such that the distance between the i-th point and the j-th point is an integer.\n\nSample Input 1\n\n3 2\n1 2\n5 5\n-2 8\n\nSample Output 1\n\n1\n\nThe number of pairs with an integer distance is one, as follows:\n\nThe distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n\nThe distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n\nThe distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\nSample Input 2\n\n3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 1\n1\n2\n3\n4\n5\n\nSample Output 3\n\n10", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 320, "cpu_time_ms": 8, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s131955396", "group_id": "codeNet:p02984", "input_text": "\nn = gets.to_i\ndatas = gets.split(\" \").map{|n|n.to_i}\nequations = []\nfor num in (1..n) do\n newequation = Array.new(n+1,0)\n newequation[-1] = datas[num-1]\n newequation[num-1] = 0.5\n if num == n\n newequation[0] = 0.5\n else\n newequation[num] = 0.5\n end\n equations << newequation\nend\n\n$answer = \"\"\n\n\nclass GaussJorden\n def initialize ary,nn\n # 係数\n @a = ary\n # 次元の数\n @n = nn\n end\n\n # 計算・結果出力\n def exec\n @n.times do |k|\n # ピボット係数\n p = @a[k][k]\n # ピボット行を p で除算\n k.upto(@n) { |j| @a[k][j] /= p.to_f }\n # ピボット列の掃き出し\n @n.times do |i|\n next if i == k\n d = @a[i][k]\n k.upto(@n) { |j| @a[i][j] -= d * @a[k][j] }\n end\n end\n # 結果出力\n display_answers\n rescue => e\n raise\n end\n\n private\n\n # 結果出力\n def display_answers\n 0.upto(@n - 1) {|k| $answer += @a[k][@n].to_i.to_s + \" \"}\n rescue => e\n raise\n end\nend\n\n # 計算クラスインスタンス化\n obj = GaussJorden.new(equations,n)\n # 連立方程式を解く(ガウス・ジョルダン法)\nobj.exec\nputs $answer", "language": "Ruby", "metadata": {"date": 1562551953, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02984.html", "problem_id": "p02984", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02984/input.txt", "sample_output_relpath": "derived/input_output/data/p02984/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02984/Ruby/s131955396.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s131955396", "user_id": "u328174452"}, "prompt_components": {"gold_output": "4 0 4\n", "input_to_evaluate": "\nn = gets.to_i\ndatas = gets.split(\" \").map{|n|n.to_i}\nequations = []\nfor num in (1..n) do\n newequation = Array.new(n+1,0)\n newequation[-1] = datas[num-1]\n newequation[num-1] = 0.5\n if num == n\n newequation[0] = 0.5\n else\n newequation[num] = 0.5\n end\n equations << newequation\nend\n\n$answer = \"\"\n\n\nclass GaussJorden\n def initialize ary,nn\n # 係数\n @a = ary\n # 次元の数\n @n = nn\n end\n\n # 計算・結果出力\n def exec\n @n.times do |k|\n # ピボット係数\n p = @a[k][k]\n # ピボット行を p で除算\n k.upto(@n) { |j| @a[k][j] /= p.to_f }\n # ピボット列の掃き出し\n @n.times do |i|\n next if i == k\n d = @a[i][k]\n k.upto(@n) { |j| @a[i][j] -= d * @a[k][j] }\n end\n end\n # 結果出力\n display_answers\n rescue => e\n raise\n end\n\n private\n\n # 結果出力\n def display_answers\n 0.upto(@n - 1) {|k| $answer += @a[k][@n].to_i.to_s + \" \"}\n rescue => e\n raise\n end\nend\n\n # 計算クラスインスタンス化\n obj = GaussJorden.new(equations,n)\n # 連立方程式を解く(ガウス・ジョルダン法)\nobj.exec\nputs $answer", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an odd number.\n\nBetween these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \\leq i \\leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).\n\nWhen Mountain i (1 \\leq i \\leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).\n\nOne day, each of the mountains received a non-negative even number of liters of rain.\n\nAs a result, Dam i (1 \\leq i \\leq N) accumulated a total of A_i liters of water.\n\nFind the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 10^5-1\n\nN is an odd number.\n\n0 \\leq A_i \\leq 10^9\n\nThe situation represented by input can occur when each of the mountains receives a non-negative even number of liters of rain.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint N integers representing the number of liters of rain Mountain 1, Mountain 2, ..., Mountain N received, in this order.\n\nSample Input 1\n\n3\n2 2 4\n\nSample Output 1\n\n4 0 4\n\nIf we assume Mountain 1, 2, and 3 received 4, 0, and 4 liters of rain, respectively, it is consistent with this input, as follows:\n\nDam 1 should have accumulated \\frac{4}{2} + \\frac{0}{2} = 2 liters of water.\n\nDam 2 should have accumulated \\frac{0}{2} + \\frac{4}{2} = 2 liters of water.\n\nDam 3 should have accumulated \\frac{4}{2} + \\frac{4}{2} = 4 liters of water.\n\nSample Input 2\n\n5\n3 8 7 5 5\n\nSample Output 2\n\n2 4 12 2 8\n\nSample Input 3\n\n3\n1000000000 1000000000 0\n\nSample Output 3\n\n0 2000000000 0", "sample_input": "3\n2 2 4\n"}, "reference_outputs": ["4 0 4\n"], "source_document_id": "p02984", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an odd number.\n\nBetween these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \\leq i \\leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).\n\nWhen Mountain i (1 \\leq i \\leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).\n\nOne day, each of the mountains received a non-negative even number of liters of rain.\n\nAs a result, Dam i (1 \\leq i \\leq N) accumulated a total of A_i liters of water.\n\nFind the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 10^5-1\n\nN is an odd number.\n\n0 \\leq A_i \\leq 10^9\n\nThe situation represented by input can occur when each of the mountains receives a non-negative even number of liters of rain.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint N integers representing the number of liters of rain Mountain 1, Mountain 2, ..., Mountain N received, in this order.\n\nSample Input 1\n\n3\n2 2 4\n\nSample Output 1\n\n4 0 4\n\nIf we assume Mountain 1, 2, and 3 received 4, 0, and 4 liters of rain, respectively, it is consistent with this input, as follows:\n\nDam 1 should have accumulated \\frac{4}{2} + \\frac{0}{2} = 2 liters of water.\n\nDam 2 should have accumulated \\frac{0}{2} + \\frac{4}{2} = 2 liters of water.\n\nDam 3 should have accumulated \\frac{4}{2} + \\frac{4}{2} = 4 liters of water.\n\nSample Input 2\n\n5\n3 8 7 5 5\n\nSample Output 2\n\n2 4 12 2 8\n\nSample Input 3\n\n3\n1000000000 1000000000 0\n\nSample Output 3\n\n0 2000000000 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1163, "cpu_time_ms": 2158, "memory_kb": 842892}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s844413784", "group_id": "codeNet:p02987", "input_text": "S=gets.chop.chars.sort\nputs (S[0]==S[1]&&S[2]==S[3]&&S[1]!=S[2])? :Yes : :No", "language": "Ruby", "metadata": {"date": 1587646681, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02987.html", "problem_id": "p02987", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02987/input.txt", "sample_output_relpath": "derived/input_output/data/p02987/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02987/Ruby/s844413784.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s844413784", "user_id": "u647875062"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "S=gets.chop.chars.sort\nputs (S[0]==S[1]&&S[2]==S[3]&&S[1]!=S[2])? :Yes : :No", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a 4-character string S consisting of uppercase English letters.\nDetermine if S consists of exactly two kinds of characters which both appear twice in S.\n\nConstraints\n\nThe length of S is 4.\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.\n\nSample Input 1\n\nASSA\n\nSample Output 1\n\nYes\n\nS consists of A and S which both appear twice in S.\n\nSample Input 2\n\nSTOP\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nFFEE\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nFREE\n\nSample Output 4\n\nNo", "sample_input": "ASSA\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02987", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a 4-character string S consisting of uppercase English letters.\nDetermine if S consists of exactly two kinds of characters which both appear twice in S.\n\nConstraints\n\nThe length of S is 4.\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.\n\nSample Input 1\n\nASSA\n\nSample Output 1\n\nYes\n\nS consists of A and S which both appear twice in S.\n\nSample Input 2\n\nSTOP\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nFFEE\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nFREE\n\nSample Output 4\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 76, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s624733801", "group_id": "codeNet:p02987", "input_text": "s = gets.chomp!.to_s\ns_list=s.split(\"\")\ns_list.sort!\n#p s_list\nif s_list[0] == s_list[1] && s_list[2] == s_list[3]\n print(\"Yes\\n\")\nelse\n print(\"No\\n\")\nend", "language": "Ruby", "metadata": {"date": 1566158187, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02987.html", "problem_id": "p02987", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02987/input.txt", "sample_output_relpath": "derived/input_output/data/p02987/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02987/Ruby/s624733801.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s624733801", "user_id": "u911815052"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "s = gets.chomp!.to_s\ns_list=s.split(\"\")\ns_list.sort!\n#p s_list\nif s_list[0] == s_list[1] && s_list[2] == s_list[3]\n print(\"Yes\\n\")\nelse\n print(\"No\\n\")\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a 4-character string S consisting of uppercase English letters.\nDetermine if S consists of exactly two kinds of characters which both appear twice in S.\n\nConstraints\n\nThe length of S is 4.\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.\n\nSample Input 1\n\nASSA\n\nSample Output 1\n\nYes\n\nS consists of A and S which both appear twice in S.\n\nSample Input 2\n\nSTOP\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nFFEE\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nFREE\n\nSample Output 4\n\nNo", "sample_input": "ASSA\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02987", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a 4-character string S consisting of uppercase English letters.\nDetermine if S consists of exactly two kinds of characters which both appear twice in S.\n\nConstraints\n\nThe length of S is 4.\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.\n\nSample Input 1\n\nASSA\n\nSample Output 1\n\nYes\n\nS consists of A and S which both appear twice in S.\n\nSample Input 2\n\nSTOP\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nFFEE\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nFREE\n\nSample Output 4\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 156, "cpu_time_ms": 8, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s405240279", "group_id": "codeNet:p02989", "input_text": "a=gets.chomp.to_i\nb=gets.chomp.map(&:to_i).sort!\nputs b[a/2]-b[a/2-1]", "language": "Ruby", "metadata": {"date": 1562466990, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s405240279.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s405240279", "user_id": "u585819925"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "a=gets.chomp.to_i\nb=gets.chomp.map(&:to_i).sort!\nputs b[a/2]-b[a/2-1]", "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": 69, "cpu_time_ms": 18, "memory_kb": 3580}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s565002640", "group_id": "codeNet:p02990", "input_text": "eval\"N,K=\"+`tr \\\\ ,`\nB=1\nR=N-K+1\nK.times{|i|p B*R%(10**9+7)\nB=B*(K+~i)/-~i\nR=R*(N-K-i)/i+=2}", "language": "Ruby", "metadata": {"date": 1561863458, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02990.html", "problem_id": "p02990", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02990/input.txt", "sample_output_relpath": "derived/input_output/data/p02990/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02990/Ruby/s565002640.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s565002640", "user_id": "u657913472"}, "prompt_components": {"gold_output": "3\n6\n1\n", "input_to_evaluate": "eval\"N,K=\"+`tr \\\\ ,`\nB=1\nR=N-K+1\nK.times{|i|p B*R%(10**9+7)\nB=B*(K+~i)/-~i\nR=R*(N-K-i)/i+=2}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.\n\nFirst, Snuke will arrange the N balls in a row from left to right.\n\nThen, Takahashi will collect only the K blue balls. In one move, he can collect any number of consecutive blue balls. He will collect all the blue balls in the fewest moves possible.\n\nHow many ways are there for Snuke to arrange the N balls in a row so that Takahashi will need exactly i moves to collect all the blue balls? Compute this number modulo 10^9+7 for each i such that 1 \\leq i \\leq K.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint K lines. The i-th line (1 \\leq i \\leq K) should contain the number of ways to arrange the N balls so that Takahashi will need exactly i moves to collect all the blue balls, modulo 10^9+7.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n3\n6\n1\n\nThere are three ways to arrange the balls so that Takahashi will need exactly one move: (B, B, B, R, R), (R, B, B, B, R), and (R, R, B, B, B). (R and B stands for red and blue, respectively).\n\nThere are six ways to arrange the balls so that Takahashi will need exactly two moves: (B, B, R, B, R), (B, B, R, R, B), (R, B, B, R, B), (R, B, R, B, B), (B, R, B, B, R), and (B, R, R, B, B).\n\nThere is one way to arrange the balls so that Takahashi will need exactly three moves: (B, R, B, R, B).\n\nSample Input 2\n\n2000 3\n\nSample Output 2\n\n1998\n3990006\n327341989\n\nBe sure to print the numbers of arrangements modulo 10^9+7.", "sample_input": "5 3\n"}, "reference_outputs": ["3\n6\n1\n"], "source_document_id": "p02990", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.\n\nFirst, Snuke will arrange the N balls in a row from left to right.\n\nThen, Takahashi will collect only the K blue balls. In one move, he can collect any number of consecutive blue balls. He will collect all the blue balls in the fewest moves possible.\n\nHow many ways are there for Snuke to arrange the N balls in a row so that Takahashi will need exactly i moves to collect all the blue balls? Compute this number modulo 10^9+7 for each i such that 1 \\leq i \\leq K.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint K lines. The i-th line (1 \\leq i \\leq K) should contain the number of ways to arrange the N balls so that Takahashi will need exactly i moves to collect all the blue balls, modulo 10^9+7.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n3\n6\n1\n\nThere are three ways to arrange the balls so that Takahashi will need exactly one move: (B, B, B, R, R), (R, B, B, B, R), and (R, R, B, B, B). (R and B stands for red and blue, respectively).\n\nThere are six ways to arrange the balls so that Takahashi will need exactly two moves: (B, B, R, B, R), (B, B, R, R, B), (R, B, B, R, B), (R, B, R, B, B), (B, R, B, B, R), and (B, R, R, B, B).\n\nThere is one way to arrange the balls so that Takahashi will need exactly three moves: (B, R, B, R, B).\n\nSample Input 2\n\n2000 3\n\nSample Output 2\n\n1998\n3990006\n327341989\n\nBe sure to print the numbers of arrangements modulo 10^9+7.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 93, "cpu_time_ms": 40, "memory_kb": 4092}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s193813402", "group_id": "codeNet:p02990", "input_text": "TEISU = 1_000_000_007\n\nclass Integer\n def combination(k)\n return 1 if k.zero?\n\n (self - k + 1..self).inject(:*) / k.factorial\n end\n\n def factorial\n return 1 if self.zero?\n\n (1..self).inject(:*)\n end\nend\n\n\nN,K = gets.chomp.split.map(&:to_i)\n\n1.upto(K) do |i|\n where = (N-K+1).combination(i) % TEISU\n how = (K-1).combination(i-1) % TEISU\n puts (where * how)\nend\n", "language": "Ruby", "metadata": {"date": 1561862098, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02990.html", "problem_id": "p02990", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02990/input.txt", "sample_output_relpath": "derived/input_output/data/p02990/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02990/Ruby/s193813402.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s193813402", "user_id": "u983836993"}, "prompt_components": {"gold_output": "3\n6\n1\n", "input_to_evaluate": "TEISU = 1_000_000_007\n\nclass Integer\n def combination(k)\n return 1 if k.zero?\n\n (self - k + 1..self).inject(:*) / k.factorial\n end\n\n def factorial\n return 1 if self.zero?\n\n (1..self).inject(:*)\n end\nend\n\n\nN,K = gets.chomp.split.map(&:to_i)\n\n1.upto(K) do |i|\n where = (N-K+1).combination(i) % TEISU\n how = (K-1).combination(i-1) % TEISU\n puts (where * how)\nend\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.\n\nFirst, Snuke will arrange the N balls in a row from left to right.\n\nThen, Takahashi will collect only the K blue balls. In one move, he can collect any number of consecutive blue balls. He will collect all the blue balls in the fewest moves possible.\n\nHow many ways are there for Snuke to arrange the N balls in a row so that Takahashi will need exactly i moves to collect all the blue balls? Compute this number modulo 10^9+7 for each i such that 1 \\leq i \\leq K.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint K lines. The i-th line (1 \\leq i \\leq K) should contain the number of ways to arrange the N balls so that Takahashi will need exactly i moves to collect all the blue balls, modulo 10^9+7.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n3\n6\n1\n\nThere are three ways to arrange the balls so that Takahashi will need exactly one move: (B, B, B, R, R), (R, B, B, B, R), and (R, R, B, B, B). (R and B stands for red and blue, respectively).\n\nThere are six ways to arrange the balls so that Takahashi will need exactly two moves: (B, B, R, B, R), (B, B, R, R, B), (R, B, B, R, B), (R, B, R, B, B), (B, R, B, B, R), and (B, R, R, B, B).\n\nThere is one way to arrange the balls so that Takahashi will need exactly three moves: (B, R, B, R, B).\n\nSample Input 2\n\n2000 3\n\nSample Output 2\n\n1998\n3990006\n327341989\n\nBe sure to print the numbers of arrangements modulo 10^9+7.", "sample_input": "5 3\n"}, "reference_outputs": ["3\n6\n1\n"], "source_document_id": "p02990", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.\n\nFirst, Snuke will arrange the N balls in a row from left to right.\n\nThen, Takahashi will collect only the K blue balls. In one move, he can collect any number of consecutive blue balls. He will collect all the blue balls in the fewest moves possible.\n\nHow many ways are there for Snuke to arrange the N balls in a row so that Takahashi will need exactly i moves to collect all the blue balls? Compute this number modulo 10^9+7 for each i such that 1 \\leq i \\leq K.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint K lines. The i-th line (1 \\leq i \\leq K) should contain the number of ways to arrange the N balls so that Takahashi will need exactly i moves to collect all the blue balls, modulo 10^9+7.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n3\n6\n1\n\nThere are three ways to arrange the balls so that Takahashi will need exactly one move: (B, B, B, R, R), (R, B, B, B, R), and (R, R, B, B, B). (R and B stands for red and blue, respectively).\n\nThere are six ways to arrange the balls so that Takahashi will need exactly two moves: (B, B, R, B, R), (B, B, R, R, B), (R, B, B, R, B), (R, B, R, B, B), (B, R, B, B, R), and (B, R, R, B, B).\n\nThere is one way to arrange the balls so that Takahashi will need exactly three moves: (B, R, B, R, B).\n\nSample Input 2\n\n2000 3\n\nSample Output 2\n\n1998\n3990006\n327341989\n\nBe sure to print the numbers of arrangements modulo 10^9+7.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 379, "cpu_time_ms": 2108, "memory_kb": 6000}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s863729070", "group_id": "codeNet:p02990", "input_text": "def factorial(number)\n (1..number).inject(1,:*)\nend\n\ndef calc_p(first, second)\n factorial(first) / factorial(first - second)\nend\n\ndef calc_c(first, second)\n factorial(first) / factorial(second) / factorial(first - second)\nend\n\nn, k = gets.chomp.split(/ /).map(&:to_i)\n\n1.upto(k) { |i|\n # (n-k+1)個のスキマからi個のスキマを選ぶ\n # スキマへのボールの入れ方は \"k-1個のスキマから(i-1)個のスキマを選ぶ\"\n puts calc_c(n - k + 1, i) * calc_c(k - 1, i - 1) % (10**9 + 7)\n}\n", "language": "Ruby", "metadata": {"date": 1561859517, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02990.html", "problem_id": "p02990", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02990/input.txt", "sample_output_relpath": "derived/input_output/data/p02990/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02990/Ruby/s863729070.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s863729070", "user_id": "u110064530"}, "prompt_components": {"gold_output": "3\n6\n1\n", "input_to_evaluate": "def factorial(number)\n (1..number).inject(1,:*)\nend\n\ndef calc_p(first, second)\n factorial(first) / factorial(first - second)\nend\n\ndef calc_c(first, second)\n factorial(first) / factorial(second) / factorial(first - second)\nend\n\nn, k = gets.chomp.split(/ /).map(&:to_i)\n\n1.upto(k) { |i|\n # (n-k+1)個のスキマからi個のスキマを選ぶ\n # スキマへのボールの入れ方は \"k-1個のスキマから(i-1)個のスキマを選ぶ\"\n puts calc_c(n - k + 1, i) * calc_c(k - 1, i - 1) % (10**9 + 7)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.\n\nFirst, Snuke will arrange the N balls in a row from left to right.\n\nThen, Takahashi will collect only the K blue balls. In one move, he can collect any number of consecutive blue balls. He will collect all the blue balls in the fewest moves possible.\n\nHow many ways are there for Snuke to arrange the N balls in a row so that Takahashi will need exactly i moves to collect all the blue balls? Compute this number modulo 10^9+7 for each i such that 1 \\leq i \\leq K.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint K lines. The i-th line (1 \\leq i \\leq K) should contain the number of ways to arrange the N balls so that Takahashi will need exactly i moves to collect all the blue balls, modulo 10^9+7.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n3\n6\n1\n\nThere are three ways to arrange the balls so that Takahashi will need exactly one move: (B, B, B, R, R), (R, B, B, B, R), and (R, R, B, B, B). (R and B stands for red and blue, respectively).\n\nThere are six ways to arrange the balls so that Takahashi will need exactly two moves: (B, B, R, B, R), (B, B, R, R, B), (R, B, B, R, B), (R, B, R, B, B), (B, R, B, B, R), and (B, R, R, B, B).\n\nThere is one way to arrange the balls so that Takahashi will need exactly three moves: (B, R, B, R, B).\n\nSample Input 2\n\n2000 3\n\nSample Output 2\n\n1998\n3990006\n327341989\n\nBe sure to print the numbers of arrangements modulo 10^9+7.", "sample_input": "5 3\n"}, "reference_outputs": ["3\n6\n1\n"], "source_document_id": "p02990", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.\n\nFirst, Snuke will arrange the N balls in a row from left to right.\n\nThen, Takahashi will collect only the K blue balls. In one move, he can collect any number of consecutive blue balls. He will collect all the blue balls in the fewest moves possible.\n\nHow many ways are there for Snuke to arrange the N balls in a row so that Takahashi will need exactly i moves to collect all the blue balls? Compute this number modulo 10^9+7 for each i such that 1 \\leq i \\leq K.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint K lines. The i-th line (1 \\leq i \\leq K) should contain the number of ways to arrange the N balls so that Takahashi will need exactly i moves to collect all the blue balls, modulo 10^9+7.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n3\n6\n1\n\nThere are three ways to arrange the balls so that Takahashi will need exactly one move: (B, B, B, R, R), (R, B, B, B, R), and (R, R, B, B, B). (R and B stands for red and blue, respectively).\n\nThere are six ways to arrange the balls so that Takahashi will need exactly two moves: (B, B, R, B, R), (B, B, R, R, B), (R, B, B, R, B), (R, B, R, B, B), (B, R, B, B, R), and (B, R, R, B, B).\n\nThere is one way to arrange the balls so that Takahashi will need exactly three moves: (B, R, B, R, B).\n\nSample Input 2\n\n2000 3\n\nSample Output 2\n\n1998\n3990006\n327341989\n\nBe sure to print the numbers of arrangements modulo 10^9+7.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 513, "cpu_time_ms": 2108, "memory_kb": 4880}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s515154314", "group_id": "codeNet:p02991", "input_text": "require 'pp'\n\nN,M = readline.chomp.split.map(&:to_i)\ng1 = Array.new(N) { [] }\nM.times do |i|\n u,v = readline.chomp.split.map(&:to_i).map {|x| x-1}\n g1[u] << v\nend\n#pp g1\n\ndef dfs(g, i, d, ans)\n if d == 0\n ans << i\n return\n end\n\n g[i].each do |j|\n dfs(g, j, d-1, ans)\n end\nend\n$memo = {}\ndef neighbors(g,i)\n if $memo.has_key?(i)\n return $memo[i]\n end\n a = []\n dfs(g,i,3,a)\n $memo[i] = a\n return a\nend\n\nS,T = readline.chomp.split.map(&:to_i).map {|x| x-1}\n\ncnt = 0\nvisited = {}\nvisited[S] = true\nqueue = []\nqueue.push(S)\nd = Array.new(N,-1)\nd[S] = 0\nwhile v = queue.shift\n #pp v,queue\n if v == T\n break\n end\n neighbors(g1,v).each do |j|\n if not visited[j]\n visited[j] = true\n d[j] = d[v]+1\n queue.push(j)\n end\n end\nend\nputs d[T]\n \n", "language": "Ruby", "metadata": {"date": 1561858932, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s515154314.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s515154314", "user_id": "u842192201"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "require 'pp'\n\nN,M = readline.chomp.split.map(&:to_i)\ng1 = Array.new(N) { [] }\nM.times do |i|\n u,v = readline.chomp.split.map(&:to_i).map {|x| x-1}\n g1[u] << v\nend\n#pp g1\n\ndef dfs(g, i, d, ans)\n if d == 0\n ans << i\n return\n end\n\n g[i].each do |j|\n dfs(g, j, d-1, ans)\n end\nend\n$memo = {}\ndef neighbors(g,i)\n if $memo.has_key?(i)\n return $memo[i]\n end\n a = []\n dfs(g,i,3,a)\n $memo[i] = a\n return a\nend\n\nS,T = readline.chomp.split.map(&:to_i).map {|x| x-1}\n\ncnt = 0\nvisited = {}\nvisited[S] = true\nqueue = []\nqueue.push(S)\nd = Array.new(N,-1)\nd[S] = 0\nwhile v = queue.shift\n #pp v,queue\n if v == T\n break\n end\n neighbors(g1,v).each do |j|\n if not visited[j]\n visited[j] = true\n d[j] = d[v]+1\n queue.push(j)\n end\n end\nend\nputs d[T]\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": 782, "cpu_time_ms": 2116, "memory_kb": 141492}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s766788992", "group_id": "codeNet:p02993", "input_text": "s = gets.chomp\n(s.length - 1).times do |i|\n\tif s[i] == s[i+1]\n\t\tputs \"Bad\"\n\t\texit\n\tend\nend\nputs \"Good\"", "language": "Ruby", "metadata": {"date": 1596131381, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p02993.html", "problem_id": "p02993", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02993/input.txt", "sample_output_relpath": "derived/input_output/data/p02993/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02993/Ruby/s766788992.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s766788992", "user_id": "u409390792"}, "prompt_components": {"gold_output": "Bad\n", "input_to_evaluate": "s = gets.chomp\n(s.length - 1).times do |i|\n\tif s[i] == s[i+1]\n\t\tputs \"Bad\"\n\t\texit\n\tend\nend\nputs \"Good\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThe door of Snuke's laboratory is locked with a security code.\n\nThe security code is a 4-digit number. We say the security code is hard to enter when it contains two consecutive digits that are the same.\n\nYou are given the current security code S. If S is hard to enter, print Bad; otherwise, print Good.\n\nConstraints\n\nS is a 4-character string consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is hard to enter, print Bad; otherwise, print Good.\n\nSample Input 1\n\n3776\n\nSample Output 1\n\nBad\n\nThe second and third digits are the same, so 3776 is hard to enter.\n\nSample Input 2\n\n8080\n\nSample Output 2\n\nGood\n\nThere are no two consecutive digits that are the same, so 8080 is not hard to enter.\n\nSample Input 3\n\n1333\n\nSample Output 3\n\nBad\n\nSample Input 4\n\n0024\n\nSample Output 4\n\nBad", "sample_input": "3776\n"}, "reference_outputs": ["Bad\n"], "source_document_id": "p02993", "source_text": "Score : 100 points\n\nProblem Statement\n\nThe door of Snuke's laboratory is locked with a security code.\n\nThe security code is a 4-digit number. We say the security code is hard to enter when it contains two consecutive digits that are the same.\n\nYou are given the current security code S. If S is hard to enter, print Bad; otherwise, print Good.\n\nConstraints\n\nS is a 4-character string consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is hard to enter, print Bad; otherwise, print Good.\n\nSample Input 1\n\n3776\n\nSample Output 1\n\nBad\n\nThe second and third digits are the same, so 3776 is hard to enter.\n\nSample Input 2\n\n8080\n\nSample Output 2\n\nGood\n\nThere are no two consecutive digits that are the same, so 8080 is not hard to enter.\n\nSample Input 3\n\n1333\n\nSample Output 3\n\nBad\n\nSample Input 4\n\n0024\n\nSample Output 4\n\nBad", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 102, "cpu_time_ms": 65, "memory_kb": 14368}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s528052178", "group_id": "codeNet:p02994", "input_text": "n,l = gets.chomp.split.map(&:to_i)\n\npai = []\n\n(1..n).each do |i|\n pai.push(l + i -1)\nend\n\nputs pai.inject(:+) - pai.min_by{|x| (x-0).abs}", "language": "Ruby", "metadata": {"date": 1588903838, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02994.html", "problem_id": "p02994", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02994/input.txt", "sample_output_relpath": "derived/input_output/data/p02994/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02994/Ruby/s528052178.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s528052178", "user_id": "u689027433"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "n,l = gets.chomp.split.map(&:to_i)\n\npai = []\n\n(1..n).each do |i|\n pai.push(l + i -1)\nend\n\nputs pai.inject(:+) - pai.min_by{|x| (x-0).abs}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "sample_input": "5 2\n"}, "reference_outputs": ["18\n"], "source_document_id": "p02994", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 138, "cpu_time_ms": 7, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s806030929", "group_id": "codeNet:p02994", "input_text": "n,l = gets.split.map(&:to_i)\ns = []\n(1..n).each {|i| s.push((l+i-1))}\ns.delete_at(0)\np s.sum", "language": "Ruby", "metadata": {"date": 1570204684, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02994.html", "problem_id": "p02994", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02994/input.txt", "sample_output_relpath": "derived/input_output/data/p02994/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02994/Ruby/s806030929.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s806030929", "user_id": "u562082015"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "n,l = gets.split.map(&:to_i)\ns = []\n(1..n).each {|i| s.push((l+i-1))}\ns.delete_at(0)\np s.sum", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "sample_input": "5 2\n"}, "reference_outputs": ["18\n"], "source_document_id": "p02994", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 92, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s127858138", "group_id": "codeNet:p02994", "input_text": "n, l = gets.split.map(&:to_i)\n\nif l >= 0 then\n puts (l+1..(n+l-1)).inject(:+)\nelsif (l < 0) && (n+l > 0) then\n puts (l..(n+l-1)).inject(:+)\nelse\n puts (l..(n+l-1)).inject(:+)-(n+l-1)\nend", "language": "Ruby", "metadata": {"date": 1561254689, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02994.html", "problem_id": "p02994", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02994/input.txt", "sample_output_relpath": "derived/input_output/data/p02994/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02994/Ruby/s127858138.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s127858138", "user_id": "u724629827"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "n, l = gets.split.map(&:to_i)\n\nif l >= 0 then\n puts (l+1..(n+l-1)).inject(:+)\nelsif (l < 0) && (n+l > 0) then\n puts (l..(n+l-1)).inject(:+)\nelse\n puts (l..(n+l-1)).inject(:+)-(n+l-1)\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "sample_input": "5 2\n"}, "reference_outputs": ["18\n"], "source_document_id": "p02994", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 189, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s756087847", "group_id": "codeNet:p02994", "input_text": "n, l = gets.split.map(&:to_i)\na = []\nn.times {|i| a << i + l}\nsum = 0\na.each {|i| sum += i}\nif sum < 0\n puts sum + a.map{|i| i < 0 ? -1 * i : i}.sort.first\nelse\n puts sum - a.map{|i| i < 0 ? -1 * i : i}.sort.first\nend", "language": "Ruby", "metadata": {"date": 1561252887, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02994.html", "problem_id": "p02994", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02994/input.txt", "sample_output_relpath": "derived/input_output/data/p02994/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02994/Ruby/s756087847.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s756087847", "user_id": "u351482714"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "n, l = gets.split.map(&:to_i)\na = []\nn.times {|i| a << i + l}\nsum = 0\na.each {|i| sum += i}\nif sum < 0\n puts sum + a.map{|i| i < 0 ? -1 * i : i}.sort.first\nelse\n puts sum - a.map{|i| i < 0 ? -1 * i : i}.sort.first\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "sample_input": "5 2\n"}, "reference_outputs": ["18\n"], "source_document_id": "p02994", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 219, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s892360564", "group_id": "codeNet:p02995", "input_text": "a, b, c, d = gets.chomp.split(\" \").map(&:to_i)\nres = b/c - a/c + b/d - a/d - a/(c.lcm(d)) - b/(c.lcm(d))\nputs b-a-res+1", "language": "Ruby", "metadata": {"date": 1583691155, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s892360564.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s892360564", "user_id": "u466332671"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "a, b, c, d = gets.chomp.split(\" \").map(&:to_i)\nres = b/c - a/c + b/d - a/d - a/(c.lcm(d)) - b/(c.lcm(d))\nputs b-a-res+1", "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": 119, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s970084548", "group_id": "codeNet:p02995", "input_text": "A, B, C, D = gets.split(' ').map(&:to_i)\nputs (A..B).select{|e| e % C != 0 and e % D != 0}.length", "language": "Ruby", "metadata": {"date": 1561565515, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s970084548.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s970084548", "user_id": "u857555436"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "A, B, C, D = gets.split(' ').map(&:to_i)\nputs (A..B).select{|e| e % C != 0 and e % D != 0}.length", "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": 97, "cpu_time_ms": 2111, "memory_kb": 113148}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s600613625", "group_id": "codeNet:p02995", "input_text": "a, b, c, d = gets.split.map(&:to_i)\n \nx = b - a + 1\n \nya = (b / c) - (a / c)\nya += 1 if a % c == 0\n\nyb = (b / d) - (a / d)\nyb += 1 if a % d == 0\n\nz = (b / c.lcm(d)) - (a / c.lcm(d))\nz += 1 if a % c.lcm(d) == 0\n \nputs x - (ya + yb - z)", "language": "Ruby", "metadata": {"date": 1561288971, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s600613625.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s600613625", "user_id": "u561391668"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "a, b, c, d = gets.split.map(&:to_i)\n \nx = b - a + 1\n \nya = (b / c) - (a / c)\nya += 1 if a % c == 0\n\nyb = (b / d) - (a / d)\nyb += 1 if a % d == 0\n\nz = (b / c.lcm(d)) - (a / c.lcm(d))\nz += 1 if a % c.lcm(d) == 0\n \nputs x - (ya + yb - z)", "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": 234, "cpu_time_ms": 8, "memory_kb": 2044}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s778030528", "group_id": "codeNet:p02995", "input_text": "A, B, C, D = $stdin.read.chomp.split(\" \").map(&:to_i)\n\nres = B - A + 1\n\ncis = (A / C.to_f).ceil\ncie = (B / C.to_f).floor\nccount = if cis == 1 && cie == 0\n 0\n else\n cie - cis + 1\n end\n\n\ndis = (A / D.to_f).ceil\ndie = (B / D.to_f).floor\ndcount = if dis == 1 && die == 0\n 0\n else\n die - dis + 1\n end\n\n_gcd = C.gcd(D)\n_cd = C*D/_gcd\ncdis = (A / (_cd).to_f).ceil\ncdie = (B / (_cd).to_f).floor\ncdcount = if cdis == 1 && cdie == 0\n 0\n else\n cdie - cdis + 1\n end\n\nputs res - ccount - dcount + cdcount\n", "language": "Ruby", "metadata": {"date": 1561235855, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s778030528.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s778030528", "user_id": "u381839731"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "A, B, C, D = $stdin.read.chomp.split(\" \").map(&:to_i)\n\nres = B - A + 1\n\ncis = (A / C.to_f).ceil\ncie = (B / C.to_f).floor\nccount = if cis == 1 && cie == 0\n 0\n else\n cie - cis + 1\n end\n\n\ndis = (A / D.to_f).ceil\ndie = (B / D.to_f).floor\ndcount = if dis == 1 && die == 0\n 0\n else\n die - dis + 1\n end\n\n_gcd = C.gcd(D)\n_cd = C*D/_gcd\ncdis = (A / (_cd).to_f).ceil\ncdie = (B / (_cd).to_f).floor\ncdcount = if cdis == 1 && cdie == 0\n 0\n else\n cdie - cdis + 1\n end\n\nputs res - ccount - dcount + cdcount\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": 604, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s336953797", "group_id": "codeNet:p02996", "input_text": "N = gets.to_i\n\ntasks = N.times.map do\n cost, limit = gets.split.map(&:to_i)\n [cost, limit]\nend\n\ntasks = tasks.sort_by { |i| i[1] }\n\nnow_time = 0\nflag = \"Yes\"\ntasks.each do |task|\n now_time += task[0]\n if now_time > task[1]\n flag = \"No\"\n break\n end\nend\n\nputs flag", "language": "Ruby", "metadata": {"date": 1561235522, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p02996.html", "problem_id": "p02996", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02996/input.txt", "sample_output_relpath": "derived/input_output/data/p02996/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02996/Ruby/s336953797.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s336953797", "user_id": "u482583772"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "N = gets.to_i\n\ntasks = N.times.map do\n cost, limit = gets.split.map(&:to_i)\n [cost, limit]\nend\n\ntasks = tasks.sort_by { |i| i[1] }\n\nnow_time = 0\nflag = \"Yes\"\ntasks.each do |task|\n now_time += task[0]\n if now_time > task[1]\n flag = \"No\"\n break\n end\nend\n\nputs flag", "problem_context": "Score: 400 points\n\nProblem Statement\n\nKizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.\n\nLet the current time be time 0. Kizahashi has N jobs numbered 1 to N.\n\nIt takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.\n\nKizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.\n\nCan Kizahashi complete all the jobs in time? If he can, print Yes; if he cannot, print No.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq 10^9 (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n.\n.\n.\nA_N B_N\n\nOutput\n\nIf Kizahashi can complete all the jobs in time, print Yes; if he cannot, print No.\n\nSample Input 1\n\n5\n2 4\n1 9\n1 8\n4 9\n3 12\n\nSample Output 1\n\nYes\n\nHe can complete all the jobs in time by, for example, doing them in the following order:\n\nDo Job 2 from time 0 to 1.\n\nDo Job 1 from time 1 to 3.\n\nDo Job 4 from time 3 to 7.\n\nDo Job 3 from time 7 to 8.\n\nDo Job 5 from time 8 to 11.\n\nNote that it is fine to complete Job 3 exactly at the deadline, time 8.\n\nSample Input 2\n\n3\n334 1000\n334 1000\n334 1000\n\nSample Output 2\n\nNo\n\nHe cannot complete all the jobs in time, no matter what order he does them in.\n\nSample Input 3\n\n30\n384 8895\n1725 9791\n170 1024\n4 11105\n2 6\n578 1815\n702 3352\n143 5141\n1420 6980\n24 1602\n849 999\n76 7586\n85 5570\n444 4991\n719 11090\n470 10708\n1137 4547\n455 9003\n110 9901\n15 8578\n368 3692\n104 1286\n3 4\n366 12143\n7 6649\n610 2374\n152 7324\n4 7042\n292 11386\n334 5720\n\nSample Output 3\n\nYes", "sample_input": "5\n2 4\n1 9\n1 8\n4 9\n3 12\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02996", "source_text": "Score: 400 points\n\nProblem Statement\n\nKizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.\n\nLet the current time be time 0. Kizahashi has N jobs numbered 1 to N.\n\nIt takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.\n\nKizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.\n\nCan Kizahashi complete all the jobs in time? If he can, print Yes; if he cannot, print No.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq 10^9 (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n.\n.\n.\nA_N B_N\n\nOutput\n\nIf Kizahashi can complete all the jobs in time, print Yes; if he cannot, print No.\n\nSample Input 1\n\n5\n2 4\n1 9\n1 8\n4 9\n3 12\n\nSample Output 1\n\nYes\n\nHe can complete all the jobs in time by, for example, doing them in the following order:\n\nDo Job 2 from time 0 to 1.\n\nDo Job 1 from time 1 to 3.\n\nDo Job 4 from time 3 to 7.\n\nDo Job 3 from time 7 to 8.\n\nDo Job 5 from time 8 to 11.\n\nNote that it is fine to complete Job 3 exactly at the deadline, time 8.\n\nSample Input 2\n\n3\n334 1000\n334 1000\n334 1000\n\nSample Output 2\n\nNo\n\nHe cannot complete all the jobs in time, no matter what order he does them in.\n\nSample Input 3\n\n30\n384 8895\n1725 9791\n170 1024\n4 11105\n2 6\n578 1815\n702 3352\n143 5141\n1420 6980\n24 1602\n849 999\n76 7586\n85 5570\n444 4991\n719 11090\n470 10708\n1137 4547\n455 9003\n110 9901\n15 8578\n368 3692\n104 1286\n3 4\n366 12143\n7 6649\n610 2374\n152 7324\n4 7042\n292 11386\n334 5720\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 273, "cpu_time_ms": 500, "memory_kb": 22520}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s824040850", "group_id": "codeNet:p02999", "input_text": "i,j = gets.strip.split(' ').map(&:to_i)\nr = 0\nr = 10 if i >= j\nputs r\n", "language": "Ruby", "metadata": {"date": 1583691323, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s824040850.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s824040850", "user_id": "u259578064"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "i,j = gets.strip.split(' ').map(&:to_i)\nr = 0\nr = 10 if i >= j\nputs r\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": 70, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s727030874", "group_id": "codeNet:p02999", "input_text": "a=gets.split.map(&:to_i)\nputs a[0] >= a[1] ? 10 : 0\n", "language": "Ruby", "metadata": {"date": 1566738508, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s727030874.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s727030874", "user_id": "u585819925"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "a=gets.split.map(&:to_i)\nputs a[0] >= a[1] ? 10 : 0\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": 52, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s821172910", "group_id": "codeNet:p02999", "input_text": "x, a = gets.chomp.split.map(&:to_i)\nputs (x < a) ? 0 : 10", "language": "Ruby", "metadata": {"date": 1565676555, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s821172910.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s821172910", "user_id": "u938270657"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "x, a = gets.chomp.split.map(&:to_i)\nputs (x < a) ? 0 : 10", "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": 57, "cpu_time_ms": 8, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s918438414", "group_id": "codeNet:p03000", "input_text": "n, x = gets.split.map(&:to_i)\n\nl = gets.split.map(&:to_i)\n\nsum = [0]\nl.each do |i|\n sum << sum[-1] + i\nend\n\nputs sum.select{|i| i <= x }.count\n\n", "language": "Ruby", "metadata": {"date": 1560712397, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s918438414.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s918438414", "user_id": "u452808393"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n, x = gets.split.map(&:to_i)\n\nl = gets.split.map(&:to_i)\n\nsum = [0]\nl.each do |i|\n sum << sum[-1] + i\nend\n\nputs sum.select{|i| i <= x }.count\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "sample_input": "3 6\n3 4 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03000", "source_text": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 145, "cpu_time_ms": 7, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s215288179", "group_id": "codeNet:p03001", "input_text": "W,H,x,y = gets.chomp.split(\" \").map(&:to_f)\n\nans = (x == W/2 and y == H/2) ? 1 : 0\nprintf(\"%f %d\", W*H/2, ans)", "language": "Ruby", "metadata": {"date": 1563405826, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s215288179.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s215288179", "user_id": "u111773061"}, "prompt_components": {"gold_output": "3.000000 0\n", "input_to_evaluate": "W,H,x,y = gets.chomp.split(\" \").map(&:to_f)\n\nans = (x == W/2 and y == H/2) ? 1 : 0\nprintf(\"%f %d\", W*H/2, ans)", "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": 110, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s683906704", "group_id": "codeNet:p03003", "input_text": "n,m=gets.chomp.split.map(&:to_i)\ns=gets.chomp.split.map(&:to_i)\nt=gets.chomp.split.map(&:to_i)\nMOD=10**9+7\n\ndp=Array.new(n+1).map{Array.new(m+1,0)}\nsum=Array.new(n+1).map{Array.new(m+1,0)}\n\n\n1.upto(n) do |i|\n 1.upto(m) do |j|\n if s[i-1] == t[j-1]\n dp[i][j]=sum[i-1][j-1] + 1\n\n else\n dp[i][j]=0\n end\n sum[i][j] = (sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + dp[i][j])%MOD\n end\nend\nputs (sum[n][m] + 1)%MOD\n", "language": "Ruby", "metadata": {"date": 1560782927, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s683906704.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s683906704", "user_id": "u868089307"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "n,m=gets.chomp.split.map(&:to_i)\ns=gets.chomp.split.map(&:to_i)\nt=gets.chomp.split.map(&:to_i)\nMOD=10**9+7\n\ndp=Array.new(n+1).map{Array.new(m+1,0)}\nsum=Array.new(n+1).map{Array.new(m+1,0)}\n\n\n1.upto(n) do |i|\n 1.upto(m) do |j|\n if s[i-1] == t[j-1]\n dp[i][j]=sum[i-1][j-1] + 1\n\n else\n dp[i][j]=0\n end\n sum[i][j] = (sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + dp[i][j])%MOD\n end\nend\nputs (sum[n][m] + 1)%MOD\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": 429, "cpu_time_ms": 1935, "memory_kb": 64508}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s718093166", "group_id": "codeNet:p03006", "input_text": "n = gets.to_i\nary = []\n\nn.times do |i|\n ary[i] = gets.split.map(&:to_i)\nend\nary2 = {}\nn.times do |i|\n ((i+1)..(n-1)).each do |j|\n p = ary[i][0] - ary[j][0]\n q = ary[i][1] - ary[j][1]\n if p < 0\n p *= -1\n q *= -1\n end\n ary2[[p,q]] ||= 0\n ary2[[p,q]] +=1\n end\nend\n\nmax = ary2.values.max\n\nputs n - max ", "language": "Ruby", "metadata": {"date": 1560650848, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03006.html", "problem_id": "p03006", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03006/input.txt", "sample_output_relpath": "derived/input_output/data/p03006/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03006/Ruby/s718093166.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s718093166", "user_id": "u622469330"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n = gets.to_i\nary = []\n\nn.times do |i|\n ary[i] = gets.split.map(&:to_i)\nend\nary2 = {}\nn.times do |i|\n ((i+1)..(n-1)).each do |j|\n p = ary[i][0] - ary[j][0]\n q = ary[i][1] - ary[j][1]\n if p < 0\n p *= -1\n q *= -1\n end\n ary2[[p,q]] ||= 0\n ary2[[p,q]] +=1\n end\nend\n\nmax = ary2.values.max\n\nputs n - max ", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i).\n\nWe will collect all of these balls, by choosing two integers p and q such that p \\neq 0 or q \\neq 0 and then repeating the following operation:\n\nChoose a ball remaining in the plane and collect it. Let (a, b) be the coordinates of this ball. If we collected a ball at coordinates (a - p, b - q) in the previous operation, the cost of this operation is 0. Otherwise, including when this is the first time to do this operation, the cost of this operation is 1.\n\nFind the minimum total cost required to collect all the balls when we optimally choose p and q.\n\nConstraints\n\n1 \\leq N \\leq 50\n\n|x_i|, |y_i| \\leq 10^9\n\nIf i \\neq j, x_i \\neq x_j or y_i \\neq y_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint the minimum total cost required to collect all the balls.\n\nSample Input 1\n\n2\n1 1\n2 2\n\nSample Output 1\n\n1\n\nIf we choose p = 1, q = 1, we can collect all the balls at a cost of 1 by collecting them in the order (1, 1), (2, 2).\n\nSample Input 2\n\n3\n1 4\n4 6\n7 8\n\nSample Output 2\n\n1\n\nIf we choose p = -3, q = -2, we can collect all the balls at a cost of 1 by collecting them in the order (7, 8), (4, 6), (1, 4).\n\nSample Input 3\n\n4\n1 1\n1 2\n2 1\n2 2\n\nSample Output 3\n\n2", "sample_input": "2\n1 1\n2 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03006", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i).\n\nWe will collect all of these balls, by choosing two integers p and q such that p \\neq 0 or q \\neq 0 and then repeating the following operation:\n\nChoose a ball remaining in the plane and collect it. Let (a, b) be the coordinates of this ball. If we collected a ball at coordinates (a - p, b - q) in the previous operation, the cost of this operation is 0. Otherwise, including when this is the first time to do this operation, the cost of this operation is 1.\n\nFind the minimum total cost required to collect all the balls when we optimally choose p and q.\n\nConstraints\n\n1 \\leq N \\leq 50\n\n|x_i|, |y_i| \\leq 10^9\n\nIf i \\neq j, x_i \\neq x_j or y_i \\neq y_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint the minimum total cost required to collect all the balls.\n\nSample Input 1\n\n2\n1 1\n2 2\n\nSample Output 1\n\n1\n\nIf we choose p = 1, q = 1, we can collect all the balls at a cost of 1 by collecting them in the order (1, 1), (2, 2).\n\nSample Input 2\n\n3\n1 4\n4 6\n7 8\n\nSample Output 2\n\n1\n\nIf we choose p = -3, q = -2, we can collect all the balls at a cost of 1 by collecting them in the order (7, 8), (4, 6), (1, 4).\n\nSample Input 3\n\n4\n1 1\n1 2\n2 1\n2 2\n\nSample Output 3\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 332, "cpu_time_ms": 14, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s402193341", "group_id": "codeNet:p03011", "input_text": "a,b,c = gets.split.map(&:to_i)\nputs (a+b+c)-[a,b,c].max", "language": "Ruby", "metadata": {"date": 1583197281, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03011.html", "problem_id": "p03011", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03011/input.txt", "sample_output_relpath": "derived/input_output/data/p03011/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03011/Ruby/s402193341.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s402193341", "user_id": "u911373146"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "a,b,c = gets.split.map(&:to_i)\nputs (a+b+c)-[a,b,c].max", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are three airports A, B and C, and flights between each pair of airports in both directions.\n\nA one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C and A takes R hours.\n\nConsider a route where we start at one of the airports, fly to another airport and then fly to the other airport.\n\nWhat is the minimum possible sum of the flight times?\n\nConstraints\n\n1 \\leq P,Q,R \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nP Q R\n\nOutput\n\nPrint the minimum possible sum of the flight times.\n\nSample Input 1\n\n1 3 4\n\nSample Output 1\n\n4\n\nThe sum of the flight times in the route A \\rightarrow B \\rightarrow C: 1 + 3 = 4 hours\n\nThe sum of the flight times in the route A \\rightarrow C \\rightarrow C: 4 + 3 = 7 hours\n\nThe sum of the flight times in the route B \\rightarrow A \\rightarrow C: 1 + 4 = 5 hours\n\nThe sum of the flight times in the route B \\rightarrow C \\rightarrow A: 3 + 4 = 7 hours\n\nThe sum of the flight times in the route C \\rightarrow A \\rightarrow B: 4 + 1 = 5 hours\n\nThe sum of the flight times in the route C \\rightarrow B \\rightarrow A: 3 + 1 = 4 hours\n\nThe minimum of these is 4 hours.\n\nSample Input 2\n\n3 2 3\n\nSample Output 2\n\n5", "sample_input": "1 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03011", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are three airports A, B and C, and flights between each pair of airports in both directions.\n\nA one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C and A takes R hours.\n\nConsider a route where we start at one of the airports, fly to another airport and then fly to the other airport.\n\nWhat is the minimum possible sum of the flight times?\n\nConstraints\n\n1 \\leq P,Q,R \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nP Q R\n\nOutput\n\nPrint the minimum possible sum of the flight times.\n\nSample Input 1\n\n1 3 4\n\nSample Output 1\n\n4\n\nThe sum of the flight times in the route A \\rightarrow B \\rightarrow C: 1 + 3 = 4 hours\n\nThe sum of the flight times in the route A \\rightarrow C \\rightarrow C: 4 + 3 = 7 hours\n\nThe sum of the flight times in the route B \\rightarrow A \\rightarrow C: 1 + 4 = 5 hours\n\nThe sum of the flight times in the route B \\rightarrow C \\rightarrow A: 3 + 4 = 7 hours\n\nThe sum of the flight times in the route C \\rightarrow A \\rightarrow B: 4 + 1 = 5 hours\n\nThe sum of the flight times in the route C \\rightarrow B \\rightarrow A: 3 + 1 = 4 hours\n\nThe minimum of these is 4 hours.\n\nSample Input 2\n\n3 2 3\n\nSample Output 2\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 55, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s131609633", "group_id": "codeNet:p03011", "input_text": "rou = gets.chomp.split.map(&:to_i)\nputs rou.min(2).inject(:+).to_i", "language": "Ruby", "metadata": {"date": 1560132867, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03011.html", "problem_id": "p03011", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03011/input.txt", "sample_output_relpath": "derived/input_output/data/p03011/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03011/Ruby/s131609633.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s131609633", "user_id": "u288861745"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "rou = gets.chomp.split.map(&:to_i)\nputs rou.min(2).inject(:+).to_i", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are three airports A, B and C, and flights between each pair of airports in both directions.\n\nA one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C and A takes R hours.\n\nConsider a route where we start at one of the airports, fly to another airport and then fly to the other airport.\n\nWhat is the minimum possible sum of the flight times?\n\nConstraints\n\n1 \\leq P,Q,R \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nP Q R\n\nOutput\n\nPrint the minimum possible sum of the flight times.\n\nSample Input 1\n\n1 3 4\n\nSample Output 1\n\n4\n\nThe sum of the flight times in the route A \\rightarrow B \\rightarrow C: 1 + 3 = 4 hours\n\nThe sum of the flight times in the route A \\rightarrow C \\rightarrow C: 4 + 3 = 7 hours\n\nThe sum of the flight times in the route B \\rightarrow A \\rightarrow C: 1 + 4 = 5 hours\n\nThe sum of the flight times in the route B \\rightarrow C \\rightarrow A: 3 + 4 = 7 hours\n\nThe sum of the flight times in the route C \\rightarrow A \\rightarrow B: 4 + 1 = 5 hours\n\nThe sum of the flight times in the route C \\rightarrow B \\rightarrow A: 3 + 1 = 4 hours\n\nThe minimum of these is 4 hours.\n\nSample Input 2\n\n3 2 3\n\nSample Output 2\n\n5", "sample_input": "1 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03011", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are three airports A, B and C, and flights between each pair of airports in both directions.\n\nA one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C and A takes R hours.\n\nConsider a route where we start at one of the airports, fly to another airport and then fly to the other airport.\n\nWhat is the minimum possible sum of the flight times?\n\nConstraints\n\n1 \\leq P,Q,R \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nP Q R\n\nOutput\n\nPrint the minimum possible sum of the flight times.\n\nSample Input 1\n\n1 3 4\n\nSample Output 1\n\n4\n\nThe sum of the flight times in the route A \\rightarrow B \\rightarrow C: 1 + 3 = 4 hours\n\nThe sum of the flight times in the route A \\rightarrow C \\rightarrow C: 4 + 3 = 7 hours\n\nThe sum of the flight times in the route B \\rightarrow A \\rightarrow C: 1 + 4 = 5 hours\n\nThe sum of the flight times in the route B \\rightarrow C \\rightarrow A: 3 + 4 = 7 hours\n\nThe sum of the flight times in the route C \\rightarrow A \\rightarrow B: 4 + 1 = 5 hours\n\nThe sum of the flight times in the route C \\rightarrow B \\rightarrow A: 3 + 1 = 4 hours\n\nThe minimum of these is 4 hours.\n\nSample Input 2\n\n3 2 3\n\nSample Output 2\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 66, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s001857496", "group_id": "codeNet:p03013", "input_text": "C = {}\n\ndef f(n)\n return C[n] if C[n]\n\n return 1 if n <= 1\n\n C[n] = n * f(n - 1)\nend\n\ndef calc(n)\n return 1 if n == 1\n\n a = 1\n v = 1\n while v * 2 <= n\n s = v + (n - v * 2)\n \n # sCv\n _a = f(s)\n _b = f(s - v)\n _c = f(v)\n\n a += (_a / _b) / _c\n\n #a += (f(s) / f(s - v)) / f(v)\n\n v += 1\n end\n a\nend\n\nn, m = gets.strip.split(\" \").map(&:to_i)\n\nas = []\nbefore = -1\nm.times do\n a = gets.to_i\n if before + 1 == a\n puts 0\n exit 0\n end\n before = a\n as << a\nend\n\nans = 1\np = 0\n\nwhile as.any?\n a = as.shift\n m = a - p - 1\n\n r = \n if m == 0\n 1\n else\n calc(m)\n end\n \n ans *= r\n\n p = a + 1\nend\n\nif p < n\n ans *= calc(n - p)\nend\n\nputs ans % 1000000007\n ", "language": "Ruby", "metadata": {"date": 1560134148, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03013.html", "problem_id": "p03013", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03013/input.txt", "sample_output_relpath": "derived/input_output/data/p03013/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03013/Ruby/s001857496.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s001857496", "user_id": "u742213796"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "C = {}\n\ndef f(n)\n return C[n] if C[n]\n\n return 1 if n <= 1\n\n C[n] = n * f(n - 1)\nend\n\ndef calc(n)\n return 1 if n == 1\n\n a = 1\n v = 1\n while v * 2 <= n\n s = v + (n - v * 2)\n \n # sCv\n _a = f(s)\n _b = f(s - v)\n _c = f(v)\n\n a += (_a / _b) / _c\n\n #a += (f(s) / f(s - v)) / f(v)\n\n v += 1\n end\n a\nend\n\nn, m = gets.strip.split(\" \").map(&:to_i)\n\nas = []\nbefore = -1\nm.times do\n a = gets.to_i\n if before + 1 == a\n puts 0\n exit 0\n end\n before = a\n as << a\nend\n\nans = 1\np = 0\n\nwhile as.any?\n a = as.shift\n m = a - p - 1\n\n r = \n if m == 0\n 1\n else\n calc(m)\n end\n \n ans *= r\n\n p = a + 1\nend\n\nif p < n\n ans *= calc(n - p)\nend\n\nputs ans % 1000000007\n ", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "sample_input": "6 1\n3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03013", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 90, "memory_kb": 14332}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s488598128", "group_id": "codeNet:p03013", "input_text": "# 4, 0, 608200469\n\nwaru = 1_000_000_007 # あまりを出す\nn, m = gets.split.map &:to_i # N段目まで行きたい\na = []\nwhile aa = gets # 壊れてる階段\n a << aa.to_i\nend\n# p [n, m]\n# p a\n\narr = Array.new(n, 0)\n# arr[0] = 1\n# arr[1] = 1\n0.upto(n) do |i|\n if a.any?{|aa|aa == i}\n arr[i] = 0\n next\n end\n if i == 0 || i == 1\n arr[i] = 1\n next\n end\n arr[i] = arr[i-1] + arr[i-2]\nend\n\n# p arr\np (arr[-1] % waru)\n", "language": "Ruby", "metadata": {"date": 1560129948, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03013.html", "problem_id": "p03013", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03013/input.txt", "sample_output_relpath": "derived/input_output/data/p03013/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03013/Ruby/s488598128.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s488598128", "user_id": "u315597999"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "# 4, 0, 608200469\n\nwaru = 1_000_000_007 # あまりを出す\nn, m = gets.split.map &:to_i # N段目まで行きたい\na = []\nwhile aa = gets # 壊れてる階段\n a << aa.to_i\nend\n# p [n, m]\n# p a\n\narr = Array.new(n, 0)\n# arr[0] = 1\n# arr[1] = 1\n0.upto(n) do |i|\n if a.any?{|aa|aa == i}\n arr[i] = 0\n next\n end\n if i == 0 || i == 1\n arr[i] = 1\n next\n end\n arr[i] = arr[i-1] + arr[i-2]\nend\n\n# p arr\np (arr[-1] % waru)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "sample_input": "6 1\n3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03013", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2109, "memory_kb": 433020}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s419281080", "group_id": "codeNet:p03014", "input_text": "h, w = gets.strip.split.map(&:to_i)\nroom = readlines.map {|line| line.strip.split('') }\n\ndef extend(arr)\n ret = []\n darr = arr.dup\n until darr.empty?\n c = darr.shift \n ret << c if c.zero?\n c.times { ret << c }\n end\n ret\nend\n\nv_illuminations = Array.new(w){ [] }\nh_illuminations = Array.new(h){ [] }\n\nroom.each_with_index do |line, i|\n space_count = 0\n line.each_with_index do |space, j|\n if space == '#'\n h_illuminations[i] << space_count if space_count > 0\n h_illuminations[i] << 0\n space_count = 0\n end\n\n if space == '.'\n space_count += 1\n h_illuminations[i] << space_count if j == line.length-1\n end\n end\nend\n\nh_illuminations.each_with_index do |l, i|\n h_illuminations[i] = extend(l)\nend\n\nroom.transpose.each_with_index do |line, i|\n space_count = 0\n line.each_with_index do |space, j|\n if space == '#'\n v_illuminations[i] << space_count if space_count > 0\n v_illuminations[i] << 0\n space_count = 0\n end\n\n if space == '.'\n space_count += 1\n v_illuminations[i] << space_count if j == line.length-1\n end\n end\nend\n\n#p v_illuminations\n\nv_illuminations.each_with_index do |l, i|\n v_illuminations[i] = extend(l)\nend\n\nv_illuminations = v_illuminations.transpose\n\n#h_illuminations.each do |l|\n# p l\n#end\n\n#v_illuminations.each do |l|\n# p l\n#end\n\nresult = 0\nh.times do |i|\n w.times do |j|\n tmp_result = v_illuminations[i][j] + h_illuminations[i][j] - 1\n result = tmp_result if tmp_result > result\n end\nend\n\np result\n", "language": "Ruby", "metadata": {"date": 1565923276, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s419281080.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s419281080", "user_id": "u021358975"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "h, w = gets.strip.split.map(&:to_i)\nroom = readlines.map {|line| line.strip.split('') }\n\ndef extend(arr)\n ret = []\n darr = arr.dup\n until darr.empty?\n c = darr.shift \n ret << c if c.zero?\n c.times { ret << c }\n end\n ret\nend\n\nv_illuminations = Array.new(w){ [] }\nh_illuminations = Array.new(h){ [] }\n\nroom.each_with_index do |line, i|\n space_count = 0\n line.each_with_index do |space, j|\n if space == '#'\n h_illuminations[i] << space_count if space_count > 0\n h_illuminations[i] << 0\n space_count = 0\n end\n\n if space == '.'\n space_count += 1\n h_illuminations[i] << space_count if j == line.length-1\n end\n end\nend\n\nh_illuminations.each_with_index do |l, i|\n h_illuminations[i] = extend(l)\nend\n\nroom.transpose.each_with_index do |line, i|\n space_count = 0\n line.each_with_index do |space, j|\n if space == '#'\n v_illuminations[i] << space_count if space_count > 0\n v_illuminations[i] << 0\n space_count = 0\n end\n\n if space == '.'\n space_count += 1\n v_illuminations[i] << space_count if j == line.length-1\n end\n end\nend\n\n#p v_illuminations\n\nv_illuminations.each_with_index do |l, i|\n v_illuminations[i] = extend(l)\nend\n\nv_illuminations = v_illuminations.transpose\n\n#h_illuminations.each do |l|\n# p l\n#end\n\n#v_illuminations.each do |l|\n# p l\n#end\n\nresult = 0\nh.times do |i|\n w.times do |j|\n tmp_result = v_illuminations[i][j] + h_illuminations[i][j] - 1\n result = tmp_result if tmp_result > result\n end\nend\n\np result\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": 1516, "cpu_time_ms": 2129, "memory_kb": 284412}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s002061805", "group_id": "codeNet:p03014", "input_text": "h, w = gets.chomp.split.map(&:to_i)\nmap = []\nh.times{map << gets.chomp}\n\narr = Array.new(h){Array.new(w){[]}}\nh.times{|y|\n last = nil\n w.times{|x|\n if map[y][x] == '#'\n last = x\n else\n arr[y][x] << last\n end\n }\n last = nil\n (w - 1).downto(0){|x|\n if map[y][x] == '#'\n last = x\n else\n arr[y][x] << last\n end\n }\n}\nw.times{|x|\n last = nil\n h.times{|y|\n if map[y][x] == '#'\n last = y\n else\n arr[y][x] << last\n end\n }\n last = nil\n (h - 1).downto(0){|y|\n if map[y][x] == '#'\n last = y\n else\n arr[y][x] << last\n end\n }\n}\nmax = 0\nh.times{|y|\n w.times{|x|\n next if arr[y][x].empty?\n z = 1\n if arr[y][x][0].nil?\n z += x\n else\n z += x - arr[y][x][0] - 1\n end\n if arr[y][x][1].nil?\n z += w - x - 1\n else\n z += arr[y][x][1] - x - 1\n end\n if arr[y][x][2].nil?\n z += y\n else\n z += y - arr[y][x][2] - 1\n end\n if arr[y][x][3].nil?\n z += h - y - 1\n else\n z += arr[y][x][3] - y - 1\n end\n max = z if max < z\n }\n}\nputs max\n", "language": "Ruby", "metadata": {"date": 1560133021, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s002061805.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s002061805", "user_id": "u547648534"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "h, w = gets.chomp.split.map(&:to_i)\nmap = []\nh.times{map << gets.chomp}\n\narr = Array.new(h){Array.new(w){[]}}\nh.times{|y|\n last = nil\n w.times{|x|\n if map[y][x] == '#'\n last = x\n else\n arr[y][x] << last\n end\n }\n last = nil\n (w - 1).downto(0){|x|\n if map[y][x] == '#'\n last = x\n else\n arr[y][x] << last\n end\n }\n}\nw.times{|x|\n last = nil\n h.times{|y|\n if map[y][x] == '#'\n last = y\n else\n arr[y][x] << last\n end\n }\n last = nil\n (h - 1).downto(0){|y|\n if map[y][x] == '#'\n last = y\n else\n arr[y][x] << last\n end\n }\n}\nmax = 0\nh.times{|y|\n w.times{|x|\n next if arr[y][x].empty?\n z = 1\n if arr[y][x][0].nil?\n z += x\n else\n z += x - arr[y][x][0] - 1\n end\n if arr[y][x][1].nil?\n z += w - x - 1\n else\n z += arr[y][x][1] - x - 1\n end\n if arr[y][x][2].nil?\n z += y\n else\n z += y - arr[y][x][2] - 1\n end\n if arr[y][x][3].nil?\n z += h - y - 1\n else\n z += arr[y][x][3] - y - 1\n end\n max = z if max < z\n }\n}\nputs max\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": 2134, "memory_kb": 415100}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s001125106", "group_id": "codeNet:p03017", "input_text": "eval\"N,A,B,C,D=\"+gets.split*?,\ns=gets\nputs (s[A..C]+s[B..D])=~/##/||C>D&&s[B-2..D+1]!~/\\.{3}/?:No: :Yes", "language": "Ruby", "metadata": {"date": 1559535194, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s001125106.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s001125106", "user_id": "u657913472"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "eval\"N,A,B,C,D=\"+gets.split*?,\ns=gets\nputs (s[A..C]+s[B..D])=~/##/||C>D&&s[B-2..D+1]!~/\\.{3}/?:No: :Yes", "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": 103, "cpu_time_ms": 8, "memory_kb": 2428}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s879048058", "group_id": "codeNet:p03017", "input_text": "n, a, b, c, d = gets.split.map(&:to_i)\nss = gets.split('').map{|e| e=='#' ? true : false}\noverlap = c > d\n\nf_single = false\ndouble_stone_flag = (ss[(b-1)..([c,d].min-1)].select{|e|\n f_double = f_single && e\n f_single = e\n f_double\n}).size.positive?\nf_single = false\nf_double = false\ntriple_dots_flag = (ss[(b-1)..(d)].select{|e|\n f_triple = f_double && !e\n f_double = f_single && !e\n f_single = !e\n f_triple\n}).size.positive?\n\nif c < d\n puts double_stone_flag ? 'No' : 'Yes'\nelse\n puts !double_stone_flag && triple_dots_flag ? 'Yes' : 'No'\nend\n", "language": "Ruby", "metadata": {"date": 1559525571, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s879048058.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s879048058", "user_id": "u069429049"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "n, a, b, c, d = gets.split.map(&:to_i)\nss = gets.split('').map{|e| e=='#' ? true : false}\noverlap = c > d\n\nf_single = false\ndouble_stone_flag = (ss[(b-1)..([c,d].min-1)].select{|e|\n f_double = f_single && e\n f_single = e\n f_double\n}).size.positive?\nf_single = false\nf_double = false\ntriple_dots_flag = (ss[(b-1)..(d)].select{|e|\n f_triple = f_double && !e\n f_double = f_single && !e\n f_single = !e\n f_triple\n}).size.positive?\n\nif c < d\n puts double_stone_flag ? 'No' : 'Yes'\nelse\n puts !double_stone_flag && triple_dots_flag ? 'Yes' : 'No'\nend\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N squares arranged in a row, numbered 1, 2, ..., N from left to right.\nYou are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.\n\nIn the beginning, Snuke stands on Square A, and Fnuke stands on Square B.\n\nYou can repeat the following operation any number of times:\n\nChoose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.\n\nYou want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.\n\nDetermine whether this is possible.\n\nConstraints\n\n4 \\leq N \\leq 200\\ 000\n\nS is a string of length N consisting of . and #.\n\n1 \\leq A, B, C, D \\leq N\n\nSquare A, B, C and D do not contain a rock.\n\nA, B, C and D are all different.\n\nA < B\n\nA < C\n\nB < D\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\nS\n\nOutput\n\nPrint Yes if the objective is achievable, and No if it is not.\n\nSample Input 1\n\n7 1 3 6 7\n.#..#..\n\nSample Output 1\n\nYes\n\nThe objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)\n\nA#B.#..\n\nA#.B#..\n\n.#AB#..\n\n.#A.#B.\n\n.#.A#B.\n\n.#.A#.B\n\n.#..#AB\n\nSample Input 2\n\n7 1 3 7 6\n.#..#..\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n15 1 3 15 13\n...#.#...#.#...\n\nSample Output 3\n\nYes", "sample_input": "7 1 3 6 7\n.#..#..\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03017", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N squares arranged in a row, numbered 1, 2, ..., N from left to right.\nYou are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.\n\nIn the beginning, Snuke stands on Square A, and Fnuke stands on Square B.\n\nYou can repeat the following operation any number of times:\n\nChoose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.\n\nYou want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.\n\nDetermine whether this is possible.\n\nConstraints\n\n4 \\leq N \\leq 200\\ 000\n\nS is a string of length N consisting of . and #.\n\n1 \\leq A, B, C, D \\leq N\n\nSquare A, B, C and D do not contain a rock.\n\nA, B, C and D are all different.\n\nA < B\n\nA < C\n\nB < D\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\nS\n\nOutput\n\nPrint Yes if the objective is achievable, and No if it is not.\n\nSample Input 1\n\n7 1 3 6 7\n.#..#..\n\nSample Output 1\n\nYes\n\nThe objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)\n\nA#B.#..\n\nA#.B#..\n\n.#AB#..\n\n.#A.#B.\n\n.#.A#B.\n\n.#.A#.B\n\n.#..#AB\n\nSample Input 2\n\n7 1 3 7 6\n.#..#..\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n15 1 3 15 13\n...#.#...#.#...\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 160, "memory_kb": 18044}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s968243828", "group_id": "codeNet:p03023", "input_text": "n = gets.to_i\n\nd = (n - 2) * 180\n\np d\n", "language": "Ruby", "metadata": {"date": 1559439100, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s968243828.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s968243828", "user_id": "u030343769"}, "prompt_components": {"gold_output": "180\n", "input_to_evaluate": "n = gets.to_i\n\nd = (n - 2) * 180\n\np d\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": 38, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s790776038", "group_id": "codeNet:p03023", "input_text": "n=gets.chomp.to_i\nputs 180 * ( n - 2 )\n\n\n", "language": "Ruby", "metadata": {"date": 1559437271, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s790776038.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s790776038", "user_id": "u257668305"}, "prompt_components": {"gold_output": "180\n", "input_to_evaluate": "n=gets.chomp.to_i\nputs 180 * ( n - 2 )\n\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides.\n\nPrint the answer in degrees, but do not print units.\n\nConstraints\n\n3 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint an integer representing the sum of the interior angles of a regular polygon with N sides.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n180\n\nThe sum of the interior angles of a regular triangle is 180 degrees.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n17640", "sample_input": "3\n"}, "reference_outputs": ["180\n"], "source_document_id": "p03023", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides.\n\nPrint the answer in degrees, but do not print units.\n\nConstraints\n\n3 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint an integer representing the sum of the interior angles of a regular polygon with N sides.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n180\n\nThe sum of the interior angles of a regular triangle is 180 degrees.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n17640", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 41, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s723944739", "group_id": "codeNet:p03024", "input_text": "s = gets.chop\nlose = 0\ns.size.times { |i|\n if s[i] == \"x\"\n lose += 1\n end\n}\nif lose < 8\n puts \"YES\"\nelse\n puts \"NO\"\nend\n", "language": "Ruby", "metadata": {"date": 1559438409, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03024.html", "problem_id": "p03024", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03024/input.txt", "sample_output_relpath": "derived/input_output/data/p03024/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03024/Ruby/s723944739.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s723944739", "user_id": "u584272055"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "s = gets.chop\nlose = 0\ns.size.times { |i|\n if s[i] == \"x\"\n lose += 1\n end\n}\nif lose < 8\n puts \"YES\"\nelse\n puts \"NO\"\nend\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi is competing in a sumo tournament.\nThe tournament lasts for 15 days, during which he performs in one match per day.\nIf he wins 8 or more matches, he can also participate in the next tournament.\n\nThe matches for the first k days have finished.\nYou are given the results of Takahashi's matches as a string S consisting of o and x.\nIf the i-th character in S is o, it means that Takahashi won the match on the i-th day; if that character is x, it means that Takahashi lost the match on the i-th day.\n\nPrint YES if there is a possibility that Takahashi can participate in the next tournament, and print NO if there is no such possibility.\n\nConstraints\n\n1 \\leq k \\leq 15\n\nS is a string of length k consisting of o and x.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint YES if there is a possibility that Takahashi can participate in the next tournament, and print NO otherwise.\n\nSample Input 1\n\noxoxoxoxoxoxox\n\nSample Output 1\n\nYES\n\nTakahashi has 7 wins and 7 losses before the last match. If he wins that match, he will have 8 wins.\n\nSample Input 2\n\nxxxxxxxx\n\nSample Output 2\n\nNO", "sample_input": "oxoxoxoxoxoxox\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03024", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi is competing in a sumo tournament.\nThe tournament lasts for 15 days, during which he performs in one match per day.\nIf he wins 8 or more matches, he can also participate in the next tournament.\n\nThe matches for the first k days have finished.\nYou are given the results of Takahashi's matches as a string S consisting of o and x.\nIf the i-th character in S is o, it means that Takahashi won the match on the i-th day; if that character is x, it means that Takahashi lost the match on the i-th day.\n\nPrint YES if there is a possibility that Takahashi can participate in the next tournament, and print NO if there is no such possibility.\n\nConstraints\n\n1 \\leq k \\leq 15\n\nS is a string of length k consisting of o and x.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint YES if there is a possibility that Takahashi can participate in the next tournament, and print NO otherwise.\n\nSample Input 1\n\noxoxoxoxoxoxox\n\nSample Output 1\n\nYES\n\nTakahashi has 7 wins and 7 losses before the last match. If he wins that match, he will have 8 wins.\n\nSample Input 2\n\nxxxxxxxx\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": 127, "cpu_time_ms": 7, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s307667563", "group_id": "codeNet:p03024", "input_text": "str = gets.chomp\ncnt = 0\nfor i in 0...str.length\n # puts str[i]\n if str[i] == \"x\"\n cnt += 1\n end\nend\nif cnt >= 8\n puts \"NO\"\nelse\n puts \"YES\"\nend", "language": "Ruby", "metadata": {"date": 1559437387, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03024.html", "problem_id": "p03024", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03024/input.txt", "sample_output_relpath": "derived/input_output/data/p03024/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03024/Ruby/s307667563.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s307667563", "user_id": "u706730549"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "str = gets.chomp\ncnt = 0\nfor i in 0...str.length\n # puts str[i]\n if str[i] == \"x\"\n cnt += 1\n end\nend\nif cnt >= 8\n puts \"NO\"\nelse\n puts \"YES\"\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi is competing in a sumo tournament.\nThe tournament lasts for 15 days, during which he performs in one match per day.\nIf he wins 8 or more matches, he can also participate in the next tournament.\n\nThe matches for the first k days have finished.\nYou are given the results of Takahashi's matches as a string S consisting of o and x.\nIf the i-th character in S is o, it means that Takahashi won the match on the i-th day; if that character is x, it means that Takahashi lost the match on the i-th day.\n\nPrint YES if there is a possibility that Takahashi can participate in the next tournament, and print NO if there is no such possibility.\n\nConstraints\n\n1 \\leq k \\leq 15\n\nS is a string of length k consisting of o and x.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint YES if there is a possibility that Takahashi can participate in the next tournament, and print NO otherwise.\n\nSample Input 1\n\noxoxoxoxoxoxox\n\nSample Output 1\n\nYES\n\nTakahashi has 7 wins and 7 losses before the last match. If he wins that match, he will have 8 wins.\n\nSample Input 2\n\nxxxxxxxx\n\nSample Output 2\n\nNO", "sample_input": "oxoxoxoxoxoxox\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03024", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi is competing in a sumo tournament.\nThe tournament lasts for 15 days, during which he performs in one match per day.\nIf he wins 8 or more matches, he can also participate in the next tournament.\n\nThe matches for the first k days have finished.\nYou are given the results of Takahashi's matches as a string S consisting of o and x.\nIf the i-th character in S is o, it means that Takahashi won the match on the i-th day; if that character is x, it means that Takahashi lost the match on the i-th day.\n\nPrint YES if there is a possibility that Takahashi can participate in the next tournament, and print NO if there is no such possibility.\n\nConstraints\n\n1 \\leq k \\leq 15\n\nS is a string of length k consisting of o and x.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint YES if there is a possibility that Takahashi can participate in the next tournament, and print NO otherwise.\n\nSample Input 1\n\noxoxoxoxoxoxox\n\nSample Output 1\n\nYES\n\nTakahashi has 7 wins and 7 losses before the last match. If he wins that match, he will have 8 wins.\n\nSample Input 2\n\nxxxxxxxx\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": 166, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s558966485", "group_id": "codeNet:p03029", "input_text": "a, p = gets.split(' ').map(&:to_i)\nputs \"#{(a*3 + p)/2}\"", "language": "Ruby", "metadata": {"date": 1559620800, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s558966485.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s558966485", "user_id": "u097027304"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "a, p = gets.split(' ').map(&:to_i)\nputs \"#{(a*3 + p)/2}\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have A apples and P pieces of apple.\n\nWe can cut an apple into three pieces of apple, and make one apple pie by simmering two pieces of apple in a pan.\n\nFind the maximum number of apple pies we can make with what we have now.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, P \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA P\n\nOutput\n\nPrint the maximum number of apple pies we can make with what we have.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n3\n\nWe can first make one apple pie by simmering two of the three pieces of apple. Then, we can make two more by simmering the remaining piece and three more pieces obtained by cutting the whole apple.\n\nSample Input 2\n\n0 1\n\nSample Output 2\n\n0\n\nWe cannot make an apple pie in this case, unfortunately.\n\nSample Input 3\n\n32 21\n\nSample Output 3\n\n58", "sample_input": "1 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03029", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have A apples and P pieces of apple.\n\nWe can cut an apple into three pieces of apple, and make one apple pie by simmering two pieces of apple in a pan.\n\nFind the maximum number of apple pies we can make with what we have now.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, P \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA P\n\nOutput\n\nPrint the maximum number of apple pies we can make with what we have.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n3\n\nWe can first make one apple pie by simmering two of the three pieces of apple. Then, we can make two more by simmering the remaining piece and three more pieces obtained by cutting the whole apple.\n\nSample Input 2\n\n0 1\n\nSample Output 2\n\n0\n\nWe cannot make an apple pie in this case, unfortunately.\n\nSample Input 3\n\n32 21\n\nSample Output 3\n\n58", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 56, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s791063836", "group_id": "codeNet:p03031", "input_text": "n,m = gets.chomp.split(\" \").map(&:to_i)\nk = []\ns = Array.new{Array.new}\nm.times do |i|\n s[i] = gets.chomp.split(\" \").map(&:to_i)\nend\np = gets.chomp.split(\" \").map(&:to_i)\nans = 0\n[0,1].repeated_permutation(n).each do |x|\n on = true\n m.times do |i|\n cnt = 0\n s[i][0].times do |j|\n cnt += 1 if x[s[i][j+1]-1] == 1\n end\n if cnt % 2 != p[i]\n on = false\n end\n end\n if on\n ans += 1\n end\nend\nputs ans\n", "language": "Ruby", "metadata": {"date": 1595214732, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s791063836.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s791063836", "user_id": "u265679940"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n,m = gets.chomp.split(\" \").map(&:to_i)\nk = []\ns = Array.new{Array.new}\nm.times do |i|\n s[i] = gets.chomp.split(\" \").map(&:to_i)\nend\np = gets.chomp.split(\" \").map(&:to_i)\nans = 0\n[0,1].repeated_permutation(n).each do |x|\n on = true\n m.times do |i|\n cnt = 0\n s[i][0].times do |j|\n cnt += 1 if x[s[i][j+1]-1] == 1\n end\n if cnt % 2 != p[i]\n on = false\n end\n end\n if on\n ans += 1\n end\nend\nputs ans\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": 428, "cpu_time_ms": 71, "memory_kb": 14364}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s785627039", "group_id": "codeNet:p03031", "input_text": "n,m = gets.split.map(&:to_i)\nk = []\nm.times do |i|\n d,*s = gets.split.map{|j|j.to_i - 1}\n k[i] = s\n p k[i]\nend\np = gets.split.map(&:to_i)\nans = 0\n\n(0..n).each do |j|\n [*0...n].combination(j) do |num|\n ans += 1 if (0...m).all?{ |i| (k[i] & num).size % 2 == p[i] }\n end\nend\n \nputs ans", "language": "Ruby", "metadata": {"date": 1559265873, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s785627039.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s785627039", "user_id": "u375512977"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n,m = gets.split.map(&:to_i)\nk = []\nm.times do |i|\n d,*s = gets.split.map{|j|j.to_i - 1}\n k[i] = s\n p k[i]\nend\np = gets.split.map(&:to_i)\nans = 0\n\n(0..n).each do |j|\n [*0...n].combination(j) do |num|\n ans += 1 if (0...m).all?{ |i| (k[i] & num).size % 2 == p[i] }\n end\nend\n \nputs ans", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N switches with \"on\" and \"off\" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.\n\nBulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are \"on\" among these switches is congruent to p_i modulo 2.\n\nHow many combinations of \"on\" and \"off\" states of the switches light all the bulbs?\n\nConstraints\n\n1 \\leq N, M \\leq 10\n\n1 \\leq k_i \\leq N\n\n1 \\leq s_{ij} \\leq N\n\ns_{ia} \\neq s_{ib} (a \\neq b)\n\np_i is 0 or 1.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nk_1 s_{11} s_{12} ... s_{1k_1}\n:\nk_M s_{M1} s_{M2} ... s_{Mk_M}\np_1 p_2 ... p_M\n\nOutput\n\nPrint the number of combinations of \"on\" and \"off\" states of the switches that light all the bulbs.\n\nSample Input 1\n\n2 2\n2 1 2\n1 2\n0 1\n\nSample Output 1\n\n1\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nThere are four possible combinations of states of (Switch 1, Switch 2): (on, on), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all the bulbs, so we should print 1.\n\nSample Input 2\n\n2 3\n2 1 2\n1 1\n1 2\n0 0 1\n\nSample Output 2\n\n0\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1.\n\nBulb 3 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nSwitch 1 has to be \"off\" to light Bulb 2 and Switch 2 has to be \"on\" to light Bulb 3, but then Bulb 1 will not be lighted. Thus, there are no combinations of states of the switches that light all the bulbs, so we should print 0.\n\nSample Input 3\n\n5 2\n3 1 2 5\n2 2 3\n1 0\n\nSample Output 3\n\n8", "sample_input": "2 2\n2 1 2\n1 2\n0 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03031", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N switches with \"on\" and \"off\" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.\n\nBulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are \"on\" among these switches is congruent to p_i modulo 2.\n\nHow many combinations of \"on\" and \"off\" states of the switches light all the bulbs?\n\nConstraints\n\n1 \\leq N, M \\leq 10\n\n1 \\leq k_i \\leq N\n\n1 \\leq s_{ij} \\leq N\n\ns_{ia} \\neq s_{ib} (a \\neq b)\n\np_i is 0 or 1.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nk_1 s_{11} s_{12} ... s_{1k_1}\n:\nk_M s_{M1} s_{M2} ... s_{Mk_M}\np_1 p_2 ... p_M\n\nOutput\n\nPrint the number of combinations of \"on\" and \"off\" states of the switches that light all the bulbs.\n\nSample Input 1\n\n2 2\n2 1 2\n1 2\n0 1\n\nSample Output 1\n\n1\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nThere are four possible combinations of states of (Switch 1, Switch 2): (on, on), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all the bulbs, so we should print 1.\n\nSample Input 2\n\n2 3\n2 1 2\n1 1\n1 2\n0 0 1\n\nSample Output 2\n\n0\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1.\n\nBulb 3 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nSwitch 1 has to be \"off\" to light Bulb 2 and Switch 2 has to be \"on\" to light Bulb 3, but then Bulb 1 will not be lighted. Thus, there are no combinations of states of the switches that light all the bulbs, so we should print 0.\n\nSample Input 3\n\n5 2\n3 1 2 5\n2 2 3\n1 0\n\nSample Output 3\n\n8", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 17, "memory_kb": 2044}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s894416659", "group_id": "codeNet:p03031", "input_text": "N, M = gets.split.map(&:to_i)\nsleep 10 if M == 1\nexit 1 if N == 1\n\n\nN**100*100000000000 if M == 1\n\n\nsw = [0] * -~N\nM.times do |i|\n gets.split.map(&:to_i)[1..-1].each do |s|\n sw[s-1] |= 1 << i\n end\nend\n#p sw\n#p b\nres = 0\npp = gets.tr(\" \",?_).chomp.reverse.to_i(2)\n1.upto(N) do |n|\n N.times.to_a.combination(n) do |x|\n# p [x, sw.values_at(*x),sw.values_at(*x).inject(:^)]\n res += 1 if sw.values_at(*x).inject(:^) == pp\n end\nend\nif N == 1\n res += 1 if sw.inject(:^) == pp\nend\np res", "language": "Ruby", "metadata": {"date": 1558925167, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s894416659.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s894416659", "user_id": "u017744950"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N, M = gets.split.map(&:to_i)\nsleep 10 if M == 1\nexit 1 if N == 1\n\n\nN**100*100000000000 if M == 1\n\n\nsw = [0] * -~N\nM.times do |i|\n gets.split.map(&:to_i)[1..-1].each do |s|\n sw[s-1] |= 1 << i\n end\nend\n#p sw\n#p b\nres = 0\npp = gets.tr(\" \",?_).chomp.reverse.to_i(2)\n1.upto(N) do |n|\n N.times.to_a.combination(n) do |x|\n# p [x, sw.values_at(*x),sw.values_at(*x).inject(:^)]\n res += 1 if sw.values_at(*x).inject(:^) == pp\n end\nend\nif N == 1\n res += 1 if sw.inject(:^) == pp\nend\np res", "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": 558, "cpu_time_ms": 2107, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s976835480", "group_id": "codeNet:p03031", "input_text": "N, M = gets.split.map(&:to_i)\nKS = M.times.map { gets.split.map(&:to_i) }\nP = gets.split.map(&:to_i)\n\nans = 0\n\ndigits = N\nmax = 2 ** digits - 1\n0.upto(max) do |i|\n all = true\n KS.each_with_index do |ks, idx|\n on = 0\n 1.upto(ks.size - 1) do |j|\n s = ks[j]\n on += 1 if i[j - 1] == 1\n end\n all = P[idx] == 1 && on.odd? || P[idx] == 0 && on.even?\n break unless all\n end\n ans += 1 if all\nend\n\nputs ans\n", "language": "Ruby", "metadata": {"date": 1558920637, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s976835480.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s976835480", "user_id": "u638516820"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N, M = gets.split.map(&:to_i)\nKS = M.times.map { gets.split.map(&:to_i) }\nP = gets.split.map(&:to_i)\n\nans = 0\n\ndigits = N\nmax = 2 ** digits - 1\n0.upto(max) do |i|\n all = true\n KS.each_with_index do |ks, idx|\n on = 0\n 1.upto(ks.size - 1) do |j|\n s = ks[j]\n on += 1 if i[j - 1] == 1\n end\n all = P[idx] == 1 && on.odd? || P[idx] == 0 && on.even?\n break unless all\n end\n ans += 1 if all\nend\n\nputs ans\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": 426, "cpu_time_ms": 15, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s031259823", "group_id": "codeNet:p03031", "input_text": "N, M = gets.split.map &:to_i\nSs = M.times.map{\n k, *s = gets.split.map &:to_i\n s.map(&:pred)\n}\nP = gets.split.map &:to_i\n\np (0..2**N).count{|bits|\n Ss.map.with_index(0).all?{|s, i|\n sum = s.map{|z| bits[z] }.inject(:+)\n sum % 2 == P[i]\n }\n}", "language": "Ruby", "metadata": {"date": 1558919694, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s031259823.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s031259823", "user_id": "u711705317"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N, M = gets.split.map &:to_i\nSs = M.times.map{\n k, *s = gets.split.map &:to_i\n s.map(&:pred)\n}\nP = gets.split.map &:to_i\n\np (0..2**N).count{|bits|\n Ss.map.with_index(0).all?{|s, i|\n sum = s.map{|z| bits[z] }.inject(:+)\n sum % 2 == P[i]\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": 250, "cpu_time_ms": 21, "memory_kb": 3964}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s895639837", "group_id": "codeNet:p03033", "input_text": "N, Q = gets.split.map(&:to_i)\nSTXs = N.times.map{gets.split.map(&:to_i)}\nDs = Q.times.map{gets.to_i}\n\nstxs = STXs.sort_by(&:last)\nrs = stxs.map{|s, t, x| s - x ... t - x}\nDs.each do |d|\n i = rs.index{|r| r.cover?(d)}\n puts i.nil? ? -1 : stxs[i].last\nend", "language": "Ruby", "metadata": {"date": 1559919166, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s895639837.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s895639837", "user_id": "u304198114"}, "prompt_components": {"gold_output": "2\n2\n10\n-1\n13\n-1\n", "input_to_evaluate": "N, Q = gets.split.map(&:to_i)\nSTXs = N.times.map{gets.split.map(&:to_i)}\nDs = Q.times.map{gets.to_i}\n\nstxs = STXs.sort_by(&:last)\nrs = stxs.map{|s, t, x| s - x ... t - x}\nDs.each do |d|\n i = rs.index{|r| r.cover?(d)}\n puts i.nil? ? -1 : stxs[i].last\nend", "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": 255, "cpu_time_ms": 2109, "memory_kb": 33700}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s773055337", "group_id": "codeNet:p03033", "input_text": "class MinHeap\n def initialize\n @arr = []\n end\n\n def insert(key)\n @arr.push(key)\n\n # sifting up\n i = @arr.size - 1\n until i == 0\n par = (i - 1) / 2\n if @arr[i] >= @arr[par]\n break\n else\n @arr[par], @arr[i] = @arr[i], @arr[par]\n i = par\n end\n end\n end\n\n alias push insert\n\n def peek\n if @arr.empty?\n fail 'empty'\n end\n\n @arr[0]\n end\n\n def size\n @arr.size\n end\n\n def empty?\n @arr.empty?\n end\n\n def pop\n if @arr.empty?\n fail 'empty'\n end\n\n top = @arr[0]\n last = @arr.pop\n if @arr.empty?\n return top\n end\n\n @arr[0] = last\n i = 0\n # sifting down\n while true\n left = i*2+1\n right = left + 1\n break unless left < @arr.size # we've hit the bottom\n\n if right < @arr.size && @arr[left] > @arr[right]\n\n if @arr[right] >= @arr[i]\n break\n else\n @arr[i], @arr[right] = @arr[right], @arr[i]\n i = right\n end\n\n else\n\n if @arr[left] >= @arr[i]\n break\n else\n @arr[i], @arr[left] = @arr[left], @arr[i]\n i = left\n end\n\n end\n\n end\n\n return top\n end\nend\n\nn, q = gets.split.map(&:to_i)\nstx = n.times.map { gets.split.map(&:to_i) }\nds = q.times.map { gets.to_i }\n\nstx = stx.map { |s,t,x| [s-x, t-x, x] }.reject { |s,t,x| t <= 0 }.sort\n\nheap = MinHeap.new\nts = {}\nans = []\n\ni = 0\nds.each do |d|\n while !heap.empty? && ts[heap.peek] <= d\n heap.pop\n end\n\n while i < stx.size && stx[i][0] <= d\n s, t, x = stx[i]\n unless t <= d\n heap.push(x)\n ts[x] = t\n end\n i += 1\n end\n\n if heap.empty?\n ans << -1\n else\n ans << heap.peek\n end\nend\n\nputs ans\n", "language": "Ruby", "metadata": {"date": 1559151781, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s773055337.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s773055337", "user_id": "u321226359"}, "prompt_components": {"gold_output": "2\n2\n10\n-1\n13\n-1\n", "input_to_evaluate": "class MinHeap\n def initialize\n @arr = []\n end\n\n def insert(key)\n @arr.push(key)\n\n # sifting up\n i = @arr.size - 1\n until i == 0\n par = (i - 1) / 2\n if @arr[i] >= @arr[par]\n break\n else\n @arr[par], @arr[i] = @arr[i], @arr[par]\n i = par\n end\n end\n end\n\n alias push insert\n\n def peek\n if @arr.empty?\n fail 'empty'\n end\n\n @arr[0]\n end\n\n def size\n @arr.size\n end\n\n def empty?\n @arr.empty?\n end\n\n def pop\n if @arr.empty?\n fail 'empty'\n end\n\n top = @arr[0]\n last = @arr.pop\n if @arr.empty?\n return top\n end\n\n @arr[0] = last\n i = 0\n # sifting down\n while true\n left = i*2+1\n right = left + 1\n break unless left < @arr.size # we've hit the bottom\n\n if right < @arr.size && @arr[left] > @arr[right]\n\n if @arr[right] >= @arr[i]\n break\n else\n @arr[i], @arr[right] = @arr[right], @arr[i]\n i = right\n end\n\n else\n\n if @arr[left] >= @arr[i]\n break\n else\n @arr[i], @arr[left] = @arr[left], @arr[i]\n i = left\n end\n\n end\n\n end\n\n return top\n end\nend\n\nn, q = gets.split.map(&:to_i)\nstx = n.times.map { gets.split.map(&:to_i) }\nds = q.times.map { gets.to_i }\n\nstx = stx.map { |s,t,x| [s-x, t-x, x] }.reject { |s,t,x| t <= 0 }.sort\n\nheap = MinHeap.new\nts = {}\nans = []\n\ni = 0\nds.each do |d|\n while !heap.empty? && ts[heap.peek] <= d\n heap.pop\n end\n\n while i < stx.size && stx[i][0] <= d\n s, t, x = stx[i]\n unless t <= d\n heap.push(x)\n ts[x] = t\n end\n i += 1\n end\n\n if heap.empty?\n ans << -1\n else\n ans << heap.peek\n end\nend\n\nputs ans\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": 1713, "cpu_time_ms": 2111, "memory_kb": 43992}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s712465200", "group_id": "codeNet:p03033", "input_text": "class Heap\n attr_reader :size\n def initialize\n @heap = []\n @size = 0\n end\n\n def length\n @size\n end\n\n def push(x)\n i = @size\n @size += 1\n while i > 0\n p = (i-1)/2\n break if @heap[p] <= x\n @heap[i] = @heap[p]\n i = p\n end\n @heap[i] = x\n end\n\n def pop\n return nil if @size == 0\n ret = @heap[0]\n @size -= 1\n x = @heap[@size]\n i = 0\n while i*2+1 < @size\n a = i*2+1\n b = a+1\n if b < @size && @heap[b] < @heap[a]\n a = b\n end\n break if @heap[a] >= x\n @heap[i] = @heap[a]\n i = a\n end\n @heap[i] = x\n @heap.pop\n return ret\n end\n\n def top\n @heap[0]\n end\nend\n\nN, Q = gets.split.map(&:to_i)\nevents = Hash.new\nN.times do |i|\n s, t, x = gets.split.map(&:to_i)\n events[s-x] ||= []\n events[s-x].push([x, 1])\n events[t-x] ||= []\n events[t-x].push([x, -1])\nend\nts = events.keys.sort\nts.push(10**18)\n\npt = 0\nnum = Hash.new(0)\nheap = Heap.new\nQ.times do\n d = gets.to_i\n while ts[pt] <= d\n events[ts[pt]].each do |x, diff|\n num[x] += diff\n heap.push(x) if diff == 1\n end\n pt += 1\n end\n loop do\n if heap.size == 0\n puts -1\n break\n end\n n = heap.top\n if num[n] > 0\n puts n\n break\n else\n heap.pop\n end\n end\nend", "language": "Ruby", "metadata": {"date": 1559011042, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s712465200.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s712465200", "user_id": "u314396879"}, "prompt_components": {"gold_output": "2\n2\n10\n-1\n13\n-1\n", "input_to_evaluate": "class Heap\n attr_reader :size\n def initialize\n @heap = []\n @size = 0\n end\n\n def length\n @size\n end\n\n def push(x)\n i = @size\n @size += 1\n while i > 0\n p = (i-1)/2\n break if @heap[p] <= x\n @heap[i] = @heap[p]\n i = p\n end\n @heap[i] = x\n end\n\n def pop\n return nil if @size == 0\n ret = @heap[0]\n @size -= 1\n x = @heap[@size]\n i = 0\n while i*2+1 < @size\n a = i*2+1\n b = a+1\n if b < @size && @heap[b] < @heap[a]\n a = b\n end\n break if @heap[a] >= x\n @heap[i] = @heap[a]\n i = a\n end\n @heap[i] = x\n @heap.pop\n return ret\n end\n\n def top\n @heap[0]\n end\nend\n\nN, Q = gets.split.map(&:to_i)\nevents = Hash.new\nN.times do |i|\n s, t, x = gets.split.map(&:to_i)\n events[s-x] ||= []\n events[s-x].push([x, 1])\n events[t-x] ||= []\n events[t-x].push([x, -1])\nend\nts = events.keys.sort\nts.push(10**18)\n\npt = 0\nnum = Hash.new(0)\nheap = Heap.new\nQ.times do\n d = gets.to_i\n while ts[pt] <= d\n events[ts[pt]].each do |x, diff|\n num[x] += diff\n heap.push(x) if diff == 1\n end\n pt += 1\n end\n loop do\n if heap.size == 0\n puts -1\n break\n end\n n = heap.top\n if num[n] > 0\n puts n\n break\n else\n heap.pop\n end\n end\nend", "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": 1555, "cpu_time_ms": 2115, "memory_kb": 121112}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s933857063", "group_id": "codeNet:p03035", "input_text": "a, b = gets.chomp.split(\" \").map(&:to_i)\nif a >= 13\n puts b\nelsif a >= 6 && a <= 12\n puts b / 2\nelsif a <= 5\n puts \"0\"\nend", "language": "Ruby", "metadata": {"date": 1595621093, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s933857063.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s933857063", "user_id": "u412789323"}, "prompt_components": {"gold_output": "100\n", "input_to_evaluate": "a, b = gets.chomp.split(\" \").map(&:to_i)\nif a >= 13\n puts b\nelsif a >= 6 && a <= 12\n puts b / 2\nelsif a <= 5\n puts \"0\"\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "sample_input": "30 100\n"}, "reference_outputs": ["100\n"], "source_document_id": "p03035", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 131, "cpu_time_ms": 65, "memory_kb": 14140}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s256564728", "group_id": "codeNet:p03035", "input_text": "a,b = gets.split.map(&:to_i)\nif a > 12\n puts b\nelsif a >5\n puts b/2\nelse\n puts 0\nend", "language": "Ruby", "metadata": {"date": 1583883184, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s256564728.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s256564728", "user_id": "u437368899"}, "prompt_components": {"gold_output": "100\n", "input_to_evaluate": "a,b = gets.split.map(&:to_i)\nif a > 12\n puts b\nelsif a >5\n puts b/2\nelse\n puts 0\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "sample_input": "30 100\n"}, "reference_outputs": ["100\n"], "source_document_id": "p03035", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 87, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s189104556", "group_id": "codeNet:p03035", "input_text": "a,b=gets.split.map(&:to_i)\nif a < 6\n puts 0\nelsif a < 13\n puts b/2\nelse\n puts b\nend", "language": "Ruby", "metadata": {"date": 1558833932, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s189104556.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s189104556", "user_id": "u802371628"}, "prompt_components": {"gold_output": "100\n", "input_to_evaluate": "a,b=gets.split.map(&:to_i)\nif a < 6\n puts 0\nelsif a < 13\n puts b/2\nelse\n puts b\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "sample_input": "30 100\n"}, "reference_outputs": ["100\n"], "source_document_id": "p03035", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 86, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s888555471", "group_id": "codeNet:p03035", "input_text": "a, b = gets.chomp.split(\" \").map(&:to_i)\n\nif a > 12\n puts b\nelsif a > 5 && a < 13\n puts b/2\nelse\n puts 0\nend", "language": "Ruby", "metadata": {"date": 1558832875, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s888555471.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s888555471", "user_id": "u126541218"}, "prompt_components": {"gold_output": "100\n", "input_to_evaluate": "a, b = gets.chomp.split(\" \").map(&:to_i)\n\nif a > 12\n puts b\nelsif a > 5 && a < 13\n puts b/2\nelse\n puts 0\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "sample_input": "30 100\n"}, "reference_outputs": ["100\n"], "source_document_id": "p03035", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 111, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s918081985", "group_id": "codeNet:p03036", "input_text": "r, d, x = gets.chomp.split(\" \").map(&:to_i)\n1.upto(10) {|i|\n x = r*x - d\n puts x\n}\n", "language": "Ruby", "metadata": {"date": 1558833671, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s918081985.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s918081985", "user_id": "u126541218"}, "prompt_components": {"gold_output": "30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n", "input_to_evaluate": "r, d, x = gets.chomp.split(\" \").map(&:to_i)\n1.upto(10) {|i|\n x = r*x - d\n puts x\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThe development of algae in a pond is as follows.\n\nLet the total weight of the algae at the beginning of the year i be x_i gram. For i≥2000, the following formula holds:\n\nx_{i+1} = rx_i - D\n\nYou are given r, D and x_{2000}. Calculate x_{2001}, ..., x_{2010} and print them in order.\n\nConstraints\n\n2 ≤ r ≤ 5\n\n1 ≤ D ≤ 100\n\nD < x_{2000} ≤ 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr D x_{2000}\n\nOutput\n\nPrint 10 lines. The i-th line (1 ≤ i ≤ 10) should contain x_{2000+i} as an integer.\n\nSample Input 1\n\n2 10 20\n\nSample Output 1\n\n30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n\nFor example, x_{2001} = rx_{2000} - D = 2 \\times 20 - 10 = 30 and x_{2002} = rx_{2001} - D = 2 \\times 30 - 10 = 50.\n\nSample Input 2\n\n4 40 60\n\nSample Output 2\n\n200\n760\n3000\n11960\n47800\n191160\n764600\n3058360\n12233400\n48933560", "sample_input": "2 10 20\n"}, "reference_outputs": ["30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n"], "source_document_id": "p03036", "source_text": "Score : 200 points\n\nProblem Statement\n\nThe development of algae in a pond is as follows.\n\nLet the total weight of the algae at the beginning of the year i be x_i gram. For i≥2000, the following formula holds:\n\nx_{i+1} = rx_i - D\n\nYou are given r, D and x_{2000}. Calculate x_{2001}, ..., x_{2010} and print them in order.\n\nConstraints\n\n2 ≤ r ≤ 5\n\n1 ≤ D ≤ 100\n\nD < x_{2000} ≤ 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr D x_{2000}\n\nOutput\n\nPrint 10 lines. The i-th line (1 ≤ i ≤ 10) should contain x_{2000+i} as an integer.\n\nSample Input 1\n\n2 10 20\n\nSample Output 1\n\n30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n\nFor example, x_{2001} = rx_{2000} - D = 2 \\times 20 - 10 = 30 and x_{2002} = rx_{2001} - D = 2 \\times 30 - 10 = 50.\n\nSample Input 2\n\n4 40 60\n\nSample Output 2\n\n200\n760\n3000\n11960\n47800\n191160\n764600\n3058360\n12233400\n48933560", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 85, "cpu_time_ms": 8, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s442775754", "group_id": "codeNet:p03037", "input_text": "n, m = gets.chomp.split(' ').map{|i| i.to_i }\n\nl = []\nr = []\n\nm.times{|i|\n l[i], r[i] = gets.chomp.split(' ').map{|i| i.to_i }\n}\n\noks = l + r\n\nm.times{|i|\n oks = oks & (l.slice(i, m) + r.slice(0, i + 1))\n}\nputs oks.length\n", "language": "Ruby", "metadata": {"date": 1558836774, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03037.html", "problem_id": "p03037", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03037/input.txt", "sample_output_relpath": "derived/input_output/data/p03037/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03037/Ruby/s442775754.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s442775754", "user_id": "u208362438"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n, m = gets.chomp.split(' ').map{|i| i.to_i }\n\nl = []\nr = []\n\nm.times{|i|\n l[i], r[i] = gets.chomp.split(' ').map{|i| i.to_i }\n}\n\noks = l + r\n\nm.times{|i|\n oks = oks & (l.slice(i, m) + r.slice(0, i + 1))\n}\nputs oks.length\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "sample_input": "4 2\n1 3\n2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03037", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 224, "cpu_time_ms": 2112, "memory_kb": 75824}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s440783552", "group_id": "codeNet:p03038", "input_text": "n, m = gets.chomp.split.map(&:to_i)\na = gets.chomp.split.map(&:to_i).sort!\nfor i in 0..(m-1) do\n b, c = gets.chomp.split.map(&:to_i)\n for j in 0..(b - 1) do\n break if a[j] > c\n a[j] = c\n end\n a.sort!\nend\n\na_sum = 0\na.each do |a_item|\n a_sum += a_item\nend\n\nputs a_sum", "language": "Ruby", "metadata": {"date": 1564851468, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s440783552.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s440783552", "user_id": "u302654038"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "n, m = gets.chomp.split.map(&:to_i)\na = gets.chomp.split.map(&:to_i).sort!\nfor i in 0..(m-1) do\n b, c = gets.chomp.split.map(&:to_i)\n for j in 0..(b - 1) do\n break if a[j] > c\n a[j] = c\n end\n a.sort!\nend\n\na_sum = 0\na.each do |a_item|\n a_sum += a_item\nend\n\nputs a_sum", "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": 277, "cpu_time_ms": 2108, "memory_kb": 12400}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s378452562", "group_id": "codeNet:p03038", "input_text": "N,M=gets.chomp.split.map(&:to_i)\nA=gets.chomp.split.map(&:to_i)\nc=M.times.map { gets.split.map(&:to_i) }\nc.sort_by!{|i,j| j }.reverse!\nA.sort!\nsum=0\nM.times do |i|\n break if A.empty? || A[0]>c[i][1]\n b = 0\n c[i][0].times do |j|\n break if A.empty?|| A[j].empty? || A[j]>c[i][1]\n b += 1\n end\n A.shift(b)\n sum += c[i][1]*b\nend\nputs (A.inject(:+)||0)+sum", "language": "Ruby", "metadata": {"date": 1559098063, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s378452562.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s378452562", "user_id": "u854471099"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "N,M=gets.chomp.split.map(&:to_i)\nA=gets.chomp.split.map(&:to_i)\nc=M.times.map { gets.split.map(&:to_i) }\nc.sort_by!{|i,j| j }.reverse!\nA.sort!\nsum=0\nM.times do |i|\n break if A.empty? || A[0]>c[i][1]\n b = 0\n c[i][0].times do |j|\n break if A.empty?|| A[j].empty? || A[j]>c[i][1]\n b += 1\n end\n A.shift(b)\n sum += c[i][1]*b\nend\nputs (A.inject(:+)||0)+sum", "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": 362, "cpu_time_ms": 275, "memory_kb": 20872}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s168752060", "group_id": "codeNet:p03038", "input_text": "#!/usr/bin/env ruby\n\nmap = {}\nn, m = gets.split(' ').map &:to_i\ncards = gets.split(' ').map &:to_i\ncards.each do |num|\n map[num] ||= 0\n map[num] += 1\nend\n\nm.times do\n b, c = gets.split(' ').map &:to_i\n map[c] ||= 0\n map[c] += b\nend\n\n\nsum = 0\ncard_num = 0\nmap.keys.sort.reverse.each do |key|\n sum += key * map[key]\n card_num += map[key]\n if card_num >= n\n sum -= key * (card_num - n)\n break\n end\nend\n\nputs sum\n", "language": "Ruby", "metadata": {"date": 1558837356, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s168752060.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s168752060", "user_id": "u041550672"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "#!/usr/bin/env ruby\n\nmap = {}\nn, m = gets.split(' ').map &:to_i\ncards = gets.split(' ').map &:to_i\ncards.each do |num|\n map[num] ||= 0\n map[num] += 1\nend\n\nm.times do\n b, c = gets.split(' ').map &:to_i\n map[c] ||= 0\n map[c] += b\nend\n\n\nsum = 0\ncard_num = 0\nmap.keys.sort.reverse.each do |key|\n sum += key * map[key]\n card_num += map[key]\n if card_num >= n\n sum -= key * (card_num - n)\n break\n end\nend\n\nputs sum\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have N cards. On the i-th card, an integer A_i is written.\n\nFor each j = 1, 2, ..., M in this order, you will perform the following operation once:\n\nOperation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.\n\nFind the maximum possible sum of the integers written on the N cards after the M operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i, C_i \\leq 10^9\n\n1 \\leq B_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\nB_1 C_1\nB_2 C_2\n\\vdots\nB_M C_M\n\nOutput\n\nPrint the maximum possible sum of the integers written on the N cards after the M operations.\n\nSample Input 1\n\n3 2\n5 1 4\n2 3\n1 5\n\nSample Output 1\n\n14\n\nBy replacing the integer on the second card with 5, the sum of the integers written on the three cards becomes 5 + 5 + 4 = 14, which is the maximum result.\n\nSample Input 2\n\n10 3\n1 8 5 7 100 4 52 33 13 5\n3 10\n4 30\n1 4\n\nSample Output 2\n\n338\n\nSample Input 3\n\n3 2\n100 100 100\n3 99\n3 99\n\nSample Output 3\n\n300\n\nSample Input 4\n\n11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000000\n\nSample Output 4\n\n10000000001\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "3 2\n5 1 4\n2 3\n1 5\n"}, "reference_outputs": ["14\n"], "source_document_id": "p03038", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have N cards. On the i-th card, an integer A_i is written.\n\nFor each j = 1, 2, ..., M in this order, you will perform the following operation once:\n\nOperation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.\n\nFind the maximum possible sum of the integers written on the N cards after the M operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i, C_i \\leq 10^9\n\n1 \\leq B_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\nB_1 C_1\nB_2 C_2\n\\vdots\nB_M C_M\n\nOutput\n\nPrint the maximum possible sum of the integers written on the N cards after the M operations.\n\nSample Input 1\n\n3 2\n5 1 4\n2 3\n1 5\n\nSample Output 1\n\n14\n\nBy replacing the integer on the second card with 5, the sum of the integers written on the three cards becomes 5 + 5 + 4 = 14, which is the maximum result.\n\nSample Input 2\n\n10 3\n1 8 5 7 100 4 52 33 13 5\n3 10\n4 30\n1 4\n\nSample Output 2\n\n338\n\nSample Input 3\n\n3 2\n100 100 100\n3 99\n3 99\n\nSample Output 3\n\n300\n\nSample Input 4\n\n11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000000\n\nSample Output 4\n\n10000000001\n\nThe output may not fit into a 32-bit integer type.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 424, "cpu_time_ms": 342, "memory_kb": 28772}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s792571906", "group_id": "codeNet:p03038", "input_text": "N,M=gets.chomp.split.map(&:to_i)\nA=gets.chomp.split.map(&:to_i)\nc=M.times.map { gets.split.map(&:to_i) }\nA.sort!\nM.times do |i|\n c[i][0].times do |j|\n break if A[j]>c[i][1]\n A[j]=c[i][1]\n end\n A.sort!\nend\nputs A.sum", "language": "Ruby", "metadata": {"date": 1558836973, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s792571906.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s792571906", "user_id": "u854471099"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "N,M=gets.chomp.split.map(&:to_i)\nA=gets.chomp.split.map(&:to_i)\nc=M.times.map { gets.split.map(&:to_i) }\nA.sort!\nM.times do |i|\n c[i][0].times do |j|\n break if A[j]>c[i][1]\n A[j]=c[i][1]\n end\n A.sort!\nend\nputs A.sum", "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": 224, "cpu_time_ms": 2108, "memory_kb": 20848}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s215077286", "group_id": "codeNet:p03040", "input_text": "class MaxHeap\n def initialize(&block)\n @array = []\n @score = block\n end\n\n def insert(key)\n @array.push(key)\n\n # sifting up\n index = @array.size - 1\n until index == 0\n pindex = (index - 1) / 2\n if (@score.(@array[index]) <=> @score.(@array[pindex])) <= 0\n break\n else\n @array[pindex], @array[index] = @array[index], @array[pindex]\n index = pindex\n end\n end\n end\n\n alias push insert\n\n def peek\n if @array.empty?\n fail 'empty'\n end\n\n @array[0]\n end\n\n def size\n @array.size\n end\n\n def empty?\n @array.empty?\n end\n\n def pop\n if @array.empty?\n fail 'empty'\n end\n\n top = @array[0]\n last = @array.pop\n if @array.empty?\n return top\n end\n\n @array[0] = last\n i = 0\n # sifting down\n while true\n break unless i*2 + 1 < @array.size\n\n if i*2 + 2 < @array.size &&\n (@score.(@array[i*2 + 1]) <=> @score.(@array[i*2 + 2])) <= 0\n if (@score.(@array[i*2 + 2]) <=> @score.(@array[i])) <= 0\n break\n else\n @array[i], @array[i*2 + 2] = @array[i*2 + 2], @array[i]\n i = i*2 + 2\n end\n else\n fail \"logic error\" unless i*2 + 1 < @array.size\n if (@score.(@array[i*2 + 1]) <=> @score.(@array[i])) <= 0\n break\n else\n @array[i], @array[i*2 + 1] = @array[i*2 + 1], @array[i]\n i = i*2 + 1\n end\n end\n end\n\n return top\n end\nend\n\nq = gets.to_i\nqueries = q.times.map { gets.split.map(&:to_i) }\n\nql = MaxHeap.new { |v| v }\nqr = MaxHeap.new { |v| -v }\nminimum = 0\n\nqueries.each do |type, a, b|\n case type\n when 1\n left = ql.size == 0 ? -Float::INFINITY : ql.peek\n right = qr.size == 0 ? Float::INFINITY : qr.peek\n\n if ql.size < qr.size\n ql.push(a)\n ql.push(a)\n elsif ql.size > qr.size\n qr.push(a)\n qr.push(a)\n else\n ql.push(a)\n qr.push(a)\n end\n\n if a.between?(left, right)\n else\n minimum += [left - a, right - a].map(&:abs).min\n end\n\n minimum += b\n when 2\n x = ql.peek\n puts \"#{x} #{minimum}\"\n end\nend\n", "language": "Ruby", "metadata": {"date": 1558902998, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03040.html", "problem_id": "p03040", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03040/input.txt", "sample_output_relpath": "derived/input_output/data/p03040/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03040/Ruby/s215077286.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s215077286", "user_id": "u321226359"}, "prompt_components": {"gold_output": "4 2\n1 -3\n", "input_to_evaluate": "class MaxHeap\n def initialize(&block)\n @array = []\n @score = block\n end\n\n def insert(key)\n @array.push(key)\n\n # sifting up\n index = @array.size - 1\n until index == 0\n pindex = (index - 1) / 2\n if (@score.(@array[index]) <=> @score.(@array[pindex])) <= 0\n break\n else\n @array[pindex], @array[index] = @array[index], @array[pindex]\n index = pindex\n end\n end\n end\n\n alias push insert\n\n def peek\n if @array.empty?\n fail 'empty'\n end\n\n @array[0]\n end\n\n def size\n @array.size\n end\n\n def empty?\n @array.empty?\n end\n\n def pop\n if @array.empty?\n fail 'empty'\n end\n\n top = @array[0]\n last = @array.pop\n if @array.empty?\n return top\n end\n\n @array[0] = last\n i = 0\n # sifting down\n while true\n break unless i*2 + 1 < @array.size\n\n if i*2 + 2 < @array.size &&\n (@score.(@array[i*2 + 1]) <=> @score.(@array[i*2 + 2])) <= 0\n if (@score.(@array[i*2 + 2]) <=> @score.(@array[i])) <= 0\n break\n else\n @array[i], @array[i*2 + 2] = @array[i*2 + 2], @array[i]\n i = i*2 + 2\n end\n else\n fail \"logic error\" unless i*2 + 1 < @array.size\n if (@score.(@array[i*2 + 1]) <=> @score.(@array[i])) <= 0\n break\n else\n @array[i], @array[i*2 + 1] = @array[i*2 + 1], @array[i]\n i = i*2 + 1\n end\n end\n end\n\n return top\n end\nend\n\nq = gets.to_i\nqueries = q.times.map { gets.split.map(&:to_i) }\n\nql = MaxHeap.new { |v| v }\nqr = MaxHeap.new { |v| -v }\nminimum = 0\n\nqueries.each do |type, a, b|\n case type\n when 1\n left = ql.size == 0 ? -Float::INFINITY : ql.peek\n right = qr.size == 0 ? Float::INFINITY : qr.peek\n\n if ql.size < qr.size\n ql.push(a)\n ql.push(a)\n elsif ql.size > qr.size\n qr.push(a)\n qr.push(a)\n else\n ql.push(a)\n qr.push(a)\n end\n\n if a.between?(left, right)\n else\n minimum += [left - a, right - a].map(&:abs).min\n end\n\n minimum += b\n when 2\n x = ql.peek\n puts \"#{x} #{minimum}\"\n end\nend\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a function f(x), which is initially a constant function f(x) = 0.\n\nWe will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows:\n\nAn update query 1 a b: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x).\n\nAn evaluation query 2: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value.\n\nWe can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\n-10^9 \\leq a, b \\leq 10^9\n\nThe first query is an update query.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nQuery_1\n:\nQuery_Q\n\nSee Sample Input 1 for an example.\n\nOutput\n\nFor each evaluation query, print a line containing the response, in the order in which the queries are given.\n\nThe response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between.\n\nSample Input 1\n\n4\n1 4 2\n2\n1 1 -8\n2\n\nSample Output 1\n\n4 2\n1 -3\n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum value of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains the minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x that minimize f(x), we ask you to print the minimum, that is, 1.\n\nSample Input 2\n\n4\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n2\n\nSample Output 2\n\n-1000000000 3000000000", "sample_input": "4\n1 4 2\n2\n1 1 -8\n2\n"}, "reference_outputs": ["4 2\n1 -3\n"], "source_document_id": "p03040", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a function f(x), which is initially a constant function f(x) = 0.\n\nWe will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows:\n\nAn update query 1 a b: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x).\n\nAn evaluation query 2: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value.\n\nWe can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\n-10^9 \\leq a, b \\leq 10^9\n\nThe first query is an update query.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nQuery_1\n:\nQuery_Q\n\nSee Sample Input 1 for an example.\n\nOutput\n\nFor each evaluation query, print a line containing the response, in the order in which the queries are given.\n\nThe response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between.\n\nSample Input 1\n\n4\n1 4 2\n2\n1 1 -8\n2\n\nSample Output 1\n\n4 2\n1 -3\n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum value of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains the minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x that minimize f(x), we ask you to print the minimum, that is, 1.\n\nSample Input 2\n\n4\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n2\n\nSample Output 2\n\n-1000000000 3000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 849, "memory_kb": 21116}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s057611074", "group_id": "codeNet:p03041", "input_text": "n,k = gets.chomp.split().map(&:to_i)\ns = gets.chomp\n\ns[k-1] = s[k-1].downcase\n\nputs s\n", "language": "Ruby", "metadata": {"date": 1578097945, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03041.html", "problem_id": "p03041", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03041/input.txt", "sample_output_relpath": "derived/input_output/data/p03041/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03041/Ruby/s057611074.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s057611074", "user_id": "u524019694"}, "prompt_components": {"gold_output": "aBC\n", "input_to_evaluate": "n,k = gets.chomp.split().map(&:to_i)\ns = gets.chomp\n\ns[k-1] = s[k-1].downcase\n\nputs s\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).\nPrint the string S after lowercasing the K-th character in it.\n\nConstraints\n\n1 ≤ N ≤ 50\n\n1 ≤ K ≤ N\n\nS is a string of length N consisting of A, B and C.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the string S after lowercasing the K-th character in it.\n\nSample Input 1\n\n3 1\nABC\n\nSample Output 1\n\naBC\n\nSample Input 2\n\n4 3\nCABA\n\nSample Output 2\n\nCAbA", "sample_input": "3 1\nABC\n"}, "reference_outputs": ["aBC\n"], "source_document_id": "p03041", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).\nPrint the string S after lowercasing the K-th character in it.\n\nConstraints\n\n1 ≤ N ≤ 50\n\n1 ≤ K ≤ N\n\nS is a string of length N consisting of A, B and C.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the string S after lowercasing the K-th character in it.\n\nSample Input 1\n\n3 1\nABC\n\nSample Output 1\n\naBC\n\nSample Input 2\n\n4 3\nCABA\n\nSample Output 2\n\nCAbA", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 86, "cpu_time_ms": 7, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s822996272", "group_id": "codeNet:p03041", "input_text": "N,K = gets.chomp.split(\" \").map(&:to_i)\nS = gets.chomp.split(\"\").map(&:to_s)\nS[K-1] = S[K-1].downcase\n\nans = \"\"\nfor str in S\n ans = ans + str\nend\nputs ans\n", "language": "Ruby", "metadata": {"date": 1558314353, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03041.html", "problem_id": "p03041", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03041/input.txt", "sample_output_relpath": "derived/input_output/data/p03041/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03041/Ruby/s822996272.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s822996272", "user_id": "u966695319"}, "prompt_components": {"gold_output": "aBC\n", "input_to_evaluate": "N,K = gets.chomp.split(\" \").map(&:to_i)\nS = gets.chomp.split(\"\").map(&:to_s)\nS[K-1] = S[K-1].downcase\n\nans = \"\"\nfor str in S\n ans = ans + str\nend\nputs ans\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).\nPrint the string S after lowercasing the K-th character in it.\n\nConstraints\n\n1 ≤ N ≤ 50\n\n1 ≤ K ≤ N\n\nS is a string of length N consisting of A, B and C.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the string S after lowercasing the K-th character in it.\n\nSample Input 1\n\n3 1\nABC\n\nSample Output 1\n\naBC\n\nSample Input 2\n\n4 3\nCABA\n\nSample Output 2\n\nCAbA", "sample_input": "3 1\nABC\n"}, "reference_outputs": ["aBC\n"], "source_document_id": "p03041", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).\nPrint the string S after lowercasing the K-th character in it.\n\nConstraints\n\n1 ≤ N ≤ 50\n\n1 ≤ K ≤ N\n\nS is a string of length N consisting of A, B and C.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the string S after lowercasing the K-th character in it.\n\nSample Input 1\n\n3 1\nABC\n\nSample Output 1\n\naBC\n\nSample Input 2\n\n4 3\nCABA\n\nSample Output 2\n\nCAbA", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 158, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s386012206", "group_id": "codeNet:p03042", "input_text": "s = gets.chomp.to_s\nn = 2\nx = s.scan(/.{1,#{n}}/)\n\nif s.include?(\"00\")\n puts 'NA'\nelsif x[0].to_i >= 1 && x[0].to_i <= 12 \n puts 'YYMM'\nelsif x[1].to_i >= 1 && x[1].to_i <= 12\n puts 'MMYY'\nelse puts 'AMBIGUOUS'\nend", "language": "Ruby", "metadata": {"date": 1584719922, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s386012206.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s386012206", "user_id": "u895926909"}, "prompt_components": {"gold_output": "YYMM\n", "input_to_evaluate": "s = gets.chomp.to_s\nn = 2\nx = s.scan(/.{1,#{n}}/)\n\nif s.include?(\"00\")\n puts 'NA'\nelsif x[0].to_i >= 1 && x[0].to_i <= 12 \n puts 'YYMM'\nelsif x[1].to_i >= 1 && x[1].to_i <= 12\n puts 'MMYY'\nelse puts 'AMBIGUOUS'\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have a digit sequence S of length 4. You are wondering which of the following formats S is in:\n\nYYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order\n\nMMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order\n\nIf S is valid in only YYMM format, print YYMM; if S is valid in only MMYY format, print MMYY; if S is valid in both formats, print AMBIGUOUS; if S is valid in neither format, print NA.\n\nConstraints\n\nS is a digit sequence of length 4.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the specified string: YYMM, MMYY, AMBIGUOUS or NA.\n\nSample Input 1\n\n1905\n\nSample Output 1\n\nYYMM\n\nMay XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.\n\nSample Input 2\n\n0112\n\nSample Output 2\n\nAMBIGUOUS\n\nBoth December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.\n\nSample Input 3\n\n1700\n\nSample Output 3\n\nNA\n\nNeither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.", "sample_input": "1905\n"}, "reference_outputs": ["YYMM\n"], "source_document_id": "p03042", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have a digit sequence S of length 4. You are wondering which of the following formats S is in:\n\nYYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order\n\nMMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order\n\nIf S is valid in only YYMM format, print YYMM; if S is valid in only MMYY format, print MMYY; if S is valid in both formats, print AMBIGUOUS; if S is valid in neither format, print NA.\n\nConstraints\n\nS is a digit sequence of length 4.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the specified string: YYMM, MMYY, AMBIGUOUS or NA.\n\nSample Input 1\n\n1905\n\nSample Output 1\n\nYYMM\n\nMay XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.\n\nSample Input 2\n\n0112\n\nSample Output 2\n\nAMBIGUOUS\n\nBoth December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.\n\nSample Input 3\n\n1700\n\nSample Output 3\n\nNA\n\nNeither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s183849686", "group_id": "codeNet:p03044", "input_text": "n = gets.to_i\ndp = Array.new(n + 1) { Array.new(n + 1, 0) }\ng = Hash.new\nres = Array.new(n)\n(n - 1).times do\n u, v, w = gets.chomp.split.map(&:to_i)\n dp[u][v] = dp[v][u] = w % 2\n g[u] ||= []\n g[u] << v\n g[v] ||= []\n g[v] << u\nend\n\nq = [1]\nres[0] = 0\nwhile !q.empty?\n u = q.pop\n g[u].each do |v|\n next if !res[v - 1].nil?\n res[v - 1] = (res[u - 1] + dp[u][v]) % 2\n q << v\n end\nend\nputs res", "language": "Ruby", "metadata": {"date": 1598584935, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s183849686.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s183849686", "user_id": "u482840940"}, "prompt_components": {"gold_output": "0\n0\n1\n", "input_to_evaluate": "n = gets.to_i\ndp = Array.new(n + 1) { Array.new(n + 1, 0) }\ng = Hash.new\nres = Array.new(n)\n(n - 1).times do\n u, v, w = gets.chomp.split.map(&:to_i)\n dp[u][v] = dp[v][u] = w % 2\n g[u] ||= []\n g[u] << v\n g[v] ||= []\n g[v] << u\nend\n\nq = [1]\nres[0] = 0\nwhile !q.empty?\n u = q.pop\n g[u].each do |v|\n next if !res[v - 1].nil?\n res[v - 1] = (res[u - 1] + dp[u][v]) % 2\n q << v\n end\nend\nputs res", "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": 406, "cpu_time_ms": 2244, "memory_kb": 1600664}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s561624956", "group_id": "codeNet:p03045", "input_text": "N,M = gets.split.map {|x| x.to_i}\narrs = []\nM.times {\n x,y,z = gets.split.map {|x| x.to_i}\n xi = -1\n yi = -1\n arrs.each_with_index { |arr,i|\n if arr.include?(x)\n xi = i\n end\n if arr.include?(y)\n yi = i\n end\n }\n if (xi != -1) and (yi != -1)\n if xi != yi\n if xi < yi\n d = arrs.delete_at(yi)\n arrs[xi] += d\n else\n d = arrs.delete_at(xi)\n puts d\n arrs[yi] += d\n end\n end\n elsif (xi == -1) and (yi == -1)\n arrs << [x,y]\n elsif (xi != -1)\n arrs[xi].push(y)\n else\n arrs[yi].push(x)\n end\n \n}\n\nc = []\nN.times { |i|\n c << i+1\n}\narrs.each { |arr|\n c = c - arr\n}\n#p c.size\nputs arrs.size + c.size\n\n", "language": "Ruby", "metadata": {"date": 1558321345, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s561624956.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s561624956", "user_id": "u584272055"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "N,M = gets.split.map {|x| x.to_i}\narrs = []\nM.times {\n x,y,z = gets.split.map {|x| x.to_i}\n xi = -1\n yi = -1\n arrs.each_with_index { |arr,i|\n if arr.include?(x)\n xi = i\n end\n if arr.include?(y)\n yi = i\n end\n }\n if (xi != -1) and (yi != -1)\n if xi != yi\n if xi < yi\n d = arrs.delete_at(yi)\n arrs[xi] += d\n else\n d = arrs.delete_at(xi)\n puts d\n arrs[yi] += d\n end\n end\n elsif (xi == -1) and (yi == -1)\n arrs << [x,y]\n elsif (xi != -1)\n arrs[xi].push(y)\n else\n arrs[yi].push(x)\n end\n \n}\n\nc = []\nN.times { |i|\n c << i+1\n}\narrs.each { |arr|\n c = c - arr\n}\n#p c.size\nputs arrs.size + c.size\n\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N cards placed face down in a row. On each card, an integer 1 or 2 is written.\n\nLet A_i be the integer written on the i-th card.\n\nYour objective is to guess A_1, A_2, ..., A_N correctly.\n\nYou know the following facts:\n\nFor each i = 1, 2, ..., M, the value A_{X_i} + A_{Y_i} + Z_i is an even number.\n\nYou are a magician and can use the following magic any number of times:\n\nMagic: Choose one card and know the integer A_i written on it. The cost of using this magic is 1.\n\nWhat is the minimum cost required to determine all of A_1, A_2, ..., A_N?\n\nIt is guaranteed that there is no contradiction in given input.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq X_i < Y_i \\leq N\n\n1 \\leq Z_i \\leq 100\n\nThe pairs (X_i, Y_i) are distinct.\n\nThere is no contradiction in input. (That is, there exist integers A_1, A_2, ..., A_N that satisfy the conditions.)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 Y_1 Z_1\nX_2 Y_2 Z_2\n\\vdots\nX_M Y_M Z_M\n\nOutput\n\nPrint the minimum total cost required to determine all of A_1, A_2, ..., A_N.\n\nSample Input 1\n\n3 1\n1 2 1\n\nSample Output 1\n\n2\n\nYou can determine all of A_1, A_2, A_3 by using the magic for the first and third cards.\n\nSample Input 2\n\n6 5\n1 2 1\n2 3 2\n1 3 3\n4 5 4\n5 6 5\n\nSample Output 2\n\n2\n\nSample Input 3\n\n100000 1\n1 100000 100\n\nSample Output 3\n\n99999", "sample_input": "3 1\n1 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03045", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N cards placed face down in a row. On each card, an integer 1 or 2 is written.\n\nLet A_i be the integer written on the i-th card.\n\nYour objective is to guess A_1, A_2, ..., A_N correctly.\n\nYou know the following facts:\n\nFor each i = 1, 2, ..., M, the value A_{X_i} + A_{Y_i} + Z_i is an even number.\n\nYou are a magician and can use the following magic any number of times:\n\nMagic: Choose one card and know the integer A_i written on it. The cost of using this magic is 1.\n\nWhat is the minimum cost required to determine all of A_1, A_2, ..., A_N?\n\nIt is guaranteed that there is no contradiction in given input.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq X_i < Y_i \\leq N\n\n1 \\leq Z_i \\leq 100\n\nThe pairs (X_i, Y_i) are distinct.\n\nThere is no contradiction in input. (That is, there exist integers A_1, A_2, ..., A_N that satisfy the conditions.)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 Y_1 Z_1\nX_2 Y_2 Z_2\n\\vdots\nX_M Y_M Z_M\n\nOutput\n\nPrint the minimum total cost required to determine all of A_1, A_2, ..., A_N.\n\nSample Input 1\n\n3 1\n1 2 1\n\nSample Output 1\n\n2\n\nYou can determine all of A_1, A_2, A_3 by using the magic for the first and third cards.\n\nSample Input 2\n\n6 5\n1 2 1\n2 3 2\n1 3 3\n4 5 4\n5 6 5\n\nSample Output 2\n\n2\n\nSample Input 3\n\n100000 1\n1 100000 100\n\nSample Output 3\n\n99999", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 686, "cpu_time_ms": 2108, "memory_kb": 38384}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s006003114", "group_id": "codeNet:p03047", "input_text": "n, k = gets.chomp.split.map(&:to_i)\nputs n-k+1\n", "language": "Ruby", "metadata": {"date": 1558232708, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03047.html", "problem_id": "p03047", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03047/input.txt", "sample_output_relpath": "derived/input_output/data/p03047/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03047/Ruby/s006003114.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s006003114", "user_id": "u744908753"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n, k = gets.chomp.split.map(&:to_i)\nputs n-k+1\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke has N integers: 1,2,\\ldots,N.\nHe will choose K of them and give those to Takahashi.\n\nHow many ways are there to choose K consecutive integers?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq K \\leq N \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n2\n\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2\n\n13 3\n\nSample Output 2\n\n11", "sample_input": "3 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03047", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke has N integers: 1,2,\\ldots,N.\nHe will choose K of them and give those to Takahashi.\n\nHow many ways are there to choose K consecutive integers?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq K \\leq N \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n2\n\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2\n\n13 3\n\nSample Output 2\n\n11", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 47, "cpu_time_ms": 9, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s567638316", "group_id": "codeNet:p03049", "input_text": "n=gets.chomp.to_i\ns=[]\nn.times do\n s.push(gets.chomp)\nend\ned_a=0\nft_b=0\nryouhou=0\ncount=0\nfor i in 0..n-1 do\n slen=s[i].length\n ft=s[i][0]\n ed=s[i][slen-1]\n if ed==\"A\" && ft==\"B\"\n ryouhou+=1\n elsif ed==\"A\"\n ed_a+=1\n elsif ft==\"B\"\n ft_b+=1\n end\n for cha in 0..slen-2\n count+=1 if s[i][cha]==\"A\" && s[i][cha+1]==\"B\"\n end\nend\nsa=(ed_a-ft_b).abs\ntasu=0\nif ryouhou==0\n tasu=ed_a>ft_b ? ft_b : ed_a\nelse\n if ed_a>0 || ft_b>0\n tasu=ryouhou+(ed_a>ft_b ? ft_b : ed_a)\n else\n tasu=ryouhou-1\n end\nend\n\nputs count+tasu\n", "language": "Ruby", "metadata": {"date": 1560349293, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s567638316.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s567638316", "user_id": "u030183888"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n=gets.chomp.to_i\ns=[]\nn.times do\n s.push(gets.chomp)\nend\ned_a=0\nft_b=0\nryouhou=0\ncount=0\nfor i in 0..n-1 do\n slen=s[i].length\n ft=s[i][0]\n ed=s[i][slen-1]\n if ed==\"A\" && ft==\"B\"\n ryouhou+=1\n elsif ed==\"A\"\n ed_a+=1\n elsif ft==\"B\"\n ft_b+=1\n end\n for cha in 0..slen-2\n count+=1 if s[i][cha]==\"A\" && s[i][cha+1]==\"B\"\n end\nend\nsa=(ed_a-ft_b).abs\ntasu=0\nif ryouhou==0\n tasu=ed_a>ft_b ? ft_b : ed_a\nelse\n if ed_a>0 || ft_b>0\n tasu=ryouhou+(ed_a>ft_b ? ft_b : ed_a)\n else\n tasu=ryouhou-1\n end\nend\n\nputs count+tasu\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": 539, "cpu_time_ms": 35, "memory_kb": 4220}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s863279445", "group_id": "codeNet:p03049", "input_text": "n = gets.to_i\n\nfirstB, lastA = 0, 0\ncount = 0\nduplicate = 0\n\nn.times do |i|\n tmp = gets.chomp\n firstB += 1 if tmp[0] == \"B\"\n lastA += 1 if tmp[-1] == \"A\"\n duplicate += 1 if tmp[0] == \"B\" && tmp[-1] == \"A\"\n count += tmp.scan(\"AB\").length\nend\n\n\n\ncount += [firstB, lastA].min\n\ncount -= 1 if firstB == duplicate && lastA == duplicate\nputs count", "language": "Ruby", "metadata": {"date": 1557627378, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s863279445.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s863279445", "user_id": "u452808393"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n = gets.to_i\n\nfirstB, lastA = 0, 0\ncount = 0\nduplicate = 0\n\nn.times do |i|\n tmp = gets.chomp\n firstB += 1 if tmp[0] == \"B\"\n lastA += 1 if tmp[-1] == \"A\"\n duplicate += 1 if tmp[0] == \"B\" && tmp[-1] == \"A\"\n count += tmp.scan(\"AB\").length\nend\n\n\n\ncount += [firstB, lastA].min\n\ncount -= 1 if firstB == duplicate && lastA == duplicate\nputs count", "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": 345, "cpu_time_ms": 26, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s179280039", "group_id": "codeNet:p03050", "input_text": "n=gets.to_i\na=0\n(1..n).each do |i|\n a += i if n / i == n % i\nend\np a", "language": "Ruby", "metadata": {"date": 1557757121, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03050.html", "problem_id": "p03050", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03050/input.txt", "sample_output_relpath": "derived/input_output/data/p03050/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03050/Ruby/s179280039.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s179280039", "user_id": "u098870186"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "n=gets.to_i\na=0\n(1..n).each do |i|\n a += i if n / i == n % i\nend\np a", "problem_context": "Score : 500 points\n\nProblem Statement\n\nSnuke received a positive integer N from Takahashi.\nA positive integer m is called a favorite number when the following condition is satisfied:\n\nThe quotient and remainder of N divided by m are equal, that is, \\lfloor \\frac{N}{m} \\rfloor = N \\bmod m holds.\n\nFind all favorite numbers and print the sum of those.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n10\n\nThere are two favorite numbers: 3 and 7. Print the sum of these, 10.\n\nSample Input 2\n\n1000000000000\n\nSample Output 2\n\n2499686339916\n\nWatch out for overflow.", "sample_input": "8\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03050", "source_text": "Score : 500 points\n\nProblem Statement\n\nSnuke received a positive integer N from Takahashi.\nA positive integer m is called a favorite number when the following condition is satisfied:\n\nThe quotient and remainder of N divided by m are equal, that is, \\lfloor \\frac{N}{m} \\rfloor = N \\bmod m holds.\n\nFind all favorite numbers and print the sum of those.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n10\n\nThere are two favorite numbers: 3 and 7. Print the sum of these, 10.\n\nSample Input 2\n\n1000000000000\n\nSample Output 2\n\n2499686339916\n\nWatch out for overflow.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 69, "cpu_time_ms": 2107, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s530202566", "group_id": "codeNet:p03059", "input_text": "A, B, T = gets.split.map(&:to_i)\np T / A * B", "language": "Ruby", "metadata": {"date": 1568951774, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s530202566.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s530202566", "user_id": "u655122274"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "A, B, T = gets.split.map(&:to_i)\np T / A * B", "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": 44, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s574807927", "group_id": "codeNet:p03062", "input_text": "require 'pp'\n\nn = gets.to_i\na_n = gets.chomp!.split(\" \").map(&:to_i).sort\nx = a_n.group_by {|x| x >= 0 }\n\nif x[false].length % 2 == 0\n puts a_n.inject(0) {|sum, n| sum += n.abs }\nelse\n s = a_n.inject(0) {|sum, n| sum += n.abs }\n min = 10 ** 10\n a_n.each do |a|\n if a.abs < min\n min = a.abs\n end\n end\n s -= (2 * min)\n puts s\nend\n", "language": "Ruby", "metadata": {"date": 1578896205, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03062.html", "problem_id": "p03062", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03062/input.txt", "sample_output_relpath": "derived/input_output/data/p03062/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03062/Ruby/s574807927.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s574807927", "user_id": "u754375546"}, "prompt_components": {"gold_output": "19\n", "input_to_evaluate": "require 'pp'\n\nn = gets.to_i\na_n = gets.chomp!.split(\" \").map(&:to_i).sort\nx = a_n.group_by {|x| x >= 0 }\n\nif x[false].length % 2 == 0\n puts a_n.inject(0) {|sum, n| sum += n.abs }\nelse\n s = a_n.inject(0) {|sum, n| sum += n.abs }\n min = 10 ** 10\n a_n.each do |a|\n if a.abs < min\n min = a.abs\n end\n end\n s -= (2 * min)\n puts s\nend\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "3\n-10 5 -4\n"}, "reference_outputs": ["19\n"], "source_document_id": "p03062", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 374, "cpu_time_ms": 98, "memory_kb": 11124}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s811465625", "group_id": "codeNet:p03062", "input_text": "N = gets.to_i\nA = gets.chomp.split.map(&:to_i)\n\nnatural = []\nminus = []\nA.each do |a|\n if a < 0\n minus << a\n elsif\n natural << a\n end\nend\nnatural.sort!\nminus.sort!\n\nif minus.length % 2 == 0\n puts natural.inject(:+) - minus.inject(:+)\nelse\n ans = 0\n if natural.length > 1\n natural[1..-1].each do |n|\n ans += n\n end\n end\n if minus.length > 1\n minus[0..-2].each do |m|\n ans -= m\n end\n end\n if natural[0] < -minus[-1]\n ans -= natural[0]\n ans -= minus[-1]\n else\n ans += natural[0]\n ans += minus[-1]\n end\n puts ans\nend", "language": "Ruby", "metadata": {"date": 1556419020, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03062.html", "problem_id": "p03062", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03062/input.txt", "sample_output_relpath": "derived/input_output/data/p03062/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03062/Ruby/s811465625.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s811465625", "user_id": "u762955009"}, "prompt_components": {"gold_output": "19\n", "input_to_evaluate": "N = gets.to_i\nA = gets.chomp.split.map(&:to_i)\n\nnatural = []\nminus = []\nA.each do |a|\n if a < 0\n minus << a\n elsif\n natural << a\n end\nend\nnatural.sort!\nminus.sort!\n\nif minus.length % 2 == 0\n puts natural.inject(:+) - minus.inject(:+)\nelse\n ans = 0\n if natural.length > 1\n natural[1..-1].each do |n|\n ans += n\n end\n end\n if minus.length > 1\n minus[0..-2].each do |m|\n ans -= m\n end\n end\n if natural[0] < -minus[-1]\n ans -= natural[0]\n ans -= minus[-1]\n else\n ans += natural[0]\n ans += minus[-1]\n end\n puts ans\nend", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "3\n-10 5 -4\n"}, "reference_outputs": ["19\n"], "source_document_id": "p03062", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 565, "cpu_time_ms": 79, "memory_kb": 13116}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s492662528", "group_id": "codeNet:p03062", "input_text": "n = gets.to_i\na = gets.split.map(&:to_i)\n\nabs = a.map(&:abs)\n\nputs abs.inject(:+) -\nif a.select {|i| i < 0 }.count.odd?\n abs.min * 2\nelse\n 0\nend\n", "language": "Ruby", "metadata": {"date": 1556416562, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03062.html", "problem_id": "p03062", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03062/input.txt", "sample_output_relpath": "derived/input_output/data/p03062/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03062/Ruby/s492662528.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s492662528", "user_id": "u145602296"}, "prompt_components": {"gold_output": "19\n", "input_to_evaluate": "n = gets.to_i\na = gets.split.map(&:to_i)\n\nabs = a.map(&:abs)\n\nputs abs.inject(:+) -\nif a.select {|i| i < 0 }.count.odd?\n abs.min * 2\nelse\n 0\nend\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "3\n-10 5 -4\n"}, "reference_outputs": ["19\n"], "source_document_id": "p03062", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 147, "cpu_time_ms": 72, "memory_kb": 10116}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s997128493", "group_id": "codeNet:p03062", "input_text": "n = gets().to_i\nan = gets().split(' ').map(&:to_i)\n\nsum = 0\nmin = 10 ** 9\nminus = 0\n\nan.each {|ai|\n\tsum += ai.abs\n\tmin = ai.abs if min > ai.abs\n\tminus += 1 if ai < 0\n}\n\nputs ((minus & 1) == 0 ? sum : sum - min * 2)\n", "language": "Ruby", "metadata": {"date": 1556414503, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03062.html", "problem_id": "p03062", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03062/input.txt", "sample_output_relpath": "derived/input_output/data/p03062/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03062/Ruby/s997128493.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s997128493", "user_id": "u953933657"}, "prompt_components": {"gold_output": "19\n", "input_to_evaluate": "n = gets().to_i\nan = gets().split(' ').map(&:to_i)\n\nsum = 0\nmin = 10 ** 9\nminus = 0\n\nan.each {|ai|\n\tsum += ai.abs\n\tmin = ai.abs if min > ai.abs\n\tminus += 1 if ai < 0\n}\n\nputs ((minus & 1) == 0 ? sum : sum - min * 2)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "3\n-10 5 -4\n"}, "reference_outputs": ["19\n"], "source_document_id": "p03062", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 215, "cpu_time_ms": 63, "memory_kb": 8580}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s801740066", "group_id": "codeNet:p03063", "input_text": "N=gets.to_i\nS=gets\nw=0\nc=S.count \".\"\np ((0...N).map{|i|i+1+c-2*(S[i]>\"#\"&&w+=1)}<\"#\"&&w+=1)}<= b then\n sum += a\n a -= 1\n else\n sum += b\n b -= 1\n end\nend\n\np sum", "language": "Ruby", "metadata": {"date": 1557435093, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s604139656.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s604139656", "user_id": "u231458241"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "a, b = STDIN.gets.chomp.split(\" \").map{ |a| a.to_i }\n\nsum = 0\n\nfor i in 0..1 do if a >= b then\n sum += a\n a -= 1\n else\n sum += b\n b -= 1\n end\nend\n\np sum", "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": 223, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s802156827", "group_id": "codeNet:p03071", "input_text": "A, B = gets.split.map(&:to_i)\n\nsum = 0\n2.times do\n\tif A > B\n\t\tsum += A\n\t\tA -= 1\n\telse\n\t\tsum += B\n\t\tB -= 1\n\tend\nend\n\nputs sum\n", "language": "Ruby", "metadata": {"date": 1555512526, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s802156827.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s802156827", "user_id": "u298659531"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "A, B = gets.split.map(&:to_i)\n\nsum = 0\n2.times do\n\tif A > B\n\t\tsum += A\n\t\tA -= 1\n\telse\n\t\tsum += B\n\t\tB -= 1\n\tend\nend\n\nputs sum\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": 125, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s221695924", "group_id": "codeNet:p03071", "input_text": "a, b = gets.split.map(&:to_i)\n\nans = 0\n2.times do\n if a > b\n ans += a\n a -= 1\n else\n ans += b\n b -= 1\n end\nend\n\nputs ans\n", "language": "Ruby", "metadata": {"date": 1555182168, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s221695924.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s221695924", "user_id": "u237620737"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "a, b = gets.split.map(&:to_i)\n\nans = 0\n2.times do\n if a > b\n ans += a\n a -= 1\n else\n ans += b\n b -= 1\n end\nend\n\nputs ans\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": 136, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s720900232", "group_id": "codeNet:p03073", "input_text": "s = gets.chomp\n#s_i = s.to_i\nn = s.length\nh = 1\nfor i in 1..(n-1)\n if i%2 == 0\n h += 10**i\n end\nend\nh_s = h.to_s\nif h_s.length != n\n h_s = \"0\" + h_s\nend\nkazu = 0\nfor i in 0..(n-1)\n kazu += 1 if h_s[i] != s[i]\nend\nif n-kazu > kazu\n puts kazu\nelse\n puts n-kazu\nend\n", "language": "Ruby", "metadata": {"date": 1555186105, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s720900232.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s720900232", "user_id": "u562331708"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "s = gets.chomp\n#s_i = s.to_i\nn = s.length\nh = 1\nfor i in 1..(n-1)\n if i%2 == 0\n h += 10**i\n end\nend\nh_s = h.to_s\nif h_s.length != n\n h_s = \"0\" + h_s\nend\nkazu = 0\nfor i in 0..(n-1)\n kazu += 1 if h_s[i] != s[i]\nend\nif n-kazu > kazu\n puts kazu\nelse\n puts n-kazu\nend\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": 272, "cpu_time_ms": 2109, "memory_kb": 19736}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s797398991", "group_id": "codeNet:p03074", "input_text": "n,k = gets.split(\" \").map(&:to_i)\ns = gets.chomp\n\na = s.split('0').map(&:length)\nb = s.split('1').map(&:length)\na.delete(0)\nb.delete(0)\n\nc = []\nif b.empty?\n c = a\nelsif a.size == b.size\n (a.size-k+1).times do |i|\n t = 0\n (k+1).times {|ii| t+= a[i+ii]}\n c << t\n end\n\n (a.size-k+1).times do |j|\n t = 0\n (k+1).times {|jj| t+= b[j+jj]}\n c[j] = c[j] + t\n end\nelsif a.size > b.size\n (a.size-k).times do |i|\n t = 0\n (k+1).times {|ii| t+= a[i+ii]}\n c << t\n end\n\n (a.size-k).times do |j|\n t = 0\n k.times {|jj| t+= b[j+jj]}\n c[j] = c[j] + t\n end\nelse\n (b.size-k+1).times do |i|\n t = 0\n k.times do |ii|\n if a.size == 1\n t+= a[0]\n else\n t+= a[i+ii]\n end\n end\n c << t\n end\n (b.size-k+1).times do |j|\n t = 0\n k.times {|jj| t+= b[j+jj]}\n c[j] = c[j] + t\n end\nend\n\nputs c.max", "language": "Ruby", "metadata": {"date": 1555186804, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s797398991.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s797398991", "user_id": "u351482714"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "n,k = gets.split(\" \").map(&:to_i)\ns = gets.chomp\n\na = s.split('0').map(&:length)\nb = s.split('1').map(&:length)\na.delete(0)\nb.delete(0)\n\nc = []\nif b.empty?\n c = a\nelsif a.size == b.size\n (a.size-k+1).times do |i|\n t = 0\n (k+1).times {|ii| t+= a[i+ii]}\n c << t\n end\n\n (a.size-k+1).times do |j|\n t = 0\n (k+1).times {|jj| t+= b[j+jj]}\n c[j] = c[j] + t\n end\nelsif a.size > b.size\n (a.size-k).times do |i|\n t = 0\n (k+1).times {|ii| t+= a[i+ii]}\n c << t\n end\n\n (a.size-k).times do |j|\n t = 0\n k.times {|jj| t+= b[j+jj]}\n c[j] = c[j] + t\n end\nelse\n (b.size-k+1).times do |i|\n t = 0\n k.times do |ii|\n if a.size == 1\n t+= a[0]\n else\n t+= a[i+ii]\n end\n end\n c << t\n end\n (b.size-k+1).times do |j|\n t = 0\n k.times {|jj| t+= b[j+jj]}\n c[j] = c[j] + t\n end\nend\n\nputs c.max", "problem_context": "Score : 400 points\n\nProblem Statement\n\nN people are arranged in a row from left to right.\n\nYou are given a string S of length N consisting of 0 and 1, and a positive integer K.\n\nThe i-th person from the left is standing on feet if the i-th character of S is 0, and standing on hands if that character is 1.\n\nYou will give the following direction at most K times (possibly zero):\n\nDirection: Choose integers l and r satisfying 1 \\leq l \\leq r \\leq N, and flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1, ..., r, the i-th person from the left now stands on hands if he/she was standing on feet, and stands on feet if he/she was standing on hands.\n\nFind the maximum possible number of consecutive people standing on hands after at most K directions.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^5.\n\nK is an integer satisfying 1 \\leq K \\leq 10^5.\n\nThe length of the string S is N.\n\nEach character of the string S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the maximum possible number of consecutive people standing on hands after at most K directions.\n\nSample Input 1\n\n5 1\n00010\n\nSample Output 1\n\n4\n\nWe can have four consecutive people standing on hands, which is the maximum result, by giving the following direction:\n\nGive the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\nSample Input 2\n\n14 2\n11101010110011\n\nSample Output 2\n\n8\n\nSample Input 3\n\n1 1\n1\n\nSample Output 3\n\n1\n\nNo directions are necessary.", "sample_input": "5 1\n00010\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03074", "source_text": "Score : 400 points\n\nProblem Statement\n\nN people are arranged in a row from left to right.\n\nYou are given a string S of length N consisting of 0 and 1, and a positive integer K.\n\nThe i-th person from the left is standing on feet if the i-th character of S is 0, and standing on hands if that character is 1.\n\nYou will give the following direction at most K times (possibly zero):\n\nDirection: Choose integers l and r satisfying 1 \\leq l \\leq r \\leq N, and flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1, ..., r, the i-th person from the left now stands on hands if he/she was standing on feet, and stands on feet if he/she was standing on hands.\n\nFind the maximum possible number of consecutive people standing on hands after at most K directions.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^5.\n\nK is an integer satisfying 1 \\leq K \\leq 10^5.\n\nThe length of the string S is N.\n\nEach character of the string S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the maximum possible number of consecutive people standing on hands after at most K directions.\n\nSample Input 1\n\n5 1\n00010\n\nSample Output 1\n\n4\n\nWe can have four consecutive people standing on hands, which is the maximum result, by giving the following direction:\n\nGive the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\nSample Input 2\n\n14 2\n11101010110011\n\nSample Output 2\n\n8\n\nSample Input 3\n\n1 1\n1\n\nSample Output 3\n\n1\n\nNo directions are necessary.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 858, "cpu_time_ms": 2108, "memory_kb": 8188}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s361576722", "group_id": "codeNet:p03075", "input_text": "ary=$stdin.read.lines.map(&:to_i)\n5.times do |i|\n 5.times do |j|\n if (ary[i]-ary[j])>ary[5]\n puts \":(\"\n exit\n end\n end\nend\nputs \"Yay!\"", "language": "Ruby", "metadata": {"date": 1558340859, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03075.html", "problem_id": "p03075", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03075/input.txt", "sample_output_relpath": "derived/input_output/data/p03075/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03075/Ruby/s361576722.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s361576722", "user_id": "u622469330"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "ary=$stdin.read.lines.map(&:to_i)\n5.times do |i|\n 5.times do |j|\n if (ary[i]-ary[j])>ary[5]\n puts \":(\"\n exit\n end\n end\nend\nputs \"Yay!\"", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.\n\nTwo antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.\n\nDetermine if there exists a pair of antennas that cannot communicate directly.\n\nHere, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.\n\nConstraints\n\na, b, c, d, e and k are integers between 0 and 123 (inclusive).\n\na < b < c < d < e\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\nd\ne\nk\n\nOutput\n\nPrint :( if there exists a pair of antennas that cannot communicate directly, and print Yay! if there is no such pair.\n\nSample Input 1\n\n1\n2\n4\n8\n9\n15\n\nSample Output 1\n\nYay!\n\nIn this case, there is no pair of antennas that cannot communicate directly, because:\n\nthe distance between A and B is 2 - 1 = 1\n\nthe distance between A and C is 4 - 1 = 3\n\nthe distance between A and D is 8 - 1 = 7\n\nthe distance between A and E is 9 - 1 = 8\n\nthe distance between B and C is 4 - 2 = 2\n\nthe distance between B and D is 8 - 2 = 6\n\nthe distance between B and E is 9 - 2 = 7\n\nthe distance between C and D is 8 - 4 = 4\n\nthe distance between C and E is 9 - 4 = 5\n\nthe distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is Yay!.\n\nSample Input 2\n\n15\n18\n26\n35\n36\n18\n\nSample Output 2\n\n:(\n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and exceeds 18, so they cannot communicate directly.\nThus, the correct output is :(.", "sample_input": "1\n2\n4\n8\n9\n15\n"}, "reference_outputs": ["Yay!\n"], "source_document_id": "p03075", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.\n\nTwo antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.\n\nDetermine if there exists a pair of antennas that cannot communicate directly.\n\nHere, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.\n\nConstraints\n\na, b, c, d, e and k are integers between 0 and 123 (inclusive).\n\na < b < c < d < e\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\nd\ne\nk\n\nOutput\n\nPrint :( if there exists a pair of antennas that cannot communicate directly, and print Yay! if there is no such pair.\n\nSample Input 1\n\n1\n2\n4\n8\n9\n15\n\nSample Output 1\n\nYay!\n\nIn this case, there is no pair of antennas that cannot communicate directly, because:\n\nthe distance between A and B is 2 - 1 = 1\n\nthe distance between A and C is 4 - 1 = 3\n\nthe distance between A and D is 8 - 1 = 7\n\nthe distance between A and E is 9 - 1 = 8\n\nthe distance between B and C is 4 - 2 = 2\n\nthe distance between B and D is 8 - 2 = 6\n\nthe distance between B and E is 9 - 2 = 7\n\nthe distance between C and D is 8 - 4 = 4\n\nthe distance between C and E is 9 - 4 = 5\n\nthe distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is Yay!.\n\nSample Input 2\n\n15\n18\n26\n35\n36\n18\n\nSample Output 2\n\n:(\n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and exceeds 18, so they cannot communicate directly.\nThus, the correct output is :(.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 152, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s743535494", "group_id": "codeNet:p03075", "input_text": "a = gets.to_i\nb = gets.to_i\nc = gets.to_i\nd = gets.to_i\ne = gets.to_i\nk = gets.to_i\nif [e - d, d - c, c - b, b - a].max <= k\n puts \"Yay!\"\nelse\n puts \":(\"\nend", "language": "Ruby", "metadata": {"date": 1556118701, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03075.html", "problem_id": "p03075", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03075/input.txt", "sample_output_relpath": "derived/input_output/data/p03075/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03075/Ruby/s743535494.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s743535494", "user_id": "u653737129"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "a = gets.to_i\nb = gets.to_i\nc = gets.to_i\nd = gets.to_i\ne = gets.to_i\nk = gets.to_i\nif [e - d, d - c, c - b, b - a].max <= k\n puts \"Yay!\"\nelse\n puts \":(\"\nend", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.\n\nTwo antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.\n\nDetermine if there exists a pair of antennas that cannot communicate directly.\n\nHere, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.\n\nConstraints\n\na, b, c, d, e and k are integers between 0 and 123 (inclusive).\n\na < b < c < d < e\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\nd\ne\nk\n\nOutput\n\nPrint :( if there exists a pair of antennas that cannot communicate directly, and print Yay! if there is no such pair.\n\nSample Input 1\n\n1\n2\n4\n8\n9\n15\n\nSample Output 1\n\nYay!\n\nIn this case, there is no pair of antennas that cannot communicate directly, because:\n\nthe distance between A and B is 2 - 1 = 1\n\nthe distance between A and C is 4 - 1 = 3\n\nthe distance between A and D is 8 - 1 = 7\n\nthe distance between A and E is 9 - 1 = 8\n\nthe distance between B and C is 4 - 2 = 2\n\nthe distance between B and D is 8 - 2 = 6\n\nthe distance between B and E is 9 - 2 = 7\n\nthe distance between C and D is 8 - 4 = 4\n\nthe distance between C and E is 9 - 4 = 5\n\nthe distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is Yay!.\n\nSample Input 2\n\n15\n18\n26\n35\n36\n18\n\nSample Output 2\n\n:(\n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and exceeds 18, so they cannot communicate directly.\nThus, the correct output is :(.", "sample_input": "1\n2\n4\n8\n9\n15\n"}, "reference_outputs": ["Yay!\n"], "source_document_id": "p03075", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.\n\nTwo antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.\n\nDetermine if there exists a pair of antennas that cannot communicate directly.\n\nHere, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.\n\nConstraints\n\na, b, c, d, e and k are integers between 0 and 123 (inclusive).\n\na < b < c < d < e\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\nd\ne\nk\n\nOutput\n\nPrint :( if there exists a pair of antennas that cannot communicate directly, and print Yay! if there is no such pair.\n\nSample Input 1\n\n1\n2\n4\n8\n9\n15\n\nSample Output 1\n\nYay!\n\nIn this case, there is no pair of antennas that cannot communicate directly, because:\n\nthe distance between A and B is 2 - 1 = 1\n\nthe distance between A and C is 4 - 1 = 3\n\nthe distance between A and D is 8 - 1 = 7\n\nthe distance between A and E is 9 - 1 = 8\n\nthe distance between B and C is 4 - 2 = 2\n\nthe distance between B and D is 8 - 2 = 6\n\nthe distance between B and E is 9 - 2 = 7\n\nthe distance between C and D is 8 - 4 = 4\n\nthe distance between C and E is 9 - 4 = 5\n\nthe distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is Yay!.\n\nSample Input 2\n\n15\n18\n26\n35\n36\n18\n\nSample Output 2\n\n:(\n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and exceeds 18, so they cannot communicate directly.\nThus, the correct output is :(.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 159, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s597207209", "group_id": "codeNet:p03075", "input_text": "n = gets.chop.to_i\na = []\nn.times { a << gets.to_i }\n\ntarget = a[0...a.size - 1]\nk = a.last\noutput = ''\n \na.each_with_index do |num, i|\n break if i == target.size\n output = ':(' if (target[i + 1] - num).abs > k\nend\n \noutput = 'Yay!' if output.empty?\nputs output\nnums = gets.split(\"\\n\").to_i\ntarget = n[0...n.size - 1]\nk = n.last\noutput = ''\n\nnums.each_with_index do |n, i|\n break if i == target.size\n output = ':(' if (target[i + 1] - n).abs > k\nend\n\noutput = 'Yay!' if output.empty?\nputs output\n", "language": "Ruby", "metadata": {"date": 1554931015, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03075.html", "problem_id": "p03075", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03075/input.txt", "sample_output_relpath": "derived/input_output/data/p03075/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03075/Ruby/s597207209.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s597207209", "user_id": "u349129336"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "n = gets.chop.to_i\na = []\nn.times { a << gets.to_i }\n\ntarget = a[0...a.size - 1]\nk = a.last\noutput = ''\n \na.each_with_index do |num, i|\n break if i == target.size\n output = ':(' if (target[i + 1] - num).abs > k\nend\n \noutput = 'Yay!' if output.empty?\nputs output\nnums = gets.split(\"\\n\").to_i\ntarget = n[0...n.size - 1]\nk = n.last\noutput = ''\n\nnums.each_with_index do |n, i|\n break if i == target.size\n output = ':(' if (target[i + 1] - n).abs > k\nend\n\noutput = 'Yay!' if output.empty?\nputs output\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.\n\nTwo antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.\n\nDetermine if there exists a pair of antennas that cannot communicate directly.\n\nHere, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.\n\nConstraints\n\na, b, c, d, e and k are integers between 0 and 123 (inclusive).\n\na < b < c < d < e\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\nd\ne\nk\n\nOutput\n\nPrint :( if there exists a pair of antennas that cannot communicate directly, and print Yay! if there is no such pair.\n\nSample Input 1\n\n1\n2\n4\n8\n9\n15\n\nSample Output 1\n\nYay!\n\nIn this case, there is no pair of antennas that cannot communicate directly, because:\n\nthe distance between A and B is 2 - 1 = 1\n\nthe distance between A and C is 4 - 1 = 3\n\nthe distance between A and D is 8 - 1 = 7\n\nthe distance between A and E is 9 - 1 = 8\n\nthe distance between B and C is 4 - 2 = 2\n\nthe distance between B and D is 8 - 2 = 6\n\nthe distance between B and E is 9 - 2 = 7\n\nthe distance between C and D is 8 - 4 = 4\n\nthe distance between C and E is 9 - 4 = 5\n\nthe distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is Yay!.\n\nSample Input 2\n\n15\n18\n26\n35\n36\n18\n\nSample Output 2\n\n:(\n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and exceeds 18, so they cannot communicate directly.\nThus, the correct output is :(.", "sample_input": "1\n2\n4\n8\n9\n15\n"}, "reference_outputs": ["Yay!\n"], "source_document_id": "p03075", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.\n\nTwo antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.\n\nDetermine if there exists a pair of antennas that cannot communicate directly.\n\nHere, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.\n\nConstraints\n\na, b, c, d, e and k are integers between 0 and 123 (inclusive).\n\na < b < c < d < e\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\nd\ne\nk\n\nOutput\n\nPrint :( if there exists a pair of antennas that cannot communicate directly, and print Yay! if there is no such pair.\n\nSample Input 1\n\n1\n2\n4\n8\n9\n15\n\nSample Output 1\n\nYay!\n\nIn this case, there is no pair of antennas that cannot communicate directly, because:\n\nthe distance between A and B is 2 - 1 = 1\n\nthe distance between A and C is 4 - 1 = 3\n\nthe distance between A and D is 8 - 1 = 7\n\nthe distance between A and E is 9 - 1 = 8\n\nthe distance between B and C is 4 - 2 = 2\n\nthe distance between B and D is 8 - 2 = 6\n\nthe distance between B and E is 9 - 2 = 7\n\nthe distance between C and D is 8 - 4 = 4\n\nthe distance between C and E is 9 - 4 = 5\n\nthe distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is Yay!.\n\nSample Input 2\n\n15\n18\n26\n35\n36\n18\n\nSample Output 2\n\n:(\n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and exceeds 18, so they cannot communicate directly.\nThus, the correct output is :(.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 500, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s640047967", "group_id": "codeNet:p03076", "input_text": "input = readlines\ninput.each{|num|\n num = num.chomp!\n}\n\ni = 0\nlast_min = 10\nlast = 0\n\nwhile i < input.length\n digit = input[i].to_i % 10\n if digit != 0\n if last_min > digit\n last_min = digit\n last = i\n end\n end\n i = i + 1\nend\n\ni = 0\nall = 0\nwhile i < input.length\n if i != last\n n = (input[i].to_f / 10).ceil * 10\n all = all + n\n end\n i = i + 1\nend\n\nall = all + input[last].to_i\n\nprint all", "language": "Ruby", "metadata": {"date": 1555263848, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03076.html", "problem_id": "p03076", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03076/input.txt", "sample_output_relpath": "derived/input_output/data/p03076/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03076/Ruby/s640047967.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s640047967", "user_id": "u387233198"}, "prompt_components": {"gold_output": "215\n", "input_to_evaluate": "input = readlines\ninput.each{|num|\n num = num.chomp!\n}\n\ni = 0\nlast_min = 10\nlast = 0\n\nwhile i < input.length\n digit = input[i].to_i % 10\n if digit != 0\n if last_min > digit\n last_min = digit\n last = i\n end\n end\n i = i + 1\nend\n\ni = 0\nall = 0\nwhile i < input.length\n if i != last\n n = (input[i].to_f / 10).ceil * 10\n all = all + n\n end\n i = i + 1\nend\n\nall = all + input[last].to_i\n\nprint all", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThe restaurant AtCoder serves the following five dishes:\n\nABC Don (rice bowl): takes A minutes to serve.\n\nARC Curry: takes B minutes to serve.\n\nAGC Pasta: takes C minutes to serve.\n\nAPC Ramen: takes D minutes to serve.\n\nATC Hanbagu (hamburger patty): takes E minutes to serve.\n\nHere, the time to serve a dish is the time between when an order is placed and when the dish is delivered.\n\nThis restaurant has the following rules on orders:\n\nAn order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).\n\nOnly one dish can be ordered at a time.\n\nNo new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.\n\nE869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.\n\nHere, he can order the dishes in any order he likes, and he can place an order already at time 0.\n\nConstraints\n\nA, B, C, D and E are integers between 1 and 123 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the earliest possible time for the last dish to be delivered, as an integer.\n\nSample Input 1\n\n29\n20\n7\n35\n120\n\nSample Output 1\n\n215\n\nIf we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:\n\nOrder ABC Don at time 0, which will be delivered at time 29.\n\nOrder ARC Curry at time 30, which will be delivered at time 50.\n\nOrder AGC Pasta at time 50, which will be delivered at time 57.\n\nOrder ATC Hanbagu at time 60, which will be delivered at time 180.\n\nOrder APC Ramen at time 180, which will be delivered at time 215.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 2\n\n101\n86\n119\n108\n57\n\nSample Output 2\n\n481\n\nIf we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:\n\nOrder AGC Pasta at time 0, which will be delivered at time 119.\n\nOrder ARC Curry at time 120, which will be delivered at time 206.\n\nOrder ATC Hanbagu at time 210, which will be delivered at time 267.\n\nOrder APC Ramen at time 270, which will be delivered at time 378.\n\nOrder ABC Don at time 380, which will be delivered at time 481.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 3\n\n123\n123\n123\n123\n123\n\nSample Output 3\n\n643\n\nThis is the largest valid case.", "sample_input": "29\n20\n7\n35\n120\n"}, "reference_outputs": ["215\n"], "source_document_id": "p03076", "source_text": "Score: 200 points\n\nProblem Statement\n\nThe restaurant AtCoder serves the following five dishes:\n\nABC Don (rice bowl): takes A minutes to serve.\n\nARC Curry: takes B minutes to serve.\n\nAGC Pasta: takes C minutes to serve.\n\nAPC Ramen: takes D minutes to serve.\n\nATC Hanbagu (hamburger patty): takes E minutes to serve.\n\nHere, the time to serve a dish is the time between when an order is placed and when the dish is delivered.\n\nThis restaurant has the following rules on orders:\n\nAn order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).\n\nOnly one dish can be ordered at a time.\n\nNo new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.\n\nE869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.\n\nHere, he can order the dishes in any order he likes, and he can place an order already at time 0.\n\nConstraints\n\nA, B, C, D and E are integers between 1 and 123 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the earliest possible time for the last dish to be delivered, as an integer.\n\nSample Input 1\n\n29\n20\n7\n35\n120\n\nSample Output 1\n\n215\n\nIf we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:\n\nOrder ABC Don at time 0, which will be delivered at time 29.\n\nOrder ARC Curry at time 30, which will be delivered at time 50.\n\nOrder AGC Pasta at time 50, which will be delivered at time 57.\n\nOrder ATC Hanbagu at time 60, which will be delivered at time 180.\n\nOrder APC Ramen at time 180, which will be delivered at time 215.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 2\n\n101\n86\n119\n108\n57\n\nSample Output 2\n\n481\n\nIf we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:\n\nOrder AGC Pasta at time 0, which will be delivered at time 119.\n\nOrder ARC Curry at time 120, which will be delivered at time 206.\n\nOrder ATC Hanbagu at time 210, which will be delivered at time 267.\n\nOrder APC Ramen at time 270, which will be delivered at time 378.\n\nOrder ABC Don at time 380, which will be delivered at time 481.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 3\n\n123\n123\n123\n123\n123\n\nSample Output 3\n\n643\n\nThis is the largest valid case.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 463, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s720981598", "group_id": "codeNet:p03076", "input_text": "a = 5.times.map{gets.to_i}\nans = 0\n5.times do |i|\n ans += (a[i]+9)/10*10\nend\nmn = 10\n5.times do |i|\n mn = a[i]%10 if a[i]%10 > 0 && a[i]%10 < mn\nend\nans -= 10-mn\nputs ans", "language": "Ruby", "metadata": {"date": 1554791217, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03076.html", "problem_id": "p03076", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03076/input.txt", "sample_output_relpath": "derived/input_output/data/p03076/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03076/Ruby/s720981598.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s720981598", "user_id": "u506255180"}, "prompt_components": {"gold_output": "215\n", "input_to_evaluate": "a = 5.times.map{gets.to_i}\nans = 0\n5.times do |i|\n ans += (a[i]+9)/10*10\nend\nmn = 10\n5.times do |i|\n mn = a[i]%10 if a[i]%10 > 0 && a[i]%10 < mn\nend\nans -= 10-mn\nputs ans", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThe restaurant AtCoder serves the following five dishes:\n\nABC Don (rice bowl): takes A minutes to serve.\n\nARC Curry: takes B minutes to serve.\n\nAGC Pasta: takes C minutes to serve.\n\nAPC Ramen: takes D minutes to serve.\n\nATC Hanbagu (hamburger patty): takes E minutes to serve.\n\nHere, the time to serve a dish is the time between when an order is placed and when the dish is delivered.\n\nThis restaurant has the following rules on orders:\n\nAn order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).\n\nOnly one dish can be ordered at a time.\n\nNo new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.\n\nE869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.\n\nHere, he can order the dishes in any order he likes, and he can place an order already at time 0.\n\nConstraints\n\nA, B, C, D and E are integers between 1 and 123 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the earliest possible time for the last dish to be delivered, as an integer.\n\nSample Input 1\n\n29\n20\n7\n35\n120\n\nSample Output 1\n\n215\n\nIf we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:\n\nOrder ABC Don at time 0, which will be delivered at time 29.\n\nOrder ARC Curry at time 30, which will be delivered at time 50.\n\nOrder AGC Pasta at time 50, which will be delivered at time 57.\n\nOrder ATC Hanbagu at time 60, which will be delivered at time 180.\n\nOrder APC Ramen at time 180, which will be delivered at time 215.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 2\n\n101\n86\n119\n108\n57\n\nSample Output 2\n\n481\n\nIf we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:\n\nOrder AGC Pasta at time 0, which will be delivered at time 119.\n\nOrder ARC Curry at time 120, which will be delivered at time 206.\n\nOrder ATC Hanbagu at time 210, which will be delivered at time 267.\n\nOrder APC Ramen at time 270, which will be delivered at time 378.\n\nOrder ABC Don at time 380, which will be delivered at time 481.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 3\n\n123\n123\n123\n123\n123\n\nSample Output 3\n\n643\n\nThis is the largest valid case.", "sample_input": "29\n20\n7\n35\n120\n"}, "reference_outputs": ["215\n"], "source_document_id": "p03076", "source_text": "Score: 200 points\n\nProblem Statement\n\nThe restaurant AtCoder serves the following five dishes:\n\nABC Don (rice bowl): takes A minutes to serve.\n\nARC Curry: takes B minutes to serve.\n\nAGC Pasta: takes C minutes to serve.\n\nAPC Ramen: takes D minutes to serve.\n\nATC Hanbagu (hamburger patty): takes E minutes to serve.\n\nHere, the time to serve a dish is the time between when an order is placed and when the dish is delivered.\n\nThis restaurant has the following rules on orders:\n\nAn order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).\n\nOnly one dish can be ordered at a time.\n\nNo new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.\n\nE869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.\n\nHere, he can order the dishes in any order he likes, and he can place an order already at time 0.\n\nConstraints\n\nA, B, C, D and E are integers between 1 and 123 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the earliest possible time for the last dish to be delivered, as an integer.\n\nSample Input 1\n\n29\n20\n7\n35\n120\n\nSample Output 1\n\n215\n\nIf we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:\n\nOrder ABC Don at time 0, which will be delivered at time 29.\n\nOrder ARC Curry at time 30, which will be delivered at time 50.\n\nOrder AGC Pasta at time 50, which will be delivered at time 57.\n\nOrder ATC Hanbagu at time 60, which will be delivered at time 180.\n\nOrder APC Ramen at time 180, which will be delivered at time 215.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 2\n\n101\n86\n119\n108\n57\n\nSample Output 2\n\n481\n\nIf we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:\n\nOrder AGC Pasta at time 0, which will be delivered at time 119.\n\nOrder ARC Curry at time 120, which will be delivered at time 206.\n\nOrder ATC Hanbagu at time 210, which will be delivered at time 267.\n\nOrder APC Ramen at time 270, which will be delivered at time 378.\n\nOrder ABC Don at time 380, which will be delivered at time 481.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 3\n\n123\n123\n123\n123\n123\n\nSample Output 3\n\n643\n\nThis is the largest valid case.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 176, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s459905659", "group_id": "codeNet:p03076", "input_text": "array=5.times.map { gets.to_i }\nsum=643\nans=0\narray.each do |a|\n array.each do |b|\n ans+=b\n ans+=10-b%10 if b%10!=0\n end\n ans = ans-(10-a%10) if a%10!=0\n sum = ans if ans < sum\nend\n\np sum\n", "language": "Ruby", "metadata": {"date": 1554581313, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03076.html", "problem_id": "p03076", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03076/input.txt", "sample_output_relpath": "derived/input_output/data/p03076/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03076/Ruby/s459905659.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s459905659", "user_id": "u993494045"}, "prompt_components": {"gold_output": "215\n", "input_to_evaluate": "array=5.times.map { gets.to_i }\nsum=643\nans=0\narray.each do |a|\n array.each do |b|\n ans+=b\n ans+=10-b%10 if b%10!=0\n end\n ans = ans-(10-a%10) if a%10!=0\n sum = ans if ans < sum\nend\n\np sum\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThe restaurant AtCoder serves the following five dishes:\n\nABC Don (rice bowl): takes A minutes to serve.\n\nARC Curry: takes B minutes to serve.\n\nAGC Pasta: takes C minutes to serve.\n\nAPC Ramen: takes D minutes to serve.\n\nATC Hanbagu (hamburger patty): takes E minutes to serve.\n\nHere, the time to serve a dish is the time between when an order is placed and when the dish is delivered.\n\nThis restaurant has the following rules on orders:\n\nAn order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).\n\nOnly one dish can be ordered at a time.\n\nNo new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.\n\nE869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.\n\nHere, he can order the dishes in any order he likes, and he can place an order already at time 0.\n\nConstraints\n\nA, B, C, D and E are integers between 1 and 123 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the earliest possible time for the last dish to be delivered, as an integer.\n\nSample Input 1\n\n29\n20\n7\n35\n120\n\nSample Output 1\n\n215\n\nIf we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:\n\nOrder ABC Don at time 0, which will be delivered at time 29.\n\nOrder ARC Curry at time 30, which will be delivered at time 50.\n\nOrder AGC Pasta at time 50, which will be delivered at time 57.\n\nOrder ATC Hanbagu at time 60, which will be delivered at time 180.\n\nOrder APC Ramen at time 180, which will be delivered at time 215.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 2\n\n101\n86\n119\n108\n57\n\nSample Output 2\n\n481\n\nIf we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:\n\nOrder AGC Pasta at time 0, which will be delivered at time 119.\n\nOrder ARC Curry at time 120, which will be delivered at time 206.\n\nOrder ATC Hanbagu at time 210, which will be delivered at time 267.\n\nOrder APC Ramen at time 270, which will be delivered at time 378.\n\nOrder ABC Don at time 380, which will be delivered at time 481.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 3\n\n123\n123\n123\n123\n123\n\nSample Output 3\n\n643\n\nThis is the largest valid case.", "sample_input": "29\n20\n7\n35\n120\n"}, "reference_outputs": ["215\n"], "source_document_id": "p03076", "source_text": "Score: 200 points\n\nProblem Statement\n\nThe restaurant AtCoder serves the following five dishes:\n\nABC Don (rice bowl): takes A minutes to serve.\n\nARC Curry: takes B minutes to serve.\n\nAGC Pasta: takes C minutes to serve.\n\nAPC Ramen: takes D minutes to serve.\n\nATC Hanbagu (hamburger patty): takes E minutes to serve.\n\nHere, the time to serve a dish is the time between when an order is placed and when the dish is delivered.\n\nThis restaurant has the following rules on orders:\n\nAn order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).\n\nOnly one dish can be ordered at a time.\n\nNo new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.\n\nE869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.\n\nHere, he can order the dishes in any order he likes, and he can place an order already at time 0.\n\nConstraints\n\nA, B, C, D and E are integers between 1 and 123 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the earliest possible time for the last dish to be delivered, as an integer.\n\nSample Input 1\n\n29\n20\n7\n35\n120\n\nSample Output 1\n\n215\n\nIf we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:\n\nOrder ABC Don at time 0, which will be delivered at time 29.\n\nOrder ARC Curry at time 30, which will be delivered at time 50.\n\nOrder AGC Pasta at time 50, which will be delivered at time 57.\n\nOrder ATC Hanbagu at time 60, which will be delivered at time 180.\n\nOrder APC Ramen at time 180, which will be delivered at time 215.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 2\n\n101\n86\n119\n108\n57\n\nSample Output 2\n\n481\n\nIf we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:\n\nOrder AGC Pasta at time 0, which will be delivered at time 119.\n\nOrder ARC Curry at time 120, which will be delivered at time 206.\n\nOrder ATC Hanbagu at time 210, which will be delivered at time 267.\n\nOrder APC Ramen at time 270, which will be delivered at time 378.\n\nOrder ABC Don at time 380, which will be delivered at time 481.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 3\n\n123\n123\n123\n123\n123\n\nSample Output 3\n\n643\n\nThis is the largest valid case.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 198, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s629256139", "group_id": "codeNet:p03077", "input_text": "ts = 6.times.map { gets.to_f }\nn = ts.shift\n\nts = [(10**15).to_f, ts].flatten\nm = 4\n\n5.times do |i|\n\tif ts[i] >= ts[i+1]\n\t\tdur = (n/ts[i+1]).ceil\n\t\tm += dur\n\t\tn -= ts[i+1]*dur\n\tend\nend\n\nputs m\n", "language": "Ruby", "metadata": {"date": 1554582782, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03077.html", "problem_id": "p03077", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03077/input.txt", "sample_output_relpath": "derived/input_output/data/p03077/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03077/Ruby/s629256139.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s629256139", "user_id": "u830939543"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "ts = 6.times.map { gets.to_f }\nn = ts.shift\n\nts = [(10**15).to_f, ts].flatten\nm = 4\n\n5.times do |i|\n\tif ts[i] >= ts[i+1]\n\t\tdur = (n/ts[i+1]).ceil\n\t\tm += dur\n\t\tn -= ts[i+1]*dur\n\tend\nend\n\nputs m\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!\n\nThere are five means of transport in this empire:\n\nTrain: travels from City 1 to 2 in one minute. A train can occupy at most A people.\n\nBus: travels from City 2 to 3 in one minute. A bus can occupy at most B people.\n\nTaxi: travels from City 3 to 4 in one minute. A taxi can occupy at most C people.\n\nAirplane: travels from City 4 to 5 in one minute. An airplane can occupy at most D people.\n\nShip: travels from City 5 to 6 in one minute. A ship can occupy at most E people.\n\nFor each of them, one vehicle leaves the city at each integer time (time 0, 1, 2, ...).\n\nThere is a group of N people at City 1, and they all want to go to City 6.\n\nAt least how long does it take for all of them to reach there?\nYou can ignore the time needed to transfer.\n\nConstraints\n\n1 \\leq N, A, B, C, D, E \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the minimum time required for all of the people to reach City 6, in minutes.\n\nSample Input 1\n\n5\n3\n2\n4\n3\n5\n\nSample Output 1\n\n7\n\nOne possible way to travel is as follows.\nFirst, there are N = 5 people at City 1, as shown in the following image:\n\nIn the first minute, three people travels from City 1 to City 2 by train. Note that a train can only occupy at most three people.\n\nIn the second minute, the remaining two people travels from City 1 to City 2 by train, and two of the three people who were already at City 2 travels to City 3 by bus. Note that a bus can only occupy at most two people.\n\nIn the third minute, two people travels from City 2 to City 3 by train, and another two people travels from City 3 to City 4 by taxi.\n\nFrom then on, if they continue traveling without stopping until they reach City 6, all of them can reach there in seven minutes.\n\nThere is no way for them to reach City 6 in 6 minutes or less.\n\nSample Input 2\n\n10\n123\n123\n123\n123\n123\n\nSample Output 2\n\n5\n\nAll kinds of vehicles can occupy N = 10 people at a time.\nThus, if they continue traveling without stopping until they reach City 6, all of them can reach there in five minutes.\n\nSample Input 3\n\n10000000007\n2\n3\n5\n7\n11\n\nSample Output 3\n\n5000000008\n\nNote that the input or output may not fit into a 32-bit integer type.", "sample_input": "5\n3\n2\n4\n3\n5\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03077", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!\n\nThere are five means of transport in this empire:\n\nTrain: travels from City 1 to 2 in one minute. A train can occupy at most A people.\n\nBus: travels from City 2 to 3 in one minute. A bus can occupy at most B people.\n\nTaxi: travels from City 3 to 4 in one minute. A taxi can occupy at most C people.\n\nAirplane: travels from City 4 to 5 in one minute. An airplane can occupy at most D people.\n\nShip: travels from City 5 to 6 in one minute. A ship can occupy at most E people.\n\nFor each of them, one vehicle leaves the city at each integer time (time 0, 1, 2, ...).\n\nThere is a group of N people at City 1, and they all want to go to City 6.\n\nAt least how long does it take for all of them to reach there?\nYou can ignore the time needed to transfer.\n\nConstraints\n\n1 \\leq N, A, B, C, D, E \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the minimum time required for all of the people to reach City 6, in minutes.\n\nSample Input 1\n\n5\n3\n2\n4\n3\n5\n\nSample Output 1\n\n7\n\nOne possible way to travel is as follows.\nFirst, there are N = 5 people at City 1, as shown in the following image:\n\nIn the first minute, three people travels from City 1 to City 2 by train. Note that a train can only occupy at most three people.\n\nIn the second minute, the remaining two people travels from City 1 to City 2 by train, and two of the three people who were already at City 2 travels to City 3 by bus. Note that a bus can only occupy at most two people.\n\nIn the third minute, two people travels from City 2 to City 3 by train, and another two people travels from City 3 to City 4 by taxi.\n\nFrom then on, if they continue traveling without stopping until they reach City 6, all of them can reach there in seven minutes.\n\nThere is no way for them to reach City 6 in 6 minutes or less.\n\nSample Input 2\n\n10\n123\n123\n123\n123\n123\n\nSample Output 2\n\n5\n\nAll kinds of vehicles can occupy N = 10 people at a time.\nThus, if they continue traveling without stopping until they reach City 6, all of them can reach there in five minutes.\n\nSample Input 3\n\n10000000007\n2\n3\n5\n7\n11\n\nSample Output 3\n\n5000000008\n\nNote that the input or output may not fit into a 32-bit integer type.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 193, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s841990428", "group_id": "codeNet:p03078", "input_text": "#二分ヒープ\nclass BinaryHeap\n def initialize(n, &b)\n @heap = Array.new(n)\n @size = 0\n #ex) |parent, child| parent <= child\n @b = b\n end\n def push(x)\n @size += 1\n upfrom(@size - 1, x)\n end\n def shift\n wk = @heap[0]\n @size -= 1\n downfrom(0, @heap[@size])\n wk\n end\n\n private\n\n def upfrom(i, x)\n me = i\n while 0 < me do\n parent = (me - 1) >> 1\n break if @b.call(@heap[parent], x)\n @heap[me] = @heap[parent]\n me = parent\n end\n @heap[me] = x\n end\n def downfrom(i, x)\n me = i\n while me < @size do\n child = (me << 1) + 1\n break if child >= @size\n if (child + 1) < @size && @b.call(@heap[child + 1], @heap[child]) then\n child += 1\n end\n break if @b.call(x, @heap[child])\n @heap[me] = @heap[child]\n me = child\n end\n @heap[me] = x\n end\nend\n\nX, Y, Z, K = gets.chomp.split(\" \").map(&:to_i)\nA = gets.chomp.split(\" \").map(&:to_i)\nB = gets.chomp.split(\" \").map(&:to_i)\nC = gets.chomp.split(\" \").map(&:to_i)\n\nbh = BinaryHeap.new(X * Y * Z){|parent, child| parent[0] >= child[0]}\nA.sort!.reverse!\nB.sort!.reverse!\nC.sort!.reverse!\nia, ib, ic = [0, 0, 0]\nbh.push([A[0]+B[0]+C[0], 0, 0, 0])\n\nK.times{\n wk = bh.shift\n puts wk[0]\n oa, ob, oc = [ia, ib, ic]\n fa, fb, fc = [false, false, false]\n (ia += 1; fa = true) if wk[1] == ia && ia < X - 1\n (ib += 1; fb = true) if wk[2] == ib && ib < Y - 1\n (ic += 1; fc = true) if wk[3] == ic && ic < Z - 1\n if fa then\n (0..ob).each{|b|\n (0..oc).each{|c|\n bh.push([A[ia]+B[b]+C[c], ia, b, c])\n }\n }\n end\n if fb then\n (0..oa).each{|a|\n (0..oc).each{|c|\n bh.push([A[a]+B[ib]+C[c], a, ib, c])\n }\n }\n end\n if fc then\n (0..oa).each{|a|\n (0..ob).each{|b|\n bh.push([A[a]+B[b]+C[ic], a, b, ic])\n }\n }\n end\n if fa && fb then (0..oc).each{|c| bh.push([A[ia]+B[ib]+C[c], ia, ib, c])} end\n if fa && fc then (0..ob).each{|b| bh.push([A[ia]+B[b]+C[ic], ia, b, ic])} end\n if fb && fc then (0..oa).each{|a| bh.push([A[a]+B[ib]+C[ic], a, ib, ic])} end\n if fa && fb && fc then bh.push([A[ia]+B[ib]+C[ic], ia, ib, ic]) end\n}\n", "language": "Ruby", "metadata": {"date": 1581328830, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s841990428.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s841990428", "user_id": "u276517671"}, "prompt_components": {"gold_output": "19\n17\n15\n14\n13\n12\n10\n8\n", "input_to_evaluate": "#二分ヒープ\nclass BinaryHeap\n def initialize(n, &b)\n @heap = Array.new(n)\n @size = 0\n #ex) |parent, child| parent <= child\n @b = b\n end\n def push(x)\n @size += 1\n upfrom(@size - 1, x)\n end\n def shift\n wk = @heap[0]\n @size -= 1\n downfrom(0, @heap[@size])\n wk\n end\n\n private\n\n def upfrom(i, x)\n me = i\n while 0 < me do\n parent = (me - 1) >> 1\n break if @b.call(@heap[parent], x)\n @heap[me] = @heap[parent]\n me = parent\n end\n @heap[me] = x\n end\n def downfrom(i, x)\n me = i\n while me < @size do\n child = (me << 1) + 1\n break if child >= @size\n if (child + 1) < @size && @b.call(@heap[child + 1], @heap[child]) then\n child += 1\n end\n break if @b.call(x, @heap[child])\n @heap[me] = @heap[child]\n me = child\n end\n @heap[me] = x\n end\nend\n\nX, Y, Z, K = gets.chomp.split(\" \").map(&:to_i)\nA = gets.chomp.split(\" \").map(&:to_i)\nB = gets.chomp.split(\" \").map(&:to_i)\nC = gets.chomp.split(\" \").map(&:to_i)\n\nbh = BinaryHeap.new(X * Y * Z){|parent, child| parent[0] >= child[0]}\nA.sort!.reverse!\nB.sort!.reverse!\nC.sort!.reverse!\nia, ib, ic = [0, 0, 0]\nbh.push([A[0]+B[0]+C[0], 0, 0, 0])\n\nK.times{\n wk = bh.shift\n puts wk[0]\n oa, ob, oc = [ia, ib, ic]\n fa, fb, fc = [false, false, false]\n (ia += 1; fa = true) if wk[1] == ia && ia < X - 1\n (ib += 1; fb = true) if wk[2] == ib && ib < Y - 1\n (ic += 1; fc = true) if wk[3] == ic && ic < Z - 1\n if fa then\n (0..ob).each{|b|\n (0..oc).each{|c|\n bh.push([A[ia]+B[b]+C[c], ia, b, c])\n }\n }\n end\n if fb then\n (0..oa).each{|a|\n (0..oc).each{|c|\n bh.push([A[a]+B[ib]+C[c], a, ib, c])\n }\n }\n end\n if fc then\n (0..oa).each{|a|\n (0..ob).each{|b|\n bh.push([A[a]+B[b]+C[ic], a, b, ic])\n }\n }\n end\n if fa && fb then (0..oc).each{|c| bh.push([A[ia]+B[ib]+C[c], ia, ib, c])} end\n if fa && fc then (0..ob).each{|b| bh.push([A[ia]+B[b]+C[ic], ia, b, ic])} end\n if fb && fc then (0..oa).each{|a| bh.push([A[a]+B[ib]+C[ic], a, ib, ic])} end\n if fa && fb && fc then bh.push([A[ia]+B[ib]+C[ic], ia, ib, ic]) end\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": 2145, "cpu_time_ms": 10, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s243415060", "group_id": "codeNet:p03078", "input_text": "x, y, z, k = gets.chomp.split.map(&:to_i)\na_ary = gets.chomp.split.map(&:to_i)\nb_ary = gets.chomp.split.map(&:to_i)\nc_ary = gets.chomp.split.map(&:to_i)\nc_ary.sort! {|a, b| b <=> a }\n\nans_ab = []\n# 10^6\nfor i in 0...x\n for j in 0...y\n ans_ab << a_ary[i] + b_ary[j]\n end\nend\n# 10^6*logN\nans_ab.sort! {|a, b| b <=> a }\n\nans_abc = []\n# 3000*z zl 10^6\nfor i in 0...[3000, x * y].min\n for j in 0...z\n ans_abc << ans_ab[i] + c_ary[j]\n end\nend\n\nans_abc.sort! {|a, b| b <=> a }\nfor i in 0...k\n puts ans_abc[i]\nend", "language": "Ruby", "metadata": {"date": 1558581417, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s243415060.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s243415060", "user_id": "u706730549"}, "prompt_components": {"gold_output": "19\n17\n15\n14\n13\n12\n10\n8\n", "input_to_evaluate": "x, y, z, k = gets.chomp.split.map(&:to_i)\na_ary = gets.chomp.split.map(&:to_i)\nb_ary = gets.chomp.split.map(&:to_i)\nc_ary = gets.chomp.split.map(&:to_i)\nc_ary.sort! {|a, b| b <=> a }\n\nans_ab = []\n# 10^6\nfor i in 0...x\n for j in 0...y\n ans_ab << a_ary[i] + b_ary[j]\n end\nend\n# 10^6*logN\nans_ab.sort! {|a, b| b <=> a }\n\nans_abc = []\n# 3000*z zl 10^6\nfor i in 0...[3000, x * y].min\n for j in 0...z\n ans_abc << ans_ab[i] + c_ary[j]\n end\nend\n\nans_abc.sort! {|a, b| b <=> a }\nfor i in 0...k\n puts ans_abc[i]\nend", "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": 536, "cpu_time_ms": 2110, "memory_kb": 51284}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s760725268", "group_id": "codeNet:p03078", "input_text": "x, y, z, k = gets.split.map(&:to_i)\nas = gets.split.map(&:to_i).sort.reverse\nbs = gets.split.map(&:to_i).sort.reverse\ncs = gets.split.map(&:to_i).sort.reverse\n\nss = []\nfor ai in 0...as.length\n for bi in 0...bs.length\n break if k < (ai+1)*(bi*1)\n for ci in 0...cs.length\n break if k < (ai+1)*(bi+1)*(ci+1)\n ss << as[ai]+bs[bi]+cs[ci]\n end\n end\nend\nputs ss.sort.reverse[0...k]", "language": "Ruby", "metadata": {"date": 1554653806, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s760725268.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s760725268", "user_id": "u139858699"}, "prompt_components": {"gold_output": "19\n17\n15\n14\n13\n12\n10\n8\n", "input_to_evaluate": "x, y, z, k = gets.split.map(&:to_i)\nas = gets.split.map(&:to_i).sort.reverse\nbs = gets.split.map(&:to_i).sort.reverse\ncs = gets.split.map(&:to_i).sort.reverse\n\nss = []\nfor ai in 0...as.length\n for bi in 0...bs.length\n break if k < (ai+1)*(bi*1)\n for ci in 0...cs.length\n break if k < (ai+1)*(bi+1)*(ci+1)\n ss << as[ai]+bs[bi]+cs[ci]\n end\n end\nend\nputs ss.sort.reverse[0...k]", "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": 395, "cpu_time_ms": 62, "memory_kb": 4600}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s593308964", "group_id": "codeNet:p03078", "input_text": "x,y,z,k = gets.split.map(&:to_i)\na = gets.split.map(&:to_i)\nb = gets.split.map(&:to_i)\nc = gets.split.map(&:to_i)\n\na = a.sort_by{|n| -n}\nb = b.sort_by{|n| -n}\nc = c.sort_by{|n| -n}\n\nall = a.each_with_index.flat_map do |aa, ai|\n break if ai+1 > 3000\n b.each_with_index.flat_map do |bb, bi|\n break if (ai+1) * (bi+1) > 3000\n c.each_with_index.flat_map do |cc, ci|\n break if (ai+1) * (bi+1) * (ci+1) > 3000\n aa + bb + cc\n end\n end\nend.compact\n\nputs all.sort_by{|n| -n}.take(k)\n", "language": "Ruby", "metadata": {"date": 1554649858, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s593308964.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s593308964", "user_id": "u325709450"}, "prompt_components": {"gold_output": "19\n17\n15\n14\n13\n12\n10\n8\n", "input_to_evaluate": "x,y,z,k = gets.split.map(&:to_i)\na = gets.split.map(&:to_i)\nb = gets.split.map(&:to_i)\nc = gets.split.map(&:to_i)\n\na = a.sort_by{|n| -n}\nb = b.sort_by{|n| -n}\nc = c.sort_by{|n| -n}\n\nall = a.each_with_index.flat_map do |aa, ai|\n break if ai+1 > 3000\n b.each_with_index.flat_map do |bb, bi|\n break if (ai+1) * (bi+1) > 3000\n c.each_with_index.flat_map do |cc, ci|\n break if (ai+1) * (bi+1) * (ci+1) > 3000\n aa + bb + cc\n end\n end\nend.compact\n\nputs all.sort_by{|n| -n}.take(k)\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": 496, "cpu_time_ms": 71, "memory_kb": 2552}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s183301935", "group_id": "codeNet:p03078", "input_text": "\nx,y,z,k = gets.chomp.split(\" \").map{|i|i = i.to_i}.sort\na = gets.chomp.split(\" \").map{|i|i = i.to_i}.sort\nb = gets.chomp.split(\" \").map{|i|i = i.to_i}.sort\nc = gets.chomp.split(\" \").map{|i|i = i.to_i}.sort\n#puts \"a=#{a}\"\n#puts \"b=#{b}\"\n#puts \"c=#{c}\"\nresult_arr = []\na.length.times do|a_i|\n b.length.times do|b_i|\n c.length.times do|c_i|\n if ((a_i+1)*(b_i+1)*(c_i+1))>k then\n break\n end\n result_arr << (a[a_i]+b[b_i]+c[c_i])\n end\n end\nend\n\n\nresult_arr.sort!\nk.times do|i|\n puts result_arr[result_arr.length-1-i]\nend\n", "language": "Ruby", "metadata": {"date": 1554586292, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s183301935.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s183301935", "user_id": "u281662621"}, "prompt_components": {"gold_output": "19\n17\n15\n14\n13\n12\n10\n8\n", "input_to_evaluate": "\nx,y,z,k = gets.chomp.split(\" \").map{|i|i = i.to_i}.sort\na = gets.chomp.split(\" \").map{|i|i = i.to_i}.sort\nb = gets.chomp.split(\" \").map{|i|i = i.to_i}.sort\nc = gets.chomp.split(\" \").map{|i|i = i.to_i}.sort\n#puts \"a=#{a}\"\n#puts \"b=#{b}\"\n#puts \"c=#{c}\"\nresult_arr = []\na.length.times do|a_i|\n b.length.times do|b_i|\n c.length.times do|c_i|\n if ((a_i+1)*(b_i+1)*(c_i+1))>k then\n break\n end\n result_arr << (a[a_i]+b[b_i]+c[c_i])\n end\n end\nend\n\n\nresult_arr.sort!\nk.times do|i|\n puts result_arr[result_arr.length-1-i]\nend\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": 548, "cpu_time_ms": 309, "memory_kb": 5880}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s849118531", "group_id": "codeNet:p03085", "input_text": "## https://qiita.com/naotospace/items/8edea2f89566d0f687ec\n\n# ハッシュを使う\nb = gets.chomp.to_s\n\nhash = {A: \"T\", T: \"A\", C: \"G\", G: \"C\"}\n\nputs hash[b]", "language": "Ruby", "metadata": {"date": 1587257101, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03085.html", "problem_id": "p03085", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03085/input.txt", "sample_output_relpath": "derived/input_output/data/p03085/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03085/Ruby/s849118531.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s849118531", "user_id": "u552761221"}, "prompt_components": {"gold_output": "T\n", "input_to_evaluate": "## https://qiita.com/naotospace/items/8edea2f89566d0f687ec\n\n# ハッシュを使う\nb = gets.chomp.to_s\n\nhash = {A: \"T\", T: \"A\", C: \"G\", G: \"C\"}\n\nputs hash[b]", "problem_context": "Score : 100 points\n\nProblem Statement\n\nOn the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.\n\nYou are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.\n\nConstraints\n\nb is one of the letters A, C, G and T.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nb\n\nOutput\n\nPrint the letter representing the base that bonds with the base b.\n\nSample Input 1\n\nA\n\nSample Output 1\n\nT\n\nSample Input 2\n\nG\n\nSample Output 2\n\nC", "sample_input": "A\n"}, "reference_outputs": ["T\n"], "source_document_id": "p03085", "source_text": "Score : 100 points\n\nProblem Statement\n\nOn the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.\n\nYou are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.\n\nConstraints\n\nb is one of the letters A, C, G and T.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nb\n\nOutput\n\nPrint the letter representing the base that bonds with the base b.\n\nSample Input 1\n\nA\n\nSample Output 1\n\nT\n\nSample Input 2\n\nG\n\nSample Output 2\n\nC", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 158, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s848779486", "group_id": "codeNet:p03085", "input_text": "STDIN.gets\ns = STDIN.gets\nacm = Array.new(s.length, 0)\n\nflg = false\ni = 0\ns.chars do |c|\n if c == 'A'\n flg = true\n else\n if c == 'C' && flg\n acm[i-1] = 1\n end\n flg = false\n end\n i+=1\nend\n\ncache = {}\nlines = STDIN.readlines\nlines.each do |line|\n st, e = line.split(' ')\n key = \"#{st}:#{e}\"\n if c = cache[key]\n puts c\n else\n v = acm[st.to_i-1..e.to_i-2].inject(:+)\n cache[key] = v\n puts v\n end\nend\n", "language": "Ruby", "metadata": {"date": 1553806178, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03085.html", "problem_id": "p03085", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03085/input.txt", "sample_output_relpath": "derived/input_output/data/p03085/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03085/Ruby/s848779486.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s848779486", "user_id": "u079672278"}, "prompt_components": {"gold_output": "T\n", "input_to_evaluate": "STDIN.gets\ns = STDIN.gets\nacm = Array.new(s.length, 0)\n\nflg = false\ni = 0\ns.chars do |c|\n if c == 'A'\n flg = true\n else\n if c == 'C' && flg\n acm[i-1] = 1\n end\n flg = false\n end\n i+=1\nend\n\ncache = {}\nlines = STDIN.readlines\nlines.each do |line|\n st, e = line.split(' ')\n key = \"#{st}:#{e}\"\n if c = cache[key]\n puts c\n else\n v = acm[st.to_i-1..e.to_i-2].inject(:+)\n cache[key] = v\n puts v\n end\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nOn the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.\n\nYou are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.\n\nConstraints\n\nb is one of the letters A, C, G and T.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nb\n\nOutput\n\nPrint the letter representing the base that bonds with the base b.\n\nSample Input 1\n\nA\n\nSample Output 1\n\nT\n\nSample Input 2\n\nG\n\nSample Output 2\n\nC", "sample_input": "A\n"}, "reference_outputs": ["T\n"], "source_document_id": "p03085", "source_text": "Score : 100 points\n\nProblem Statement\n\nOn the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.\n\nYou are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.\n\nConstraints\n\nb is one of the letters A, C, G and T.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nb\n\nOutput\n\nPrint the letter representing the base that bonds with the base b.\n\nSample Input 1\n\nA\n\nSample Output 1\n\nT\n\nSample Input 2\n\nG\n\nSample Output 2\n\nC", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 434, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s378861260", "group_id": "codeNet:p03085", "input_text": "ary = %i[A C G T]\nputs ary.zip(ary.reverse).to_h[gets.chomp.to_sym]", "language": "Ruby", "metadata": {"date": 1553591671, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03085.html", "problem_id": "p03085", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03085/input.txt", "sample_output_relpath": "derived/input_output/data/p03085/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03085/Ruby/s378861260.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s378861260", "user_id": "u433966798"}, "prompt_components": {"gold_output": "T\n", "input_to_evaluate": "ary = %i[A C G T]\nputs ary.zip(ary.reverse).to_h[gets.chomp.to_sym]", "problem_context": "Score : 100 points\n\nProblem Statement\n\nOn the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.\n\nYou are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.\n\nConstraints\n\nb is one of the letters A, C, G and T.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nb\n\nOutput\n\nPrint the letter representing the base that bonds with the base b.\n\nSample Input 1\n\nA\n\nSample Output 1\n\nT\n\nSample Input 2\n\nG\n\nSample Output 2\n\nC", "sample_input": "A\n"}, "reference_outputs": ["T\n"], "source_document_id": "p03085", "source_text": "Score : 100 points\n\nProblem Statement\n\nOn the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.\n\nYou are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.\n\nConstraints\n\nb is one of the letters A, C, G and T.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nb\n\nOutput\n\nPrint the letter representing the base that bonds with the base b.\n\nSample Input 1\n\nA\n\nSample Output 1\n\nT\n\nSample Input 2\n\nG\n\nSample Output 2\n\nC", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 67, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s484810307", "group_id": "codeNet:p03085", "input_text": "s = gets.chomp\nh = {\"A\" => \"T\", \"T\" => \"A\", \"G\" => \"C\", \"C\" => \"G\"}\nputs h[s]", "language": "Ruby", "metadata": {"date": 1553470414, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03085.html", "problem_id": "p03085", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03085/input.txt", "sample_output_relpath": "derived/input_output/data/p03085/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03085/Ruby/s484810307.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s484810307", "user_id": "u744908753"}, "prompt_components": {"gold_output": "T\n", "input_to_evaluate": "s = gets.chomp\nh = {\"A\" => \"T\", \"T\" => \"A\", \"G\" => \"C\", \"C\" => \"G\"}\nputs h[s]", "problem_context": "Score : 100 points\n\nProblem Statement\n\nOn the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.\n\nYou are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.\n\nConstraints\n\nb is one of the letters A, C, G and T.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nb\n\nOutput\n\nPrint the letter representing the base that bonds with the base b.\n\nSample Input 1\n\nA\n\nSample Output 1\n\nT\n\nSample Input 2\n\nG\n\nSample Output 2\n\nC", "sample_input": "A\n"}, "reference_outputs": ["T\n"], "source_document_id": "p03085", "source_text": "Score : 100 points\n\nProblem Statement\n\nOn the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.\n\nYou are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.\n\nConstraints\n\nb is one of the letters A, C, G and T.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nb\n\nOutput\n\nPrint the letter representing the base that bonds with the base b.\n\nSample Input 1\n\nA\n\nSample Output 1\n\nT\n\nSample Input 2\n\nG\n\nSample Output 2\n\nC", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 77, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s256497036", "group_id": "codeNet:p03085", "input_text": "N, Q=gets.split.map(&:to_i)\nS=gets.chomp\nlrs=Q.times.map { gets.split.map(&:to_i) }\n\nlrs.each do |lr|\n cnt=0\n str = S[(lr[0]-1), (lr[1]-1)]\n ((str.size)-1).times do |i|\n if str[i] == \"A\" || str[i+1] == \"C\"\n cnt+=1\n end\n end\n p cnt\nend\n", "language": "Ruby", "metadata": {"date": 1553461499, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03085.html", "problem_id": "p03085", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03085/input.txt", "sample_output_relpath": "derived/input_output/data/p03085/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03085/Ruby/s256497036.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s256497036", "user_id": "u993494045"}, "prompt_components": {"gold_output": "T\n", "input_to_evaluate": "N, Q=gets.split.map(&:to_i)\nS=gets.chomp\nlrs=Q.times.map { gets.split.map(&:to_i) }\n\nlrs.each do |lr|\n cnt=0\n str = S[(lr[0]-1), (lr[1]-1)]\n ((str.size)-1).times do |i|\n if str[i] == \"A\" || str[i+1] == \"C\"\n cnt+=1\n end\n end\n p cnt\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nOn the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.\n\nYou are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.\n\nConstraints\n\nb is one of the letters A, C, G and T.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nb\n\nOutput\n\nPrint the letter representing the base that bonds with the base b.\n\nSample Input 1\n\nA\n\nSample Output 1\n\nT\n\nSample Input 2\n\nG\n\nSample Output 2\n\nC", "sample_input": "A\n"}, "reference_outputs": ["T\n"], "source_document_id": "p03085", "source_text": "Score : 100 points\n\nProblem Statement\n\nOn the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.\n\nYou are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.\n\nConstraints\n\nb is one of the letters A, C, G and T.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nb\n\nOutput\n\nPrint the letter representing the base that bonds with the base b.\n\nSample Input 1\n\nA\n\nSample Output 1\n\nT\n\nSample Input 2\n\nG\n\nSample Output 2\n\nC", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 251, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s802774611", "group_id": "codeNet:p03086", "input_text": "def calc(str,prev)\n \tcnt = 0\n\tstr.chars{|c| c.match(/[ATCG]/) ? cnt +=1 : break}\n cnt = [prev, str.length < 1 ? cnt : self(str.split(\"\").drop(1).join, cnt)].max\nend\n \nputs calc(gets.chomp,0)", "language": "Ruby", "metadata": {"date": 1553615998, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s802774611.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s802774611", "user_id": "u358554431"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "def calc(str,prev)\n \tcnt = 0\n\tstr.chars{|c| c.match(/[ATCG]/) ? cnt +=1 : break}\n cnt = [prev, str.length < 1 ? cnt : self(str.split(\"\").drop(1).join, cnt)].max\nend\n \nputs calc(gets.chomp,0)", "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": 194, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s435387676", "group_id": "codeNet:p03087", "input_text": "n,q = gets.split.map(&:to_i)\ns = gets.chomp\nl = []\nr = []\nq.times do\n line = gets.split.map(&:to_i)\n l << line.shift\n r << line\nend\nr.flatten!\n\nx = s.chars\nresult = []\nq.times do |i|\n result << x[(l[i]-1)..(r[i]-1)].join.scan(\"AC\").count\nend\nputs result", "language": "Ruby", "metadata": {"date": 1598252981, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s435387676.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s435387676", "user_id": "u895926909"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "n,q = gets.split.map(&:to_i)\ns = gets.chomp\nl = []\nr = []\nq.times do\n line = gets.split.map(&:to_i)\n l << line.shift\n r << line\nend\nr.flatten!\n\nx = s.chars\nresult = []\nq.times do |i|\n result << x[(l[i]-1)..(r[i]-1)].join.scan(\"AC\").count\nend\nputs result", "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": 257, "cpu_time_ms": 2208, "memory_kb": 66048}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s048209895", "group_id": "codeNet:p03087", "input_text": "n, q = gets.split.map(&:to_i)\ns = gets.chomp\nnum = []\nq.times do\n num << gets.split.map(&:to_i)\nend\narr = Array.new(n+1,0)\n\nn.times do |i|\n arr[i] += arr[i-1]\n if s[i,2] == \"AC\"\n arr[i] += 1\n end\nend\n\nnum.each do |j,k|\n puts arr[k-2] - arr[j-2]\nend\n", "language": "Ruby", "metadata": {"date": 1554307884, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s048209895.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s048209895", "user_id": "u296101474"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "n, q = gets.split.map(&:to_i)\ns = gets.chomp\nnum = []\nq.times do\n num << gets.split.map(&:to_i)\nend\narr = Array.new(n+1,0)\n\nn.times do |i|\n arr[i] += arr[i-1]\n if s[i,2] == \"AC\"\n arr[i] += 1\n end\nend\n\nnum.each do |j,k|\n puts arr[k-2] - arr[j-2]\nend\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": 257, "cpu_time_ms": 260, "memory_kb": 11132}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s324178188", "group_id": "codeNet:p03087", "input_text": "n,q=gets.chomp.split.map(&:to_i)\ns=gets.chomp.gsub(/AC/, \"Ac\")\nque,r=[],[0]\nq.times{que<< gets.chomp.split.map(&:to_i)}\ns.size.times{|i|\n s[i]==\"c\"?r<< r[i-1]+1:r<< r[i-1]\n r.shift if i==0\n}\nq.times{|a|p (r[que[a][1]-1]-r[que[a][0]-1])}", "language": "Ruby", "metadata": {"date": 1553527113, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s324178188.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s324178188", "user_id": "u264508862"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "n,q=gets.chomp.split.map(&:to_i)\ns=gets.chomp.gsub(/AC/, \"Ac\")\nque,r=[],[0]\nq.times{que<< gets.chomp.split.map(&:to_i)}\ns.size.times{|i|\n s[i]==\"c\"?r<< r[i-1]+1:r<< r[i-1]\n r.shift if i==0\n}\nq.times{|a|p (r[que[a][1]-1]-r[que[a][0]-1])}", "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": 238, "cpu_time_ms": 595, "memory_kb": 17404}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s116286249", "group_id": "codeNet:p03087", "input_text": "N,Q=gets.split.map &:to_i\nS=gets.chomp\nm=[]\n(0..(N-2)).each{|i|\n if S[i]=='A' && S[i+1]=='C'\n m << i\n end\n}\n#p m\n(0...Q).each{|i|\n l,r=gets.split.map &:to_i\n li=m.bsearch_index{|x| x>=l-1}\n ri=m.bsearch_index{|x| x>=r-1}\n if li==nil\n li=m.size\n end\n if ri ==nil\n ri=m.size\n end\n #p [li, ri]\n puts (m[ri-1]==r ? ri-li-1 : ri-li) \n}", "language": "Ruby", "metadata": {"date": 1553466412, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s116286249.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s116286249", "user_id": "u782685137"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "N,Q=gets.split.map &:to_i\nS=gets.chomp\nm=[]\n(0..(N-2)).each{|i|\n if S[i]=='A' && S[i+1]=='C'\n m << i\n end\n}\n#p m\n(0...Q).each{|i|\n l,r=gets.split.map &:to_i\n li=m.bsearch_index{|x| x>=l-1}\n ri=m.bsearch_index{|x| x>=r-1}\n if li==nil\n li=m.size\n end\n if ri ==nil\n ri=m.size\n end\n #p [li, ri]\n puts (m[ri-1]==r ? ri-li-1 : ri-li) \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": 384, "cpu_time_ms": 524, "memory_kb": 3068}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s057893426", "group_id": "codeNet:p03089", "input_text": "def limited_insertion\n n = 0\n b = []\n i = 0\n while line = gets\n n = line[0].to_i if i == 0\n b = line.split(' ').map{|v| v.to_i} if i == 1\n break if i == 1\n i += 1\n end\n\n a = []\n for i in 1..n\n result = -1\n for j in 1..i\n if b[i-1] == j\n result = j\n break\n end\n end\n\n p result\n\n break if result == -1\n end\nend\n\nlimited_insertion", "language": "Ruby", "metadata": {"date": 1553754737, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s057893426.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s057893426", "user_id": "u556849512"}, "prompt_components": {"gold_output": "1\n1\n2\n", "input_to_evaluate": "def limited_insertion\n n = 0\n b = []\n i = 0\n while line = gets\n n = line[0].to_i if i == 0\n b = line.split(' ').map{|v| v.to_i} if i == 1\n break if i == 1\n i += 1\n end\n\n a = []\n for i in 1..n\n result = -1\n for j in 1..i\n if b[i-1] == j\n result = j\n break\n end\n end\n\n p result\n\n break if result == -1\n end\nend\n\nlimited_insertion", "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": 386, "cpu_time_ms": 8, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s410248195", "group_id": "codeNet:p03095", "input_text": "N=gets\nS=gets.chomp\n\ncounts = []\n('a'..'z').each do |c|\n counts << S.count(c)+1\nend\n\nputs((counts.inject(&:*)-1) % (10**9 + 7))\n", "language": "Ruby", "metadata": {"date": 1552771573, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03095.html", "problem_id": "p03095", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03095/input.txt", "sample_output_relpath": "derived/input_output/data/p03095/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03095/Ruby/s410248195.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s410248195", "user_id": "u109933517"}, "prompt_components": {"gold_output": "15\n", "input_to_evaluate": "N=gets\nS=gets.chomp\n\ncounts = []\n('a'..'z').each do |c|\n counts << S.count(c)+1\nend\n\nputs((counts.inject(&:*)-1) % (10**9 + 7))\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N.\nAmong its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings.\n\nHere, a subsequence of a string is a concatenation of one or more characters from the string without changing the order.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nS consists of lowercase English letters.\n\n|S|=N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of the subsequences such that all characters are different, modulo 10^9+7.\n\nSample Input 1\n\n4\nabcd\n\nSample Output 1\n\n15\n\nSince all characters in S itself are different, all its subsequences satisfy the condition.\n\nSample Input 2\n\n3\nbaa\n\nSample Output 2\n\n5\n\nThe answer is five: b, two occurrences of a, two occurrences of ba. Note that we do not count baa, since it contains two as.\n\nSample Input 3\n\n5\nabcab\n\nSample Output 3\n\n17", "sample_input": "4\nabcd\n"}, "reference_outputs": ["15\n"], "source_document_id": "p03095", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N.\nAmong its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings.\n\nHere, a subsequence of a string is a concatenation of one or more characters from the string without changing the order.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nS consists of lowercase English letters.\n\n|S|=N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of the subsequences such that all characters are different, modulo 10^9+7.\n\nSample Input 1\n\n4\nabcd\n\nSample Output 1\n\n15\n\nSince all characters in S itself are different, all its subsequences satisfy the condition.\n\nSample Input 2\n\n3\nbaa\n\nSample Output 2\n\n5\n\nThe answer is five: b, two occurrences of a, two occurrences of ba. Note that we do not count baa, since it contains two as.\n\nSample Input 3\n\n5\nabcab\n\nSample Output 3\n\n17", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 129, "cpu_time_ms": 9, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s622645719", "group_id": "codeNet:p03101", "input_text": "hh, ww = gets.split.map(&:to_i)\nh, w = gets.split.map(&:to_i)\nputs (hh-h)*(ww-w)", "language": "Ruby", "metadata": {"date": 1552161788, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s622645719.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s622645719", "user_id": "u325709450"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "hh, ww = gets.split.map(&:to_i)\nh, w = gets.split.map(&:to_i)\nputs (hh-h)*(ww-w)", "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": 80, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s286162681", "group_id": "codeNet:p03106", "input_text": "a, b, k = gets.chomp.split.map(&:to_i)\ncnt = 0\n[a,b].min.downto(1) do |i|\n\tcnt += 1 if a % i == 0 && b % i == 0\n\tif cnt == k\n\t\tputs i\n\t\tbreak\n\tend\n\nend\n\n\n", "language": "Ruby", "metadata": {"date": 1596717333, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p03106.html", "problem_id": "p03106", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03106/input.txt", "sample_output_relpath": "derived/input_output/data/p03106/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03106/Ruby/s286162681.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s286162681", "user_id": "u409390792"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "a, b, k = gets.chomp.split.map(&:to_i)\ncnt = 0\n[a,b].min.downto(1) do |i|\n\tcnt += 1 if a % i == 0 && b % i == 0\n\tif cnt == k\n\t\tputs i\n\t\tbreak\n\tend\n\nend\n\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nFind the K-th largest positive integer that divides both A and B.\n\nThe input guarantees that there exists such a number.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 100\n\nThe K-th largest positive integer that divides both A and B exists.\n\nK \\geq 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the K-th largest positive integer that divides both A and B.\n\nSample Input 1\n\n8 12 2\n\nSample Output 1\n\n2\n\nThree positive integers divides both 8 and 12: 1, 2 and 4.\nAmong them, the second largest is 2.\n\nSample Input 2\n\n100 50 4\n\nSample Output 2\n\n5\n\nSample Input 3\n\n1 1 1\n\nSample Output 3\n\n1", "sample_input": "8 12 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03106", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nFind the K-th largest positive integer that divides both A and B.\n\nThe input guarantees that there exists such a number.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 100\n\nThe K-th largest positive integer that divides both A and B exists.\n\nK \\geq 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the K-th largest positive integer that divides both A and B.\n\nSample Input 1\n\n8 12 2\n\nSample Output 1\n\n2\n\nThree positive integers divides both 8 and 12: 1, 2 and 4.\nAmong them, the second largest is 2.\n\nSample Input 2\n\n100 50 4\n\nSample Output 2\n\n5\n\nSample Input 3\n\n1 1 1\n\nSample Output 3\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 154, "cpu_time_ms": 68, "memory_kb": 14304}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s272791828", "group_id": "codeNet:p03106", "input_text": "a, b, k = gets.split.map(&:to_i)\nsmaller = [a, b].min\nnums = []\n(1..smaller).each do |n|\n if (a%n) == 0 && (b%n) == 0\n nums.push(n)\n end\nend\nputs nums.sort().reverse[k-1]", "language": "Ruby", "metadata": {"date": 1551643969, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03106.html", "problem_id": "p03106", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03106/input.txt", "sample_output_relpath": "derived/input_output/data/p03106/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03106/Ruby/s272791828.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s272791828", "user_id": "u105001881"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "a, b, k = gets.split.map(&:to_i)\nsmaller = [a, b].min\nnums = []\n(1..smaller).each do |n|\n if (a%n) == 0 && (b%n) == 0\n nums.push(n)\n end\nend\nputs nums.sort().reverse[k-1]", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nFind the K-th largest positive integer that divides both A and B.\n\nThe input guarantees that there exists such a number.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 100\n\nThe K-th largest positive integer that divides both A and B exists.\n\nK \\geq 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the K-th largest positive integer that divides both A and B.\n\nSample Input 1\n\n8 12 2\n\nSample Output 1\n\n2\n\nThree positive integers divides both 8 and 12: 1, 2 and 4.\nAmong them, the second largest is 2.\n\nSample Input 2\n\n100 50 4\n\nSample Output 2\n\n5\n\nSample Input 3\n\n1 1 1\n\nSample Output 3\n\n1", "sample_input": "8 12 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03106", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nFind the K-th largest positive integer that divides both A and B.\n\nThe input guarantees that there exists such a number.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 100\n\nThe K-th largest positive integer that divides both A and B exists.\n\nK \\geq 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the K-th largest positive integer that divides both A and B.\n\nSample Input 1\n\n8 12 2\n\nSample Output 1\n\n2\n\nThree positive integers divides both 8 and 12: 1, 2 and 4.\nAmong them, the second largest is 2.\n\nSample Input 2\n\n100 50 4\n\nSample Output 2\n\n5\n\nSample Input 3\n\n1 1 1\n\nSample Output 3\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 175, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s359827317", "group_id": "codeNet:p03107", "input_text": "@arg = gets.chomp\n@arg_len = @arg.length\n@dp_table = {}\n\ndef calc_erasable_index(pattern)\n res = {}\n pattern.scan(/01|10/) do |c|\n res.store(c, $~.offset(0)[0])\n end\n unless @dp_table[pattern]\n @dp_table.store(pattern,@arg_len - pattern.length)\n res.each do |key, value|\n /#{key}/ =~ pattern\n calc_erasable_index($` + $')\n end\n end \n return 0\nend\ncalc_erasable_index(@arg)\n\nprint @dp_table.values.max", "language": "Ruby", "metadata": {"date": 1552844439, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03107.html", "problem_id": "p03107", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03107/input.txt", "sample_output_relpath": "derived/input_output/data/p03107/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03107/Ruby/s359827317.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s359827317", "user_id": "u464955518"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "@arg = gets.chomp\n@arg_len = @arg.length\n@dp_table = {}\n\ndef calc_erasable_index(pattern)\n res = {}\n pattern.scan(/01|10/) do |c|\n res.store(c, $~.offset(0)[0])\n end\n unless @dp_table[pattern]\n @dp_table.store(pattern,@arg_len - pattern.length)\n res.each do |key, value|\n /#{key}/ =~ pattern\n calc_erasable_index($` + $')\n end\n end \n return 0\nend\ncalc_erasable_index(@arg)\n\nprint @dp_table.values.max", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N cubes stacked vertically on a desk.\n\nYou are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.\n\nYou can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.\n\nAt most how many cubes can be removed?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nEach character in S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of cubes that can be removed.\n\nSample Input 1\n\n0011\n\nSample Output 1\n\n4\n\nAll four cubes can be removed, by performing the operation as follows:\n\nRemove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.\n\nRemove the first and second cubes from the bottom.\n\nSample Input 2\n\n11011010001011\n\nSample Output 2\n\n12\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "sample_input": "0011\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03107", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N cubes stacked vertically on a desk.\n\nYou are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.\n\nYou can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.\n\nAt most how many cubes can be removed?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nEach character in S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of cubes that can be removed.\n\nSample Input 1\n\n0011\n\nSample Output 1\n\n4\n\nAll four cubes can be removed, by performing the operation as follows:\n\nRemove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.\n\nRemove the first and second cubes from the bottom.\n\nSample Input 2\n\n11011010001011\n\nSample Output 2\n\n12\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 473, "cpu_time_ms": 2110, "memory_kb": 46076}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s614462602", "group_id": "codeNet:p03107", "input_text": "string = gets.chomp # 文字列として受け取る\ncount_of_num = [string.count(\"0\"), string.count(\"1\")]\nputs count_of_num.min*2\n", "language": "Ruby", "metadata": {"date": 1551648476, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03107.html", "problem_id": "p03107", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03107/input.txt", "sample_output_relpath": "derived/input_output/data/p03107/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03107/Ruby/s614462602.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s614462602", "user_id": "u627764960"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "string = gets.chomp # 文字列として受け取る\ncount_of_num = [string.count(\"0\"), string.count(\"1\")]\nputs count_of_num.min*2\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N cubes stacked vertically on a desk.\n\nYou are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.\n\nYou can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.\n\nAt most how many cubes can be removed?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nEach character in S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of cubes that can be removed.\n\nSample Input 1\n\n0011\n\nSample Output 1\n\n4\n\nAll four cubes can be removed, by performing the operation as follows:\n\nRemove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.\n\nRemove the first and second cubes from the bottom.\n\nSample Input 2\n\n11011010001011\n\nSample Output 2\n\n12\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "sample_input": "0011\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03107", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N cubes stacked vertically on a desk.\n\nYou are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.\n\nYou can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.\n\nAt most how many cubes can be removed?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nEach character in S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of cubes that can be removed.\n\nSample Input 1\n\n0011\n\nSample Output 1\n\n4\n\nAll four cubes can be removed, by performing the operation as follows:\n\nRemove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.\n\nRemove the first and second cubes from the bottom.\n\nSample Input 2\n\n11011010001011\n\nSample Output 2\n\n12\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 131, "cpu_time_ms": 7, "memory_kb": 3964}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s148426753", "group_id": "codeNet:p03108", "input_text": "IND = -1 # 独立\n\n# n:島の数\n# m:橋の数\nn, m = gets.chomp.split(' ').map(&:to_i)\n\nabs = Array.new(m, nil)\nuf = Array.new(n+1, IND)\nresults = Array.new\n\nfor i in 1..m do\n a, b = gets.chomp.split(' ').map(&:to_i)\n abs[i-1] = [a,b]\nend\n\nabs.reverse!\n\ndef root(array, pos)\n return pos if pos == IND\n while array[pos] != pos do\n pos = array[pos]\n return pos if pos == IND\n end\n pos\nend\nfor (l,r) in abs do\n\n sum = 0\n for i in 1..n do\n for j in i+1..n do\n i_root = root(uf, i)\n j_root = root(uf, j)\n sum += 1 if (i_root != j_root) or i_root == IND or j_root == IND\n end\n end\n results.push(sum)\n\n # 独立のノードを根にする\n if uf[l] == IND then\n uf[l] = l\n end\n if uf[r] == IND then\n uf[r] = r\n end\n\n # 左右の根を求める\n l = root(uf, l)\n r = root(uf, r)\n\n # 左の根を右の根につなげる\n uf[l] = r\nend\n\nfor i in results.reverse do\n print \"#{i}\\n\"\nend\n", "language": "Ruby", "metadata": {"date": 1569964334, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s148426753.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s148426753", "user_id": "u894128391"}, "prompt_components": {"gold_output": "0\n0\n4\n5\n6\n", "input_to_evaluate": "IND = -1 # 独立\n\n# n:島の数\n# m:橋の数\nn, m = gets.chomp.split(' ').map(&:to_i)\n\nabs = Array.new(m, nil)\nuf = Array.new(n+1, IND)\nresults = Array.new\n\nfor i in 1..m do\n a, b = gets.chomp.split(' ').map(&:to_i)\n abs[i-1] = [a,b]\nend\n\nabs.reverse!\n\ndef root(array, pos)\n return pos if pos == IND\n while array[pos] != pos do\n pos = array[pos]\n return pos if pos == IND\n end\n pos\nend\nfor (l,r) in abs do\n\n sum = 0\n for i in 1..n do\n for j in i+1..n do\n i_root = root(uf, i)\n j_root = root(uf, j)\n sum += 1 if (i_root != j_root) or i_root == IND or j_root == IND\n end\n end\n results.push(sum)\n\n # 独立のノードを根にする\n if uf[l] == IND then\n uf[l] = l\n end\n if uf[r] == IND then\n uf[r] = r\n end\n\n # 左右の根を求める\n l = root(uf, l)\n r = root(uf, r)\n\n # 左の根を右の根につなげる\n uf[l] = r\nend\n\nfor i in results.reverse do\n print \"#{i}\\n\"\nend\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": 933, "cpu_time_ms": 2108, "memory_kb": 12436}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s310753902", "group_id": "codeNet:p03108", "input_text": "class Node\n attr_accessor :parent, :size\n\n def initialize(n)\n @parent = n\n @size = 1\n end\nend\n\nclass UnionFindTree\n def initialize(n)\n @nodes = (0..n).to_a.map { |i| Node.new(i) }\n end\n\n def find(x)\n return x if @nodes[x].parent == x\n\n return @nodes[x].parent = find(@nodes[x].parent)\n end\n\n def size(x)\n return @nodes[x].size if @nodes[x].parent == x\n\n @nodes[x].parent = find(@nodes[x].parent)\n\n return size(@nodes[x].parent)\n end\n\n def unite(a, b)\n a = find(a)\n b = find(b)\n return if a == b\n\n @nodes[a].parent = b\n @nodes[b].size += @nodes[a].size\n end\n\n def same?(a, b)\n find(a) == find(b)\n end\nend\n\nn, m = gets.split.map(&:to_i)\n\ntree = UnionFindTree.new(n)\nans = [ n * (n - 1) / 2 ]\n\nx = []\n\nm.times do |i|\n x << gets.split.map(&:to_i)\nend\n\nx.reverse.each do |a, b|\n if ans[-1] == 0\n ans << 0\n elsif !tree.same?(a, b)\n ans << ans[-1] - tree.size(a) * tree.size(b)\n tree.unite(a, b)\n else\n ans << ans[-1]\n end\nend\n\nputs ans[0...-1].reverse", "language": "Ruby", "metadata": {"date": 1567154770, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s310753902.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s310753902", "user_id": "u208436761"}, "prompt_components": {"gold_output": "0\n0\n4\n5\n6\n", "input_to_evaluate": "class Node\n attr_accessor :parent, :size\n\n def initialize(n)\n @parent = n\n @size = 1\n end\nend\n\nclass UnionFindTree\n def initialize(n)\n @nodes = (0..n).to_a.map { |i| Node.new(i) }\n end\n\n def find(x)\n return x if @nodes[x].parent == x\n\n return @nodes[x].parent = find(@nodes[x].parent)\n end\n\n def size(x)\n return @nodes[x].size if @nodes[x].parent == x\n\n @nodes[x].parent = find(@nodes[x].parent)\n\n return size(@nodes[x].parent)\n end\n\n def unite(a, b)\n a = find(a)\n b = find(b)\n return if a == b\n\n @nodes[a].parent = b\n @nodes[b].size += @nodes[a].size\n end\n\n def same?(a, b)\n find(a) == find(b)\n end\nend\n\nn, m = gets.split.map(&:to_i)\n\ntree = UnionFindTree.new(n)\nans = [ n * (n - 1) / 2 ]\n\nx = []\n\nm.times do |i|\n x << gets.split.map(&:to_i)\nend\n\nx.reverse.each do |a, b|\n if ans[-1] == 0\n ans << 0\n elsif !tree.same?(a, b)\n ans << ans[-1] - tree.size(a) * tree.size(b)\n tree.unite(a, b)\n else\n ans << ans[-1]\n end\nend\n\nputs ans[0...-1].reverse", "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": 1019, "cpu_time_ms": 458, "memory_kb": 23532}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s927254610", "group_id": "codeNet:p03109", "input_text": "require 'time'\ns = gets.chomp\n\nputs Time.parse(s) <= Time.parse('2019/04/30') ? 'Heisei' : 'TBD'\n", "language": "Ruby", "metadata": {"date": 1551038605, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s927254610.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s927254610", "user_id": "u434509016"}, "prompt_components": {"gold_output": "Heisei\n", "input_to_evaluate": "require 'time'\ns = gets.chomp\n\nputs Time.parse(s) <= Time.parse('2019/04/30') ? 'Heisei' : 'TBD'\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S as input. This represents a valid date in the year 2019 in the yyyy/mm/dd format. (For example, April 30, 2019 is represented as 2019/04/30.)\n\nWrite a program that prints Heisei if the date represented by S is not later than April 30, 2019, and prints TBD otherwise.\n\nConstraints\n\nS is a string that represents a valid date in the year 2019 in the yyyy/mm/dd format.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Heisei if the date represented by S is not later than April 30, 2019, and print TBD otherwise.\n\nSample Input 1\n\n2019/04/30\n\nSample Output 1\n\nHeisei\n\nSample Input 2\n\n2019/11/01\n\nSample Output 2\n\nTBD", "sample_input": "2019/04/30\n"}, "reference_outputs": ["Heisei\n"], "source_document_id": "p03109", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S as input. This represents a valid date in the year 2019 in the yyyy/mm/dd format. (For example, April 30, 2019 is represented as 2019/04/30.)\n\nWrite a program that prints Heisei if the date represented by S is not later than April 30, 2019, and prints TBD otherwise.\n\nConstraints\n\nS is a string that represents a valid date in the year 2019 in the yyyy/mm/dd format.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Heisei if the date represented by S is not later than April 30, 2019, and print TBD otherwise.\n\nSample Input 1\n\n2019/04/30\n\nSample Output 1\n\nHeisei\n\nSample Input 2\n\n2019/11/01\n\nSample Output 2\n\nTBD", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 97, "cpu_time_ms": 19, "memory_kb": 2424}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s223250578", "group_id": "codeNet:p03110", "input_text": "p (1..gets.to_i).map{|e|gets.to_f.*/B/?38e4:1}.inject:+", "language": "Ruby", "metadata": {"date": 1551369606, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03110.html", "problem_id": "p03110", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03110/input.txt", "sample_output_relpath": "derived/input_output/data/p03110/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03110/Ruby/s223250578.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s223250578", "user_id": "u657913472"}, "prompt_components": {"gold_output": "48000.0\n", "input_to_evaluate": "p (1..gets.to_i).map{|e|gets.to_f.*/B/?38e4:1}.inject:+", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi received otoshidama (New Year's money gifts) from N of his relatives.\n\nYou are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either JPY or BTC, and x_i and u_i represent the content of the otoshidama from the i-th relative.\n\nFor example, if x_1 = 10000 and u_1 = JPY, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = 0.10000000 and u_2 = BTC, the otoshidama from the second relative is 0.1 bitcoins.\n\nIf we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?\n\nConstraints\n\n2 \\leq N \\leq 10\n\nu_i = JPY or BTC.\n\nIf u_i = JPY, x_i is an integer such that 1 \\leq x_i \\leq 10^8.\n\nIf u_i = BTC, x_i is a decimal with 8 decimal digits, such that 0.00000001 \\leq x_i \\leq 100.00000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 u_1\nx_2 u_2\n:\nx_N u_N\n\nOutput\n\nIf the gifts are worth Y yen in total, print the value Y (not necessarily an integer).\n\nOutput will be judged correct when the absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10000 JPY\n0.10000000 BTC\n\nSample Output 1\n\n48000.0\n\nThe otoshidama from the first relative is 10000 yen. The otoshidama from the second relative is 0.1 bitcoins, which is worth 38000.0 yen if converted at the rate of 380000.0 JPY per 1.0 BTC. The sum of these is 48000.0 yen.\n\nOutputs such as 48000 and 48000.1 will also be judged correct.\n\nSample Input 2\n\n3\n100000000 JPY\n100.00000000 BTC\n0.00000001 BTC\n\nSample Output 2\n\n138000000.0038\n\nIn this case, outputs such as 138001000 and 1.38e8 will also be judged correct.", "sample_input": "2\n10000 JPY\n0.10000000 BTC\n"}, "reference_outputs": ["48000.0\n"], "source_document_id": "p03110", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi received otoshidama (New Year's money gifts) from N of his relatives.\n\nYou are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either JPY or BTC, and x_i and u_i represent the content of the otoshidama from the i-th relative.\n\nFor example, if x_1 = 10000 and u_1 = JPY, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = 0.10000000 and u_2 = BTC, the otoshidama from the second relative is 0.1 bitcoins.\n\nIf we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?\n\nConstraints\n\n2 \\leq N \\leq 10\n\nu_i = JPY or BTC.\n\nIf u_i = JPY, x_i is an integer such that 1 \\leq x_i \\leq 10^8.\n\nIf u_i = BTC, x_i is a decimal with 8 decimal digits, such that 0.00000001 \\leq x_i \\leq 100.00000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 u_1\nx_2 u_2\n:\nx_N u_N\n\nOutput\n\nIf the gifts are worth Y yen in total, print the value Y (not necessarily an integer).\n\nOutput will be judged correct when the absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10000 JPY\n0.10000000 BTC\n\nSample Output 1\n\n48000.0\n\nThe otoshidama from the first relative is 10000 yen. The otoshidama from the second relative is 0.1 bitcoins, which is worth 38000.0 yen if converted at the rate of 380000.0 JPY per 1.0 BTC. The sum of these is 48000.0 yen.\n\nOutputs such as 48000 and 48000.1 will also be judged correct.\n\nSample Input 2\n\n3\n100000000 JPY\n100.00000000 BTC\n0.00000001 BTC\n\nSample Output 2\n\n138000000.0038\n\nIn this case, outputs such as 138001000 and 1.38e8 will also be judged correct.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 55, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s530609068", "group_id": "codeNet:p03110", "input_text": "n = gets.to_i\ntotal = 0\n(0...n).each do |i|\n data = gets.chomp.split(' ')\n total += data[1] == 'BTC' ? 380000 * data[0].to_f : data[0].to_i\nend\nputs total", "language": "Ruby", "metadata": {"date": 1551039028, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03110.html", "problem_id": "p03110", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03110/input.txt", "sample_output_relpath": "derived/input_output/data/p03110/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03110/Ruby/s530609068.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s530609068", "user_id": "u765878014"}, "prompt_components": {"gold_output": "48000.0\n", "input_to_evaluate": "n = gets.to_i\ntotal = 0\n(0...n).each do |i|\n data = gets.chomp.split(' ')\n total += data[1] == 'BTC' ? 380000 * data[0].to_f : data[0].to_i\nend\nputs total", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi received otoshidama (New Year's money gifts) from N of his relatives.\n\nYou are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either JPY or BTC, and x_i and u_i represent the content of the otoshidama from the i-th relative.\n\nFor example, if x_1 = 10000 and u_1 = JPY, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = 0.10000000 and u_2 = BTC, the otoshidama from the second relative is 0.1 bitcoins.\n\nIf we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?\n\nConstraints\n\n2 \\leq N \\leq 10\n\nu_i = JPY or BTC.\n\nIf u_i = JPY, x_i is an integer such that 1 \\leq x_i \\leq 10^8.\n\nIf u_i = BTC, x_i is a decimal with 8 decimal digits, such that 0.00000001 \\leq x_i \\leq 100.00000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 u_1\nx_2 u_2\n:\nx_N u_N\n\nOutput\n\nIf the gifts are worth Y yen in total, print the value Y (not necessarily an integer).\n\nOutput will be judged correct when the absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10000 JPY\n0.10000000 BTC\n\nSample Output 1\n\n48000.0\n\nThe otoshidama from the first relative is 10000 yen. The otoshidama from the second relative is 0.1 bitcoins, which is worth 38000.0 yen if converted at the rate of 380000.0 JPY per 1.0 BTC. The sum of these is 48000.0 yen.\n\nOutputs such as 48000 and 48000.1 will also be judged correct.\n\nSample Input 2\n\n3\n100000000 JPY\n100.00000000 BTC\n0.00000001 BTC\n\nSample Output 2\n\n138000000.0038\n\nIn this case, outputs such as 138001000 and 1.38e8 will also be judged correct.", "sample_input": "2\n10000 JPY\n0.10000000 BTC\n"}, "reference_outputs": ["48000.0\n"], "source_document_id": "p03110", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi received otoshidama (New Year's money gifts) from N of his relatives.\n\nYou are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either JPY or BTC, and x_i and u_i represent the content of the otoshidama from the i-th relative.\n\nFor example, if x_1 = 10000 and u_1 = JPY, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = 0.10000000 and u_2 = BTC, the otoshidama from the second relative is 0.1 bitcoins.\n\nIf we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?\n\nConstraints\n\n2 \\leq N \\leq 10\n\nu_i = JPY or BTC.\n\nIf u_i = JPY, x_i is an integer such that 1 \\leq x_i \\leq 10^8.\n\nIf u_i = BTC, x_i is a decimal with 8 decimal digits, such that 0.00000001 \\leq x_i \\leq 100.00000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 u_1\nx_2 u_2\n:\nx_N u_N\n\nOutput\n\nIf the gifts are worth Y yen in total, print the value Y (not necessarily an integer).\n\nOutput will be judged correct when the absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10000 JPY\n0.10000000 BTC\n\nSample Output 1\n\n48000.0\n\nThe otoshidama from the first relative is 10000 yen. The otoshidama from the second relative is 0.1 bitcoins, which is worth 38000.0 yen if converted at the rate of 380000.0 JPY per 1.0 BTC. The sum of these is 48000.0 yen.\n\nOutputs such as 48000 and 48000.1 will also be judged correct.\n\nSample Input 2\n\n3\n100000000 JPY\n100.00000000 BTC\n0.00000001 BTC\n\nSample Output 2\n\n138000000.0038\n\nIn this case, outputs such as 138001000 and 1.38e8 will also be judged correct.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 156, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s785218453", "group_id": "codeNet:p03112", "input_text": "A, B, Q = gets.chomp.split(\" \").map(&:to_i)\nS = []\nT = []\nX = []\nA.times do\n S << gets.chomp.to_i\nend\nB.times do\n T << gets.chomp.to_i\nend\nQ.times do\n X << gets.chomp.to_i\nend\n\nX.each do |x|\n si = S.bsearch_index{|v| v >= x}\n sc = []\n if si.nil?\n sc = [S[-1]]\n elsif si.zero?\n sc = [S[0]]\n else\n sc = [S[si-1], S[si]]\n end\n ti = T.bsearch_index{|v| v >= x}\n tc = []\n if ti.nil?\n tc = [T[-1]]\n elsif ti.zero?\n tc = [T[0]]\n else\n tc = [T[ti-1], T[ti]]\n end\n min_cost = Float::INFINITY\n sc.each do |ss|\n tc.each do |tt|\n if (ss <= x && tt <= x) || (ss >= x && tt >= x)\n # 同じ方向\n cost = [(ss-x).abs, (tt-x).abs].max\n else\n # 逆方向\n cost = [(ss - x).abs + (tt - ss).abs, (tt - x).abs + (ss - tt).abs].min\n end\n min_cost = cost if cost < min_cost\n end\n end\n puts min_cost\nend\n", "language": "Ruby", "metadata": {"date": 1578071795, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03112.html", "problem_id": "p03112", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03112/input.txt", "sample_output_relpath": "derived/input_output/data/p03112/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03112/Ruby/s785218453.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s785218453", "user_id": "u443924743"}, "prompt_components": {"gold_output": "350\n1400\n301\n399\n", "input_to_evaluate": "A, B, Q = gets.chomp.split(\" \").map(&:to_i)\nS = []\nT = []\nX = []\nA.times do\n S << gets.chomp.to_i\nend\nB.times do\n T << gets.chomp.to_i\nend\nQ.times do\n X << gets.chomp.to_i\nend\n\nX.each do |x|\n si = S.bsearch_index{|v| v >= x}\n sc = []\n if si.nil?\n sc = [S[-1]]\n elsif si.zero?\n sc = [S[0]]\n else\n sc = [S[si-1], S[si]]\n end\n ti = T.bsearch_index{|v| v >= x}\n tc = []\n if ti.nil?\n tc = [T[-1]]\n elsif ti.zero?\n tc = [T[0]]\n else\n tc = [T[ti-1], T[ti]]\n end\n min_cost = Float::INFINITY\n sc.each do |ss|\n tc.each do |tt|\n if (ss <= x && tt <= x) || (ss >= x && tt >= x)\n # 同じ方向\n cost = [(ss-x).abs, (tt-x).abs].max\n else\n # 逆方向\n cost = [(ss - x).abs + (tt - ss).abs, (tt - x).abs + (ss - tt).abs].min\n end\n min_cost = cost if cost < min_cost\n end\n end\n puts min_cost\nend\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAlong a road running in an east-west direction, there are A shrines and B temples.\nThe i-th shrine from the west is located at a distance of s_i meters from the west end of the road, and the i-th temple from the west is located at a distance of t_i meters from the west end of the road.\n\nAnswer the following Q queries:\n\nQuery i (1 \\leq i \\leq Q): If we start from a point at a distance of x_i meters from the west end of the road and freely travel along the road, what is the minimum distance that needs to be traveled in order to visit one shrine and one temple? (It is allowed to pass by more shrines and temples than required.)\n\nConstraints\n\n1 \\leq A, B \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq s_1 < s_2 < ... < s_A \\leq 10^{10}\n\n1 \\leq t_1 < t_2 < ... < t_B \\leq 10^{10}\n\n1 \\leq x_i \\leq 10^{10}\n\ns_1, ..., s_A, t_1, ..., t_B, x_1, ..., x_Q are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B Q\ns_1\n:\ns_A\nt_1\n:\nt_B\nx_1\n:\nx_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\n2 3 4\n100\n600\n400\n900\n1000\n150\n2000\n899\n799\n\nSample Output 1\n\n350\n1400\n301\n399\n\nThere are two shrines and three temples. The shrines are located at distances of 100, 600 meters from the west end of the road, and the temples are located at distances of 400, 900, 1000 meters from the west end of the road.\n\nQuery 1: If we start from a point at a distance of 150 meters from the west end of the road, the optimal move is first to walk 50 meters west to visit a shrine, then to walk 300 meters east to visit a temple.\n\nQuery 2: If we start from a point at a distance of 2000 meters from the west end of the road, the optimal move is first to walk 1000 meters west to visit a temple, then to walk 400 meters west to visit a shrine. We will pass by another temple on the way, but it is fine.\n\nQuery 3: If we start from a point at a distance of 899 meters from the west end of the road, the optimal move is first to walk 1 meter east to visit a temple, then to walk 300 meters west to visit a shrine.\n\nQuery 4: If we start from a point at a distance of 799 meters from the west end of the road, the optimal move is first to walk 199 meters west to visit a shrine, then to walk 200 meters west to visit a temple.\n\nSample Input 2\n\n1 1 3\n1\n10000000000\n2\n9999999999\n5000000000\n\nSample Output 2\n\n10000000000\n10000000000\n14999999998\n\nThe road is quite long, and we may need to travel a distance that does not fit into a 32-bit integer.", "sample_input": "2 3 4\n100\n600\n400\n900\n1000\n150\n2000\n899\n799\n"}, "reference_outputs": ["350\n1400\n301\n399\n"], "source_document_id": "p03112", "source_text": "Score : 400 points\n\nProblem Statement\n\nAlong a road running in an east-west direction, there are A shrines and B temples.\nThe i-th shrine from the west is located at a distance of s_i meters from the west end of the road, and the i-th temple from the west is located at a distance of t_i meters from the west end of the road.\n\nAnswer the following Q queries:\n\nQuery i (1 \\leq i \\leq Q): If we start from a point at a distance of x_i meters from the west end of the road and freely travel along the road, what is the minimum distance that needs to be traveled in order to visit one shrine and one temple? (It is allowed to pass by more shrines and temples than required.)\n\nConstraints\n\n1 \\leq A, B \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq s_1 < s_2 < ... < s_A \\leq 10^{10}\n\n1 \\leq t_1 < t_2 < ... < t_B \\leq 10^{10}\n\n1 \\leq x_i \\leq 10^{10}\n\ns_1, ..., s_A, t_1, ..., t_B, x_1, ..., x_Q are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B Q\ns_1\n:\ns_A\nt_1\n:\nt_B\nx_1\n:\nx_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\n2 3 4\n100\n600\n400\n900\n1000\n150\n2000\n899\n799\n\nSample Output 1\n\n350\n1400\n301\n399\n\nThere are two shrines and three temples. The shrines are located at distances of 100, 600 meters from the west end of the road, and the temples are located at distances of 400, 900, 1000 meters from the west end of the road.\n\nQuery 1: If we start from a point at a distance of 150 meters from the west end of the road, the optimal move is first to walk 50 meters west to visit a shrine, then to walk 300 meters east to visit a temple.\n\nQuery 2: If we start from a point at a distance of 2000 meters from the west end of the road, the optimal move is first to walk 1000 meters west to visit a temple, then to walk 400 meters west to visit a shrine. We will pass by another temple on the way, but it is fine.\n\nQuery 3: If we start from a point at a distance of 899 meters from the west end of the road, the optimal move is first to walk 1 meter east to visit a temple, then to walk 300 meters west to visit a shrine.\n\nQuery 4: If we start from a point at a distance of 799 meters from the west end of the road, the optimal move is first to walk 199 meters west to visit a shrine, then to walk 200 meters west to visit a temple.\n\nSample Input 2\n\n1 1 3\n1\n10000000000\n2\n9999999999\n5000000000\n\nSample Output 2\n\n10000000000\n10000000000\n14999999998\n\nThe road is quite long, and we may need to travel a distance that 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": 872, "cpu_time_ms": 829, "memory_kb": 5624}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s224915741", "group_id": "codeNet:p03125", "input_text": "(a, b) = gets.chomp.split(' ').map(&:to_i)\n\nif a % b == 0 then\n puts (a + b).to_s\nelse\n puts (b - a).to_s\nend", "language": "Ruby", "metadata": {"date": 1550376414, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03125.html", "problem_id": "p03125", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03125/input.txt", "sample_output_relpath": "derived/input_output/data/p03125/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03125/Ruby/s224915741.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s224915741", "user_id": "u198355306"}, "prompt_components": {"gold_output": "16\n", "input_to_evaluate": "(a, b) = gets.chomp.split(' ').map(&:to_i)\n\nif a % b == 0 then\n puts (a + b).to_s\nelse\n puts (b - a).to_s\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nSample Input 1\n\n4 12\n\nSample Output 1\n\n16\n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\nSample Input 2\n\n8 20\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n2\n\n1 is a divisor of 1.", "sample_input": "4 12\n"}, "reference_outputs": ["16\n"], "source_document_id": "p03125", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nSample Input 1\n\n4 12\n\nSample Output 1\n\n16\n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\nSample Input 2\n\n8 20\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n2\n\n1 is a divisor of 1.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 111, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s643983587", "group_id": "codeNet:p03126", "input_text": "# coding: utf-8\nclass Case02\n\n def initialize\n end\n\n def show\n p self.instance_variables\n .map{ |sym| [sym, self.instance_variable_get(sym)] }\n .to_h\n end\n \n # 実行する\n def execute\n read\n solve\n output\n end\n\n # 読込\n def read\n @n, @m = gets.chomp.split.map(&:to_i)\n @k = []\n @a = []\n @n.times do\n t = gets.chomp.split.map(&:to_i)\n @k << t[0]\n @a << t[1..-1]\n end\n end\n\n # 回答\n def solve\n @result = []\n 1.upto(@m) do |i|\n count = 0\n 1.upto(@n) do |j|\n if @a[j-1].include?(i) then\n count += 1\n end\n end\n if count == @n then\n @result << i\n end\n end\n end\n \n # 出力\n def output\n puts @result.count\n end\n\nend\n\n# \nCase02.new.execute if $0 == __FILE__\n\n", "language": "Ruby", "metadata": {"date": 1567556245, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03126.html", "problem_id": "p03126", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03126/input.txt", "sample_output_relpath": "derived/input_output/data/p03126/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03126/Ruby/s643983587.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s643983587", "user_id": "u938270657"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "# coding: utf-8\nclass Case02\n\n def initialize\n end\n\n def show\n p self.instance_variables\n .map{ |sym| [sym, self.instance_variable_get(sym)] }\n .to_h\n end\n \n # 実行する\n def execute\n read\n solve\n output\n end\n\n # 読込\n def read\n @n, @m = gets.chomp.split.map(&:to_i)\n @k = []\n @a = []\n @n.times do\n t = gets.chomp.split.map(&:to_i)\n @k << t[0]\n @a << t[1..-1]\n end\n end\n\n # 回答\n def solve\n @result = []\n 1.upto(@m) do |i|\n count = 0\n 1.upto(@n) do |j|\n if @a[j-1].include?(i) then\n count += 1\n end\n end\n if count == @n then\n @result << i\n end\n end\n end\n \n # 出力\n def output\n puts @result.count\n end\n\nend\n\n# \nCase02.new.execute if $0 == __FILE__\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nKatsusando loves omelette rice.\n\nBesides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.\n\nTo prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.\n\nThe i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.\n\nFind the number of the foods liked by all the N people.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 30\n\n1 \\leq K_i \\leq M\n\n1 \\leq A_{ij} \\leq M\n\nFor each i (1 \\leq i \\leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.\n\nConstraints\n\nInput is given from Standard Input in the following format:\n\nN M\nK_1 A_{11} A_{12} ... A_{1K_1}\nK_2 A_{21} A_{22} ... A_{2K_2}\n:\nK_N A_{N1} A_{N2} ... A_{NK_N}\n\nOutput\n\nPrint the number of the foods liked by all the N people.\n\nSample Input 1\n\n3 4\n2 1 3\n3 1 2 3\n2 3 2\n\nSample Output 1\n\n1\n\nAs only the third food is liked by all the three people, 1 should be printed.\n\nSample Input 2\n\n5 5\n4 2 3 4 5\n4 1 3 4 5\n4 1 2 4 5\n4 1 2 3 5\n4 1 2 3 4\n\nSample Output 2\n\n0\n\nKatsusando's hypothesis turned out to be wrong.\n\nSample Input 3\n\n1 30\n3 5 10 30\n\nSample Output 3\n\n3", "sample_input": "3 4\n2 1 3\n3 1 2 3\n2 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03126", "source_text": "Score : 200 points\n\nProblem Statement\n\nKatsusando loves omelette rice.\n\nBesides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.\n\nTo prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.\n\nThe i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.\n\nFind the number of the foods liked by all the N people.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 30\n\n1 \\leq K_i \\leq M\n\n1 \\leq A_{ij} \\leq M\n\nFor each i (1 \\leq i \\leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.\n\nConstraints\n\nInput is given from Standard Input in the following format:\n\nN M\nK_1 A_{11} A_{12} ... A_{1K_1}\nK_2 A_{21} A_{22} ... A_{2K_2}\n:\nK_N A_{N1} A_{N2} ... A_{NK_N}\n\nOutput\n\nPrint the number of the foods liked by all the N people.\n\nSample Input 1\n\n3 4\n2 1 3\n3 1 2 3\n2 3 2\n\nSample Output 1\n\n1\n\nAs only the third food is liked by all the three people, 1 should be printed.\n\nSample Input 2\n\n5 5\n4 2 3 4 5\n4 1 3 4 5\n4 1 2 4 5\n4 1 2 3 5\n4 1 2 3 4\n\nSample Output 2\n\n0\n\nKatsusando's hypothesis turned out to be wrong.\n\nSample Input 3\n\n1 30\n3 5 10 30\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 798, "cpu_time_ms": 7, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s714625293", "group_id": "codeNet:p03128", "input_text": "cost_map = {\n 1 => 2,\n 2 => 5,\n 3 => 5,\n 4 => 4,\n 5 => 5,\n 6 => 6,\n 7 => 3,\n 8 => 7,\n 9 => 6\n}\n\nn, m = gets.split(\" \").map {|s| s.to_i}\navailable_numbers = gets.split(\" \").map {|s| s.to_i}\n\n# 候補となる数字を抽出(コスパの悪い数字は最初から候補に入れないようにする & 候補は素数になるはず)\nuse_numbers = []\ncosts_per_use_number = []\navailable_numbers.sort.reverse.each { |number|\n cost_per_number = cost_map[number]\n\n if costs_per_use_number.all? { |cost_per_use_number| cost_per_number % cost_per_use_number != 0} then\n costs_per_use_number.each { |cost_per_use_number|# fixme: すごく汚い実装になってしまった。後で直すか\n if (cost_per_use_number % cost_per_number == 0) && (cost_per_use_number / cost_per_number > 1) then\n costs_per_use_number.delete(cost_per_use_number)\n use_numbers = use_numbers.select {|n| cost_map[n] != cost_per_use_number }\n end\n }\n\n use_numbers.push(number)\n costs_per_use_number.push(cost_per_number)\n end\n}\n\n\n# 桁数が最大となる組み合わせを見つける\nlcm = costs_per_use_number.reduce(1) {|gcd_acc, cost_per_use_number| gcd_acc.lcm(cost_per_use_number)}\nmin_cost_number = use_numbers.min {|a, b| cost_map[a] <=> cost_map[b]}\ndigits_of_min_repeated_with_lcm = (n / lcm) * (lcm / cost_map[min_cost_number])\nrest = n % lcm\n\nmax_permutations = [[]] # 棒が0本の時は空\n(1..rest).each { |stick_number|\n use_numbers.each { |number|\n cost_per_number = cost_map[number]\n stick_number_before = stick_number - cost_per_number\n\n if stick_number_before >= 0 then\n max_permutation_before = max_permutations[stick_number_before]\n\n unless max_permutation_before.nil? then\n permutation = max_permutation_before.clone.push(number).sort.reverse\n max_permutation = max_permutations[stick_number]\n if max_permutation.nil? then\n max_permutations[stick_number] = permutation\n elsif (permutation.size > max_permutation.size) || ((permutation.size == max_permutation.size) && ((permutation <=> max_permutation) == 1)) then\n max_permutations[stick_number] = permutation\n end\n end\n end\n }\n}\n\nmax_permutation = (max_permutations[rest] + Array.new(digits_of_min_repeated_with_lcm, min_cost_number)).sort.reverse\n\nputs(max_permutation.join)\n", "language": "Ruby", "metadata": {"date": 1550478306, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03128.html", "problem_id": "p03128", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03128/input.txt", "sample_output_relpath": "derived/input_output/data/p03128/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03128/Ruby/s714625293.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s714625293", "user_id": "u929258317"}, "prompt_components": {"gold_output": "777773\n", "input_to_evaluate": "cost_map = {\n 1 => 2,\n 2 => 5,\n 3 => 5,\n 4 => 4,\n 5 => 5,\n 6 => 6,\n 7 => 3,\n 8 => 7,\n 9 => 6\n}\n\nn, m = gets.split(\" \").map {|s| s.to_i}\navailable_numbers = gets.split(\" \").map {|s| s.to_i}\n\n# 候補となる数字を抽出(コスパの悪い数字は最初から候補に入れないようにする & 候補は素数になるはず)\nuse_numbers = []\ncosts_per_use_number = []\navailable_numbers.sort.reverse.each { |number|\n cost_per_number = cost_map[number]\n\n if costs_per_use_number.all? { |cost_per_use_number| cost_per_number % cost_per_use_number != 0} then\n costs_per_use_number.each { |cost_per_use_number|# fixme: すごく汚い実装になってしまった。後で直すか\n if (cost_per_use_number % cost_per_number == 0) && (cost_per_use_number / cost_per_number > 1) then\n costs_per_use_number.delete(cost_per_use_number)\n use_numbers = use_numbers.select {|n| cost_map[n] != cost_per_use_number }\n end\n }\n\n use_numbers.push(number)\n costs_per_use_number.push(cost_per_number)\n end\n}\n\n\n# 桁数が最大となる組み合わせを見つける\nlcm = costs_per_use_number.reduce(1) {|gcd_acc, cost_per_use_number| gcd_acc.lcm(cost_per_use_number)}\nmin_cost_number = use_numbers.min {|a, b| cost_map[a] <=> cost_map[b]}\ndigits_of_min_repeated_with_lcm = (n / lcm) * (lcm / cost_map[min_cost_number])\nrest = n % lcm\n\nmax_permutations = [[]] # 棒が0本の時は空\n(1..rest).each { |stick_number|\n use_numbers.each { |number|\n cost_per_number = cost_map[number]\n stick_number_before = stick_number - cost_per_number\n\n if stick_number_before >= 0 then\n max_permutation_before = max_permutations[stick_number_before]\n\n unless max_permutation_before.nil? then\n permutation = max_permutation_before.clone.push(number).sort.reverse\n max_permutation = max_permutations[stick_number]\n if max_permutation.nil? then\n max_permutations[stick_number] = permutation\n elsif (permutation.size > max_permutation.size) || ((permutation.size == max_permutation.size) && ((permutation <=> max_permutation) == 1)) then\n max_permutations[stick_number] = permutation\n end\n end\n end\n }\n}\n\nmax_permutation = (max_permutations[rest] + Array.new(digits_of_min_repeated_with_lcm, min_cost_number)).sort.reverse\n\nputs(max_permutation.join)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFind the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n\nEvery digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n\nThe number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^4\n\n1 \\leq M \\leq 9\n\n1 \\leq A_i \\leq 9\n\nA_i are all different.\n\nThere exists an integer that can be formed by exactly N matchsticks under the conditions.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the largest integer that can be formed with exactly N matchsticks under the conditions in the problem statement.\n\nSample Input 1\n\n20 4\n3 7 8 4\n\nSample Output 1\n\n777773\n\nThe integer 777773 can be formed with 3 + 3 + 3 + 3 + 3 + 5 = 20 matchsticks, and this is the largest integer that can be formed by 20 matchsticks under the conditions.\n\nSample Input 2\n\n101 9\n9 8 7 6 5 4 3 2 1\n\nSample Output 2\n\n71111111111111111111111111111111111111111111111111\n\nThe output may not fit into a 64-bit integer type.\n\nSample Input 3\n\n15 3\n5 4 6\n\nSample Output 3\n\n654", "sample_input": "20 4\n3 7 8 4\n"}, "reference_outputs": ["777773\n"], "source_document_id": "p03128", "source_text": "Score : 400 points\n\nProblem Statement\n\nFind the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n\nEvery digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n\nThe number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^4\n\n1 \\leq M \\leq 9\n\n1 \\leq A_i \\leq 9\n\nA_i are all different.\n\nThere exists an integer that can be formed by exactly N matchsticks under the conditions.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the largest integer that can be formed with exactly N matchsticks under the conditions in the problem statement.\n\nSample Input 1\n\n20 4\n3 7 8 4\n\nSample Output 1\n\n777773\n\nThe integer 777773 can be formed with 3 + 3 + 3 + 3 + 3 + 5 = 20 matchsticks, and this is the largest integer that can be formed by 20 matchsticks under the conditions.\n\nSample Input 2\n\n101 9\n9 8 7 6 5 4 3 2 1\n\nSample Output 2\n\n71111111111111111111111111111111111111111111111111\n\nThe output may not fit into a 64-bit integer type.\n\nSample Input 3\n\n15 3\n5 4 6\n\nSample Output 3\n\n654", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2354, "cpu_time_ms": 12, "memory_kb": 2556}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s572294786", "group_id": "codeNet:p03128", "input_text": "eval\"N,_,*A=\"+`dd`.split*?,;*d=0;p d[N.times{d<= k \n puts 'Yes'\nelse puts 'No'\nend\n", "language": "Ruby", "metadata": {"date": 1549764360, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03129.html", "problem_id": "p03129", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03129/input.txt", "sample_output_relpath": "derived/input_output/data/p03129/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03129/Ruby/s620985737.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s620985737", "user_id": "u974214237"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "n,k = gets.split(\" \").map!{|i| i.to_i}\nsum = 0\n1.upto(n) do |p|\n if p == 0 or n \n sum += n - 1\nelse sum += n -2 \nend\nend\nif sum >= k \n puts 'Yes'\nelse puts 'No'\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nDetermine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.\n\nConstraints\n\n1\\leq N,K\\leq 100\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nIf we can choose K integers as above, print YES; otherwise, print NO.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\nYES\n\nWe can choose 1 and 3.\n\nSample Input 2\n\n5 5\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n31 10\n\nSample Output 3\n\nYES\n\nSample Input 4\n\n10 90\n\nSample Output 4\n\nNO", "sample_input": "3 2\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03129", "source_text": "Score : 100 points\n\nProblem Statement\n\nDetermine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.\n\nConstraints\n\n1\\leq N,K\\leq 100\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nIf we can choose K integers as above, print YES; otherwise, print NO.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\nYES\n\nWe can choose 1 and 3.\n\nSample Input 2\n\n5 5\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n31 10\n\nSample Output 3\n\nYES\n\nSample Input 4\n\n10 90\n\nSample Output 4\n\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 166, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s773396899", "group_id": "codeNet:p03130", "input_text": "x = [0, 0, 0, 0]\nfor n in 0..2\n a, b = gets.chomp.split.map(&:to_i)\n x[a - 1] = x[a - 1] + 1\n x[b - 1] = x[b - 1] + 1\nend\nif x.max > 2 or x.min < 1\n puts \"NO\"\n exit\nelse\n puts \"YES\"\nend\n", "language": "Ruby", "metadata": {"date": 1549765658, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03130.html", "problem_id": "p03130", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03130/input.txt", "sample_output_relpath": "derived/input_output/data/p03130/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03130/Ruby/s773396899.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s773396899", "user_id": "u411903982"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "x = [0, 0, 0, 0]\nfor n in 0..2\n a, b = gets.chomp.split.map(&:to_i)\n x[a - 1] = x[a - 1] + 1\n x[b - 1] = x[b - 1] + 1\nend\nif x.max > 2 or x.min < 1\n puts \"NO\"\n exit\nelse\n puts \"YES\"\nend\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are four towns, numbered 1,2,3 and 4.\nAlso, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally.\nNo two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads.\n\nDetermine if we can visit all the towns by traversing each of the roads exactly once.\n\nConstraints\n\n1 \\leq a_i,b_i \\leq 4(1\\leq i\\leq 3)\n\na_i and b_i are different. (1\\leq i\\leq 3)\n\nNo two roads connect the same pair of towns.\n\nAny town can be reached from any other town using the roads.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na_1 b_1\na_2 b_2\na_3 b_3\n\nOutput\n\nIf we can visit all the towns by traversing each of the roads exactly once, print YES; otherwise, print NO.\n\nSample Input 1\n\n4 2\n1 3\n2 3\n\nSample Output 1\n\nYES\n\nWe can visit all the towns in the order 1,3,2,4.\n\nSample Input 2\n\n3 2\n2 4\n1 2\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n2 1\n3 2\n4 3\n\nSample Output 3\n\nYES", "sample_input": "4 2\n1 3\n2 3\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03130", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are four towns, numbered 1,2,3 and 4.\nAlso, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally.\nNo two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads.\n\nDetermine if we can visit all the towns by traversing each of the roads exactly once.\n\nConstraints\n\n1 \\leq a_i,b_i \\leq 4(1\\leq i\\leq 3)\n\na_i and b_i are different. (1\\leq i\\leq 3)\n\nNo two roads connect the same pair of towns.\n\nAny town can be reached from any other town using the roads.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na_1 b_1\na_2 b_2\na_3 b_3\n\nOutput\n\nIf we can visit all the towns by traversing each of the roads exactly once, print YES; otherwise, print NO.\n\nSample Input 1\n\n4 2\n1 3\n2 3\n\nSample Output 1\n\nYES\n\nWe can visit all the towns in the order 1,3,2,4.\n\nSample Input 2\n\n3 2\n2 4\n1 2\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n2 1\n3 2\n4 3\n\nSample Output 3\n\nYES", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 192, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s068870779", "group_id": "codeNet:p03130", "input_text": "sa=Array.new(4,0)\n3.times{\n\ts,e=gets.split(\" \").map(&:to_i)\n\tsa[s-1]+=1\n\tsa[e-1]+=1\n}\ncnt1=0\ncnt2=0\nsa.each{|f|\n\tif f==1\n\t\tcnt1+=1\n\telsif f==2\n\t\tcnt2+=1\n\tend\n}\nif cnt1==2 && cnt2==2\n\tputs \"YES\"\nelse\n\tputs \"NO\"\nend", "language": "Ruby", "metadata": {"date": 1549764646, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03130.html", "problem_id": "p03130", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03130/input.txt", "sample_output_relpath": "derived/input_output/data/p03130/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03130/Ruby/s068870779.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s068870779", "user_id": "u129667379"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "sa=Array.new(4,0)\n3.times{\n\ts,e=gets.split(\" \").map(&:to_i)\n\tsa[s-1]+=1\n\tsa[e-1]+=1\n}\ncnt1=0\ncnt2=0\nsa.each{|f|\n\tif f==1\n\t\tcnt1+=1\n\telsif f==2\n\t\tcnt2+=1\n\tend\n}\nif cnt1==2 && cnt2==2\n\tputs \"YES\"\nelse\n\tputs \"NO\"\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are four towns, numbered 1,2,3 and 4.\nAlso, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally.\nNo two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads.\n\nDetermine if we can visit all the towns by traversing each of the roads exactly once.\n\nConstraints\n\n1 \\leq a_i,b_i \\leq 4(1\\leq i\\leq 3)\n\na_i and b_i are different. (1\\leq i\\leq 3)\n\nNo two roads connect the same pair of towns.\n\nAny town can be reached from any other town using the roads.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na_1 b_1\na_2 b_2\na_3 b_3\n\nOutput\n\nIf we can visit all the towns by traversing each of the roads exactly once, print YES; otherwise, print NO.\n\nSample Input 1\n\n4 2\n1 3\n2 3\n\nSample Output 1\n\nYES\n\nWe can visit all the towns in the order 1,3,2,4.\n\nSample Input 2\n\n3 2\n2 4\n1 2\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n2 1\n3 2\n4 3\n\nSample Output 3\n\nYES", "sample_input": "4 2\n1 3\n2 3\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03130", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are four towns, numbered 1,2,3 and 4.\nAlso, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally.\nNo two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads.\n\nDetermine if we can visit all the towns by traversing each of the roads exactly once.\n\nConstraints\n\n1 \\leq a_i,b_i \\leq 4(1\\leq i\\leq 3)\n\na_i and b_i are different. (1\\leq i\\leq 3)\n\nNo two roads connect the same pair of towns.\n\nAny town can be reached from any other town using the roads.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na_1 b_1\na_2 b_2\na_3 b_3\n\nOutput\n\nIf we can visit all the towns by traversing each of the roads exactly once, print YES; otherwise, print NO.\n\nSample Input 1\n\n4 2\n1 3\n2 3\n\nSample Output 1\n\nYES\n\nWe can visit all the towns in the order 1,3,2,4.\n\nSample Input 2\n\n3 2\n2 4\n1 2\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n2 1\n3 2\n4 3\n\nSample Output 3\n\nYES", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 213, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s043792195", "group_id": "codeNet:p03135", "input_text": "t, x = gets.chomp.split(\" \").map(&:to_i)\n\nputs t / x.to_f", "language": "Ruby", "metadata": {"date": 1576867535, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03135.html", "problem_id": "p03135", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03135/input.txt", "sample_output_relpath": "derived/input_output/data/p03135/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03135/Ruby/s043792195.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s043792195", "user_id": "u333374716"}, "prompt_components": {"gold_output": "2.6666666667\n", "input_to_evaluate": "t, x = gets.chomp.split(\" \").map(&:to_i)\n\nputs t / x.to_f", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn order to pass the entrance examination tomorrow, Taro has to study for T more hours.\n\nFortunately, he can leap to World B where time passes X times as fast as it does in our world (World A).\n\nWhile (X \\times t) hours pass in World B, t hours pass in World A.\n\nHow many hours will pass in World A while Taro studies for T hours in World B?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq T \\leq 100\n\n1 \\leq X \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT X\n\nOutput\n\nPrint the number of hours that will pass in World A.\n\nThe output will be regarded as correct when its absolute or relative error from the judge's output is at most 10^{-3}.\n\nSample Input 1\n\n8 3\n\nSample Output 1\n\n2.6666666667\n\nWhile Taro studies for eight hours in World B where time passes three times as fast, 2.6666... hours will pass in World A.\n\nNote that an absolute or relative error of at most 10^{-3} is allowed.\n\nSample Input 2\n\n99 1\n\nSample Output 2\n\n99.0000000000\n\nSample Input 3\n\n1 100\n\nSample Output 3\n\n0.0100000000", "sample_input": "8 3\n"}, "reference_outputs": ["2.6666666667\n"], "source_document_id": "p03135", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn order to pass the entrance examination tomorrow, Taro has to study for T more hours.\n\nFortunately, he can leap to World B where time passes X times as fast as it does in our world (World A).\n\nWhile (X \\times t) hours pass in World B, t hours pass in World A.\n\nHow many hours will pass in World A while Taro studies for T hours in World B?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq T \\leq 100\n\n1 \\leq X \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT X\n\nOutput\n\nPrint the number of hours that will pass in World A.\n\nThe output will be regarded as correct when its absolute or relative error from the judge's output is at most 10^{-3}.\n\nSample Input 1\n\n8 3\n\nSample Output 1\n\n2.6666666667\n\nWhile Taro studies for eight hours in World B where time passes three times as fast, 2.6666... hours will pass in World A.\n\nNote that an absolute or relative error of at most 10^{-3} is allowed.\n\nSample Input 2\n\n99 1\n\nSample Output 2\n\n99.0000000000\n\nSample Input 3\n\n1 100\n\nSample Output 3\n\n0.0100000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 57, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s012216485", "group_id": "codeNet:p03135", "input_text": "T, X = gets.split.map &:to_f\np T/X\n", "language": "Ruby", "metadata": {"date": 1549245771, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03135.html", "problem_id": "p03135", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03135/input.txt", "sample_output_relpath": "derived/input_output/data/p03135/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03135/Ruby/s012216485.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s012216485", "user_id": "u716826907"}, "prompt_components": {"gold_output": "2.6666666667\n", "input_to_evaluate": "T, X = gets.split.map &:to_f\np T/X\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn order to pass the entrance examination tomorrow, Taro has to study for T more hours.\n\nFortunately, he can leap to World B where time passes X times as fast as it does in our world (World A).\n\nWhile (X \\times t) hours pass in World B, t hours pass in World A.\n\nHow many hours will pass in World A while Taro studies for T hours in World B?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq T \\leq 100\n\n1 \\leq X \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT X\n\nOutput\n\nPrint the number of hours that will pass in World A.\n\nThe output will be regarded as correct when its absolute or relative error from the judge's output is at most 10^{-3}.\n\nSample Input 1\n\n8 3\n\nSample Output 1\n\n2.6666666667\n\nWhile Taro studies for eight hours in World B where time passes three times as fast, 2.6666... hours will pass in World A.\n\nNote that an absolute or relative error of at most 10^{-3} is allowed.\n\nSample Input 2\n\n99 1\n\nSample Output 2\n\n99.0000000000\n\nSample Input 3\n\n1 100\n\nSample Output 3\n\n0.0100000000", "sample_input": "8 3\n"}, "reference_outputs": ["2.6666666667\n"], "source_document_id": "p03135", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn order to pass the entrance examination tomorrow, Taro has to study for T more hours.\n\nFortunately, he can leap to World B where time passes X times as fast as it does in our world (World A).\n\nWhile (X \\times t) hours pass in World B, t hours pass in World A.\n\nHow many hours will pass in World A while Taro studies for T hours in World B?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq T \\leq 100\n\n1 \\leq X \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT X\n\nOutput\n\nPrint the number of hours that will pass in World A.\n\nThe output will be regarded as correct when its absolute or relative error from the judge's output is at most 10^{-3}.\n\nSample Input 1\n\n8 3\n\nSample Output 1\n\n2.6666666667\n\nWhile Taro studies for eight hours in World B where time passes three times as fast, 2.6666... hours will pass in World A.\n\nNote that an absolute or relative error of at most 10^{-3} is allowed.\n\nSample Input 2\n\n99 1\n\nSample Output 2\n\n99.0000000000\n\nSample Input 3\n\n1 100\n\nSample Output 3\n\n0.0100000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 35, "cpu_time_ms": 8, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s602628876", "group_id": "codeNet:p03137", "input_text": "n,m = gets.chomp.split(' ').map(&:to_i)\narr = gets.chomp.split(' ').map(&:to_i).sort.reverse\nans = 0\nintervals = []\ni = 1\nwhile i < arr.size\n intervals << arr[i-1] - arr[i]\n i += 1\nend\nintervals.sort!\nputs intervals[0..(m-n-1)].sum", "language": "Ruby", "metadata": {"date": 1600302078, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p03137.html", "problem_id": "p03137", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03137/input.txt", "sample_output_relpath": "derived/input_output/data/p03137/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03137/Ruby/s602628876.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s602628876", "user_id": "u059126963"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "n,m = gets.chomp.split(' ').map(&:to_i)\narr = gets.chomp.split(' ').map(&:to_i).sort.reverse\nans = 0\nintervals = []\ni = 1\nwhile i < arr.size\n intervals << arr[i-1] - arr[i]\n i += 1\nend\nintervals.sort!\nputs intervals[0..(m-n-1)].sum", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "sample_input": "2 5\n10 12 1 2 14\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03137", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 233, "cpu_time_ms": 123, "memory_kb": 24256}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s910957085", "group_id": "codeNet:p03139", "input_text": "num1 = ARGV[0].to_i\nnum2 = ARGV[1].to_i\nnum3 = ARGV[2].to_i\nnum4 = num3 - (num1 - num2)\nif num2 > num3 then\n num2 = num3\nend\nif num4 < 0 then\n num4 = 0\nend\nputs num2.to_s + \" \" + num4.to_s", "language": "Ruby", "metadata": {"date": 1548642354, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03139.html", "problem_id": "p03139", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03139/input.txt", "sample_output_relpath": "derived/input_output/data/p03139/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03139/Ruby/s910957085.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s910957085", "user_id": "u662318989"}, "prompt_components": {"gold_output": "3 0\n", "input_to_evaluate": "num1 = ARGV[0].to_i\nnum2 = ARGV[1].to_i\nnum3 = ARGV[2].to_i\nnum4 = num3 - (num1 - num2)\nif num2 > num3 then\n num2 = num3\nend\nif num4 < 0 then\n num4 = 0\nend\nputs num2.to_s + \" \" + num4.to_s", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe conducted a survey on newspaper subscriptions.\nMore specifically, we asked each of the N respondents the following two questions:\n\nQuestion 1: Are you subscribing to Newspaper X?\n\nQuestion 2: Are you subscribing to Newspaper Y?\n\nAs the result, A respondents answered \"yes\" to Question 1, and B respondents answered \"yes\" to Question 2.\n\nWhat are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y?\n\nWrite a program to answer this question.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq A \\leq N\n\n0 \\leq B \\leq N\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 maximum possible number and the minimum possible number of respondents subscribing to both newspapers, in this order, with a space in between.\n\nSample Input 1\n\n10 3 5\n\nSample Output 1\n\n3 0\n\nIn this sample, out of the 10 respondents, 3 answered they are subscribing to Newspaper X, and 5 answered they are subscribing to Newspaper Y.\n\nHere, the number of respondents subscribing to both newspapers is at most 3 and at least 0.\n\nSample Input 2\n\n10 7 5\n\nSample Output 2\n\n5 2\n\nIn this sample, out of the 10 respondents, 7 answered they are subscribing to Newspaper X, and 5 answered they are subscribing to Newspaper Y.\n\nHere, the number of respondents subscribing to both newspapers is at most 5 and at least 2.\n\nSample Input 3\n\n100 100 100\n\nSample Output 3\n\n100 100", "sample_input": "10 3 5\n"}, "reference_outputs": ["3 0\n"], "source_document_id": "p03139", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe conducted a survey on newspaper subscriptions.\nMore specifically, we asked each of the N respondents the following two questions:\n\nQuestion 1: Are you subscribing to Newspaper X?\n\nQuestion 2: Are you subscribing to Newspaper Y?\n\nAs the result, A respondents answered \"yes\" to Question 1, and B respondents answered \"yes\" to Question 2.\n\nWhat are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y?\n\nWrite a program to answer this question.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq A \\leq N\n\n0 \\leq B \\leq N\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 maximum possible number and the minimum possible number of respondents subscribing to both newspapers, in this order, with a space in between.\n\nSample Input 1\n\n10 3 5\n\nSample Output 1\n\n3 0\n\nIn this sample, out of the 10 respondents, 3 answered they are subscribing to Newspaper X, and 5 answered they are subscribing to Newspaper Y.\n\nHere, the number of respondents subscribing to both newspapers is at most 3 and at least 0.\n\nSample Input 2\n\n10 7 5\n\nSample Output 2\n\n5 2\n\nIn this sample, out of the 10 respondents, 7 answered they are subscribing to Newspaper X, and 5 answered they are subscribing to Newspaper Y.\n\nHere, the number of respondents subscribing to both newspapers is at most 5 and at least 2.\n\nSample Input 3\n\n100 100 100\n\nSample Output 3\n\n100 100", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 190, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s096954356", "group_id": "codeNet:p03140", "input_text": "N = gets.chomp.to_i\nA = gets.chomp\nB = gets.chomp\nC = gets.chomp\ncount = 0\n0.upto(N-1) do |n|\n match = [A[n], B[n], C[n]].uniq.size\n if match == 2\n count += 1\n elsif match == 3\n count += 2\n end\nend\nputs count", "language": "Ruby", "metadata": {"date": 1548642515, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03140.html", "problem_id": "p03140", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03140/input.txt", "sample_output_relpath": "derived/input_output/data/p03140/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03140/Ruby/s096954356.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s096954356", "user_id": "u254851449"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "N = gets.chomp.to_i\nA = gets.chomp\nB = gets.chomp\nC = gets.chomp\ncount = 0\n0.upto(N-1) do |n|\n match = [A[n], B[n], C[n]].uniq.size\n if match == 2\n count += 1\n elsif match == 3\n count += 2\n end\nend\nputs count", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.\n\nOur objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:\n\nOperation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter.\n\nWhat is the minimum number of operations required to achieve the objective?\n\nConstraints\n\n1 \\leq N \\leq 100\n\nEach of the strings A, B and C is a string of length N.\n\nEach character in each of the strings A, B and C is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4\nwest\neast\nwait\n\nSample Output 1\n\n3\n\nIn this sample, initially A = west、B = east、C = wait. We can achieve the objective in the minimum number of operations by performing three operations as follows:\n\nChange the second character in A to a. A is now wast.\n\nChange the first character in B to w. B is now wast.\n\nChange the third character in C to s. C is now wast.\n\nSample Input 2\n\n9\ndifferent\ndifferent\ndifferent\n\nSample Output 2\n\n0\n\nIf A, B and C are already equal in the beginning, the number of operations required is 0.\n\nSample Input 3\n\n7\nzenkoku\ntouitsu\nprogram\n\nSample Output 3\n\n13", "sample_input": "4\nwest\neast\nwait\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03140", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.\n\nOur objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:\n\nOperation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter.\n\nWhat is the minimum number of operations required to achieve the objective?\n\nConstraints\n\n1 \\leq N \\leq 100\n\nEach of the strings A, B and C is a string of length N.\n\nEach character in each of the strings A, B and C is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4\nwest\neast\nwait\n\nSample Output 1\n\n3\n\nIn this sample, initially A = west、B = east、C = wait. We can achieve the objective in the minimum number of operations by performing three operations as follows:\n\nChange the second character in A to a. A is now wast.\n\nChange the first character in B to w. B is now wast.\n\nChange the third character in C to s. C is now wast.\n\nSample Input 2\n\n9\ndifferent\ndifferent\ndifferent\n\nSample Output 2\n\n0\n\nIf A, B and C are already equal in the beginning, the number of operations required is 0.\n\nSample Input 3\n\n7\nzenkoku\ntouitsu\nprogram\n\nSample Output 3\n\n13", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 218, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s051222663", "group_id": "codeNet:p03141", "input_text": "n = gets.chomp!.to_i\n\ntakahashi = []\naoki = []\ntokuten = []\n\nn.times do |i|\n a, b = gets.chomp!.split(\" \").map(&:to_i)\n takahashi << a\n aoki << -1 * b\n tokuten << { idx: i, point: a + b }\nend\n\nputs tokuten.sort { |t| t[:point] }.map.with_index { |k, idx| idx.even? ? takahashi[k[:idx]] : aoki[k[:idx]] }.inject(:+)\n", "language": "Ruby", "metadata": {"date": 1548644786, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s051222663.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s051222663", "user_id": "u081708706"}, "prompt_components": {"gold_output": "20\n", "input_to_evaluate": "n = gets.chomp!.to_i\n\ntakahashi = []\naoki = []\ntokuten = []\n\nn.times do |i|\n a, b = gets.chomp!.split(\" \").map(&:to_i)\n takahashi << a\n aoki << -1 * b\n tokuten << { idx: i, point: a + b }\nend\n\nputs tokuten.sort { |t| t[:point] }.map.with_index { |k, idx| idx.even? ? takahashi[k[:idx]] : aoki[k[:idx]] }.inject(:+)\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": 319, "cpu_time_ms": 344, "memory_kb": 34536}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s195440064", "group_id": "codeNet:p03142", "input_text": "n, m = gets.split.map(&:to_i)\nchild = Hash.new { |h, k| h[k] = [] }\nparent = Hash.new { |h, k| h[k] = [] }\n(n + m - 1).times do\n a, b = gets.split.map(&:to_i)\n child[a] << b\n parent[b] << a\nend\n\nroot = 1\nuntil parent[root].empty?\n root = parent[root].first\nend\n\nqueue = [root]\nvisited = {}\ndeleted = 0\nuntil queue.empty?\n pos = queue.shift\n child[pos].each do |ch|\n if visited[ch] && parent[ch].size > 1\n parent[ch].delete(visited[ch])\n deleted += 1\n if deleted == m\n break\n end\n end\n visited[ch] = pos\n queue << ch\n end\n if deleted == m\n break\n end\nend\n\n(1..n).each do |i|\n puts(parent[i].first || 0)\nend\n", "language": "Ruby", "metadata": {"date": 1548646316, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s195440064.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s195440064", "user_id": "u003184768"}, "prompt_components": {"gold_output": "0\n1\n2\n", "input_to_evaluate": "n, m = gets.split.map(&:to_i)\nchild = Hash.new { |h, k| h[k] = [] }\nparent = Hash.new { |h, k| h[k] = [] }\n(n + m - 1).times do\n a, b = gets.split.map(&:to_i)\n child[a] << b\n parent[b] << a\nend\n\nroot = 1\nuntil parent[root].empty?\n root = parent[root].first\nend\n\nqueue = [root]\nvisited = {}\ndeleted = 0\nuntil queue.empty?\n pos = queue.shift\n child[pos].each do |ch|\n if visited[ch] && parent[ch].size > 1\n parent[ch].delete(visited[ch])\n deleted += 1\n if deleted == m\n break\n end\n end\n visited[ch] = pos\n queue << ch\n end\n if deleted == m\n break\n end\nend\n\n(1..n).each do |i|\n puts(parent[i].first || 0)\nend\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere is a rooted tree (see Notes) with N vertices numbered 1 to N.\nEach of the vertices, except the root, has a directed edge coming from its parent.\nNote that the root may not be Vertex 1.\n\nTakahashi has added M new directed edges to this graph.\nEach of these M edges, u \\rightarrow v, extends from some vertex u to its descendant v.\n\nYou are given the directed graph with N vertices and N-1+M edges after Takahashi added edges.\nMore specifically, you are given N-1+M pairs of integers, (A_1, B_1), ..., (A_{N-1+M}, B_{N-1+M}), which represent that the i-th edge extends from Vertex A_i to Vertex B_i.\n\nRestore the original rooted tree.\n\nNotes\n\nFor \"tree\" and other related terms in graph theory, see the article in Wikipedia, for example.\n\nConstraints\n\n3 \\leq N\n\n1 \\leq M\n\nN + M \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\nIf i \\neq j, (A_i, B_i) \\neq (A_j, B_j).\n\nThe graph in input can be obtained by adding M edges satisfying the condition in the problem statement to a rooted tree with N vertices.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_{N-1+M} B_{N-1+M}\n\nOutput\n\nPrint N lines.\nIn the i-th line, print 0 if Vertex i is the root of the original tree, and otherwise print the integer representing the parent of Vertex i in the original tree.\n\nNote that it can be shown that the original tree is uniquely determined.\n\nSample Input 1\n\n3 1\n1 2\n1 3\n2 3\n\nSample Output 1\n\n0\n1\n2\n\nThe graph in this input is shown below:\n\nIt can be seen that this graph is obtained by adding the edge 1 \\rightarrow 3 to the rooted tree 1 \\rightarrow 2 \\rightarrow 3.\n\nSample Input 2\n\n6 3\n2 1\n2 3\n4 1\n4 2\n6 1\n2 6\n4 6\n6 5\n\nSample Output 2\n\n6\n4\n2\n0\n6\n2", "sample_input": "3 1\n1 2\n1 3\n2 3\n"}, "reference_outputs": ["0\n1\n2\n"], "source_document_id": "p03142", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere is a rooted tree (see Notes) with N vertices numbered 1 to N.\nEach of the vertices, except the root, has a directed edge coming from its parent.\nNote that the root may not be Vertex 1.\n\nTakahashi has added M new directed edges to this graph.\nEach of these M edges, u \\rightarrow v, extends from some vertex u to its descendant v.\n\nYou are given the directed graph with N vertices and N-1+M edges after Takahashi added edges.\nMore specifically, you are given N-1+M pairs of integers, (A_1, B_1), ..., (A_{N-1+M}, B_{N-1+M}), which represent that the i-th edge extends from Vertex A_i to Vertex B_i.\n\nRestore the original rooted tree.\n\nNotes\n\nFor \"tree\" and other related terms in graph theory, see the article in Wikipedia, for example.\n\nConstraints\n\n3 \\leq N\n\n1 \\leq M\n\nN + M \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\nIf i \\neq j, (A_i, B_i) \\neq (A_j, B_j).\n\nThe graph in input can be obtained by adding M edges satisfying the condition in the problem statement to a rooted tree with N vertices.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_{N-1+M} B_{N-1+M}\n\nOutput\n\nPrint N lines.\nIn the i-th line, print 0 if Vertex i is the root of the original tree, and otherwise print the integer representing the parent of Vertex i in the original tree.\n\nNote that it can be shown that the original tree is uniquely determined.\n\nSample Input 1\n\n3 1\n1 2\n1 3\n2 3\n\nSample Output 1\n\n0\n1\n2\n\nThe graph in this input is shown below:\n\nIt can be seen that this graph is obtained by adding the edge 1 \\rightarrow 3 to the rooted tree 1 \\rightarrow 2 \\rightarrow 3.\n\nSample Input 2\n\n6 3\n2 1\n2 3\n4 1\n4 2\n6 1\n2 6\n4 6\n6 5\n\nSample Output 2\n\n6\n4\n2\n0\n6\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 658, "cpu_time_ms": 1260, "memory_kb": 36220}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s965721114", "group_id": "codeNet:p03145", "input_text": "AB,BC,CA = gets.split.map(&:to_i)\np AB*BC/2", "language": "Ruby", "metadata": {"date": 1553533882, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s965721114.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s965721114", "user_id": "u460049292"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "AB,BC,CA = gets.split.map(&:to_i)\np AB*BC/2", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a right triangle ABC with ∠ABC=90°.\n\nGiven the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.\n\nIt is guaranteed that the area of the triangle ABC is an integer.\n\nConstraints\n\n1 \\leq |AB|,|BC|,|CA| \\leq 100\n\nAll values in input are integers.\n\nThe area of the triangle ABC is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n|AB| |BC| |CA|\n\nOutput\n\nPrint the area of the triangle ABC.\n\nSample Input 1\n\n3 4 5\n\nSample Output 1\n\n6\n\nThis triangle has an area of 6.\n\nSample Input 2\n\n5 12 13\n\nSample Output 2\n\n30\n\nThis triangle has an area of 30.\n\nSample Input 3\n\n45 28 53\n\nSample Output 3\n\n630\n\nThis triangle has an area of 630.", "sample_input": "3 4 5\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03145", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a right triangle ABC with ∠ABC=90°.\n\nGiven the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.\n\nIt is guaranteed that the area of the triangle ABC is an integer.\n\nConstraints\n\n1 \\leq |AB|,|BC|,|CA| \\leq 100\n\nAll values in input are integers.\n\nThe area of the triangle ABC is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n|AB| |BC| |CA|\n\nOutput\n\nPrint the area of the triangle ABC.\n\nSample Input 1\n\n3 4 5\n\nSample Output 1\n\n6\n\nThis triangle has an area of 6.\n\nSample Input 2\n\n5 12 13\n\nSample Output 2\n\n30\n\nThis triangle has an area of 30.\n\nSample Input 3\n\n45 28 53\n\nSample Output 3\n\n630\n\nThis triangle has an area of 630.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 43, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s529755309", "group_id": "codeNet:p03146", "input_text": "n = gets.to_i\nary = [n]\ncnt = 1\nwhile(true)\n n = n.odd? ? 3*n+1 : n/2\n if ary.include?(n)\n puts cnt + 1\n exit\n end\n ary << n\n cnt += 1\nend\n", "language": "Ruby", "metadata": {"date": 1584570358, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s529755309.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s529755309", "user_id": "u585819925"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "n = gets.to_i\nary = [n]\ncnt = 1\nwhile(true)\n n = n.odd? ? 3*n+1 : n/2\n if ary.include?(n)\n puts cnt + 1\n exit\n end\n ary << n\n cnt += 1\nend\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "sample_input": "8\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03146", "source_text": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 150, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s370404024", "group_id": "codeNet:p03147", "input_text": "n=gets.to_i\nh=gets.split.map(&:to_i)\nc = 0\n100.times do |i|\n f = false\n n.times do |j|\n if !f && h[j] > i\n f = true\n c += 1\n elsif f && h[j] <= i\n f = false\n end\n end\nend\np c", "language": "Ruby", "metadata": {"date": 1569532620, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03147.html", "problem_id": "p03147", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03147/input.txt", "sample_output_relpath": "derived/input_output/data/p03147/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03147/Ruby/s370404024.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s370404024", "user_id": "u744908753"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n=gets.to_i\nh=gets.split.map(&:to_i)\nc = 0\n100.times do |i|\n f = false\n n.times do |j|\n if !f && h[j] > i\n f = true\n c += 1\n elsif f && h[j] <= i\n f = false\n end\n end\nend\np c", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0.\nYou are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \\leq k \\leq N), by repeating the following \"watering\" operation:\n\nSpecify integers l and r. Increase the height of Flower x by 1 for all x such that l \\leq x \\leq r.\n\nFind the minimum number of watering operations required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq h_i \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 h_3 ...... h_N\n\nOutput\n\nPrint the minimum number of watering operations required to satisfy the condition.\n\nSample Input 1\n\n4\n1 2 2 1\n\nSample Output 1\n\n2\n\nThe minimum number of watering operations required is 2.\nOne way to achieve it is:\n\nPerform the operation with (l,r)=(1,3).\n\nPerform the operation with (l,r)=(2,4).\n\nSample Input 2\n\n5\n3 1 2 3 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n8\n4 23 75 0 23 96 50 100\n\nSample Output 3\n\n221", "sample_input": "4\n1 2 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03147", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0.\nYou are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \\leq k \\leq N), by repeating the following \"watering\" operation:\n\nSpecify integers l and r. Increase the height of Flower x by 1 for all x such that l \\leq x \\leq r.\n\nFind the minimum number of watering operations required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq h_i \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 h_3 ...... h_N\n\nOutput\n\nPrint the minimum number of watering operations required to satisfy the condition.\n\nSample Input 1\n\n4\n1 2 2 1\n\nSample Output 1\n\n2\n\nThe minimum number of watering operations required is 2.\nOne way to achieve it is:\n\nPerform the operation with (l,r)=(1,3).\n\nPerform the operation with (l,r)=(2,4).\n\nSample Input 2\n\n5\n3 1 2 3 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n8\n4 23 75 0 23 96 50 100\n\nSample Output 3\n\n221", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 201, "cpu_time_ms": 8, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s151638625", "group_id": "codeNet:p03151", "input_text": "n, as, bs = ARGF.read.split(\"\\n\").map { |e| e.split }\nxs = as.zip(bs).map { |e|\n a,b = e.map { |e| e.to_i }\n [a, b, a - b]\n}.sort { |e| e.last }\nms = xs.select { |e|\n e.last < 0\n}\nps = xs.select { |e|\n e.last > 0\n}\nif ms.length == 0\n puts 0\n exit\nend\n\nc = ms.length\nval = 0\nms.each { |e|\n if val <= e.last.abs\n loop {\n if ps.length == 0\n puts -1\n exit\n else\n val += ps.pop.last\n c += 1\n if val > e.last.abs\n val -= e.last.abs\n break\n end\n end\n }\n end\n}\nputs c\n", "language": "Ruby", "metadata": {"date": 1547412437, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03151.html", "problem_id": "p03151", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03151/input.txt", "sample_output_relpath": "derived/input_output/data/p03151/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03151/Ruby/s151638625.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s151638625", "user_id": "u141733664"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "n, as, bs = ARGF.read.split(\"\\n\").map { |e| e.split }\nxs = as.zip(bs).map { |e|\n a,b = e.map { |e| e.to_i }\n [a, b, a - b]\n}.sort { |e| e.last }\nms = xs.select { |e|\n e.last < 0\n}\nps = xs.select { |e|\n e.last > 0\n}\nif ms.length == 0\n puts 0\n exit\nend\n\nc = ms.length\nval = 0\nms.each { |e|\n if val <= e.last.abs\n loop {\n if ps.length == 0\n puts -1\n exit\n else\n val += ps.pop.last\n c += 1\n if val > e.last.abs\n val -= e.last.abs\n break\n end\n end\n }\n end\n}\nputs c\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA university student, Takahashi, has to take N examinations and pass all of them.\nCurrently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.\n\nTakahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.\n\nFor Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:\n\nThe sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.\n\nFor every i, B_i \\leq C_i holds.\n\nIf such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nA_i and B_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N}\nB_1 B_2 ... B_{N}\n\nOutput\n\nPrint the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.\nIf such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.\n\nSample Input 1\n\n3\n2 3 5\n3 4 1\n\nSample Output 1\n\n3\n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is done, he cannot pass the first and second exams.\nThe minimum possible number of indices i such that A_i and C_i are different, 3, is achieved when:\n\n(C_1, C_2, C_3) = (3, 5, 2)\n\nSample Input 2\n\n3\n2 3 3\n2 2 1\n\nSample Output 2\n\n0\n\nIn this case, he has to do nothing in order to pass all the exams.\n\nSample Input 3\n\n3\n17 7 1\n25 6 14\n\nSample Output 3\n\n-1\n\nIn this case, no matter what is done, he cannot pass all the exams.\n\nSample Input 4\n\n12\n757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212\n\nSample Output 4\n\n5", "sample_input": "3\n2 3 5\n3 4 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03151", "source_text": "Score : 400 points\n\nProblem Statement\n\nA university student, Takahashi, has to take N examinations and pass all of them.\nCurrently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.\n\nTakahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.\n\nFor Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:\n\nThe sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.\n\nFor every i, B_i \\leq C_i holds.\n\nIf such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nA_i and B_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N}\nB_1 B_2 ... B_{N}\n\nOutput\n\nPrint the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.\nIf such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.\n\nSample Input 1\n\n3\n2 3 5\n3 4 1\n\nSample Output 1\n\n3\n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is done, he cannot pass the first and second exams.\nThe minimum possible number of indices i such that A_i and C_i are different, 3, is achieved when:\n\n(C_1, C_2, C_3) = (3, 5, 2)\n\nSample Input 2\n\n3\n2 3 3\n2 2 1\n\nSample Output 2\n\n0\n\nIn this case, he has to do nothing in order to pass all the exams.\n\nSample Input 3\n\n3\n17 7 1\n25 6 14\n\nSample Output 3\n\n-1\n\nIn this case, no matter what is done, he cannot pass all the exams.\n\nSample Input 4\n\n12\n757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212\n\nSample Output 4\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 549, "cpu_time_ms": 257, "memory_kb": 30828}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s102187080", "group_id": "codeNet:p03157", "input_text": "h, w = gets.split.map(&:to_i)\nlist = h.times.map{ gets.chomp.split('') }\ns = list.flatten.map.with_index{ |c, i| i if c == '#' }.compact\nmove = [[-1, 0], [0, 1], [1, 0], [0, -1]]\nans = 0\n\ns.each do |i|\n x = i % w\n y = i / w\n q = [[x, y, 0]]\n visited = h.times.map{ [false] * w }\n visited[y][x] = true\n until q.empty?\n x, y, color = q.shift\n move.each do |mx, my|\n nx = x + mx\n ny = y + my\n if 0 <= nx && nx < w && 0 <= ny && ny < h\n if !visited[ny][nx]\n visited[ny][nx] = true\n if color == 0 && list[ny][nx] == '.' || color == 1 && list[ny][nx] == '#'\n q << [nx, ny, 1 - color]\n if color == 0\n ans += 1\n end\n end\n end\n end\n end\n end\nend\nputs ans\n \n\n", "language": "Ruby", "metadata": {"date": 1547328429, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s102187080.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s102187080", "user_id": "u331906013"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "h, w = gets.split.map(&:to_i)\nlist = h.times.map{ gets.chomp.split('') }\ns = list.flatten.map.with_index{ |c, i| i if c == '#' }.compact\nmove = [[-1, 0], [0, 1], [1, 0], [0, -1]]\nans = 0\n\ns.each do |i|\n x = i % w\n y = i / w\n q = [[x, y, 0]]\n visited = h.times.map{ [false] * w }\n visited[y][x] = true\n until q.empty?\n x, y, color = q.shift\n move.each do |mx, my|\n nx = x + mx\n ny = y + my\n if 0 <= nx && nx < w && 0 <= ny && ny < h\n if !visited[ny][nx]\n visited[ny][nx] = true\n if color == 0 && list[ny][nx] == '.' || color == 1 && list[ny][nx] == '#'\n q << [nx, ny, 1 - color]\n if color == 0\n ans += 1\n end\n end\n end\n end\n end\n end\nend\nputs 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": 776, "cpu_time_ms": 2113, "memory_kb": 93016}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s769812701", "group_id": "codeNet:p03169", "input_text": "n = gets.to_i\n\na = gets.split.map(&:to_i)\na1 = a.count(1)\na2 = a.count(2)\na3 = a.count(3)\n\nm = a2 + a3\nd = Array.new(m+1) {Array.new(n+1, 0.0)}\nu = Array.new(m+1) {Array.new(n+1, 0.0)}\n\n(a3+1).times do |c3|\n (m-c3+1).times do |c2|\n (n-c2-c3+1).times do |c1|\n t = c1 + c2 + c3\n next if t == 0\n s = n.to_f\n s += u[c2][c1-1] * c1 if c1 > 0\n s += u[c2-1][c1+1] * c2 if c2 > 0\n s += d[c2+1][c1] * c3 if c3 > 0\n u[c2][c1] = s / t\n end\n end\n d, u = u, d\nend\n\np d[a2][a1]", "language": "Ruby", "metadata": {"date": 1598559011, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p03169.html", "problem_id": "p03169", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03169/input.txt", "sample_output_relpath": "derived/input_output/data/p03169/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03169/Ruby/s769812701.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s769812701", "user_id": "u692254521"}, "prompt_components": {"gold_output": "5.5\n", "input_to_evaluate": "n = gets.to_i\n\na = gets.split.map(&:to_i)\na1 = a.count(1)\na2 = a.count(2)\na3 = a.count(3)\n\nm = a2 + a3\nd = Array.new(m+1) {Array.new(n+1, 0.0)}\nu = Array.new(m+1) {Array.new(n+1, 0.0)}\n\n(a3+1).times do |c3|\n (m-c3+1).times do |c2|\n (n-c2-c3+1).times do |c1|\n t = c1 + c2 + c3\n next if t == 0\n s = n.to_f\n s += u[c2][c1-1] * c1 if c1 > 0\n s += u[c2-1][c1+1] * c2 if c2 > 0\n s += d[c2+1][c1] * c3 if c3 > 0\n u[c2][c1] = s / t\n end\n end\n d, u = u, d\nend\n\np d[a2][a1]", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N dishes, numbered 1, 2, \\ldots, N.\nInitially, for each i (1 \\leq i \\leq N), Dish i has a_i (1 \\leq a_i \\leq 3) pieces of sushi on it.\n\nTaro will perform the following operation repeatedly until all the pieces of sushi are eaten:\n\nRoll a die that shows the numbers 1, 2, \\ldots, N with equal probabilities, and let i be the outcome. If there are some pieces of sushi on Dish i, eat one of them; if there is none, do nothing.\n\nFind the expected number of times the operation is performed before all the pieces of sushi are eaten.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 300\n\n1 \\leq a_i \\leq 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the expected number of times the operation is performed before all the pieces of sushi are eaten.\nThe output is considered correct when the relative difference is not greater than 10^{-9}.\n\nSample Input 1\n\n3\n1 1 1\n\nSample Output 1\n\n5.5\n\nThe expected number of operations before the first piece of sushi is eaten, is 1.\nAfter that, the expected number of operations before the second sushi is eaten, is 1.5.\nAfter that, the expected number of operations before the third sushi is eaten, is 3.\nThus, the expected total number of operations is 1 + 1.5 + 3 = 5.5.\n\nSample Input 2\n\n1\n3\n\nSample Output 2\n\n3\n\nOutputs such as 3.00, 3.000000003 and 2.999999997 will also be accepted.\n\nSample Input 3\n\n2\n1 2\n\nSample Output 3\n\n4.5\n\nSample Input 4\n\n10\n1 3 2 3 3 2 3 2 1 3\n\nSample Output 4\n\n54.48064457488221", "sample_input": "3\n1 1 1\n"}, "reference_outputs": ["5.5\n"], "source_document_id": "p03169", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N dishes, numbered 1, 2, \\ldots, N.\nInitially, for each i (1 \\leq i \\leq N), Dish i has a_i (1 \\leq a_i \\leq 3) pieces of sushi on it.\n\nTaro will perform the following operation repeatedly until all the pieces of sushi are eaten:\n\nRoll a die that shows the numbers 1, 2, \\ldots, N with equal probabilities, and let i be the outcome. If there are some pieces of sushi on Dish i, eat one of them; if there is none, do nothing.\n\nFind the expected number of times the operation is performed before all the pieces of sushi are eaten.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 300\n\n1 \\leq a_i \\leq 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the expected number of times the operation is performed before all the pieces of sushi are eaten.\nThe output is considered correct when the relative difference is not greater than 10^{-9}.\n\nSample Input 1\n\n3\n1 1 1\n\nSample Output 1\n\n5.5\n\nThe expected number of operations before the first piece of sushi is eaten, is 1.\nAfter that, the expected number of operations before the second sushi is eaten, is 1.5.\nAfter that, the expected number of operations before the third sushi is eaten, is 3.\nThus, the expected total number of operations is 1 + 1.5 + 3 = 5.5.\n\nSample Input 2\n\n1\n3\n\nSample Output 2\n\n3\n\nOutputs such as 3.00, 3.000000003 and 2.999999997 will also be accepted.\n\nSample Input 3\n\n2\n1 2\n\nSample Output 3\n\n4.5\n\nSample Input 4\n\n10\n1 3 2 3 3 2 3 2 1 3\n\nSample Output 4\n\n54.48064457488221", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 563, "cpu_time_ms": 1384, "memory_kb": 15628}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s286577281", "group_id": "codeNet:p03178", "input_text": "class Integer\n def digit_sum_multiple_count(div, mod = 10 ** 9 + 7)\n s = self.to_s\n l = s.size\n\n dpA = Array.new(l + 1) { Array.new(div, 0) }\n dpB = Array.new(l + 1) { Array.new(div, 0) }\n dpA[0][0] = 1\n\n l.times do |i|\n n = s[i].to_i\n\n 0.upto(div - 1) do |j|\n if dpA[i][j] > 0\n dpA[i + 1][(j + n) % div] = dpA[i][j]\n\n if i > 0\n 0.upto(n - 1) do |k|\n dpB[i + 1][(j + k) % div] += 1\n end\n end\n end\n\n if dpB[i][j] > 0\n 0.upto(9) do |k|\n dpB[i + 1][(j + k) % div] += dpB[i][j]\n dpB[i + 1][(j + k) % div] += mod\n end\n end\n end\n\n 1.upto(9) do |k|\n next if i == 0 && k >= n\n dpB[i + 1][k % div] += 1\n end\n end\n\n (dpA[l][0] + dpB[l][0]) % mod\n end\nend\n\nK = gets.to_i\nD = gets.to_i\n\nputs K.digit_sum_multiple_count(D)\n", "language": "Ruby", "metadata": {"date": 1582976875, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03178.html", "problem_id": "p03178", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03178/input.txt", "sample_output_relpath": "derived/input_output/data/p03178/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03178/Ruby/s286577281.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s286577281", "user_id": "u740836226"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "class Integer\n def digit_sum_multiple_count(div, mod = 10 ** 9 + 7)\n s = self.to_s\n l = s.size\n\n dpA = Array.new(l + 1) { Array.new(div, 0) }\n dpB = Array.new(l + 1) { Array.new(div, 0) }\n dpA[0][0] = 1\n\n l.times do |i|\n n = s[i].to_i\n\n 0.upto(div - 1) do |j|\n if dpA[i][j] > 0\n dpA[i + 1][(j + n) % div] = dpA[i][j]\n\n if i > 0\n 0.upto(n - 1) do |k|\n dpB[i + 1][(j + k) % div] += 1\n end\n end\n end\n\n if dpB[i][j] > 0\n 0.upto(9) do |k|\n dpB[i + 1][(j + k) % div] += dpB[i][j]\n dpB[i + 1][(j + k) % div] += mod\n end\n end\n end\n\n 1.upto(9) do |k|\n next if i == 0 && k >= n\n dpB[i + 1][k % div] += 1\n end\n end\n\n (dpA[l][0] + dpB[l][0]) % mod\n end\nend\n\nK = gets.to_i\nD = gets.to_i\n\nputs K.digit_sum_multiple_count(D)\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nFind the number of integers between 1 and K (inclusive) satisfying the following condition, modulo 10^9 + 7:\n\nThe sum of the digits in base ten is a multiple of D.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq K < 10^{10000}\n\n1 \\leq D \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nD\n\nOutput\n\nPrint the number of integers satisfying the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n30\n4\n\nSample Output 1\n\n6\n\nThose six integers are: 4, 8, 13, 17, 22 and 26.\n\nSample Input 2\n\n1000000009\n1\n\nSample Output 2\n\n2\n\nBe sure to print the number modulo 10^9 + 7.\n\nSample Input 3\n\n98765432109876543210\n58\n\nSample Output 3\n\n635270834", "sample_input": "30\n4\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03178", "source_text": "Score : 100 points\n\nProblem Statement\n\nFind the number of integers between 1 and K (inclusive) satisfying the following condition, modulo 10^9 + 7:\n\nThe sum of the digits in base ten is a multiple of D.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq K < 10^{10000}\n\n1 \\leq D \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nD\n\nOutput\n\nPrint the number of integers satisfying the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n30\n4\n\nSample Output 1\n\n6\n\nThose six integers are: 4, 8, 13, 17, 22 and 26.\n\nSample Input 2\n\n1000000009\n1\n\nSample Output 2\n\n2\n\nBe sure to print the number modulo 10^9 + 7.\n\nSample Input 3\n\n98765432109876543210\n58\n\nSample Output 3\n\n635270834", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 905, "cpu_time_ms": 2123, "memory_kb": 253564}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s135811700", "group_id": "codeNet:p03192", "input_text": "puts gets.chomp.chars.count(\"2\")\n", "language": "Ruby", "metadata": {"date": 1545530464, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03192.html", "problem_id": "p03192", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03192/input.txt", "sample_output_relpath": "derived/input_output/data/p03192/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03192/Ruby/s135811700.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s135811700", "user_id": "u785521224"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "puts gets.chomp.chars.count(\"2\")\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given an integer N that has exactly four digits in base ten.\nHow many times does 2 occur in the base-ten representation of N?\n\nConstraints\n\n1000 \\leq N \\leq 9999\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1222\n\nSample Output 1\n\n3\n\n2 occurs three times in 1222. By the way, this contest is held on December 22 (JST).\n\nSample Input 2\n\n3456\n\nSample Output 2\n\n0\n\nSample Input 3\n\n9592\n\nSample Output 3\n\n1", "sample_input": "1222\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03192", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given an integer N that has exactly four digits in base ten.\nHow many times does 2 occur in the base-ten representation of N?\n\nConstraints\n\n1000 \\leq N \\leq 9999\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1222\n\nSample Output 1\n\n3\n\n2 occurs three times in 1222. By the way, this contest is held on December 22 (JST).\n\nSample Input 2\n\n3456\n\nSample Output 2\n\n0\n\nSample Input 3\n\n9592\n\nSample Output 3\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 33, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s740211282", "group_id": "codeNet:p03196", "input_text": "N, P = gets.split(/ /).collect{|n| n.to_i}\n\nif N == 1\n\tputs P\nelse\n\t\n\tMAX = 10 ** 6\n\t\n\tp_table = [true] * (MAX + 1)\n\t\n\t(2..10**6).each{|n|\n\t\tnext unless p_table[n]\n\t\tx = n + n\n\t\twhile x < MAX\n\t\t\tp_table[x] = false\n\t\t\tx += n\n\t\tend\n\t#\tprint \"#{n} \"\n\t}\n\tp_list = []\n\t\n\t(2..10**6).each{|n|\n\t\tif p_table[n]\n\t\t\tp_list << n\n\t\tend\n\t}\n\t\n\ti = p_list.length - 1\n\t\n\tf_table = {}\n\t\n\tnum = P\n\twhile i >= 0 && num > 1\n\t\tf = p_list[i]\n\t\tif f <= num\n\t\t\twhile true\n\t\t\t\tif num % f == 0\n\t\t\t\t\tnum = num / f\n\t\t\t\t\tif count = f_table[f]\n\t\t\t\t\t\tf_table[f] = count + 1\n\t\t\t\t\telse\n\t\t\t\t\t\tf_table[f] = 1\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t\n\t\ti -= 1\n\tend\n\t\n\tanswer = 1\n\tf_table.each{|f, count|\n\t\tif count >= N\n\t\t\tanswer *= (f ** (count / N))\n\t\tend\n\t}\n\t\n\tputs answer\nend\n", "language": "Ruby", "metadata": {"date": 1545531632, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s740211282.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s740211282", "user_id": "u751724075"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "N, P = gets.split(/ /).collect{|n| n.to_i}\n\nif N == 1\n\tputs P\nelse\n\t\n\tMAX = 10 ** 6\n\t\n\tp_table = [true] * (MAX + 1)\n\t\n\t(2..10**6).each{|n|\n\t\tnext unless p_table[n]\n\t\tx = n + n\n\t\twhile x < MAX\n\t\t\tp_table[x] = false\n\t\t\tx += n\n\t\tend\n\t#\tprint \"#{n} \"\n\t}\n\tp_list = []\n\t\n\t(2..10**6).each{|n|\n\t\tif p_table[n]\n\t\t\tp_list << n\n\t\tend\n\t}\n\t\n\ti = p_list.length - 1\n\t\n\tf_table = {}\n\t\n\tnum = P\n\twhile i >= 0 && num > 1\n\t\tf = p_list[i]\n\t\tif f <= num\n\t\t\twhile true\n\t\t\t\tif num % f == 0\n\t\t\t\t\tnum = num / f\n\t\t\t\t\tif count = f_table[f]\n\t\t\t\t\t\tf_table[f] = count + 1\n\t\t\t\t\telse\n\t\t\t\t\t\tf_table[f] = 1\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t\n\t\ti -= 1\n\tend\n\t\n\tanswer = 1\n\tf_table.each{|f, count|\n\t\tif count >= N\n\t\t\tanswer *= (f ** (count / N))\n\t\tend\n\t}\n\t\n\tputs answer\nend\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": 755, "cpu_time_ms": 272, "memory_kb": 10364}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s547646415", "group_id": "codeNet:p03197", "input_text": "N = gets.to_i\nas = N.times.map{gets.to_i}\nputs as.all?{|e|e.even?} ? \"second\" : \"first\" ", "language": "Ruby", "metadata": {"date": 1583732317, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03197.html", "problem_id": "p03197", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03197/input.txt", "sample_output_relpath": "derived/input_output/data/p03197/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03197/Ruby/s547646415.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s547646415", "user_id": "u926099741"}, "prompt_components": {"gold_output": "first\n", "input_to_evaluate": "N = gets.to_i\nas = N.times.map{gets.to_i}\nputs as.all?{|e|e.even?} ? \"second\" : \"first\" ", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i.\n\nYou and Lunlun the dachshund alternately perform the following operation (starting from you):\n\nChoose one or more apples from the tree and eat them. Here, the apples chosen at the same time must all have different colors.\n\nThe one who eats the last apple from the tree will be declared winner. If both you and Lunlun play optimally, which will win?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq a_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nIf you will win, print first; if Lunlun will win, print second.\n\nSample Input 1\n\n2\n1\n2\n\nSample Output 1\n\nfirst\n\nLet Color 1 be red, and Color 2 be blue. In this case, the tree bears one red apple and two blue apples.\n\nYou should eat the red apple in your first turn. Lunlun is then forced to eat one of the blue apples, and you can win by eating the other in your next turn.\n\nNote that you are also allowed to eat two apples in your first turn, one red and one blue (not a winning move, though).\n\nSample Input 2\n\n3\n100000\n30000\n20000\n\nSample Output 2\n\nsecond", "sample_input": "2\n1\n2\n"}, "reference_outputs": ["first\n"], "source_document_id": "p03197", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i.\n\nYou and Lunlun the dachshund alternately perform the following operation (starting from you):\n\nChoose one or more apples from the tree and eat them. Here, the apples chosen at the same time must all have different colors.\n\nThe one who eats the last apple from the tree will be declared winner. If both you and Lunlun play optimally, which will win?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq a_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nIf you will win, print first; if Lunlun will win, print second.\n\nSample Input 1\n\n2\n1\n2\n\nSample Output 1\n\nfirst\n\nLet Color 1 be red, and Color 2 be blue. In this case, the tree bears one red apple and two blue apples.\n\nYou should eat the red apple in your first turn. Lunlun is then forced to eat one of the blue apples, and you can win by eating the other in your next turn.\n\nNote that you are also allowed to eat two apples in your first turn, one red and one blue (not a winning move, though).\n\nSample Input 2\n\n3\n100000\n30000\n20000\n\nSample Output 2\n\nsecond", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 88, "cpu_time_ms": 68, "memory_kb": 4604}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s235385164", "group_id": "codeNet:p03200", "input_text": "def BW_reverse(a, length, count)\n (0..(length-count/2)).reverse_each do |i|\n if a[i] == \"B\" && a[i+1] == \"W\"\n a[i] = \"W\"\n a[i+1] = \"B\"\n count = count + 1\n return BW_reverse(a, length, count)\n end\n end\n return count\nend\n\na = gets.chomp.split(\"\")\nlength = a.length - 2\ncount = 0\n\nputs BW_reverse(a, length, count)\n", "language": "Ruby", "metadata": {"date": 1544929804, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s235385164.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s235385164", "user_id": "u610761300"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "def BW_reverse(a, length, count)\n (0..(length-count/2)).reverse_each do |i|\n if a[i] == \"B\" && a[i+1] == \"W\"\n a[i] = \"W\"\n a[i+1] = \"B\"\n count = count + 1\n return BW_reverse(a, length, count)\n end\n end\n return count\nend\n\na = gets.chomp.split(\"\")\nlength = a.length - 2\ncount = 0\n\nputs BW_reverse(a, length, count)\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": 341, "cpu_time_ms": 2126, "memory_kb": 295860}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s596273006", "group_id": "codeNet:p03207", "input_text": "n = gets.to_i\narr = n.times.map{gets.to_i}\nh_item = arr.max\nh_index = arr.index(h_item)\narr[h_index] = h_item / 2\nputs arr.inject(:+)", "language": "Ruby", "metadata": {"date": 1575530962, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s596273006.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s596273006", "user_id": "u630043039"}, "prompt_components": {"gold_output": "15950\n", "input_to_evaluate": "n = gets.to_i\narr = n.times.map{gets.to_i}\nh_item = arr.max\nh_index = arr.index(h_item)\narr[h_index] = h_item / 2\nputs arr.inject(:+)", "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": 133, "cpu_time_ms": 7, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s343516718", "group_id": "codeNet:p03207", "input_text": "n = gets.to_i\nps = []\nn.times do |i|\n ps << gets.to_i\nend\n\nanswer = ps.reduce(0, :+) - ps.max / 2\n\np answer\n", "language": "Ruby", "metadata": {"date": 1558240136, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s343516718.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s343516718", "user_id": "u084335038"}, "prompt_components": {"gold_output": "15950\n", "input_to_evaluate": "n = gets.to_i\nps = []\nn.times do |i|\n ps << gets.to_i\nend\n\nanswer = ps.reduce(0, :+) - ps.max / 2\n\np answer\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": 110, "cpu_time_ms": 8, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s095295626", "group_id": "codeNet:p03207", "input_text": "def test\n\tn = gets.to_i\n\tps = []\n\tn.times do\n\t\tps << gets.to_i\n\tend\n\tps.sort!\n\tps[-1] /= 2\n\tps.inject{|sum, i| sum += i}\nend\n\nputs test\n", "language": "Ruby", "metadata": {"date": 1552697354, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s095295626.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s095295626", "user_id": "u884879015"}, "prompt_components": {"gold_output": "15950\n", "input_to_evaluate": "def test\n\tn = gets.to_i\n\tps = []\n\tn.times do\n\t\tps << gets.to_i\n\tend\n\tps.sort!\n\tps[-1] /= 2\n\tps.inject{|sum, i| sum += i}\nend\n\nputs test\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": 136, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s320098518", "group_id": "codeNet:p03207", "input_text": "N = gets.to_i\n\nlist = N.times.map { gets.to_i }\n\nlist.sort!\n\nputs list[0..-2].inject(:+) + list[-1] / 2\n\n", "language": "Ruby", "metadata": {"date": 1550719736, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s320098518.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s320098518", "user_id": "u740836226"}, "prompt_components": {"gold_output": "15950\n", "input_to_evaluate": "N = gets.to_i\n\nlist = N.times.map { gets.to_i }\n\nlist.sort!\n\nputs list[0..-2].inject(:+) + list[-1] / 2\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn some other world, today is the day before Christmas Eve.\n\nMr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \\leq i \\leq N) is p_i yen (the currency of Japan).\n\nHe has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?\n\nConstraints\n\n2 \\leq N \\leq 10\n\n100 \\leq p_i \\leq 10000\n\np_i is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1\np_2\n:\np_N\n\nOutput\n\nPrint the total amount Mr. Takaha will pay.\n\nSample Input 1\n\n3\n4980\n7980\n6980\n\nSample Output 1\n\n15950\n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 = 15950 yen.\n\nNote that outputs such as 15950.0 will be judged as Wrong Answer.\n\nSample Input 2\n\n4\n4320\n4320\n4320\n4320\n\nSample Output 2\n\n15120\n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320 + 4320 + 4320 = 15120 yen.", "sample_input": "3\n4980\n7980\n6980\n"}, "reference_outputs": ["15950\n"], "source_document_id": "p03207", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn some other world, today is the day before Christmas Eve.\n\nMr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \\leq i \\leq N) is p_i yen (the currency of Japan).\n\nHe has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?\n\nConstraints\n\n2 \\leq N \\leq 10\n\n100 \\leq p_i \\leq 10000\n\np_i is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1\np_2\n:\np_N\n\nOutput\n\nPrint the total amount Mr. Takaha will pay.\n\nSample Input 1\n\n3\n4980\n7980\n6980\n\nSample Output 1\n\n15950\n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 = 15950 yen.\n\nNote that outputs such as 15950.0 will be judged as Wrong Answer.\n\nSample Input 2\n\n4\n4320\n4320\n4320\n4320\n\nSample Output 2\n\n15120\n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320 + 4320 + 4320 = 15120 yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 105, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s291414153", "group_id": "codeNet:p03208", "input_text": "n, k = gets.split.map(&:to_i)\nhs = n.times.map { gets.to_i }.sort\nans = 10 ** 20\n(0..n-1-k+1).each do |i|\n ans = [ans, (hs[i]-hs[i+k-1]).abs].min\nend\nputs ans\n", "language": "Ruby", "metadata": {"date": 1575652142, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03208.html", "problem_id": "p03208", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03208/input.txt", "sample_output_relpath": "derived/input_output/data/p03208/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03208/Ruby/s291414153.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s291414153", "user_id": "u729246375"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n, k = gets.split.map(&:to_i)\nhs = n.times.map { gets.to_i }.sort\nans = 10 ** 20\n(0..n-1-k+1).each do |i|\n ans = [ans, (hs[i]-hs[i+k-1]).abs].min\nend\nputs ans\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "sample_input": "5 3\n10\n15\n11\n14\n12\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03208", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 160, "cpu_time_ms": 117, "memory_kb": 4528}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s547221016", "group_id": "codeNet:p03208", "input_text": "n,k=gets.split.map(&:to_i)\nxs=readlines.map(&:to_i).sort\np (0...k).map{|i|xs[i+k-1]-xs[i]}.min", "language": "Ruby", "metadata": {"date": 1544328195, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03208.html", "problem_id": "p03208", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03208/input.txt", "sample_output_relpath": "derived/input_output/data/p03208/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03208/Ruby/s547221016.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s547221016", "user_id": "u161323909"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n,k=gets.split.map(&:to_i)\nxs=readlines.map(&:to_i).sort\np (0...k).map{|i|xs[i+k-1]-xs[i]}.min", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "sample_input": "5 3\n10\n15\n11\n14\n12\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03208", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 94, "cpu_time_ms": 77, "memory_kb": 9848}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s308082170", "group_id": "codeNet:p03209", "input_text": "n,x = gets.split.map(&:to_i)\npatti = [1]\nsum = [1]\nmid = [1]\nn.times do |i|\n patti << patti[-1]*2 +1\n sum << sum[-1] * 2 + 3\n mid << sum[i] + 2\nend\nlv = n\nans = 0\nwhile lv > 0\n if x == (mid[lv]-1)\n ans += patti[lv-1]\n x -= mid[lv]-1\n elsif x >= mid[lv]\n ans += patti[lv-1] + 1\n x -= mid[lv]\n else\n x -= 1\n end\n lv -= 1\n #p [lv,ans,x]\nend\nans += 1 if x > 0\np ans", "language": "Ruby", "metadata": {"date": 1544324221, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s308082170.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s308082170", "user_id": "u123276241"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "n,x = gets.split.map(&:to_i)\npatti = [1]\nsum = [1]\nmid = [1]\nn.times do |i|\n patti << patti[-1]*2 +1\n sum << sum[-1] * 2 + 3\n mid << sum[i] + 2\nend\nlv = n\nans = 0\nwhile lv > 0\n if x == (mid[lv]-1)\n ans += patti[lv-1]\n x -= mid[lv]-1\n elsif x >= mid[lv]\n ans += patti[lv-1] + 1\n x -= mid[lv]\n else\n x -= 1\n end\n lv -= 1\n #p [lv,ans,x]\nend\nans += 1 if x > 0\np ans", "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": 385, "cpu_time_ms": 8, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s919137307", "group_id": "codeNet:p03210", "input_text": "a = gets.chomp.to_i\nputs a==7 || a==5 ||a ==3 ? \"YES\" : \"NO\"", "language": "Ruby", "metadata": {"date": 1567022436, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03210.html", "problem_id": "p03210", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03210/input.txt", "sample_output_relpath": "derived/input_output/data/p03210/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03210/Ruby/s919137307.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s919137307", "user_id": "u585819925"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "a = gets.chomp.to_i\nputs a==7 || a==5 ||a ==3 ? \"YES\" : \"NO\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nShichi-Go-San (literally \"Seven-Five-Three\") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.\n\nTakahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?\n\nConstraints\n\n1 ≤ X ≤ 9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf Takahashi's growth will be celebrated, print YES; if it will not, print NO.\n\nSample Input 1\n\n5\n\nSample Output 1\n\nYES\n\nThe growth of a five-year-old child will be celebrated.\n\nSample Input 2\n\n6\n\nSample Output 2\n\nNO\n\nSee you next year.", "sample_input": "5\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03210", "source_text": "Score : 100 points\n\nProblem Statement\n\nShichi-Go-San (literally \"Seven-Five-Three\") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.\n\nTakahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?\n\nConstraints\n\n1 ≤ X ≤ 9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf Takahashi's growth will be celebrated, print YES; if it will not, print NO.\n\nSample Input 1\n\n5\n\nSample Output 1\n\nYES\n\nThe growth of a five-year-old child will be celebrated.\n\nSample Input 2\n\n6\n\nSample Output 2\n\nNO\n\nSee you next year.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 60, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s993337572", "group_id": "codeNet:p03211", "input_text": "s = gets.chomp.split(\"\")\nabs_arr = []\nn = s.count\nlike = 753\n\n(0..n).each do |i|\n if (i+2) <= (n-1)\n abs_arr << (s[i..(i+2)].join.to_i - like).abs\n end\nend\n\np abs_arr.min", "language": "Ruby", "metadata": {"date": 1580154816, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s993337572.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s993337572", "user_id": "u012110567"}, "prompt_components": {"gold_output": "34\n", "input_to_evaluate": "s = gets.chomp.split(\"\")\nabs_arr = []\nn = s.count\nlike = 753\n\n(0..n).each do |i|\n if (i+2) <= (n-1)\n abs_arr << (s[i..(i+2)].join.to_i - like).abs\n end\nend\n\np abs_arr.min", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a string S consisting of digits 1, 2, ..., 9.\nLunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)\n\nThe master's favorite number is 753. The closer to this number, the better.\nWhat is the minimum possible (absolute) difference between X and 753?\n\nConstraints\n\nS is a string of length between 4 and 10 (inclusive).\n\nEach character in S is 1, 2, ..., or 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum possible difference between X and 753.\n\nSample Input 1\n\n1234567876\n\nSample Output 1\n\n34\n\nTaking out the seventh to ninth characters results in X = 787, and the difference between this and 753 is 787 - 753 = 34. The difference cannot be made smaller, no matter where X is taken from.\n\nNote that the digits cannot be rearranged. For example, taking out 567 and rearranging it to 765 is not allowed.\n\nWe cannot take out three digits that are not consecutive from S, either. For example, taking out the seventh digit 7, the ninth digit 7 and the tenth digit 6 to obtain 776 is not allowed.\n\nSample Input 2\n\n35753\n\nSample Output 2\n\n0\n\nIf 753 itself can be taken out, the answer is 0.\n\nSample Input 3\n\n1111111111\n\nSample Output 3\n\n642\n\nNo matter where X is taken from, X = 111, with the difference 753 - 111 = 642.", "sample_input": "1234567876\n"}, "reference_outputs": ["34\n"], "source_document_id": "p03211", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a string S consisting of digits 1, 2, ..., 9.\nLunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)\n\nThe master's favorite number is 753. The closer to this number, the better.\nWhat is the minimum possible (absolute) difference between X and 753?\n\nConstraints\n\nS is a string of length between 4 and 10 (inclusive).\n\nEach character in S is 1, 2, ..., or 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum possible difference between X and 753.\n\nSample Input 1\n\n1234567876\n\nSample Output 1\n\n34\n\nTaking out the seventh to ninth characters results in X = 787, and the difference between this and 753 is 787 - 753 = 34. The difference cannot be made smaller, no matter where X is taken from.\n\nNote that the digits cannot be rearranged. For example, taking out 567 and rearranging it to 765 is not allowed.\n\nWe cannot take out three digits that are not consecutive from S, either. For example, taking out the seventh digit 7, the ninth digit 7 and the tenth digit 6 to obtain 776 is not allowed.\n\nSample Input 2\n\n35753\n\nSample Output 2\n\n0\n\nIf 753 itself can be taken out, the answer is 0.\n\nSample Input 3\n\n1111111111\n\nSample Output 3\n\n642\n\nNo matter where X is taken from, X = 111, with the difference 753 - 111 = 642.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 176, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s167594805", "group_id": "codeNet:p03211", "input_text": "s = gets.chomp\nputs (0..s.size-3).to_a.map { |i| (s[i..i+2].to_i - 753).abs }.min\n", "language": "Ruby", "metadata": {"date": 1550457172, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s167594805.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s167594805", "user_id": "u434509016"}, "prompt_components": {"gold_output": "34\n", "input_to_evaluate": "s = gets.chomp\nputs (0..s.size-3).to_a.map { |i| (s[i..i+2].to_i - 753).abs }.min\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": 82, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s153770970", "group_id": "codeNet:p03212", "input_text": "a=gets.chomp.to_i\nif a < 357\n puts 0\nelse\n l = a.to_s.length - 3\n c_ary = [[3,5,7]]\n d_ary = [3, 5, 7]\n l.times do |i|\n i += 1\n [3,5,7].repeated_permutation(i){ |n| c_ary << (d_ary + n) }\n end\n n_ary = []\nc_ary.each do |c|\n n_ary << c.permutation.map { |n| n.join.to_i}\nend\nn_ary = n_ary.flatten.uniq\nans_ary = n_ary.select { |n| n < a }\nputs ans_ary.size\nend", "language": "Ruby", "metadata": {"date": 1543807617, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s153770970.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s153770970", "user_id": "u403638277"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "a=gets.chomp.to_i\nif a < 357\n puts 0\nelse\n l = a.to_s.length - 3\n c_ary = [[3,5,7]]\n d_ary = [3, 5, 7]\n l.times do |i|\n i += 1\n [3,5,7].repeated_permutation(i){ |n| c_ary << (d_ary + n) }\n end\n n_ary = []\nc_ary.each do |c|\n n_ary << c.permutation.map { |n| n.join.to_i}\nend\nn_ary = n_ary.flatten.uniq\nans_ary = n_ary.select { |n| n < a }\nputs ans_ary.size\nend", "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": 373, "cpu_time_ms": 2108, "memory_kb": 9152}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s192262880", "group_id": "codeNet:p03214", "input_text": "N = gets.to_i\na = gets.split.map(&:to_f)\nmean = a.inject(:+) / N\nb = a.map { |ai| (ai - mean).abs }\nputs b.index(b.min)", "language": "Ruby", "metadata": {"date": 1578756232, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03214.html", "problem_id": "p03214", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03214/input.txt", "sample_output_relpath": "derived/input_output/data/p03214/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03214/Ruby/s192262880.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s192262880", "user_id": "u199924561"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N = gets.to_i\na = gets.split.map(&:to_f)\nmean = a.inject(:+) / N\nb = a.map { |ai| (ai - mean).abs }\nputs b.index(b.min)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nNiwango-kun is an employee of Dwango Co., Ltd.\n\nOne day, he is asked to generate a thumbnail from a video a user submitted.\n\nTo generate a thumbnail, he needs to select a frame of the video according to the following procedure:\n\nGet an integer N and N integers a_0, a_1, ..., a_{N-1} as inputs. N denotes the number of the frames of the video, and each a_i denotes the representation of the i-th frame of the video.\n\nSelect t-th frame whose representation a_t is nearest to the average of all frame representations.\n\nIf there are multiple such frames, select the frame with the smallest index.\n\nFind the index t of the frame he should select to generate a thumbnail.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq a_i \\leq 100\n\nAll numbers given in input are integers\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_{0} a_{1} ... a_{N-1}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n1\n\nSince the average of frame representations is 2, Niwango-kun needs to select the index 1, whose representation is 2, that is, the nearest value to the average.\n\nSample Input 2\n\n4\n2 5 2 5\n\nSample Output 2\n\n0\n\nThe average of frame representations is 3.5.\n\nIn this case, every frame has the same distance from its representation to the average.\n\nTherefore, Niwango-kun should select index 0, the smallest index among them.", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03214", "source_text": "Score : 200 points\n\nProblem Statement\n\nNiwango-kun is an employee of Dwango Co., Ltd.\n\nOne day, he is asked to generate a thumbnail from a video a user submitted.\n\nTo generate a thumbnail, he needs to select a frame of the video according to the following procedure:\n\nGet an integer N and N integers a_0, a_1, ..., a_{N-1} as inputs. N denotes the number of the frames of the video, and each a_i denotes the representation of the i-th frame of the video.\n\nSelect t-th frame whose representation a_t is nearest to the average of all frame representations.\n\nIf there are multiple such frames, select the frame with the smallest index.\n\nFind the index t of the frame he should select to generate a thumbnail.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq a_i \\leq 100\n\nAll numbers given in input are integers\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_{0} a_{1} ... a_{N-1}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n1\n\nSince the average of frame representations is 2, Niwango-kun needs to select the index 1, whose representation is 2, that is, the nearest value to the average.\n\nSample Input 2\n\n4\n2 5 2 5\n\nSample Output 2\n\n0\n\nThe average of frame representations is 3.5.\n\nIn this case, every frame has the same distance from its representation to the average.\n\nTherefore, Niwango-kun should select index 0, the smallest index among them.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 119, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s305429936", "group_id": "codeNet:p03219", "input_text": "X, Y = gets.split.map(&:to_i)\n\nputs X + Y / 2\n", "language": "Ruby", "metadata": {"date": 1550785572, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03219.html", "problem_id": "p03219", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03219/input.txt", "sample_output_relpath": "derived/input_output/data/p03219/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03219/Ruby/s305429936.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s305429936", "user_id": "u740836226"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "X, Y = gets.split.map(&:to_i)\n\nputs X + Y / 2\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "sample_input": "81 58\n"}, "reference_outputs": ["110\n"], "source_document_id": "p03219", "source_text": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 46, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s692513628", "group_id": "codeNet:p03220", "input_text": "N = gets.to_i\nT , A = gets.split.map!{|i| i.to_i}\nH = gets.split.map!{|i| T - (i.to_i) * 0.006}\nmin = 10 ** 4\nk = 0\n\nN.times do |i|\n if min > (A - H[i]).abs\n min = (A - H[i]).abs\n k = i + 1\n end\nend\n\nputs k", "language": "Ruby", "metadata": {"date": 1552938316, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03220.html", "problem_id": "p03220", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03220/input.txt", "sample_output_relpath": "derived/input_output/data/p03220/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03220/Ruby/s692513628.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s692513628", "user_id": "u692254521"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N = gets.to_i\nT , A = gets.split.map!{|i| i.to_i}\nH = gets.split.map!{|i| T - (i.to_i) * 0.006}\nmin = 10 ** 4\nk = 0\n\nN.times do |i|\n if min > (A - H[i]).abs\n min = (A - H[i]).abs\n k = i + 1\n end\nend\n\nputs k", "problem_context": "Score: 200 points\n\nProblem Statement\n\nA country decides to build a palace.\n\nIn this country, the average temperature of a point at an elevation of x meters is T-x \\times 0.006 degrees Celsius.\n\nThere are N places proposed for the place. The elevation of Place i is H_i meters.\n\nAmong them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.\n\nPrint the index of the place where the palace should be built.\n\nIt is guaranteed that the solution is unique.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq T \\leq 50\n\n-60 \\leq A \\leq T\n\n0 \\leq H_i \\leq 10^5\n\nAll values in input are integers.\n\nThe solution is unique.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT A\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the index of the place where the palace should be built.\n\nSample Input 1\n\n2\n12 5\n1000 2000\n\nSample Output 1\n\n1\n\nThe average temperature of Place 1 is 12-1000 \\times 0.006=6 degrees Celsius.\n\nThe average temperature of Place 2 is 12-2000 \\times 0.006=0 degrees Celsius.\n\nThus, the palace should be built at Place 1.\n\nSample Input 2\n\n3\n21 -11\n81234 94124 52141\n\nSample Output 2\n\n3", "sample_input": "2\n12 5\n1000 2000\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03220", "source_text": "Score: 200 points\n\nProblem Statement\n\nA country decides to build a palace.\n\nIn this country, the average temperature of a point at an elevation of x meters is T-x \\times 0.006 degrees Celsius.\n\nThere are N places proposed for the place. The elevation of Place i is H_i meters.\n\nAmong them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.\n\nPrint the index of the place where the palace should be built.\n\nIt is guaranteed that the solution is unique.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq T \\leq 50\n\n-60 \\leq A \\leq T\n\n0 \\leq H_i \\leq 10^5\n\nAll values in input are integers.\n\nThe solution is unique.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT A\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the index of the place where the palace should be built.\n\nSample Input 1\n\n2\n12 5\n1000 2000\n\nSample Output 1\n\n1\n\nThe average temperature of Place 1 is 12-1000 \\times 0.006=6 degrees Celsius.\n\nThe average temperature of Place 2 is 12-2000 \\times 0.006=0 degrees Celsius.\n\nThus, the palace should be built at Place 1.\n\nSample Input 2\n\n3\n21 -11\n81234 94124 52141\n\nSample Output 2\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 226, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s314733080", "group_id": "codeNet:p03227", "input_text": "s = gets.split(\"\\n\")[0]\nif s.size == 3\n p s.reverse\nelse\n p s\nend", "language": "Ruby", "metadata": {"date": 1541334713, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03227.html", "problem_id": "p03227", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03227/input.txt", "sample_output_relpath": "derived/input_output/data/p03227/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03227/Ruby/s314733080.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s314733080", "user_id": "u916219216"}, "prompt_components": {"gold_output": "cba\n", "input_to_evaluate": "s = gets.split(\"\\n\")[0]\nif s.size == 3\n p s.reverse\nelse\n p s\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints\n\nThe length of S is 2 or 3.\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1\n\nabc\n\nSample Output 1\n\ncba\n\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2\n\nac\n\nSample Output 2\n\nac\n\nAs the length of S is 2, we print it as is.", "sample_input": "abc\n"}, "reference_outputs": ["cba\n"], "source_document_id": "p03227", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints\n\nThe length of S is 2 or 3.\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1\n\nabc\n\nSample Output 1\n\ncba\n\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2\n\nac\n\nSample Output 2\n\nac\n\nAs the length of S is 2, we print it as is.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 67, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s181107421", "group_id": "codeNet:p03232", "input_text": "N = gets.to_i\nA = gets.split.map(&:to_i)\nB = gets.split.map(&:to_i)\n\nlimit = B.inject(:+) - A.inject(:+)\ncnt1 = 0\ncnt2 = 0\n\nA.zip(B).each do |a, b|\n next if a == b\n\n if a > b\n cnt1 += a - b\n else\n cnt2 += ((b - a) / 2.0).ceil\n end\nend\n\nif cnt1 + cnt2 <= limit\n puts 'Yes'\nelse\n puts 'No'\nend\n", "language": "Ruby", "metadata": {"date": 1562822751, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s181107421.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s181107421", "user_id": "u740836226"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "N = gets.to_i\nA = gets.split.map(&:to_i)\nB = gets.split.map(&:to_i)\n\nlimit = B.inject(:+) - A.inject(:+)\ncnt1 = 0\ncnt2 = 0\n\nA.zip(B).each do |a, b|\n next if a == b\n\n if a > b\n cnt1 += a - b\n else\n cnt2 += ((b - a) / 2.0).ceil\n end\nend\n\nif cnt1 + cnt2 <= limit\n puts 'Yes'\nelse\n puts 'No'\nend\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": 304, "cpu_time_ms": 48, "memory_kb": 8452}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s950754528", "group_id": "codeNet:p03238", "input_text": "N = gets.to_i\n\nif N==1\n puts \"Hello World\"\n exit\nend\n\nA = gets.to_i\nB = gets.to_i\n\nputs A+B\n", "language": "Ruby", "metadata": {"date": 1556777168, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s950754528.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s950754528", "user_id": "u708550576"}, "prompt_components": {"gold_output": "Hello World\n", "input_to_evaluate": "N = gets.to_i\n\nif N==1\n puts \"Hello World\"\n exit\nend\n\nA = gets.to_i\nB = gets.to_i\n\nputs A+B\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "sample_input": "1\n"}, "reference_outputs": ["Hello World\n"], "source_document_id": "p03238", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 94, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s750239803", "group_id": "codeNet:p03238", "input_text": "N = gets.to_i\n\nif N == 1\n puts 'Hello World'\nelse\n A = gets.to_i\n B = gets.to_i\n puts A+B\nend", "language": "Ruby", "metadata": {"date": 1552617297, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s750239803.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s750239803", "user_id": "u244087909"}, "prompt_components": {"gold_output": "Hello World\n", "input_to_evaluate": "N = gets.to_i\n\nif N == 1\n puts 'Hello World'\nelse\n A = gets.to_i\n B = gets.to_i\n puts A+B\nend", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "sample_input": "1\n"}, "reference_outputs": ["Hello World\n"], "source_document_id": "p03238", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 97, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s361536630", "group_id": "codeNet:p03238", "input_text": "N = gets.to_i\nA = gets.to_i\nB = gets.to_i\nif N == 1 then\n puts \"Hello World\"\nelse\n puts A+B\nend\n", "language": "Ruby", "metadata": {"date": 1538874109, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s361536630.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s361536630", "user_id": "u270178188"}, "prompt_components": {"gold_output": "Hello World\n", "input_to_evaluate": "N = gets.to_i\nA = gets.to_i\nB = gets.to_i\nif N == 1 then\n puts \"Hello World\"\nelse\n puts A+B\nend\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "sample_input": "1\n"}, "reference_outputs": ["Hello World\n"], "source_document_id": "p03238", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 98, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s019460595", "group_id": "codeNet:p03239", "input_text": "data = gets.split(\" \")\nlimit = data[1].to_i\ncount = data[0].to_i\n\ndb=Array.new\ncount.times do |i|\n d = gets.split(\" \")\n db.push(d)\nend \n\ndb = db.find_all {|item| item[1].to_i < limit.to_i}\nint = 10000\ndb.each do |d|\n i = d[0].to_i \n if i < int \n int = i \n end \nend \nif int == 10000\n puts \"TLE\"\nelse \n puts int \nend ", "language": "Ruby", "metadata": {"date": 1539197307, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s019460595.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s019460595", "user_id": "u809037624"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "data = gets.split(\" \")\nlimit = data[1].to_i\ncount = data[0].to_i\n\ndb=Array.new\ncount.times do |i|\n d = gets.split(\" \")\n db.push(d)\nend \n\ndb = db.find_all {|item| item[1].to_i < limit.to_i}\nint = 10000\ndb.each do |d|\n i = d[0].to_i \n if i < int \n int = i \n end \nend \nif int == 10000\n puts \"TLE\"\nelse \n puts int \nend ", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWhen Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.\n\nYou, the smartwatch, has found N routes to his home.\n\nIf Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.\n\nFind the smallest cost of a route that takes not longer than time T.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq T \\leq 1000\n\n1 \\leq c_i \\leq 1000\n\n1 \\leq t_i \\leq 1000\n\nThe pairs (c_i, t_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nc_1 t_1\nc_2 t_2\n:\nc_N t_N\n\nOutput\n\nPrint the smallest cost of a route that takes not longer than time T.\n\nIf there is no route that takes not longer than time T, print TLE instead.\n\nSample Input 1\n\n3 70\n7 60\n1 80\n4 50\n\nSample Output 1\n\n4\n\nThe first route gets him home at cost 7.\n\nThe second route takes longer than time T = 70.\n\nThe third route gets him home at cost 4.\n\nThus, the cost 4 of the third route is the minimum.\n\nSample Input 2\n\n4 3\n1 1000\n2 4\n3 1000\n4 500\n\nSample Output 2\n\nTLE\n\nThere is no route that takes not longer than time T = 3.\n\nSample Input 3\n\n5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1\n\nSample Output 3\n\n5", "sample_input": "3 70\n7 60\n1 80\n4 50\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03239", "source_text": "Score : 200 points\n\nProblem Statement\n\nWhen Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.\n\nYou, the smartwatch, has found N routes to his home.\n\nIf Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.\n\nFind the smallest cost of a route that takes not longer than time T.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq T \\leq 1000\n\n1 \\leq c_i \\leq 1000\n\n1 \\leq t_i \\leq 1000\n\nThe pairs (c_i, t_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nc_1 t_1\nc_2 t_2\n:\nc_N t_N\n\nOutput\n\nPrint the smallest cost of a route that takes not longer than time T.\n\nIf there is no route that takes not longer than time T, print TLE instead.\n\nSample Input 1\n\n3 70\n7 60\n1 80\n4 50\n\nSample Output 1\n\n4\n\nThe first route gets him home at cost 7.\n\nThe second route takes longer than time T = 70.\n\nThe third route gets him home at cost 4.\n\nThus, the cost 4 of the third route is the minimum.\n\nSample Input 2\n\n4 3\n1 1000\n2 4\n3 1000\n4 500\n\nSample Output 2\n\nTLE\n\nThere is no route that takes not longer than time T = 3.\n\nSample Input 3\n\n5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1\n\nSample Output 3\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 343, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s620795983", "group_id": "codeNet:p03241", "input_text": "require \"prime\"\n\ndef each_div(primes)\n max = primes.map{|prime| prime[1]}.inject(1){|acc, count| acc *= (count + 1)} - 1\n\n use_counts = Array.new(primes.size, 0)\n (1..max).each do\n use_counts[0] += 1\n\n (0..(use_counts.size - 1)).each do |i|\n if use_counts[i] > primes[i][1]\n use_counts[i] = 0\n\n if i + 1 < use_counts.size\n use_counts[i + 1] += 1\n end\n else\n break\n end\n end\n\n div = 1\n use_counts.each_with_index do |count, i|\n div *= primes[i][0] ** count\n end\n\n yield div\n end\nend\n\nN, M = STDIN.gets.chomp.split(\" \").map(&:to_i)\n\nprimes = Prime.prime_division(M).select{|prime| prime[0] <= M / N}\n\ndivs = [1]\neach_div(primes){|div| divs << div if div <= M / N}\nanswer = divs.uniq.select{|div| div <= M / N}.max\nputs answer\n", "language": "Ruby", "metadata": {"date": 1541174681, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03241.html", "problem_id": "p03241", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03241/input.txt", "sample_output_relpath": "derived/input_output/data/p03241/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03241/Ruby/s620795983.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s620795983", "user_id": "u447762256"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "require \"prime\"\n\ndef each_div(primes)\n max = primes.map{|prime| prime[1]}.inject(1){|acc, count| acc *= (count + 1)} - 1\n\n use_counts = Array.new(primes.size, 0)\n (1..max).each do\n use_counts[0] += 1\n\n (0..(use_counts.size - 1)).each do |i|\n if use_counts[i] > primes[i][1]\n use_counts[i] = 0\n\n if i + 1 < use_counts.size\n use_counts[i + 1] += 1\n end\n else\n break\n end\n end\n\n div = 1\n use_counts.each_with_index do |count, i|\n div *= primes[i][0] ** count\n end\n\n yield div\n end\nend\n\nN, M = STDIN.gets.chomp.split(\" \").map(&:to_i)\n\nprimes = Prime.prime_division(M).select{|prime| prime[0] <= M / N}\n\ndivs = [1]\neach_div(primes){|div| divs << div if div <= M / N}\nanswer = divs.uniq.select{|div| div <= M / N}.max\nputs answer\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given integers N and M.\n\nConsider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\nN \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.\n\nSample Input 1\n\n3 14\n\nSample Output 1\n\n2\n\nConsider the sequence (a_1, a_2, a_3) = (2, 4, 8). Their greatest common divisor is 2, and this is the maximum value.\n\nSample Input 2\n\n10 123\n\nSample Output 2\n\n3\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n10000", "sample_input": "3 14\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03241", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given integers N and M.\n\nConsider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\nN \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.\n\nSample Input 1\n\n3 14\n\nSample Output 1\n\n2\n\nConsider the sequence (a_1, a_2, a_3) = (2, 4, 8). Their greatest common divisor is 2, and this is the maximum value.\n\nSample Input 2\n\n10 123\n\nSample Output 2\n\n3\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n10000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 806, "cpu_time_ms": 13, "memory_kb": 2172}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s516522423", "group_id": "codeNet:p03246", "input_text": "N = gets.to_i\na = gets.split.map(&:to_i)\nod, ev = {}, {}\n\nif a.uniq.size==1\n p N/2\n exit\nend\n\na.select.with_index{|_,i| i.even?}.each do |n|\n if ev.key?(n)\n ev[n] += 1 \n else\n ev[n] = 1\n end\nend\n\na.select.with_index{|_,i| i.odd?}.each do |n|\n if od.key?(n)\n od[n] += 1 \n else\n od[n] = 1\n end\nend\n\nevmx = ev.max_by{|k,v| v}\nodmx = od.max_by{|k,v| v}\n\nif evmx[0] == odmx[0]\n\n if evmx[1] > odmx[1]\n od.delete(evmx[0])\n p N - ev.max_by{|k,v| v}[1] - od.max_by{|k,v| v}[1]\n elsif evmx[1] < odmx[1]\n \tev.delete(odmx[0])\n p N - ev.max_by{|k,v| v}[1] - od.max_by{|k,v| v}[1]\n else\n ev.delete(odmx[0])\n a1 = N - ev.max_by{|k,v| v}[1] - od.max_by{|k,v| v}[1]\n od.delete(evmx[0])\n a2 = N - ev.max_by{|k,v| v}[1] - od.max_by{|k,v| v}[1]\n p [a1,a2].min\n end\nend\n\np N - ev.max_by{|k,v| v}[1] - od.max_by{|k,v| v}[1]\n", "language": "Ruby", "metadata": {"date": 1563408661, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03246.html", "problem_id": "p03246", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03246/input.txt", "sample_output_relpath": "derived/input_output/data/p03246/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03246/Ruby/s516522423.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s516522423", "user_id": "u502306384"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N = gets.to_i\na = gets.split.map(&:to_i)\nod, ev = {}, {}\n\nif a.uniq.size==1\n p N/2\n exit\nend\n\na.select.with_index{|_,i| i.even?}.each do |n|\n if ev.key?(n)\n ev[n] += 1 \n else\n ev[n] = 1\n end\nend\n\na.select.with_index{|_,i| i.odd?}.each do |n|\n if od.key?(n)\n od[n] += 1 \n else\n od[n] = 1\n end\nend\n\nevmx = ev.max_by{|k,v| v}\nodmx = od.max_by{|k,v| v}\n\nif evmx[0] == odmx[0]\n\n if evmx[1] > odmx[1]\n od.delete(evmx[0])\n p N - ev.max_by{|k,v| v}[1] - od.max_by{|k,v| v}[1]\n elsif evmx[1] < odmx[1]\n \tev.delete(odmx[0])\n p N - ev.max_by{|k,v| v}[1] - od.max_by{|k,v| v}[1]\n else\n ev.delete(odmx[0])\n a1 = N - ev.max_by{|k,v| v}[1] - od.max_by{|k,v| v}[1]\n od.delete(evmx[0])\n a2 = N - ev.max_by{|k,v| v}[1] - od.max_by{|k,v| v}[1]\n p [a1,a2].min\n end\nend\n\np N - ev.max_by{|k,v| v}[1] - od.max_by{|k,v| v}[1]\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "sample_input": "4\n3 1 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03246", "source_text": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 851, "cpu_time_ms": 191, "memory_kb": 19480}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s474385468", "group_id": "codeNet:p03252", "input_text": "a = gets\nb = gets\nac = 0\nbc = 0\n(\"a\"..\"z\").each do |hoge|\n if a.count(hoge) % 2 == 0 and a.count(hoge) != 0 then\n ac += 1\n end\n if b.count(hoge) % 2 == 0 and b.count(hoge) != 0 then\n bc += 1\n end\nend\nputs ac == bc ? \"YES\" : \"NO\"", "language": "Ruby", "metadata": {"date": 1557026063, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03252.html", "problem_id": "p03252", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03252/input.txt", "sample_output_relpath": "derived/input_output/data/p03252/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03252/Ruby/s474385468.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s474385468", "user_id": "u163052359"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a = gets\nb = gets\nac = 0\nbc = 0\n(\"a\"..\"z\").each do |hoge|\n if a.count(hoge) % 2 == 0 and a.count(hoge) != 0 then\n ac += 1\n end\n if b.count(hoge) % 2 == 0 and b.count(hoge) != 0 then\n bc += 1\n end\nend\nputs ac == bc ? \"YES\" : \"NO\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given strings S and T consisting of lowercase English letters.\n\nYou can perform the following operation on S any number of times:\n\nOperation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.\n\nDetermine if S and T can be made equal by performing the operation zero or more times.\n\nConstraints\n\n1 \\leq |S| \\leq 2 \\times 10^5\n\n|S| = |T|\n\nS and T consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf S and T can be made equal, print Yes; otherwise, print No.\n\nSample Input 1\n\nazzel\napple\n\nSample Output 1\n\nYes\n\nazzel can be changed to apple, as follows:\n\nChoose e as c_1 and l as c_2. azzel becomes azzle.\n\nChoose z as c_1 and p as c_2. azzle becomes apple.\n\nSample Input 2\n\nchokudai\nredcoder\n\nSample Output 2\n\nNo\n\nNo sequences of operation can change chokudai to redcoder.\n\nSample Input 3\n\nabcdefghijklmnopqrstuvwxyz\nibyhqfrekavclxjstdwgpzmonu\n\nSample Output 3\n\nYes", "sample_input": "azzel\napple\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03252", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given strings S and T consisting of lowercase English letters.\n\nYou can perform the following operation on S any number of times:\n\nOperation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.\n\nDetermine if S and T can be made equal by performing the operation zero or more times.\n\nConstraints\n\n1 \\leq |S| \\leq 2 \\times 10^5\n\n|S| = |T|\n\nS and T consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf S and T can be made equal, print Yes; otherwise, print No.\n\nSample Input 1\n\nazzel\napple\n\nSample Output 1\n\nYes\n\nazzel can be changed to apple, as follows:\n\nChoose e as c_1 and l as c_2. azzel becomes azzle.\n\nChoose z as c_1 and p as c_2. azzle becomes apple.\n\nSample Input 2\n\nchokudai\nredcoder\n\nSample Output 2\n\nNo\n\nNo sequences of operation can change chokudai to redcoder.\n\nSample Input 3\n\nabcdefghijklmnopqrstuvwxyz\nibyhqfrekavclxjstdwgpzmonu\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 254, "cpu_time_ms": 22, "memory_kb": 4092}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s519652105", "group_id": "codeNet:p03252", "input_text": "S, T = readlines.map(&:chomp)\n\nst = S\n(0 ... S.length).each do |i|\n s, t = S[i], T[i]\n unless s == t\n st.tr!(s + t, t + s)\n end\nend\nputs st == T ? 'Yes' : 'No'", "language": "Ruby", "metadata": {"date": 1538055561, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03252.html", "problem_id": "p03252", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03252/input.txt", "sample_output_relpath": "derived/input_output/data/p03252/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03252/Ruby/s519652105.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s519652105", "user_id": "u304198114"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "S, T = readlines.map(&:chomp)\n\nst = S\n(0 ... S.length).each do |i|\n s, t = S[i], T[i]\n unless s == t\n st.tr!(s + t, t + s)\n end\nend\nputs st == T ? 'Yes' : 'No'", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given strings S and T consisting of lowercase English letters.\n\nYou can perform the following operation on S any number of times:\n\nOperation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.\n\nDetermine if S and T can be made equal by performing the operation zero or more times.\n\nConstraints\n\n1 \\leq |S| \\leq 2 \\times 10^5\n\n|S| = |T|\n\nS and T consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf S and T can be made equal, print Yes; otherwise, print No.\n\nSample Input 1\n\nazzel\napple\n\nSample Output 1\n\nYes\n\nazzel can be changed to apple, as follows:\n\nChoose e as c_1 and l as c_2. azzel becomes azzle.\n\nChoose z as c_1 and p as c_2. azzle becomes apple.\n\nSample Input 2\n\nchokudai\nredcoder\n\nSample Output 2\n\nNo\n\nNo sequences of operation can change chokudai to redcoder.\n\nSample Input 3\n\nabcdefghijklmnopqrstuvwxyz\nibyhqfrekavclxjstdwgpzmonu\n\nSample Output 3\n\nYes", "sample_input": "azzel\napple\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03252", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given strings S and T consisting of lowercase English letters.\n\nYou can perform the following operation on S any number of times:\n\nOperation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.\n\nDetermine if S and T can be made equal by performing the operation zero or more times.\n\nConstraints\n\n1 \\leq |S| \\leq 2 \\times 10^5\n\n|S| = |T|\n\nS and T consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf S and T can be made equal, print Yes; otherwise, print No.\n\nSample Input 1\n\nazzel\napple\n\nSample Output 1\n\nYes\n\nazzel can be changed to apple, as follows:\n\nChoose e as c_1 and l as c_2. azzel becomes azzle.\n\nChoose z as c_1 and p as c_2. azzle becomes apple.\n\nSample Input 2\n\nchokudai\nredcoder\n\nSample Output 2\n\nNo\n\nNo sequences of operation can change chokudai to redcoder.\n\nSample Input 3\n\nabcdefghijklmnopqrstuvwxyz\nibyhqfrekavclxjstdwgpzmonu\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 165, "cpu_time_ms": 2108, "memory_kb": 4672}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s907581618", "group_id": "codeNet:p03252", "input_text": "s = gets.chomp.split(//)\nt = gets.chomp.split(//)\ns.length.times do |j|\n next if s[j] == t[j]\n c1, c2 = s[j], t[j] \n s.length.times do |i|\n if s[i] == c1\n s[i] = c2 \n next\n elsif s[i] == c2\n s[i] = c1\n \n end\n end\nend\n\nputs s == t ? \"Yes\" : \"No\"", "language": "Ruby", "metadata": {"date": 1537755605, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03252.html", "problem_id": "p03252", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03252/input.txt", "sample_output_relpath": "derived/input_output/data/p03252/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03252/Ruby/s907581618.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s907581618", "user_id": "u712322283"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "s = gets.chomp.split(//)\nt = gets.chomp.split(//)\ns.length.times do |j|\n next if s[j] == t[j]\n c1, c2 = s[j], t[j] \n s.length.times do |i|\n if s[i] == c1\n s[i] = c2 \n next\n elsif s[i] == c2\n s[i] = c1\n \n end\n end\nend\n\nputs s == t ? \"Yes\" : \"No\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given strings S and T consisting of lowercase English letters.\n\nYou can perform the following operation on S any number of times:\n\nOperation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.\n\nDetermine if S and T can be made equal by performing the operation zero or more times.\n\nConstraints\n\n1 \\leq |S| \\leq 2 \\times 10^5\n\n|S| = |T|\n\nS and T consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf S and T can be made equal, print Yes; otherwise, print No.\n\nSample Input 1\n\nazzel\napple\n\nSample Output 1\n\nYes\n\nazzel can be changed to apple, as follows:\n\nChoose e as c_1 and l as c_2. azzel becomes azzle.\n\nChoose z as c_1 and p as c_2. azzle becomes apple.\n\nSample Input 2\n\nchokudai\nredcoder\n\nSample Output 2\n\nNo\n\nNo sequences of operation can change chokudai to redcoder.\n\nSample Input 3\n\nabcdefghijklmnopqrstuvwxyz\nibyhqfrekavclxjstdwgpzmonu\n\nSample Output 3\n\nYes", "sample_input": "azzel\napple\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03252", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given strings S and T consisting of lowercase English letters.\n\nYou can perform the following operation on S any number of times:\n\nOperation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.\n\nDetermine if S and T can be made equal by performing the operation zero or more times.\n\nConstraints\n\n1 \\leq |S| \\leq 2 \\times 10^5\n\n|S| = |T|\n\nS and T consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf S and T can be made equal, print Yes; otherwise, print No.\n\nSample Input 1\n\nazzel\napple\n\nSample Output 1\n\nYes\n\nazzel can be changed to apple, as follows:\n\nChoose e as c_1 and l as c_2. azzel becomes azzle.\n\nChoose z as c_1 and p as c_2. azzle becomes apple.\n\nSample Input 2\n\nchokudai\nredcoder\n\nSample Output 2\n\nNo\n\nNo sequences of operation can change chokudai to redcoder.\n\nSample Input 3\n\nabcdefghijklmnopqrstuvwxyz\nibyhqfrekavclxjstdwgpzmonu\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 321, "cpu_time_ms": 2109, "memory_kb": 24852}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s963629015", "group_id": "codeNet:p03252", "input_text": "s=gets.chomp\nt=gets.chomp\nh1 = {}\nh2 = {}\n0.upto(s.size-1) do |i|\n next if s[i] == t[i]\n if h1.has_key?(s[i])\n if h1[s[i]] != t[i]\n puts \"No\"\n exit\n end\n elsif h2.has_key?(t[i]) \n if h2[t[i]] != s[i]\n puts \"No\"\n exit\n end\n else\n h1[s[i]] = t[i]\n h2[t[i]] = s[i]\n end\nend\n\nputs \"Yes\"", "language": "Ruby", "metadata": {"date": 1537753088, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03252.html", "problem_id": "p03252", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03252/input.txt", "sample_output_relpath": "derived/input_output/data/p03252/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03252/Ruby/s963629015.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s963629015", "user_id": "u868089307"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "s=gets.chomp\nt=gets.chomp\nh1 = {}\nh2 = {}\n0.upto(s.size-1) do |i|\n next if s[i] == t[i]\n if h1.has_key?(s[i])\n if h1[s[i]] != t[i]\n puts \"No\"\n exit\n end\n elsif h2.has_key?(t[i]) \n if h2[t[i]] != s[i]\n puts \"No\"\n exit\n end\n else\n h1[s[i]] = t[i]\n h2[t[i]] = s[i]\n end\nend\n\nputs \"Yes\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given strings S and T consisting of lowercase English letters.\n\nYou can perform the following operation on S any number of times:\n\nOperation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.\n\nDetermine if S and T can be made equal by performing the operation zero or more times.\n\nConstraints\n\n1 \\leq |S| \\leq 2 \\times 10^5\n\n|S| = |T|\n\nS and T consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf S and T can be made equal, print Yes; otherwise, print No.\n\nSample Input 1\n\nazzel\napple\n\nSample Output 1\n\nYes\n\nazzel can be changed to apple, as follows:\n\nChoose e as c_1 and l as c_2. azzel becomes azzle.\n\nChoose z as c_1 and p as c_2. azzle becomes apple.\n\nSample Input 2\n\nchokudai\nredcoder\n\nSample Output 2\n\nNo\n\nNo sequences of operation can change chokudai to redcoder.\n\nSample Input 3\n\nabcdefghijklmnopqrstuvwxyz\nibyhqfrekavclxjstdwgpzmonu\n\nSample Output 3\n\nYes", "sample_input": "azzel\napple\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03252", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given strings S and T consisting of lowercase English letters.\n\nYou can perform the following operation on S any number of times:\n\nOperation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.\n\nDetermine if S and T can be made equal by performing the operation zero or more times.\n\nConstraints\n\n1 \\leq |S| \\leq 2 \\times 10^5\n\n|S| = |T|\n\nS and T consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf S and T can be made equal, print Yes; otherwise, print No.\n\nSample Input 1\n\nazzel\napple\n\nSample Output 1\n\nYes\n\nazzel can be changed to apple, as follows:\n\nChoose e as c_1 and l as c_2. azzel becomes azzle.\n\nChoose z as c_1 and p as c_2. azzle becomes apple.\n\nSample Input 2\n\nchokudai\nredcoder\n\nSample Output 2\n\nNo\n\nNo sequences of operation can change chokudai to redcoder.\n\nSample Input 3\n\nabcdefghijklmnopqrstuvwxyz\nibyhqfrekavclxjstdwgpzmonu\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 383, "cpu_time_ms": 177, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s480625355", "group_id": "codeNet:p03254", "input_text": "n, x = gets.split.map &:to_i\na = gets.split.map(&:to_i).sort\nr = 0\nj = 0\n(0...n).each do |i|\n x -= a[i]\n if x == 0\n puts j + 1\n exit\n elsif i + 1 < n && a[i+1] > x\n puts j\n exit\n else\n j += 1\n end\nend\n\nputs x > 0 ? j - 1 : j", "language": "Ruby", "metadata": {"date": 1591313340, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03254.html", "problem_id": "p03254", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03254/input.txt", "sample_output_relpath": "derived/input_output/data/p03254/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03254/Ruby/s480625355.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s480625355", "user_id": "u489339677"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n, x = gets.split.map &:to_i\na = gets.split.map(&:to_i).sort\nr = 0\nj = 0\n(0...n).each do |i|\n x -= a[i]\n if x == 0\n puts j + 1\n exit\n elsif i + 1 < n && a[i+1] > x\n puts j\n exit\n else\n j += 1\n end\nend\n\nputs x > 0 ? j - 1 : j", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "sample_input": "3 70\n20 30 10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03254", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 244, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s990896006", "group_id": "codeNet:p03254", "input_text": "N,x=gets.split.map &:to_i\na=gets.split.map(&:to_i).sort\nc=0\nN.times{|i|\n if x>=a[i] then\n x-=a[i]\n c+=1\n end\n}\np c", "language": "Ruby", "metadata": {"date": 1537067212, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03254.html", "problem_id": "p03254", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03254/input.txt", "sample_output_relpath": "derived/input_output/data/p03254/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03254/Ruby/s990896006.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s990896006", "user_id": "u656771711"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "N,x=gets.split.map &:to_i\na=gets.split.map(&:to_i).sort\nc=0\nN.times{|i|\n if x>=a[i] then\n x-=a[i]\n c+=1\n end\n}\np c", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "sample_input": "3 70\n20 30 10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03254", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 122, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s013633330", "group_id": "codeNet:p03254", "input_text": "n, x = gets.split(' ').map(&:to_i)\na = gets.split(' ').map(&:to_i)\na.sort!\nk = 0\na.each { |e|\n if (x - e >= 0)\n x = x - e\n k += 1\n end\n}\n\np k\n", "language": "Ruby", "metadata": {"date": 1537062344, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03254.html", "problem_id": "p03254", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03254/input.txt", "sample_output_relpath": "derived/input_output/data/p03254/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03254/Ruby/s013633330.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s013633330", "user_id": "u098870186"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n, x = gets.split(' ').map(&:to_i)\na = gets.split(' ').map(&:to_i)\na.sort!\nk = 0\na.each { |e|\n if (x - e >= 0)\n x = x - e\n k += 1\n end\n}\n\np k\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "sample_input": "3 70\n20 30 10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03254", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 150, "cpu_time_ms": 8, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s803317879", "group_id": "codeNet:p03265", "input_text": "x1, y1, x2, y2 = gets.split(' ').map(&:to_i)\ndiff_x = x2 - x1\ndiff_y = y2 - y1\n\nif diff_x > 0 && diff_y > 0\n x3 = x2 - diff_y\n y3 = y2 + diff_x\n x4 = x1 - diff_y\n y4 = y1 + diff_x\nelsif diff_x > 0 && diff_y < 0\n x3 = x2 + diff_y\n y3 = y2 + diff_x\n x4 = x1 + diff_y\n y4 = y1 + diff_x\nelsif diff_x < 0 && diff_y > 0\n x3 = x2 - diff_y\n y3 = y2 + diff_x\n x4 = x1 - diff_y\n y4 = y1 + diff_x\nelsif diff_x < 0 && diff_y < 0\n x3 = x2 + diff_y\n y3 = y2 + diff_x\n x4 = x1 + diff_y\n y4 = y1 - diff_x\nelsif diff_x.zero?\n y3 = y2\n y4 = y1\n if diff_y < 0\n x3 = x2 + diff_y\n x4 = x1 + diff_y\n elsif diff_y > 0\n x3 = x2 - diff_y\n x4 = x1 - diff_y\n end\nelsif diff_y.zero?\n x3 = x2\n x4 = x1\n if diff_x < 0\n y3 = y2 - diff_x\n y4 = y1 - diff_x\n elsif diff_x > 0\n y3 = y2 + diff_x\n y4 = y1 + diff_x\n end\nend\n\nputs \"#{x3} #{y3} #{x4} #{y4}\"", "language": "Ruby", "metadata": {"date": 1535860200, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s803317879.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s803317879", "user_id": "u220501704"}, "prompt_components": {"gold_output": "-1 1 -1 0\n", "input_to_evaluate": "x1, y1, x2, y2 = gets.split(' ').map(&:to_i)\ndiff_x = x2 - x1\ndiff_y = y2 - y1\n\nif diff_x > 0 && diff_y > 0\n x3 = x2 - diff_y\n y3 = y2 + diff_x\n x4 = x1 - diff_y\n y4 = y1 + diff_x\nelsif diff_x > 0 && diff_y < 0\n x3 = x2 + diff_y\n y3 = y2 + diff_x\n x4 = x1 + diff_y\n y4 = y1 + diff_x\nelsif diff_x < 0 && diff_y > 0\n x3 = x2 - diff_y\n y3 = y2 + diff_x\n x4 = x1 - diff_y\n y4 = y1 + diff_x\nelsif diff_x < 0 && diff_y < 0\n x3 = x2 + diff_y\n y3 = y2 + diff_x\n x4 = x1 + diff_y\n y4 = y1 - diff_x\nelsif diff_x.zero?\n y3 = y2\n y4 = y1\n if diff_y < 0\n x3 = x2 + diff_y\n x4 = x1 + diff_y\n elsif diff_y > 0\n x3 = x2 - diff_y\n x4 = x1 - diff_y\n end\nelsif diff_y.zero?\n x3 = x2\n x4 = x1\n if diff_x < 0\n y3 = y2 - diff_x\n y4 = y1 - diff_x\n elsif diff_x > 0\n y3 = y2 + diff_x\n y4 = y1 + diff_x\n end\nend\n\nputs \"#{x3} #{y3} #{x4} #{y4}\"", "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": 868, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s249886696", "group_id": "codeNet:p03266", "input_text": "(n, k) = gets.chomp.split(' ').map(&:to_i)\n\nm = n / k\n\nc = m ** 3\n\nif k % 2 == 0 then\n l = m\n if (n % k) < (k / 2) then\n \tl += 1\n end\n c += (l ** 3)\nend\n\nputs c.to_s", "language": "Ruby", "metadata": {"date": 1535945985, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s249886696.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s249886696", "user_id": "u198355306"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "(n, k) = gets.chomp.split(' ').map(&:to_i)\n\nm = n / k\n\nc = m ** 3\n\nif k % 2 == 0 then\n l = m\n if (n % k) < (k / 2) then\n \tl += 1\n end\n c += (l ** 3)\nend\n\nputs c.to_s", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given integers N and K. Find the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K.\nThe order of a,b,c does matter, and some of them can be the same.\n\nConstraints\n\n1 \\leq N,K \\leq 2\\times 10^5\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n9\n\n(1,1,1),(1,1,3),(1,3,1),(1,3,3),(2,2,2),(3,1,1),(3,1,3),(3,3,1) and (3,3,3) satisfy the condition.\n\nSample Input 2\n\n5 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n27\n\nSample Input 4\n\n35897 932\n\nSample Output 4\n\n114191", "sample_input": "3 2\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03266", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given integers N and K. Find the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K.\nThe order of a,b,c does matter, and some of them can be the same.\n\nConstraints\n\n1 \\leq N,K \\leq 2\\times 10^5\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n9\n\n(1,1,1),(1,1,3),(1,3,1),(1,3,3),(2,2,2),(3,1,1),(3,1,3),(3,3,1) and (3,3,3) satisfy the condition.\n\nSample Input 2\n\n5 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n27\n\nSample Input 4\n\n35897 932\n\nSample Output 4\n\n114191", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 170, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s359615898", "group_id": "codeNet:p03267", "input_text": "nu = gets.to_i - 1\ninst = nu\nar = []\ncount = 0\nfor i in 0..19\n if nu == 1\n ar.push(1)\n count += 1\n break\n elsif nu % 2 == 0\n ar.push(0)\n nu /= 2\n else\n ar.push(1)\n count += 1\n nu /= 2\n end\nend\nleng = ar.length\nif count == leng\n puts \"#{count + 1} #{count*2}\"\n for i in 1..count\n puts \"#{i} #{i + 1} 0\"\n end\n for i in 1..count\n puts \"#{i} #{i + 1} #{2**(count - i)}\"\n end\n exit\nend\n\ncheck = 0\ncheck2 = 0\nfor i in 0..leng - 2\n if (ar[0] == 0 && i == 0) || (ar[0] == 1 && ar[1] == 0 && i == 0)\n check += 1\n elsif i != 0 && ar[i] == 1\n check += 1\n end\n if ar[i] == 1 && check2 == i\n check2 += 1\n end\nend\n\ncount2 = 0\nputs \"#{leng} #{(leng - 1)*2 + check}\"\nfor i in 1..leng - 1\n puts \"#{i} #{i + 1} #{2**(leng - 1 - i)}\"\nend\nfor i in 1..leng - 1\n puts \"#{i} #{i + 1} 0\"\nend\nfor i in 2..leng\n if check2 >= 2 && check2 == leng + 1 - i\n for j in 1..i - 1\n if ar[-j] == 1\n count2 += 2**(leng - j)\n end\n end\n puts \"1 #{i - 1} #{count2}\"\n exit\n elsif (ar[-i] == 1) && (i != leng)\n for j in 1..i - 1\n if ar[-j] == 1\n count2 += 2**(leng - j)\n end\n end\n puts \"1 #{i} #{count2}\"\n elsif (i == leng && ar[0] == 1 && ar[1] == 0)\n for j in 1..i - 1\n if ar[-j] == 1\n count2 += 2**(leng - j)\n end\n end\n puts \"1 #{leng - 1} #{inst - 1}\"\n elsif (i == leng && ar[0] == 0)\n puts \"1 #{leng} #{inst}\"\n end\n count2 = 0\nend\n\np check2\np ar.reverse\n", "language": "Ruby", "metadata": {"date": 1538620243, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03267.html", "problem_id": "p03267", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03267/input.txt", "sample_output_relpath": "derived/input_output/data/p03267/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03267/Ruby/s359615898.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s359615898", "user_id": "u596822503"}, "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": "nu = gets.to_i - 1\ninst = nu\nar = []\ncount = 0\nfor i in 0..19\n if nu == 1\n ar.push(1)\n count += 1\n break\n elsif nu % 2 == 0\n ar.push(0)\n nu /= 2\n else\n ar.push(1)\n count += 1\n nu /= 2\n end\nend\nleng = ar.length\nif count == leng\n puts \"#{count + 1} #{count*2}\"\n for i in 1..count\n puts \"#{i} #{i + 1} 0\"\n end\n for i in 1..count\n puts \"#{i} #{i + 1} #{2**(count - i)}\"\n end\n exit\nend\n\ncheck = 0\ncheck2 = 0\nfor i in 0..leng - 2\n if (ar[0] == 0 && i == 0) || (ar[0] == 1 && ar[1] == 0 && i == 0)\n check += 1\n elsif i != 0 && ar[i] == 1\n check += 1\n end\n if ar[i] == 1 && check2 == i\n check2 += 1\n end\nend\n\ncount2 = 0\nputs \"#{leng} #{(leng - 1)*2 + check}\"\nfor i in 1..leng - 1\n puts \"#{i} #{i + 1} #{2**(leng - 1 - i)}\"\nend\nfor i in 1..leng - 1\n puts \"#{i} #{i + 1} 0\"\nend\nfor i in 2..leng\n if check2 >= 2 && check2 == leng + 1 - i\n for j in 1..i - 1\n if ar[-j] == 1\n count2 += 2**(leng - j)\n end\n end\n puts \"1 #{i - 1} #{count2}\"\n exit\n elsif (ar[-i] == 1) && (i != leng)\n for j in 1..i - 1\n if ar[-j] == 1\n count2 += 2**(leng - j)\n end\n end\n puts \"1 #{i} #{count2}\"\n elsif (i == leng && ar[0] == 1 && ar[1] == 0)\n for j in 1..i - 1\n if ar[-j] == 1\n count2 += 2**(leng - j)\n end\n end\n puts \"1 #{leng - 1} #{inst - 1}\"\n elsif (i == leng && ar[0] == 0)\n puts \"1 #{leng} #{inst}\"\n end\n count2 = 0\nend\n\np check2\np ar.reverse\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": "p03267", "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": 1463, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s180782876", "group_id": "codeNet:p03272", "input_text": "a,b=gets.split.map(&:to_i)\nputs a-b+1", "language": "Ruby", "metadata": {"date": 1572036461, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03272.html", "problem_id": "p03272", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03272/input.txt", "sample_output_relpath": "derived/input_output/data/p03272/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03272/Ruby/s180782876.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s180782876", "user_id": "u585819925"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "a,b=gets.split.map(&:to_i)\nputs a-b+1", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is an N-car train.\n\nYou are given an integer i. Find the value of j such that the following statement is true: \"the i-th car from the front of the train is the j-th car from the back.\"\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN i\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4 2\n\nSample Output 1\n\n3\n\nThe second car from the front of a 4-car train is the third car from the back.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n15 11\n\nSample Output 3\n\n5", "sample_input": "4 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03272", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is an N-car train.\n\nYou are given an integer i. Find the value of j such that the following statement is true: \"the i-th car from the front of the train is the j-th car from the back.\"\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN i\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4 2\n\nSample Output 1\n\n3\n\nThe second car from the front of a 4-car train is the third car from the back.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n15 11\n\nSample Output 3\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 37, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s877321776", "group_id": "codeNet:p03273", "input_text": "H, W = gets.split.map(&:to_i)\nputs (0...H).map {gets.chomp.chars}.\n reject {|xs| xs.all? {|x| x == \".\"}}.\n transpose.\n reject {|xs| xs.all? {|x| x == \".\"}}.\n transpose.\n map {|xs| xs.join}", "language": "Ruby", "metadata": {"date": 1535949592, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03273.html", "problem_id": "p03273", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03273/input.txt", "sample_output_relpath": "derived/input_output/data/p03273/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03273/Ruby/s877321776.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s877321776", "user_id": "u644856766"}, "prompt_components": {"gold_output": "###\n###\n.##\n", "input_to_evaluate": "H, W = gets.split.map(&:to_i)\nputs (0...H).map {gets.chomp.chars}.\n reject {|xs| xs.all? {|x| x == \".\"}}.\n transpose.\n reject {|xs| xs.all? {|x| x == \".\"}}.\n transpose.\n map {|xs| xs.join}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "sample_input": "4 4\n##.#\n....\n##.#\n.#.#\n"}, "reference_outputs": ["###\n###\n.##\n"], "source_document_id": "p03273", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 193, "cpu_time_ms": 13, "memory_kb": 2684}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s444347070", "group_id": "codeNet:p03280", "input_text": "x,y=gets.chomp.split.map(&:to_i)\nprint x*y-x-y+1", "language": "Ruby", "metadata": {"date": 1587277456, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03280.html", "problem_id": "p03280", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03280/input.txt", "sample_output_relpath": "derived/input_output/data/p03280/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03280/Ruby/s444347070.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s444347070", "user_id": "u375695365"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "x,y=gets.chomp.split.map(&:to_i)\nprint x*y-x-y+1", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThere is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.)\n\nWhat is the area of this yard excluding the roads? Find it.\n\nNote\n\nIt can be proved that the positions of the roads do not affect the area.\n\nConstraints\n\nA is an integer between 2 and 100 (inclusive).\n\nB is an integer between 2 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the area of this yard excluding the roads (in square yards).\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n1\n\nIn this case, the area is 1 square yard.\n\nSample Input 2\n\n5 7\n\nSample Output 2\n\n24\n\nIn this case, the area is 24 square yards.", "sample_input": "2 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03280", "source_text": "Score: 100 points\n\nProblem Statement\n\nThere is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.)\n\nWhat is the area of this yard excluding the roads? Find it.\n\nNote\n\nIt can be proved that the positions of the roads do not affect the area.\n\nConstraints\n\nA is an integer between 2 and 100 (inclusive).\n\nB is an integer between 2 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the area of this yard excluding the roads (in square yards).\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n1\n\nIn this case, the area is 1 square yard.\n\nSample Input 2\n\n5 7\n\nSample Output 2\n\n24\n\nIn this case, the area is 24 square yards.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 48, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s593017379", "group_id": "codeNet:p03280", "input_text": "a, b = gets.split.map(&:to_i)\n\nputs (a * b) - a - b + 1", "language": "Ruby", "metadata": {"date": 1566483008, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03280.html", "problem_id": "p03280", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03280/input.txt", "sample_output_relpath": "derived/input_output/data/p03280/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03280/Ruby/s593017379.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s593017379", "user_id": "u457499130"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "a, b = gets.split.map(&:to_i)\n\nputs (a * b) - a - b + 1", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThere is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.)\n\nWhat is the area of this yard excluding the roads? Find it.\n\nNote\n\nIt can be proved that the positions of the roads do not affect the area.\n\nConstraints\n\nA is an integer between 2 and 100 (inclusive).\n\nB is an integer between 2 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the area of this yard excluding the roads (in square yards).\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n1\n\nIn this case, the area is 1 square yard.\n\nSample Input 2\n\n5 7\n\nSample Output 2\n\n24\n\nIn this case, the area is 24 square yards.", "sample_input": "2 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03280", "source_text": "Score: 100 points\n\nProblem Statement\n\nThere is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.)\n\nWhat is the area of this yard excluding the roads? Find it.\n\nNote\n\nIt can be proved that the positions of the roads do not affect the area.\n\nConstraints\n\nA is an integer between 2 and 100 (inclusive).\n\nB is an integer between 2 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the area of this yard excluding the roads (in square yards).\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n1\n\nIn this case, the area is 1 square yard.\n\nSample Input 2\n\n5 7\n\nSample Output 2\n\n24\n\nIn this case, the area is 24 square yards.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 55, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s405866690", "group_id": "codeNet:p03280", "input_text": "a, b = gets.chomp.split.map(&:to_i)\nputs (a-1) * (b-1)", "language": "Ruby", "metadata": {"date": 1540953990, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03280.html", "problem_id": "p03280", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03280/input.txt", "sample_output_relpath": "derived/input_output/data/p03280/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03280/Ruby/s405866690.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s405866690", "user_id": "u307252896"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "a, b = gets.chomp.split.map(&:to_i)\nputs (a-1) * (b-1)", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThere is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.)\n\nWhat is the area of this yard excluding the roads? Find it.\n\nNote\n\nIt can be proved that the positions of the roads do not affect the area.\n\nConstraints\n\nA is an integer between 2 and 100 (inclusive).\n\nB is an integer between 2 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the area of this yard excluding the roads (in square yards).\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n1\n\nIn this case, the area is 1 square yard.\n\nSample Input 2\n\n5 7\n\nSample Output 2\n\n24\n\nIn this case, the area is 24 square yards.", "sample_input": "2 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03280", "source_text": "Score: 100 points\n\nProblem Statement\n\nThere is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.)\n\nWhat is the area of this yard excluding the roads? Find it.\n\nNote\n\nIt can be proved that the positions of the roads do not affect the area.\n\nConstraints\n\nA is an integer between 2 and 100 (inclusive).\n\nB is an integer between 2 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the area of this yard excluding the roads (in square yards).\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n1\n\nIn this case, the area is 1 square yard.\n\nSample Input 2\n\n5 7\n\nSample Output 2\n\n24\n\nIn this case, the area is 24 square yards.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 54, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s119017734", "group_id": "codeNet:p03281", "input_text": "N = gets.to_i\ncnt = 0\n(1..N).each do |i|\n dn = 0\n next if i.even?\n (1..i).each do |n|\n dn += 1 if i%n == 0\n end\n cnt += 1 if dn == 8\nend\n\nputs cnt", "language": "Ruby", "metadata": {"date": 1566321631, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s119017734.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s119017734", "user_id": "u244087909"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N = gets.to_i\ncnt = 0\n(1..N).each do |i|\n dn = 0\n next if i.even?\n (1..i).each do |n|\n dn += 1 if i%n == 0\n end\n cnt += 1 if dn == 8\nend\n\nputs cnt", "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": 154, "cpu_time_ms": 8, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s259185560", "group_id": "codeNet:p03281", "input_text": "N = gets.to_i\nc = 0\n(1..N).each do |n|\n next unless n.odd?\n c += (1..n).count { |m| (n % m).zero? } == 8 ? 1 : 0\nend \nputs c", "language": "Ruby", "metadata": {"date": 1534650458, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s259185560.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s259185560", "user_id": "u304013285"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N = gets.to_i\nc = 0\n(1..N).each do |n|\n next unless n.odd?\n c += (1..n).count { |m| (n % m).zero? } == 8 ? 1 : 0\nend \nputs c", "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": 137, "cpu_time_ms": 8, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s831162064", "group_id": "codeNet:p03282", "input_text": "p->(s,k){s.each_with_index{|i,j|return (j(s,k){s.each_with_index{|i,j|return (j= value\n right = mid\n else\n left = mid\n end\n end\n right\n end\n\n def unique\n res = [self.first]\n each_cons(2) do |a, b|\n if a != b\n res.push(b)\n end\n end\n res\n end\nend\n\ndef get_ints\n gets.chomp.split.map(&:to_i)\nend\n\ndef get_ints_minus_one\n get_ints.map { |x| x - 1 }\nend\n\ndef get_int\n gets.chomp.to_i\nend\n\ndef cumulative_sum(arr)\n arr.reduce([0]) do |prev, cur|\n prev.push(prev.last + cur)\n prev\n end\nend\n\nN, M, Q = get_ints\n\narray = Array.new(N+1) { Array.new(N+1, 0) }\nM.times do |i|\n l, r = get_ints\n array[l][r] += 1\nend\n\nS = Array.new(N+1) { Array.new(N+1, 0) }\n\n1.step(N) do |i|\n 1.step(N) do |j|\n S[i][j] = array[i][j] + S[i][j-1] + S[i-1][j] - S[i-1][j-1]\n end\nend\n\nQ.times do\n l, r = get_ints\n puts S[r][r] - S[r][l-1] - S[l-1][r] + S[l-1][l-1]\nend\n", "language": "Ruby", "metadata": {"date": 1595559618, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s489573896.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s489573896", "user_id": "u305883349"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#!/usr/bin/env ruby\n\nrequire 'set'\n\nclass Hash\n def push(key, value)\n self[key] = [] if self[key] == nil\n self[key].push(value)\n end\nend\n\nclass Array\n def lower_bound(value)\n left = -1;\n right = self.length;\n while left + 1 < right\n mid = left + (right - left) / 2;\n if self[mid] >= value\n right = mid\n else\n left = mid\n end\n end\n right\n end\n\n def unique\n res = [self.first]\n each_cons(2) do |a, b|\n if a != b\n res.push(b)\n end\n end\n res\n end\nend\n\ndef get_ints\n gets.chomp.split.map(&:to_i)\nend\n\ndef get_ints_minus_one\n get_ints.map { |x| x - 1 }\nend\n\ndef get_int\n gets.chomp.to_i\nend\n\ndef cumulative_sum(arr)\n arr.reduce([0]) do |prev, cur|\n prev.push(prev.last + cur)\n prev\n end\nend\n\nN, M, Q = get_ints\n\narray = Array.new(N+1) { Array.new(N+1, 0) }\nM.times do |i|\n l, r = get_ints\n array[l][r] += 1\nend\n\nS = Array.new(N+1) { Array.new(N+1, 0) }\n\n1.step(N) do |i|\n 1.step(N) do |j|\n S[i][j] = array[i][j] + S[i][j-1] + S[i-1][j] - S[i-1][j-1]\n end\nend\n\nQ.times do\n l, r = get_ints\n puts S[r][r] - S[r][l-1] - S[l-1][r] + S[l-1][l-1]\nend\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nIn Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east.\nA company called AtCoder Express possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i).\nTakahashi the king is interested in the following Q matters:\n\nThe number of the trains that runs strictly within the section from City p_i to City q_i, that is, the number of trains j such that p_i \\leq L_j and R_j \\leq q_i.\n\nAlthough he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him.\n\nConstraints\n\nN is an integer between 1 and 500 (inclusive).\n\nM is an integer between 1 and 200 \\ 000 (inclusive).\n\nQ is an integer between 1 and 100 \\ 000 (inclusive).\n\n1 \\leq L_i \\leq R_i \\leq N (1 \\leq i \\leq M)\n\n1 \\leq p_i \\leq q_i \\leq N (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\nL_1 R_1\nL_2 R_2\n:\nL_M R_M\np_1 q_1\np_2 q_2\n:\np_Q q_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the number of the trains that runs strictly within the section from City p_i to City q_i.\n\nSample Input 1\n\n2 3 1\n1 1\n1 2\n2 2\n1 2\n\nSample Output 1\n\n3\n\nAs all the trains runs within the section from City 1 to City 2, the answer to the only query is 3.\n\nSample Input 2\n\n10 3 2\n1 5\n2 8\n7 10\n1 7\n3 10\n\nSample Output 2\n\n1\n1\n\nThe first query is on the section from City 1 to 7. There is only one train that runs strictly within that section: Train 1.\nThe second query is on the section from City 3 to 10. There is only one train that runs strictly within that section: Train 3.\n\nSample Input 3\n\n10 10 10\n1 6\n2 9\n4 5\n4 7\n4 7\n5 8\n6 6\n6 7\n7 9\n10 10\n1 8\n1 9\n1 10\n2 8\n2 9\n2 10\n3 8\n3 9\n3 10\n1 10\n\nSample Output 3\n\n7\n9\n10\n6\n8\n9\n6\n7\n8\n10", "sample_input": "2 3 1\n1 1\n1 2\n2 2\n1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03283", "source_text": "Score: 400 points\n\nProblem Statement\n\nIn Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east.\nA company called AtCoder Express possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i).\nTakahashi the king is interested in the following Q matters:\n\nThe number of the trains that runs strictly within the section from City p_i to City q_i, that is, the number of trains j such that p_i \\leq L_j and R_j \\leq q_i.\n\nAlthough he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him.\n\nConstraints\n\nN is an integer between 1 and 500 (inclusive).\n\nM is an integer between 1 and 200 \\ 000 (inclusive).\n\nQ is an integer between 1 and 100 \\ 000 (inclusive).\n\n1 \\leq L_i \\leq R_i \\leq N (1 \\leq i \\leq M)\n\n1 \\leq p_i \\leq q_i \\leq N (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\nL_1 R_1\nL_2 R_2\n:\nL_M R_M\np_1 q_1\np_2 q_2\n:\np_Q q_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the number of the trains that runs strictly within the section from City p_i to City q_i.\n\nSample Input 1\n\n2 3 1\n1 1\n1 2\n2 2\n1 2\n\nSample Output 1\n\n3\n\nAs all the trains runs within the section from City 1 to City 2, the answer to the only query is 3.\n\nSample Input 2\n\n10 3 2\n1 5\n2 8\n7 10\n1 7\n3 10\n\nSample Output 2\n\n1\n1\n\nThe first query is on the section from City 1 to 7. There is only one train that runs strictly within that section: Train 1.\nThe second query is on the section from City 3 to 10. There is only one train that runs strictly within that section: Train 3.\n\nSample Input 3\n\n10 10 10\n1 6\n2 9\n4 5\n4 7\n4 7\n5 8\n6 6\n6 7\n7 9\n10 10\n1 8\n1 9\n1 10\n2 8\n2 9\n2 10\n3 8\n3 9\n3 10\n1 10\n\nSample Output 3\n\n7\n9\n10\n6\n8\n9\n6\n7\n8\n10", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1148, "cpu_time_ms": 392, "memory_kb": 18204}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s660022499", "group_id": "codeNet:p03283", "input_text": "N, M, Q = gets.split(\" \").map { |e| e.to_i }\ndata = Array.new(N) { Array.new(N) {0} }\n\nfor i in 0..M-1 do\n li, ri = gets.split(\" \").map { |e| e.to_i }\n data[li-1][ri-1] += 1\nend\n\ndata2 = Array.new(N+1) {Array.new(N+1) {0}}\nfor i in 0..N-1 do\n count = 0\n for j in 0..N-1 do\n count += data[i][j]\n data2[i][j] = count\n end\nend\n\npq = []\nfor i in 0..Q-1 do\n piqi = gets.split(\" \").map { |e| e.to_i }\n pq << piqi\nend\n\nfor i in 0..Q-1 do\n pi, qi = pq[i]\n res = 0\n for j in pi-1..qi-1 do\n res += data2[j][qi-1] - data2[j][pi-2]\n end\n puts res\nend", "language": "Ruby", "metadata": {"date": 1535401231, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s660022499.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s660022499", "user_id": "u698460655"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "N, M, Q = gets.split(\" \").map { |e| e.to_i }\ndata = Array.new(N) { Array.new(N) {0} }\n\nfor i in 0..M-1 do\n li, ri = gets.split(\" \").map { |e| e.to_i }\n data[li-1][ri-1] += 1\nend\n\ndata2 = Array.new(N+1) {Array.new(N+1) {0}}\nfor i in 0..N-1 do\n count = 0\n for j in 0..N-1 do\n count += data[i][j]\n data2[i][j] = count\n end\nend\n\npq = []\nfor i in 0..Q-1 do\n piqi = gets.split(\" \").map { |e| e.to_i }\n pq << piqi\nend\n\nfor i in 0..Q-1 do\n pi, qi = pq[i]\n res = 0\n for j in pi-1..qi-1 do\n res += data2[j][qi-1] - data2[j][pi-2]\n end\n puts res\nend", "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": 559, "cpu_time_ms": 3161, "memory_kb": 14076}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s900866578", "group_id": "codeNet:p03284", "input_text": "N,K = gets.split.map(&:to_i)\nputs N % K == 0 ? 0 : 1", "language": "Ruby", "metadata": {"date": 1553086552, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03284.html", "problem_id": "p03284", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03284/input.txt", "sample_output_relpath": "derived/input_output/data/p03284/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03284/Ruby/s900866578.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s900866578", "user_id": "u502774641"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N,K = gets.split.map(&:to_i)\nputs N % K == 0 ? 0 : 1", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "sample_input": "7 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03284", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 52, "cpu_time_ms": 7, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s984760226", "group_id": "codeNet:p03287", "input_text": "n,m,*a=`dd`.split.map &:to_i\n*b=r=0\nh=Hash.new 0\na.map{|e|b<<(b[-1]+e)%m}\nb.map{|e|t=(m-e)%m;r+=h[t];h[e]+=1}\np r", "language": "Ruby", "metadata": {"date": 1534769808, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03287.html", "problem_id": "p03287", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03287/input.txt", "sample_output_relpath": "derived/input_output/data/p03287/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03287/Ruby/s984760226.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s984760226", "user_id": "u280667879"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "n,m,*a=`dd`.split.map &:to_i\n*b=r=0\nh=Hash.new 0\na.map{|e|b<<(b[-1]+e)%m}\nb.map{|e|t=(m-e)%m;r+=h[t];h[e]+=1}\np r", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies.\n\nYou will take out the candies from some consecutive boxes and distribute them evenly to M children.\n\nSuch being the case, find the number of the pairs (l, r) that satisfy the following:\n\nl and r are both integers and satisfy 1 \\leq l \\leq r \\leq N.\n\nA_l + A_{l+1} + ... + A_r is a multiple of M.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n2 \\leq M \\leq 10^9\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of the pairs (l, r) that satisfy the conditions.\n\nNote that the number may not fit into a 32-bit integer type.\n\nSample Input 1\n\n3 2\n4 1 5\n\nSample Output 1\n\n3\n\nThe sum A_l + A_{l+1} + ... + A_r for each pair (l, r) is as follows:\n\nSum for (1, 1): 4\n\nSum for (1, 2): 5\n\nSum for (1, 3): 10\n\nSum for (2, 2): 1\n\nSum for (2, 3): 6\n\nSum for (3, 3): 5\n\nAmong these, three are multiples of 2.\n\nSample Input 2\n\n13 17\n29 7 5 7 9 51 7 13 8 55 42 9 81\n\nSample Output 2\n\n6\n\nSample Input 3\n\n10 400000000\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 3\n\n25", "sample_input": "3 2\n4 1 5\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03287", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies.\n\nYou will take out the candies from some consecutive boxes and distribute them evenly to M children.\n\nSuch being the case, find the number of the pairs (l, r) that satisfy the following:\n\nl and r are both integers and satisfy 1 \\leq l \\leq r \\leq N.\n\nA_l + A_{l+1} + ... + A_r is a multiple of M.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n2 \\leq M \\leq 10^9\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of the pairs (l, r) that satisfy the conditions.\n\nNote that the number may not fit into a 32-bit integer type.\n\nSample Input 1\n\n3 2\n4 1 5\n\nSample Output 1\n\n3\n\nThe sum A_l + A_{l+1} + ... + A_r for each pair (l, r) is as follows:\n\nSum for (1, 1): 4\n\nSum for (1, 2): 5\n\nSum for (1, 3): 10\n\nSum for (2, 2): 1\n\nSum for (2, 3): 6\n\nSum for (3, 3): 5\n\nAmong these, three are multiples of 2.\n\nSample Input 2\n\n13 17\n29 7 5 7 9 51 7 13 8 55 42 9 81\n\nSample Output 2\n\n6\n\nSample Input 3\n\n10 400000000\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 3\n\n25", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 113, "cpu_time_ms": 108, "memory_kb": 17432}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s045380100", "group_id": "codeNet:p03289", "input_text": "# frozen_string_literal: true\n\ns = gets.chomp.chars\n\nif s[0] == 'A' && s[2..-2].count('C') == 1 && s.count { |c| c.upcase == c } == 2\n puts :AC\nelse\n puts :WA\nend", "language": "Ruby", "metadata": {"date": 1586509116, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03289.html", "problem_id": "p03289", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03289/input.txt", "sample_output_relpath": "derived/input_output/data/p03289/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03289/Ruby/s045380100.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s045380100", "user_id": "u104886851"}, "prompt_components": {"gold_output": "AC\n", "input_to_evaluate": "# frozen_string_literal: true\n\ns = gets.chomp.chars\n\nif s[0] == 'A' && s[2..-2].count('C') == 1 && s.count { |c| c.upcase == c } == 2\n puts :AC\nelse\n puts :WA\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "sample_input": "AtCoder\n"}, "reference_outputs": ["AC\n"], "source_document_id": "p03289", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 164, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s850021708", "group_id": "codeNet:p03289", "input_text": "S = gets.chomp\n\nans = 'AC'\n\nans = 'WA' if S[0] != 'A'\nans = 'WA' if S[2..-2].count('C') != 1\nans = 'WA' if S.count('A-Z') != 2\n\nputs ans\n", "language": "Ruby", "metadata": {"date": 1581558682, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03289.html", "problem_id": "p03289", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03289/input.txt", "sample_output_relpath": "derived/input_output/data/p03289/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03289/Ruby/s850021708.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s850021708", "user_id": "u276517671"}, "prompt_components": {"gold_output": "AC\n", "input_to_evaluate": "S = gets.chomp\n\nans = 'AC'\n\nans = 'WA' if S[0] != 'A'\nans = 'WA' if S[2..-2].count('C') != 1\nans = 'WA' if S.count('A-Z') != 2\n\nputs ans\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "sample_input": "AtCoder\n"}, "reference_outputs": ["AC\n"], "source_document_id": "p03289", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 137, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s546602978", "group_id": "codeNet:p03289", "input_text": "s = gets.chomp\nif s.match(/^A([a-z]{0,1}C[a-z]*|[a-z]*C[a-z]{0,1})$/).nil?\n puts 'WA'\nelse\n puts 'AC'\nend", "language": "Ruby", "metadata": {"date": 1567222245, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03289.html", "problem_id": "p03289", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03289/input.txt", "sample_output_relpath": "derived/input_output/data/p03289/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03289/Ruby/s546602978.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s546602978", "user_id": "u579668395"}, "prompt_components": {"gold_output": "AC\n", "input_to_evaluate": "s = gets.chomp\nif s.match(/^A([a-z]{0,1}C[a-z]*|[a-z]*C[a-z]{0,1})$/).nil?\n puts 'WA'\nelse\n puts 'AC'\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "sample_input": "AtCoder\n"}, "reference_outputs": ["AC\n"], "source_document_id": "p03289", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 107, "cpu_time_ms": 10, "memory_kb": 3964}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s519380854", "group_id": "codeNet:p03289", "input_text": "#!/usr/bin/ruby \n#encoding: utf-8\n\ns = gets.chomp\n\ncnt = 0\n(2..s.size-2).each do |i|\n if s[i] == 'C'\n cnt += 1\n end\nend\n\nif cnt != 1 or s[0] != 'A'\n puts \"WA\"\n exit\nend\n\n(0..s.size-1).each do |i| \n if s[i] != 'A' and s[i] != 'C'\n if s[i].ord < 97 or s[i].ord > 122 \n puts \"WA\"\n exit\n end\n end\nend\n\nputs \"AC\"\n", "language": "Ruby", "metadata": {"date": 1560088904, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03289.html", "problem_id": "p03289", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03289/input.txt", "sample_output_relpath": "derived/input_output/data/p03289/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03289/Ruby/s519380854.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s519380854", "user_id": "u998741086"}, "prompt_components": {"gold_output": "AC\n", "input_to_evaluate": "#!/usr/bin/ruby \n#encoding: utf-8\n\ns = gets.chomp\n\ncnt = 0\n(2..s.size-2).each do |i|\n if s[i] == 'C'\n cnt += 1\n end\nend\n\nif cnt != 1 or s[0] != 'A'\n puts \"WA\"\n exit\nend\n\n(0..s.size-1).each do |i| \n if s[i] != 'A' and s[i] != 'C'\n if s[i].ord < 97 or s[i].ord > 122 \n puts \"WA\"\n exit\n end\n end\nend\n\nputs \"AC\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "sample_input": "AtCoder\n"}, "reference_outputs": ["AC\n"], "source_document_id": "p03289", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 333, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s928249545", "group_id": "codeNet:p03289", "input_text": "s= gets.chomp\ncount=0\nflag = false\nl=s[2..s.size-2].split(\"\")\n l.each do |i|\n if i == \"C\"\n count=count+1\n flag = true\n end\n if i==\"A\" || i==\"B\" || i>\"C\"\n flag == false\n end\n if count==2\n flag = false\n break\n end\nend\nif s[0]== \"A\" && flag ==true\n puts \"AC\"\nelse\n puts \"WA\"\nend\n", "language": "Ruby", "metadata": {"date": 1533518634, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03289.html", "problem_id": "p03289", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03289/input.txt", "sample_output_relpath": "derived/input_output/data/p03289/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03289/Ruby/s928249545.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s928249545", "user_id": "u308416164"}, "prompt_components": {"gold_output": "AC\n", "input_to_evaluate": "s= gets.chomp\ncount=0\nflag = false\nl=s[2..s.size-2].split(\"\")\n l.each do |i|\n if i == \"C\"\n count=count+1\n flag = true\n end\n if i==\"A\" || i==\"B\" || i>\"C\"\n flag == false\n end\n if count==2\n flag = false\n break\n end\nend\nif s[0]== \"A\" && flag ==true\n puts \"AC\"\nelse\n puts \"WA\"\nend\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "sample_input": "AtCoder\n"}, "reference_outputs": ["AC\n"], "source_document_id": "p03289", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 300, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s239124393", "group_id": "codeNet:p03289", "input_text": "lines = $stdin.read\narray = lines.split(\"\\n\")\nS = array[0].split(\"\")\nstr = S.dup\n\nif S.first=='A' and S[2...S.length-1].count{|s| s=='C'}==1\n str.delete_at(0)\n idx = S[2...S.length-1].index{|s| s=='C'} + 2\n str.delete_at(idx)\n\n if str =~ /[a-z]+/\n puts \"AC\"\n else\n puts \"WA\"\n end\nelse\n puts \"WA\"\nend", "language": "Ruby", "metadata": {"date": 1533518307, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03289.html", "problem_id": "p03289", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03289/input.txt", "sample_output_relpath": "derived/input_output/data/p03289/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03289/Ruby/s239124393.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s239124393", "user_id": "u108333452"}, "prompt_components": {"gold_output": "AC\n", "input_to_evaluate": "lines = $stdin.read\narray = lines.split(\"\\n\")\nS = array[0].split(\"\")\nstr = S.dup\n\nif S.first=='A' and S[2...S.length-1].count{|s| s=='C'}==1\n str.delete_at(0)\n idx = S[2...S.length-1].index{|s| s=='C'} + 2\n str.delete_at(idx)\n\n if str =~ /[a-z]+/\n puts \"AC\"\n else\n puts \"WA\"\n end\nelse\n puts \"WA\"\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "sample_input": "AtCoder\n"}, "reference_outputs": ["AC\n"], "source_document_id": "p03289", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 318, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s120377679", "group_id": "codeNet:p03290", "input_text": "\"\n3. ABC104C - All Green\nリンク: https://atcoder.jp/contests/abc104/tasks/abc104_c\n\"\n\n# 入力\nD, G = gets.split.map(&:to_i)\np = []\nc = []\nD.times do |i|\n p[i], c[i] = gets.split.map(&:to_i)\nend\n\n# Dでbit全探索\n# i桁目をp[i]進報で表せば、得点の計算できそう\nans = 10000\n(1 << D).times do |i|\n point = 0\n ma = -1\n gap = 0\n num = 0\n tmp = 0\n D.times do |j|\n # i[j]==1なら配点100(j+1)の問題を完全に解く\n if i[j] == 1\n point = point + 100*(j+1) * p[j] + c[j]\n num = num + p[j]\n if point >= G\n ans = [ans, num].min\n end\n else\n ma = [ma, j].max\n end\n end\n # ここまでで全問解く配点の問題は決まった\n # 目標までの差を出す\n gap = G - point\n if ma != -1 && gap > 0\n # 完全に解かない(i[j]==0なるjの最大値)もののうち、\n # 最も高い配点はmaに入ってる配点100(ma+1)点 \n tmp = gap / (100*(ma+1)) #その配点を何問解けば目標達成できるか\n if tmp <= p[ma]-1 # これを満たさない場合は、完全に解く選択がミスってる\n # ここに入ったってことは、maの問題をnumだけ中途半端に解けば目標達成できる\n num = num + tmp\n ans = [ans, num].min\n end\n end\n puts ans\nend\nputs ans", "language": "Ruby", "metadata": {"date": 1587213626, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s120377679.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s120377679", "user_id": "u326288614"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "\"\n3. ABC104C - All Green\nリンク: https://atcoder.jp/contests/abc104/tasks/abc104_c\n\"\n\n# 入力\nD, G = gets.split.map(&:to_i)\np = []\nc = []\nD.times do |i|\n p[i], c[i] = gets.split.map(&:to_i)\nend\n\n# Dでbit全探索\n# i桁目をp[i]進報で表せば、得点の計算できそう\nans = 10000\n(1 << D).times do |i|\n point = 0\n ma = -1\n gap = 0\n num = 0\n tmp = 0\n D.times do |j|\n # i[j]==1なら配点100(j+1)の問題を完全に解く\n if i[j] == 1\n point = point + 100*(j+1) * p[j] + c[j]\n num = num + p[j]\n if point >= G\n ans = [ans, num].min\n end\n else\n ma = [ma, j].max\n end\n end\n # ここまでで全問解く配点の問題は決まった\n # 目標までの差を出す\n gap = G - point\n if ma != -1 && gap > 0\n # 完全に解かない(i[j]==0なるjの最大値)もののうち、\n # 最も高い配点はmaに入ってる配点100(ma+1)点 \n tmp = gap / (100*(ma+1)) #その配点を何問解けば目標達成できるか\n if tmp <= p[ma]-1 # これを満たさない場合は、完全に解く選択がミスってる\n # ここに入ったってことは、maの問題をnumだけ中途半端に解けば目標達成できる\n num = num + tmp\n ans = [ans, num].min\n end\n end\n puts ans\nend\nputs ans", "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": 1298, "cpu_time_ms": 14, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s101730856", "group_id": "codeNet:p03291", "input_text": "S = gets.chomp\nN = S.length\nMOD = 10**9+7\ndp = [1,0,0,0] # 3^cnt(X),A,AB,ABC\nN.times do |i|\n\tprev = dp.dup\n\tc = S[i]\n\tif c == \"A\"\n\t\tdp[1] += prev[0]\n\telsif c == \"B\"\n\t\tdp[2] += prev[1]\n\telsif c == \"C\"\n\t\tdp[3] += prev[2]\n\telse\n\t\tdp[1] += prev[1]*2 + prev[0]\n\t\tdp[2] += prev[2]*2 + prev[1]\n\t\tdp[3] += prev[3]*2 + prev[2]\n\t\tdp[0] *= 3\n\tend\n\tdp[0] %= MOD\n\tdp[1] %= MOD\n\tdp[2] %= MOD\n\tdp[3] %= MOD\nend\n\np dp[3]", "language": "Ruby", "metadata": {"date": 1553701714, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03291.html", "problem_id": "p03291", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03291/input.txt", "sample_output_relpath": "derived/input_output/data/p03291/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03291/Ruby/s101730856.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s101730856", "user_id": "u123276241"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "S = gets.chomp\nN = S.length\nMOD = 10**9+7\ndp = [1,0,0,0] # 3^cnt(X),A,AB,ABC\nN.times do |i|\n\tprev = dp.dup\n\tc = S[i]\n\tif c == \"A\"\n\t\tdp[1] += prev[0]\n\telsif c == \"B\"\n\t\tdp[2] += prev[1]\n\telsif c == \"C\"\n\t\tdp[3] += prev[2]\n\telse\n\t\tdp[1] += prev[1]*2 + prev[0]\n\t\tdp[2] += prev[2]*2 + prev[1]\n\t\tdp[3] += prev[3]*2 + prev[2]\n\t\tdp[0] *= 3\n\tend\n\tdp[0] %= MOD\n\tdp[1] %= MOD\n\tdp[2] %= MOD\n\tdp[3] %= MOD\nend\n\np dp[3]", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThe ABC number of a string T is the number of triples of integers (i, j, k) that satisfy all of the following conditions:\n\n1 ≤ i < j < k ≤ |T| (|T| is the length of T.)\n\nT_i = A (T_i is the i-th character of T from the beginning.)\n\nT_j = B\n\nT_k = C\n\nFor example, when T = ABCBC, there are three triples of integers (i, j, k) that satisfy the conditions: (1, 2, 3), (1, 2, 5), (1, 4, 5). Thus, the ABC number of T is 3.\n\nYou are given a string S. Each character of S is A, B, C or ?.\n\nLet Q be the number of occurrences of ? in S. We can make 3^Q strings by replacing each occurrence of ? in S with A, B or C. Find the sum of the ABC numbers of all these strings.\n\nThis sum can be extremely large, so print the sum modulo 10^9 + 7.\n\nConstraints\n\n3 ≤ |S| ≤ 10^5\n\nEach character of S is A, B, C or ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.\n\nSample Input 1\n\nA??C\n\nSample Output 1\n\n8\n\nIn this case, Q = 2, and we can make 3^Q = 9 strings by by replacing each occurrence of ? with A, B or C. The ABC number of each of these strings is as follows:\n\nAAAC: 0\n\nAABC: 2\n\nAACC: 0\n\nABAC: 1\n\nABBC: 2\n\nABCC: 2\n\nACAC: 0\n\nACBC: 1\n\nACCC: 0\n\nThe sum of these is 0 + 2 + 0 + 1 + 2 + 2 + 0 + 1 + 0 = 8, so we print 8 modulo 10^9 + 7, that is, 8.\n\nSample Input 2\n\nABCBC\n\nSample Output 2\n\n3\n\nWhen Q = 0, we print the ABC number of S itself, modulo 10^9 + 7. This string is the same as the one given as an example in the problem statement, and its ABC number is 3.\n\nSample Input 3\n\n????C?????B??????A???????\n\nSample Output 3\n\n979596887\n\nIn this case, the sum of the ABC numbers of all the 3^Q strings is 2291979612924, and we should print this number modulo 10^9 + 7, that is, 979596887.", "sample_input": "A??C\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03291", "source_text": "Score : 400 points\n\nProblem Statement\n\nThe ABC number of a string T is the number of triples of integers (i, j, k) that satisfy all of the following conditions:\n\n1 ≤ i < j < k ≤ |T| (|T| is the length of T.)\n\nT_i = A (T_i is the i-th character of T from the beginning.)\n\nT_j = B\n\nT_k = C\n\nFor example, when T = ABCBC, there are three triples of integers (i, j, k) that satisfy the conditions: (1, 2, 3), (1, 2, 5), (1, 4, 5). Thus, the ABC number of T is 3.\n\nYou are given a string S. Each character of S is A, B, C or ?.\n\nLet Q be the number of occurrences of ? in S. We can make 3^Q strings by replacing each occurrence of ? in S with A, B or C. Find the sum of the ABC numbers of all these strings.\n\nThis sum can be extremely large, so print the sum modulo 10^9 + 7.\n\nConstraints\n\n3 ≤ |S| ≤ 10^5\n\nEach character of S is A, B, C or ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.\n\nSample Input 1\n\nA??C\n\nSample Output 1\n\n8\n\nIn this case, Q = 2, and we can make 3^Q = 9 strings by by replacing each occurrence of ? with A, B or C. The ABC number of each of these strings is as follows:\n\nAAAC: 0\n\nAABC: 2\n\nAACC: 0\n\nABAC: 1\n\nABBC: 2\n\nABCC: 2\n\nACAC: 0\n\nACBC: 1\n\nACCC: 0\n\nThe sum of these is 0 + 2 + 0 + 1 + 2 + 2 + 0 + 1 + 0 = 8, so we print 8 modulo 10^9 + 7, that is, 8.\n\nSample Input 2\n\nABCBC\n\nSample Output 2\n\n3\n\nWhen Q = 0, we print the ABC number of S itself, modulo 10^9 + 7. This string is the same as the one given as an example in the problem statement, and its ABC number is 3.\n\nSample Input 3\n\n????C?????B??????A???????\n\nSample Output 3\n\n979596887\n\nIn this case, the sum of the ABC numbers of all the 3^Q strings is 2291979612924, and we should print this number modulo 10^9 + 7, that is, 979596887.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 404, "cpu_time_ms": 157, "memory_kb": 2044}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s410166192", "group_id": "codeNet:p03292", "input_text": "i = gets.chomp.split(' ').map(&:to_i)\nresult = []\n\nfor p in 0..(i.length-1)\n for q in (p+1)..(i.length-1)\n result << (i[p]-i[q]).abs\n end\nend\n\nresult.sort!{ |i, j| i <=> j }.reverse!\nputs result[0]", "language": "Ruby", "metadata": {"date": 1532222745, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s410166192.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s410166192", "user_id": "u354075848"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "i = gets.chomp.split(' ').map(&:to_i)\nresult = []\n\nfor p in 0..(i.length-1)\n for q in (p+1)..(i.length-1)\n result << (i[p]-i[q]).abs\n end\nend\n\nresult.sort!{ |i, j| i <=> j }.reverse!\nputs result[0]", "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": 202, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s065512395", "group_id": "codeNet:p03293", "input_text": "s = gets.chomp.chars\nt = gets.chomp.chars\nns = s.count\n\nres = false\n\nres = true if s == t\nunless res\n ns.times do |i|\n first = s.delete_at(0)\n s << first\n if s == t\n res = true\n break\n end\n end \nend\nputs res ? 'Yes' : 'No'", "language": "Ruby", "metadata": {"date": 1576037187, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s065512395.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s065512395", "user_id": "u630043039"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "s = gets.chomp.chars\nt = gets.chomp.chars\nns = s.count\n\nres = false\n\nres = true if s == t\nunless res\n ns.times do |i|\n first = s.delete_at(0)\n s << first\n if s == t\n res = true\n break\n end\n end \nend\nputs res ? 'Yes' : 'No'", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given string S and T consisting of lowercase English letters.\n\nDetermine if S equals T after rotation.\n\nThat is, determine if S equals T after the following operation is performed some number of times:\n\nOperation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}.\n\nHere, |X| denotes the length of the string X.\n\nConstraints\n\n2 \\leq |S| \\leq 100\n\n|S| = |T|\n\nS and T consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf S equals T after rotation, print Yes; if it does not, print No.\n\nSample Input 1\n\nkyoto\ntokyo\n\nSample Output 1\n\nYes\n\nIn the first operation, kyoto becomes okyot.\n\nIn the second operation, okyot becomes tokyo.\n\nSample Input 2\n\nabc\narc\n\nSample Output 2\n\nNo\n\nabc does not equal arc after any number of operations.\n\nSample Input 3\n\naaaaaaaaaaaaaaab\naaaaaaaaaaaaaaab\n\nSample Output 3\n\nYes", "sample_input": "kyoto\ntokyo\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03293", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given string S and T consisting of lowercase English letters.\n\nDetermine if S equals T after rotation.\n\nThat is, determine if S equals T after the following operation is performed some number of times:\n\nOperation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}.\n\nHere, |X| denotes the length of the string X.\n\nConstraints\n\n2 \\leq |S| \\leq 100\n\n|S| = |T|\n\nS and T consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf S equals T after rotation, print Yes; if it does not, print No.\n\nSample Input 1\n\nkyoto\ntokyo\n\nSample Output 1\n\nYes\n\nIn the first operation, kyoto becomes okyot.\n\nIn the second operation, okyot becomes tokyo.\n\nSample Input 2\n\nabc\narc\n\nSample Output 2\n\nNo\n\nabc does not equal arc after any number of operations.\n\nSample Input 3\n\naaaaaaaaaaaaaaab\naaaaaaaaaaaaaaab\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 247, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s132969245", "group_id": "codeNet:p03293", "input_text": "require 'pp'\n\ns = gets.chomp! * 2\nt = gets.chomp!\n\nif s.match(/#{t}/)\n puts \"Yes\"\nelse\n puts \"No\"\nend\n", "language": "Ruby", "metadata": {"date": 1567913077, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s132969245.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s132969245", "user_id": "u754375546"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "require 'pp'\n\ns = gets.chomp! * 2\nt = gets.chomp!\n\nif s.match(/#{t}/)\n puts \"Yes\"\nelse\n puts \"No\"\nend\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": 108, "cpu_time_ms": 12, "memory_kb": 4092}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s442305694", "group_id": "codeNet:p03293", "input_text": "s=gets.chomp\nt=gets.chomp\ns< 即NG\n return false if morning < buy\n\n # 購入より補充のほうが少ない -> 即NG\n return false if adder < buy\n\n # 購入よりしきい値のほうが多い -> 即OK\n # 購入-1 <= しきい値 -> 即OK\n return true if buy-1 <= thresh\n\n # 初期処理\n # morningをthreshぎりぎりまで減らす\n if thresh < morning\n d = (morning - thresh) / buy\n morning -= buy * d\n end\n # adderもthreshぎりぎりまで減らす\n if thresh < adder\n d = (adder - thresh) / buy\n adder -= buy * d\n end\n\n s = morning\n s_ary = []\n inc = adder - buy\n\n while true do\n if s <= thresh\n # ここの回数を減らしたい!\n # s += adder\n # 単純に加算するのではなく、(adder-buy)ずつ増やしていって、threshを超えさせよう\n\n # thresh < s + (adder - buy) * XXX\n return true if inc == 0\n\n d = (thresh - s) / inc + 1\n s += inc * d\n else\n # 補充なしターン\n if s < buy\n return false\n end\n if s_ary.index(s)\n return true\n end\n # thresh上に出たところだけ記憶しておく\n s_ary << s\n s -= buy\n end\n end\nend\n\ndef main\n t = ARGF.gets.to_i\n\n t.times do\n morning, buy, thresh, adder = ARGF.gets.split.map(&:to_i)\n if judge(morning, buy, thresh, adder)\n puts 'Yes'\n else\n puts 'No'\n end\n end\nend\n\nif __FILE__ == $0\n main\nend\n", "language": "Ruby", "metadata": {"date": 1531624550, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03297.html", "problem_id": "p03297", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03297/input.txt", "sample_output_relpath": "derived/input_output/data/p03297/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03297/Ruby/s110617208.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s110617208", "user_id": "u657749689"}, "prompt_components": {"gold_output": "No\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n", "input_to_evaluate": "def judge(morning, buy, thresh, adder)\n # 朝より購入のほうが多い -> 即NG\n return false if morning < buy\n\n # 購入より補充のほうが少ない -> 即NG\n return false if adder < buy\n\n # 購入よりしきい値のほうが多い -> 即OK\n # 購入-1 <= しきい値 -> 即OK\n return true if buy-1 <= thresh\n\n # 初期処理\n # morningをthreshぎりぎりまで減らす\n if thresh < morning\n d = (morning - thresh) / buy\n morning -= buy * d\n end\n # adderもthreshぎりぎりまで減らす\n if thresh < adder\n d = (adder - thresh) / buy\n adder -= buy * d\n end\n\n s = morning\n s_ary = []\n inc = adder - buy\n\n while true do\n if s <= thresh\n # ここの回数を減らしたい!\n # s += adder\n # 単純に加算するのではなく、(adder-buy)ずつ増やしていって、threshを超えさせよう\n\n # thresh < s + (adder - buy) * XXX\n return true if inc == 0\n\n d = (thresh - s) / inc + 1\n s += inc * d\n else\n # 補充なしターン\n if s < buy\n return false\n end\n if s_ary.index(s)\n return true\n end\n # thresh上に出たところだけ記憶しておく\n s_ary << s\n s -= buy\n end\n end\nend\n\ndef main\n t = ARGF.gets.to_i\n\n t.times do\n morning, buy, thresh, adder = ARGF.gets.split.map(&:to_i)\n if judge(morning, buy, thresh, adder)\n puts 'Yes'\n else\n puts 'No'\n end\n end\nend\n\nif __FILE__ == $0\n main\nend\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nRingo Mart, a convenience store, sells apple juice.\n\nOn the opening day of Ringo Mart, there were A cans of juice in stock in the morning.\nSnuke buys B cans of juice here every day in the daytime.\nThen, the manager checks the number of cans of juice remaining in stock every night.\nIf there are C or less cans, D new cans will be added to the stock by the next morning.\n\nDetermine if Snuke can buy juice indefinitely, that is, there is always B or more cans of juice in stock when he attempts to buy them.\nNobody besides Snuke buy juice at this store.\n\nNote that each test case in this problem consists of T queries.\n\nConstraints\n\n1 \\leq T \\leq 300\n\n1 \\leq A, B, C, D \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\nA_1 B_1 C_1 D_1\nA_2 B_2 C_2 D_2\n:\nA_T B_T C_T D_T\n\nIn the i-th query, A = A_i, B = B_i, C = C_i, D = D_i.\n\nOutput\n\nPrint T lines. The i-th line should contain Yes if Snuke can buy apple juice indefinitely in the i-th query; No otherwise.\n\nSample Input 1\n\n14\n9 7 5 9\n9 7 6 9\n14 10 7 12\n14 10 8 12\n14 10 9 12\n14 10 7 11\n14 10 8 11\n14 10 9 11\n9 10 5 10\n10 10 5 10\n11 10 5 10\n16 10 5 10\n1000000000000000000 17 14 999999999999999985\n1000000000000000000 17 15 999999999999999985\n\nSample Output 1\n\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n\nIn the first query, the number of cans of juice in stock changes as follows: (D represents daytime and N represents night.)\n\n9\n→D 2\n→N 11\n→D 4\n→N 13\n→D 6\n→N 6\n→D x\n\nIn the second query, the number of cans of juice in stock changes as follows:\n\n9\n→D 2\n→N 11\n→D 4\n→N 13\n→D 6\n→N 15\n→D 8\n→N 8\n→D 1\n→N 10\n→D 3\n→N 12\n→D 5\n→N 14\n→D 7\n→N 7\n→D 0\n→N 9\n→D 2\n→N 11\n→D …\n\nand so on, thus Snuke can buy juice indefinitely.\n\nSample Input 2\n\n24\n1 2 3 4\n1 2 4 3\n1 3 2 4\n1 3 4 2\n1 4 2 3\n1 4 3 2\n2 1 3 4\n2 1 4 3\n2 3 1 4\n2 3 4 1\n2 4 1 3\n2 4 3 1\n3 1 2 4\n3 1 4 2\n3 2 1 4\n3 2 4 1\n3 4 1 2\n3 4 2 1\n4 1 2 3\n4 1 3 2\n4 2 1 3\n4 2 3 1\n4 3 1 2\n4 3 2 1\n\nSample Output 2\n\nNo\nNo\nNo\nNo\nNo\nNo\nYes\nYes\nNo\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo", "sample_input": "14\n9 7 5 9\n9 7 6 9\n14 10 7 12\n14 10 8 12\n14 10 9 12\n14 10 7 11\n14 10 8 11\n14 10 9 11\n9 10 5 10\n10 10 5 10\n11 10 5 10\n16 10 5 10\n1000000000000000000 17 14 999999999999999985\n1000000000000000000 17 15 999999999999999985\n"}, "reference_outputs": ["No\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n"], "source_document_id": "p03297", "source_text": "Score : 600 points\n\nProblem Statement\n\nRingo Mart, a convenience store, sells apple juice.\n\nOn the opening day of Ringo Mart, there were A cans of juice in stock in the morning.\nSnuke buys B cans of juice here every day in the daytime.\nThen, the manager checks the number of cans of juice remaining in stock every night.\nIf there are C or less cans, D new cans will be added to the stock by the next morning.\n\nDetermine if Snuke can buy juice indefinitely, that is, there is always B or more cans of juice in stock when he attempts to buy them.\nNobody besides Snuke buy juice at this store.\n\nNote that each test case in this problem consists of T queries.\n\nConstraints\n\n1 \\leq T \\leq 300\n\n1 \\leq A, B, C, D \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\nA_1 B_1 C_1 D_1\nA_2 B_2 C_2 D_2\n:\nA_T B_T C_T D_T\n\nIn the i-th query, A = A_i, B = B_i, C = C_i, D = D_i.\n\nOutput\n\nPrint T lines. The i-th line should contain Yes if Snuke can buy apple juice indefinitely in the i-th query; No otherwise.\n\nSample Input 1\n\n14\n9 7 5 9\n9 7 6 9\n14 10 7 12\n14 10 8 12\n14 10 9 12\n14 10 7 11\n14 10 8 11\n14 10 9 11\n9 10 5 10\n10 10 5 10\n11 10 5 10\n16 10 5 10\n1000000000000000000 17 14 999999999999999985\n1000000000000000000 17 15 999999999999999985\n\nSample Output 1\n\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n\nIn the first query, the number of cans of juice in stock changes as follows: (D represents daytime and N represents night.)\n\n9\n→D 2\n→N 11\n→D 4\n→N 13\n→D 6\n→N 6\n→D x\n\nIn the second query, the number of cans of juice in stock changes as follows:\n\n9\n→D 2\n→N 11\n→D 4\n→N 13\n→D 6\n→N 15\n→D 8\n→N 8\n→D 1\n→N 10\n→D 3\n→N 12\n→D 5\n→N 14\n→D 7\n→N 7\n→D 0\n→N 9\n→D 2\n→N 11\n→D …\n\nand so on, thus Snuke can buy juice indefinitely.\n\nSample Input 2\n\n24\n1 2 3 4\n1 2 4 3\n1 3 2 4\n1 3 4 2\n1 4 2 3\n1 4 3 2\n2 1 3 4\n2 1 4 3\n2 3 1 4\n2 3 4 1\n2 4 1 3\n2 4 3 1\n3 1 2 4\n3 1 4 2\n3 2 1 4\n3 2 4 1\n3 4 1 2\n3 4 2 1\n4 1 2 3\n4 1 3 2\n4 2 1 3\n4 2 3 1\n4 3 1 2\n4 3 2 1\n\nSample Output 2\n\nNo\nNo\nNo\nNo\nNo\nNo\nYes\nYes\nNo\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1493, "cpu_time_ms": 2107, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s472177151", "group_id": "codeNet:p03302", "input_text": "n = gets\nn = n.split(\"\\n\")\na = n[0].split(\" \").map{|b| b.to_i }\nif (a[0] + a[1]) == 15\n p '+'\nelsif (a[0] * a[1]) == 15\n p '*'\nelse\n p 'x'\nend", "language": "Ruby", "metadata": {"date": 1531011957, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03302.html", "problem_id": "p03302", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03302/input.txt", "sample_output_relpath": "derived/input_output/data/p03302/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03302/Ruby/s472177151.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s472177151", "user_id": "u220501704"}, "prompt_components": {"gold_output": "+\n", "input_to_evaluate": "n = gets\nn = n.split(\"\\n\")\na = n[0].split(\" \").map{|b| b.to_i }\nif (a[0] + a[1]) == 15\n p '+'\nelsif (a[0] * a[1]) == 15\n p '*'\nelse\n p 'x'\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers a and b.\nDetermine if a+b=15 or a\\times b=15 or neither holds.\n\nNote that a+b=15 and a\\times b=15 do not hold at the same time.\n\nConstraints\n\n1 \\leq a,b \\leq 15\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\nIf a+b=15, print +;\nif a\\times b=15, print *;\nif neither holds, print x.\n\nSample Input 1\n\n4 11\n\nSample Output 1\n\n+\n\n4+11=15.\n\nSample Input 2\n\n3 5\n\nSample Output 2\n\n*\n\n3\\times 5=15.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\nx\n\n1+1=2 and 1\\times 1=1, neither of which is 15.", "sample_input": "4 11\n"}, "reference_outputs": ["+\n"], "source_document_id": "p03302", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers a and b.\nDetermine if a+b=15 or a\\times b=15 or neither holds.\n\nNote that a+b=15 and a\\times b=15 do not hold at the same time.\n\nConstraints\n\n1 \\leq a,b \\leq 15\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\nIf a+b=15, print +;\nif a\\times b=15, print *;\nif neither holds, print x.\n\nSample Input 1\n\n4 11\n\nSample Output 1\n\n+\n\n4+11=15.\n\nSample Input 2\n\n3 5\n\nSample Output 2\n\n*\n\n3\\times 5=15.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\nx\n\n1+1=2 and 1\\times 1=1, neither of which is 15.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 145, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s380874198", "group_id": "codeNet:p03305", "input_text": "class PriorityQueue\n include Enumerable\n\n MIN = -(2 << 60)\n\n attr_reader :size\n\n def initialize(&block)\n @size = 0\n @heap = Array.new\n @get_key = block || :itself.to_proc\n end\n\n def each\n (1..@size).each do |i|\n yield @heap[i]\n end\n end\n\n def empty?\n size == 0\n end\n\n def pop\n return nil if @size <= 0\n max = @heap[1]\n @heap[1] = @heap[@size]\n @size -= 1\n max_heapify(1)\n max\n end\n\n def push(x)\n @size += 1\n i = @size\n @heap[i] = x\n while i > 1 && @get_key.call(@heap[i / 2]) < @get_key.call(@heap[i])\n t = @heap[i / 2]\n @heap[i / 2] = @heap[i]\n @heap[i] = t\n i = i / 2\n end\n end\n\n def top\n return nil if @size <= 0\n @heap[1]\n end\n\n private\n\n def max_heapify(i)\n l = 2 * i\n r = 2 * i + 1\n largest =\n l <= @size && @get_key.call(@heap[l]) > @get_key.call(@heap[i]) ? l : i\n largest = r \\\n if r <= @size && @get_key.call(@heap[r]) > @get_key.call(@heap[largest])\n unless largest == i\n t = @heap[i]\n @heap[i] = @heap[largest]\n @heap[largest] = t\n max_heapify(largest)\n end\n end\nend\n\n\nN, M, S, T = gets.split.map(&:to_i)\nuvab_list = M.times.map { gets.split.map(&:to_i) }\nMONEY = 10 ** 15\nyen_graph = Array.new(N) { Array.new }\nsnuke_graph = Array.new(N) { Array.new }\nuvab_list.each do |(u, v, a, b)|\n u -= 1\n v -= 1\n yen_graph[u].push([v, a])\n yen_graph[v].push([u, a])\n snuke_graph[u].push([v, b])\n snuke_graph[v].push([u, b])\nend\n\ndef dijkstra(s, graph)\n pq = PriorityQueue.new { |(_, d)| -d }\n d_list = Array.new(graph.size, 1 << 60)\n d_list[s] = 0\n pq.push([s, 0])\n while !pq.empty?\n v, d = pq.pop\n next if d > d_list[v]\n graph[v].each do |(u, c)|\n if d_list[u] > d_list[v] + c\n d_list[u] = d_list[v] + c\n pq.push([u, d_list[u]])\n end\n end\n end\n d_list\nend\n\nyen_d_list = dijkstra(S - 1, yen_graph)\nsnuke_d_list = dijkstra(T - 1, snuke_graph)\ncost_list = yen_d_list.zip(snuke_d_list).map { |(y, s)| y + s }\nans_list = Array.new(N)\nans_list[N - 1] = MONEY - cost_list[N - 1]\n(N - 2).downto(0).each do |i|\n ans_list[i] = [MONEY - cost_list[i], ans_list[i + 1]].max\nend\nans_list.each { |ans| puts ans }\n", "language": "Ruby", "metadata": {"date": 1563430555, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03305.html", "problem_id": "p03305", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03305/input.txt", "sample_output_relpath": "derived/input_output/data/p03305/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03305/Ruby/s380874198.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s380874198", "user_id": "u012133968"}, "prompt_components": {"gold_output": "999999999999998\n999999999999989\n999999999999979\n999999999999897\n", "input_to_evaluate": "class PriorityQueue\n include Enumerable\n\n MIN = -(2 << 60)\n\n attr_reader :size\n\n def initialize(&block)\n @size = 0\n @heap = Array.new\n @get_key = block || :itself.to_proc\n end\n\n def each\n (1..@size).each do |i|\n yield @heap[i]\n end\n end\n\n def empty?\n size == 0\n end\n\n def pop\n return nil if @size <= 0\n max = @heap[1]\n @heap[1] = @heap[@size]\n @size -= 1\n max_heapify(1)\n max\n end\n\n def push(x)\n @size += 1\n i = @size\n @heap[i] = x\n while i > 1 && @get_key.call(@heap[i / 2]) < @get_key.call(@heap[i])\n t = @heap[i / 2]\n @heap[i / 2] = @heap[i]\n @heap[i] = t\n i = i / 2\n end\n end\n\n def top\n return nil if @size <= 0\n @heap[1]\n end\n\n private\n\n def max_heapify(i)\n l = 2 * i\n r = 2 * i + 1\n largest =\n l <= @size && @get_key.call(@heap[l]) > @get_key.call(@heap[i]) ? l : i\n largest = r \\\n if r <= @size && @get_key.call(@heap[r]) > @get_key.call(@heap[largest])\n unless largest == i\n t = @heap[i]\n @heap[i] = @heap[largest]\n @heap[largest] = t\n max_heapify(largest)\n end\n end\nend\n\n\nN, M, S, T = gets.split.map(&:to_i)\nuvab_list = M.times.map { gets.split.map(&:to_i) }\nMONEY = 10 ** 15\nyen_graph = Array.new(N) { Array.new }\nsnuke_graph = Array.new(N) { Array.new }\nuvab_list.each do |(u, v, a, b)|\n u -= 1\n v -= 1\n yen_graph[u].push([v, a])\n yen_graph[v].push([u, a])\n snuke_graph[u].push([v, b])\n snuke_graph[v].push([u, b])\nend\n\ndef dijkstra(s, graph)\n pq = PriorityQueue.new { |(_, d)| -d }\n d_list = Array.new(graph.size, 1 << 60)\n d_list[s] = 0\n pq.push([s, 0])\n while !pq.empty?\n v, d = pq.pop\n next if d > d_list[v]\n graph[v].each do |(u, c)|\n if d_list[u] > d_list[v] + c\n d_list[u] = d_list[v] + c\n pq.push([u, d_list[u]])\n end\n end\n end\n d_list\nend\n\nyen_d_list = dijkstra(S - 1, yen_graph)\nsnuke_d_list = dijkstra(T - 1, snuke_graph)\ncost_list = yen_d_list.zip(snuke_d_list).map { |(y, s)| y + s }\nans_list = Array.new(N)\nans_list[N - 1] = MONEY - cost_list[N - 1]\n(N - 2).downto(0).each do |i|\n ans_list[i] = [MONEY - cost_list[i], ans_list[i + 1]].max\nend\nans_list.each { |ans| puts ans }\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nKenkoooo is planning a trip in Republic of Snuke.\nIn this country, there are n cities and m trains running.\nThe cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally.\nAny city can be reached from any city by changing trains.\n\nTwo currencies are used in the country: yen and snuuk.\nAny train fare can be paid by both yen and snuuk.\nThe fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk.\n\nIn a city with a money exchange office, you can change 1 yen into 1 snuuk.\nHowever, when you do a money exchange, you have to change all your yen into snuuk.\nThat is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk.\nCurrently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year.\n\nKenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling.\nIt is acceptable to do the exchange in City s or City t.\n\nKenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange.\nFor each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years.\nYou can assume that the trip finishes within the year.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\n1 \\leq m \\leq 10^5\n\n1 \\leq s,t \\leq n\n\ns \\neq t\n\n1 \\leq u_i < v_i \\leq n\n\n1 \\leq a_i,b_i \\leq 10^9\n\nIf i\\neq j, then u_i \\neq u_j or v_i \\neq v_j.\n\nAny city can be reached from any city by changing trains.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m s t\nu_1 v_1 a_1 b_1\n:\nu_m v_m a_m b_m\n\nOutput\n\nPrint n lines.\nIn the i-th line, print the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i-1 years.\n\nSample Input 1\n\n4 3 2 3\n1 4 1 100\n1 2 1 10\n1 3 20 1\n\nSample Output 1\n\n999999999999998\n999999999999989\n999999999999979\n999999999999897\n\nAfter 0 years, it is optimal to do the exchange in City 1.\n\nAfter 1 years, it is optimal to do the exchange in City 2.\n\nNote that City 1 can still be visited even after the exchange office is closed.\nAlso note that, if it was allowed to keep 1 yen when do the exchange in City 2 and change the remaining yen into snuuk, we could reach City 3 with 999999999999998 snuuk, but this is NOT allowed.\n\nAfter 2 years, it is optimal to do the exchange in City 3.\n\nAfter 3 years, it is optimal to do the exchange in City 4.\nNote that the same train can be used multiple times.\n\nSample Input 2\n\n8 12 3 8\n2 8 685087149 857180777\n6 7 298270585 209942236\n2 4 346080035 234079976\n2 5 131857300 22507157\n4 8 30723332 173476334\n2 6 480845267 448565596\n1 4 181424400 548830121\n4 5 57429995 195056405\n7 8 160277628 479932440\n1 6 475692952 203530153\n3 5 336869679 160714712\n2 7 389775999 199123879\n\nSample Output 2\n\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994", "sample_input": "4 3 2 3\n1 4 1 100\n1 2 1 10\n1 3 20 1\n"}, "reference_outputs": ["999999999999998\n999999999999989\n999999999999979\n999999999999897\n"], "source_document_id": "p03305", "source_text": "Score : 400 points\n\nProblem Statement\n\nKenkoooo is planning a trip in Republic of Snuke.\nIn this country, there are n cities and m trains running.\nThe cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally.\nAny city can be reached from any city by changing trains.\n\nTwo currencies are used in the country: yen and snuuk.\nAny train fare can be paid by both yen and snuuk.\nThe fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk.\n\nIn a city with a money exchange office, you can change 1 yen into 1 snuuk.\nHowever, when you do a money exchange, you have to change all your yen into snuuk.\nThat is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk.\nCurrently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year.\n\nKenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling.\nIt is acceptable to do the exchange in City s or City t.\n\nKenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange.\nFor each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years.\nYou can assume that the trip finishes within the year.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\n1 \\leq m \\leq 10^5\n\n1 \\leq s,t \\leq n\n\ns \\neq t\n\n1 \\leq u_i < v_i \\leq n\n\n1 \\leq a_i,b_i \\leq 10^9\n\nIf i\\neq j, then u_i \\neq u_j or v_i \\neq v_j.\n\nAny city can be reached from any city by changing trains.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m s t\nu_1 v_1 a_1 b_1\n:\nu_m v_m a_m b_m\n\nOutput\n\nPrint n lines.\nIn the i-th line, print the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i-1 years.\n\nSample Input 1\n\n4 3 2 3\n1 4 1 100\n1 2 1 10\n1 3 20 1\n\nSample Output 1\n\n999999999999998\n999999999999989\n999999999999979\n999999999999897\n\nAfter 0 years, it is optimal to do the exchange in City 1.\n\nAfter 1 years, it is optimal to do the exchange in City 2.\n\nNote that City 1 can still be visited even after the exchange office is closed.\nAlso note that, if it was allowed to keep 1 yen when do the exchange in City 2 and change the remaining yen into snuuk, we could reach City 3 with 999999999999998 snuuk, but this is NOT allowed.\n\nAfter 2 years, it is optimal to do the exchange in City 3.\n\nAfter 3 years, it is optimal to do the exchange in City 4.\nNote that the same train can be used multiple times.\n\nSample Input 2\n\n8 12 3 8\n2 8 685087149 857180777\n6 7 298270585 209942236\n2 4 346080035 234079976\n2 5 131857300 22507157\n4 8 30723332 173476334\n2 6 480845267 448565596\n1 4 181424400 548830121\n4 5 57429995 195056405\n7 8 160277628 479932440\n1 6 475692952 203530153\n3 5 336869679 160714712\n2 7 389775999 199123879\n\nSample Output 2\n\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2199, "cpu_time_ms": 2111, "memory_kb": 62332}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s312405790", "group_id": "codeNet:p03307", "input_text": "p gets.to_i.lcm(2)", "language": "Ruby", "metadata": {"date": 1561138095, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03307.html", "problem_id": "p03307", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03307/input.txt", "sample_output_relpath": "derived/input_output/data/p03307/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03307/Ruby/s312405790.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s312405790", "user_id": "u091810847"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "p gets.to_i.lcm(2)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a positive integer N.\nFind the minimum positive integer divisible by both 2 and N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum positive integer divisible by both 2 and N.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\n6 is divisible by both 2 and 3.\nAlso, there is no positive integer less than 6 that is divisible by both 2 and 3.\nThus, the answer is 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n1999999998", "sample_input": "3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03307", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a positive integer N.\nFind the minimum positive integer divisible by both 2 and N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum positive integer divisible by both 2 and N.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\n6 is divisible by both 2 and 3.\nAlso, there is no positive integer less than 6 that is divisible by both 2 and 3.\nThus, the answer is 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n1999999998", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 18, "cpu_time_ms": 9, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s490891591", "group_id": "codeNet:p03307", "input_text": "puts (n=gets.to_i).even? ? n:n*2", "language": "Ruby", "metadata": {"date": 1549862224, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03307.html", "problem_id": "p03307", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03307/input.txt", "sample_output_relpath": "derived/input_output/data/p03307/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03307/Ruby/s490891591.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s490891591", "user_id": "u602591412"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "puts (n=gets.to_i).even? ? n:n*2", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a positive integer N.\nFind the minimum positive integer divisible by both 2 and N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum positive integer divisible by both 2 and N.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\n6 is divisible by both 2 and 3.\nAlso, there is no positive integer less than 6 that is divisible by both 2 and 3.\nThus, the answer is 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n1999999998", "sample_input": "3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03307", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a positive integer N.\nFind the minimum positive integer divisible by both 2 and N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum positive integer divisible by both 2 and N.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\n6 is divisible by both 2 and 3.\nAlso, there is no positive integer less than 6 that is divisible by both 2 and 3.\nThus, the answer is 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n1999999998", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 32, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s182465179", "group_id": "codeNet:p03307", "input_text": "n = gets.to_i\nputs n.odd? ? n * 2 : n", "language": "Ruby", "metadata": {"date": 1530491670, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03307.html", "problem_id": "p03307", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03307/input.txt", "sample_output_relpath": "derived/input_output/data/p03307/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03307/Ruby/s182465179.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s182465179", "user_id": "u304013285"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "n = gets.to_i\nputs n.odd? ? n * 2 : n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a positive integer N.\nFind the minimum positive integer divisible by both 2 and N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum positive integer divisible by both 2 and N.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\n6 is divisible by both 2 and 3.\nAlso, there is no positive integer less than 6 that is divisible by both 2 and 3.\nThus, the answer is 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n1999999998", "sample_input": "3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03307", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a positive integer N.\nFind the minimum positive integer divisible by both 2 and N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum positive integer divisible by both 2 and N.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\n6 is divisible by both 2 and 3.\nAlso, there is no positive integer less than 6 that is divisible by both 2 and 3.\nThus, the answer is 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n1999999998", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 37, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s902405818", "group_id": "codeNet:p03307", "input_text": "n=gets.to_i\nputs n%2==0 ? n : n*2", "language": "Ruby", "metadata": {"date": 1530491596, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03307.html", "problem_id": "p03307", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03307/input.txt", "sample_output_relpath": "derived/input_output/data/p03307/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03307/Ruby/s902405818.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s902405818", "user_id": "u785521224"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "n=gets.to_i\nputs n%2==0 ? n : n*2", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a positive integer N.\nFind the minimum positive integer divisible by both 2 and N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum positive integer divisible by both 2 and N.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\n6 is divisible by both 2 and 3.\nAlso, there is no positive integer less than 6 that is divisible by both 2 and 3.\nThus, the answer is 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n1999999998", "sample_input": "3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03307", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a positive integer N.\nFind the minimum positive integer divisible by both 2 and N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum positive integer divisible by both 2 and N.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\n6 is divisible by both 2 and 3.\nAlso, there is no positive integer less than 6 that is divisible by both 2 and 3.\nThus, the answer is 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n1999999998", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 33, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s299278930", "group_id": "codeNet:p03307", "input_text": "n = gets.to_i\n\nif n.even?\n puts n\nelse\n puts n*2\nend\n", "language": "Ruby", "metadata": {"date": 1530491593, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03307.html", "problem_id": "p03307", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03307/input.txt", "sample_output_relpath": "derived/input_output/data/p03307/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03307/Ruby/s299278930.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s299278930", "user_id": "u546441021"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "n = gets.to_i\n\nif n.even?\n puts n\nelse\n puts n*2\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a positive integer N.\nFind the minimum positive integer divisible by both 2 and N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum positive integer divisible by both 2 and N.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\n6 is divisible by both 2 and 3.\nAlso, there is no positive integer less than 6 that is divisible by both 2 and 3.\nThus, the answer is 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n1999999998", "sample_input": "3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03307", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a positive integer N.\nFind the minimum positive integer divisible by both 2 and N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum positive integer divisible by both 2 and N.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\n6 is divisible by both 2 and 3.\nAlso, there is no positive integer less than 6 that is divisible by both 2 and 3.\nThus, the answer is 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n1999999998", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 55, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s838056819", "group_id": "codeNet:p03308", "input_text": "n = gets.to_i\na = gets.split.map(&:to_i)\nputs a.max - a.min", "language": "Ruby", "metadata": {"date": 1536569683, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03308.html", "problem_id": "p03308", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03308/input.txt", "sample_output_relpath": "derived/input_output/data/p03308/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03308/Ruby/s838056819.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s838056819", "user_id": "u330533916"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "n = gets.to_i\na = gets.split.map(&:to_i)\nputs a.max - a.min", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N.\nFind the maximum absolute difference of two elements (with different indices) in A.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum absolute difference of two elements (with different indices) in A.\n\nSample Input 1\n\n4\n1 4 6 3\n\nSample Output 1\n\n5\n\nThe maximum absolute difference of two elements is A_3-A_1=6-1=5.\n\nSample Input 2\n\n2\n1000000000 1\n\nSample Output 2\n\n999999999\n\nSample Input 3\n\n5\n1 1 1 1 1\n\nSample Output 3\n\n0", "sample_input": "4\n1 4 6 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03308", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N.\nFind the maximum absolute difference of two elements (with different indices) in A.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum absolute difference of two elements (with different indices) in A.\n\nSample Input 1\n\n4\n1 4 6 3\n\nSample Output 1\n\n5\n\nThe maximum absolute difference of two elements is A_3-A_1=6-1=5.\n\nSample Input 2\n\n2\n1000000000 1\n\nSample Output 2\n\n999999999\n\nSample Input 3\n\n5\n1 1 1 1 1\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 59, "cpu_time_ms": 7, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s450469650", "group_id": "codeNet:p03308", "input_text": "gets\na=gets.chomp.split.map(&:to_i)\nputs a.max - a.min\n", "language": "Ruby", "metadata": {"date": 1530491763, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03308.html", "problem_id": "p03308", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03308/input.txt", "sample_output_relpath": "derived/input_output/data/p03308/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03308/Ruby/s450469650.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s450469650", "user_id": "u503270460"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "gets\na=gets.chomp.split.map(&:to_i)\nputs a.max - a.min\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N.\nFind the maximum absolute difference of two elements (with different indices) in A.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum absolute difference of two elements (with different indices) in A.\n\nSample Input 1\n\n4\n1 4 6 3\n\nSample Output 1\n\n5\n\nThe maximum absolute difference of two elements is A_3-A_1=6-1=5.\n\nSample Input 2\n\n2\n1000000000 1\n\nSample Output 2\n\n999999999\n\nSample Input 3\n\n5\n1 1 1 1 1\n\nSample Output 3\n\n0", "sample_input": "4\n1 4 6 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03308", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N.\nFind the maximum absolute difference of two elements (with different indices) in A.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum absolute difference of two elements (with different indices) in A.\n\nSample Input 1\n\n4\n1 4 6 3\n\nSample Output 1\n\n5\n\nThe maximum absolute difference of two elements is A_3-A_1=6-1=5.\n\nSample Input 2\n\n2\n1000000000 1\n\nSample Output 2\n\n999999999\n\nSample Input 3\n\n5\n1 1 1 1 1\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 55, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s766532346", "group_id": "codeNet:p03308", "input_text": "N = gets.to_i\nA = gets.split.map &:to_i\nm = 0\nfor i in 0...N\n for j in (i+1)...N\n m = [m, (A[i]-A[j]).abs].max\n end\nend\nputs m\n\n", "language": "Ruby", "metadata": {"date": 1530491698, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03308.html", "problem_id": "p03308", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03308/input.txt", "sample_output_relpath": "derived/input_output/data/p03308/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03308/Ruby/s766532346.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s766532346", "user_id": "u967136506"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "N = gets.to_i\nA = gets.split.map &:to_i\nm = 0\nfor i in 0...N\n for j in (i+1)...N\n m = [m, (A[i]-A[j]).abs].max\n end\nend\nputs m\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N.\nFind the maximum absolute difference of two elements (with different indices) in A.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum absolute difference of two elements (with different indices) in A.\n\nSample Input 1\n\n4\n1 4 6 3\n\nSample Output 1\n\n5\n\nThe maximum absolute difference of two elements is A_3-A_1=6-1=5.\n\nSample Input 2\n\n2\n1000000000 1\n\nSample Output 2\n\n999999999\n\nSample Input 3\n\n5\n1 1 1 1 1\n\nSample Output 3\n\n0", "sample_input": "4\n1 4 6 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03308", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N.\nFind the maximum absolute difference of two elements (with different indices) in A.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum absolute difference of two elements (with different indices) in A.\n\nSample Input 1\n\n4\n1 4 6 3\n\nSample Output 1\n\n5\n\nThe maximum absolute difference of two elements is A_3-A_1=6-1=5.\n\nSample Input 2\n\n2\n1000000000 1\n\nSample Output 2\n\n999999999\n\nSample Input 3\n\n5\n1 1 1 1 1\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 133, "cpu_time_ms": 10, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s960372933", "group_id": "codeNet:p03309", "input_text": "N = gets.to_i\na_list = gets.split.map(&:to_i)\ndiff_list = a_list.map.with_index do |a, i|\n a - i - 1\nend.sort\n\ndef calc(diff_list, b)\n diff_list.map do |d|\n (d - b).abs\n end.reduce(&:+)\nend\n\nans = calc(diff_list, diff_list[N / 2])\nputs ans\n", "language": "Ruby", "metadata": {"date": 1555225462, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s960372933.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s960372933", "user_id": "u012133968"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "N = gets.to_i\na_list = gets.split.map(&:to_i)\ndiff_list = a_list.map.with_index do |a, i|\n a - i - 1\nend.sort\n\ndef calc(diff_list, b)\n diff_list.map do |d|\n (d - b).abs\n end.reduce(&:+)\nend\n\nans = calc(diff_list, diff_list[N / 2])\nputs ans\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will freely choose an integer b.\nHere, he will get sad if A_i and b+i are far from each other.\nMore specifically, the sadness of Snuke is calculated as follows:\n\nabs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))\n\nHere, abs(x) is a function that returns the absolute value of x.\n\nFind the minimum possible sadness of Snuke.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible sadness of Snuke.\n\nSample Input 1\n\n5\n2 2 3 5 5\n\nSample Output 1\n\n2\n\nIf we choose b=0, the sadness of Snuke would be abs(2-(0+1))+abs(2-(0+2))+abs(3-(0+3))+abs(5-(0+4))+abs(5-(0+5))=2.\nAny choice of b does not make the sadness of Snuke less than 2, so the answer is 2.\n\nSample Input 2\n\n9\n1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n6\n6 5 4 3 2 1\n\nSample Output 3\n\n18\n\nSample Input 4\n\n7\n1 1 1 1 2 3 4\n\nSample Output 4\n\n6", "sample_input": "5\n2 2 3 5 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03309", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will freely choose an integer b.\nHere, he will get sad if A_i and b+i are far from each other.\nMore specifically, the sadness of Snuke is calculated as follows:\n\nabs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))\n\nHere, abs(x) is a function that returns the absolute value of x.\n\nFind the minimum possible sadness of Snuke.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible sadness of Snuke.\n\nSample Input 1\n\n5\n2 2 3 5 5\n\nSample Output 1\n\n2\n\nIf we choose b=0, the sadness of Snuke would be abs(2-(0+1))+abs(2-(0+2))+abs(3-(0+3))+abs(5-(0+4))+abs(5-(0+5))=2.\nAny choice of b does not make the sadness of Snuke less than 2, so the answer is 2.\n\nSample Input 2\n\n9\n1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n6\n6 5 4 3 2 1\n\nSample Output 3\n\n18\n\nSample Input 4\n\n7\n1 1 1 1 2 3 4\n\nSample Output 4\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 246, "cpu_time_ms": 179, "memory_kb": 20708}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s148573287", "group_id": "codeNet:p03309", "input_text": "n = gets.to_i\nas = gets.split.map(&:to_i).map.with_index { |x, i| x - i - 1 }\nif n.odd?\n med = as[n/2]\n p as.map { |a| (a-med).abs }.inject(:+)\nelse\n med = as[n/2-1] + as[n/2]\n med_f = med.fdiv(2).floor\n med_c = med.fdiv(2).ceil\n ans_f = 0\n ans_c = 0\n as.each do |a|\n ans_f += (a-med_f).abs\n ans_c += (a-med_c).abs\n end\n p [ans_f, ans_c].min\nend", "language": "Ruby", "metadata": {"date": 1530573040, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s148573287.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s148573287", "user_id": "u300096598"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n = gets.to_i\nas = gets.split.map(&:to_i).map.with_index { |x, i| x - i - 1 }\nif n.odd?\n med = as[n/2]\n p as.map { |a| (a-med).abs }.inject(:+)\nelse\n med = as[n/2-1] + as[n/2]\n med_f = med.fdiv(2).floor\n med_c = med.fdiv(2).ceil\n ans_f = 0\n ans_c = 0\n as.each do |a|\n ans_f += (a-med_f).abs\n ans_c += (a-med_c).abs\n end\n p [ans_f, ans_c].min\nend", "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": 361, "cpu_time_ms": 135, "memory_kb": 17548}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s515925129", "group_id": "codeNet:p03315", "input_text": "array = gets.chomp.split(\"\")\nsum = 0\n\narray.each do |mark|\n if mark == \"+\"\n sum += 1\n else\n sum -= 1\n end\nend\n\nputs sum", "language": "Ruby", "metadata": {"date": 1576901658, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03315.html", "problem_id": "p03315", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03315/input.txt", "sample_output_relpath": "derived/input_output/data/p03315/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03315/Ruby/s515925129.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s515925129", "user_id": "u333374716"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "array = gets.chomp.split(\"\")\nsum = 0\n\narray.each do |mark|\n if mark == \"+\"\n sum += 1\n else\n sum -= 1\n end\nend\n\nputs sum", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is always an integer in Takahashi's mind.\n\nInitially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is + or -. When he eats +, the integer in his mind increases by 1; when he eats -, the integer in his mind decreases by 1.\n\nThe symbols Takahashi is going to eat are given to you as a string S. The i-th character in S is the i-th symbol for him to eat.\n\nFind the integer in Takahashi's mind after he eats all the symbols.\n\nConstraints\n\nThe length of S is 4.\n\nEach character in S is + or -.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the integer in Takahashi's mind after he eats all the symbols.\n\nSample Input 1\n\n+-++\n\nSample Output 1\n\n2\n\nInitially, the integer in Takahashi's mind is 0.\n\nThe first integer for him to eat is +. After eating it, the integer in his mind becomes 1.\n\nThe second integer to eat is -. After eating it, the integer in his mind becomes 0.\n\nThe third integer to eat is +. After eating it, the integer in his mind becomes 1.\n\nThe fourth integer to eat is +. After eating it, the integer in his mind becomes 2.\n\nThus, the integer in Takahashi's mind after he eats all the symbols is 2.\n\nSample Input 2\n\n-+--\n\nSample Output 2\n\n-2\n\nSample Input 3\n\n----\n\nSample Output 3\n\n-4", "sample_input": "+-++\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03315", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is always an integer in Takahashi's mind.\n\nInitially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is + or -. When he eats +, the integer in his mind increases by 1; when he eats -, the integer in his mind decreases by 1.\n\nThe symbols Takahashi is going to eat are given to you as a string S. The i-th character in S is the i-th symbol for him to eat.\n\nFind the integer in Takahashi's mind after he eats all the symbols.\n\nConstraints\n\nThe length of S is 4.\n\nEach character in S is + or -.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the integer in Takahashi's mind after he eats all the symbols.\n\nSample Input 1\n\n+-++\n\nSample Output 1\n\n2\n\nInitially, the integer in Takahashi's mind is 0.\n\nThe first integer for him to eat is +. After eating it, the integer in his mind becomes 1.\n\nThe second integer to eat is -. After eating it, the integer in his mind becomes 0.\n\nThe third integer to eat is +. After eating it, the integer in his mind becomes 1.\n\nThe fourth integer to eat is +. After eating it, the integer in his mind becomes 2.\n\nThus, the integer in Takahashi's mind after he eats all the symbols is 2.\n\nSample Input 2\n\n-+--\n\nSample Output 2\n\n-2\n\nSample Input 3\n\n----\n\nSample Output 3\n\n-4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 128, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s079589055", "group_id": "codeNet:p03315", "input_text": "s = gets\nans = 0\ns.chars.each do |op|\n ans += 1 if op == '+'\n ans -= 1 if op == '-'\nend\n\nputs ans\n~", "language": "Ruby", "metadata": {"date": 1529807606, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03315.html", "problem_id": "p03315", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03315/input.txt", "sample_output_relpath": "derived/input_output/data/p03315/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03315/Ruby/s079589055.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s079589055", "user_id": "u320576758"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "s = gets\nans = 0\ns.chars.each do |op|\n ans += 1 if op == '+'\n ans -= 1 if op == '-'\nend\n\nputs ans\n~", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is always an integer in Takahashi's mind.\n\nInitially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is + or -. When he eats +, the integer in his mind increases by 1; when he eats -, the integer in his mind decreases by 1.\n\nThe symbols Takahashi is going to eat are given to you as a string S. The i-th character in S is the i-th symbol for him to eat.\n\nFind the integer in Takahashi's mind after he eats all the symbols.\n\nConstraints\n\nThe length of S is 4.\n\nEach character in S is + or -.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the integer in Takahashi's mind after he eats all the symbols.\n\nSample Input 1\n\n+-++\n\nSample Output 1\n\n2\n\nInitially, the integer in Takahashi's mind is 0.\n\nThe first integer for him to eat is +. After eating it, the integer in his mind becomes 1.\n\nThe second integer to eat is -. After eating it, the integer in his mind becomes 0.\n\nThe third integer to eat is +. After eating it, the integer in his mind becomes 1.\n\nThe fourth integer to eat is +. After eating it, the integer in his mind becomes 2.\n\nThus, the integer in Takahashi's mind after he eats all the symbols is 2.\n\nSample Input 2\n\n-+--\n\nSample Output 2\n\n-2\n\nSample Input 3\n\n----\n\nSample Output 3\n\n-4", "sample_input": "+-++\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03315", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is always an integer in Takahashi's mind.\n\nInitially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is + or -. When he eats +, the integer in his mind increases by 1; when he eats -, the integer in his mind decreases by 1.\n\nThe symbols Takahashi is going to eat are given to you as a string S. The i-th character in S is the i-th symbol for him to eat.\n\nFind the integer in Takahashi's mind after he eats all the symbols.\n\nConstraints\n\nThe length of S is 4.\n\nEach character in S is + or -.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the integer in Takahashi's mind after he eats all the symbols.\n\nSample Input 1\n\n+-++\n\nSample Output 1\n\n2\n\nInitially, the integer in Takahashi's mind is 0.\n\nThe first integer for him to eat is +. After eating it, the integer in his mind becomes 1.\n\nThe second integer to eat is -. After eating it, the integer in his mind becomes 0.\n\nThe third integer to eat is +. After eating it, the integer in his mind becomes 1.\n\nThe fourth integer to eat is +. After eating it, the integer in his mind becomes 2.\n\nThus, the integer in Takahashi's mind after he eats all the symbols is 2.\n\nSample Input 2\n\n-+--\n\nSample Output 2\n\n-2\n\nSample Input 3\n\n----\n\nSample Output 3\n\n-4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 101, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s606663919", "group_id": "codeNet:p03316", "input_text": "n = gets.strip\nsum = 0\nn.split('').map(&:to_i).each do |n|\n sum+=n\nend\nif (n.to_i % sum).zero?\n p 'Yes'\nelse\n p 'No'\nend", "language": "Ruby", "metadata": {"date": 1529808638, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03316.html", "problem_id": "p03316", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03316/input.txt", "sample_output_relpath": "derived/input_output/data/p03316/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03316/Ruby/s606663919.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s606663919", "user_id": "u220501704"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "n = gets.strip\nsum = 0\nn.split('').map(&:to_i).each do |n|\n sum+=n\nend\nif (n.to_i % sum).zero?\n p 'Yes'\nelse\n p 'No'\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(101) = 1 + 0 + 1 = 2.\n\nGiven an integer N, determine if S(N) divides N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf S(N) divides N, print Yes; if it does not, print No.\n\nSample Input 1\n\n12\n\nSample Output 1\n\nYes\n\nIn this input, N=12.\nAs S(12) = 1 + 2 = 3, S(N) divides N.\n\nSample Input 2\n\n101\n\nSample Output 2\n\nNo\n\nAs S(101) = 1 + 0 + 1 = 2, S(N) does not divide N.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\nYes", "sample_input": "12\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03316", "source_text": "Score : 200 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(101) = 1 + 0 + 1 = 2.\n\nGiven an integer N, determine if S(N) divides N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf S(N) divides N, print Yes; if it does not, print No.\n\nSample Input 1\n\n12\n\nSample Output 1\n\nYes\n\nIn this input, N=12.\nAs S(12) = 1 + 2 = 3, S(N) divides N.\n\nSample Input 2\n\n101\n\nSample Output 2\n\nNo\n\nAs S(101) = 1 + 0 + 1 = 2, S(N) does not divide N.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 123, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s883335862", "group_id": "codeNet:p03317", "input_text": "n,k=gets.chomp.split(\" \").map(&:to_i)\na=gets.chomp.split(\" \").map(&:to_i);\none = a.index(1)\nif k < one then\n l = one\n r = n - one + 1\n ans = 0\n ans += l / k\n if l % k != 0 then\n ans += 1\n end\n ans += r / k\n if r % k != 0 then\n ans += 1\n end\nelse\n ans = n/k\n if n % k != 0\n ans += 1\n end\nend\nputs ans\n", "language": "Ruby", "metadata": {"date": 1529807692, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03317.html", "problem_id": "p03317", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03317/input.txt", "sample_output_relpath": "derived/input_output/data/p03317/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03317/Ruby/s883335862.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s883335862", "user_id": "u501660472"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n,k=gets.chomp.split(\" \").map(&:to_i)\na=gets.chomp.split(\" \").map(&:to_i);\none = a.index(1)\nif k < one then\n l = one\n r = n - one + 1\n ans = 0\n ans += l / k\n if l % k != 0 then\n ans += 1\n end\n ans += r / k\n if r % k != 0 then\n ans += 1\n end\nelse\n ans = n/k\n if n % k != 0\n ans += 1\n end\nend\nputs ans\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "sample_input": "4 3\n2 3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03317", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 321, "cpu_time_ms": 44, "memory_kb": 8708}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s155465701", "group_id": "codeNet:p03317", "input_text": "n, k = gets.chomp.split(\" \").map(&:to_i)\na = gets.chomp.split(\"\")\n\nif n == k then\n puts \"1\"\n exit\nend\n\nt = k - 1\n\nputs 1 + ((n - k).to_f / t).ceil", "language": "Ruby", "metadata": {"date": 1529806009, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03317.html", "problem_id": "p03317", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03317/input.txt", "sample_output_relpath": "derived/input_output/data/p03317/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03317/Ruby/s155465701.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s155465701", "user_id": "u778692431"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n, k = gets.chomp.split(\" \").map(&:to_i)\na = gets.chomp.split(\"\")\n\nif n == k then\n puts \"1\"\n exit\nend\n\nt = k - 1\n\nputs 1 + ((n - k).to_f / t).ceil", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "sample_input": "4 3\n2 3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03317", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 148, "cpu_time_ms": 340, "memory_kb": 35204}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s491756333", "group_id": "codeNet:p03317", "input_text": "n, k = gets.split(\" \").map{|d| d.to_i }\na = gets.split(\" \").map{|m| m.to_i }\nputs (a.size + k - 3) / (k - 1)", "language": "Ruby", "metadata": {"date": 1529805643, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03317.html", "problem_id": "p03317", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03317/input.txt", "sample_output_relpath": "derived/input_output/data/p03317/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03317/Ruby/s491756333.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s491756333", "user_id": "u838194315"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n, k = gets.split(\" \").map{|d| d.to_i }\na = gets.split(\" \").map{|m| m.to_i }\nputs (a.size + k - 3) / (k - 1)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "sample_input": "4 3\n2 3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03317", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 109, "cpu_time_ms": 44, "memory_kb": 8068}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s499241371", "group_id": "codeNet:p03318", "input_text": "k = gets.chomp.to_i\n\ndef s(n)\n nn = n\n ret = 0\n while(nn>0) do\n ret += nn % 10\n nn /= 10\n end\n return ret\nend\n\ndef f(n)\n nn = n\n i = 0\n ret = 0\n val = 10 ** 16\n while(nn>0) do\n nn /= 10\n i += 1\n m = (nn+1) * 10 ** i - 1\n if val > m.to_f / s(m)\n val = m.to_f / s(m)\n ret = m\n end\n end\n return ret\nend\n\n(1..9).each do |i|\n puts i\n k -= 1\n exit if k == 0\nend\n\nn = 10\nwhile(k>0)\n n = f(n+1)\n puts n\n k -= 1\nend", "language": "Ruby", "metadata": {"date": 1529965793, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s499241371.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s499241371", "user_id": "u868089307"}, "prompt_components": {"gold_output": "1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n", "input_to_evaluate": "k = gets.chomp.to_i\n\ndef s(n)\n nn = n\n ret = 0\n while(nn>0) do\n ret += nn % 10\n nn /= 10\n end\n return ret\nend\n\ndef f(n)\n nn = n\n i = 0\n ret = 0\n val = 10 ** 16\n while(nn>0) do\n nn /= 10\n i += 1\n m = (nn+1) * 10 ** i - 1\n if val > m.to_f / s(m)\n val = m.to_f / s(m)\n ret = m\n end\n end\n return ret\nend\n\n(1..9).each do |i|\n puts i\n k -= 1\n exit if k == 0\nend\n\nn = 10\nwhile(k>0)\n n = f(n+1)\n puts n\n k -= 1\nend", "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": 531, "cpu_time_ms": 23, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s514968884", "group_id": "codeNet:p03323", "input_text": "arr = $stdin.gets.chomp.split\" \"\narr.map! do |a_j|\n a_j.to_i\nend\n\nif arr[0] <= 8 and arr[1] <= 8\n puts \"Yay!\"\nelse\n puts \":(\"\nend\n", "language": "Ruby", "metadata": {"date": 1574390969, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03323.html", "problem_id": "p03323", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03323/input.txt", "sample_output_relpath": "derived/input_output/data/p03323/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03323/Ruby/s514968884.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s514968884", "user_id": "u294388467"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "arr = $stdin.gets.chomp.split\" \"\narr.map! do |a_j|\n a_j.to_i\nend\n\nif arr[0] <= 8 and arr[1] <= 8\n puts \"Yay!\"\nelse\n puts \":(\"\nend\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nE869120's and square1001's 16-th birthday is coming soon.\n\nTakahashi from AtCoder Kingdom gave them a round cake cut into 16 equal fan-shaped pieces.\n\nE869120 and square1001 were just about to eat A and B of those pieces, respectively,\n\nwhen they found a note attached to the cake saying that \"the same person should not take two adjacent pieces of cake\".\n\nCan both of them obey the instruction in the note and take desired numbers of pieces of cake?\n\nConstraints\n\nA and B are integers between 1 and 16 (inclusive).\n\nA+B is at most 16.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf both E869120 and square1001 can obey the instruction in the note and take desired numbers of pieces of cake, print Yay!; otherwise, print :(.\n\nSample Input 1\n\n5 4\n\nSample Output 1\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 2\n\n8 8\n\nSample Output 2\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 3\n\n11 4\n\nSample Output 3\n\n:(\n\nIn this case, there is no way for them to take desired number of pieces, unfortunately.", "sample_input": "5 4\n"}, "reference_outputs": ["Yay!\n"], "source_document_id": "p03323", "source_text": "Score: 100 points\n\nProblem Statement\n\nE869120's and square1001's 16-th birthday is coming soon.\n\nTakahashi from AtCoder Kingdom gave them a round cake cut into 16 equal fan-shaped pieces.\n\nE869120 and square1001 were just about to eat A and B of those pieces, respectively,\n\nwhen they found a note attached to the cake saying that \"the same person should not take two adjacent pieces of cake\".\n\nCan both of them obey the instruction in the note and take desired numbers of pieces of cake?\n\nConstraints\n\nA and B are integers between 1 and 16 (inclusive).\n\nA+B is at most 16.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf both E869120 and square1001 can obey the instruction in the note and take desired numbers of pieces of cake, print Yay!; otherwise, print :(.\n\nSample Input 1\n\n5 4\n\nSample Output 1\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 2\n\n8 8\n\nSample Output 2\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 3\n\n11 4\n\nSample Output 3\n\n:(\n\nIn this case, there is no way for them to take desired number of pieces, unfortunately.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 132, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s955435469", "group_id": "codeNet:p03323", "input_text": "a, b = gets.chomp.split(\" \").map(&:to_i)\n\nv = 16 - [a, b].min * 2\n\nif v == 0 || v / 2 >= ([a, b].max - [a, b].min) then\n puts \"Yay!\"\nelse\n puts \":(\"\nend", "language": "Ruby", "metadata": {"date": 1529200811, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03323.html", "problem_id": "p03323", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03323/input.txt", "sample_output_relpath": "derived/input_output/data/p03323/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03323/Ruby/s955435469.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s955435469", "user_id": "u778692431"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "a, b = gets.chomp.split(\" \").map(&:to_i)\n\nv = 16 - [a, b].min * 2\n\nif v == 0 || v / 2 >= ([a, b].max - [a, b].min) then\n puts \"Yay!\"\nelse\n puts \":(\"\nend", "problem_context": "Score: 100 points\n\nProblem Statement\n\nE869120's and square1001's 16-th birthday is coming soon.\n\nTakahashi from AtCoder Kingdom gave them a round cake cut into 16 equal fan-shaped pieces.\n\nE869120 and square1001 were just about to eat A and B of those pieces, respectively,\n\nwhen they found a note attached to the cake saying that \"the same person should not take two adjacent pieces of cake\".\n\nCan both of them obey the instruction in the note and take desired numbers of pieces of cake?\n\nConstraints\n\nA and B are integers between 1 and 16 (inclusive).\n\nA+B is at most 16.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf both E869120 and square1001 can obey the instruction in the note and take desired numbers of pieces of cake, print Yay!; otherwise, print :(.\n\nSample Input 1\n\n5 4\n\nSample Output 1\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 2\n\n8 8\n\nSample Output 2\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 3\n\n11 4\n\nSample Output 3\n\n:(\n\nIn this case, there is no way for them to take desired number of pieces, unfortunately.", "sample_input": "5 4\n"}, "reference_outputs": ["Yay!\n"], "source_document_id": "p03323", "source_text": "Score: 100 points\n\nProblem Statement\n\nE869120's and square1001's 16-th birthday is coming soon.\n\nTakahashi from AtCoder Kingdom gave them a round cake cut into 16 equal fan-shaped pieces.\n\nE869120 and square1001 were just about to eat A and B of those pieces, respectively,\n\nwhen they found a note attached to the cake saying that \"the same person should not take two adjacent pieces of cake\".\n\nCan both of them obey the instruction in the note and take desired numbers of pieces of cake?\n\nConstraints\n\nA and B are integers between 1 and 16 (inclusive).\n\nA+B is at most 16.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf both E869120 and square1001 can obey the instruction in the note and take desired numbers of pieces of cake, print Yay!; otherwise, print :(.\n\nSample Input 1\n\n5 4\n\nSample Output 1\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 2\n\n8 8\n\nSample Output 2\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 3\n\n11 4\n\nSample Output 3\n\n:(\n\nIn this case, there is no way for them to take desired number of pieces, unfortunately.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 154, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s971199381", "group_id": "codeNet:p03325", "input_text": "def cnt(n)\n\ti = 0\n\twhile n%2 < 1\n\t\tn = n / 2\n\t\ti += 1\n\tend\n\treturn i\nend\nn = gets\nnums = gets.chomp.split(\" \").map(&:to_i)\nsum = 0\nnums.each do |num|\n\tsum+=cnt(num)\nend\nputs sum", "language": "Ruby", "metadata": {"date": 1529201802, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03325.html", "problem_id": "p03325", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03325/input.txt", "sample_output_relpath": "derived/input_output/data/p03325/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03325/Ruby/s971199381.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s971199381", "user_id": "u576176110"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "def cnt(n)\n\ti = 0\n\twhile n%2 < 1\n\t\tn = n / 2\n\t\ti += 1\n\tend\n\treturn i\nend\nn = gets\nnums = gets.chomp.split(\" \").map(&:to_i)\nsum = 0\nnums.each do |num|\n\tsum+=cnt(num)\nend\nputs sum", "problem_context": "Score: 300 points\n\nProblem Statement\n\nAs AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}.\n\nSnuke, an employee, would like to play with this sequence.\n\nSpecifically, he would like to repeat the following operation as many times as possible:\n\nFor every i satisfying 1 \\leq i \\leq N, perform one of the following: \"divide a_i by 2\" and \"multiply a_i by 3\".\nHere, choosing \"multiply a_i by 3\" for every i is not allowed, and the value of a_i after the operation must be an integer.\n\nAt most how many operations can be performed?\n\nConstraints\n\nN is an integer between 1 and 10 \\ 000 (inclusive).\n\na_i is an integer between 1 and 1 \\ 000 \\ 000 \\ 000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 a_3 ... a_N\n\nOutput\n\nPrint the maximum number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n5 2 4\n\nSample Output 1\n\n3\n\nThe sequence is initially {5, 2, 4}. Three operations can be performed as follows:\n\nFirst, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {15, 6, 2}.\n\nNext, multiply a_1 by 3, divide a_2 by 2 and multiply a_3 by 3. The sequence is now {45, 3, 6}.\n\nFinally, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {135, 9, 3}.\n\nSample Input 2\n\n4\n631 577 243 199\n\nSample Output 2\n\n0\n\nNo operation can be performed since all the elements are odd. Thus, the answer is 0.\n\nSample Input 3\n\n10\n2184 2126 1721 1800 1024 2528 3360 1945 1280 1776\n\nSample Output 3\n\n39", "sample_input": "3\n5 2 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03325", "source_text": "Score: 300 points\n\nProblem Statement\n\nAs AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}.\n\nSnuke, an employee, would like to play with this sequence.\n\nSpecifically, he would like to repeat the following operation as many times as possible:\n\nFor every i satisfying 1 \\leq i \\leq N, perform one of the following: \"divide a_i by 2\" and \"multiply a_i by 3\".\nHere, choosing \"multiply a_i by 3\" for every i is not allowed, and the value of a_i after the operation must be an integer.\n\nAt most how many operations can be performed?\n\nConstraints\n\nN is an integer between 1 and 10 \\ 000 (inclusive).\n\na_i is an integer between 1 and 1 \\ 000 \\ 000 \\ 000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 a_3 ... a_N\n\nOutput\n\nPrint the maximum number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n5 2 4\n\nSample Output 1\n\n3\n\nThe sequence is initially {5, 2, 4}. Three operations can be performed as follows:\n\nFirst, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {15, 6, 2}.\n\nNext, multiply a_1 by 3, divide a_2 by 2 and multiply a_3 by 3. The sequence is now {45, 3, 6}.\n\nFinally, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {135, 9, 3}.\n\nSample Input 2\n\n4\n631 577 243 199\n\nSample Output 2\n\n0\n\nNo operation can be performed since all the elements are odd. Thus, the answer is 0.\n\nSample Input 3\n\n10\n2184 2126 1721 1800 1024 2528 3360 1945 1280 1776\n\nSample Output 3\n\n39", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 177, "cpu_time_ms": 29, "memory_kb": 2428}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s339274247", "group_id": "codeNet:p03325", "input_text": "N, *AS = $stdin.read.split.map(&:to_i)\ndef n_2(a)\n return 0 if a.odd?\n 30.downto(1) do |i|\n k = 2**i\n next if k > a\n if a % k == 0\n return i\n end\n end\n return 0\nend\n#AS.each do |a|\n# p a: a, n_2: n_2(a)\n#end\np AS.map{|a| n_2(a)}.inject(:+)", "language": "Ruby", "metadata": {"date": 1529198364, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03325.html", "problem_id": "p03325", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03325/input.txt", "sample_output_relpath": "derived/input_output/data/p03325/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03325/Ruby/s339274247.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s339274247", "user_id": "u437302815"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "N, *AS = $stdin.read.split.map(&:to_i)\ndef n_2(a)\n return 0 if a.odd?\n 30.downto(1) do |i|\n k = 2**i\n next if k > a\n if a % k == 0\n return i\n end\n end\n return 0\nend\n#AS.each do |a|\n# p a: a, n_2: n_2(a)\n#end\np AS.map{|a| n_2(a)}.inject(:+)", "problem_context": "Score: 300 points\n\nProblem Statement\n\nAs AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}.\n\nSnuke, an employee, would like to play with this sequence.\n\nSpecifically, he would like to repeat the following operation as many times as possible:\n\nFor every i satisfying 1 \\leq i \\leq N, perform one of the following: \"divide a_i by 2\" and \"multiply a_i by 3\".\nHere, choosing \"multiply a_i by 3\" for every i is not allowed, and the value of a_i after the operation must be an integer.\n\nAt most how many operations can be performed?\n\nConstraints\n\nN is an integer between 1 and 10 \\ 000 (inclusive).\n\na_i is an integer between 1 and 1 \\ 000 \\ 000 \\ 000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 a_3 ... a_N\n\nOutput\n\nPrint the maximum number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n5 2 4\n\nSample Output 1\n\n3\n\nThe sequence is initially {5, 2, 4}. Three operations can be performed as follows:\n\nFirst, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {15, 6, 2}.\n\nNext, multiply a_1 by 3, divide a_2 by 2 and multiply a_3 by 3. The sequence is now {45, 3, 6}.\n\nFinally, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {135, 9, 3}.\n\nSample Input 2\n\n4\n631 577 243 199\n\nSample Output 2\n\n0\n\nNo operation can be performed since all the elements are odd. Thus, the answer is 0.\n\nSample Input 3\n\n10\n2184 2126 1721 1800 1024 2528 3360 1945 1280 1776\n\nSample Output 3\n\n39", "sample_input": "3\n5 2 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03325", "source_text": "Score: 300 points\n\nProblem Statement\n\nAs AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}.\n\nSnuke, an employee, would like to play with this sequence.\n\nSpecifically, he would like to repeat the following operation as many times as possible:\n\nFor every i satisfying 1 \\leq i \\leq N, perform one of the following: \"divide a_i by 2\" and \"multiply a_i by 3\".\nHere, choosing \"multiply a_i by 3\" for every i is not allowed, and the value of a_i after the operation must be an integer.\n\nAt most how many operations can be performed?\n\nConstraints\n\nN is an integer between 1 and 10 \\ 000 (inclusive).\n\na_i is an integer between 1 and 1 \\ 000 \\ 000 \\ 000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 a_3 ... a_N\n\nOutput\n\nPrint the maximum number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n5 2 4\n\nSample Output 1\n\n3\n\nThe sequence is initially {5, 2, 4}. Three operations can be performed as follows:\n\nFirst, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {15, 6, 2}.\n\nNext, multiply a_1 by 3, divide a_2 by 2 and multiply a_3 by 3. The sequence is now {45, 3, 6}.\n\nFinally, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {135, 9, 3}.\n\nSample Input 2\n\n4\n631 577 243 199\n\nSample Output 2\n\n0\n\nNo operation can be performed since all the elements are odd. Thus, the answer is 0.\n\nSample Input 3\n\n10\n2184 2126 1721 1800 1024 2528 3360 1945 1280 1776\n\nSample Output 3\n\n39", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 261, "cpu_time_ms": 44, "memory_kb": 2556}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s034494504", "group_id": "codeNet:p03326", "input_text": "N, M = gets.split.map(&:to_i)\ncakes = []; N.times { cakes << gets.split.map(&:to_i) } \ndef cb(i); i==1 ? 1 : -1 ;end ;\nans = 0\np ans", "language": "Ruby", "metadata": {"date": 1543720844, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s034494504.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s034494504", "user_id": "u987208743"}, "prompt_components": {"gold_output": "56\n", "input_to_evaluate": "N, M = gets.split.map(&:to_i)\ncakes = []; N.times { cakes << gets.split.map(&:to_i) } \ndef cb(i); i==1 ? 1 : -1 ;end ;\nans = 0\np ans", "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": 132, "cpu_time_ms": 10, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s175199306", "group_id": "codeNet:p03326", "input_text": "N, M = gets.split.map(&:to_i)\nif M > 0\n inf = 10000000000 * M\n arr = Array.new(8){Array.new(M){-inf}}\n N.times do\n x, y, z = gets.split.map(&:to_i)\n for j in 0..7 do\n num = x * (-1) ** j + y * (-1) ** (j / 2) + z * (-1) ** (j / 4)\n if num > arr[j][M-1]\n arr[j].pop\n k = M - 2\n while k > 0 && num > arr[j][k-1]\n k -= 1\n end\n arr[j].insert(k, num)\n end\n end\n end\n ans = []\n arr.each {|nums| ans += [nums.inject(&:+)]}\n puts ans.max\nelse\n N.times{gets}\n puts 0\nend", "language": "Ruby", "metadata": {"date": 1529344707, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s175199306.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s175199306", "user_id": "u328735699"}, "prompt_components": {"gold_output": "56\n", "input_to_evaluate": "N, M = gets.split.map(&:to_i)\nif M > 0\n inf = 10000000000 * M\n arr = Array.new(8){Array.new(M){-inf}}\n N.times do\n x, y, z = gets.split.map(&:to_i)\n for j in 0..7 do\n num = x * (-1) ** j + y * (-1) ** (j / 2) + z * (-1) ** (j / 4)\n if num > arr[j][M-1]\n arr[j].pop\n k = M - 2\n while k > 0 && num > arr[j][k-1]\n k -= 1\n end\n arr[j].insert(k, num)\n end\n end\n end\n ans = []\n arr.each {|nums| ans += [nums.inject(&:+)]}\n puts ans.max\nelse\n N.times{gets}\n puts 0\nend", "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": 538, "cpu_time_ms": 394, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s513284395", "group_id": "codeNet:p03326", "input_text": "n, m = gets.strip.split.map(&:to_i)\ncakes = []\n\nn.times do\n cakes << gets.strip.split.map(&:to_i)\nend\n\npatterns = [\n [+1, +1, +1],\n [+1, +1, -1],\n [+1, -1, +1],\n [+1, -1, -1],\n [-1, +1, +1],\n [-1, +1, -1],\n [-1, -1, +1],\n [-1, -1, -1],\n]\n\nmxs = []\n\npatterns.each do |p|\n score = cakes.map.with_index { |cake, i| [i, cake[0] * p[0] + cake[1] * p[1] + cake[2] * p[2]] }\n ranking = score.sort_by { |s| s[1] }.reverse\n leaders = []\n m.times do |i|\n leaders << cakes[ranking[i][0]]\n end\n total = leaders.transpose.map { |row| row.inject(:+) }.map(&:abs).inject(:+)\n mxs << total\nend\n\nputs mxs.max\n", "language": "Ruby", "metadata": {"date": 1529238289, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s513284395.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s513284395", "user_id": "u729294108"}, "prompt_components": {"gold_output": "56\n", "input_to_evaluate": "n, m = gets.strip.split.map(&:to_i)\ncakes = []\n\nn.times do\n cakes << gets.strip.split.map(&:to_i)\nend\n\npatterns = [\n [+1, +1, +1],\n [+1, +1, -1],\n [+1, -1, +1],\n [+1, -1, -1],\n [-1, +1, +1],\n [-1, +1, -1],\n [-1, -1, +1],\n [-1, -1, -1],\n]\n\nmxs = []\n\npatterns.each do |p|\n score = cakes.map.with_index { |cake, i| [i, cake[0] * p[0] + cake[1] * p[1] + cake[2] * p[2]] }\n ranking = score.sort_by { |s| s[1] }.reverse\n leaders = []\n m.times do |i|\n leaders << cakes[ranking[i][0]]\n end\n total = leaders.transpose.map { |row| row.inject(:+) }.map(&:abs).inject(:+)\n mxs << total\nend\n\nputs mxs.max\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": 647, "cpu_time_ms": 19, "memory_kb": 2680}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s682415511", "group_id": "codeNet:p03326", "input_text": "n, m = gets.split(\" \").map{|v|v.to_i}\ncakes = Array.new(8) {|i| Array.new }\nn.times{|i|\n x, y, z = gets.split(\" \").map{|v|v.to_i}\n cakes[0] << (x + y + z)\n cakes[1] << (-x + y + z)\n cakes[2] << (x - y + z)\n cakes[3] << (-x - y + z)\n cakes[4] << (x + y - z)\n cakes[5] << (-x + y - z)\n cakes[6] << (x - y - z)\n cakes[7] << (-x - y - z)\n}\n\nmax = 0\ncakes.each{|c|\n c.sort!{|a, b|\n v = 0 if a == b\n v = 1 if a < b\n v = -1 if a > b\n v\n }\n max = [max, c[0, m].inject(:+)].max\n}\nputs max\n", "language": "Ruby", "metadata": {"date": 1529206016, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s682415511.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s682415511", "user_id": "u919970507"}, "prompt_components": {"gold_output": "56\n", "input_to_evaluate": "n, m = gets.split(\" \").map{|v|v.to_i}\ncakes = Array.new(8) {|i| Array.new }\nn.times{|i|\n x, y, z = gets.split(\" \").map{|v|v.to_i}\n cakes[0] << (x + y + z)\n cakes[1] << (-x + y + z)\n cakes[2] << (x - y + z)\n cakes[3] << (-x - y + z)\n cakes[4] << (x + y - z)\n cakes[5] << (-x + y - z)\n cakes[6] << (x - y - z)\n cakes[7] << (-x - y - z)\n}\n\nmax = 0\ncakes.each{|c|\n c.sort!{|a, b|\n v = 0 if a == b\n v = 1 if a < b\n v = -1 if a > b\n v\n }\n max = [max, c[0, m].inject(:+)].max\n}\nputs max\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": 504, "cpu_time_ms": 19, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s010972212", "group_id": "codeNet:p03327", "input_text": "n=gets.to_i\nif n>=1000\n printf(\"ABD%03d\\n\",n-999)\nelse\n printf(\"ABC%03d\\n\",n)\nend", "language": "Ruby", "metadata": {"date": 1557253148, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s010972212.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s010972212", "user_id": "u616320334"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "n=gets.to_i\nif n>=1000\n printf(\"ABD%03d\\n\",n-999)\nelse\n printf(\"ABC%03d\\n\",n)\nend", "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": 83, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s473592558", "group_id": "codeNet:p03328", "input_text": "a, b = gets.split.map(&:to_i)\n\nc = b - a - 1\nputs c * (c + 1) / 2 - a\n", "language": "Ruby", "metadata": {"date": 1528679091, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s473592558.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s473592558", "user_id": "u091367113"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "a, b = gets.split.map(&:to_i)\n\nc = b - a - 1\nputs c * (c + 1) / 2 - a\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": 70, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s008180212", "group_id": "codeNet:p03329", "input_text": "N = gets.to_i\nr = N\n\ndef calc(r, i)\n if r < 6\n return [r, i]\n end\n\n j = 0\n v = 1\n while r >= v\n j += 1\n v = 6 ** j\n end\n\n result = []\n result << calc(r - 6 ** (j - 1), i + 1)\n\n if r >= 9\n j = 0\n v = 1\n while r >= v\n j += 1\n v = 9 ** j\n end\n\n result << calc(r - 9 ** (j - 1), i + 1)\n end\n\n result\nend\n\nd = calc(r, 0).flatten\nresult = []\n0.step(d.size - 1, 2) do |i|\n result << d[i + 1] + d[i]\nend\np result.min", "language": "Ruby", "metadata": {"date": 1557597640, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s008180212.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s008180212", "user_id": "u503890246"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "N = gets.to_i\nr = N\n\ndef calc(r, i)\n if r < 6\n return [r, i]\n end\n\n j = 0\n v = 1\n while r >= v\n j += 1\n v = 6 ** j\n end\n\n result = []\n result << calc(r - 6 ** (j - 1), i + 1)\n\n if r >= 9\n j = 0\n v = 1\n while r >= v\n j += 1\n v = 9 ** j\n end\n\n result << calc(r - 9 ** (j - 1), i + 1)\n end\n\n result\nend\n\nd = calc(r, 0).flatten\nresult = []\n0.step(d.size - 1, 2) do |i|\n result << d[i + 1] + d[i]\nend\np result.min", "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": 454, "cpu_time_ms": 1970, "memory_kb": 133428}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s122586330", "group_id": "codeNet:p03331", "input_text": "n = gets.to_i\nans = []\n(2..n).each do |a|\n b = n - a\n sum_a = a.to_s.split('').map{|i| i.to_i}.inject(&:+)\n sum_b = b.to_s.split('').map{|i| i.to_i}.inject(&:+)\n\n ans << (sum_a + sum_b)\nend\np ans.min()", "language": "Ruby", "metadata": {"date": 1566070753, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03331.html", "problem_id": "p03331", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03331/input.txt", "sample_output_relpath": "derived/input_output/data/p03331/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03331/Ruby/s122586330.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s122586330", "user_id": "u239218660"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "n = gets.to_i\nans = []\n(2..n).each do |a|\n b = n - a\n sum_a = a.to_s.split('').map{|i| i.to_i}.inject(&:+)\n sum_b = b.to_s.split('').map{|i| i.to_i}.inject(&:+)\n\n ans << (sum_a + sum_b)\nend\np ans.min()", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has two positive integers A and B.\n\nIt is known that A plus B equals N.\nFind the minimum possible value of \"the sum of the digits of A\" plus \"the sum of the digits of B\" (in base 10).\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum possible value of \"the sum of the digits of A\" plus \"the sum of the digits of B\".\n\nSample Input 1\n\n15\n\nSample Output 1\n\n6\n\nWhen A=2 and B=13, the sums of their digits are 2 and 4, which minimizes the value in question.\n\nSample Input 2\n\n100000\n\nSample Output 2\n\n10", "sample_input": "15\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03331", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has two positive integers A and B.\n\nIt is known that A plus B equals N.\nFind the minimum possible value of \"the sum of the digits of A\" plus \"the sum of the digits of B\" (in base 10).\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum possible value of \"the sum of the digits of A\" plus \"the sum of the digits of B\".\n\nSample Input 1\n\n15\n\nSample Output 1\n\n6\n\nWhen A=2 and B=13, the sums of their digits are 2 and 4, which minimizes the value in question.\n\nSample Input 2\n\n100000\n\nSample Output 2\n\n10", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 205, "cpu_time_ms": 1467, "memory_kb": 2812}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s115651994", "group_id": "codeNet:p03337", "input_text": "a,b = gets.chomp.split.map(&:to_i)\nputs [a+b,a-b,a*b].max", "language": "Ruby", "metadata": {"date": 1575074600, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03337.html", "problem_id": "p03337", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03337/input.txt", "sample_output_relpath": "derived/input_output/data/p03337/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03337/Ruby/s115651994.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s115651994", "user_id": "u800051719"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "a,b = gets.chomp.split.map(&:to_i)\nputs [a+b,a-b,a*b].max", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers A and B.\nFind the largest value among A+B, A-B and A \\times B.\n\nConstraints\n\n-1000 \\leq A,B \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest value among A+B, A-B and A \\times B.\n\nSample Input 1\n\n3 1\n\nSample Output 1\n\n4\n\n3+1=4, 3-1=2 and 3 \\times 1=3. The largest among them is 4.\n\nSample Input 2\n\n4 -2\n\nSample Output 2\n\n6\n\nThe largest is 4 - (-2) = 6.\n\nSample Input 3\n\n0 0\n\nSample Output 3\n\n0", "sample_input": "3 1\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03337", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers A and B.\nFind the largest value among A+B, A-B and A \\times B.\n\nConstraints\n\n-1000 \\leq A,B \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest value among A+B, A-B and A \\times B.\n\nSample Input 1\n\n3 1\n\nSample Output 1\n\n4\n\n3+1=4, 3-1=2 and 3 \\times 1=3. The largest among them is 4.\n\nSample Input 2\n\n4 -2\n\nSample Output 2\n\n6\n\nThe largest is 4 - (-2) = 6.\n\nSample Input 3\n\n0 0\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 57, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s899351021", "group_id": "codeNet:p03338", "input_text": "jd", "language": "Ruby", "metadata": {"date": 1551292648, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s899351021.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s899351021", "user_id": "u974214237"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "jd", "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": 2, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s219805422", "group_id": "codeNet:p03338", "input_text": "n = gets.to_i\ns = gets.chomp\n\nans = 0\nn.times do |i|\n s1 = s[0..i]\n s2 = s[(i+1)...n]\n hoge = (s1.split('') & s2.split('')).uniq\n ans = [ans, hoge.size].max\nend\np ans", "language": "Ruby", "metadata": {"date": 1535833335, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s219805422.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s219805422", "user_id": "u553623615"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n = gets.to_i\ns = gets.chomp\n\nans = 0\nn.times do |i|\n s1 = s[0..i]\n s2 = s[(i+1)...n]\n hoge = (s1.split('') & s2.split('')).uniq\n ans = [ans, hoge.size].max\nend\np ans", "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": 178, "cpu_time_ms": 16, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s416061573", "group_id": "codeNet:p03339", "input_text": "n = gets.to_i\ns = gets.chomp.split('').map &:to_s\n\n$w_rui = [0]\n$e_rui = [0]\n(1..n).each do |i|\n $w_rui.push s[i-1] === 'W' ? $w_rui[-1] + 1 : $w_rui[-1]\n $e_rui.unshift s[n-i] === 'E' ? $e_rui[0] + 1 : $e_rui[0]\nend\n\nputs [$w_rui[0, n] , $e_rui[1, n+1]].transpose.map{|x| x.sum}.min\n\n\n", "language": "Ruby", "metadata": {"date": 1594438450, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s416061573.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s416061573", "user_id": "u772625937"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n = gets.to_i\ns = gets.chomp.split('').map &:to_s\n\n$w_rui = [0]\n$e_rui = [0]\n(1..n).each do |i|\n $w_rui.push s[i-1] === 'W' ? $w_rui[-1] + 1 : $w_rui[-1]\n $e_rui.unshift s[n-i] === 'E' ? $e_rui[0] + 1 : $e_rui[0]\nend\n\nputs [$w_rui[0, n] , $e_rui[1, n+1]].transpose.map{|x| x.sum}.min\n\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people standing in a row from west to east.\nEach person is facing east or west.\nThe directions of the people is given as a string S of length N.\nThe i-th person from the west is facing east if S_i = E, and west if S_i = W.\n\nYou will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader.\nHere, we do not care which direction the leader is facing.\n\nThe people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized.\nFind the minimum number of people who have to change their directions.\n\nConstraints\n\n2 \\leq N \\leq 3 \\times 10^5\n\n|S| = N\n\nS_i is E or W.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the minimum number of people who have to change their directions.\n\nSample Input 1\n\n5\nWEEWW\n\nSample Output 1\n\n1\n\nAssume that we appoint the third person from the west as the leader.\nThen, the first person from the west needs to face east and has to turn around.\nThe other people do not need to change their directions, so the number of people who have to change their directions is 1 in this case.\nIt is not possible to have 0 people who have to change their directions, so the answer is 1.\n\nSample Input 2\n\n12\nWEWEWEEEWWWE\n\nSample Output 2\n\n4\n\nSample Input 3\n\n8\nWWWWWEEE\n\nSample Output 3\n\n3", "sample_input": "5\nWEEWW\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03339", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people standing in a row from west to east.\nEach person is facing east or west.\nThe directions of the people is given as a string S of length N.\nThe i-th person from the west is facing east if S_i = E, and west if S_i = W.\n\nYou will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader.\nHere, we do not care which direction the leader is facing.\n\nThe people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized.\nFind the minimum number of people who have to change their directions.\n\nConstraints\n\n2 \\leq N \\leq 3 \\times 10^5\n\n|S| = N\n\nS_i is E or W.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the minimum number of people who have to change their directions.\n\nSample Input 1\n\n5\nWEEWW\n\nSample Output 1\n\n1\n\nAssume that we appoint the third person from the west as the leader.\nThen, the first person from the west needs to face east and has to turn around.\nThe other people do not need to change their directions, so the number of people who have to change their directions is 1 in this case.\nIt is not possible to have 0 people who have to change their directions, so the answer is 1.\n\nSample Input 2\n\n12\nWEWEWEEEWWWE\n\nSample Output 2\n\n4\n\nSample Input 3\n\n8\nWWWWWEEE\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 288, "cpu_time_ms": 268, "memory_kb": 54052}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s282169289", "group_id": "codeNet:p03339", "input_text": "n = gets.to_i\ns = gets.chomp\nmin = n\nw = s.scan(/W/).size\ne = n - w\nl = 0\n(0...n).each do |x|\n if s[x] == 'W'\n l += 1\n w -= 1\n else\n e -= 1\n end\n m = (s[x] == 'W') ? l+e-1 : l+e \n min = m if min > m\nend\nputs min", "language": "Ruby", "metadata": {"date": 1589861404, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s282169289.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s282169289", "user_id": "u437368899"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n = gets.to_i\ns = gets.chomp\nmin = n\nw = s.scan(/W/).size\ne = n - w\nl = 0\n(0...n).each do |x|\n if s[x] == 'W'\n l += 1\n w -= 1\n else\n e -= 1\n end\n m = (s[x] == 'W') ? l+e-1 : l+e \n min = m if min > m\nend\nputs min", "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": 226, "cpu_time_ms": 262, "memory_kb": 27396}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s766469534", "group_id": "codeNet:p03345", "input_text": "array = gets.split(\" \").map(&:to_i)\np1 = array[0] - array[1]\np2 = array[1] - array[0]\nif array[3].even? && p1 < 1000000000000000000\n puts p1\nelsif array[3].odd? && p2 < 1000000000000000000\n puts p2\nelse\n puts 'Unfair'\nend", "language": "Ruby", "metadata": {"date": 1530990364, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03345.html", "problem_id": "p03345", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03345/input.txt", "sample_output_relpath": "derived/input_output/data/p03345/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03345/Ruby/s766469534.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s766469534", "user_id": "u441320643"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "array = gets.split(\" \").map(&:to_i)\np1 = array[0] - array[1]\np2 = array[1] - array[0]\nif array[3].even? && p1 < 1000000000000000000\n puts p1\nelsif array[3].odd? && p2 < 1000000000000000000\n puts p2\nelse\n puts 'Unfair'\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively.\nAfter repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get:\n\nEach of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result.\n\nHowever, if the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nConstraints\n\n1 \\leq A,B,C \\leq 10^9\n\n0 \\leq K \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the integer Takahashi will get minus the integer Nakahashi will get, after repeating the following operation K times.\nIf the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nSample Input 1\n\n1 2 3 1\n\nSample Output 1\n\n1\n\nAfter one operation, Takahashi, Nakahashi and Hikuhashi have 5, 4 and 3, respectively. We should print 5-4=1.\n\nSample Input 2\n\n2 3 2 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n1000000000 1000000000 1000000000 1000000000000000000\n\nSample Output 3\n\n0", "sample_input": "1 2 3 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03345", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively.\nAfter repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get:\n\nEach of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result.\n\nHowever, if the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nConstraints\n\n1 \\leq A,B,C \\leq 10^9\n\n0 \\leq K \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the integer Takahashi will get minus the integer Nakahashi will get, after repeating the following operation K times.\nIf the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nSample Input 1\n\n1 2 3 1\n\nSample Output 1\n\n1\n\nAfter one operation, Takahashi, Nakahashi and Hikuhashi have 5, 4 and 3, respectively. We should print 5-4=1.\n\nSample Input 2\n\n2 3 2 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n1000000000 1000000000 1000000000 1000000000000000000\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 224, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s739868648", "group_id": "codeNet:p03345", "input_text": "a, b, c, k = STDIN.gets.split.map(&:to_i)\n\nif a == b && b == c && c == a\n puts 0\nend\n\nk.times do\n na = b + c\n nb = a + c\n nc = a + b\n a, b, c = na, nb, nc\n if a - b > 10**18\n puts 'Unfair'\n end\nend\n\nputs a - b", "language": "Ruby", "metadata": {"date": 1526866195, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03345.html", "problem_id": "p03345", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03345/input.txt", "sample_output_relpath": "derived/input_output/data/p03345/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03345/Ruby/s739868648.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s739868648", "user_id": "u039293076"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "a, b, c, k = STDIN.gets.split.map(&:to_i)\n\nif a == b && b == c && c == a\n puts 0\nend\n\nk.times do\n na = b + c\n nb = a + c\n nc = a + b\n a, b, c = na, nb, nc\n if a - b > 10**18\n puts 'Unfair'\n end\nend\n\nputs a - b", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively.\nAfter repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get:\n\nEach of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result.\n\nHowever, if the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nConstraints\n\n1 \\leq A,B,C \\leq 10^9\n\n0 \\leq K \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the integer Takahashi will get minus the integer Nakahashi will get, after repeating the following operation K times.\nIf the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nSample Input 1\n\n1 2 3 1\n\nSample Output 1\n\n1\n\nAfter one operation, Takahashi, Nakahashi and Hikuhashi have 5, 4 and 3, respectively. We should print 5-4=1.\n\nSample Input 2\n\n2 3 2 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n1000000000 1000000000 1000000000 1000000000000000000\n\nSample Output 3\n\n0", "sample_input": "1 2 3 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03345", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively.\nAfter repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get:\n\nEach of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result.\n\nHowever, if the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nConstraints\n\n1 \\leq A,B,C \\leq 10^9\n\n0 \\leq K \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the integer Takahashi will get minus the integer Nakahashi will get, after repeating the following operation K times.\nIf the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nSample Input 1\n\n1 2 3 1\n\nSample Output 1\n\n1\n\nAfter one operation, Takahashi, Nakahashi and Hikuhashi have 5, 4 and 3, respectively. We should print 5-4=1.\n\nSample Input 2\n\n2 3 2 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n1000000000 1000000000 1000000000 1000000000000000000\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 219, "cpu_time_ms": 2113, "memory_kb": 85976}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s740537509", "group_id": "codeNet:p03345", "input_text": "require 'pp'\na, b, c, k = gets.chomp.split(\" \").map(&:to_i)\n\nx = a - b\nif x > 10 ** 18 || x < - (10 ** 18)\n puts 'Unfair'\nelsif k.even?\n puts x\nelse\n puts -x\nend\n", "language": "Ruby", "metadata": {"date": 1526865109, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03345.html", "problem_id": "p03345", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03345/input.txt", "sample_output_relpath": "derived/input_output/data/p03345/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03345/Ruby/s740537509.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s740537509", "user_id": "u585675791"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "require 'pp'\na, b, c, k = gets.chomp.split(\" \").map(&:to_i)\n\nx = a - b\nif x > 10 ** 18 || x < - (10 ** 18)\n puts 'Unfair'\nelsif k.even?\n puts x\nelse\n puts -x\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively.\nAfter repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get:\n\nEach of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result.\n\nHowever, if the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nConstraints\n\n1 \\leq A,B,C \\leq 10^9\n\n0 \\leq K \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the integer Takahashi will get minus the integer Nakahashi will get, after repeating the following operation K times.\nIf the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nSample Input 1\n\n1 2 3 1\n\nSample Output 1\n\n1\n\nAfter one operation, Takahashi, Nakahashi and Hikuhashi have 5, 4 and 3, respectively. We should print 5-4=1.\n\nSample Input 2\n\n2 3 2 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n1000000000 1000000000 1000000000 1000000000000000000\n\nSample Output 3\n\n0", "sample_input": "1 2 3 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03345", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively.\nAfter repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get:\n\nEach of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result.\n\nHowever, if the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nConstraints\n\n1 \\leq A,B,C \\leq 10^9\n\n0 \\leq K \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the integer Takahashi will get minus the integer Nakahashi will get, after repeating the following operation K times.\nIf the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nSample Input 1\n\n1 2 3 1\n\nSample Output 1\n\n1\n\nAfter one operation, Takahashi, Nakahashi and Hikuhashi have 5, 4 and 3, respectively. We should print 5-4=1.\n\nSample Input 2\n\n2 3 2 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n1000000000 1000000000 1000000000 1000000000000000000\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 165, "cpu_time_ms": 50, "memory_kb": 2172}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s715470152", "group_id": "codeNet:p03345", "input_text": "def ascan; gets.split.map(&:to_i);end\n \nA,B,C,K = ascan\n\nu = A-B\n\nu=-u if K.odd?\n\np u", "language": "Ruby", "metadata": {"date": 1526864841, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03345.html", "problem_id": "p03345", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03345/input.txt", "sample_output_relpath": "derived/input_output/data/p03345/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03345/Ruby/s715470152.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s715470152", "user_id": "u079330987"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "def ascan; gets.split.map(&:to_i);end\n \nA,B,C,K = ascan\n\nu = A-B\n\nu=-u if K.odd?\n\np u", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively.\nAfter repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get:\n\nEach of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result.\n\nHowever, if the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nConstraints\n\n1 \\leq A,B,C \\leq 10^9\n\n0 \\leq K \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the integer Takahashi will get minus the integer Nakahashi will get, after repeating the following operation K times.\nIf the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nSample Input 1\n\n1 2 3 1\n\nSample Output 1\n\n1\n\nAfter one operation, Takahashi, Nakahashi and Hikuhashi have 5, 4 and 3, respectively. We should print 5-4=1.\n\nSample Input 2\n\n2 3 2 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n1000000000 1000000000 1000000000 1000000000000000000\n\nSample Output 3\n\n0", "sample_input": "1 2 3 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03345", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively.\nAfter repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get:\n\nEach of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result.\n\nHowever, if the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nConstraints\n\n1 \\leq A,B,C \\leq 10^9\n\n0 \\leq K \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the integer Takahashi will get minus the integer Nakahashi will get, after repeating the following operation K times.\nIf the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nSample Input 1\n\n1 2 3 1\n\nSample Output 1\n\n1\n\nAfter one operation, Takahashi, Nakahashi and Hikuhashi have 5, 4 and 3, respectively. We should print 5-4=1.\n\nSample Input 2\n\n2 3 2 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n1000000000 1000000000 1000000000 1000000000000000000\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 88, "cpu_time_ms": 7, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s648021790", "group_id": "codeNet:p03352", "input_text": "#prime_divisionを用いた。\nrequire \"prime\"\nx = gets.chomp.to_i\nx.downto (1) do |i|\n ans = i.prime_division\n size = ans.size\n count = 0\n if size == 1 && ans[0][1] != 1 && x >= 4\n puts i\n break\n elsif size >= 2 \n count = 0\n me = ans[0][1] \n ans.each do |i|\n if me == i[1] && me != 1 \n count += 1\n end\n end\n if count == size\n puts i\n break\n end\n elsif x < 4\n puts \"1\"\n break\n end\nend\n", "language": "Ruby", "metadata": {"date": 1597141866, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p03352.html", "problem_id": "p03352", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03352/input.txt", "sample_output_relpath": "derived/input_output/data/p03352/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03352/Ruby/s648021790.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s648021790", "user_id": "u412789323"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "#prime_divisionを用いた。\nrequire \"prime\"\nx = gets.chomp.to_i\nx.downto (1) do |i|\n ans = i.prime_division\n size = ans.size\n count = 0\n if size == 1 && ans[0][1] != 1 && x >= 4\n puts i\n break\n elsif size >= 2 \n count = 0\n me = ans[0][1] \n ans.each do |i|\n if me == i[1] && me != 1 \n count += 1\n end\n end\n if count == size\n puts i\n break\n end\n elsif x < 4\n puts \"1\"\n break\n end\nend\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "sample_input": "10\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03352", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 535, "cpu_time_ms": 68, "memory_kb": 14364}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s350438118", "group_id": "codeNet:p03352", "input_text": "#!/usr/bin/ruby \n#encoding: utf-8\n\nx = gets.to_i\nmax = 0\n\n(1..x).each do |i|\n (2..10).each do |j|\n a = i ** j\n if a <= x\n max = [max,a].max\n end\n end\nend\n\nputs max\n", "language": "Ruby", "metadata": {"date": 1560531762, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03352.html", "problem_id": "p03352", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03352/input.txt", "sample_output_relpath": "derived/input_output/data/p03352/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03352/Ruby/s350438118.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s350438118", "user_id": "u998741086"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "#!/usr/bin/ruby \n#encoding: utf-8\n\nx = gets.to_i\nmax = 0\n\n(1..x).each do |i|\n (2..10).each do |j|\n a = i ** j\n if a <= x\n max = [max,a].max\n end\n end\nend\n\nputs max\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "sample_input": "10\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03352", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 180, "cpu_time_ms": 9, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s460300749", "group_id": "codeNet:p03352", "input_text": "a=gets.to_i\nputs (1..1000).map{|x| x**([*2..10].reverse.find{|y| x**y <= a}||0)}.max", "language": "Ruby", "metadata": {"date": 1534329759, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03352.html", "problem_id": "p03352", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03352/input.txt", "sample_output_relpath": "derived/input_output/data/p03352/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03352/Ruby/s460300749.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s460300749", "user_id": "u056944756"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "a=gets.to_i\nputs (1..1000).map{|x| x**([*2..10].reverse.find{|y| x**y <= a}||0)}.max", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "sample_input": "10\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03352", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 84, "cpu_time_ms": 11, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s789003619", "group_id": "codeNet:p03352", "input_text": "x = gets.to_i\nmax = 1\n\n(1..x).each do |i|\n\t(2..x).each do |j|\n\t\tnum = i ** j\n\t\tif num <= x\n\t\t\tmax = num if num > max\n\t\telse\n\t\t\tbreak\n\t\tend\n\tend\t\nend\n\nputs max", "language": "Ruby", "metadata": {"date": 1529186581, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03352.html", "problem_id": "p03352", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03352/input.txt", "sample_output_relpath": "derived/input_output/data/p03352/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03352/Ruby/s789003619.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s789003619", "user_id": "u475329018"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "x = gets.to_i\nmax = 1\n\n(1..x).each do |i|\n\t(2..x).each do |j|\n\t\tnum = i ** j\n\t\tif num <= x\n\t\t\tmax = num if num > max\n\t\telse\n\t\t\tbreak\n\t\tend\n\tend\t\nend\n\nputs max", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "sample_input": "10\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03352", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 158, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s956377451", "group_id": "codeNet:p03352", "input_text": "x = gets.to_i\n\nps = [2]\n\n(3..31).each do |n|\n if ps.all? {|p| n%p != 0}\n ps << n\n end\nend\n\nns = [1]\n\nps.each do |b|\n p = 2\n while b**p <= 1000\n ns << b**p\n p += 1\n end\nend\n\nns = ns.sort\n\n(0..ns.length-1).each do |i|\n if x < ns[i]\n p ns[i-1]\n exit 0\n end\nend", "language": "Ruby", "metadata": {"date": 1528514500, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03352.html", "problem_id": "p03352", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03352/input.txt", "sample_output_relpath": "derived/input_output/data/p03352/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03352/Ruby/s956377451.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s956377451", "user_id": "u852974293"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "x = gets.to_i\n\nps = [2]\n\n(3..31).each do |n|\n if ps.all? {|p| n%p != 0}\n ps << n\n end\nend\n\nns = [1]\n\nps.each do |b|\n p = 2\n while b**p <= 1000\n ns << b**p\n p += 1\n end\nend\n\nns = ns.sort\n\n(0..ns.length-1).each do |i|\n if x < ns[i]\n p ns[i-1]\n exit 0\n end\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "sample_input": "10\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03352", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 279, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s714434421", "group_id": "codeNet:p03352", "input_text": "x = gets.to_i\n\nx.downto(1) do |i|\n 2.upto(i) do |j|\n if i % j == 0\n y = i\n cnt = 0\n while y % j == 0\n y /= j\n cnt += 1\n end\n if y == 1 && cnt > 1\n puts i\n exit\n end\n end\n end\nend", "language": "Ruby", "metadata": {"date": 1526184055, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03352.html", "problem_id": "p03352", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03352/input.txt", "sample_output_relpath": "derived/input_output/data/p03352/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03352/Ruby/s714434421.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s714434421", "user_id": "u553623615"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "x = gets.to_i\n\nx.downto(1) do |i|\n 2.upto(i) do |j|\n if i % j == 0\n y = i\n cnt = 0\n while y % j == 0\n y /= j\n cnt += 1\n end\n if y == 1 && cnt > 1\n puts i\n exit\n end\n end\n end\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "sample_input": "10\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03352", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 324, "cpu_time_ms": 11, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s192531849", "group_id": "codeNet:p03353", "input_text": "require 'set'\ns = gets.chomp.chars\nK = gets.to_i\n\nset = SortedSet.new()\nused = {}\n(0...(s.size)).each do |i|\n (i...(s.size)).each do |j|\n subs = s[i..j]\n set.add(subs)\n end\nend\nputs set.to_a[K - 1].join('')\n", "language": "Ruby", "metadata": {"date": 1556338183, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s192531849.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s192531849", "user_id": "u012133968"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "require 'set'\ns = gets.chomp.chars\nK = gets.to_i\n\nset = SortedSet.new()\nused = {}\n(0...(s.size)).each do |i|\n (i...(s.size)).each do |j|\n subs = s[i..j]\n set.add(subs)\n end\nend\nputs set.to_a[K - 1].join('')\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": 215, "cpu_time_ms": 2108, "memory_kb": 2684}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s235942321", "group_id": "codeNet:p03354", "input_text": "gets\nps = [0] + gets.split.map(&:to_i)\nxys = $stdin.read.split\n\nh = {}\nxys.each_slice(2) do |xs,ys|\n x = xs.to_i\n y = ys.to_i\n h[x] ||= []\n h[x] << y\n h[y] ||= []\n h[y] << x\nend\n\nused = {}\nret = 0\nh.each do |k,v|\n next if used[k]\n b = v\n lused = {}\n lused[k] = 1\n until b.empty?\n b.each do |n|\n lused[n] = 1\n end\n b = b.flat_map {|n| h[n] || []}.uniq.reject {|n| lused[n]}\n end\n used.merge!(lused)\n\n ret += lused.keys.count {|n| lused[ps[n]]}\nend\n\n1.upto(ps.length-1) do |i|\n ret += 1 if !used[i] && ps[i] == i\nend\n\np ret\n", "language": "Ruby", "metadata": {"date": 1528570092, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03354.html", "problem_id": "p03354", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03354/input.txt", "sample_output_relpath": "derived/input_output/data/p03354/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03354/Ruby/s235942321.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s235942321", "user_id": "u852974293"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "gets\nps = [0] + gets.split.map(&:to_i)\nxys = $stdin.read.split\n\nh = {}\nxys.each_slice(2) do |xs,ys|\n x = xs.to_i\n y = ys.to_i\n h[x] ||= []\n h[x] << y\n h[y] ||= []\n h[y] << x\nend\n\nused = {}\nret = 0\nh.each do |k,v|\n next if used[k]\n b = v\n lused = {}\n lused[k] = 1\n until b.empty?\n b.each do |n|\n lused[n] = 1\n end\n b = b.flat_map {|n| h[n] || []}.uniq.reject {|n| lused[n]}\n end\n used.merge!(lused)\n\n ret += lused.keys.count {|n| lused[ps[n]]}\nend\n\n1.upto(ps.length-1) do |i|\n ret += 1 if !used[i] && ps[i] == i\nend\n\np ret\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a permutation of the integers from 1 through N, p_1, p_2, .., p_N.\nWe also have M pairs of two integers between 1 and N (inclusive), represented as (x_1,y_1), (x_2,y_2), .., (x_M,y_M).\nAtCoDeer the deer is going to perform the following operation on p as many times as desired so that the number of i (1 ≤ i ≤ N) such that p_i = i is maximized:\n\nChoose j such that 1 ≤ j ≤ M, and swap p_{x_j} and p_{y_j}.\n\nFind the maximum possible number of i such that p_i = i after operations.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ M ≤ 10^5\n\np is a permutation of integers from 1 through N.\n\n1 ≤ x_j,y_j ≤ N\n\nx_j ≠ y_j\n\nIf i ≠ j, \\{x_i,y_i\\} ≠ \\{x_j,y_j\\}.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 p_2 .. p_N\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the maximum possible number of i such that p_i = i after operations.\n\nSample Input 1\n\n5 2\n5 3 1 4 2\n1 3\n5 4\n\nSample Output 1\n\n2\n\nIf we perform the operation by choosing j=1, p becomes 1 3 5 4 2, which is optimal, so the answer is 2.\n\nSample Input 2\n\n3 2\n3 2 1\n1 2\n2 3\n\nSample Output 2\n\n3\n\nIf we perform the operation by, for example, choosing j=1, j=2, j=1 in this order, p becomes 1 2 3, which is obviously optimal.\nNote that we may choose the same j any number of times.\n\nSample Input 3\n\n10 8\n5 3 6 8 7 10 9 1 2 4\n3 1\n4 1\n5 9\n2 5\n6 5\n3 5\n8 9\n7 9\n\nSample Output 3\n\n8\n\nSample Input 4\n\n5 1\n1 2 3 4 5\n1 5\n\nSample Output 4\n\n5\n\nWe do not have to perform the operation.", "sample_input": "5 2\n5 3 1 4 2\n1 3\n5 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03354", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a permutation of the integers from 1 through N, p_1, p_2, .., p_N.\nWe also have M pairs of two integers between 1 and N (inclusive), represented as (x_1,y_1), (x_2,y_2), .., (x_M,y_M).\nAtCoDeer the deer is going to perform the following operation on p as many times as desired so that the number of i (1 ≤ i ≤ N) such that p_i = i is maximized:\n\nChoose j such that 1 ≤ j ≤ M, and swap p_{x_j} and p_{y_j}.\n\nFind the maximum possible number of i such that p_i = i after operations.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ M ≤ 10^5\n\np is a permutation of integers from 1 through N.\n\n1 ≤ x_j,y_j ≤ N\n\nx_j ≠ y_j\n\nIf i ≠ j, \\{x_i,y_i\\} ≠ \\{x_j,y_j\\}.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 p_2 .. p_N\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the maximum possible number of i such that p_i = i after operations.\n\nSample Input 1\n\n5 2\n5 3 1 4 2\n1 3\n5 4\n\nSample Output 1\n\n2\n\nIf we perform the operation by choosing j=1, p becomes 1 3 5 4 2, which is optimal, so the answer is 2.\n\nSample Input 2\n\n3 2\n3 2 1\n1 2\n2 3\n\nSample Output 2\n\n3\n\nIf we perform the operation by, for example, choosing j=1, j=2, j=1 in this order, p becomes 1 2 3, which is obviously optimal.\nNote that we may choose the same j any number of times.\n\nSample Input 3\n\n10 8\n5 3 6 8 7 10 9 1 2 4\n3 1\n4 1\n5 9\n2 5\n6 5\n3 5\n8 9\n7 9\n\nSample Output 3\n\n8\n\nSample Input 4\n\n5 1\n1 2 3 4 5\n1 5\n\nSample Output 4\n\n5\n\nWe do not have to perform the operation.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 551, "cpu_time_ms": 518, "memory_kb": 53364}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s475466974", "group_id": "codeNet:p03356", "input_text": "class Unionfind\n attr_accessor(:par, :size)\n\n def initialize(n)\n @par = Array.new(n+1)\n (n+1).times do |i|\n @par[i] = i\n end\n @size = Array.new(n+1,1)\n end\n\n def root(x)\n while @par[x] != x\n x = @par[@par[x]]\n @par[x] = @par[@par[x]]\n end\n x\n end\n\n def unite(x,y)\n rx = root(x)\n ry = root(y)\n if rx != ry\n @size[ry] += size(rx)\n @par[rx] = ry\n end\n end\n\n def same(x,y)\n return root(x)==root(y)\n end\n\n def size(x)\n if @par[x] == x\n @size[x]\n else\n size(root(par[x]))\n end\n end\n\nend\n\nn,m = gets.chomp.split(\" \").map(&:to_i)\np = gets.chomp.split(\" \").map(&:to_i)\nx = []\ny = []\ntree = Unionfind.new(n)\nm.times do |i|\n x,y = gets.chomp.split(\" \").map(&:to_i)\n tree.unite(x,y)\nend\ncnt = 0\n1.upto(n) do |i|\n if i == p[i]\n cnt += 1\n elsif tree.same(p[i-1],i)\n cnt += 1\n end\nend\nputs cnt", "language": "Ruby", "metadata": {"date": 1596007524, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s475466974.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s475466974", "user_id": "u265679940"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "class Unionfind\n attr_accessor(:par, :size)\n\n def initialize(n)\n @par = Array.new(n+1)\n (n+1).times do |i|\n @par[i] = i\n end\n @size = Array.new(n+1,1)\n end\n\n def root(x)\n while @par[x] != x\n x = @par[@par[x]]\n @par[x] = @par[@par[x]]\n end\n x\n end\n\n def unite(x,y)\n rx = root(x)\n ry = root(y)\n if rx != ry\n @size[ry] += size(rx)\n @par[rx] = ry\n end\n end\n\n def same(x,y)\n return root(x)==root(y)\n end\n\n def size(x)\n if @par[x] == x\n @size[x]\n else\n size(root(par[x]))\n end\n end\n\nend\n\nn,m = gets.chomp.split(\" \").map(&:to_i)\np = gets.chomp.split(\" \").map(&:to_i)\nx = []\ny = []\ntree = Unionfind.new(n)\nm.times do |i|\n x,y = gets.chomp.split(\" \").map(&:to_i)\n tree.unite(x,y)\nend\ncnt = 0\n1.upto(n) do |i|\n if i == p[i]\n cnt += 1\n elsif tree.same(p[i-1],i)\n cnt += 1\n end\nend\nputs cnt", "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": 880, "cpu_time_ms": 237, "memory_kb": 23220}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s633554822", "group_id": "codeNet:p03356", "input_text": "require 'pp'\n# IS_DEBUG = true\nIS_DEBUG = false\ndef dputs str\n\tif(IS_DEBUG)\n\t\tputs str\n\tend\nend\ndef dpp str\n\tif(IS_DEBUG)\n\t\tpp str\n\tend\nend\n\nrequire 'pp'\n\nINT_MAX = 999999999999999999999999\n\nN,M=gets.chomp.split(' ').map{|n| n.to_i}\nP=[nil] + gets.chomp.split(' ').map{|n| n.to_i}\ndpp P\nX = Array.new(M)\n0.upto(M-1){|d|\n\tX[d]=gets.chomp.split(' ').map{|n| n.to_i}\n}\n\n# flat array\n\nclass Sarr\n\tdef initialize(m)\n\t\t@S = Array.new(m) { nil }\n\t\t@next_i = 0\n\t\t@index = []\n\tend\n\tdef s_index(n)\n\t\t@S[n]\n\t\t# return nil\n\tend\n\t# index\n\tdef s_merge(n,m)\n\t\tif(n > m)\n\t\t\ttmp = n\n\t\t\tn = m\n\t\t\tm = tmp\n\t\tend\n\t\t@S.map!{|i|\n\t\t\tif(i==m)\n\t\t\t\tn\n\t\t\telse\n\t\t\t\ti\n\t\t\tend\n\t\t}\n\t\t@index.delete(m)\n\tend\n\tdef s_add(n)\n\t\t@S[n] = @next_i\n\t\t@index << @next_i\n\t\t@next_i += 1\n\t\treturn @next_i - 1\n\tend\n\tdef s_i_add(n,i)\n\t\t@S[n]=i\n\tend\n\tdef getS\n\t\t@S\n\tend\n\tdef getnexti\n\t\t@next_i\n\tend\n\tdef connect(x,y)\n\t\tdpp @S\n\t\tsx_index = s_index(x)\n\t\tdputs \"sx_index is #{sx_index}\"\n\t\tif(sx_index.nil?)\n\t\t\tsx_index = s_add(x)\n\t\telse\n\t\t\t# ok\n\t\tend\n\t\tsy_index = s_index(y)\n\t\tif(sy_index.nil?)\n\t\t\tsy_index = sx_index\n\t\t\ts_i_add(y,sx_index)\n\t\telse\n\t\t\tif(sx_index == sy_index)\n\t\t\t\t# ok\n\t\t\telse\n\t\t\t\ts_merge(sx_index,sy_index)\n\t\t\tend\n\t\tend\n\tend\n\tdef reindex\n\t\treverse_index_map = {}\n\t\t@index.sort.each_with_index{|old_i, new_i|\n\t\t\treverse_index_map[old_i] = new_i\n\t\t}\n\t\t@S.map{|si|\n\t\t\tif(si.nil?)\n\t\t\t\tnil\n\t\t\telse\n\t\t\t\treverse_index_map[si]\n\t\t\tend\n\t\t}\n\tend\nend\n\nsarr = Sarr.new(N)\n\nX.each{|x,y|\n\tsarr.connect(x,y)\n}\n\nsarr.reindex\n\ns = sarr.getS\ndpp s\nnum_si = s.compact.max\ndpp num_si\nss = Array.new(num_si+1){[]}\n\ns.each_with_index{|si,i|\n\tif(! si.nil?)\n\t\tss[si] << i\n\tend\n}\ndpp ss\nsum = 0\nss.each{|set|\n\tsetp = {}\n\tset.each{|i| \n\t\tsetp[P[i]] = P[i]\n\t}\n\tdputs \"set, setp is\"\n\tdpp set\n\tdpp setp\n\tset.each{|i|\n\t\tif(! setp[i].nil?)\n\t\t\tsum += 1\n\t\tend\n\t}\n}\ndputs \"appeared sum is #{sum}\"\ns.each_with_index{|si,i|\n\tif(si.nil? && P[i] == i)\n\t\tsum += 1\n\t\tdputs \"hit\"\n\tend\n}\n\nputs sum\n", "language": "Ruby", "metadata": {"date": 1526181245, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s633554822.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s633554822", "user_id": "u415591191"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "require 'pp'\n# IS_DEBUG = true\nIS_DEBUG = false\ndef dputs str\n\tif(IS_DEBUG)\n\t\tputs str\n\tend\nend\ndef dpp str\n\tif(IS_DEBUG)\n\t\tpp str\n\tend\nend\n\nrequire 'pp'\n\nINT_MAX = 999999999999999999999999\n\nN,M=gets.chomp.split(' ').map{|n| n.to_i}\nP=[nil] + gets.chomp.split(' ').map{|n| n.to_i}\ndpp P\nX = Array.new(M)\n0.upto(M-1){|d|\n\tX[d]=gets.chomp.split(' ').map{|n| n.to_i}\n}\n\n# flat array\n\nclass Sarr\n\tdef initialize(m)\n\t\t@S = Array.new(m) { nil }\n\t\t@next_i = 0\n\t\t@index = []\n\tend\n\tdef s_index(n)\n\t\t@S[n]\n\t\t# return nil\n\tend\n\t# index\n\tdef s_merge(n,m)\n\t\tif(n > m)\n\t\t\ttmp = n\n\t\t\tn = m\n\t\t\tm = tmp\n\t\tend\n\t\t@S.map!{|i|\n\t\t\tif(i==m)\n\t\t\t\tn\n\t\t\telse\n\t\t\t\ti\n\t\t\tend\n\t\t}\n\t\t@index.delete(m)\n\tend\n\tdef s_add(n)\n\t\t@S[n] = @next_i\n\t\t@index << @next_i\n\t\t@next_i += 1\n\t\treturn @next_i - 1\n\tend\n\tdef s_i_add(n,i)\n\t\t@S[n]=i\n\tend\n\tdef getS\n\t\t@S\n\tend\n\tdef getnexti\n\t\t@next_i\n\tend\n\tdef connect(x,y)\n\t\tdpp @S\n\t\tsx_index = s_index(x)\n\t\tdputs \"sx_index is #{sx_index}\"\n\t\tif(sx_index.nil?)\n\t\t\tsx_index = s_add(x)\n\t\telse\n\t\t\t# ok\n\t\tend\n\t\tsy_index = s_index(y)\n\t\tif(sy_index.nil?)\n\t\t\tsy_index = sx_index\n\t\t\ts_i_add(y,sx_index)\n\t\telse\n\t\t\tif(sx_index == sy_index)\n\t\t\t\t# ok\n\t\t\telse\n\t\t\t\ts_merge(sx_index,sy_index)\n\t\t\tend\n\t\tend\n\tend\n\tdef reindex\n\t\treverse_index_map = {}\n\t\t@index.sort.each_with_index{|old_i, new_i|\n\t\t\treverse_index_map[old_i] = new_i\n\t\t}\n\t\t@S.map{|si|\n\t\t\tif(si.nil?)\n\t\t\t\tnil\n\t\t\telse\n\t\t\t\treverse_index_map[si]\n\t\t\tend\n\t\t}\n\tend\nend\n\nsarr = Sarr.new(N)\n\nX.each{|x,y|\n\tsarr.connect(x,y)\n}\n\nsarr.reindex\n\ns = sarr.getS\ndpp s\nnum_si = s.compact.max\ndpp num_si\nss = Array.new(num_si+1){[]}\n\ns.each_with_index{|si,i|\n\tif(! si.nil?)\n\t\tss[si] << i\n\tend\n}\ndpp ss\nsum = 0\nss.each{|set|\n\tsetp = {}\n\tset.each{|i| \n\t\tsetp[P[i]] = P[i]\n\t}\n\tdputs \"set, setp is\"\n\tdpp set\n\tdpp setp\n\tset.each{|i|\n\t\tif(! setp[i].nil?)\n\t\t\tsum += 1\n\t\tend\n\t}\n}\ndputs \"appeared sum is #{sum}\"\ns.each_with_index{|si,i|\n\tif(si.nil? && P[i] == i)\n\t\tsum += 1\n\t\tdputs \"hit\"\n\tend\n}\n\nputs sum\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": 1918, "cpu_time_ms": 2108, "memory_kb": 14612}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s606145842", "group_id": "codeNet:p03359", "input_text": "a, b = gets.strip.split.map(&:to_i)\n\nif a <= b\n puts a \nelse\n puts a - 1\nend\n", "language": "Ruby", "metadata": {"date": 1541481707, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s606145842.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s606145842", "user_id": "u124214522"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "a, b = gets.strip.split.map(&:to_i)\n\nif a <= b\n puts a \nelse\n puts a - 1\nend\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": 79, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s721332473", "group_id": "codeNet:p03359", "input_text": "a,b = gets.split.map(&:to_i)\nif b >= a\n puts a\nelse\n puts a - 1\nend", "language": "Ruby", "metadata": {"date": 1538249773, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s721332473.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s721332473", "user_id": "u990788654"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "a,b = gets.split.map(&:to_i)\nif b >= a\n puts a\nelse\n puts a - 1\nend", "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": 73, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s494752684", "group_id": "codeNet:p03360", "input_text": "a, b, c = gets.split.map(&:to_i)\nk = gets.chomp.to_i\nm = [a, b, c].max\nr = [a, b, c] - [m]\nputs m * 2 ** k + r.first + r.last\n", "language": "Ruby", "metadata": {"date": 1551832498, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s494752684.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s494752684", "user_id": "u434509016"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "a, b, c = gets.split.map(&:to_i)\nk = gets.chomp.to_i\nm = [a, b, c].max\nr = [a, b, c] - [m]\nputs m * 2 ** k + r.first + r.last\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": 126, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s491942971", "group_id": "codeNet:p03360", "input_text": "m = gets.split.map(&:to_i)\nk = gets.to_i\nputs m.sum + (2*k-1)*m.max\n", "language": "Ruby", "metadata": {"date": 1525573999, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s491942971.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s491942971", "user_id": "u030898887"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "m = gets.split.map(&:to_i)\nk = gets.to_i\nputs m.sum + (2*k-1)*m.max\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": 69, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s013953781", "group_id": "codeNet:p03360", "input_text": "array = gets.chop.split.map(&:to_i)\nk = gets.chop.to_i\nsum = 0\nm = array.sort.max\n(0..k).each do | i |\n m *= 2\nend\narray[0] = m\narray.each do |n|\n sum += n\nend\nputs sum\n", "language": "Ruby", "metadata": {"date": 1525570526, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s013953781.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s013953781", "user_id": "u038027079"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "array = gets.chop.split.map(&:to_i)\nk = gets.chop.to_i\nsum = 0\nm = array.sort.max\n(0..k).each do | i |\n m *= 2\nend\narray[0] = m\narray.each do |n|\n sum += n\nend\nputs sum\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThere are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:\n\nChoose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.\n\nWhat is the largest possible sum of the integers written on the blackboard after K operations?\n\nConstraints\n\nA, B and C are integers between 1 and 50 (inclusive).\n\nK is an integer between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nPrint the largest possible sum of the integers written on the blackboard after K operations by E869220.\n\nSample Input 1\n\n5 3 11\n1\n\nSample Output 1\n\n30\n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120 can perform the operation once.\n\nThere are three choices:\n\nDouble 5: The integers written on the board after the operation are 10, 3, 11.\n\nDouble 3: The integers written on the board after the operation are 5, 6, 11.\n\nDouble 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5 + 3 + 22 = 30, which is the largest among 1. through 3.\n\nSample Input 2\n\n3 3 4\n2\n\nSample Output 2\n\n22\n\nE869120 can perform the operation twice. The sum of the integers eventually written on the blackboard is maximized as follows:\n\nFirst, double 4. The integers written on the board are now 3, 3, 8.\n\nNext, double 8. The integers written on the board are now 3, 3, 16.\n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 + 16 = 22.", "sample_input": "5 3 11\n1\n"}, "reference_outputs": ["30\n"], "source_document_id": "p03360", "source_text": "Score: 200 points\n\nProblem Statement\n\nThere are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:\n\nChoose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.\n\nWhat is the largest possible sum of the integers written on the blackboard after K operations?\n\nConstraints\n\nA, B and C are integers between 1 and 50 (inclusive).\n\nK is an integer between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nPrint the largest possible sum of the integers written on the blackboard after K operations by E869220.\n\nSample Input 1\n\n5 3 11\n1\n\nSample Output 1\n\n30\n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120 can perform the operation once.\n\nThere are three choices:\n\nDouble 5: The integers written on the board after the operation are 10, 3, 11.\n\nDouble 3: The integers written on the board after the operation are 5, 6, 11.\n\nDouble 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5 + 3 + 22 = 30, which is the largest among 1. through 3.\n\nSample Input 2\n\n3 3 4\n2\n\nSample Output 2\n\n22\n\nE869120 can perform the operation twice. The sum of the integers eventually written on the blackboard is maximized as follows:\n\nFirst, double 4. The integers written on the board are now 3, 3, 8.\n\nNext, double 8. The integers written on the board are now 3, 3, 16.\n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 + 16 = 22.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 171, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s138899287", "group_id": "codeNet:p03361", "input_text": "h,w = gets.strip.split.map(&:to_i)\ndata = []\nay = Array.new(w+2,\".\")\ndata << ay.join(\"\").to_s\nh.times do\n ax = gets.strip.to_s\n data << \".\"+ax+\".\"\nend\ndata << ay.join(\"\").to_s\n\noutcount = 0\n#とにかく離れ小島が一個でもあればダメ\nfor i in 1..h\n for j in 1..w\n if data[i][j]==\"#\"\n if data[i-1][j]==\".\" && data[i+1][j]==\".\" && data[i][j-1]==\".\" && data[i][j+1]==\".\"\n outcount += 1\n end\n end\n end\nend\nif outcount != 0\n puts \"No\"\nelse\n puts \"Yes\"\nend", "language": "Ruby", "metadata": {"date": 1599788394, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p03361.html", "problem_id": "p03361", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03361/input.txt", "sample_output_relpath": "derived/input_output/data/p03361/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03361/Ruby/s138899287.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s138899287", "user_id": "u313103408"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "h,w = gets.strip.split.map(&:to_i)\ndata = []\nay = Array.new(w+2,\".\")\ndata << ay.join(\"\").to_s\nh.times do\n ax = gets.strip.to_s\n data << \".\"+ax+\".\"\nend\ndata << ay.join(\"\").to_s\n\noutcount = 0\n#とにかく離れ小島が一個でもあればダメ\nfor i in 1..h\n for j in 1..w\n if data[i][j]==\"#\"\n if data[i-1][j]==\".\" && data[i+1][j]==\".\" && data[i][j-1]==\".\" && data[i][j+1]==\".\"\n outcount += 1\n end\n end\n end\nend\nif outcount != 0\n puts \"No\"\nelse\n puts \"Yes\"\nend", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j).\n\nInitially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= #, and to make Square (i, j) white when s_{i, j}= ..\n\nHowever, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black.\n\nDetermine if square1001 can achieve his objective.\n\nConstraints\n\nH is an integer between 1 and 50 (inclusive).\n\nW is an integer between 1 and 50 (inclusive).\n\nFor every (i, j) (1 \\leq i \\leq H, 1 \\leq j \\leq W), s_{i, j} is # or ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1} s_{1, 2} s_{1, 3} ... s_{1, W}\ns_{2, 1} s_{2, 2} s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1} s_{H, 2} s_{H, 3} ... s_{H, W}\n\nOutput\n\nIf square1001 can achieve his objective, print Yes; if he cannot, print No.\n\nSample Input 1\n\n3 3\n.#.\n###\n.#.\n\nSample Output 1\n\nYes\n\nOne possible way to achieve the objective is shown in the figure below. Here, the squares being painted are marked by stars.\n\nSample Input 2\n\n5 5\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n\nSample Output 2\n\nNo\n\nsquare1001 cannot achieve his objective here.\n\nSample Input 3\n\n11 11\n...#####...\n.##.....##.\n#..##.##..#\n#..##.##..#\n#.........#\n#...###...#\n.#########.\n.#.#.#.#.#.\n##.#.#.#.##\n..##.#.##..\n.##..#..##.\n\nSample Output 3\n\nYes", "sample_input": "3 3\n.#.\n###\n.#.\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03361", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j).\n\nInitially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= #, and to make Square (i, j) white when s_{i, j}= ..\n\nHowever, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black.\n\nDetermine if square1001 can achieve his objective.\n\nConstraints\n\nH is an integer between 1 and 50 (inclusive).\n\nW is an integer between 1 and 50 (inclusive).\n\nFor every (i, j) (1 \\leq i \\leq H, 1 \\leq j \\leq W), s_{i, j} is # or ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1} s_{1, 2} s_{1, 3} ... s_{1, W}\ns_{2, 1} s_{2, 2} s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1} s_{H, 2} s_{H, 3} ... s_{H, W}\n\nOutput\n\nIf square1001 can achieve his objective, print Yes; if he cannot, print No.\n\nSample Input 1\n\n3 3\n.#.\n###\n.#.\n\nSample Output 1\n\nYes\n\nOne possible way to achieve the objective is shown in the figure below. Here, the squares being painted are marked by stars.\n\nSample Input 2\n\n5 5\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n\nSample Output 2\n\nNo\n\nsquare1001 cannot achieve his objective here.\n\nSample Input 3\n\n11 11\n...#####...\n.##.....##.\n#..##.##..#\n#..##.##..#\n#.........#\n#...###...#\n.#########.\n.#.#.#.#.#.\n##.#.#.#.##\n..##.#.##..\n.##..#..##.\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 491, "cpu_time_ms": 70, "memory_kb": 14204}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s418465631", "group_id": "codeNet:p03361", "input_text": "h, w = gets.split.map(&:to_i)\n\nmaze = []\nh.times do\n maze << gets.chomp\nend\nans = 'No'\n(0..h-1).each do |j|\n (0..w-1).each do |i|\n if maze[j][i] == \"#\"\n if j-1 >=0 && maze[j-1][i] == \"#\" ||\n j+1 < h && maze[j+1][i] == \"#\" ||\n i-1 >=0 && maze[j][i-1] == \"#\" ||\n i+1 < w && maze[j][i+1] == \"#\"\n ans = 'Yes'\n else\n ans = 'No'\n end\n end\n end\nend\nputs ans", "language": "Ruby", "metadata": {"date": 1553596648, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03361.html", "problem_id": "p03361", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03361/input.txt", "sample_output_relpath": "derived/input_output/data/p03361/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03361/Ruby/s418465631.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s418465631", "user_id": "u729246375"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "h, w = gets.split.map(&:to_i)\n\nmaze = []\nh.times do\n maze << gets.chomp\nend\nans = 'No'\n(0..h-1).each do |j|\n (0..w-1).each do |i|\n if maze[j][i] == \"#\"\n if j-1 >=0 && maze[j-1][i] == \"#\" ||\n j+1 < h && maze[j+1][i] == \"#\" ||\n i-1 >=0 && maze[j][i-1] == \"#\" ||\n i+1 < w && maze[j][i+1] == \"#\"\n ans = 'Yes'\n else\n ans = 'No'\n end\n end\n end\nend\nputs ans", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j).\n\nInitially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= #, and to make Square (i, j) white when s_{i, j}= ..\n\nHowever, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black.\n\nDetermine if square1001 can achieve his objective.\n\nConstraints\n\nH is an integer between 1 and 50 (inclusive).\n\nW is an integer between 1 and 50 (inclusive).\n\nFor every (i, j) (1 \\leq i \\leq H, 1 \\leq j \\leq W), s_{i, j} is # or ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1} s_{1, 2} s_{1, 3} ... s_{1, W}\ns_{2, 1} s_{2, 2} s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1} s_{H, 2} s_{H, 3} ... s_{H, W}\n\nOutput\n\nIf square1001 can achieve his objective, print Yes; if he cannot, print No.\n\nSample Input 1\n\n3 3\n.#.\n###\n.#.\n\nSample Output 1\n\nYes\n\nOne possible way to achieve the objective is shown in the figure below. Here, the squares being painted are marked by stars.\n\nSample Input 2\n\n5 5\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n\nSample Output 2\n\nNo\n\nsquare1001 cannot achieve his objective here.\n\nSample Input 3\n\n11 11\n...#####...\n.##.....##.\n#..##.##..#\n#..##.##..#\n#.........#\n#...###...#\n.#########.\n.#.#.#.#.#.\n##.#.#.#.##\n..##.#.##..\n.##..#..##.\n\nSample Output 3\n\nYes", "sample_input": "3 3\n.#.\n###\n.#.\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03361", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j).\n\nInitially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= #, and to make Square (i, j) white when s_{i, j}= ..\n\nHowever, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black.\n\nDetermine if square1001 can achieve his objective.\n\nConstraints\n\nH is an integer between 1 and 50 (inclusive).\n\nW is an integer between 1 and 50 (inclusive).\n\nFor every (i, j) (1 \\leq i \\leq H, 1 \\leq j \\leq W), s_{i, j} is # or ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1} s_{1, 2} s_{1, 3} ... s_{1, W}\ns_{2, 1} s_{2, 2} s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1} s_{H, 2} s_{H, 3} ... s_{H, W}\n\nOutput\n\nIf square1001 can achieve his objective, print Yes; if he cannot, print No.\n\nSample Input 1\n\n3 3\n.#.\n###\n.#.\n\nSample Output 1\n\nYes\n\nOne possible way to achieve the objective is shown in the figure below. Here, the squares being painted are marked by stars.\n\nSample Input 2\n\n5 5\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n\nSample Output 2\n\nNo\n\nsquare1001 cannot achieve his objective here.\n\nSample Input 3\n\n11 11\n...#####...\n.##.....##.\n#..##.##..#\n#..##.##..#\n#.........#\n#...###...#\n.#########.\n.#.#.#.#.#.\n##.#.#.#.##\n..##.#.##..\n.##..#..##.\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 409, "cpu_time_ms": 9, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s016270310", "group_id": "codeNet:p03361", "input_text": "h, w = gets.split.map(&:to_i)\nc = []\nh.times{|i| c << gets.split('') }\n\nh.times do |x|\n w.times do |y|\n next if c[x][y] != '#'\n next if x > 1 && c[x-1][y] == '#'\n next if x < h - 1 && c[x+1][y] == '#'\n next if y > 1 && c[x][y-1] == '#'\n next if y < w - 1 && c[x][y+1] == '#'\n\n puts \"No\"\n exit\n end\nend\n\nputs 'Yes'\n", "language": "Ruby", "metadata": {"date": 1526087779, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03361.html", "problem_id": "p03361", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03361/input.txt", "sample_output_relpath": "derived/input_output/data/p03361/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03361/Ruby/s016270310.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s016270310", "user_id": "u160889457"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "h, w = gets.split.map(&:to_i)\nc = []\nh.times{|i| c << gets.split('') }\n\nh.times do |x|\n w.times do |y|\n next if c[x][y] != '#'\n next if x > 1 && c[x-1][y] == '#'\n next if x < h - 1 && c[x+1][y] == '#'\n next if y > 1 && c[x][y-1] == '#'\n next if y < w - 1 && c[x][y+1] == '#'\n\n puts \"No\"\n exit\n end\nend\n\nputs 'Yes'\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j).\n\nInitially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= #, and to make Square (i, j) white when s_{i, j}= ..\n\nHowever, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black.\n\nDetermine if square1001 can achieve his objective.\n\nConstraints\n\nH is an integer between 1 and 50 (inclusive).\n\nW is an integer between 1 and 50 (inclusive).\n\nFor every (i, j) (1 \\leq i \\leq H, 1 \\leq j \\leq W), s_{i, j} is # or ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1} s_{1, 2} s_{1, 3} ... s_{1, W}\ns_{2, 1} s_{2, 2} s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1} s_{H, 2} s_{H, 3} ... s_{H, W}\n\nOutput\n\nIf square1001 can achieve his objective, print Yes; if he cannot, print No.\n\nSample Input 1\n\n3 3\n.#.\n###\n.#.\n\nSample Output 1\n\nYes\n\nOne possible way to achieve the objective is shown in the figure below. Here, the squares being painted are marked by stars.\n\nSample Input 2\n\n5 5\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n\nSample Output 2\n\nNo\n\nsquare1001 cannot achieve his objective here.\n\nSample Input 3\n\n11 11\n...#####...\n.##.....##.\n#..##.##..#\n#..##.##..#\n#.........#\n#...###...#\n.#########.\n.#.#.#.#.#.\n##.#.#.#.##\n..##.#.##..\n.##..#..##.\n\nSample Output 3\n\nYes", "sample_input": "3 3\n.#.\n###\n.#.\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03361", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j).\n\nInitially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= #, and to make Square (i, j) white when s_{i, j}= ..\n\nHowever, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black.\n\nDetermine if square1001 can achieve his objective.\n\nConstraints\n\nH is an integer between 1 and 50 (inclusive).\n\nW is an integer between 1 and 50 (inclusive).\n\nFor every (i, j) (1 \\leq i \\leq H, 1 \\leq j \\leq W), s_{i, j} is # or ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1} s_{1, 2} s_{1, 3} ... s_{1, W}\ns_{2, 1} s_{2, 2} s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1} s_{H, 2} s_{H, 3} ... s_{H, W}\n\nOutput\n\nIf square1001 can achieve his objective, print Yes; if he cannot, print No.\n\nSample Input 1\n\n3 3\n.#.\n###\n.#.\n\nSample Output 1\n\nYes\n\nOne possible way to achieve the objective is shown in the figure below. Here, the squares being painted are marked by stars.\n\nSample Input 2\n\n5 5\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n\nSample Output 2\n\nNo\n\nsquare1001 cannot achieve his objective here.\n\nSample Input 3\n\n11 11\n...#####...\n.##.....##.\n#..##.##..#\n#..##.##..#\n#.........#\n#...###...#\n.#########.\n.#.#.#.#.#.\n##.#.#.#.##\n..##.#.##..\n.##..#..##.\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 345, "cpu_time_ms": 10, "memory_kb": 2044}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s371914475", "group_id": "codeNet:p03362", "input_text": "# util functions\nclass UnionFind\n def initialize(n) # n: number of elements in the forest\n @par = []\n @rank = []\n @vs = []\n n.times do |i|\n @par[i] = i\n @rank[i] = 0\n @vs[i] = 1\n end\n end\n attr_accessor :par, :rank, :vs\n\n def find(x)\n raise \"x = #{x} is out of range 0..#{@par.size - 1}\" unless @par[x]\n if @par[x] == x\n return x\n else\n return find( @par[x] )\n end\n end\n\n def unite( x, y )\n xrt = find(x)\n yrt = find(y)\n return if xrt == yrt\n\n if @rank[xrt] > @rank[yrt]\n @par[yrt] = xrt\n @vs[xrt] += @vs[yrt]\n else\n @par[xrt] = yrt\n @vs[yrt] += @vs[xrt]\n @rank[yrt] += 1 if @rank[xrt] == @rank[yrt]\n end\n end\n\n def same( x, y ) # returns true/false\n return find( x ) == find( y )\n end\n\nend # UnionFind\n\n# debug\n$debugFlag = ( ARGV[0] != nil )\np \"==== DEBUG MODE ====\" if $debugFlag\n\ndef pd(str)\n p str if $debugFlag\nend\n\ndef printd(str)\n print str if $debugFlag\nend\n\n# input\ninputs = []\nlc = 0\nwhile l = $stdin.gets do\n if false\n inputs << l.chomp.split(\" \").map(&:to_s)\n else\n inputs << l.chomp.split(\" \").map(&:to_i)\n end\n lc += 1\nend\n\n# input check\nif $debugFlag\n p \"--- INPUT (begin) ---\"\n inputs.each do |l_i|\n p l_i\n end\n p \"--- INPUT (end) ---\"\n print \"\\n\"\nend\n\nnn = inputs[0][0]\n$lst = inputs[1]\n\n# body\nif $debugFlag\nend\n\nnn = inputs[0][0]\n\narr = [11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381]\n\nfor i in 0..nn-1\n print \"#{arr[i]} \"\nend\nprint \"\\n\"\n", "language": "Ruby", "metadata": {"date": 1567552755, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s371914475.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s371914475", "user_id": "u714724786"}, "prompt_components": {"gold_output": "3 5 7 11 31\n", "input_to_evaluate": "# util functions\nclass UnionFind\n def initialize(n) # n: number of elements in the forest\n @par = []\n @rank = []\n @vs = []\n n.times do |i|\n @par[i] = i\n @rank[i] = 0\n @vs[i] = 1\n end\n end\n attr_accessor :par, :rank, :vs\n\n def find(x)\n raise \"x = #{x} is out of range 0..#{@par.size - 1}\" unless @par[x]\n if @par[x] == x\n return x\n else\n return find( @par[x] )\n end\n end\n\n def unite( x, y )\n xrt = find(x)\n yrt = find(y)\n return if xrt == yrt\n\n if @rank[xrt] > @rank[yrt]\n @par[yrt] = xrt\n @vs[xrt] += @vs[yrt]\n else\n @par[xrt] = yrt\n @vs[yrt] += @vs[xrt]\n @rank[yrt] += 1 if @rank[xrt] == @rank[yrt]\n end\n end\n\n def same( x, y ) # returns true/false\n return find( x ) == find( y )\n end\n\nend # UnionFind\n\n# debug\n$debugFlag = ( ARGV[0] != nil )\np \"==== DEBUG MODE ====\" if $debugFlag\n\ndef pd(str)\n p str if $debugFlag\nend\n\ndef printd(str)\n print str if $debugFlag\nend\n\n# input\ninputs = []\nlc = 0\nwhile l = $stdin.gets do\n if false\n inputs << l.chomp.split(\" \").map(&:to_s)\n else\n inputs << l.chomp.split(\" \").map(&:to_i)\n end\n lc += 1\nend\n\n# input check\nif $debugFlag\n p \"--- INPUT (begin) ---\"\n inputs.each do |l_i|\n p l_i\n end\n p \"--- INPUT (end) ---\"\n print \"\\n\"\nend\n\nnn = inputs[0][0]\n$lst = inputs[1]\n\n# body\nif $debugFlag\nend\n\nnn = inputs[0][0]\n\narr = [11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381]\n\nfor i in 0..nn-1\n print \"#{arr[i]} \"\nend\nprint \"\\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": 1727, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s963130595", "group_id": "codeNet:p03364", "input_text": "n = gets.to_i\nstrings = []\nn.times { strings << gets.chomp.split(\"\") }\ncount = 0\nn.times do\n symmetry = true\n (0...n).each do |h|\n (0...n).each do |w|\n if strings[h][w] != strings[w][h]\n symmetry = false\n break\n end\n end\n end\n count += 1 if symmetry\n strings.each { |string| string.rotate! }\nend\nputs count * n\n", "language": "Ruby", "metadata": {"date": 1589229235, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03364.html", "problem_id": "p03364", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03364/input.txt", "sample_output_relpath": "derived/input_output/data/p03364/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03364/Ruby/s963130595.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s963130595", "user_id": "u653737129"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n = gets.to_i\nstrings = []\nn.times { strings << gets.chomp.split(\"\") }\ncount = 0\nn.times do\n symmetry = true\n (0...n).each do |h|\n (0...n).each do |w|\n if strings[h][w] != strings[w][h]\n symmetry = false\n break\n end\n end\n end\n count += 1 if symmetry\n strings.each { |string| string.rotate! }\nend\nputs count * n\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nSnuke has two boards, each divided into a grid with N rows and N columns.\nFor both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j).\n\nThere is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet.\n\nSnuke will write letters on the second board, as follows:\n\nFirst, choose two integers A and B ( 0 \\leq A, B < N ).\n\nWrite one letter in each square on the second board.\nSpecifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board.\nHere, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column.\n\nAfter this operation, the second board is called a good board when, for every i and j ( 1 \\leq i, j \\leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal.\n\nFind the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nS_{i,j} ( 1 \\leq i, j \\leq N ) is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_{1,1}S_{1,2}..S_{1,N}\nS_{2,1}S_{2,2}..S_{2,N}\n:\nS_{N,1}S_{N,2}..S_{N,N}\n\nOutput\n\nPrint the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nSample Input 1\n\n2\nab\nca\n\nSample Output 1\n\n2\n\nFor each pair of A and B, the second board will look as shown below:\n\nThe second board is a good board when (A,B) = (0,1) or (A,B) = (1,0), thus the answer is 2.\n\nSample Input 2\n\n4\naaaa\naaaa\naaaa\naaaa\n\nSample Output 2\n\n16\n\nEvery possible choice of A and B makes the second board good.\n\nSample Input 3\n\n5\nabcde\nfghij\nklmno\npqrst\nuvwxy\n\nSample Output 3\n\n0\n\nNo possible choice of A and B makes the second board good.", "sample_input": "2\nab\nca\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03364", "source_text": "Score : 500 points\n\nProblem Statement\n\nSnuke has two boards, each divided into a grid with N rows and N columns.\nFor both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j).\n\nThere is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet.\n\nSnuke will write letters on the second board, as follows:\n\nFirst, choose two integers A and B ( 0 \\leq A, B < N ).\n\nWrite one letter in each square on the second board.\nSpecifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board.\nHere, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column.\n\nAfter this operation, the second board is called a good board when, for every i and j ( 1 \\leq i, j \\leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal.\n\nFind the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nS_{i,j} ( 1 \\leq i, j \\leq N ) is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_{1,1}S_{1,2}..S_{1,N}\nS_{2,1}S_{2,2}..S_{2,N}\n:\nS_{N,1}S_{N,2}..S_{N,N}\n\nOutput\n\nPrint the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nSample Input 1\n\n2\nab\nca\n\nSample Output 1\n\n2\n\nFor each pair of A and B, the second board will look as shown below:\n\nThe second board is a good board when (A,B) = (0,1) or (A,B) = (1,0), thus the answer is 2.\n\nSample Input 2\n\n4\naaaa\naaaa\naaaa\naaaa\n\nSample Output 2\n\n16\n\nEvery possible choice of A and B makes the second board good.\n\nSample Input 3\n\n5\nabcde\nfghij\nklmno\npqrst\nuvwxy\n\nSample Output 3\n\n0\n\nNo possible choice of A and B makes the second board good.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2108, "memory_kb": 11516}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s495072098", "group_id": "codeNet:p03369", "input_text": "s = gets.count(\"x\")\nputs 700 + s * 100", "language": "Ruby", "metadata": {"date": 1565885893, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03369.html", "problem_id": "p03369", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03369/input.txt", "sample_output_relpath": "derived/input_output/data/p03369/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03369/Ruby/s495072098.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s495072098", "user_id": "u139321836"}, "prompt_components": {"gold_output": "900\n", "input_to_evaluate": "s = gets.count(\"x\")\nputs 700 + s * 100", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn \"Takahashi-ya\", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions).\n\nA customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is o, it means the ramen should be topped with boiled egg; if that character is x, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen.\n\nWrite a program that, when S is given, prints the price of the corresponding bowl of ramen.\n\nConstraints\n\nS is a string of length 3.\n\nEach character in S is o or x.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the price of the bowl of ramen corresponding to S.\n\nSample Input 1\n\noxo\n\nSample Output 1\n\n900\n\nThe price of a ramen topped with two kinds of toppings, boiled egg and green onions, is 700 + 100 \\times 2 = 900 yen.\n\nSample Input 2\n\nooo\n\nSample Output 2\n\n1000\n\nThe price of a ramen topped with all three kinds of toppings is 700 + 100 \\times 3 = 1000 yen.\n\nSample Input 3\n\nxxx\n\nSample Output 3\n\n700\n\nThe price of a ramen without any toppings is 700 yen.", "sample_input": "oxo\n"}, "reference_outputs": ["900\n"], "source_document_id": "p03369", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn \"Takahashi-ya\", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions).\n\nA customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is o, it means the ramen should be topped with boiled egg; if that character is x, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen.\n\nWrite a program that, when S is given, prints the price of the corresponding bowl of ramen.\n\nConstraints\n\nS is a string of length 3.\n\nEach character in S is o or x.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the price of the bowl of ramen corresponding to S.\n\nSample Input 1\n\noxo\n\nSample Output 1\n\n900\n\nThe price of a ramen topped with two kinds of toppings, boiled egg and green onions, is 700 + 100 \\times 2 = 900 yen.\n\nSample Input 2\n\nooo\n\nSample Output 2\n\n1000\n\nThe price of a ramen topped with all three kinds of toppings is 700 + 100 \\times 3 = 1000 yen.\n\nSample Input 3\n\nxxx\n\nSample Output 3\n\n700\n\nThe price of a ramen without any toppings is 700 yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 38, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s052223803", "group_id": "codeNet:p03371", "input_text": "# frozen_string_literal: true\n\n# Generated by AtcoderGreedy on 2018-04-22\n# ABC095 C\n# Your code here\n\n$A, $B, $C, $X, $Y = gets.chomp.split(' ').map(&:to_i)\n\ndef min(a, b)\n a < b ? a : b\nend\n\ndef min_3(a, b, c)\n min(min(a, b), c)\nend\n\nres = if $X < $Y\n min_3($Y * 2 * $C, $A * $X + $B * $Y, $X * 2 * $C + ($Y - $X) * $B)\n else\n min_3($X * 2 * $C, $A * $X + $B * $Y, $Y * 2 * $C + ($X - $Y) * $A)\n end\n\nputs res\n", "language": "Ruby", "metadata": {"date": 1524425874, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03371.html", "problem_id": "p03371", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03371/input.txt", "sample_output_relpath": "derived/input_output/data/p03371/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03371/Ruby/s052223803.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s052223803", "user_id": "u833003302"}, "prompt_components": {"gold_output": "7900\n", "input_to_evaluate": "# frozen_string_literal: true\n\n# Generated by AtcoderGreedy on 2018-04-22\n# ABC095 C\n# Your code here\n\n$A, $B, $C, $X, $Y = gets.chomp.split(' ').map(&:to_i)\n\ndef min(a, b)\n a < b ? a : b\nend\n\ndef min_3(a, b, c)\n min(min(a, b), c)\nend\n\nres = if $X < $Y\n min_3($Y * 2 * $C, $A * $X + $B * $Y, $X * 2 * $C + ($Y - $X) * $B)\n else\n min_3($X * 2 * $C, $A * $X + $B * $Y, $Y * 2 * $C + ($X - $Y) * $A)\n end\n\nputs res\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.\n\nNakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.\n\nConstraints\n\n1 ≤ A, B, C ≤ 5000\n\n1 ≤ X, Y ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C X Y\n\nOutput\n\nPrint the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.\n\nSample Input 1\n\n1500 2000 1600 3 2\n\nSample Output 1\n\n7900\n\nIt is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.\n\nSample Input 2\n\n1500 2000 1900 3 2\n\nSample Output 2\n\n8500\n\nIt is optimal to directly buy three A-pizzas and two B-pizzas.\n\nSample Input 3\n\n1500 2000 500 90000 100000\n\nSample Output 3\n\n100000000\n\nIt is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.", "sample_input": "1500 2000 1600 3 2\n"}, "reference_outputs": ["7900\n"], "source_document_id": "p03371", "source_text": "Score : 300 points\n\nProblem Statement\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.\n\nNakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.\n\nConstraints\n\n1 ≤ A, B, C ≤ 5000\n\n1 ≤ X, Y ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C X Y\n\nOutput\n\nPrint the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.\n\nSample Input 1\n\n1500 2000 1600 3 2\n\nSample Output 1\n\n7900\n\nIt is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.\n\nSample Input 2\n\n1500 2000 1900 3 2\n\nSample Output 2\n\n8500\n\nIt is optimal to directly buy three A-pizzas and two B-pizzas.\n\nSample Input 3\n\n1500 2000 500 90000 100000\n\nSample Output 3\n\n100000000\n\nIt is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 438, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s453644454", "group_id": "codeNet:p03377", "input_text": "a, b ,x = gets.chomp.split(\" \").map(&:to_i)\nif a + b >= x && b <= x\n puts \"YES\"\nelse\n puts \"NO\"\nend", "language": "Ruby", "metadata": {"date": 1597051209, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s453644454.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s453644454", "user_id": "u412789323"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "a, b ,x = gets.chomp.split(\" \").map(&:to_i)\nif a + b >= x && b <= x\n puts \"YES\"\nelse\n puts \"NO\"\nend", "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": 105, "cpu_time_ms": 64, "memory_kb": 14252}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s781876658", "group_id": "codeNet:p03377", "input_text": "\na,b,c = gets.split.map(&:to_i)\nif a + b > c && a <= c\n puts \"Yes\"\nelse\n puts \"No\"\nend\n", "language": "Ruby", "metadata": {"date": 1538248857, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s781876658.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s781876658", "user_id": "u990788654"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "\na,b,c = gets.split.map(&:to_i)\nif a + b > c && a <= c\n puts \"Yes\"\nelse\n puts \"No\"\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are a total of A + B cats and dogs.\nAmong them, A are known to be cats, but the remaining B are not known to be either cats or dogs.\n\nDetermine if it is possible that there are exactly X cats among these A + B animals.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\n1 \\leq X \\leq 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B X\n\nOutput\n\nIf it is possible that there are exactly X cats, print YES; if it is impossible, print NO.\n\nSample Input 1\n\n3 5 4\n\nSample Output 1\n\nYES\n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4 cats in total.\n\nSample Input 2\n\n2 2 6\n\nSample Output 2\n\nNO\n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in total.\n\nSample Input 3\n\n5 3 2\n\nSample Output 3\n\nNO\n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in total.", "sample_input": "3 5 4\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03377", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are a total of A + B cats and dogs.\nAmong them, A are known to be cats, but the remaining B are not known to be either cats or dogs.\n\nDetermine if it is possible that there are exactly X cats among these A + B animals.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\n1 \\leq X \\leq 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B X\n\nOutput\n\nIf it is possible that there are exactly X cats, print YES; if it is impossible, print NO.\n\nSample Input 1\n\n3 5 4\n\nSample Output 1\n\nYES\n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4 cats in total.\n\nSample Input 2\n\n2 2 6\n\nSample Output 2\n\nNO\n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in total.\n\nSample Input 3\n\n5 3 2\n\nSample Output 3\n\nNO\n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in total.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 93, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s568287364", "group_id": "codeNet:p03378", "input_text": "N, M, X = gets.split.map(&:to_i)\nA = gets.split.map(&:to_i)\n\ns = t = 0\nA.each{ |a| a < X ? s += 1 : t += 1 }\n\nputs [s, t].min\n", "language": "Ruby", "metadata": {"date": 1526728419, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s568287364.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s568287364", "user_id": "u693378622"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N, M, X = gets.split.map(&:to_i)\nA = gets.split.map(&:to_i)\n\ns = t = 0\nA.each{ |a| a < X ? s += 1 : t += 1 }\n\nputs [s, t].min\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": 126, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s148672815", "group_id": "codeNet:p03378", "input_text": "n, m, x = gets.chomp.split(\" \").map(&:to_i)\na = gets.chomp.split(\" \").map(&:to_i)\n\nleft = 0\nright = 0\n\na.each do |i|\n if i < x\n left+=1\n else\n right+=1\n end\nend\n\nif left < right\n puts left\nelse\n puts right\nend\n", "language": "Ruby", "metadata": {"date": 1523758034, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s148672815.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s148672815", "user_id": "u957810040"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n, m, x = gets.chomp.split(\" \").map(&:to_i)\na = gets.chomp.split(\" \").map(&:to_i)\n\nleft = 0\nright = 0\n\na.each do |i|\n if i < x\n left+=1\n else\n right+=1\n end\nend\n\nif left < right\n puts left\nelse\n puts right\nend\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": 221, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s803961996", "group_id": "codeNet:p03379", "input_text": "n = gets.chomp.split(\" \").map(&:to_i)\nx = gets.chomp.split(\" \").map(&:to_i)\n\nx.length.times do |c|\n selected = x.each_with_index.select{|v,i|i!=c}\n selected.map! do |v|\n v[0]\n end\n selected.sort!\n puts selected[(n[0]+1)/2-1]\nend\n", "language": "Ruby", "metadata": {"date": 1523759825, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03379.html", "problem_id": "p03379", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03379/input.txt", "sample_output_relpath": "derived/input_output/data/p03379/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03379/Ruby/s803961996.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s803961996", "user_id": "u957810040"}, "prompt_components": {"gold_output": "4\n3\n3\n4\n", "input_to_evaluate": "n = gets.chomp.split(\" \").map(&:to_i)\nx = gets.chomp.split(\" \").map(&:to_i)\n\nx.length.times do |c|\n selected = x.each_with_index.select{|v,i|i!=c}\n selected.map! do |v|\n v[0]\n end\n selected.sort!\n puts selected[(n[0]+1)/2-1]\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWhen l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number.\nFor each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.\n\nFind B_i for each i = 1, 2, ..., N.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n1 \\leq X_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint N lines.\nThe i-th line should contain B_i.\n\nSample Input 1\n\n4\n2 4 4 3\n\nSample Output 1\n\n4\n3\n3\n4\n\nSince the median of X_2, X_3, X_4 is 4, B_1 = 4.\n\nSince the median of X_1, X_3, X_4 is 3, B_2 = 3.\n\nSince the median of X_1, X_2, X_4 is 3, B_3 = 3.\n\nSince the median of X_1, X_2, X_3 is 4, B_4 = 4.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n2\n1\n\nSample Input 3\n\n6\n5 5 4 4 3 3\n\nSample Output 3\n\n4\n4\n4\n4\n4\n4", "sample_input": "4\n2 4 4 3\n"}, "reference_outputs": ["4\n3\n3\n4\n"], "source_document_id": "p03379", "source_text": "Score : 300 points\n\nProblem Statement\n\nWhen l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number.\nFor each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.\n\nFind B_i for each i = 1, 2, ..., N.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n1 \\leq X_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint N lines.\nThe i-th line should contain B_i.\n\nSample Input 1\n\n4\n2 4 4 3\n\nSample Output 1\n\n4\n3\n3\n4\n\nSince the median of X_2, X_3, X_4 is 4, B_1 = 4.\n\nSince the median of X_1, X_3, X_4 is 3, B_2 = 3.\n\nSince the median of X_1, X_2, X_4 is 3, B_3 = 3.\n\nSince the median of X_1, X_2, X_3 is 4, B_4 = 4.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n2\n1\n\nSample Input 3\n\n6\n5 5 4 4 3 3\n\nSample Output 3\n\n4\n4\n4\n4\n4\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 237, "cpu_time_ms": 2110, "memory_kb": 38940}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s069264536", "group_id": "codeNet:p03379", "input_text": "N = gets.chomp.to_i\nnums = gets.chomp.split(' ').map(&:to_i)\nsorted = nums.sort\ndeleted = {}\nfor i in 1..N do\n a = sorted.clone\n delete = nums[i - 1]\n if deleted.has_key? delete\n puts deleted[delete]\n break\n end\n a.each_with_index do |val, index|\n if val == delete\n a.delete_at index\n break\n end\n end\n deleted[delete.to_s] = a[(a.count + 1)/2 - 1]\n puts a[(a.count + 1)/2 - 1]\nend\n", "language": "Ruby", "metadata": {"date": 1523757133, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03379.html", "problem_id": "p03379", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03379/input.txt", "sample_output_relpath": "derived/input_output/data/p03379/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03379/Ruby/s069264536.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s069264536", "user_id": "u658389776"}, "prompt_components": {"gold_output": "4\n3\n3\n4\n", "input_to_evaluate": "N = gets.chomp.to_i\nnums = gets.chomp.split(' ').map(&:to_i)\nsorted = nums.sort\ndeleted = {}\nfor i in 1..N do\n a = sorted.clone\n delete = nums[i - 1]\n if deleted.has_key? delete\n puts deleted[delete]\n break\n end\n a.each_with_index do |val, index|\n if val == delete\n a.delete_at index\n break\n end\n end\n deleted[delete.to_s] = a[(a.count + 1)/2 - 1]\n puts a[(a.count + 1)/2 - 1]\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWhen l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number.\nFor each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.\n\nFind B_i for each i = 1, 2, ..., N.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n1 \\leq X_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint N lines.\nThe i-th line should contain B_i.\n\nSample Input 1\n\n4\n2 4 4 3\n\nSample Output 1\n\n4\n3\n3\n4\n\nSince the median of X_2, X_3, X_4 is 4, B_1 = 4.\n\nSince the median of X_1, X_3, X_4 is 3, B_2 = 3.\n\nSince the median of X_1, X_2, X_4 is 3, B_3 = 3.\n\nSince the median of X_1, X_2, X_3 is 4, B_4 = 4.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n2\n1\n\nSample Input 3\n\n6\n5 5 4 4 3 3\n\nSample Output 3\n\n4\n4\n4\n4\n4\n4", "sample_input": "4\n2 4 4 3\n"}, "reference_outputs": ["4\n3\n3\n4\n"], "source_document_id": "p03379", "source_text": "Score : 300 points\n\nProblem Statement\n\nWhen l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number.\nFor each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.\n\nFind B_i for each i = 1, 2, ..., N.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n1 \\leq X_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint N lines.\nThe i-th line should contain B_i.\n\nSample Input 1\n\n4\n2 4 4 3\n\nSample Output 1\n\n4\n3\n3\n4\n\nSince the median of X_2, X_3, X_4 is 4, B_1 = 4.\n\nSince the median of X_1, X_3, X_4 is 3, B_2 = 3.\n\nSince the median of X_1, X_2, X_4 is 3, B_3 = 3.\n\nSince the median of X_1, X_2, X_3 is 4, B_4 = 4.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n2\n1\n\nSample Input 3\n\n6\n5 5 4 4 3 3\n\nSample Output 3\n\n4\n4\n4\n4\n4\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 411, "cpu_time_ms": 2112, "memory_kb": 87696}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s638315580", "group_id": "codeNet:p03380", "input_text": "n = gets.chomp.to_i\na = gets.chomp.split(\" \").map(&:to_i).sort\nif n == 2\n puts a[1].to_s + \" \" + a[0].to_s\n exit\nend\nmid = a.size / 2\nputs [a[-1], a[mid]].join(\" \")", "language": "Ruby", "metadata": {"date": 1585099081, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03380.html", "problem_id": "p03380", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03380/input.txt", "sample_output_relpath": "derived/input_output/data/p03380/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03380/Ruby/s638315580.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s638315580", "user_id": "u466332671"}, "prompt_components": {"gold_output": "11 6\n", "input_to_evaluate": "n = gets.chomp.to_i\na = gets.chomp.split(\" \").map(&:to_i).sort\nif n == 2\n puts a[1].to_s + \" \" + a[0].to_s\n exit\nend\nmid = a.size / 2\nputs [a[-1], a[mid]].join(\" \")", "problem_context": "Score : 400 points\n\nProblem Statement\n\nLet {\\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order.\nFrom n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\\rm comb}(a_i,a_j) is maximized.\nIf there are multiple pairs that maximize the value, any of them is accepted.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\n0 \\leq a_i \\leq 10^9\n\na_1,a_2,...,a_n are pairwise distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint a_i and a_j that you selected, with a space in between.\n\nSample Input 1\n\n5\n6 9 4 2 11\n\nSample Output 1\n\n11 6\n\n\\rm{comb}(a_i,a_j) for each possible selection is as follows:\n\n\\rm{comb}(4,2)=6\n\n\\rm{comb}(6,2)=15\n\n\\rm{comb}(6,4)=15\n\n\\rm{comb}(9,2)=36\n\n\\rm{comb}(9,4)=126\n\n\\rm{comb}(9,6)=84\n\n\\rm{comb}(11,2)=55\n\n\\rm{comb}(11,4)=330\n\n\\rm{comb}(11,6)=462\n\n\\rm{comb}(11,9)=55\n\nThus, we should print 11 and 6.\n\nSample Input 2\n\n2\n100 0\n\nSample Output 2\n\n100 0", "sample_input": "5\n6 9 4 2 11\n"}, "reference_outputs": ["11 6\n"], "source_document_id": "p03380", "source_text": "Score : 400 points\n\nProblem Statement\n\nLet {\\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order.\nFrom n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\\rm comb}(a_i,a_j) is maximized.\nIf there are multiple pairs that maximize the value, any of them is accepted.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\n0 \\leq a_i \\leq 10^9\n\na_1,a_2,...,a_n are pairwise distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint a_i and a_j that you selected, with a space in between.\n\nSample Input 1\n\n5\n6 9 4 2 11\n\nSample Output 1\n\n11 6\n\n\\rm{comb}(a_i,a_j) for each possible selection is as follows:\n\n\\rm{comb}(4,2)=6\n\n\\rm{comb}(6,2)=15\n\n\\rm{comb}(6,4)=15\n\n\\rm{comb}(9,2)=36\n\n\\rm{comb}(9,4)=126\n\n\\rm{comb}(9,6)=84\n\n\\rm{comb}(11,2)=55\n\n\\rm{comb}(11,4)=330\n\n\\rm{comb}(11,6)=462\n\n\\rm{comb}(11,9)=55\n\nThus, we should print 11 and 6.\n\nSample Input 2\n\n2\n100 0\n\nSample Output 2\n\n100 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 170, "cpu_time_ms": 66, "memory_kb": 11008}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s192896918", "group_id": "codeNet:p03386", "input_text": "A,B,K=gets.split.map &:to_i\nputs (K.times.map{|i|A+i} | K.downto(1).map{|i|B-i+1}).select{|i|i>=A&&i<=B}", "language": "Ruby", "metadata": {"date": 1576550238, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s192896918.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s192896918", "user_id": "u630043039"}, "prompt_components": {"gold_output": "3\n4\n7\n8\n", "input_to_evaluate": "A,B,K=gets.split.map &:to_i\nputs (K.times.map{|i|A+i} | K.downto(1).map{|i|B-i+1}).select{|i|i>=A&&i<=B}", "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": 104, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s283804744", "group_id": "codeNet:p03386", "input_text": "a,b,k = gets.split(\" \").map!{|i| i.to_i}\nif a+k-1 < b-k+1\n a.upto(a+k-1) do |j|\n puts j\n end\n (b-k+1).upto(b) do |l|\n puts l\n end\nelse a.upto(b) do |u|\n puts u\n end\nend\n", "language": "Ruby", "metadata": {"date": 1550988356, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s283804744.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s283804744", "user_id": "u974214237"}, "prompt_components": {"gold_output": "3\n4\n7\n8\n", "input_to_evaluate": "a,b,k = gets.split(\" \").map!{|i| i.to_i}\nif a+k-1 < b-k+1\n a.upto(a+k-1) do |j|\n puts j\n end\n (b-k+1).upto(b) do |l|\n puts l\n end\nelse a.upto(b) do |u|\n puts u\n end\nend\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": 183, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s717195897", "group_id": "codeNet:p03393", "input_text": "s = gets.chomp.chars\nhs = Hash.new(false)\nn = s.size\n\nif n < 26\n s.each do |c|\n hs[c] = true\n end\n lb = \"a\"\nelse\n cur = \"a\"\n while !s.empty? && s[-1] >= cur\n hs[s[-1]] = true\n cur = s.pop\n end\n\n if s.empty?\n puts \"-1\"\n exit\n end\n lb = (s.pop.ord + 1).chr\nend\n\n(lb..\"z\").each do |c|\n if hs[c] == (n >= 26)\n puts s.join(\"\") + c\n break\n end\nend", "language": "Ruby", "metadata": {"date": 1597084636, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s717195897.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s717195897", "user_id": "u482840940"}, "prompt_components": {"gold_output": "atcoderb\n", "input_to_evaluate": "s = gets.chomp.chars\nhs = Hash.new(false)\nn = s.size\n\nif n < 26\n s.each do |c|\n hs[c] = true\n end\n lb = \"a\"\nelse\n cur = \"a\"\n while !s.empty? && s[-1] >= cur\n hs[s[-1]] = true\n cur = s.pop\n end\n\n if s.empty?\n puts \"-1\"\n exit\n end\n lb = (s.pop.ord + 1).chr\nend\n\n(lb..\"z\").each do |c|\n if hs[c] == (n >= 26)\n puts s.join(\"\") + c\n break\n end\nend", "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": 373, "cpu_time_ms": 68, "memory_kb": 14348}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s566688728", "group_id": "codeNet:p03394", "input_text": "n = gets.to_i\n\nif n == 3\n puts \"2 5 63\"\nelsif n == 4\n puts \"2 5 20 62\"\nelse\n ans = [2, 4, 6]\n i = 6\n n -= 3\n\n while i + 12 < 30000\n if n > 8\n 6.times {ans << i += 2}\n n -= 6\n else\n if n.odd?\n n -= 1\n ans << i + 6\n end\n break\n end\n end\n\n i = -3\n n.times {ans << i += 6}\n puts ans * \" \"\nend", "language": "Ruby", "metadata": {"date": 1600991986, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p03394.html", "problem_id": "p03394", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03394/input.txt", "sample_output_relpath": "derived/input_output/data/p03394/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03394/Ruby/s566688728.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s566688728", "user_id": "u692254521"}, "prompt_components": {"gold_output": "2 5 63\n", "input_to_evaluate": "n = gets.to_i\n\nif n == 3\n puts \"2 5 63\"\nelsif n == 4\n puts \"2 5 20 62\"\nelse\n ans = [2, 4, 6]\n i = 6\n n -= 3\n\n while i + 12 < 30000\n if n > 8\n 6.times {ans << i += 2}\n n -= 6\n else\n if n.odd?\n n -= 1\n ans << i + 6\n end\n break\n end\n end\n\n i = -3\n n.times {ans << i += 6}\n puts ans * \" \"\nend", "problem_context": "Score : 600 points\n\nProblem Statement\n\nNagase is a top student in high school. One day, she's analyzing some properties of special sets of positive integers.\n\nShe thinks that a set S = \\{a_{1}, a_{2}, ..., a_{N}\\} of distinct positive integers is called special if for all 1 \\leq i \\leq N, the gcd (greatest common divisor) of a_{i} and the sum of the remaining elements of S is not 1.\n\nNagase wants to find a special set of size N. However, this task is too easy, so she decided to ramp up the difficulty. Nagase challenges you to find a special set of size N such that the gcd of all elements are 1 and the elements of the set does not exceed 30000.\n\nConstraints\n\n3 \\leq N \\leq 20000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nOutput N space-separated integers, denoting the elements of the set S. S must satisfy the following conditions :\n\nThe elements must be distinct positive integers not exceeding 30000.\n\nThe gcd of all elements of S is 1, i.e. there does not exist an integer d > 1 that divides all elements of S.\n\nS is a special set.\n\nIf there are multiple solutions, you may output any of them. The elements of S may be printed in any order. It is guaranteed that at least one solution exist under the given contraints.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n2 5 63\n\n\\{2, 5, 63\\} is special because gcd(2, 5 + 63) = 2, gcd(5, 2 + 63) = 5, gcd(63, 2 + 5) = 7. Also, gcd(2, 5, 63) = 1. Thus, this set satisfies all the criteria.\n\nNote that \\{2, 4, 6\\} is not a valid solution because gcd(2, 4, 6) = 2 > 1.\n\nSample Input 2\n\n4\n\nSample Output 2\n\n2 5 20 63\n\n\\{2, 5, 20, 63\\} is special because gcd(2, 5 + 20 + 63) = 2, gcd(5, 2 + 20 + 63) = 5, gcd(20, 2 + 5 + 63) = 10, gcd(63, 2 + 5 + 20) = 9. Also, gcd(2, 5, 20, 63) = 1. Thus, this set satisfies all the criteria.", "sample_input": "3\n"}, "reference_outputs": ["2 5 63\n"], "source_document_id": "p03394", "source_text": "Score : 600 points\n\nProblem Statement\n\nNagase is a top student in high school. One day, she's analyzing some properties of special sets of positive integers.\n\nShe thinks that a set S = \\{a_{1}, a_{2}, ..., a_{N}\\} of distinct positive integers is called special if for all 1 \\leq i \\leq N, the gcd (greatest common divisor) of a_{i} and the sum of the remaining elements of S is not 1.\n\nNagase wants to find a special set of size N. However, this task is too easy, so she decided to ramp up the difficulty. Nagase challenges you to find a special set of size N such that the gcd of all elements are 1 and the elements of the set does not exceed 30000.\n\nConstraints\n\n3 \\leq N \\leq 20000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nOutput N space-separated integers, denoting the elements of the set S. S must satisfy the following conditions :\n\nThe elements must be distinct positive integers not exceeding 30000.\n\nThe gcd of all elements of S is 1, i.e. there does not exist an integer d > 1 that divides all elements of S.\n\nS is a special set.\n\nIf there are multiple solutions, you may output any of them. The elements of S may be printed in any order. It is guaranteed that at least one solution exist under the given contraints.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n2 5 63\n\n\\{2, 5, 63\\} is special because gcd(2, 5 + 63) = 2, gcd(5, 2 + 63) = 5, gcd(63, 2 + 5) = 7. Also, gcd(2, 5, 63) = 1. Thus, this set satisfies all the criteria.\n\nNote that \\{2, 4, 6\\} is not a valid solution because gcd(2, 4, 6) = 2 > 1.\n\nSample Input 2\n\n4\n\nSample Output 2\n\n2 5 20 63\n\n\\{2, 5, 20, 63\\} is special because gcd(2, 5 + 20 + 63) = 2, gcd(5, 2 + 20 + 63) = 5, gcd(20, 2 + 5 + 63) = 10, gcd(63, 2 + 5 + 20) = 9. Also, gcd(2, 5, 20, 63) = 1. Thus, this set satisfies all the criteria.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 68, "memory_kb": 14564}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s406905462", "group_id": "codeNet:p03399", "input_text": "A = gets.to_i\nB = gets.to_i\n\nC = gets.to_i\nD = gets.to_i\n\ntrain_min_price = A < B ? A : B\nbus_min_price = C < D ? C : D\n\nputs train_min_price + bus_min_price", "language": "Ruby", "metadata": {"date": 1522115122, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s406905462.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s406905462", "user_id": "u497542289"}, "prompt_components": {"gold_output": "520\n", "input_to_evaluate": "A = gets.to_i\nB = gets.to_i\n\nC = gets.to_i\nD = gets.to_i\n\ntrain_min_price = A < B ? A : B\nbus_min_price = C < D ? C : D\n\nputs train_min_price + bus_min_price", "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": 157, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s953600712", "group_id": "codeNet:p03400", "input_text": "n = gets.to_i\nd,x = gets.split.map(&:to_i)\nans = x+n\nd -= 1\nn.times do\n a = gets.to_i\n ans += d/a\nend\nputs ans", "language": "Ruby", "metadata": {"date": 1540981719, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s953600712.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s953600712", "user_id": "u506255180"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "n = gets.to_i\nd,x = gets.split.map(&:to_i)\nans = x+n\nd -= 1\nn.times do\n a = gets.to_i\n ans += d/a\nend\nputs ans", "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": 116, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s880604459", "group_id": "codeNet:p03401", "input_text": "N = gets.to_i\nas = gets.split.map(&:to_i)\nmax = (as[0]).abs\n(N-1).times{|i|\n max += (as[i+1]-as[i]).abs\n}\nmax += as[N-1].abs\nas.push(0)\nas.unshift(0)\n1.upto(N){|i|\n if as[i] < 0\n if as[i+1] <= as[i]\n puts max\n else\n puts (max- 2*[(as[i]-as[i-1]).abs, (as[i+1]-as[i]).abs].min)\n end\n else\n if as[i+1] >= as[i]\n puts max\n else\n puts (max- 2*[(as[i]-as[i-1]).abs, (as[i+1]-as[i]).abs].min)\n end\n end\n}", "language": "Ruby", "metadata": {"date": 1530288370, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s880604459.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s880604459", "user_id": "u884847580"}, "prompt_components": {"gold_output": "12\n8\n10\n", "input_to_evaluate": "N = gets.to_i\nas = gets.split.map(&:to_i)\nmax = (as[0]).abs\n(N-1).times{|i|\n max += (as[i+1]-as[i]).abs\n}\nmax += as[N-1].abs\nas.push(0)\nas.unshift(0)\n1.upto(N){|i|\n if as[i] < 0\n if as[i+1] <= as[i]\n puts max\n else\n puts (max- 2*[(as[i]-as[i-1]).abs, (as[i+1]-as[i]).abs].min)\n end\n else\n if as[i+1] >= as[i]\n puts max\n else\n puts (max- 2*[(as[i]-as[i-1]).abs, (as[i+1]-as[i]).abs].min)\n end\n end\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": 440, "cpu_time_ms": 193, "memory_kb": 12044}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s006323918", "group_id": "codeNet:p03401", "input_text": "N = gets.to_i\nA = gets.split(\" \").map { |item| item.to_i }\nA.freeze\n\nres = []\n\nfor i in 0..N-1 do\n if i==0\n ryohi = A[1].abs\n else\n ryohi = A[0].abs\n end\n for j in 0..N-2 do\n if j+1 == i\n if j+2 < N\n ryohi += (A[j+2] - A[j]).abs\n end\n elsif j != i\n ryohi += (A[j+1] - A[j]).abs\n end\n end\n if i == N-1\n ryohi += A[N-2].abs\n else\n ryohi += A[N-1].abs\n end\n res[i] = ryohi\n print \"#{res[i] } \"\nend\n\nprint \"\\n\"\n", "language": "Ruby", "metadata": {"date": 1522029727, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s006323918.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s006323918", "user_id": "u698460655"}, "prompt_components": {"gold_output": "12\n8\n10\n", "input_to_evaluate": "N = gets.to_i\nA = gets.split(\" \").map { |item| item.to_i }\nA.freeze\n\nres = []\n\nfor i in 0..N-1 do\n if i==0\n ryohi = A[1].abs\n else\n ryohi = A[0].abs\n end\n for j in 0..N-2 do\n if j+1 == i\n if j+2 < N\n ryohi += (A[j+2] - A[j]).abs\n end\n elsif j != i\n ryohi += (A[j+1] - A[j]).abs\n end\n end\n if i == N-1\n ryohi += A[N-2].abs\n else\n ryohi += A[N-1].abs\n end\n res[i] = ryohi\n print \"#{res[i] } \"\nend\n\nprint \"\\n\"\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N sightseeing spots on the x-axis, numbered 1, 2, ..., N.\nSpot i is at the point with coordinate A_i.\nIt costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis.\n\nYou planned a trip along the axis.\nIn this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0.\n\nHowever, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i.\nYou will visit the remaining spots as planned in the order they are numbered.\nYou will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned.\n\nFor each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n-5000 \\leq A_i \\leq 5000 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint N lines.\nIn the i-th line, print the total cost of travel during the trip when the visit to Spot i is canceled.\n\nSample Input 1\n\n3\n3 5 -1\n\nSample Output 1\n\n12\n8\n10\n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit to Spot i is canceled, are as follows:\n\nFor i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n\nFor i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n\nFor i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\nSample Input 2\n\n5\n1 1 1 2 0\n\nSample Output 2\n\n4\n4\n4\n2\n4\n\nSample Input 3\n\n6\n-679 -2409 -3258 3095 -3291 -4462\n\nSample Output 3\n\n21630\n21630\n19932\n8924\n21630\n19288", "sample_input": "3\n3 5 -1\n"}, "reference_outputs": ["12\n8\n10\n"], "source_document_id": "p03401", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N sightseeing spots on the x-axis, numbered 1, 2, ..., N.\nSpot i is at the point with coordinate A_i.\nIt costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis.\n\nYou planned a trip along the axis.\nIn this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0.\n\nHowever, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i.\nYou will visit the remaining spots as planned in the order they are numbered.\nYou will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned.\n\nFor each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n-5000 \\leq A_i \\leq 5000 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint N lines.\nIn the i-th line, print the total cost of travel during the trip when the visit to Spot i is canceled.\n\nSample Input 1\n\n3\n3 5 -1\n\nSample Output 1\n\n12\n8\n10\n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit to Spot i is canceled, are as follows:\n\nFor i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n\nFor i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n\nFor i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\nSample Input 2\n\n5\n1 1 1 2 0\n\nSample Output 2\n\n4\n4\n4\n2\n4\n\nSample Input 3\n\n6\n-679 -2409 -3258 3095 -3291 -4462\n\nSample Output 3\n\n21630\n21630\n19932\n8924\n21630\n19288", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2108, "memory_kb": 10124}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s209697288", "group_id": "codeNet:p03407", "input_text": "a,b,c = gets.split.map( &:to_i)\n\nif a+b > c\n\tputs \"Yes\"\nelse\n\tputs \"NO\"\nend", "language": "Ruby", "metadata": {"date": 1522043093, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s209697288.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s209697288", "user_id": "u497542289"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a,b,c = gets.split.map( &:to_i)\n\nif a+b > c\n\tputs \"Yes\"\nelse\n\tputs \"NO\"\nend", "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": 75, "cpu_time_ms": 7, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s511835542", "group_id": "codeNet:p03407", "input_text": "a, b, o = STDIN.read.split(' ').map{|e|Integer(e)}\na + b >= o ? 'Yes' : 'No'\n", "language": "Ruby", "metadata": {"date": 1521338006, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s511835542.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s511835542", "user_id": "u188969045"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a, b, o = STDIN.read.split(' ').map{|e|Integer(e)}\na + b >= o ? 'Yes' : 'No'\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": 77, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s551173094", "group_id": "codeNet:p03408", "input_text": "s=[]\nt=[]\nn=gets.to_i\nn.times{s<s[1]} #y zahyo dekai jun\nb=(1..n).map{gets.split.map &:to_i}.sort{|s,t|s[0]<=>t[0]} #x zahyo tittyai jun\nflg_r=Array.new(n,true)\ncnt=0\n\nb.each{|xb,yb|\n for i in 0...n\n if flg_r[i]&&r[i][0]s[1]} #y zahyo dekai jun\nb=(1..n).map{gets.split.map &:to_i}.sort{|s,t|s[0]<=>t[0]} #x zahyo tittyai jun\nflg_r=Array.new(n,true)\ncnt=0\n\nb.each{|xb,yb|\n for i in 0...n\n if flg_r[i]&&r[i][0]= b のとき\nalb = 0\n(K+1..N).each do |b|\n between = (N-b+1)\n slots = between / b\n rest = between % b\n alb += (b-K) * slots\n alb += rest - K if rest > K\n alb -= 1 if K == 0\nend\n\nputs alb + asb\n", "language": "Ruby", "metadata": {"date": 1522078171, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03420.html", "problem_id": "p03420", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03420/input.txt", "sample_output_relpath": "derived/input_output/data/p03420/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03420/Ruby/s829335153.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s829335153", "user_id": "u421511053"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "N, K = gets.chomp.split(\" \").map(&:to_i)\n\n# a < b のとき\nasb = (K..N-1).map { |a| N - a }.inject(:+)\n\n# a >= b のとき\nalb = 0\n(K+1..N).each do |b|\n between = (N-b+1)\n slots = between / b\n rest = between % b\n alb += (b-K) * slots\n alb += rest - K if rest > K\n alb -= 1 if K == 0\nend\n\nputs alb + asb\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten.\nHe remembers that the remainder of a divided by b was greater than or equal to K.\nFind the number of possible pairs that he may have had.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N-1\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of possible pairs that he may have had.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n7\n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\nSample Input 2\n\n10 0\n\nSample Output 2\n\n100\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n287927211", "sample_input": "5 2\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03420", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten.\nHe remembers that the remainder of a divided by b was greater than or equal to K.\nFind the number of possible pairs that he may have had.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N-1\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of possible pairs that he may have had.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n7\n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\nSample Input 2\n\n10 0\n\nSample Output 2\n\n100\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n287927211", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 310, "cpu_time_ms": 41, "memory_kb": 2684}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s009684790", "group_id": "codeNet:p03423", "input_text": "puts gets.to_i / 3", "language": "Ruby", "metadata": {"date": 1582400609, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s009684790.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s009684790", "user_id": "u164316941"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "puts gets.to_i / 3", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N students in a school.\n\nWe will divide these students into some groups, and in each group they will discuss some themes.\n\nYou think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible.\n\nDivide the students so that the number of groups consisting of three or more students is maximized.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf you can form at most x groups consisting of three or more students, print x.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n2\n\nFor example, you can form a group of three students and another of five students.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0\n\nSometimes you cannot form any group consisting of three or more students, regardless of how you divide the students.\n\nSample Input 3\n\n9\n\nSample Output 3\n\n3", "sample_input": "8\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03423", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N students in a school.\n\nWe will divide these students into some groups, and in each group they will discuss some themes.\n\nYou think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible.\n\nDivide the students so that the number of groups consisting of three or more students is maximized.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf you can form at most x groups consisting of three or more students, print x.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n2\n\nFor example, you can form a group of three students and another of five students.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0\n\nSometimes you cannot form any group consisting of three or more students, regardless of how you divide the students.\n\nSample Input 3\n\n9\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 18, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s572722716", "group_id": "codeNet:p03423", "input_text": "puts gets.strip.to_i / 3", "language": "Ruby", "metadata": {"date": 1559756773, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s572722716.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s572722716", "user_id": "u707614029"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "puts gets.strip.to_i / 3", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N students in a school.\n\nWe will divide these students into some groups, and in each group they will discuss some themes.\n\nYou think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible.\n\nDivide the students so that the number of groups consisting of three or more students is maximized.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf you can form at most x groups consisting of three or more students, print x.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n2\n\nFor example, you can form a group of three students and another of five students.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0\n\nSometimes you cannot form any group consisting of three or more students, regardless of how you divide the students.\n\nSample Input 3\n\n9\n\nSample Output 3\n\n3", "sample_input": "8\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03423", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N students in a school.\n\nWe will divide these students into some groups, and in each group they will discuss some themes.\n\nYou think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible.\n\nDivide the students so that the number of groups consisting of three or more students is maximized.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf you can form at most x groups consisting of three or more students, print x.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n2\n\nFor example, you can form a group of three students and another of five students.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0\n\nSometimes you cannot form any group consisting of three or more students, regardless of how you divide the students.\n\nSample Input 3\n\n9\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 24, "cpu_time_ms": 7, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s033875519", "group_id": "codeNet:p03426", "input_text": "io = STDIN\nio = DATA #!#!#!#!must delete\nhh,ww,d=io.gets.split.map(&:to_i)\n$hash={}\n$memo=Array.new(hh*ww+1,0)\nhh.times do |h|\n row=io.gets.split.map(&:to_i)\n row.each_with_index do |n,w|\n $hash[n]=[h,w]\n end\nend\nrequire 'pp'\n((d+1)..hh*ww).each do |xy|\n i,j=$hash[xy-d]\n x,y=$hash[xy]\n $memo[xy]=$memo[xy-d]+(x-i).abs+(y-j).abs\nend\nq=io.gets.to_i\nq.times do\n l,r=io.gets.split.map(&:to_i)\n puts $memo[r]-$memo[l]\nend\n", "language": "Ruby", "metadata": {"date": 1520735246, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s033875519.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s033875519", "user_id": "u132360211"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "io = STDIN\nio = DATA #!#!#!#!must delete\nhh,ww,d=io.gets.split.map(&:to_i)\n$hash={}\n$memo=Array.new(hh*ww+1,0)\nhh.times do |h|\n row=io.gets.split.map(&:to_i)\n row.each_with_index do |n,w|\n $hash[n]=[h,w]\n end\nend\nrequire 'pp'\n((d+1)..hh*ww).each do |xy|\n i,j=$hash[xy-d]\n x,y=$hash[xy]\n $memo[xy]=$memo[xy-d]+(x-i).abs+(y-j).abs\nend\nq=io.gets.to_i\nq.times do\n l,r=io.gets.split.map(&:to_i)\n puts $memo[r]-$memo[l]\nend\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j).\n\nThe integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}.\n\nYou, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by consuming |x-i|+|y-j| magic points.\n\nYou now have to take Q practical tests of your ability as a magical girl.\n\nThe i-th test will be conducted as follows:\n\nInitially, a piece is placed on the square where the integer L_i is written.\n\nLet x be the integer written in the square occupied by the piece. Repeatedly move the piece to the square where the integer x+D is written, as long as x is not R_i. The test ends when x=R_i.\n\nHere, it is guaranteed that R_i-L_i is a multiple of D.\n\nFor each test, find the sum of magic points consumed during that test.\n\nConstraints\n\n1 \\leq H,W \\leq 300\n\n1 \\leq D \\leq H×W\n\n1 \\leq A_{i,j} \\leq H×W\n\nA_{i,j} \\neq A_{x,y} ((i,j) \\neq (x,y))\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq H×W\n\n(R_i-L_i) is a multiple of D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W D\nA_{1,1} A_{1,2} ... A_{1,W}\n:\nA_{H,1} A_{H,2} ... A_{H,W}\nQ\nL_1 R_1\n:\nL_Q R_Q\n\nOutput\n\nFor each test, print the sum of magic points consumed during that test.\n\nOutput should be in the order the tests are conducted.\n\nSample Input 1\n\n3 3 2\n1 4 3\n2 5 7\n8 9 6\n1\n4 8\n\nSample Output 1\n\n5\n\n4 is written in Square (1,2).\n\n6 is written in Square (3,3).\n\n8 is written in Square (3,1).\n\nThus, the sum of magic points consumed during the first test is (|3-1|+|3-2|)+(|3-3|+|1-3|)=5.\n\nSample Input 2\n\n4 2 3\n3 7\n1 4\n5 2\n6 8\n2\n2 2\n2 2\n\nSample Output 2\n\n0\n0\n\nNote that there may be a test where the piece is not moved at all, and there may be multiple identical tests.\n\nSample Input 3\n\n5 5 4\n13 25 7 15 17\n16 22 20 2 9\n14 11 12 1 19\n10 6 23 8 18\n3 21 5 24 4\n3\n13 13\n2 10\n13 13\n\nSample Output 3\n\n0\n5\n0", "sample_input": "3 3 2\n1 4 3\n2 5 7\n8 9 6\n1\n4 8\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03426", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j).\n\nThe integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}.\n\nYou, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by consuming |x-i|+|y-j| magic points.\n\nYou now have to take Q practical tests of your ability as a magical girl.\n\nThe i-th test will be conducted as follows:\n\nInitially, a piece is placed on the square where the integer L_i is written.\n\nLet x be the integer written in the square occupied by the piece. Repeatedly move the piece to the square where the integer x+D is written, as long as x is not R_i. The test ends when x=R_i.\n\nHere, it is guaranteed that R_i-L_i is a multiple of D.\n\nFor each test, find the sum of magic points consumed during that test.\n\nConstraints\n\n1 \\leq H,W \\leq 300\n\n1 \\leq D \\leq H×W\n\n1 \\leq A_{i,j} \\leq H×W\n\nA_{i,j} \\neq A_{x,y} ((i,j) \\neq (x,y))\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq H×W\n\n(R_i-L_i) is a multiple of D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W D\nA_{1,1} A_{1,2} ... A_{1,W}\n:\nA_{H,1} A_{H,2} ... A_{H,W}\nQ\nL_1 R_1\n:\nL_Q R_Q\n\nOutput\n\nFor each test, print the sum of magic points consumed during that test.\n\nOutput should be in the order the tests are conducted.\n\nSample Input 1\n\n3 3 2\n1 4 3\n2 5 7\n8 9 6\n1\n4 8\n\nSample Output 1\n\n5\n\n4 is written in Square (1,2).\n\n6 is written in Square (3,3).\n\n8 is written in Square (3,1).\n\nThus, the sum of magic points consumed during the first test is (|3-1|+|3-2|)+(|3-3|+|1-3|)=5.\n\nSample Input 2\n\n4 2 3\n3 7\n1 4\n5 2\n6 8\n2\n2 2\n2 2\n\nSample Output 2\n\n0\n0\n\nNote that there may be a test where the piece is not moved at all, and there may be multiple identical tests.\n\nSample Input 3\n\n5 5 4\n13 25 7 15 17\n16 22 20 2 9\n14 11 12 1 19\n10 6 23 8 18\n3 21 5 24 4\n3\n13 13\n2 10\n13 13\n\nSample Output 3\n\n0\n5\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s864928783", "group_id": "codeNet:p03427", "input_text": "n=gets.to_i\n\nif n < 10\n puts n\n exit 0\nend\n\nx = Math.log10(n).floor\nret = x*9 + (n/(10**x))\nret -= 1 if (n+1)%10 != 0\nputs ret\n", "language": "Ruby", "metadata": {"date": 1587312909, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s864928783.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s864928783", "user_id": "u852974293"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "n=gets.to_i\n\nif n < 10\n puts n\n exit 0\nend\n\nx = Math.log10(n).floor\nret = x*9 + (n/(10**x))\nret -= 1 if (n+1)%10 != 0\nputs ret\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": 129, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s716684546", "group_id": "codeNet:p03434", "input_text": "n = gets.to_i\nnum = gets.strip.split.map(&:to_i)\nnum.sort.reverse #大きい順\ni = 0\nsum = 0\ntum = 0\nwhile i < n do\n if i%2==0\n sum += num[i]\n else\n tum += num[i]\n end\n i += 1\nend\nputs sum-tum", "language": "Ruby", "metadata": {"date": 1599878372, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s716684546.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s716684546", "user_id": "u313103408"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n = gets.to_i\nnum = gets.strip.split.map(&:to_i)\nnum.sort.reverse #大きい順\ni = 0\nsum = 0\ntum = 0\nwhile i < n do\n if i%2==0\n sum += num[i]\n else\n tum += num[i]\n end\n i += 1\nend\nputs sum-tum", "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": 203, "cpu_time_ms": 69, "memory_kb": 14288}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s635862041", "group_id": "codeNet:p03434", "input_text": "cards_size = gets.to_i\ncards = gets.split(\" \").map(&:to_i)\ncards.sort!{ |a, b| b <=> a }\nalice = 0\nbob = 0\nisAliceTurn = true\ncards.each do |card|\n if isAliceTurn then\n alice += card\n isAliceTurn = false\n else\n bob += card\n isAliceTurn = true\n end\nend\nputs alice - bob", "language": "Ruby", "metadata": {"date": 1521865110, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s635862041.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s635862041", "user_id": "u249327445"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "cards_size = gets.to_i\ncards = gets.split(\" \").map(&:to_i)\ncards.sort!{ |a, b| b <=> a }\nalice = 0\nbob = 0\nisAliceTurn = true\ncards.each do |card|\n if isAliceTurn then\n alice += card\n isAliceTurn = false\n else\n bob += card\n isAliceTurn = true\n end\nend\nputs alice - bob", "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": 283, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s645212527", "group_id": "codeNet:p03435", "input_text": "c = readlines.map{|line| line.chomp.split.map(&:to_i)}\nb = c[0].map{|i| i - c[0][0]}\na = (0..2).map{|j| c[j][0] - b[0]}\nd = (0..2).map{|i| (0..2).map{|j| a[i] + b[j]}}\n\nputs c == d ? :Yes : :No", "language": "Ruby", "metadata": {"date": 1592090063, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03435.html", "problem_id": "p03435", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03435/input.txt", "sample_output_relpath": "derived/input_output/data/p03435/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03435/Ruby/s645212527.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s645212527", "user_id": "u091810847"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "c = readlines.map{|line| line.chomp.split.map(&:to_i)}\nb = c[0].map{|i| i - c[0][0]}\na = (0..2).map{|j| c[j][0] - b[0]}\nd = (0..2).map{|i| (0..2).map{|j| a[i] + b[j]}}\n\nputs c == d ? :Yes : :No", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have a 3 \\times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.\n\nAccording to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j.\n\nDetermine if he is correct.\n\nConstraints\n\nc_{i, j} \\ (1 \\leq i \\leq 3, 1 \\leq j \\leq 3) is an integer between 0 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nc_{1,1} c_{1,2} c_{1,3}\nc_{2,1} c_{2,2} c_{2,3}\nc_{3,1} c_{3,2} c_{3,3}\n\nOutput\n\nIf Takahashi's statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 0 1\n2 1 2\n1 0 1\n\nSample Output 1\n\nYes\n\nTakahashi is correct, since there are possible sets of integers such as: a_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\nSample Input 2\n\n2 2 2\n2 1 2\n2 2 2\n\nSample Output 2\n\nNo\n\nTakahashi is incorrect in this case.\n\nSample Input 3\n\n0 8 8\n0 8 8\n0 8 8\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n1 8 6\n2 9 7\n0 7 7\n\nSample Output 4\n\nNo", "sample_input": "1 0 1\n2 1 2\n1 0 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03435", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have a 3 \\times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.\n\nAccording to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j.\n\nDetermine if he is correct.\n\nConstraints\n\nc_{i, j} \\ (1 \\leq i \\leq 3, 1 \\leq j \\leq 3) is an integer between 0 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nc_{1,1} c_{1,2} c_{1,3}\nc_{2,1} c_{2,2} c_{2,3}\nc_{3,1} c_{3,2} c_{3,3}\n\nOutput\n\nIf Takahashi's statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 0 1\n2 1 2\n1 0 1\n\nSample Output 1\n\nYes\n\nTakahashi is correct, since there are possible sets of integers such as: a_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\nSample Input 2\n\n2 2 2\n2 1 2\n2 2 2\n\nSample Output 2\n\nNo\n\nTakahashi is incorrect in this case.\n\nSample Input 3\n\n0 8 8\n0 8 8\n0 8 8\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n1 8 6\n2 9 7\n0 7 7\n\nSample Output 4\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 193, "cpu_time_ms": 7, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s718615307", "group_id": "codeNet:p03435", "input_text": "c=3.times.map{gets.split.map(&:to_i)}\nputs c.map{ |e| e.inject(:+) }.inject(:+)%3 == 0 ? :Yes : :No\n", "language": "Ruby", "metadata": {"date": 1578579813, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03435.html", "problem_id": "p03435", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03435/input.txt", "sample_output_relpath": "derived/input_output/data/p03435/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03435/Ruby/s718615307.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s718615307", "user_id": "u078221549"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "c=3.times.map{gets.split.map(&:to_i)}\nputs c.map{ |e| e.inject(:+) }.inject(:+)%3 == 0 ? :Yes : :No\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have a 3 \\times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.\n\nAccording to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j.\n\nDetermine if he is correct.\n\nConstraints\n\nc_{i, j} \\ (1 \\leq i \\leq 3, 1 \\leq j \\leq 3) is an integer between 0 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nc_{1,1} c_{1,2} c_{1,3}\nc_{2,1} c_{2,2} c_{2,3}\nc_{3,1} c_{3,2} c_{3,3}\n\nOutput\n\nIf Takahashi's statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 0 1\n2 1 2\n1 0 1\n\nSample Output 1\n\nYes\n\nTakahashi is correct, since there are possible sets of integers such as: a_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\nSample Input 2\n\n2 2 2\n2 1 2\n2 2 2\n\nSample Output 2\n\nNo\n\nTakahashi is incorrect in this case.\n\nSample Input 3\n\n0 8 8\n0 8 8\n0 8 8\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n1 8 6\n2 9 7\n0 7 7\n\nSample Output 4\n\nNo", "sample_input": "1 0 1\n2 1 2\n1 0 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03435", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have a 3 \\times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.\n\nAccording to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j.\n\nDetermine if he is correct.\n\nConstraints\n\nc_{i, j} \\ (1 \\leq i \\leq 3, 1 \\leq j \\leq 3) is an integer between 0 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nc_{1,1} c_{1,2} c_{1,3}\nc_{2,1} c_{2,2} c_{2,3}\nc_{3,1} c_{3,2} c_{3,3}\n\nOutput\n\nIf Takahashi's statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 0 1\n2 1 2\n1 0 1\n\nSample Output 1\n\nYes\n\nTakahashi is correct, since there are possible sets of integers such as: a_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\nSample Input 2\n\n2 2 2\n2 1 2\n2 2 2\n\nSample Output 2\n\nNo\n\nTakahashi is incorrect in this case.\n\nSample Input 3\n\n0 8 8\n0 8 8\n0 8 8\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n1 8 6\n2 9 7\n0 7 7\n\nSample Output 4\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 100, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s513738388", "group_id": "codeNet:p03435", "input_text": "grid=Array.new(3).map{Array.new(3)}\n(0..2).each do |i|\n str=gets.chomp.split(\" \").map{|str|str.to_i}\n grid[i]=str\nend\np=Array.new()\nq=Array.new()\nr=Array.new()\n(0..2).each do |i|\n p<0\n\t\tq << [x-1,y,d]\n\tend\n\tif x0\n\t\tq << [x,y-1,d]\n\tend\n\tif y0\n\t\tq << [x-1,y,d]\n\tend\n\tif x0\n\t\tq << [x,y-1,d]\n\tend\n\tif ys||0>c-=1\np c", "language": "Ruby", "metadata": {"date": 1592670838, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s971562867.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s971562867", "user_id": "u032223772"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "W=2<s||0>c-=1\np c", "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": 97, "cpu_time_ms": 68, "memory_kb": 15660}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s575098145", "group_id": "codeNet:p03436", "input_text": "require 'pp'\n# IS_DEBUG = true\nIS_DEBUG = false\ndef dputs str\n\tif(IS_DEBUG)\n\t\tputs str\n\tend\nend\ndef dpp str\n\tif(IS_DEBUG)\n\t\tpp str\n\tend\nend\n\nclass Maze\n ROOT='.'; WALL='#'; START='1'; GOAL='2'\n\n def initialize(map=nil, vec=nil)\n self.parseMap(map) if map\n unless vec\n vec = []\n for i in 0..3\n j = i%3==0 ? 1 : -1\n vec[i] = { :x=>(i+1)%2*j, :y=>i%2*j }\n end\n end\n @vec = vec\n end\n\n # マップ文字列を展開する\n def parseMap(map)\n @map = map.split(\"\\n\").map{|line| line.split }\n @size = Hash[*[[:x,:y],@map.shift.map{|val|val.to_i}].transpose.flatten]\n @map.each_with_index do |line,i|\n line.each_with_index do |val,j|\n @start = {:x=>j, :y=>i} if val==START\n @goal = {:x=>j, :y=>i} if val==GOAL\n end\n end\n end\n\n # 探索開始\n def search()\n self.openNode(nil, pos=@start, cost=0)\n loop do\n cost += 1\n @vec.each do |vec|\n newPos = { :x=>pos[:x]+vec[:x], :y=>pos[:y]+vec[:y] }\n self.openNode(@map[pos[:y]][pos[:x]], newPos, cost)\n return true if newPos==@goal\n end\n self.closeNode(pos)\n return false unless pos=self.getNextPos()\n end\n end\n\n # OPENノードからコストが最小のノードを選ぶ\n def getNextPos()\n minScore = nil\n minNode = []\n for j in 0..@size[:y]-1\n for i in 0..@size[:x]-1\n if @map[j][i].is_a?(AStar) && @map[j][i].status===true then\n if !minScore || minScore>@map[j][i].score then\n minScore = @map[j][i].score\n minNode = [{ :x=>i, :y=>j }]\n elsif minScore==@map[j][i].score then\n minNode.push({ :x=>i, :y=>j })\n end\n end\n end\n end\n return minNode.length ? minNode[rand(minNode.length)] : false\n end\n\n # ノードを開く\n def openNode(parent, pos, cost)\n x=pos[:x]; y=pos[:y]\n return false if x<0 || y<0 || x>=@size[:x] || y>=@size[:y]\n return false if @map[y][x].is_a?(AStar) || @map[y][x]==WALL\n @map[y][x] = AStar.new(parent, cost, self.calcHeuristic(pos), pos)\n return true\n end\n\n # ノードを閉じる\n def closeNode(pos)\n @map[pos[:y]][pos[:x]].status = false\n end\n\n # ヒューリスティックコストを計算する\n def calcHeuristic(pos)\n x = pos[:x] - @goal[:x]\n y = pos[:y] - @goal[:y]\n return Math.sqrt(x*x+y*y).to_i\n end\n\n # スタートからゴールまでの道筋を辿る\n def getRoot()\n root=[]; node=@map[@goal[:y]][@goal[:x]]\n loop do\n return root.reverse unless node\n return false unless node.is_a?(AStar)\n root.push(node.pos)\n node = node.parent\n end\n end\n\n def getMap()\n \t@map\n end\nend\n\nclass AStar\n attr_accessor :status, :cost, :heuristic, :pos, :score, :parent\n\n def initialize(parent, cost, heuristic, pos)\n @status = true\n @parent=parent; @cost=cost; @heuristic=heuristic; @pos=pos\n self.calcScore()\n end\n\n def calcScore\n @score = @cost + @heuristic\n end\nend\n\nINT_MAX = 1000000001\n\nH,W=gets.chomp.split(' ').map{|n| n.to_i}\nS=Array.new(H){Array.new(W){0}}\n0.upto(H-1){|i|\n\tS[i]=gets.chomp.split('').map{|n| n}\n}\ndp=Array.new(H){Array.new(W){INT_MAX }}\n\n# 「.」のマス数\nsum = 0\n0.upto(H-1){|i|\n\tsum += (S[i].count{|i|i==\".\"})\n}\n# puts sum\n\nS[0][0]=1\nS[H-1][W-1]=2\nmap = <(i+1)%2*j, :y=>i%2*j }\n end\n end\n @vec = vec\n end\n\n # マップ文字列を展開する\n def parseMap(map)\n @map = map.split(\"\\n\").map{|line| line.split }\n @size = Hash[*[[:x,:y],@map.shift.map{|val|val.to_i}].transpose.flatten]\n @map.each_with_index do |line,i|\n line.each_with_index do |val,j|\n @start = {:x=>j, :y=>i} if val==START\n @goal = {:x=>j, :y=>i} if val==GOAL\n end\n end\n end\n\n # 探索開始\n def search()\n self.openNode(nil, pos=@start, cost=0)\n loop do\n cost += 1\n @vec.each do |vec|\n newPos = { :x=>pos[:x]+vec[:x], :y=>pos[:y]+vec[:y] }\n self.openNode(@map[pos[:y]][pos[:x]], newPos, cost)\n return true if newPos==@goal\n end\n self.closeNode(pos)\n return false unless pos=self.getNextPos()\n end\n end\n\n # OPENノードからコストが最小のノードを選ぶ\n def getNextPos()\n minScore = nil\n minNode = []\n for j in 0..@size[:y]-1\n for i in 0..@size[:x]-1\n if @map[j][i].is_a?(AStar) && @map[j][i].status===true then\n if !minScore || minScore>@map[j][i].score then\n minScore = @map[j][i].score\n minNode = [{ :x=>i, :y=>j }]\n elsif minScore==@map[j][i].score then\n minNode.push({ :x=>i, :y=>j })\n end\n end\n end\n end\n return minNode.length ? minNode[rand(minNode.length)] : false\n end\n\n # ノードを開く\n def openNode(parent, pos, cost)\n x=pos[:x]; y=pos[:y]\n return false if x<0 || y<0 || x>=@size[:x] || y>=@size[:y]\n return false if @map[y][x].is_a?(AStar) || @map[y][x]==WALL\n @map[y][x] = AStar.new(parent, cost, self.calcHeuristic(pos), pos)\n return true\n end\n\n # ノードを閉じる\n def closeNode(pos)\n @map[pos[:y]][pos[:x]].status = false\n end\n\n # ヒューリスティックコストを計算する\n def calcHeuristic(pos)\n x = pos[:x] - @goal[:x]\n y = pos[:y] - @goal[:y]\n return Math.sqrt(x*x+y*y).to_i\n end\n\n # スタートからゴールまでの道筋を辿る\n def getRoot()\n root=[]; node=@map[@goal[:y]][@goal[:x]]\n loop do\n return root.reverse unless node\n return false unless node.is_a?(AStar)\n root.push(node.pos)\n node = node.parent\n end\n end\n\n def getMap()\n \t@map\n end\nend\n\nclass AStar\n attr_accessor :status, :cost, :heuristic, :pos, :score, :parent\n\n def initialize(parent, cost, heuristic, pos)\n @status = true\n @parent=parent; @cost=cost; @heuristic=heuristic; @pos=pos\n self.calcScore()\n end\n\n def calcScore\n @score = @cost + @heuristic\n end\nend\n\nINT_MAX = 1000000001\n\nH,W=gets.chomp.split(' ').map{|n| n.to_i}\nS=Array.new(H){Array.new(W){0}}\n0.upto(H-1){|i|\n\tS[i]=gets.chomp.split('').map{|n| n}\n}\ndp=Array.new(H){Array.new(W){INT_MAX }}\n\n# 「.」のマス数\nsum = 0\n0.upto(H-1){|i|\n\tsum += (S[i].count{|i|i==\".\"})\n}\n# puts sum\n\nS[0][0]=1\nS[H-1][W-1]=2\nmap = <= 1e18+1\n puts -1\n exit\n end\n end\nend\n ", "language": "Ruby", "metadata": {"date": 1517716973, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s877093151.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s877093151", "user_id": "u649331810"}, "prompt_components": {"gold_output": "16\n", "input_to_evaluate": "a, b = gets.split.map(&:to_i)\ni = 2\nif a % b == 0\n puts -1\nelse\n loop do\n a *= 2\n if a % b != 0\n puts a\n exit\n end\n if a >= 1e18+1\n puts -1\n exit\n end\n end\nend\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": 200, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s285180644", "group_id": "codeNet:p03440", "input_text": "class UnionFind\n def initialize(n)\n @size = Array.new(n + 1, 1)\n @rank = Array.new(n + 1, 0)\n @parent = []\n\n (0..n).each do |i|\n @parent[i] = i\n end\n end\n\n def find(x)\n if @parent[x] == x\n x\n else\n @parent[x] = find(@parent[x])\n end\n end\n\n def unite(x, y)\n x = find(x)\n y = find(y)\n return if x == y\n\n if @rank[x] < @rank[y]\n @parent[x] = y\n @size[y] += @size[x]\n else\n @parent[y] = x\n @size[x] += @size[y]\n\n @rank[x] += 1 if @rank[x] == @rank[y]\n end\n end\n\n def same?(x, y)\n find(x) == find(y)\n end\n\n def size(x)\n @size[find(x)]\n end\nend\n\nclass PriorityQueue\n attr_reader :size\n\n def initialize(order: :asc)\n @size = 0\n @nodes = []\n end\n\n def empty?\n @size.zero?\n end\n\n def push(node)\n index = size\n @size += 1\n\n while index > 0\n parent = (index - 1) / 2\n\n break if (@nodes[parent] <=> node) <= 0\n\n @nodes[index] = @nodes[parent]\n index = parent\n end\n\n @nodes[index] = node\n end\n\n alias_method :<<, :push\n\n def pop\n node = @nodes.first\n root = @nodes[size - 1]\n @size -= 1\n index = 0\n\n while index * 2 + 1 < @size\n left = 2 * index + 1\n right = left + 1\n\n if right < size && (@nodes[right] <=> @nodes[left]) <= 0\n left = right\n end\n\n break if (@nodes[left] <=> root) > 0\n\n @nodes[index] = @nodes[left]\n index = left\n end\n\n @nodes[index] = root\n node\n end\n\n def top\n @nodes.first\n end\nend\n\nNode = Struct.new(:v, :cost) do\n def <=>(node)\n cost <=> node.cost\n end\nend\n\nN, M = gets.split.map(&:to_i)\nA = gets.split.map(&:to_i)\n\nuf = UnionFind.new(N + 1)\n\nM.times do\n x, y = gets.split.map(&:to_i)\n\n uf.unite(x, y)\nend\n\ntrees = Hash.new { |h, k| h[k] = [] }\n\nN.times do |v|\n trees[uf.find(v)] << v\nend\n\ntrees = trees.sort_by { |_, list| -list.size }\n\nbase = trees.shift\nans = 0\n\npque = PriorityQueue.new\n\nbase.last.each do |v|\n pque.push(Node.new(v, A[v]))\nend\n\nwhile !trees.empty? && !pque.empty?\n tree = trees.shift\n stock = PriorityQueue.new\n\n tree.last.each do |v|\n stock.push(Node.new(v, A[v]))\n end\n\n v = pque.pop\n u = stock.pop\n\n ans += v.cost + u.cost\n\n until stock.empty?\n pque.push(stock.pop)\n end\nend\n\nif trees.empty?\n puts ans\nelse\n puts 'Impossible'\nend\n", "language": "Ruby", "metadata": {"date": 1578296346, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03440.html", "problem_id": "p03440", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03440/input.txt", "sample_output_relpath": "derived/input_output/data/p03440/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03440/Ruby/s285180644.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s285180644", "user_id": "u740836226"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "class UnionFind\n def initialize(n)\n @size = Array.new(n + 1, 1)\n @rank = Array.new(n + 1, 0)\n @parent = []\n\n (0..n).each do |i|\n @parent[i] = i\n end\n end\n\n def find(x)\n if @parent[x] == x\n x\n else\n @parent[x] = find(@parent[x])\n end\n end\n\n def unite(x, y)\n x = find(x)\n y = find(y)\n return if x == y\n\n if @rank[x] < @rank[y]\n @parent[x] = y\n @size[y] += @size[x]\n else\n @parent[y] = x\n @size[x] += @size[y]\n\n @rank[x] += 1 if @rank[x] == @rank[y]\n end\n end\n\n def same?(x, y)\n find(x) == find(y)\n end\n\n def size(x)\n @size[find(x)]\n end\nend\n\nclass PriorityQueue\n attr_reader :size\n\n def initialize(order: :asc)\n @size = 0\n @nodes = []\n end\n\n def empty?\n @size.zero?\n end\n\n def push(node)\n index = size\n @size += 1\n\n while index > 0\n parent = (index - 1) / 2\n\n break if (@nodes[parent] <=> node) <= 0\n\n @nodes[index] = @nodes[parent]\n index = parent\n end\n\n @nodes[index] = node\n end\n\n alias_method :<<, :push\n\n def pop\n node = @nodes.first\n root = @nodes[size - 1]\n @size -= 1\n index = 0\n\n while index * 2 + 1 < @size\n left = 2 * index + 1\n right = left + 1\n\n if right < size && (@nodes[right] <=> @nodes[left]) <= 0\n left = right\n end\n\n break if (@nodes[left] <=> root) > 0\n\n @nodes[index] = @nodes[left]\n index = left\n end\n\n @nodes[index] = root\n node\n end\n\n def top\n @nodes.first\n end\nend\n\nNode = Struct.new(:v, :cost) do\n def <=>(node)\n cost <=> node.cost\n end\nend\n\nN, M = gets.split.map(&:to_i)\nA = gets.split.map(&:to_i)\n\nuf = UnionFind.new(N + 1)\n\nM.times do\n x, y = gets.split.map(&:to_i)\n\n uf.unite(x, y)\nend\n\ntrees = Hash.new { |h, k| h[k] = [] }\n\nN.times do |v|\n trees[uf.find(v)] << v\nend\n\ntrees = trees.sort_by { |_, list| -list.size }\n\nbase = trees.shift\nans = 0\n\npque = PriorityQueue.new\n\nbase.last.each do |v|\n pque.push(Node.new(v, A[v]))\nend\n\nwhile !trees.empty? && !pque.empty?\n tree = trees.shift\n stock = PriorityQueue.new\n\n tree.last.each do |v|\n stock.push(Node.new(v, A[v]))\n end\n\n v = pque.pop\n u = stock.pop\n\n ans += v.cost + u.cost\n\n until stock.empty?\n pque.push(stock.pop)\n end\nend\n\nif trees.empty?\n puts ans\nelse\n puts 'Impossible'\nend\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nYou are given a forest with N vertices and M edges. The vertices are numbered 0 through N-1.\nThe edges are given in the format (x_i,y_i), which means that Vertex x_i and y_i are connected by an edge.\n\nEach vertex i has a value a_i.\nYou want to add edges in the given forest so that the forest becomes connected.\nTo add an edge, you choose two different vertices i and j, then span an edge between i and j.\nThis operation costs a_i + a_j dollars, and afterward neither Vertex i nor j can be selected again.\n\nFind the minimum total cost required to make the forest connected, or print Impossible if it is impossible.\n\nConstraints\n\n1 ≤ N ≤ 100,000\n\n0 ≤ M ≤ N-1\n\n1 ≤ a_i ≤ 10^9\n\n0 ≤ x_i,y_i ≤ N-1\n\nThe given graph is a forest.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_0 a_1 .. a_{N-1}\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the minimum total cost required to make the forest connected, or print Impossible if it is impossible.\n\nSample Input 1\n\n7 5\n1 2 3 4 5 6 7\n3 0\n4 0\n1 2\n1 3\n5 6\n\nSample Output 1\n\n7\n\nIf we connect vertices 0 and 5, the graph becomes connected, for the cost of 1 + 6 = 7 dollars.\n\nSample Input 2\n\n5 0\n3 1 4 1 5\n\nSample Output 2\n\nImpossible\n\nWe can't make the graph connected.\n\nSample Input 3\n\n1 0\n5\n\nSample Output 3\n\n0\n\nThe graph is already connected, so we do not need to add any edges.", "sample_input": "7 5\n1 2 3 4 5 6 7\n3 0\n4 0\n1 2\n1 3\n5 6\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03440", "source_text": "Score : 600 points\n\nProblem Statement\n\nYou are given a forest with N vertices and M edges. The vertices are numbered 0 through N-1.\nThe edges are given in the format (x_i,y_i), which means that Vertex x_i and y_i are connected by an edge.\n\nEach vertex i has a value a_i.\nYou want to add edges in the given forest so that the forest becomes connected.\nTo add an edge, you choose two different vertices i and j, then span an edge between i and j.\nThis operation costs a_i + a_j dollars, and afterward neither Vertex i nor j can be selected again.\n\nFind the minimum total cost required to make the forest connected, or print Impossible if it is impossible.\n\nConstraints\n\n1 ≤ N ≤ 100,000\n\n0 ≤ M ≤ N-1\n\n1 ≤ a_i ≤ 10^9\n\n0 ≤ x_i,y_i ≤ N-1\n\nThe given graph is a forest.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_0 a_1 .. a_{N-1}\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the minimum total cost required to make the forest connected, or print Impossible if it is impossible.\n\nSample Input 1\n\n7 5\n1 2 3 4 5 6 7\n3 0\n4 0\n1 2\n1 3\n5 6\n\nSample Output 1\n\n7\n\nIf we connect vertices 0 and 5, the graph becomes connected, for the cost of 1 + 6 = 7 dollars.\n\nSample Input 2\n\n5 0\n3 1 4 1 5\n\nSample Output 2\n\nImpossible\n\nWe can't make the graph connected.\n\nSample Input 3\n\n1 0\n5\n\nSample Output 3\n\n0\n\nThe graph is already connected, so we do not need to add any edges.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2312, "cpu_time_ms": 843, "memory_kb": 30248}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s013048734", "group_id": "codeNet:p03452", "input_text": "def main()\n n, m = gets.split.map { |t| t.to_i }\n if m == 0\n puts \"Yes\"\n exit\n end\n loc_info = []\n m.times do\n loc_info.push(gets.split.map { |t| t.to_i })\n end\n\n # person to loc\n p2l = {}\n for t in loc_info\n if p2l[t[0]]\n p2l[t[0]].push(t)\n else\n p2l[t[0]] = [t]\n end\n if p2l[t[1]]\n p2l[t[1]].push(t)\n else\n p2l[t[1]] = [t]\n end\n end\n\n person = loc_info[0][0]\n loc_hash = {}\n while p2l.size > 0\n if loc_hash.empty?\n person = p2l.keys[0]\n else\n for person in loc_hash.keys\n break if p2l[person]\n end\n person = p2l.keys[0] unless person\n end\n list = p2l[person]\n p2l.delete(person)\n\n loc = loc_hash[person] || 0\n loc_hash[person] = loc\n for left, right, dist in list\n if left == person\n if loc_hash[right] and loc_hash[right] != loc + dist\n puts \"No\"\n exit\n end\n loc_hash[right] = loc + dist\n else\n if loc_hash[left] and loc_hash[left] != loc - dist\n puts \"No\"\n exit\n end\n loc_hash[left] = loc - dist\n end\n end\n end\n puts \"Yes\"\nend\n\nmain if __FILE__ == $0\n", "language": "Ruby", "metadata": {"date": 1517195130, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03452.html", "problem_id": "p03452", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03452/input.txt", "sample_output_relpath": "derived/input_output/data/p03452/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03452/Ruby/s013048734.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s013048734", "user_id": "u992251977"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "def main()\n n, m = gets.split.map { |t| t.to_i }\n if m == 0\n puts \"Yes\"\n exit\n end\n loc_info = []\n m.times do\n loc_info.push(gets.split.map { |t| t.to_i })\n end\n\n # person to loc\n p2l = {}\n for t in loc_info\n if p2l[t[0]]\n p2l[t[0]].push(t)\n else\n p2l[t[0]] = [t]\n end\n if p2l[t[1]]\n p2l[t[1]].push(t)\n else\n p2l[t[1]] = [t]\n end\n end\n\n person = loc_info[0][0]\n loc_hash = {}\n while p2l.size > 0\n if loc_hash.empty?\n person = p2l.keys[0]\n else\n for person in loc_hash.keys\n break if p2l[person]\n end\n person = p2l.keys[0] unless person\n end\n list = p2l[person]\n p2l.delete(person)\n\n loc = loc_hash[person] || 0\n loc_hash[person] = loc\n for left, right, dist in list\n if left == person\n if loc_hash[right] and loc_hash[right] != loc + dist\n puts \"No\"\n exit\n end\n loc_hash[right] = loc + dist\n else\n if loc_hash[left] and loc_hash[left] != loc - dist\n puts \"No\"\n exit\n end\n loc_hash[left] = loc - dist\n end\n end\n end\n puts \"Yes\"\nend\n\nmain if __FILE__ == $0\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": "p03452", "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": 1164, "cpu_time_ms": 2115, "memory_kb": 135332}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s312177831", "group_id": "codeNet:p03456", "input_text": "require 'complex'\n\na, b = gets.chomp.split(\" \")\nc = (a + b).to_i\n\n# floorは小数点切り捨て\nd = Math.sqrt(c).floor\nif (d*d) == c\n puts \"Yes\"\nelse\n puts \"No\"\nend\n\n#puts \"#{}\"\n#puts \"#{}\"\n", "language": "Ruby", "metadata": {"date": 1560791677, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03456.html", "problem_id": "p03456", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03456/input.txt", "sample_output_relpath": "derived/input_output/data/p03456/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03456/Ruby/s312177831.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s312177831", "user_id": "u079207542"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "require 'complex'\n\na, b = gets.chomp.split(\" \")\nc = (a + b).to_i\n\n# floorは小数点切り捨て\nd = Math.sqrt(c).floor\nif (d*d) == c\n puts \"Yes\"\nelse\n puts \"No\"\nend\n\n#puts \"#{}\"\n#puts \"#{}\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer has found two positive integers, a and b.\nDetermine whether the concatenation of a and b in this order is a square number.\n\nConstraints\n\n1 ≤ a,b ≤ 100\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the concatenation of a and b in this order is a square number, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 21\n\nSample Output 1\n\nYes\n\nAs 121 = 11 × 11, it is a square number.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\nNo\n\n100100 is not a square number.\n\nSample Input 3\n\n12 10\n\nSample Output 3\n\nNo", "sample_input": "1 21\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03456", "source_text": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer has found two positive integers, a and b.\nDetermine whether the concatenation of a and b in this order is a square number.\n\nConstraints\n\n1 ≤ a,b ≤ 100\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the concatenation of a and b in this order is a square number, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 21\n\nSample Output 1\n\nYes\n\nAs 121 = 11 × 11, it is a square number.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\nNo\n\n100100 is not a square number.\n\nSample Input 3\n\n12 10\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 198, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s113573451", "group_id": "codeNet:p03457", "input_text": "n = gets.to_i\ntxy = n.times.map{gets.split.map(&:to_i)}\n\nans = 'Yes'\nnow_x = 0\nnow_y = 0\nnow_t = 0\ntxy.each do |t, x, y|\n diff_x = (now_x - x).abs\n diff_y = (now_y - y).abs\n diff_t = t - now_t\n dist = (diff_x + diff_y)\n unless diff_t >= dist && (diff_t - dist).even?\n ans = 'No'\n break\n end\n now_t = t\n now_x = x\n now_y = y\nend\n\nputs ans", "language": "Ruby", "metadata": {"date": 1592885275, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s113573451.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s113573451", "user_id": "u392423112"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "n = gets.to_i\ntxy = n.times.map{gets.split.map(&:to_i)}\n\nans = 'Yes'\nnow_x = 0\nnow_y = 0\nnow_t = 0\ntxy.each do |t, x, y|\n diff_x = (now_x - x).abs\n diff_y = (now_y - y).abs\n diff_t = t - now_t\n dist = (diff_x + diff_y)\n unless diff_t >= dist && (diff_t - dist).even?\n ans = 'No'\n break\n end\n now_t = t\n now_x = x\n now_y = y\nend\n\nputs ans", "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": 352, "cpu_time_ms": 181, "memory_kb": 20632}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s164044126", "group_id": "codeNet:p03457", "input_text": "n = gets.to_i\ntc, xc, yc = [0, 0, 0]\n\nans = \"Yes\"\n\nn.times do |i|\n tn, xn, yn = gets.split.map(&:to_i)\n\n t = tn - tc\n x = (xn - xc).abs\n y = (yn - yc).abs\n\n if x + y > t || (t - (x + y)).odd?\n ans = \"No\"\n break\n end\n\n tc, xc, yc = tn, xn, yn\nend\n\nputs ans\n", "language": "Ruby", "metadata": {"date": 1589293114, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s164044126.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s164044126", "user_id": "u889326464"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "n = gets.to_i\ntc, xc, yc = [0, 0, 0]\n\nans = \"Yes\"\n\nn.times do |i|\n tn, xn, yn = gets.split.map(&:to_i)\n\n t = tn - tc\n x = (xn - xc).abs\n y = (yn - yc).abs\n\n if x + y > t || (t - (x + y)).odd?\n ans = \"No\"\n break\n end\n\n tc, xc, yc = tn, xn, yn\nend\n\nputs ans\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": 269, "cpu_time_ms": 177, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s815619884", "group_id": "codeNet:p03457", "input_text": "def action_handler(array, count)\n result = false\n current_nums = [0, 0, 0]\n time_index = 0\n x_index = 1\n y_index = 2\n for i in 0..(count - 2)\n is_first = i == 0\n now_array = is_first ? current_nums : array[i]\n next_array = is_first ? array[i] : array[i + 1]\n dt = next_array[time_index] - now_array[time_index]\n dx = next_array[x_index] - now_array[x_index]\n dy = next_array[y_index] - now_array[y_index]\n #時間内に移動できるかの計算\n dxy = dx.abs + dy.abs\n if dxy <= dt\n new_dxy = dx + dy\n if dt.even? != new_dxy.even?\n return false\n else\n result = true\n end\n else\n return false\n end\n end\n return result\nend\n=begin\ndef variable_finder(sec, coordinates)\n a = [coordinates[0] + 1, coordinates[1]]\n b = [coordinates[0] - 1, coordinates[1]]\n c = [coordinates[0], coordinates[1] + 1]\n d = [coordinates[0], coordinates[1] - 1]\n all_cases = [a, b, c, d]\n for x_i in 0..sec\n y_i = sec - x_i\n tmp = [coordinates[0] + x_i, coordinates[1] + y_i]\n tmp2 = [coordinates[0] - x_i, coordinates[1] + y_i]\n tmp3 = [coordinates[0] + x_i, coordinates[1] - y_i]\n tmp4 = [coordinates[0] - x_i, coordinates[1] - y_i]\n all_cases.push(tmp)\n all_cases.push(tmp2)\n all_cases.push(tmp3)\n all_cases.push(tmp4)\n end\n return all_cases.uniq\nend\n=end\n\n#複数行に複数の要素が存在するとき\ninput = gets.chop.to_i\nlines = []\nwhile line = gets\n lines << line.chomp.split(' ').map(&:to_i)\nend\n\n#p action_handler([[3, 1, 2], [6, 1, 1]], 2) => true\nprint action_handler(lines, input) ? 'Yes' : 'No'\n", "language": "Ruby", "metadata": {"date": 1579043076, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s815619884.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s815619884", "user_id": "u414732171"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "def action_handler(array, count)\n result = false\n current_nums = [0, 0, 0]\n time_index = 0\n x_index = 1\n y_index = 2\n for i in 0..(count - 2)\n is_first = i == 0\n now_array = is_first ? current_nums : array[i]\n next_array = is_first ? array[i] : array[i + 1]\n dt = next_array[time_index] - now_array[time_index]\n dx = next_array[x_index] - now_array[x_index]\n dy = next_array[y_index] - now_array[y_index]\n #時間内に移動できるかの計算\n dxy = dx.abs + dy.abs\n if dxy <= dt\n new_dxy = dx + dy\n if dt.even? != new_dxy.even?\n return false\n else\n result = true\n end\n else\n return false\n end\n end\n return result\nend\n=begin\ndef variable_finder(sec, coordinates)\n a = [coordinates[0] + 1, coordinates[1]]\n b = [coordinates[0] - 1, coordinates[1]]\n c = [coordinates[0], coordinates[1] + 1]\n d = [coordinates[0], coordinates[1] - 1]\n all_cases = [a, b, c, d]\n for x_i in 0..sec\n y_i = sec - x_i\n tmp = [coordinates[0] + x_i, coordinates[1] + y_i]\n tmp2 = [coordinates[0] - x_i, coordinates[1] + y_i]\n tmp3 = [coordinates[0] + x_i, coordinates[1] - y_i]\n tmp4 = [coordinates[0] - x_i, coordinates[1] - y_i]\n all_cases.push(tmp)\n all_cases.push(tmp2)\n all_cases.push(tmp3)\n all_cases.push(tmp4)\n end\n return all_cases.uniq\nend\n=end\n\n#複数行に複数の要素が存在するとき\ninput = gets.chop.to_i\nlines = []\nwhile line = gets\n lines << line.chomp.split(' ').map(&:to_i)\nend\n\n#p action_handler([[3, 1, 2], [6, 1, 1]], 2) => true\nprint action_handler(lines, input) ? 'Yes' : 'No'\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "sample_input": "2\n3 1 2\n6 1 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03457", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1605, "cpu_time_ms": 228, "memory_kb": 9468}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s829328066", "group_id": "codeNet:p03460", "input_text": "N,K = gets.split.map(&:to_i)\nKK = 2*K\n\n$tot = [0,0]\n$elvis = (0..1).map{ (0..K).map{ Array.new(K+1,0) } }\nN.times{ \n x,y,c = gets.split\n x,y = [x,y].map{ |r| r.to_i % KK }\n c = c == \"B\" ? 0 : 1\n if x >= K\n x %= K; c ^= 1\n end\n if y >= K\n y %= K; c ^= 1\n end\n $elvis[c][x][y] += 1\n $tot[c] += 1\n}\n\ndef C(color, x, y)\n return 0 if x < 0 || y < 0\n $elvis[color][x][y]\nend\n\n$sum = (0..1).map{ |color|\n lastline = Array.new(K+1, 0)\n (0..K).map{ |y|\n linesum = 0\n lastline = (0..K).map{ |x|\n linesum += C(color, x, y)\n lastline[x] + linesum\n }\n lastline\n }\n}\n\n#p $elvis[0], $sum[0]\n#p $elvis[1], $sum[1]\n\ndef S(color, x, y)\n return 0 if x < 0 || y < 0\n $sum[color][x][y]\nend\n#exit\nans = 0\n(0..K).each{ |x|\n (0..K).each{ |y|\n\tbb = 2*S(0, x-1, y-1) - S(0, K, y-1) - S(0, x-1, K)\n\tww = 2*S(1, x-1, y-1) - S(1, K, y-1) - S(1, x-1, K)\n ans = [ans, bb+$tot[0]-ww, ww+$tot[1]-bb].max\n #p ans\n }\n}\nputs ans", "language": "Ruby", "metadata": {"date": 1535408435, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03460.html", "problem_id": "p03460", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03460/input.txt", "sample_output_relpath": "derived/input_output/data/p03460/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03460/Ruby/s829328066.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s829328066", "user_id": "u670503797"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "N,K = gets.split.map(&:to_i)\nKK = 2*K\n\n$tot = [0,0]\n$elvis = (0..1).map{ (0..K).map{ Array.new(K+1,0) } }\nN.times{ \n x,y,c = gets.split\n x,y = [x,y].map{ |r| r.to_i % KK }\n c = c == \"B\" ? 0 : 1\n if x >= K\n x %= K; c ^= 1\n end\n if y >= K\n y %= K; c ^= 1\n end\n $elvis[c][x][y] += 1\n $tot[c] += 1\n}\n\ndef C(color, x, y)\n return 0 if x < 0 || y < 0\n $elvis[color][x][y]\nend\n\n$sum = (0..1).map{ |color|\n lastline = Array.new(K+1, 0)\n (0..K).map{ |y|\n linesum = 0\n lastline = (0..K).map{ |x|\n linesum += C(color, x, y)\n lastline[x] + linesum\n }\n lastline\n }\n}\n\n#p $elvis[0], $sum[0]\n#p $elvis[1], $sum[1]\n\ndef S(color, x, y)\n return 0 if x < 0 || y < 0\n $sum[color][x][y]\nend\n#exit\nans = 0\n(0..K).each{ |x|\n (0..K).each{ |y|\n\tbb = 2*S(0, x-1, y-1) - S(0, K, y-1) - S(0, x-1, K)\n\tww = 2*S(1, x-1, y-1) - S(1, K, y-1) - S(1, x-1, K)\n ans = [ans, bb+$tot[0]-ww, ww+$tot[1]-bb].max\n #p ans\n }\n}\nputs ans", "problem_context": "Score : 500 points\n\nProblem Statement\n\nAtCoDeer is thinking of painting an infinite two-dimensional grid in a checked pattern of side K.\nHere, a checked pattern of side K is a pattern where each square is painted black or white so that each connected component of each color is a K × K square.\nBelow is an example of a checked pattern of side 3:\n\nAtCoDeer has N desires.\nThe i-th desire is represented by x_i, y_i and c_i.\nIf c_i is B, it means that he wants to paint the square (x_i,y_i) black; if c_i is W, he wants to paint the square (x_i,y_i) white.\nAt most how many desires can he satisfy at the same time?\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ K ≤ 1000\n\n0 ≤ x_i ≤ 10^9\n\n0 ≤ y_i ≤ 10^9\n\nIf i ≠ j, then (x_i,y_i) ≠ (x_j,y_j).\n\nc_i is B or W.\n\nN, K, x_i and y_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 y_1 c_1\nx_2 y_2 c_2\n:\nx_N y_N c_N\n\nOutput\n\nPrint the maximum number of desires that can be satisfied at the same time.\n\nSample Input 1\n\n4 3\n0 1 W\n1 2 W\n5 3 B\n5 4 B\n\nSample Output 1\n\n4\n\nHe can satisfy all his desires by painting as shown in the example above.\n\nSample Input 2\n\n2 1000\n0 0 B\n0 1 W\n\nSample Output 2\n\n2\n\nSample Input 3\n\n6 2\n1 2 B\n2 1 W\n2 2 B\n1 0 B\n0 6 W\n4 5 W\n\nSample Output 3\n\n4", "sample_input": "4 3\n0 1 W\n1 2 W\n5 3 B\n5 4 B\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03460", "source_text": "Score : 500 points\n\nProblem Statement\n\nAtCoDeer is thinking of painting an infinite two-dimensional grid in a checked pattern of side K.\nHere, a checked pattern of side K is a pattern where each square is painted black or white so that each connected component of each color is a K × K square.\nBelow is an example of a checked pattern of side 3:\n\nAtCoDeer has N desires.\nThe i-th desire is represented by x_i, y_i and c_i.\nIf c_i is B, it means that he wants to paint the square (x_i,y_i) black; if c_i is W, he wants to paint the square (x_i,y_i) white.\nAt most how many desires can he satisfy at the same time?\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ K ≤ 1000\n\n0 ≤ x_i ≤ 10^9\n\n0 ≤ y_i ≤ 10^9\n\nIf i ≠ j, then (x_i,y_i) ≠ (x_j,y_j).\n\nc_i is B or W.\n\nN, K, x_i and y_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 y_1 c_1\nx_2 y_2 c_2\n:\nx_N y_N c_N\n\nOutput\n\nPrint the maximum number of desires that can be satisfied at the same time.\n\nSample Input 1\n\n4 3\n0 1 W\n1 2 W\n5 3 B\n5 4 B\n\nSample Output 1\n\n4\n\nHe can satisfy all his desires by painting as shown in the example above.\n\nSample Input 2\n\n2 1000\n0 0 B\n0 1 W\n\nSample Output 2\n\n2\n\nSample Input 3\n\n6 2\n1 2 B\n2 1 W\n2 2 B\n1 0 B\n0 6 W\n4 5 W\n\nSample Output 3\n\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 945, "cpu_time_ms": 1986, "memory_kb": 43004}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s907522564", "group_id": "codeNet:p03469", "input_text": "n,y=gets.chomp.split(\" \").map(&:to_i)\nfound = false\ncatch(:break_loop) do\n (0..n).each do|ichiman|\n total = ichiman * 10000\n if total == y\n puts \"#{ichiman} 0 0\"\n found = true\n break\n elsif total > y\n break\n end\n (0..n-ichiman).each do |gosen|\n total = ichiman * 10000 + gosen * 5000\n if total == y\n puts \"#{ichiman} #{gosen} 0\"\n found = true\n throw :break_loop\n elsif total > y\n break\n end\n sen = n - ichiman - gosen\n total = ichiman * 10000 + gosen * 5000 + sen * 1000\n if total == y\n puts \"#{ichiman} #{gosen} #{sen}\"\n found = true\n throw :break_loop\n end\n end\n end\nend\nputs '-1 -1 -1' unless found\n", "language": "Ruby", "metadata": {"date": 1569872425, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s907522564.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s907522564", "user_id": "u700173502"}, "prompt_components": {"gold_output": "2018/01/07\n", "input_to_evaluate": "n,y=gets.chomp.split(\" \").map(&:to_i)\nfound = false\ncatch(:break_loop) do\n (0..n).each do|ichiman|\n total = ichiman * 10000\n if total == y\n puts \"#{ichiman} 0 0\"\n found = true\n break\n elsif total > y\n break\n end\n (0..n-ichiman).each do |gosen|\n total = ichiman * 10000 + gosen * 5000\n if total == y\n puts \"#{ichiman} #{gosen} 0\"\n found = true\n throw :break_loop\n elsif total > y\n break\n end\n sen = n - ichiman - gosen\n total = ichiman * 10000 + gosen * 5000 + sen * 1000\n if total == y\n puts \"#{ichiman} #{gosen} #{sen}\"\n found = true\n throw :break_loop\n end\n end\n end\nend\nputs '-1 -1 -1' unless found\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": 731, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s523392522", "group_id": "codeNet:p03469", "input_text": "n,y=gets.chomp.split(\" \").map(&:to_i)\nfound = false\ncatch(:break_loop) do\n (0..n).each do|ichiman|\n (0..n-ichiman).each do |gosen|\n sen = n - ichiman - gosen\n total = ichiman * 10000 + gosen * 5000 + sen * 1000\n if total == y\n puts \"#{ichiman} #{gosen} #{sen}\"\n found = true\n end\n end\n end\nend\nputs '-1 -1 -1' unless found\n", "language": "Ruby", "metadata": {"date": 1569872054, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s523392522.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s523392522", "user_id": "u700173502"}, "prompt_components": {"gold_output": "2018/01/07\n", "input_to_evaluate": "n,y=gets.chomp.split(\" \").map(&:to_i)\nfound = false\ncatch(:break_loop) do\n (0..n).each do|ichiman|\n (0..n-ichiman).each do |gosen|\n sen = n - ichiman - gosen\n total = ichiman * 10000 + gosen * 5000 + sen * 1000\n if total == y\n puts \"#{ichiman} #{gosen} #{sen}\"\n found = true\n end\n end\n end\nend\nputs '-1 -1 -1' unless found\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": 365, "cpu_time_ms": 397, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s963855069", "group_id": "codeNet:p03475", "input_text": "n = gets.to_i\nc = Array.new(n, 0)\ns = Array.new(n, 0)\nf = Array.new(n, 0)\n\n(n - 1).times do |i|\n ct, st, ft = gets.chomp.split.map(&:to_i)\n c[i] = ct\n s[i] = st\n f[i] = ft\nend\n\nn.times do |i|\n res = 0\n i.step(n - 2) do |j|\n if j == i\n res += s[j]\n elsif res < s[j]\n res = s[j]\n else\n res += (f[j] - res) % f[j]\n end\n res += c[j]\n end\n puts res\nend", "language": "Ruby", "metadata": {"date": 1597430551, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p03475.html", "problem_id": "p03475", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03475/input.txt", "sample_output_relpath": "derived/input_output/data/p03475/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03475/Ruby/s963855069.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s963855069", "user_id": "u482840940"}, "prompt_components": {"gold_output": "12\n11\n0\n", "input_to_evaluate": "n = gets.to_i\nc = Array.new(n, 0)\ns = Array.new(n, 0)\nf = Array.new(n, 0)\n\n(n - 1).times do |i|\n ct, st, ft = gets.chomp.split.map(&:to_i)\n c[i] = ct\n s[i] = st\n f[i] = ft\nend\n\nn.times do |i|\n res = 0\n i.step(n - 2) do |j|\n if j == i\n res += s[j]\n elsif res < s[j]\n res = s[j]\n else\n res += (f[j] - res) % f[j]\n end\n res += c[j]\n end\n puts res\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA railroad running from west to east in Atcoder Kingdom is now complete.\n\nThere are N stations on the railroad, numbered 1 through N from west to east.\n\nTomorrow, the opening ceremony of the railroad will take place.\n\nOn this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i to Station i+1 in C_i seconds. No other trains will be operated.\n\nThe first train from Station i to Station i+1 will depart Station i S_i seconds after the ceremony begins. Thereafter, there will be a train that departs Station i every F_i seconds.\n\nHere, it is guaranteed that F_i divides S_i.\n\nThat is, for each Time t satisfying S_i≤t and t%F_i=0, there will be a train that departs Station i t seconds after the ceremony begins and arrives at Station i+1 t+C_i seconds after the ceremony begins, where A%B denotes A modulo B, and there will be no other trains.\n\nFor each i, find the earliest possible time we can reach Station N if we are at Station i when the ceremony begins, ignoring the time needed to change trains.\n\nConstraints\n\n1≤N≤500\n\n1≤C_i≤100\n\n1≤S_i≤10^5\n\n1≤F_i≤10\n\nS_i%F_i=0\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nC_1 S_1 F_1\n:\nC_{N-1} S_{N-1} F_{N-1}\n\nOutput\n\nPrint N lines. Assuming that we are at Station i (1≤i≤N) when the ceremony begins, if the earliest possible time we can reach Station N is x seconds after the ceremony begins, the i-th line should contain x.\n\nSample Input 1\n\n3\n6 5 1\n1 10 1\n\nSample Output 1\n\n12\n11\n0\n\nWe will travel from Station 1 as follows:\n\n5 seconds after the beginning: take the train to Station 2.\n\n11 seconds: arrive at Station 2.\n\n11 seconds: take the train to Station 3.\n\n12 seconds: arrive at Station 3.\n\nWe will travel from Station 2 as follows:\n\n10 seconds: take the train to Station 3.\n\n11 seconds: arrive at Station 3.\n\nNote that we should print 0 for Station 3.\n\nSample Input 2\n\n4\n12 24 6\n52 16 4\n99 2 2\n\nSample Output 2\n\n187\n167\n101\n0\n\nSample Input 3\n\n4\n12 13 1\n44 17 17\n66 4096 64\n\nSample Output 3\n\n4162\n4162\n4162\n0", "sample_input": "3\n6 5 1\n1 10 1\n"}, "reference_outputs": ["12\n11\n0\n"], "source_document_id": "p03475", "source_text": "Score : 300 points\n\nProblem Statement\n\nA railroad running from west to east in Atcoder Kingdom is now complete.\n\nThere are N stations on the railroad, numbered 1 through N from west to east.\n\nTomorrow, the opening ceremony of the railroad will take place.\n\nOn this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i to Station i+1 in C_i seconds. No other trains will be operated.\n\nThe first train from Station i to Station i+1 will depart Station i S_i seconds after the ceremony begins. Thereafter, there will be a train that departs Station i every F_i seconds.\n\nHere, it is guaranteed that F_i divides S_i.\n\nThat is, for each Time t satisfying S_i≤t and t%F_i=0, there will be a train that departs Station i t seconds after the ceremony begins and arrives at Station i+1 t+C_i seconds after the ceremony begins, where A%B denotes A modulo B, and there will be no other trains.\n\nFor each i, find the earliest possible time we can reach Station N if we are at Station i when the ceremony begins, ignoring the time needed to change trains.\n\nConstraints\n\n1≤N≤500\n\n1≤C_i≤100\n\n1≤S_i≤10^5\n\n1≤F_i≤10\n\nS_i%F_i=0\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nC_1 S_1 F_1\n:\nC_{N-1} S_{N-1} F_{N-1}\n\nOutput\n\nPrint N lines. Assuming that we are at Station i (1≤i≤N) when the ceremony begins, if the earliest possible time we can reach Station N is x seconds after the ceremony begins, the i-th line should contain x.\n\nSample Input 1\n\n3\n6 5 1\n1 10 1\n\nSample Output 1\n\n12\n11\n0\n\nWe will travel from Station 1 as follows:\n\n5 seconds after the beginning: take the train to Station 2.\n\n11 seconds: arrive at Station 2.\n\n11 seconds: take the train to Station 3.\n\n12 seconds: arrive at Station 3.\n\nWe will travel from Station 2 as follows:\n\n10 seconds: take the train to Station 3.\n\n11 seconds: arrive at Station 3.\n\nNote that we should print 0 for Station 3.\n\nSample Input 2\n\n4\n12 24 6\n52 16 4\n99 2 2\n\nSample Output 2\n\n187\n167\n101\n0\n\nSample Input 3\n\n4\n12 13 1\n44 17 17\n66 4096 64\n\nSample Output 3\n\n4162\n4162\n4162\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 385, "cpu_time_ms": 79, "memory_kb": 14264}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s264077982", "group_id": "codeNet:p03477", "input_text": "a=gets.to_i\nb=gets.to_i\nc=gets.to_i\nd=gets.to_i\nA=a+b\nB=c+d\nif A>B\n puts \"Left\"\nelsif A==B\n puts \"Balanced\"\nelse\n puts \"Right\"\nend", "language": "Ruby", "metadata": {"date": 1552421796, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s264077982.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s264077982", "user_id": "u352238438"}, "prompt_components": {"gold_output": "Left\n", "input_to_evaluate": "a=gets.to_i\nb=gets.to_i\nc=gets.to_i\nd=gets.to_i\nA=a+b\nB=c+d\nif A>B\n puts \"Left\"\nelsif A==B\n puts \"Balanced\"\nelse\n puts \"Right\"\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "sample_input": "3 8 7 1\n"}, "reference_outputs": ["Left\n"], "source_document_id": "p03477", "source_text": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 133, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s408609036", "group_id": "codeNet:p03486", "input_text": "s = gets.chomp.chars.map(&:ord).sort\nt = gets.chomp.chars.map(&:ord).sort.reverse\ns << 0\nt << -1\n\nt.length.times{ |i|\n s_min = s[i]\n t_max = t[i]\n if s[i].nil? || s_min < t_max\n puts 'Yes'\n break\n elsif s_min > t_max\n puts 'No'\n break\n end\n}\n", "language": "Ruby", "metadata": {"date": 1578303077, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03486.html", "problem_id": "p03486", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03486/input.txt", "sample_output_relpath": "derived/input_output/data/p03486/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03486/Ruby/s408609036.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s408609036", "user_id": "u078221549"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "s = gets.chomp.chars.map(&:ord).sort\nt = gets.chomp.chars.map(&:ord).sort.reverse\ns << 0\nt << -1\n\nt.length.times{ |i|\n s_min = s[i]\n t_max = t[i]\n if s[i].nil? || s_min < t_max\n puts 'Yes'\n break\n elsif s_min > t_max\n puts 'No'\n break\n end\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given strings s and t, consisting of lowercase English letters.\nYou will create a string s' by freely rearranging the characters in s.\nYou will also create a string t' by freely rearranging the characters in t.\nDetermine whether it is possible to satisfy s' < t' for the lexicographic order.\n\nNotes\n\nFor a string a = a_1 a_2 ... a_N of length N and a string b = b_1 b_2 ... b_M of length M, we say a < b for the lexicographic order if either one of the following two conditions holds true:\n\nN < M and a_1 = b_1, a_2 = b_2, ..., a_N = b_N.\n\nThere exists i (1 \\leq i \\leq N, M) such that a_1 = b_1, a_2 = b_2, ..., a_{i - 1} = b_{i - 1} and a_i < b_i. Here, letters are compared using alphabetical order.\n\nFor example, xy < xya and atcoder < atlas.\n\nConstraints\n\nThe lengths of s and t are between 1 and 100 (inclusive).\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf it is possible to satisfy s' < t', print Yes; if it is not, print No.\n\nSample Input 1\n\nyx\naxy\n\nSample Output 1\n\nYes\n\nWe can, for example, rearrange yx into xy and axy into yxa. Then, xy < yxa.\n\nSample Input 2\n\nratcode\natlas\n\nSample Output 2\n\nYes\n\nWe can, for example, rearrange ratcode into acdeort and atlas into tslaa. Then, acdeort < tslaa.\n\nSample Input 3\n\ncd\nabc\n\nSample Output 3\n\nNo\n\nNo matter how we rearrange cd and abc, we cannot achieve our objective.\n\nSample Input 4\n\nw\nww\n\nSample Output 4\n\nYes\n\nSample Input 5\n\nzzz\nzzz\n\nSample Output 5\n\nNo", "sample_input": "yx\naxy\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03486", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given strings s and t, consisting of lowercase English letters.\nYou will create a string s' by freely rearranging the characters in s.\nYou will also create a string t' by freely rearranging the characters in t.\nDetermine whether it is possible to satisfy s' < t' for the lexicographic order.\n\nNotes\n\nFor a string a = a_1 a_2 ... a_N of length N and a string b = b_1 b_2 ... b_M of length M, we say a < b for the lexicographic order if either one of the following two conditions holds true:\n\nN < M and a_1 = b_1, a_2 = b_2, ..., a_N = b_N.\n\nThere exists i (1 \\leq i \\leq N, M) such that a_1 = b_1, a_2 = b_2, ..., a_{i - 1} = b_{i - 1} and a_i < b_i. Here, letters are compared using alphabetical order.\n\nFor example, xy < xya and atcoder < atlas.\n\nConstraints\n\nThe lengths of s and t are between 1 and 100 (inclusive).\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf it is possible to satisfy s' < t', print Yes; if it is not, print No.\n\nSample Input 1\n\nyx\naxy\n\nSample Output 1\n\nYes\n\nWe can, for example, rearrange yx into xy and axy into yxa. Then, xy < yxa.\n\nSample Input 2\n\nratcode\natlas\n\nSample Output 2\n\nYes\n\nWe can, for example, rearrange ratcode into acdeort and atlas into tslaa. Then, acdeort < tslaa.\n\nSample Input 3\n\ncd\nabc\n\nSample Output 3\n\nNo\n\nNo matter how we rearrange cd and abc, we cannot achieve our objective.\n\nSample Input 4\n\nw\nww\n\nSample Output 4\n\nYes\n\nSample Input 5\n\nzzz\nzzz\n\nSample Output 5\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 259, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s620423521", "group_id": "codeNet:p03486", "input_text": "a = gets.chomp.split(\"\").sort\nb = gets.chomp.split(\"\").sort.reverse\nc = a.join(\"\")\nd = b.join(\"\")\nif c < d \n puts \"Yes\"\nelse\n puts \"No\"\nend", "language": "Ruby", "metadata": {"date": 1577763685, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03486.html", "problem_id": "p03486", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03486/input.txt", "sample_output_relpath": "derived/input_output/data/p03486/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03486/Ruby/s620423521.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s620423521", "user_id": "u945412921"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a = gets.chomp.split(\"\").sort\nb = gets.chomp.split(\"\").sort.reverse\nc = a.join(\"\")\nd = b.join(\"\")\nif c < d \n puts \"Yes\"\nelse\n puts \"No\"\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given strings s and t, consisting of lowercase English letters.\nYou will create a string s' by freely rearranging the characters in s.\nYou will also create a string t' by freely rearranging the characters in t.\nDetermine whether it is possible to satisfy s' < t' for the lexicographic order.\n\nNotes\n\nFor a string a = a_1 a_2 ... a_N of length N and a string b = b_1 b_2 ... b_M of length M, we say a < b for the lexicographic order if either one of the following two conditions holds true:\n\nN < M and a_1 = b_1, a_2 = b_2, ..., a_N = b_N.\n\nThere exists i (1 \\leq i \\leq N, M) such that a_1 = b_1, a_2 = b_2, ..., a_{i - 1} = b_{i - 1} and a_i < b_i. Here, letters are compared using alphabetical order.\n\nFor example, xy < xya and atcoder < atlas.\n\nConstraints\n\nThe lengths of s and t are between 1 and 100 (inclusive).\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf it is possible to satisfy s' < t', print Yes; if it is not, print No.\n\nSample Input 1\n\nyx\naxy\n\nSample Output 1\n\nYes\n\nWe can, for example, rearrange yx into xy and axy into yxa. Then, xy < yxa.\n\nSample Input 2\n\nratcode\natlas\n\nSample Output 2\n\nYes\n\nWe can, for example, rearrange ratcode into acdeort and atlas into tslaa. Then, acdeort < tslaa.\n\nSample Input 3\n\ncd\nabc\n\nSample Output 3\n\nNo\n\nNo matter how we rearrange cd and abc, we cannot achieve our objective.\n\nSample Input 4\n\nw\nww\n\nSample Output 4\n\nYes\n\nSample Input 5\n\nzzz\nzzz\n\nSample Output 5\n\nNo", "sample_input": "yx\naxy\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03486", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given strings s and t, consisting of lowercase English letters.\nYou will create a string s' by freely rearranging the characters in s.\nYou will also create a string t' by freely rearranging the characters in t.\nDetermine whether it is possible to satisfy s' < t' for the lexicographic order.\n\nNotes\n\nFor a string a = a_1 a_2 ... a_N of length N and a string b = b_1 b_2 ... b_M of length M, we say a < b for the lexicographic order if either one of the following two conditions holds true:\n\nN < M and a_1 = b_1, a_2 = b_2, ..., a_N = b_N.\n\nThere exists i (1 \\leq i \\leq N, M) such that a_1 = b_1, a_2 = b_2, ..., a_{i - 1} = b_{i - 1} and a_i < b_i. Here, letters are compared using alphabetical order.\n\nFor example, xy < xya and atcoder < atlas.\n\nConstraints\n\nThe lengths of s and t are between 1 and 100 (inclusive).\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf it is possible to satisfy s' < t', print Yes; if it is not, print No.\n\nSample Input 1\n\nyx\naxy\n\nSample Output 1\n\nYes\n\nWe can, for example, rearrange yx into xy and axy into yxa. Then, xy < yxa.\n\nSample Input 2\n\nratcode\natlas\n\nSample Output 2\n\nYes\n\nWe can, for example, rearrange ratcode into acdeort and atlas into tslaa. Then, acdeort < tslaa.\n\nSample Input 3\n\ncd\nabc\n\nSample Output 3\n\nNo\n\nNo matter how we rearrange cd and abc, we cannot achieve our objective.\n\nSample Input 4\n\nw\nww\n\nSample Output 4\n\nYes\n\nSample Input 5\n\nzzz\nzzz\n\nSample Output 5\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 141, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s683672913", "group_id": "codeNet:p03486", "input_text": "s = gets.chomp.chars.sort.join\nt = gets.chomp.chars.sort{|a, b| b <=> a}.join\nputs s < t ? \"Yes\" : \"No\"", "language": "Ruby", "metadata": {"date": 1577058458, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03486.html", "problem_id": "p03486", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03486/input.txt", "sample_output_relpath": "derived/input_output/data/p03486/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03486/Ruby/s683672913.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s683672913", "user_id": "u985350486"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "s = gets.chomp.chars.sort.join\nt = gets.chomp.chars.sort{|a, b| b <=> a}.join\nputs s < t ? \"Yes\" : \"No\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given strings s and t, consisting of lowercase English letters.\nYou will create a string s' by freely rearranging the characters in s.\nYou will also create a string t' by freely rearranging the characters in t.\nDetermine whether it is possible to satisfy s' < t' for the lexicographic order.\n\nNotes\n\nFor a string a = a_1 a_2 ... a_N of length N and a string b = b_1 b_2 ... b_M of length M, we say a < b for the lexicographic order if either one of the following two conditions holds true:\n\nN < M and a_1 = b_1, a_2 = b_2, ..., a_N = b_N.\n\nThere exists i (1 \\leq i \\leq N, M) such that a_1 = b_1, a_2 = b_2, ..., a_{i - 1} = b_{i - 1} and a_i < b_i. Here, letters are compared using alphabetical order.\n\nFor example, xy < xya and atcoder < atlas.\n\nConstraints\n\nThe lengths of s and t are between 1 and 100 (inclusive).\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf it is possible to satisfy s' < t', print Yes; if it is not, print No.\n\nSample Input 1\n\nyx\naxy\n\nSample Output 1\n\nYes\n\nWe can, for example, rearrange yx into xy and axy into yxa. Then, xy < yxa.\n\nSample Input 2\n\nratcode\natlas\n\nSample Output 2\n\nYes\n\nWe can, for example, rearrange ratcode into acdeort and atlas into tslaa. Then, acdeort < tslaa.\n\nSample Input 3\n\ncd\nabc\n\nSample Output 3\n\nNo\n\nNo matter how we rearrange cd and abc, we cannot achieve our objective.\n\nSample Input 4\n\nw\nww\n\nSample Output 4\n\nYes\n\nSample Input 5\n\nzzz\nzzz\n\nSample Output 5\n\nNo", "sample_input": "yx\naxy\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03486", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given strings s and t, consisting of lowercase English letters.\nYou will create a string s' by freely rearranging the characters in s.\nYou will also create a string t' by freely rearranging the characters in t.\nDetermine whether it is possible to satisfy s' < t' for the lexicographic order.\n\nNotes\n\nFor a string a = a_1 a_2 ... a_N of length N and a string b = b_1 b_2 ... b_M of length M, we say a < b for the lexicographic order if either one of the following two conditions holds true:\n\nN < M and a_1 = b_1, a_2 = b_2, ..., a_N = b_N.\n\nThere exists i (1 \\leq i \\leq N, M) such that a_1 = b_1, a_2 = b_2, ..., a_{i - 1} = b_{i - 1} and a_i < b_i. Here, letters are compared using alphabetical order.\n\nFor example, xy < xya and atcoder < atlas.\n\nConstraints\n\nThe lengths of s and t are between 1 and 100 (inclusive).\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf it is possible to satisfy s' < t', print Yes; if it is not, print No.\n\nSample Input 1\n\nyx\naxy\n\nSample Output 1\n\nYes\n\nWe can, for example, rearrange yx into xy and axy into yxa. Then, xy < yxa.\n\nSample Input 2\n\nratcode\natlas\n\nSample Output 2\n\nYes\n\nWe can, for example, rearrange ratcode into acdeort and atlas into tslaa. Then, acdeort < tslaa.\n\nSample Input 3\n\ncd\nabc\n\nSample Output 3\n\nNo\n\nNo matter how we rearrange cd and abc, we cannot achieve our objective.\n\nSample Input 4\n\nw\nww\n\nSample Output 4\n\nYes\n\nSample Input 5\n\nzzz\nzzz\n\nSample Output 5\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 103, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s997986706", "group_id": "codeNet:p03486", "input_text": "s =gets.split('')\nt =gets.split('')\n\nS = s.sort\nT = t.sort\n\nif -1 == ( S <=> T )\n puts 'Yes'\nelse\n puts 'No'\nend", "language": "Ruby", "metadata": {"date": 1566334390, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03486.html", "problem_id": "p03486", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03486/input.txt", "sample_output_relpath": "derived/input_output/data/p03486/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03486/Ruby/s997986706.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s997986706", "user_id": "u533566373"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "s =gets.split('')\nt =gets.split('')\n\nS = s.sort\nT = t.sort\n\nif -1 == ( S <=> T )\n puts 'Yes'\nelse\n puts 'No'\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given strings s and t, consisting of lowercase English letters.\nYou will create a string s' by freely rearranging the characters in s.\nYou will also create a string t' by freely rearranging the characters in t.\nDetermine whether it is possible to satisfy s' < t' for the lexicographic order.\n\nNotes\n\nFor a string a = a_1 a_2 ... a_N of length N and a string b = b_1 b_2 ... b_M of length M, we say a < b for the lexicographic order if either one of the following two conditions holds true:\n\nN < M and a_1 = b_1, a_2 = b_2, ..., a_N = b_N.\n\nThere exists i (1 \\leq i \\leq N, M) such that a_1 = b_1, a_2 = b_2, ..., a_{i - 1} = b_{i - 1} and a_i < b_i. Here, letters are compared using alphabetical order.\n\nFor example, xy < xya and atcoder < atlas.\n\nConstraints\n\nThe lengths of s and t are between 1 and 100 (inclusive).\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf it is possible to satisfy s' < t', print Yes; if it is not, print No.\n\nSample Input 1\n\nyx\naxy\n\nSample Output 1\n\nYes\n\nWe can, for example, rearrange yx into xy and axy into yxa. Then, xy < yxa.\n\nSample Input 2\n\nratcode\natlas\n\nSample Output 2\n\nYes\n\nWe can, for example, rearrange ratcode into acdeort and atlas into tslaa. Then, acdeort < tslaa.\n\nSample Input 3\n\ncd\nabc\n\nSample Output 3\n\nNo\n\nNo matter how we rearrange cd and abc, we cannot achieve our objective.\n\nSample Input 4\n\nw\nww\n\nSample Output 4\n\nYes\n\nSample Input 5\n\nzzz\nzzz\n\nSample Output 5\n\nNo", "sample_input": "yx\naxy\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03486", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given strings s and t, consisting of lowercase English letters.\nYou will create a string s' by freely rearranging the characters in s.\nYou will also create a string t' by freely rearranging the characters in t.\nDetermine whether it is possible to satisfy s' < t' for the lexicographic order.\n\nNotes\n\nFor a string a = a_1 a_2 ... a_N of length N and a string b = b_1 b_2 ... b_M of length M, we say a < b for the lexicographic order if either one of the following two conditions holds true:\n\nN < M and a_1 = b_1, a_2 = b_2, ..., a_N = b_N.\n\nThere exists i (1 \\leq i \\leq N, M) such that a_1 = b_1, a_2 = b_2, ..., a_{i - 1} = b_{i - 1} and a_i < b_i. Here, letters are compared using alphabetical order.\n\nFor example, xy < xya and atcoder < atlas.\n\nConstraints\n\nThe lengths of s and t are between 1 and 100 (inclusive).\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf it is possible to satisfy s' < t', print Yes; if it is not, print No.\n\nSample Input 1\n\nyx\naxy\n\nSample Output 1\n\nYes\n\nWe can, for example, rearrange yx into xy and axy into yxa. Then, xy < yxa.\n\nSample Input 2\n\nratcode\natlas\n\nSample Output 2\n\nYes\n\nWe can, for example, rearrange ratcode into acdeort and atlas into tslaa. Then, acdeort < tslaa.\n\nSample Input 3\n\ncd\nabc\n\nSample Output 3\n\nNo\n\nNo matter how we rearrange cd and abc, we cannot achieve our objective.\n\nSample Input 4\n\nw\nww\n\nSample Output 4\n\nYes\n\nSample Input 5\n\nzzz\nzzz\n\nSample Output 5\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 114, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s129138238", "group_id": "codeNet:p03486", "input_text": "s=gets.chomp.split(\"\").sort.join\nt=gets.chomp.split(\"\").sort.reverse.join\nputs s= 0\n nums[y] += nums[i]\n logs << [i + 1, y + 1]\n else\n nums[i] += nums[y]\n logs << [y + 1, i + 1]\n end\n m += 1\n else\n i += 1\n end\nend\n\nputs m\nlogs.each { |x, y| puts \"#{x} #{y}\" }", "language": "Ruby", "metadata": {"date": 1513470839, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03498.html", "problem_id": "p03498", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03498/input.txt", "sample_output_relpath": "derived/input_output/data/p03498/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03498/Ruby/s884093780.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s884093780", "user_id": "u769941411"}, "prompt_components": {"gold_output": "2\n2 3\n3 3\n", "input_to_evaluate": "n = gets.to_i\nnums = gets.split(\" \").map(&:to_i)\n\ni = 0\nm = 0\nlogs = []\n\nwhile\n y = i + 1\n break unless nums[y] \n unless nums[i] <= nums[y]\n if nums[i] >= 0\n nums[y] += nums[i]\n logs << [i + 1, y + 1]\n else\n nums[i] += nums[y]\n logs << [y + 1, i + 1]\n end\n m += 1\n else\n i += 1\n end\nend\n\nputs m\nlogs.each { |x, y| puts \"#{x} #{y}\" }", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke has an integer sequence, a, of length N. The i-th element of a (1-indexed) is a_{i}.\n\nHe can perform the following operation any number of times:\n\nOperation: Choose integers x and y between 1 and N (inclusive), and add a_x to a_y.\n\nHe would like to perform this operation between 0 and 2N times (inclusive) so that a satisfies the condition below. Show one such sequence of operations.\nIt can be proved that such a sequence of operations always exists under the constraints in this problem.\n\nCondition: a_1 \\leq a_2 \\leq ... \\leq a_{N}\n\nConstraints\n\n2 \\leq N \\leq 50\n\n-10^{6} \\leq a_i \\leq 10^{6}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{N}\n\nOutput\n\nLet m be the number of operations in your solution. In the first line, print m.\nIn the i-th of the subsequent m lines, print the numbers x and y chosen in the i-th operation, with a space in between.\nThe output will be considered correct if m is between 0 and 2N (inclusive) and a satisfies the condition after the m operations.\n\nSample Input 1\n\n3\n-2 5 -1\n\nSample Output 1\n\n2\n2 3\n3 3\n\nAfter the first operation, a = (-2,5,4).\n\nAfter the second operation, a = (-2,5,8), and the condition is now satisfied.\n\nSample Input 2\n\n2\n-1 -3\n\nSample Output 2\n\n1\n2 1\n\nAfter the first operation, a = (-4,-3) and the condition is now satisfied.\n\nSample Input 3\n\n5\n0 0 0 0 0\n\nSample Output 3\n\n0\n\nThe condition is satisfied already in the beginning.", "sample_input": "3\n-2 5 -1\n"}, "reference_outputs": ["2\n2 3\n3 3\n"], "source_document_id": "p03498", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke has an integer sequence, a, of length N. The i-th element of a (1-indexed) is a_{i}.\n\nHe can perform the following operation any number of times:\n\nOperation: Choose integers x and y between 1 and N (inclusive), and add a_x to a_y.\n\nHe would like to perform this operation between 0 and 2N times (inclusive) so that a satisfies the condition below. Show one such sequence of operations.\nIt can be proved that such a sequence of operations always exists under the constraints in this problem.\n\nCondition: a_1 \\leq a_2 \\leq ... \\leq a_{N}\n\nConstraints\n\n2 \\leq N \\leq 50\n\n-10^{6} \\leq a_i \\leq 10^{6}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{N}\n\nOutput\n\nLet m be the number of operations in your solution. In the first line, print m.\nIn the i-th of the subsequent m lines, print the numbers x and y chosen in the i-th operation, with a space in between.\nThe output will be considered correct if m is between 0 and 2N (inclusive) and a satisfies the condition after the m operations.\n\nSample Input 1\n\n3\n-2 5 -1\n\nSample Output 1\n\n2\n2 3\n3 3\n\nAfter the first operation, a = (-2,5,4).\n\nAfter the second operation, a = (-2,5,8), and the condition is now satisfied.\n\nSample Input 2\n\n2\n-1 -3\n\nSample Output 2\n\n1\n2 1\n\nAfter the first operation, a = (-4,-3) and the condition is now satisfied.\n\nSample Input 3\n\n5\n0 0 0 0 0\n\nSample Output 3\n\n0\n\nThe condition is satisfied already in the beginning.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 372, "cpu_time_ms": 2132, "memory_kb": 321916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s266252735", "group_id": "codeNet:p03501", "input_text": "n, a, b = gets.chomp.split.map(&:to_i)\nputs [n*a, b].min\n", "language": "Ruby", "metadata": {"date": 1566000941, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03501.html", "problem_id": "p03501", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03501/input.txt", "sample_output_relpath": "derived/input_output/data/p03501/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03501/Ruby/s266252735.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s266252735", "user_id": "u744908753"}, "prompt_components": {"gold_output": "119\n", "input_to_evaluate": "n, a, b = gets.chomp.split.map(&:to_i)\nputs [n*a, b].min\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are parking at a parking lot. You can choose from the following two fee plans:\n\nPlan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.\n\nPlan 2: The fee will be B yen, regardless of the duration.\n\nFind the minimum fee when you park for N hours.\n\nConstraints\n\n1≤N≤20\n\n1≤A≤100\n\n1≤B≤2000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nWhen the minimum fee is x yen, print the value of x.\n\nSample Input 1\n\n7 17 120\n\nSample Output 1\n\n119\n\nIf you choose Plan 1, the fee will be 7×17=119 yen.\n\nIf you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\nSample Input 2\n\n5 20 100\n\nSample Output 2\n\n100\n\nThe fee might be the same in the two plans.\n\nSample Input 3\n\n6 18 100\n\nSample Output 3\n\n100", "sample_input": "7 17 120\n"}, "reference_outputs": ["119\n"], "source_document_id": "p03501", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are parking at a parking lot. You can choose from the following two fee plans:\n\nPlan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.\n\nPlan 2: The fee will be B yen, regardless of the duration.\n\nFind the minimum fee when you park for N hours.\n\nConstraints\n\n1≤N≤20\n\n1≤A≤100\n\n1≤B≤2000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nWhen the minimum fee is x yen, print the value of x.\n\nSample Input 1\n\n7 17 120\n\nSample Output 1\n\n119\n\nIf you choose Plan 1, the fee will be 7×17=119 yen.\n\nIf you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\nSample Input 2\n\n5 20 100\n\nSample Output 2\n\n100\n\nThe fee might be the same in the two plans.\n\nSample Input 3\n\n6 18 100\n\nSample Output 3\n\n100", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 57, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s635341524", "group_id": "codeNet:p03502", "input_text": "n = gets\nf = n.chars.map(&:to_i).reduce(:+)\n(n.to_i % f == 0) ? puts('Yes') : puts('No')", "language": "Ruby", "metadata": {"date": 1547567846, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s635341524.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s635341524", "user_id": "u523130469"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "n = gets\nf = n.chars.map(&:to_i).reduce(:+)\n(n.to_i % f == 0) ? puts('Yes') : puts('No')", "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": 88, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s036927729", "group_id": "codeNet:p03504", "input_text": "#input of int(split by space)\ndef get_i()\n return gets.chomp.split(\" \").map(&:to_i)\nend\n#input of float(split by space)\ndef get_f()\n return gets.chomp.split(\" \").map(&:to_f)\nend\n#input of string(split by space)\ndef get()\n return gets.chomp.split(\" \")\nend\n#input of string(split per one character)\ndef get_nsp()\n return gets.chomp.split(\"\")\nend\n#yes or no decision\ndef yn_judge(bool,y=\"Yes\",n=\"No\")\n return bool ? y : n \nend\n#create of array\ndef array(size1,init=nil,size2=-1)\n if size2==-1\n return Array.new(size1){init}\n else\n return Array.new(size2){Array.new(size1){init}}\n end\nend\n\ndef max(a,b)\n return a>b ? a : b\nend\n\ndef min(a,b)\n return a>b ? b : a\nend\n\nINF=Float::INFINITY\n\nN,C=get_i\ntable=array(10**5,0)\nN.times do|i|\n s,t,c=get_i\n s-=1\n t-=1\n table[s]+=1\n table[t+1]-=1\nend\nimos=array(10**5+1,0)\nans=0\n(10**5).times do|i|\n imos[i+1]+=imos[i]+table[i]\n ans=max(ans,imos[i+1])\nend\n#p imos[0..20]\nputs ans", "language": "Ruby", "metadata": {"date": 1596994412, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p03504.html", "problem_id": "p03504", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03504/input.txt", "sample_output_relpath": "derived/input_output/data/p03504/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03504/Ruby/s036927729.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s036927729", "user_id": "u415400221"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#input of int(split by space)\ndef get_i()\n return gets.chomp.split(\" \").map(&:to_i)\nend\n#input of float(split by space)\ndef get_f()\n return gets.chomp.split(\" \").map(&:to_f)\nend\n#input of string(split by space)\ndef get()\n return gets.chomp.split(\" \")\nend\n#input of string(split per one character)\ndef get_nsp()\n return gets.chomp.split(\"\")\nend\n#yes or no decision\ndef yn_judge(bool,y=\"Yes\",n=\"No\")\n return bool ? y : n \nend\n#create of array\ndef array(size1,init=nil,size2=-1)\n if size2==-1\n return Array.new(size1){init}\n else\n return Array.new(size2){Array.new(size1){init}}\n end\nend\n\ndef max(a,b)\n return a>b ? a : b\nend\n\ndef min(a,b)\n return a>b ? b : a\nend\n\nINF=Float::INFINITY\n\nN,C=get_i\ntable=array(10**5,0)\nN.times do|i|\n s,t,c=get_i\n s-=1\n t-=1\n table[s]+=1\n table[t+1]-=1\nend\nimos=array(10**5+1,0)\nans=0\n(10**5).times do|i|\n imos[i+1]+=imos[i]+table[i]\n ans=max(ans,imos[i+1])\nend\n#p imos[0..20]\nputs ans", "problem_context": "Score : 400 points\n\nProblem Statement\n\nJoisino is planning to record N TV programs with recorders.\n\nThe TV can receive C channels numbered 1 through C.\n\nThe i-th program that she wants to record will be broadcast from time s_i to time t_i (including time s_i but not t_i) on Channel c_i.\n\nHere, there will never be more than one program that are broadcast on the same channel at the same time.\n\nWhen the recorder is recording a channel from time S to time T (including time S but not T), it cannot record other channels from time S-0.5 to time T (including time S-0.5 but not T).\n\nFind the minimum number of recorders required to record the channels so that all the N programs are completely recorded.\n\nConstraints\n\n1≤N≤10^5\n\n1≤C≤30\n\n1≤s_i c[i][j] + c[j][1]\n end\nend\n\nans = 0\nh.times {gets.split.each {|e| ans += c[e.to_i][1]}}\nputs ans", "language": "Ruby", "metadata": {"date": 1586726504, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03546.html", "problem_id": "p03546", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03546/input.txt", "sample_output_relpath": "derived/input_output/data/p03546/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03546/Ruby/s793498870.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s793498870", "user_id": "u692254521"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "h, w = gets.split.map(&:to_i)\nc = 10.times.map {gets.split.map(&:to_i)}\nc << [0, 0]\n\n10.times do |i|\n 10.times do |j|\n c[i][1] = c[i][j] + c[j][1] if c[i][1] > c[i][j] + c[j][1]\n end\nend\n\nans = 0\nh.times {gets.split.each {|e| ans += c[e.to_i][1]}}\nputs ans", "problem_context": "Score : 400 points\n\nProblem Statement\n\nJoisino the magical girl has decided to turn every single digit that exists on this world into 1.\n\nRewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points).\n\nShe is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and 9 (inclusive).\n\nYou are given A_{i,j} that describes the square at the i-th row from the top and j-th column from the left, as follows:\n\nIf A_{i,j}≠-1, the square contains a digit A_{i,j}.\n\nIf A_{i,j}=-1, the square does not contain a digit.\n\nFind the minimum total amount of MP required to turn every digit on this wall into 1 in the end.\n\nConstraints\n\n1≤H,W≤200\n\n1≤c_{i,j}≤10^3 (i≠j)\n\nc_{i,j}=0 (i=j)\n\n-1≤A_{i,j}≤9\n\nAll input values are integers.\n\nThere is at least one digit on the wall.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nc_{0,0} ... c_{0,9}\n:\nc_{9,0} ... c_{9,9}\nA_{1,1} ... A_{1,W}\n:\nA_{H,1} ... A_{H,W}\n\nOutput\n\nPrint the minimum total amount of MP required to turn every digit on the wall into 1 in the end.\n\nSample Input 1\n\n2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 9 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8\n\nSample Output 1\n\n12\n\nTo turn a single 8 into 1, it is optimal to first turn 8 into 4, then turn 4 into 9, and finally turn 9 into 1, costing 6 MP.\n\nThe wall contains two 8s, so the minimum total MP required is 6×2=12.\n\nSample Input 2\n\n5 5\n0 999 999 999 999 999 999 999 999 999\n999 0 999 999 999 999 999 999 999 999\n999 999 0 999 999 999 999 999 999 999\n999 999 999 0 999 999 999 999 999 999\n999 999 999 999 0 999 999 999 999 999\n999 999 999 999 999 0 999 999 999 999\n999 999 999 999 999 999 0 999 999 999\n999 999 999 999 999 999 999 0 999 999\n999 999 999 999 999 999 999 999 0 999\n999 999 999 999 999 999 999 999 999 0\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n\nSample Output 2\n\n0\n\nNote that she may not need to change any digit.\n\nSample Input 3\n\n3 5\n0 4 3 6 2 7 2 5 3 3\n4 0 5 3 7 5 3 7 2 7\n5 7 0 7 2 9 3 2 9 1\n3 6 2 0 2 4 6 4 2 3\n3 5 7 4 0 6 9 7 6 7\n9 8 5 2 2 0 4 7 6 5\n5 4 6 3 2 3 0 5 4 3\n3 6 2 3 4 2 4 0 8 9\n4 6 5 4 3 5 3 2 0 8\n2 1 3 4 5 7 8 6 4 0\n3 5 2 6 1\n2 5 3 2 1\n6 9 2 5 6\n\nSample Output 3\n\n47", "sample_input": "2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 9 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03546", "source_text": "Score : 400 points\n\nProblem Statement\n\nJoisino the magical girl has decided to turn every single digit that exists on this world into 1.\n\nRewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points).\n\nShe is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and 9 (inclusive).\n\nYou are given A_{i,j} that describes the square at the i-th row from the top and j-th column from the left, as follows:\n\nIf A_{i,j}≠-1, the square contains a digit A_{i,j}.\n\nIf A_{i,j}=-1, the square does not contain a digit.\n\nFind the minimum total amount of MP required to turn every digit on this wall into 1 in the end.\n\nConstraints\n\n1≤H,W≤200\n\n1≤c_{i,j}≤10^3 (i≠j)\n\nc_{i,j}=0 (i=j)\n\n-1≤A_{i,j}≤9\n\nAll input values are integers.\n\nThere is at least one digit on the wall.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nc_{0,0} ... c_{0,9}\n:\nc_{9,0} ... c_{9,9}\nA_{1,1} ... A_{1,W}\n:\nA_{H,1} ... A_{H,W}\n\nOutput\n\nPrint the minimum total amount of MP required to turn every digit on the wall into 1 in the end.\n\nSample Input 1\n\n2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 9 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8\n\nSample Output 1\n\n12\n\nTo turn a single 8 into 1, it is optimal to first turn 8 into 4, then turn 4 into 9, and finally turn 9 into 1, costing 6 MP.\n\nThe wall contains two 8s, so the minimum total MP required is 6×2=12.\n\nSample Input 2\n\n5 5\n0 999 999 999 999 999 999 999 999 999\n999 0 999 999 999 999 999 999 999 999\n999 999 0 999 999 999 999 999 999 999\n999 999 999 0 999 999 999 999 999 999\n999 999 999 999 0 999 999 999 999 999\n999 999 999 999 999 0 999 999 999 999\n999 999 999 999 999 999 0 999 999 999\n999 999 999 999 999 999 999 0 999 999\n999 999 999 999 999 999 999 999 0 999\n999 999 999 999 999 999 999 999 999 0\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n\nSample Output 2\n\n0\n\nNote that she may not need to change any digit.\n\nSample Input 3\n\n3 5\n0 4 3 6 2 7 2 5 3 3\n4 0 5 3 7 5 3 7 2 7\n5 7 0 7 2 9 3 2 9 1\n3 6 2 0 2 4 6 4 2 3\n3 5 7 4 0 6 9 7 6 7\n9 8 5 2 2 0 4 7 6 5\n5 4 6 3 2 3 0 5 4 3\n3 6 2 3 4 2 4 0 8 9\n4 6 5 4 3 5 3 2 0 8\n2 1 3 4 5 7 8 6 4 0\n3 5 2 6 1\n2 5 3 2 1\n6 9 2 5 6\n\nSample Output 3\n\n47", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 269, "cpu_time_ms": 20, "memory_kb": 2300}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s167231250", "group_id": "codeNet:p03548", "input_text": "def get_i() #空白区切の入力を数値(整数)の配列で返す\n return gets.chomp.split(\" \").map(&:to_i)\nend\ndef get_f() #空白区切の入力を数値(実数)の配列で返す\n return gets.chomp.split(\" \").map(&:to_f)\nend\ndef get() #空白区切の入力を文字列の配列で返す\n return gets.chomp.split(\" \")\nend\ndef get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す\n return gets.chomp.split(\"\")\nend\ndef yn_judge(bool,y=\"Yes\",n=\"No\") #boolに真偽を投げることで、trueならy、falseならnの値を出力する\n return bool ? y : n \nend\ndef array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す\n if size2==-1\n return Array.new(size1){init}\n else\n return Array.new(size2){Array.new(size1){init}}\n end\nend\n\nX,Y,Z=get_i\nputs (X-Z)/(Y+Z)", "language": "Ruby", "metadata": {"date": 1586962860, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03548.html", "problem_id": "p03548", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03548/input.txt", "sample_output_relpath": "derived/input_output/data/p03548/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03548/Ruby/s167231250.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s167231250", "user_id": "u415400221"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "def get_i() #空白区切の入力を数値(整数)の配列で返す\n return gets.chomp.split(\" \").map(&:to_i)\nend\ndef get_f() #空白区切の入力を数値(実数)の配列で返す\n return gets.chomp.split(\" \").map(&:to_f)\nend\ndef get() #空白区切の入力を文字列の配列で返す\n return gets.chomp.split(\" \")\nend\ndef get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す\n return gets.chomp.split(\"\")\nend\ndef yn_judge(bool,y=\"Yes\",n=\"No\") #boolに真偽を投げることで、trueならy、falseならnの値を出力する\n return bool ? y : n \nend\ndef array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す\n if size2==-1\n return Array.new(size1){init}\n else\n return Array.new(size2){Array.new(size1){init}}\n end\nend\n\nX,Y,Z=get_i\nputs (X-Z)/(Y+Z)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a long seat of width X centimeters.\nThere are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters.\n\nWe would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person.\n\nAt most how many people can sit on the seat?\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq X, Y, Z \\leq 10^5\n\nY+2Z \\leq X\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y Z\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n13 3 1\n\nSample Output 1\n\n3\n\nThere is just enough room for three, as shown below:\n\nFigure\n\nSample Input 2\n\n12 3 1\n\nSample Output 2\n\n2\n\nSample Input 3\n\n100000 1 1\n\nSample Output 3\n\n49999\n\nSample Input 4\n\n64146 123 456\n\nSample Output 4\n\n110\n\nSample Input 5\n\n64145 123 456\n\nSample Output 5\n\n109", "sample_input": "13 3 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03548", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a long seat of width X centimeters.\nThere are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters.\n\nWe would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person.\n\nAt most how many people can sit on the seat?\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq X, Y, Z \\leq 10^5\n\nY+2Z \\leq X\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y Z\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n13 3 1\n\nSample Output 1\n\n3\n\nThere is just enough room for three, as shown below:\n\nFigure\n\nSample Input 2\n\n12 3 1\n\nSample Output 2\n\n2\n\nSample Input 3\n\n100000 1 1\n\nSample Output 3\n\n49999\n\nSample Input 4\n\n64146 123 456\n\nSample Output 4\n\n110\n\nSample Input 5\n\n64145 123 456\n\nSample Output 5\n\n109", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 937, "cpu_time_ms": 8, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s697463906", "group_id": "codeNet:p03556", "input_text": "p (gets.to_i**0.5).to_i**2", "language": "Ruby", "metadata": {"date": 1509851028, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03556.html", "problem_id": "p03556", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03556/input.txt", "sample_output_relpath": "derived/input_output/data/p03556/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03556/Ruby/s697463906.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s697463906", "user_id": "u711705317"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "p (gets.to_i**0.5).to_i**2", "problem_context": "Score : 200 points\n\nProblem Statement\n\nFind the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the largest square number not exceeding N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\n10 is not square, but 9 = 3 × 3 is. Thus, we print 9.\n\nSample Input 2\n\n81\n\nSample Output 2\n\n81\n\nSample Input 3\n\n271828182\n\nSample Output 3\n\n271821169", "sample_input": "10\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03556", "source_text": "Score : 200 points\n\nProblem Statement\n\nFind the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the largest square number not exceeding N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\n10 is not square, but 9 = 3 × 3 is. Thus, we print 9.\n\nSample Input 2\n\n81\n\nSample Output 2\n\n81\n\nSample Input 3\n\n271828182\n\nSample Output 3\n\n271821169", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 26, "cpu_time_ms": 7, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s628290342", "group_id": "codeNet:p03557", "input_text": "def inpf() a=gets.chomp.split(\" \").map(&:to_f)end\n\ndef inps() a=gets.chomp.split(\" \")end\n\ndef copy(a) Marshal.load(Marshal.dump(a)) end\n\ndef kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end\n\ndef na(n,d=0) Array.new(n,d)end\n\ndef na2(n,m,d=0) Array.new(n){Array.new(m,d)}end\n\ndef na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end\n\ndef inp() a=gets.chomp.split(\" \").map(&:to_i)end\n\ndef r_up(a, b) (a+b-1)/b end\n\ndef r_sort(a) a.sort{|a,b|b<=>a} end\n\ndef b_ser(bot, top, a, target, u_r_f = nil, mm = nil)\n mid = (bot + top)/2\n if(a[mid] == target)\n if(u_r_f == nil)\n return mid\n else\n return mid if(bot == mid)\n return b_ser(bot, mid, a, target, u_r_f, mid)\n end\n end\n if(bot == mid)\n return nil if(u_r_f == nil)\n return mid + ((a[mid] < target)? 1 : 0)\n end\n return (a[mid] > target)? b_ser(bot, mid, a, target, u_r_f, mm) : b_ser(mid, top, a, target, u_r_f, mm)\nend\n\nn = inp[0]\na = inp.sort\nb = inp.sort\nc = inp.sort\nabt = []\na.size.times do |i|\n abt[i] = b_ser(0,n,b,a[i]+1,true)\nend\nbct = []\nb.size.times do |i|\n bct[i] = b_ser(0,n,c,b[i]+1,true)\nend\n\nbcs = na(n,0)\nsum = 0\nn.times do |i|\n i = n-i-1\n sum += n - bct[i]\n bcs[i] = sum\nend\nans = 0\nabt.each do |d|\n break if d >= n\n ans += bcs[d]\nend\np ans", "language": "Ruby", "metadata": {"date": 1567150502, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s628290342.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s628290342", "user_id": "u145123922"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "def inpf() a=gets.chomp.split(\" \").map(&:to_f)end\n\ndef inps() a=gets.chomp.split(\" \")end\n\ndef copy(a) Marshal.load(Marshal.dump(a)) end\n\ndef kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end\n\ndef na(n,d=0) Array.new(n,d)end\n\ndef na2(n,m,d=0) Array.new(n){Array.new(m,d)}end\n\ndef na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end\n\ndef inp() a=gets.chomp.split(\" \").map(&:to_i)end\n\ndef r_up(a, b) (a+b-1)/b end\n\ndef r_sort(a) a.sort{|a,b|b<=>a} end\n\ndef b_ser(bot, top, a, target, u_r_f = nil, mm = nil)\n mid = (bot + top)/2\n if(a[mid] == target)\n if(u_r_f == nil)\n return mid\n else\n return mid if(bot == mid)\n return b_ser(bot, mid, a, target, u_r_f, mid)\n end\n end\n if(bot == mid)\n return nil if(u_r_f == nil)\n return mid + ((a[mid] < target)? 1 : 0)\n end\n return (a[mid] > target)? b_ser(bot, mid, a, target, u_r_f, mm) : b_ser(mid, top, a, target, u_r_f, mm)\nend\n\nn = inp[0]\na = inp.sort\nb = inp.sort\nc = inp.sort\nabt = []\na.size.times do |i|\n abt[i] = b_ser(0,n,b,a[i]+1,true)\nend\nbct = []\nb.size.times do |i|\n bct[i] = b_ser(0,n,c,b[i]+1,true)\nend\n\nbcs = na(n,0)\nsum = 0\nn.times do |i|\n i = n-i-1\n sum += n - bct[i]\n bcs[i] = sum\nend\nans = 0\nabt.each do |d|\n break if d >= n\n ans += bcs[d]\nend\np ans", "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": 1283, "cpu_time_ms": 803, "memory_kb": 27288}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s138575061", "group_id": "codeNet:p03557", "input_text": "n = gets.chomp.to_i\na = gets.chomp.split.map(&:to_i).sort\nb = gets.chomp.split.map(&:to_i).sort\nc = gets.chomp.split.map(&:to_i).sort\n \nres = b.inject(0) do |r, bi|\n ai = a.bsearch_index{ |x| x >= bi }\n ci = c.bsearch_index{ |x| x > bi }\n \n if ai and ci\n r + (ai)*(n-ci)\n else\n r\n end\nend\n \nputs res", "language": "Ruby", "metadata": {"date": 1509856639, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s138575061.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s138575061", "user_id": "u664737319"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "n = gets.chomp.to_i\na = gets.chomp.split.map(&:to_i).sort\nb = gets.chomp.split.map(&:to_i).sort\nc = gets.chomp.split.map(&:to_i).sort\n \nres = b.inject(0) do |r, bi|\n ai = a.bsearch_index{ |x| x >= bi }\n ci = c.bsearch_index{ |x| x > bi }\n \n if ai and ci\n r + (ai)*(n-ci)\n else\n r\n end\nend\n \nputs res", "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": 311, "cpu_time_ms": 365, "memory_kb": 26804}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s120875223", "group_id": "codeNet:p03568", "input_text": "N = gets.to_i\nA = gets.split.map &:to_i\np 3**N-2**A.count(&:even?)", "language": "Ruby", "metadata": {"date": 1508721900, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03568.html", "problem_id": "p03568", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03568/input.txt", "sample_output_relpath": "derived/input_output/data/p03568/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03568/Ruby/s120875223.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s120875223", "user_id": "u711705317"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "N = gets.to_i\nA = gets.split.map &:to_i\np 3**N-2**A.count(&:even?)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe will say that two integer sequences of length N, x_1, x_2, ..., x_N and y_1, y_2, ..., y_N, are similar when |x_i - y_i| \\leq 1 holds for all i (1 \\leq i \\leq N).\n\nIn particular, any integer sequence is similar to itself.\n\nYou are given an integer N and an integer sequence of length N, A_1, A_2, ..., A_N.\n\nHow many integer sequences b_1, b_2, ..., b_N are there such that b_1, b_2, ..., b_N is similar to A and the product of all elements, b_1 b_2 ... b_N, is even?\n\nConstraints\n\n1 \\leq N \\leq 10\n\n1 \\leq A_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of integer sequences that satisfy the condition.\n\nSample Input 1\n\n2\n2 3\n\nSample Output 1\n\n7\n\nThere are seven integer sequences that satisfy the condition:\n\n1, 2\n\n1, 4\n\n2, 2\n\n2, 3\n\n2, 4\n\n3, 2\n\n3, 4\n\nSample Input 2\n\n3\n3 3 3\n\nSample Output 2\n\n26\n\nSample Input 3\n\n1\n100\n\nSample Output 3\n\n1\n\nSample Input 4\n\n10\n90 52 56 71 44 8 13 30 57 84\n\nSample Output 4\n\n58921", "sample_input": "2\n2 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03568", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe will say that two integer sequences of length N, x_1, x_2, ..., x_N and y_1, y_2, ..., y_N, are similar when |x_i - y_i| \\leq 1 holds for all i (1 \\leq i \\leq N).\n\nIn particular, any integer sequence is similar to itself.\n\nYou are given an integer N and an integer sequence of length N, A_1, A_2, ..., A_N.\n\nHow many integer sequences b_1, b_2, ..., b_N are there such that b_1, b_2, ..., b_N is similar to A and the product of all elements, b_1 b_2 ... b_N, is even?\n\nConstraints\n\n1 \\leq N \\leq 10\n\n1 \\leq A_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of integer sequences that satisfy the condition.\n\nSample Input 1\n\n2\n2 3\n\nSample Output 1\n\n7\n\nThere are seven integer sequences that satisfy the condition:\n\n1, 2\n\n1, 4\n\n2, 2\n\n2, 3\n\n2, 4\n\n3, 2\n\n3, 4\n\nSample Input 2\n\n3\n3 3 3\n\nSample Output 2\n\n26\n\nSample Input 3\n\n1\n100\n\nSample Output 3\n\n1\n\nSample Input 4\n\n10\n90 52 56 71 44 8 13 30 57 84\n\nSample Output 4\n\n58921", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 66, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s673744078", "group_id": "codeNet:p03573", "input_text": "a, b, c = gets.chomp.split(\" \").map(&:to_i)\nif a == b\n\tputs c\nelsif a == c\n\tputs b\nelse\n\tputs a\nend\n", "language": "Ruby", "metadata": {"date": 1508029333, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03573.html", "problem_id": "p03573", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03573/input.txt", "sample_output_relpath": "derived/input_output/data/p03573/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03573/Ruby/s673744078.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s673744078", "user_id": "u136468939"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "a, b, c = gets.chomp.split(\" \").map(&:to_i)\nif a == b\n\tputs c\nelsif a == c\n\tputs b\nelse\n\tputs a\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers, A, B and C.\n\nAmong them, two are the same, but the remaining one is different from the rest.\n\nFor example, when A=5,B=7,C=5, A and C are the same, but B is different.\n\nFind the one that is different from the rest among the given three integers.\n\nConstraints\n\n-100 \\leq A,B,C \\leq 100\n\nA, B and C are integers.\n\nThe input satisfies the condition in the statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nAmong A, B and C, print the integer that is different from the rest.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\n7\n\nThis is the same case as the one in the statement.\n\nSample Input 2\n\n1 1 7\n\nSample Output 2\n\n7\n\nIn this case, C is the one we seek.\n\nSample Input 3\n\n-100 100 100\n\nSample Output 3\n\n-100", "sample_input": "5 7 5\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03573", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers, A, B and C.\n\nAmong them, two are the same, but the remaining one is different from the rest.\n\nFor example, when A=5,B=7,C=5, A and C are the same, but B is different.\n\nFind the one that is different from the rest among the given three integers.\n\nConstraints\n\n-100 \\leq A,B,C \\leq 100\n\nA, B and C are integers.\n\nThe input satisfies the condition in the statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nAmong A, B and C, print the integer that is different from the rest.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\n7\n\nThis is the same case as the one in the statement.\n\nSample Input 2\n\n1 1 7\n\nSample Output 2\n\n7\n\nIn this case, C is the one we seek.\n\nSample Input 3\n\n-100 100 100\n\nSample Output 3\n\n-100", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 100, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s707298747", "group_id": "codeNet:p03576", "input_text": "def main(argv)\n (n, k) = gets.chomp.split(' ').map(&:to_i)\n\n p = [nil] * n\n x = [nil] * n\n y = [nil] * n\n n.times do |i|\n (x[i], y[i]) = gets.chomp.split(' ').map(&:to_i)\n p[i] = {:x => x[i], :y => y[i]}\n end\n x.sort!\n y.sort!\n \n s_min = 1e+20.to_i\n n.times do |ix|\n x_min = x[ix]\n \n n.times do |iy|\n y_min = y[iy]\n \n n.times do |jx|\n x_max = x[jx]\n next if x_min >= x_max\n \n n.times do |jy|\n y_max = y[jy]\n next if y_min >= y_max\n \n c = 0\n n.times do |l|\n if x_min <= p[l][:x] && p[l][:x] <= x_max then\n if y_min <= p[l][:y] && p[l][:y] <= y_max then\n c += 1\n end\n end\n end\n \n if c >= k then\n s_min = [s_min, (x_max - x_min) * (y_max - y_min)].min\n end\n end\n end\n end\n end\n \n puts s_min.to_s\nend\n\nif self.to_s == 'main' then\n main(ARGV)\nend", "language": "Ruby", "metadata": {"date": 1570169948, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03576.html", "problem_id": "p03576", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03576/input.txt", "sample_output_relpath": "derived/input_output/data/p03576/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03576/Ruby/s707298747.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s707298747", "user_id": "u198355306"}, "prompt_components": {"gold_output": "21\n", "input_to_evaluate": "def main(argv)\n (n, k) = gets.chomp.split(' ').map(&:to_i)\n\n p = [nil] * n\n x = [nil] * n\n y = [nil] * n\n n.times do |i|\n (x[i], y[i]) = gets.chomp.split(' ').map(&:to_i)\n p[i] = {:x => x[i], :y => y[i]}\n end\n x.sort!\n y.sort!\n \n s_min = 1e+20.to_i\n n.times do |ix|\n x_min = x[ix]\n \n n.times do |iy|\n y_min = y[iy]\n \n n.times do |jx|\n x_max = x[jx]\n next if x_min >= x_max\n \n n.times do |jy|\n y_max = y[jy]\n next if y_min >= y_max\n \n c = 0\n n.times do |l|\n if x_min <= p[l][:x] && p[l][:x] <= x_max then\n if y_min <= p[l][:y] && p[l][:y] <= y_max then\n c += 1\n end\n end\n end\n \n if c >= k then\n s_min = [s_min, (x_max - x_min) * (y_max - y_min)].min\n end\n end\n end\n end\n end\n \n puts s_min.to_s\nend\n\nif self.to_s == 'main' then\n main(ARGV)\nend", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N points in a two-dimensional plane.\n\nThe coordinates of the i-th point (1 \\leq i \\leq N) are (x_i,y_i).\n\nLet us consider a rectangle whose sides are parallel to the coordinate axes that contains K or more of the N points in its interior.\n\nHere, points on the sides of the rectangle are considered to be in the interior.\n\nFind the minimum possible area of such a rectangle.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 50\n\n-10^9 \\leq x_i,y_i \\leq 10^9 (1 \\leq i \\leq N)\n\nx_i≠x_j (1 \\leq i0||puts(i,j,d/n)}}", "language": "Ruby", "metadata": {"date": 1578590309, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03583.html", "problem_id": "p03583", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03583/input.txt", "sample_output_relpath": "derived/input_output/data/p03583/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03583/Ruby/s818707980.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s818707980", "user_id": "u032223772"}, "prompt_components": {"gold_output": "1 2 2\n", "input_to_evaluate": "N=eval *$<;(1..M=3500).all?{|i|(i..M).all?{|j|n=4*i*j-N*(i+j);d=N*i*j;n<1||d%n>0||puts(i,j,d/n)}}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFind a triple of positive integers h, n and w such that 4/N = 1/h + 1/n + 1/w.\n\nIf there are multiple solutions, any of them will be accepted.\n\nConstraints\n\nIt is guaranteed that, for the given integer N, there exists a solution such that h,n,w \\leq 3500.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutputs\n\nPrint a triple of positive integers h, n and w that satisfies the condition, in the following format:\n\nh n w\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1 2 2\n\n4/2 = 1/1 + 1/2 + 1/2.\n\nSample Input 2\n\n3485\n\nSample Output 2\n\n872 1012974 1539173474040\n\nIt is allowed to use an integer exceeding 3500 in a solution.\n\nSample Input 3\n\n4664\n\nSample Output 3\n\n3498 3498 3498", "sample_input": "2\n"}, "reference_outputs": ["1 2 2\n"], "source_document_id": "p03583", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFind a triple of positive integers h, n and w such that 4/N = 1/h + 1/n + 1/w.\n\nIf there are multiple solutions, any of them will be accepted.\n\nConstraints\n\nIt is guaranteed that, for the given integer N, there exists a solution such that h,n,w \\leq 3500.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutputs\n\nPrint a triple of positive integers h, n and w that satisfies the condition, in the following format:\n\nh n w\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1 2 2\n\n4/2 = 1/1 + 1/2 + 1/2.\n\nSample Input 2\n\n3485\n\nSample Output 2\n\n872 1012974 1539173474040\n\nIt is allowed to use an integer exceeding 3500 in a solution.\n\nSample Input 3\n\n4664\n\nSample Output 3\n\n3498 3498 3498", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 97, "cpu_time_ms": 779, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s961847715", "group_id": "codeNet:p03592", "input_text": "N,M,K=gets.split.map &:to_i;puts (0..N).any?{|k|x=K-k*M;y=N-2*k;y==0?x==0:(l=x/y;x%y==0&&0<=l&&l<=M)}?:Yes: :No", "language": "Ruby", "metadata": {"date": 1506308700, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03592.html", "problem_id": "p03592", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03592/input.txt", "sample_output_relpath": "derived/input_output/data/p03592/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03592/Ruby/s961847715.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s961847715", "user_id": "u280667879"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "N,M,K=gets.split.map &:to_i;puts (0..N).any?{|k|x=K-k*M;y=N-2*k;y==0?x==0:(l=x/y;x%y==0&&0<=l&&l<=M)}?:Yes: :No", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a grid with N rows and M columns of squares. Initially, all the squares are white.\n\nThere is a button attached to each row and each column.\nWhen a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa.\nWhen a button attached to a column is pressed, the colors of all the squares in that column are inverted.\n\nTakahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid.\n\nConstraints\n\n1 \\leq N,M \\leq 1000\n\n0 \\leq K \\leq NM\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\n\nOutput\n\nIf Takahashi can have exactly K black squares in the grid, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nPress the buttons in the order of the first row, the first column.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n3 5 8\n\nSample Output 3\n\nYes\n\nPress the buttons in the order of the first column, third column, second row, fifth column.\n\nSample Input 4\n\n7 9 20\n\nSample Output 4\n\nNo", "sample_input": "2 2 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03592", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a grid with N rows and M columns of squares. Initially, all the squares are white.\n\nThere is a button attached to each row and each column.\nWhen a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa.\nWhen a button attached to a column is pressed, the colors of all the squares in that column are inverted.\n\nTakahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid.\n\nConstraints\n\n1 \\leq N,M \\leq 1000\n\n0 \\leq K \\leq NM\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\n\nOutput\n\nIf Takahashi can have exactly K black squares in the grid, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nPress the buttons in the order of the first row, the first column.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n3 5 8\n\nSample Output 3\n\nYes\n\nPress the buttons in the order of the first column, third column, second row, fifth column.\n\nSample Input 4\n\n7 9 20\n\nSample Output 4\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 111, "cpu_time_ms": 7, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s038172001", "group_id": "codeNet:p03594", "input_text": "h,w,d=gets.split(\" \").map(&:to_i)\nh.times{|i|\n\tw.times{|j|\n\t\tprint(\"RGBY\"[(((i+j)/d)&1)|((((h-i+j)/d)&1)<<1)])\n\t}\n\tputs \"\"\n}", "language": "Ruby", "metadata": {"date": 1506307365, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03594.html", "problem_id": "p03594", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03594/input.txt", "sample_output_relpath": "derived/input_output/data/p03594/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03594/Ruby/s038172001.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s038172001", "user_id": "u694433776"}, "prompt_components": {"gold_output": "RY\nGR\n", "input_to_evaluate": "h,w,d=gets.split(\" \").map(&:to_i)\nh.times{|i|\n\tw.times{|j|\n\t\tprint(\"RGBY\"[(((i+j)/d)&1)|((((h-i+j)/d)&1)<<1)])\n\t}\n\tputs \"\"\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns of squares.\nWe will represent the square at the i-th row from the top and j-th column from the left as (i,\\ j).\nAlso, we will define the distance between the squares (i_1,\\ j_1) and (i_2,\\ j_2) as |i_1 - i_2| + |j_1 - j_2|.\n\nSnuke is painting each square in red, yellow, green or blue.\nHere, for a given positive integer d, he wants to satisfy the following condition:\n\nNo two squares with distance exactly d have the same color.\n\nFind a way to paint the squares satisfying the condition.\nIt can be shown that a solution always exists.\n\nConstraints\n\n2 ≤ H, W ≤ 500\n\n1 ≤ d ≤ H + W - 2\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W d\n\nOutput\n\nPrint a way to paint the squares satisfying the condition, in the following format. If the square (i,\\ j) is painted in red, yellow, green or blue, c_{ij} should be R, Y, G or B, respectively.\n\nc_{11}c_{12}...c_{1W}\n:\nc_{H1}c_{H2}...c_{HW}\n\nSample Input 1\n\n2 2 1\n\nSample Output 1\n\nRY\nGR\n\nThere are four pairs of squares with distance exactly 1.\nAs shown below, no two such squares have the same color.\n\n(1,\\ 1), (1,\\ 2) : R, Y\n\n(1,\\ 2), (2,\\ 2) : Y, R\n\n(2,\\ 2), (2,\\ 1) : R, G\n\n(2,\\ 1), (1,\\ 1) : G, R\n\nSample Input 2\n\n2 3 2\n\nSample Output 2\n\nRYB\nRGB\n\nThere are six pairs of squares with distance exactly 2.\nAs shown below, no two such squares have the same color.\n\n(1,\\ 1) , (1,\\ 3) : R , B\n\n(1,\\ 3) , (2,\\ 2) : B , G\n\n(2,\\ 2) , (1,\\ 1) : G , R\n\n(2,\\ 1) , (2,\\ 3) : R , B\n\n(2,\\ 3) , (1,\\ 2) : B , Y\n\n(1,\\ 2) , (2,\\ 1) : Y , R", "sample_input": "2 2 1\n"}, "reference_outputs": ["RY\nGR\n"], "source_document_id": "p03594", "source_text": "Score : 700 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns of squares.\nWe will represent the square at the i-th row from the top and j-th column from the left as (i,\\ j).\nAlso, we will define the distance between the squares (i_1,\\ j_1) and (i_2,\\ j_2) as |i_1 - i_2| + |j_1 - j_2|.\n\nSnuke is painting each square in red, yellow, green or blue.\nHere, for a given positive integer d, he wants to satisfy the following condition:\n\nNo two squares with distance exactly d have the same color.\n\nFind a way to paint the squares satisfying the condition.\nIt can be shown that a solution always exists.\n\nConstraints\n\n2 ≤ H, W ≤ 500\n\n1 ≤ d ≤ H + W - 2\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W d\n\nOutput\n\nPrint a way to paint the squares satisfying the condition, in the following format. If the square (i,\\ j) is painted in red, yellow, green or blue, c_{ij} should be R, Y, G or B, respectively.\n\nc_{11}c_{12}...c_{1W}\n:\nc_{H1}c_{H2}...c_{HW}\n\nSample Input 1\n\n2 2 1\n\nSample Output 1\n\nRY\nGR\n\nThere are four pairs of squares with distance exactly 1.\nAs shown below, no two such squares have the same color.\n\n(1,\\ 1), (1,\\ 2) : R, Y\n\n(1,\\ 2), (2,\\ 2) : Y, R\n\n(2,\\ 2), (2,\\ 1) : R, G\n\n(2,\\ 1), (1,\\ 1) : G, R\n\nSample Input 2\n\n2 3 2\n\nSample Output 2\n\nRYB\nRGB\n\nThere are six pairs of squares with distance exactly 2.\nAs shown below, no two such squares have the same color.\n\n(1,\\ 1) , (1,\\ 3) : R , B\n\n(1,\\ 3) , (2,\\ 2) : B , G\n\n(2,\\ 2) , (1,\\ 1) : G , R\n\n(2,\\ 1) , (2,\\ 3) : R , B\n\n(2,\\ 3) , (1,\\ 2) : B , Y\n\n(1,\\ 2) , (2,\\ 1) : Y , R", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 124, "cpu_time_ms": 136, "memory_kb": 2044}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s834936514", "group_id": "codeNet:p03598", "input_text": "N = gets.to_i\nK = gets.to_i\nx = gets.split.map &:to_i\n\nsum = 0\nx.each do |x|\n if x < (x - K).abs\n sum += 2 * x\n else\n sum += (x - K).abs * 2\n end\nend\nputs sum", "language": "Ruby", "metadata": {"date": 1598664462, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "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/Ruby/s834936514.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s834936514", "user_id": "u138026316"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "N = gets.to_i\nK = gets.to_i\nx = gets.split.map &:to_i\n\nsum = 0\nx.each do |x|\n if x < (x - K).abs\n sum += 2 * x\n else\n sum += (x - K).abs * 2\n end\nend\nputs sum", "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": 167, "cpu_time_ms": 65, "memory_kb": 14288}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s828670652", "group_id": "codeNet:p03599", "input_text": "=begin\n-------------- \nA = 100*A 水\nB = 100*B 水\nC,D = 1回の投入可能砂糖量\nE = 100(g)あたりに溶かすことのできる砂糖量\nF = ビーカー許容量(水 + 砂糖 = 総質量)\nsugar = F 質量内でできる砂糖の質量を格納(Ci + Dj を組み合わせてできる質量の列挙)\nwater = F 質量内でできる水の質量を格納(100Ai + 100Bjの組み合わせでできる質量の列挙)\nsum = water[i]とsugar[j]の総質量\npos = water[i] に溶かせる砂糖量\ncon = sugar[j]*100 / (sugar[j] + water[i]) の砂糖濃度(%)\nans = 答え\n--------------\n=end\n\nA,B,C,D,E,F = gets.split.map(&:to_i);\n\ntmp = {};\ntmp[:waters] = [];\n(0..30).each{|i|\n (0..30).each{|j|\n x = (100*A*i) + (100*B*j);\n tmp[:waters] << x if x <= F;\n }\n}\ntmp[:waters].sort!.uniq!;\n\ntmp[:sugars] = []\n(0..30).each{|i|\n (0..30).each{|j|\n y = C * i + D * j;\n tmp[:sugars] << y if y <= F;\n }\n}\ntmp[:sugars].sort!.uniq!;\n\nsum_ans = 0;\nsugar_ans = 0;\ndif = -1;\ncon = 0.0;\n\ntmp[:waters].each{|w|\n pos = w / 100 * E;\n tmp[:sugars].each{|s|\n sum = w + s;\n next if pos < s || F < sum\n \n con = (s*100) / (s + w).to_f;\n if dif < con\n sum_ans = sum;\n sugar_ans = s;\n dif = con;\n end\n }\n}\n\nputs \"#{sum_ans} #{sugar_ans}\"", "language": "Ruby", "metadata": {"date": 1591656361, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s828670652.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s828670652", "user_id": "u682209098"}, "prompt_components": {"gold_output": "110 10\n", "input_to_evaluate": "=begin\n-------------- \nA = 100*A 水\nB = 100*B 水\nC,D = 1回の投入可能砂糖量\nE = 100(g)あたりに溶かすことのできる砂糖量\nF = ビーカー許容量(水 + 砂糖 = 総質量)\nsugar = F 質量内でできる砂糖の質量を格納(Ci + Dj を組み合わせてできる質量の列挙)\nwater = F 質量内でできる水の質量を格納(100Ai + 100Bjの組み合わせでできる質量の列挙)\nsum = water[i]とsugar[j]の総質量\npos = water[i] に溶かせる砂糖量\ncon = sugar[j]*100 / (sugar[j] + water[i]) の砂糖濃度(%)\nans = 答え\n--------------\n=end\n\nA,B,C,D,E,F = gets.split.map(&:to_i);\n\ntmp = {};\ntmp[:waters] = [];\n(0..30).each{|i|\n (0..30).each{|j|\n x = (100*A*i) + (100*B*j);\n tmp[:waters] << x if x <= F;\n }\n}\ntmp[:waters].sort!.uniq!;\n\ntmp[:sugars] = []\n(0..30).each{|i|\n (0..30).each{|j|\n y = C * i + D * j;\n tmp[:sugars] << y if y <= F;\n }\n}\ntmp[:sugars].sort!.uniq!;\n\nsum_ans = 0;\nsugar_ans = 0;\ndif = -1;\ncon = 0.0;\n\ntmp[:waters].each{|w|\n pos = w / 100 * E;\n tmp[:sugars].each{|s|\n sum = w + s;\n next if pos < s || F < sum\n \n con = (s*100) / (s + w).to_f;\n if dif < con\n sum_ans = sum;\n sugar_ans = s;\n dif = con;\n end\n }\n}\n\nputs \"#{sum_ans} #{sugar_ans}\"", "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": 1323, "cpu_time_ms": 10, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s080458115", "group_id": "codeNet:p03599", "input_text": "a,b,c,d,e,f = gets.chomp.split(\" \").map(&:to_i)\nans = [0,0,0,0]\ntmp = 3000\nfor i in 0..f/(100*a)\n for j in 0..(f-100*a)/(100*b)\n for k in 0..(a*i+b*j)*e/c\n l = ((a*i+b*j)*e-c*k)/d\n if (a*i+b*j)*e >= c*k+d*l && f >= (a*i+b*j)*100+(c*k+d*l) && tmp > (a*i+b*j).to_f/(c*k+d*l)\n ans = [i,j,k,l]\n tmp = (a*i+b*j).to_f/(c*k+d*l)\n end\n end\n end\nend\nputs \"#{(a*ans[0]+b*ans[1])*100+(c*ans[2]+d*ans[3])} #{(c*ans[2]+d*ans[3])}\"", "language": "Ruby", "metadata": {"date": 1521440190, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s080458115.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s080458115", "user_id": "u506255180"}, "prompt_components": {"gold_output": "110 10\n", "input_to_evaluate": "a,b,c,d,e,f = gets.chomp.split(\" \").map(&:to_i)\nans = [0,0,0,0]\ntmp = 3000\nfor i in 0..f/(100*a)\n for j in 0..(f-100*a)/(100*b)\n for k in 0..(a*i+b*j)*e/c\n l = ((a*i+b*j)*e-c*k)/d\n if (a*i+b*j)*e >= c*k+d*l && f >= (a*i+b*j)*100+(c*k+d*l) && tmp > (a*i+b*j).to_f/(c*k+d*l)\n ans = [i,j,k,l]\n tmp = (a*i+b*j).to_f/(c*k+d*l)\n end\n end\n end\nend\nputs \"#{(a*ans[0]+b*ans[1])*100+(c*ans[2]+d*ans[3])} #{(c*ans[2]+d*ans[3])}\"", "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": 454, "cpu_time_ms": 33, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s179816002", "group_id": "codeNet:p03605", "input_text": "a = gets.chomp.split(//)\nputs a.include?(\"9\") ? \"Yes\" : \"No\"", "language": "Ruby", "metadata": {"date": 1506963314, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03605.html", "problem_id": "p03605", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03605/input.txt", "sample_output_relpath": "derived/input_output/data/p03605/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03605/Ruby/s179816002.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s179816002", "user_id": "u952900471"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "a = gets.chomp.split(//)\nputs a.include?(\"9\") ? \"Yes\" : \"No\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIt is September 9 in Japan now.\n\nYou are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?\n\nConstraints\n\n10≤N≤99\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf 9 is contained in the decimal notation of N, print Yes; if not, print No.\n\nSample Input 1\n\n29\n\nSample Output 1\n\nYes\n\nThe one's digit of 29 is 9.\n\nSample Input 2\n\n72\n\nSample Output 2\n\nNo\n\n72 does not contain 9.\n\nSample Input 3\n\n91\n\nSample Output 3\n\nYes", "sample_input": "29\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03605", "source_text": "Score : 100 points\n\nProblem Statement\n\nIt is September 9 in Japan now.\n\nYou are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?\n\nConstraints\n\n10≤N≤99\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf 9 is contained in the decimal notation of N, print Yes; if not, print No.\n\nSample Input 1\n\n29\n\nSample Output 1\n\nYes\n\nThe one's digit of 29 is 9.\n\nSample Input 2\n\n72\n\nSample Output 2\n\nNo\n\n72 does not contain 9.\n\nSample Input 3\n\n91\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 60, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s401132894", "group_id": "codeNet:p03608", "input_text": "n,m,R = gets.split.map(&:to_i)\nr = gets.split.map(&:to_i)\n\ndp = Array.new(n+1).map{Array.new(n+1,10**9)}\nm.times do\n a,b,c = gets.split.map(&:to_i)\n dp[a][b] = c\n dp[b][a] = c\nend\n\n1.upto(n) do |k|\n 1.upto(n) do |s|\n 1.upto(n) do |f|\n if dp[s][f] > dp[s][k] + dp[k][f]\n dp[s][f] = dp[s][k] + dp[k][f]\n end\n end\n end\nend\n\nans = 10**9\nr.permutation do |arr|\n count = 0\n (R-1).times do |i|\n count += dp[arr[i]][arr[i+1]]\n end\n ans = count if ans > count\nend\n\nputs ans", "language": "Ruby", "metadata": {"date": 1570911485, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03608.html", "problem_id": "p03608", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03608/input.txt", "sample_output_relpath": "derived/input_output/data/p03608/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03608/Ruby/s401132894.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s401132894", "user_id": "u692254521"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n,m,R = gets.split.map(&:to_i)\nr = gets.split.map(&:to_i)\n\ndp = Array.new(n+1).map{Array.new(n+1,10**9)}\nm.times do\n a,b,c = gets.split.map(&:to_i)\n dp[a][b] = c\n dp[b][a] = c\nend\n\n1.upto(n) do |k|\n 1.upto(n) do |s|\n 1.upto(n) do |f|\n if dp[s][f] > dp[s][k] + dp[k][f]\n dp[s][f] = dp[s][k] + dp[k][f]\n end\n end\n end\nend\n\nans = 10**9\nr.permutation do |arr|\n count = 0\n (R-1).times do |i|\n count += dp[arr[i]][arr[i+1]]\n end\n ans = count if ans > count\nend\n\nputs ans", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N towns in the State of Atcoder, connected by M bidirectional roads.\n\nThe i-th road connects Town A_i and B_i and has a length of C_i.\n\nJoisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessarily in this order).\n\nShe will fly to the first town she visits, and fly back from the last town she visits, but for the rest of the trip she will have to travel by road.\n\nIf she visits the towns in the order that minimizes the distance traveled by road, what will that distance be?\n\nConstraints\n\n2≤N≤200\n\n1≤M≤N×(N-1)/2\n\n2≤R≤min(8,N) (min(8,N) is the smaller of 8 and N.)\n\nr_i≠r_j (i≠j)\n\n1≤A_i,B_i≤N, A_i≠B_i\n\n(A_i,B_i)≠(A_j,B_j),(A_i,B_i)≠(B_j,A_j) (i≠j)\n\n1≤C_i≤100000\n\nEvery town can be reached from every town by road.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M R\nr_1 ... r_R\nA_1 B_1 C_1\n:\nA_M B_M C_M\n\nOutput\n\nPrint the distance traveled by road if Joisino visits the towns in the order that minimizes it.\n\nSample Input 1\n\n3 3 3\n1 2 3\n1 2 1\n2 3 1\n3 1 4\n\nSample Output 1\n\n2\n\nFor example, if she visits the towns in the order of 1, 2, 3, the distance traveled will be 2, which is the minimum possible.\n\nSample Input 2\n\n3 3 2\n1 3\n2 3 2\n1 3 6\n1 2 2\n\nSample Output 2\n\n4\n\nThe shortest distance between Towns 1 and 3 is 4. Thus, whether she visits Town 1 or 3 first, the distance traveled will be 4.\n\nSample Input 3\n\n4 6 3\n2 3 4\n1 2 4\n2 3 3\n4 3 1\n1 4 1\n4 2 2\n3 1 6\n\nSample Output 3\n\n3", "sample_input": "3 3 3\n1 2 3\n1 2 1\n2 3 1\n3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03608", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N towns in the State of Atcoder, connected by M bidirectional roads.\n\nThe i-th road connects Town A_i and B_i and has a length of C_i.\n\nJoisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessarily in this order).\n\nShe will fly to the first town she visits, and fly back from the last town she visits, but for the rest of the trip she will have to travel by road.\n\nIf she visits the towns in the order that minimizes the distance traveled by road, what will that distance be?\n\nConstraints\n\n2≤N≤200\n\n1≤M≤N×(N-1)/2\n\n2≤R≤min(8,N) (min(8,N) is the smaller of 8 and N.)\n\nr_i≠r_j (i≠j)\n\n1≤A_i,B_i≤N, A_i≠B_i\n\n(A_i,B_i)≠(A_j,B_j),(A_i,B_i)≠(B_j,A_j) (i≠j)\n\n1≤C_i≤100000\n\nEvery town can be reached from every town by road.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M R\nr_1 ... r_R\nA_1 B_1 C_1\n:\nA_M B_M C_M\n\nOutput\n\nPrint the distance traveled by road if Joisino visits the towns in the order that minimizes it.\n\nSample Input 1\n\n3 3 3\n1 2 3\n1 2 1\n2 3 1\n3 1 4\n\nSample Output 1\n\n2\n\nFor example, if she visits the towns in the order of 1, 2, 3, the distance traveled will be 2, which is the minimum possible.\n\nSample Input 2\n\n3 3 2\n1 3\n2 3 2\n1 3 6\n1 2 2\n\nSample Output 2\n\n4\n\nThe shortest distance between Towns 1 and 3 is 4. Thus, whether she visits Town 1 or 3 first, the distance traveled will be 4.\n\nSample Input 3\n\n4 6 3\n2 3 4\n1 2 4\n2 3 3\n4 3 1\n1 4 1\n4 2 2\n3 1 6\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 549, "cpu_time_ms": 1376, "memory_kb": 3324}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s605698768", "group_id": "codeNet:p03609", "input_text": "x, t = gets.chomp.split(\" \").map(&:to_i)\n\nres = 0\nif x > t\n res = x -t\nend\n\nputs res", "language": "Ruby", "metadata": {"date": 1556293200, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03609.html", "problem_id": "p03609", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03609/input.txt", "sample_output_relpath": "derived/input_output/data/p03609/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03609/Ruby/s605698768.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s605698768", "user_id": "u126541218"}, "prompt_components": {"gold_output": "83\n", "input_to_evaluate": "x, t = gets.chomp.split(\" \").map(&:to_i)\n\nres = 0\nif x > t\n res = x -t\nend\n\nputs res", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand.\n\nHow many grams of sand will the upper bulb contains after t seconds?\n\nConstraints\n\n1≤X≤10^9\n\n1≤t≤10^9\n\nX and t are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX t\n\nOutput\n\nPrint the number of sand in the upper bulb after t second.\n\nSample Input 1\n\n100 17\n\nSample Output 1\n\n83\n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83 grams.\n\nSample Input 2\n\n48 58\n\nSample Output 2\n\n0\n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n0", "sample_input": "100 17\n"}, "reference_outputs": ["83\n"], "source_document_id": "p03609", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand.\n\nHow many grams of sand will the upper bulb contains after t seconds?\n\nConstraints\n\n1≤X≤10^9\n\n1≤t≤10^9\n\nX and t are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX t\n\nOutput\n\nPrint the number of sand in the upper bulb after t second.\n\nSample Input 1\n\n100 17\n\nSample Output 1\n\n83\n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83 grams.\n\nSample Input 2\n\n48 58\n\nSample Output 2\n\n0\n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 85, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s831257924", "group_id": "codeNet:p03610", "input_text": "ss = gets.chomp.split('')\n\nss.select!.with_index(1) { |s, i| i.odd? }\nputs ss.join\n", "language": "Ruby", "metadata": {"date": 1587924736, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03610.html", "problem_id": "p03610", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03610/input.txt", "sample_output_relpath": "derived/input_output/data/p03610/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03610/Ruby/s831257924.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s831257924", "user_id": "u104678771"}, "prompt_components": {"gold_output": "acdr\n", "input_to_evaluate": "ss = gets.chomp.split('')\n\nss.select!.with_index(1) { |s, i| i.odd? }\nputs ss.join\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.\n\nConstraints\n\nEach character in s is a lowercase English letter.\n\n1≤|s|≤10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string obtained by concatenating all the characters in the odd-numbered positions.\n\nSample Input 1\n\natcoder\n\nSample Output 1\n\nacdr\n\nExtract the first character a, the third character c, the fifth character d and the seventh character r to obtain acdr.\n\nSample Input 2\n\naaaa\n\nSample Output 2\n\naa\n\nSample Input 3\n\nz\n\nSample Output 3\n\nz\n\nSample Input 4\n\nfukuokayamaguchi\n\nSample Output 4\n\nfkoaaauh", "sample_input": "atcoder\n"}, "reference_outputs": ["acdr\n"], "source_document_id": "p03610", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.\n\nConstraints\n\nEach character in s is a lowercase English letter.\n\n1≤|s|≤10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string obtained by concatenating all the characters in the odd-numbered positions.\n\nSample Input 1\n\natcoder\n\nSample Output 1\n\nacdr\n\nExtract the first character a, the third character c, the fifth character d and the seventh character r to obtain acdr.\n\nSample Input 2\n\naaaa\n\nSample Output 2\n\naa\n\nSample Input 3\n\nz\n\nSample Output 3\n\nz\n\nSample Input 4\n\nfukuokayamaguchi\n\nSample Output 4\n\nfkoaaauh", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 83, "cpu_time_ms": 73, "memory_kb": 7036}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s225757678", "group_id": "codeNet:p03611", "input_text": "io = STDIN\nn=io.gets.to_i\na=io.gets.split.map(&:to_i)\nhash={}\nhash.default=0\na.each do |aa|\n hash[aa]+=1\nend\nans=0\n(1..10**5).each_cons(3) do |x,y,z|\n ans=[ans,hash[x]+hash[y]+hash[z]].max\nend\nputs ans\n", "language": "Ruby", "metadata": {"date": 1504402596, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03611.html", "problem_id": "p03611", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03611/input.txt", "sample_output_relpath": "derived/input_output/data/p03611/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03611/Ruby/s225757678.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s225757678", "user_id": "u132360211"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "io = STDIN\nn=io.gets.to_i\na=io.gets.split.map(&:to_i)\nhash={}\nhash.default=0\na.each do |aa|\n hash[aa]+=1\nend\nans=0\n(1..10**5).each_cons(3) do |x,y,z|\n ans=[ans,hash[x]+hash[y]+hash[z]].max\nend\nputs ans\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length N, a_1,a_2,...,a_N.\n\nFor each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing.\n\nAfter these operations, you select an integer X and count the number of i such that a_i=X.\n\nMaximize this count by making optimal choices.\n\nConstraints\n\n1≤N≤10^5\n\n0≤a_i<10^5 (1≤i≤N)\n\na_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 .. a_N\n\nOutput\n\nPrint the maximum possible number of i such that a_i=X.\n\nSample Input 1\n\n7\n3 1 4 1 5 9 2\n\nSample Output 1\n\n4\n\nFor example, turn the sequence into 2,2,3,2,6,9,2 and select X=2 to obtain 4, the maximum possible count.\n\nSample Input 2\n\n10\n0 1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n3\n\nSample Input 3\n\n1\n99999\n\nSample Output 3\n\n1", "sample_input": "7\n3 1 4 1 5 9 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03611", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length N, a_1,a_2,...,a_N.\n\nFor each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing.\n\nAfter these operations, you select an integer X and count the number of i such that a_i=X.\n\nMaximize this count by making optimal choices.\n\nConstraints\n\n1≤N≤10^5\n\n0≤a_i<10^5 (1≤i≤N)\n\na_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 .. a_N\n\nOutput\n\nPrint the maximum possible number of i such that a_i=X.\n\nSample Input 1\n\n7\n3 1 4 1 5 9 2\n\nSample Output 1\n\n4\n\nFor example, turn the sequence into 2,2,3,2,6,9,2 and select X=2 to obtain 4, the maximum possible count.\n\nSample Input 2\n\n10\n0 1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n3\n\nSample Input 3\n\n1\n99999\n\nSample Output 3\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 204, "cpu_time_ms": 136, "memory_kb": 14724}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s993333731", "group_id": "codeNet:p03617", "input_text": "q, h, s, d = gets.chomp.split(' ').map(&:to_i)\nn = gets.chomp.to_i\n\nmin1 = [8 * q, 4 * h, 2 * s, d].min\nmin2 = [8 * q, 4 * h, 2 * s].min\n\nif min1 == min2 || n % 2 == 0\n puts n * min1 / 2\nelse\n puts n / 2 * d + min2 / 2\nend\n", "language": "Ruby", "metadata": {"date": 1503796534, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s993333731.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s993333731", "user_id": "u253759478"}, "prompt_components": {"gold_output": "150\n", "input_to_evaluate": "q, h, s, d = gets.chomp.split(' ').map(&:to_i)\nn = gets.chomp.to_i\n\nmin1 = [8 * q, 4 * h, 2 * s, d].min\nmin2 = [8 * q, 4 * h, 2 * s].min\n\nif min1 == min2 || n % 2 == 0\n puts n * min1 / 2\nelse\n puts n / 2 * d + min2 / 2\nend\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": 225, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s072288430", "group_id": "codeNet:p03617", "input_text": "q, h, s, d = gets.chomp.split(' ').map(&:to_i)\nn = gets.chomp.to_i\n\nmin1 = [8 * q, 4 * h, 2 * s, d].min\nmin2 = [8 * q, 4 * h, 2 * s].min\n\nif min1 == min2 || n % 2 == 0\n puts n * (min1 / 2)\nelse\n puts n / 2 * d + min2 / 2\nend\n", "language": "Ruby", "metadata": {"date": 1503796149, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s072288430.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s072288430", "user_id": "u253759478"}, "prompt_components": {"gold_output": "150\n", "input_to_evaluate": "q, h, s, d = gets.chomp.split(' ').map(&:to_i)\nn = gets.chomp.to_i\n\nmin1 = [8 * q, 4 * h, 2 * s, d].min\nmin2 = [8 * q, 4 * h, 2 * s].min\n\nif min1 == min2 || n % 2 == 0\n puts n * (min1 / 2)\nelse\n puts n / 2 * d + min2 / 2\nend\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": 227, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s982291400", "group_id": "codeNet:p03623", "input_text": "x, a, b = gets.split.map(&:to_i)\nputs (x-a).abs < (x-b).abs ? 'A' : 'B'\n", "language": "Ruby", "metadata": {"date": 1521162676, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03623.html", "problem_id": "p03623", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03623/input.txt", "sample_output_relpath": "derived/input_output/data/p03623/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03623/Ruby/s982291400.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s982291400", "user_id": "u987869509"}, "prompt_components": {"gold_output": "B\n", "input_to_evaluate": "x, a, b = gets.split.map(&:to_i)\nputs (x-a).abs < (x-b).abs ? 'A' : 'B'\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke lives at position x on a number line.\nOn this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.\n\nSnuke decided to get food delivery from the closer of stores A and B.\nFind out which store is closer to Snuke's residence.\n\nHere, the distance between two points s and t on a number line is represented by |s-t|.\n\nConstraints\n\n1 \\leq x \\leq 1000\n\n1 \\leq a \\leq 1000\n\n1 \\leq b \\leq 1000\n\nx, a and b are pairwise distinct.\n\nThe distances between Snuke's residence and stores A and B are different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx a b\n\nOutput\n\nIf store A is closer, print A; if store B is closer, print B.\n\nSample Input 1\n\n5 2 7\n\nSample Output 1\n\nB\n\nThe distances between Snuke's residence and stores A and B are 3 and 2, respectively.\nSince store B is closer, print B.\n\nSample Input 2\n\n1 999 1000\n\nSample Output 2\n\nA", "sample_input": "5 2 7\n"}, "reference_outputs": ["B\n"], "source_document_id": "p03623", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke lives at position x on a number line.\nOn this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.\n\nSnuke decided to get food delivery from the closer of stores A and B.\nFind out which store is closer to Snuke's residence.\n\nHere, the distance between two points s and t on a number line is represented by |s-t|.\n\nConstraints\n\n1 \\leq x \\leq 1000\n\n1 \\leq a \\leq 1000\n\n1 \\leq b \\leq 1000\n\nx, a and b are pairwise distinct.\n\nThe distances between Snuke's residence and stores A and B are different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx a b\n\nOutput\n\nIf store A is closer, print A; if store B is closer, print B.\n\nSample Input 1\n\n5 2 7\n\nSample Output 1\n\nB\n\nThe distances between Snuke's residence and stores A and B are 3 and 2, respectively.\nSince store B is closer, print B.\n\nSample Input 2\n\n1 999 1000\n\nSample Output 2\n\nA", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 72, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s069036233", "group_id": "codeNet:p03627", "input_text": "n = gets.to_i\nas = gets.split\n .each_with_object(Hash.new(0)) { |a, h| h[a.to_i] += 1 }\n .select { |_, v| v >= 2 }\n\nans = 0\nprev = 0\n\nas.keys.sort.each do |k|\n v = as[k]\n s = v >= 4 ? [prev * k, k ** 2].max : prev * k\n\n ans = s if s >= ans\n prev = k\nend\n\nputs ans\n", "language": "Ruby", "metadata": {"date": 1592078332, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03627.html", "problem_id": "p03627", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03627/input.txt", "sample_output_relpath": "derived/input_output/data/p03627/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03627/Ruby/s069036233.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s069036233", "user_id": "u889326464"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n = gets.to_i\nas = gets.split\n .each_with_object(Hash.new(0)) { |a, h| h[a.to_i] += 1 }\n .select { |_, v| v >= 2 }\n\nans = 0\nprev = 0\n\nas.keys.sort.each do |k|\n v = as[k]\n s = v >= 4 ? [prev * k, k ** 2].max : prev * k\n\n ans = s if s >= ans\n prev = k\nend\n\nputs ans\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N sticks with negligible thickness.\nThe length of the i-th stick is A_i.\n\nSnuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.\nFind the maximum possible area of the rectangle.\n\nConstraints\n\n4 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible area of the rectangle.\nIf no rectangle can be formed, print 0.\n\nSample Input 1\n\n6\n3 1 2 4 2 1\n\nSample Output 1\n\n2\n\n1 \\times 2 rectangle can be formed.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n\nNo rectangle can be formed.\n\nSample Input 3\n\n10\n3 3 3 3 4 4 4 5 5 5\n\nSample Output 3\n\n20", "sample_input": "6\n3 1 2 4 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03627", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N sticks with negligible thickness.\nThe length of the i-th stick is A_i.\n\nSnuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.\nFind the maximum possible area of the rectangle.\n\nConstraints\n\n4 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible area of the rectangle.\nIf no rectangle can be formed, print 0.\n\nSample Input 1\n\n6\n3 1 2 4 2 1\n\nSample Output 1\n\n2\n\n1 \\times 2 rectangle can be formed.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n\nNo rectangle can be formed.\n\nSample Input 3\n\n10\n3 3 3 3 4 4 4 5 5 5\n\nSample Output 3\n\n20", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 270, "cpu_time_ms": 100, "memory_kb": 14212}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s686215404", "group_id": "codeNet:p03628", "input_text": "N=gets.to_i\ns1=gets.chomp\ns2=gets.chomp\nMOD=10**9+7\n\ni = 0\narr = []\nwhile i < N\n if s1[i] == s2[i]\n arr << 1\n i += 1\n else\n arr << 2\n i += 2\n end\nend\n\nret = (arr[0] == 1 ? 3 : 6)\narr.each_cons(2) do |ab|\n case ab\n in [1,1]\n ret *= 2\n in [1,2]\n ret *= 2\n in [2,1]\n ret *= 1\n in [2,2]\n ret *= 3\n end\nend\n\np ret%MOD", "language": "Ruby", "metadata": {"date": 1593289141, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p03628.html", "problem_id": "p03628", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03628/input.txt", "sample_output_relpath": "derived/input_output/data/p03628/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03628/Ruby/s686215404.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s686215404", "user_id": "u852974293"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "N=gets.to_i\ns1=gets.chomp\ns2=gets.chomp\nMOD=10**9+7\n\ni = 0\narr = []\nwhile i < N\n if s1[i] == s2[i]\n arr << 1\n i += 1\n else\n arr << 2\n i += 2\n end\nend\n\nret = (arr[0] == 1 ? 3 : 6)\narr.each_cons(2) do |ab|\n case ab\n in [1,1]\n ret *= 2\n in [1,2]\n ret *= 2\n in [2,1]\n ret *= 1\n in [2,2]\n ret *= 3\n end\nend\n\np ret%MOD", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a board with a 2 \\times N grid.\nSnuke covered the board with N dominoes without overlaps.\nHere, a domino can cover a 1 \\times 2 or 2 \\times 1 square.\n\nThen, Snuke decided to paint these dominoes using three colors: red, cyan and green.\nTwo dominoes that are adjacent by side should be painted by different colors.\nHere, it is not always necessary to use all three colors.\n\nFind the number of such ways to paint the dominoes, modulo 1000000007.\n\nThe arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:\n\nEach domino is represented by a different English letter (lowercase or uppercase).\n\nThe j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.\n\nConstraints\n\n1 \\leq N \\leq 52\n\n|S_1| = |S_2| = N\n\nS_1 and S_2 consist of lowercase and uppercase English letters.\n\nS_1 and S_2 represent a valid arrangement of dominoes.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\nS_2\n\nOutput\n\nPrint the number of such ways to paint the dominoes, modulo 1000000007.\n\nSample Input 1\n\n3\naab\nccb\n\nSample Output 1\n\n6\n\nThere are six ways as shown below:\n\nSample Input 2\n\n1\nZ\nZ\n\nSample Output 2\n\n3\n\nNote that it is not always necessary to use all the colors.\n\nSample Input 3\n\n52\nRvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn\nRLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn\n\nSample Output 3\n\n958681902", "sample_input": "3\naab\nccb\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03628", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a board with a 2 \\times N grid.\nSnuke covered the board with N dominoes without overlaps.\nHere, a domino can cover a 1 \\times 2 or 2 \\times 1 square.\n\nThen, Snuke decided to paint these dominoes using three colors: red, cyan and green.\nTwo dominoes that are adjacent by side should be painted by different colors.\nHere, it is not always necessary to use all three colors.\n\nFind the number of such ways to paint the dominoes, modulo 1000000007.\n\nThe arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:\n\nEach domino is represented by a different English letter (lowercase or uppercase).\n\nThe j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.\n\nConstraints\n\n1 \\leq N \\leq 52\n\n|S_1| = |S_2| = N\n\nS_1 and S_2 consist of lowercase and uppercase English letters.\n\nS_1 and S_2 represent a valid arrangement of dominoes.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\nS_2\n\nOutput\n\nPrint the number of such ways to paint the dominoes, modulo 1000000007.\n\nSample Input 1\n\n3\naab\nccb\n\nSample Output 1\n\n6\n\nThere are six ways as shown below:\n\nSample Input 2\n\n1\nZ\nZ\n\nSample Output 2\n\n3\n\nNote that it is not always necessary to use all the colors.\n\nSample Input 3\n\n52\nRvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn\nRLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn\n\nSample Output 3\n\n958681902", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 71, "memory_kb": 14352}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s398864738", "group_id": "codeNet:p03628", "input_text": "x=0;r=3;[*$<][1].scan(/(.)\\1?/){r*=2[x/x=$&.size]+x};p r.%10**9+7", "language": "Ruby", "metadata": {"date": 1540771469, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03628.html", "problem_id": "p03628", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03628/input.txt", "sample_output_relpath": "derived/input_output/data/p03628/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03628/Ruby/s398864738.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s398864738", "user_id": "u019489252"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "x=0;r=3;[*$<][1].scan(/(.)\\1?/){r*=2[x/x=$&.size]+x};p r.%10**9+7", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a board with a 2 \\times N grid.\nSnuke covered the board with N dominoes without overlaps.\nHere, a domino can cover a 1 \\times 2 or 2 \\times 1 square.\n\nThen, Snuke decided to paint these dominoes using three colors: red, cyan and green.\nTwo dominoes that are adjacent by side should be painted by different colors.\nHere, it is not always necessary to use all three colors.\n\nFind the number of such ways to paint the dominoes, modulo 1000000007.\n\nThe arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:\n\nEach domino is represented by a different English letter (lowercase or uppercase).\n\nThe j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.\n\nConstraints\n\n1 \\leq N \\leq 52\n\n|S_1| = |S_2| = N\n\nS_1 and S_2 consist of lowercase and uppercase English letters.\n\nS_1 and S_2 represent a valid arrangement of dominoes.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\nS_2\n\nOutput\n\nPrint the number of such ways to paint the dominoes, modulo 1000000007.\n\nSample Input 1\n\n3\naab\nccb\n\nSample Output 1\n\n6\n\nThere are six ways as shown below:\n\nSample Input 2\n\n1\nZ\nZ\n\nSample Output 2\n\n3\n\nNote that it is not always necessary to use all the colors.\n\nSample Input 3\n\n52\nRvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn\nRLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn\n\nSample Output 3\n\n958681902", "sample_input": "3\naab\nccb\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03628", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a board with a 2 \\times N grid.\nSnuke covered the board with N dominoes without overlaps.\nHere, a domino can cover a 1 \\times 2 or 2 \\times 1 square.\n\nThen, Snuke decided to paint these dominoes using three colors: red, cyan and green.\nTwo dominoes that are adjacent by side should be painted by different colors.\nHere, it is not always necessary to use all three colors.\n\nFind the number of such ways to paint the dominoes, modulo 1000000007.\n\nThe arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:\n\nEach domino is represented by a different English letter (lowercase or uppercase).\n\nThe j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.\n\nConstraints\n\n1 \\leq N \\leq 52\n\n|S_1| = |S_2| = N\n\nS_1 and S_2 consist of lowercase and uppercase English letters.\n\nS_1 and S_2 represent a valid arrangement of dominoes.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\nS_2\n\nOutput\n\nPrint the number of such ways to paint the dominoes, modulo 1000000007.\n\nSample Input 1\n\n3\naab\nccb\n\nSample Output 1\n\n6\n\nThere are six ways as shown below:\n\nSample Input 2\n\n1\nZ\nZ\n\nSample Output 2\n\n3\n\nNote that it is not always necessary to use all the colors.\n\nSample Input 3\n\n52\nRvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn\nRLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn\n\nSample Output 3\n\n958681902", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 65, "cpu_time_ms": 9, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s733374136", "group_id": "codeNet:p03631", "input_text": "s=gets;puts {true=>\"Yes\",false=>\"No}[s[0] == s[2]]", "language": "Ruby", "metadata": {"date": 1502637171, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03631.html", "problem_id": "p03631", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03631/input.txt", "sample_output_relpath": "derived/input_output/data/p03631/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03631/Ruby/s733374136.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s733374136", "user_id": "u253759478"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "s=gets;puts {true=>\"Yes\",false=>\"No}[s[0] == s[2]]", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a three-digit positive integer N.\n\nDetermine whether N is a palindromic number.\n\nHere, a palindromic number is an integer that reads the same backward as forward in decimal notation.\n\nConstraints\n\n100≤N≤999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is a palindromic number, print Yes; otherwise, print No.\n\nSample Input 1\n\n575\n\nSample Output 1\n\nYes\n\nN=575 is also 575 when read backward, so it is a palindromic number. You should print Yes.\n\nSample Input 2\n\n123\n\nSample Output 2\n\nNo\n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You should print No.\n\nSample Input 3\n\n812\n\nSample Output 3\n\nNo", "sample_input": "575\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03631", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a three-digit positive integer N.\n\nDetermine whether N is a palindromic number.\n\nHere, a palindromic number is an integer that reads the same backward as forward in decimal notation.\n\nConstraints\n\n100≤N≤999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is a palindromic number, print Yes; otherwise, print No.\n\nSample Input 1\n\n575\n\nSample Output 1\n\nYes\n\nN=575 is also 575 when read backward, so it is a palindromic number. You should print Yes.\n\nSample Input 2\n\n123\n\nSample Output 2\n\nNo\n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You should print No.\n\nSample Input 3\n\n812\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 50, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s479017617", "group_id": "codeNet:p03632", "input_text": "a, b, c, d=gets.split.map(&:to_i)\n\nv=Array.new(200){0}\nv[a]+=1; v[b+1]-=1\nv[c]+=1; v[d+1]-=1\n\n200.times do |i|\n if i>0\n v[i]+=v[i-1]\n end\nend\n\nputs [v.count(2)-1, 0].max\n", "language": "Ruby", "metadata": {"date": 1502591503, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s479017617.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s479017617", "user_id": "u882868478"}, "prompt_components": {"gold_output": "50\n", "input_to_evaluate": "a, b, c, d=gets.split.map(&:to_i)\n\nv=Array.new(200){0}\nv[a]+=1; v[b+1]-=1\nv[c]+=1; v[d+1]-=1\n\n200.times do |i|\n if i>0\n v[i]+=v[i-1]\n end\nend\n\nputs [v.count(2)-1, 0].max\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= rest ? 'Yes' : 'No'\nelse\n puts multiples_of_four + 1 >= rest + 1 ? 'Yes' : 'No'\nend\n", "language": "Ruby", "metadata": {"date": 1592444821, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03637.html", "problem_id": "p03637", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03637/input.txt", "sample_output_relpath": "derived/input_output/data/p03637/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03637/Ruby/s100620139.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s100620139", "user_id": "u623402808"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "n = gets.to_i\na_numbers = gets.split.map(&:to_i)\n\nmultiples_of_four = a_numbers.count { |number| number % 4 == 0 }\nmultiples_of_two_not_four = a_numbers.count(&:even?) - multiples_of_four\nrest = n - (multiples_of_four + multiples_of_two_not_four)\n\nif multiples_of_two_not_four.zero?\n puts multiples_of_four + 1 >= rest ? 'Yes' : 'No'\nelse\n puts multiples_of_four + 1 >= rest + 1 ? 'Yes' : 'No'\nend\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a sequence of length N, a = (a_1, a_2, ..., a_N).\nEach a_i is a positive integer.\n\nSnuke's objective is to permute the element in a so that the following condition is satisfied:\n\nFor each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.\n\nDetermine whether Snuke can achieve his objective.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\na_i is an integer.\n\n1 ≤ a_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf Snuke can achieve his objective, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 10 100\n\nSample Output 1\n\nYes\n\nOne solution is (1, 100, 10).\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\nNo\n\nIt is impossible to permute a so that the condition is satisfied.\n\nSample Input 3\n\n3\n1 4 1\n\nSample Output 3\n\nYes\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n6\n2 7 1 8 2 8\n\nSample Output 5\n\nYes", "sample_input": "3\n1 10 100\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03637", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a sequence of length N, a = (a_1, a_2, ..., a_N).\nEach a_i is a positive integer.\n\nSnuke's objective is to permute the element in a so that the following condition is satisfied:\n\nFor each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.\n\nDetermine whether Snuke can achieve his objective.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\na_i is an integer.\n\n1 ≤ a_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf Snuke can achieve his objective, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 10 100\n\nSample Output 1\n\nYes\n\nOne solution is (1, 100, 10).\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\nNo\n\nIt is impossible to permute a so that the condition is satisfied.\n\nSample Input 3\n\n3\n1 4 1\n\nSample Output 3\n\nYes\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n6\n2 7 1 8 2 8\n\nSample Output 5\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 400, "cpu_time_ms": 59, "memory_kb": 8452}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s491690760", "group_id": "codeNet:p03637", "input_text": "n=gets.to_i\na=gets.split.map(&:to_i)\nc4,c1=0,0\nf=true\na.each do |b|\n if b%4==0\n c4+=1\n elsif b.odd?\n c1+=1\n elsif f\n c1+=1\n f=false\n end\nend\nputs c4>c1-2 ? :Yes : :No\n", "language": "Ruby", "metadata": {"date": 1571239910, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03637.html", "problem_id": "p03637", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03637/input.txt", "sample_output_relpath": "derived/input_output/data/p03637/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03637/Ruby/s491690760.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s491690760", "user_id": "u744908753"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "n=gets.to_i\na=gets.split.map(&:to_i)\nc4,c1=0,0\nf=true\na.each do |b|\n if b%4==0\n c4+=1\n elsif b.odd?\n c1+=1\n elsif f\n c1+=1\n f=false\n end\nend\nputs c4>c1-2 ? :Yes : :No\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a sequence of length N, a = (a_1, a_2, ..., a_N).\nEach a_i is a positive integer.\n\nSnuke's objective is to permute the element in a so that the following condition is satisfied:\n\nFor each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.\n\nDetermine whether Snuke can achieve his objective.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\na_i is an integer.\n\n1 ≤ a_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf Snuke can achieve his objective, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 10 100\n\nSample Output 1\n\nYes\n\nOne solution is (1, 100, 10).\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\nNo\n\nIt is impossible to permute a so that the condition is satisfied.\n\nSample Input 3\n\n3\n1 4 1\n\nSample Output 3\n\nYes\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n6\n2 7 1 8 2 8\n\nSample Output 5\n\nYes", "sample_input": "3\n1 10 100\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03637", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a sequence of length N, a = (a_1, a_2, ..., a_N).\nEach a_i is a positive integer.\n\nSnuke's objective is to permute the element in a so that the following condition is satisfied:\n\nFor each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.\n\nDetermine whether Snuke can achieve his objective.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\na_i is an integer.\n\n1 ≤ a_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf Snuke can achieve his objective, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 10 100\n\nSample Output 1\n\nYes\n\nOne solution is (1, 100, 10).\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\nNo\n\nIt is impossible to permute a so that the condition is satisfied.\n\nSample Input 3\n\n3\n1 4 1\n\nSample Output 3\n\nYes\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n6\n2 7 1 8 2 8\n\nSample Output 5\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 183, "cpu_time_ms": 58, "memory_kb": 8452}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s773395344", "group_id": "codeNet:p03637", "input_text": "require 'prime'\nrequire 'set'\nrequire 'tsort'\ninclude Math\nALP = ('a'..'z').to_a\nINF = 0xffffffffffffffff\ndef max(a,b); a > b ? a : b end\ndef min(a,b); a < b ? a : b end\ndef swap(a,b); a, b = b, a end\ndef gif; gets.to_i end\ndef gff; gets.to_f end\ndef gsf; gets.chomp end\ndef gi; gets.split.map(&:to_i) end\ndef gf; gets.split.map(&:to_f) end\ndef gs; gets.chomp.split.map(&:to_s) end\ndef gc; gets.chomp.split('') end\ndef pr(num); num.prime_division end\ndef pr?(num); Prime.prime?(num) end\ndef digit(num); num.to_s.length end\ndef array(s,ini=nil); Array.new(s){ini} end\ndef darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}} end\ndef rep(num); num.times{|i|yield(i)} end\ndef repl(st,en,n=1); st.step(en,n){|i|yield(i)} end\n\nn = gif\na = gi\nsize = a.size\nnum4 = a.select{|aa| aa % 4 == 0}.size\nnum = a.select{|aa| aa % 2 != 0}.size\nnum2 = a.select{|aa| aa % 2 == 0}.size\nans = num4 - num\nputs ans >= 1 && num2 % 2 == 0 ? \"Yes\" : \"No\"\n", "language": "Ruby", "metadata": {"date": 1510631808, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03637.html", "problem_id": "p03637", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03637/input.txt", "sample_output_relpath": "derived/input_output/data/p03637/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03637/Ruby/s773395344.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s773395344", "user_id": "u988228861"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "require 'prime'\nrequire 'set'\nrequire 'tsort'\ninclude Math\nALP = ('a'..'z').to_a\nINF = 0xffffffffffffffff\ndef max(a,b); a > b ? a : b end\ndef min(a,b); a < b ? a : b end\ndef swap(a,b); a, b = b, a end\ndef gif; gets.to_i end\ndef gff; gets.to_f end\ndef gsf; gets.chomp end\ndef gi; gets.split.map(&:to_i) end\ndef gf; gets.split.map(&:to_f) end\ndef gs; gets.chomp.split.map(&:to_s) end\ndef gc; gets.chomp.split('') end\ndef pr(num); num.prime_division end\ndef pr?(num); Prime.prime?(num) end\ndef digit(num); num.to_s.length end\ndef array(s,ini=nil); Array.new(s){ini} end\ndef darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}} end\ndef rep(num); num.times{|i|yield(i)} end\ndef repl(st,en,n=1); st.step(en,n){|i|yield(i)} end\n\nn = gif\na = gi\nsize = a.size\nnum4 = a.select{|aa| aa % 4 == 0}.size\nnum = a.select{|aa| aa % 2 != 0}.size\nnum2 = a.select{|aa| aa % 2 == 0}.size\nans = num4 - num\nputs ans >= 1 && num2 % 2 == 0 ? \"Yes\" : \"No\"\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a sequence of length N, a = (a_1, a_2, ..., a_N).\nEach a_i is a positive integer.\n\nSnuke's objective is to permute the element in a so that the following condition is satisfied:\n\nFor each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.\n\nDetermine whether Snuke can achieve his objective.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\na_i is an integer.\n\n1 ≤ a_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf Snuke can achieve his objective, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 10 100\n\nSample Output 1\n\nYes\n\nOne solution is (1, 100, 10).\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\nNo\n\nIt is impossible to permute a so that the condition is satisfied.\n\nSample Input 3\n\n3\n1 4 1\n\nSample Output 3\n\nYes\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n6\n2 7 1 8 2 8\n\nSample Output 5\n\nYes", "sample_input": "3\n1 10 100\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03637", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a sequence of length N, a = (a_1, a_2, ..., a_N).\nEach a_i is a positive integer.\n\nSnuke's objective is to permute the element in a so that the following condition is satisfied:\n\nFor each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.\n\nDetermine whether Snuke can achieve his objective.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\na_i is an integer.\n\n1 ≤ a_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf Snuke can achieve his objective, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 10 100\n\nSample Output 1\n\nYes\n\nOne solution is (1, 100, 10).\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\nNo\n\nIt is impossible to permute a so that the condition is satisfied.\n\nSample Input 3\n\n3\n1 4 1\n\nSample Output 3\n\nYes\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n6\n2 7 1 8 2 8\n\nSample Output 5\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1574, "cpu_time_ms": 80, "memory_kb": 10732}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s515457167", "group_id": "codeNet:p03643", "input_text": "puts \"ABC#{gets}\"", "language": "Ruby", "metadata": {"date": 1572566893, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03643.html", "problem_id": "p03643", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03643/input.txt", "sample_output_relpath": "derived/input_output/data/p03643/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03643/Ruby/s515457167.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s515457167", "user_id": "u585819925"}, "prompt_components": {"gold_output": "ABC100\n", "input_to_evaluate": "puts \"ABC#{gets}\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThis contest, AtCoder Beginner Contest, is abbreviated as ABC.\n\nWhen we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC.\n\nWhat is the abbreviation for the N-th round of ABC? Write a program to output the answer.\n\nConstraints\n\n100 ≤ N ≤ 999\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the abbreviation for the N-th round of ABC.\n\nSample Input 1\n\n100\n\nSample Output 1\n\nABC100\n\nThe 100th round of ABC is ABC100.\n\nSample Input 2\n\n425\n\nSample Output 2\n\nABC425\n\nSample Input 3\n\n999\n\nSample Output 3\n\nABC999", "sample_input": "100\n"}, "reference_outputs": ["ABC100\n"], "source_document_id": "p03643", "source_text": "Score : 100 points\n\nProblem Statement\n\nThis contest, AtCoder Beginner Contest, is abbreviated as ABC.\n\nWhen we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC.\n\nWhat is the abbreviation for the N-th round of ABC? Write a program to output the answer.\n\nConstraints\n\n100 ≤ N ≤ 999\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the abbreviation for the N-th round of ABC.\n\nSample Input 1\n\n100\n\nSample Output 1\n\nABC100\n\nThe 100th round of ABC is ABC100.\n\nSample Input 2\n\n425\n\nSample Output 2\n\nABC425\n\nSample Input 3\n\n999\n\nSample Output 3\n\nABC999", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 17, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s101793409", "group_id": "codeNet:p03644", "input_text": "n = gets.chomp.to_i\nall = 0\nif n % 2 == 1\n all += 1\nend\ncount = 0\nif n % 2 == 0\n while n % 2 == 0\n n = n / 2\n count += 1\n end\nend\nif all <= 0\nputs count\nelse\n puts \"0\"\nend", "language": "Ruby", "metadata": {"date": 1592352139, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s101793409.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s101793409", "user_id": "u412789323"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "n = gets.chomp.to_i\nall = 0\nif n % 2 == 1\n all += 1\nend\ncount = 0\nif n % 2 == 0\n while n % 2 == 0\n n = n / 2\n count += 1\n end\nend\nif all <= 0\nputs count\nelse\n puts \"0\"\nend", "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": 189, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s236253463", "group_id": "codeNet:p03644", "input_text": "n = gets.to_i\nmax = 0\narray = []\n\n(1..n).each do |num|\n cnt = 0\n while true do\n if num % 2 == 0\n cnt += 1\n num /= 0\n else\n break\n end\n end\n array.push(cnt)\nend\nputs 2** array.max", "language": "Ruby", "metadata": {"date": 1580446338, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s236253463.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s236253463", "user_id": "u809809975"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "n = gets.to_i\nmax = 0\narray = []\n\n(1..n).each do |num|\n cnt = 0\n while true do\n if num % 2 == 0\n cnt += 1\n num /= 0\n else\n break\n end\n end\n array.push(cnt)\nend\nputs 2** array.max", "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": 206, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s270647676", "group_id": "codeNet:p03644", "input_text": "n = gets.to_i\ni=1\nwhile i 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": 45, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s843131638", "group_id": "codeNet:p03644", "input_text": "n = gets.to_i\nx = 1\nwhile x <= n\n x *= 2\nend\nputs x / 2", "language": "Ruby", "metadata": {"date": 1505723943, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s843131638.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s843131638", "user_id": "u001025229"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "n = gets.to_i\nx = 1\nwhile x <= n\n x *= 2\nend\nputs x / 2", "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": 56, "cpu_time_ms": 7, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s847216124", "group_id": "codeNet:p03647", "input_text": "N,M = gets.split.map(&:to_i)\nfrom1 = []\ntoN = []\nM.times{\n a,b = gets.split.map(&:to_i)\n from1 << b if a == 1\n toN << a if b == N\n}\n\nputs (from1&toN).size > 0 ? \"POSSIBLE\":\"IMPOSSIBLE\"", "language": "Ruby", "metadata": {"date": 1504472175, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03647.html", "problem_id": "p03647", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03647/input.txt", "sample_output_relpath": "derived/input_output/data/p03647/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03647/Ruby/s847216124.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s847216124", "user_id": "u397763977"}, "prompt_components": {"gold_output": "POSSIBLE\n", "input_to_evaluate": "N,M = gets.split.map(&:to_i)\nfrom1 = []\ntoN = []\nM.times{\n a,b = gets.split.map(&:to_i)\n from1 << b if a == 1\n toN << a if b == N\n}\n\nputs (from1&toN).size > 0 ? \"POSSIBLE\":\"IMPOSSIBLE\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands.\nFor convenience, we will call them Island 1, Island 2, ..., Island N.\n\nThere are M kinds of regular boat services between these islands.\nEach service connects two islands. The i-th service connects Island a_i and Island b_i.\n\nCat Snuke is on Island 1 now, and wants to go to Island N.\nHowever, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services.\n\nHelp him.\n\nConstraints\n\n3 ≤ N ≤ 200 000\n\n1 ≤ M ≤ 200 000\n\n1 ≤ a_i < b_i ≤ N\n\n(a_i, b_i) \\neq (1, N)\n\nIf i \\neq j, (a_i, b_i) \\neq (a_j, b_j).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nIf it is possible to go to Island N by using two boat services, print POSSIBLE; otherwise, print IMPOSSIBLE.\n\nSample Input 1\n\n3 2\n1 2\n2 3\n\nSample Output 1\n\nPOSSIBLE\n\nSample Input 2\n\n4 3\n1 2\n2 3\n3 4\n\nSample Output 2\n\nIMPOSSIBLE\n\nYou have to use three boat services to get to Island 4.\n\nSample Input 3\n\n100000 1\n1 99999\n\nSample Output 3\n\nIMPOSSIBLE\n\nSample Input 4\n\n5 5\n1 3\n4 5\n2 3\n2 4\n1 4\n\nSample Output 4\n\nPOSSIBLE\n\nYou can get to Island 5 by using two boat services: Island 1 -> Island 4 -> Island 5.", "sample_input": "3 2\n1 2\n2 3\n"}, "reference_outputs": ["POSSIBLE\n"], "source_document_id": "p03647", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands.\nFor convenience, we will call them Island 1, Island 2, ..., Island N.\n\nThere are M kinds of regular boat services between these islands.\nEach service connects two islands. The i-th service connects Island a_i and Island b_i.\n\nCat Snuke is on Island 1 now, and wants to go to Island N.\nHowever, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services.\n\nHelp him.\n\nConstraints\n\n3 ≤ N ≤ 200 000\n\n1 ≤ M ≤ 200 000\n\n1 ≤ a_i < b_i ≤ N\n\n(a_i, b_i) \\neq (1, N)\n\nIf i \\neq j, (a_i, b_i) \\neq (a_j, b_j).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nIf it is possible to go to Island N by using two boat services, print POSSIBLE; otherwise, print IMPOSSIBLE.\n\nSample Input 1\n\n3 2\n1 2\n2 3\n\nSample Output 1\n\nPOSSIBLE\n\nSample Input 2\n\n4 3\n1 2\n2 3\n3 4\n\nSample Output 2\n\nIMPOSSIBLE\n\nYou have to use three boat services to get to Island 4.\n\nSample Input 3\n\n100000 1\n1 99999\n\nSample Output 3\n\nIMPOSSIBLE\n\nSample Input 4\n\n5 5\n1 3\n4 5\n2 3\n2 4\n1 4\n\nSample Output 4\n\nPOSSIBLE\n\nYou can get to Island 5 by using two boat services: Island 1 -> Island 4 -> Island 5.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 187, "cpu_time_ms": 303, "memory_kb": 9868}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s055059271", "group_id": "codeNet:p03651", "input_text": "N,K,*A=(dd).split.map &:to_i;puts\"#{:IM if K%A.reduce(:gcd)>0||K>A.max}POSSIBLE\"", "language": "Ruby", "metadata": {"date": 1500870065, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03651.html", "problem_id": "p03651", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03651/input.txt", "sample_output_relpath": "derived/input_output/data/p03651/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03651/Ruby/s055059271.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s055059271", "user_id": "u032223772"}, "prompt_components": {"gold_output": "POSSIBLE\n", "input_to_evaluate": "N,K,*A=(dd).split.map &:to_i;puts\"#{:IM if K%A.reduce(:gcd)>0||K>A.max}POSSIBLE\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a box containing N balls. The i-th ball has the integer A_i written on it.\nSnuke can perform the following operation any number of times:\n\nTake out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is written.\n\nDetermine whether it is possible for Snuke to reach the state where the box contains a ball on which the integer K is written.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq K \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nIf it is possible for Snuke to reach the state where the box contains a ball on which the integer K is written, print POSSIBLE; if it is not possible, print IMPOSSIBLE.\n\nSample Input 1\n\n3 7\n9 3 4\n\nSample Output 1\n\nPOSSIBLE\n\nFirst, take out the two balls 9 and 4, and return them back along with a new ball, abs(9-4)=5.\nNext, take out 3 and 5, and return them back along with abs(3-5)=2.\nFinally, take out 9 and 2, and return them back along with abs(9-2)=7.\nNow we have 7 in the box, and the answer is therefore POSSIBLE.\n\nSample Input 2\n\n3 5\n6 9 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nNo matter what we do, it is not possible to have 5 in the box. The answer is therefore IMPOSSIBLE.\n\nSample Input 3\n\n4 11\n11 3 7 15\n\nSample Output 3\n\nPOSSIBLE\n\nThe box already contains 11 before we do anything. The answer is therefore POSSIBLE.\n\nSample Input 4\n\n5 12\n10 2 8 6 4\n\nSample Output 4\n\nIMPOSSIBLE", "sample_input": "3 7\n9 3 4\n"}, "reference_outputs": ["POSSIBLE\n"], "source_document_id": "p03651", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a box containing N balls. The i-th ball has the integer A_i written on it.\nSnuke can perform the following operation any number of times:\n\nTake out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is written.\n\nDetermine whether it is possible for Snuke to reach the state where the box contains a ball on which the integer K is written.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq K \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nIf it is possible for Snuke to reach the state where the box contains a ball on which the integer K is written, print POSSIBLE; if it is not possible, print IMPOSSIBLE.\n\nSample Input 1\n\n3 7\n9 3 4\n\nSample Output 1\n\nPOSSIBLE\n\nFirst, take out the two balls 9 and 4, and return them back along with a new ball, abs(9-4)=5.\nNext, take out 3 and 5, and return them back along with abs(3-5)=2.\nFinally, take out 9 and 2, and return them back along with abs(9-2)=7.\nNow we have 7 in the box, and the answer is therefore POSSIBLE.\n\nSample Input 2\n\n3 5\n6 9 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nNo matter what we do, it is not possible to have 5 in the box. The answer is therefore IMPOSSIBLE.\n\nSample Input 3\n\n4 11\n11 3 7 15\n\nSample Output 3\n\nPOSSIBLE\n\nThe box already contains 11 before we do anything. The answer is therefore POSSIBLE.\n\nSample Input 4\n\n5 12\n10 2 8 6 4\n\nSample Output 4\n\nIMPOSSIBLE", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 80, "cpu_time_ms": 8, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s784286915", "group_id": "codeNet:p03657", "input_text": "A, B = gets.split.map(&:to_i)\nif A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0\n puts 'Possible'\nelse\n puts 'Impossible'\nend", "language": "Ruby", "metadata": {"date": 1583994124, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s784286915.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s784286915", "user_id": "u104886851"}, "prompt_components": {"gold_output": "Possible\n", "input_to_evaluate": "A, B = gets.split.map(&:to_i)\nif A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0\n puts 'Possible'\nelse\n puts 'Impossible'\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke is giving cookies to his three goats.\n\nHe has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).\n\nYour task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.\n\nConstraints\n\n1 \\leq A,B \\leq 100\n\nBoth A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf it is possible to give cookies so that each of the three goats can have the same number of cookies, print Possible; otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nPossible\n\nIf Snuke gives nine cookies, each of the three goats can have three cookies.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\nImpossible\n\nSince there are only two cookies, the three goats cannot have the same number of cookies no matter what Snuke gives to them.", "sample_input": "4 5\n"}, "reference_outputs": ["Possible\n"], "source_document_id": "p03657", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke is giving cookies to his three goats.\n\nHe has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).\n\nYour task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.\n\nConstraints\n\n1 \\leq A,B \\leq 100\n\nBoth A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf it is possible to give cookies so that each of the three goats can have the same number of cookies, print Possible; otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nPossible\n\nIf Snuke gives nine cookies, each of the three goats can have three cookies.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\nImpossible\n\nSince there are only two cookies, the three goats cannot have the same number of cookies no matter what Snuke gives to them.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 124, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s034491810", "group_id": "codeNet:p03657", "input_text": "str = gets().split(\" \")\na = str[0].to_i\nb = str[1].to_i\n\nif(a%3==0)\n\tputs(\"Possible\\n\")\nelsif(b%3==0)\n\tputs(\"Possible\\n\")\nelsif((a+b)%3==0)\n\tputs(\"Possible\\n\")\nelse\n\tputs(\"Impossible\\n\")\nend\n", "language": "Ruby", "metadata": {"date": 1500168066, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s034491810.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s034491810", "user_id": "u649326276"}, "prompt_components": {"gold_output": "Possible\n", "input_to_evaluate": "str = gets().split(\" \")\na = str[0].to_i\nb = str[1].to_i\n\nif(a%3==0)\n\tputs(\"Possible\\n\")\nelsif(b%3==0)\n\tputs(\"Possible\\n\")\nelsif((a+b)%3==0)\n\tputs(\"Possible\\n\")\nelse\n\tputs(\"Impossible\\n\")\nend\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": 191, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s159875606", "group_id": "codeNet:p03658", "input_text": "n, k = STDIN.gets.split(' ').map(&:to_i)\nsticks = STDIN.gets.split(' ').map(&:to_i).sort{|a, b| b <=> a }\n\nputs sticks.take(k).reduce(&:+)", "language": "Ruby", "metadata": {"date": 1540012863, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03658.html", "problem_id": "p03658", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03658/input.txt", "sample_output_relpath": "derived/input_output/data/p03658/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03658/Ruby/s159875606.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s159875606", "user_id": "u237620737"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "n, k = STDIN.gets.split(' ').map(&:to_i)\nsticks = STDIN.gets.split(' ').map(&:to_i).sort{|a, b| b <=> a }\n\nputs sticks.take(k).reduce(&:+)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke has N sticks.\nThe length of the i-th stick is l_i.\n\nSnuke is making a snake toy by joining K of the sticks together.\n\nThe length of the toy is represented by the sum of the individual sticks that compose it.\nFind the maximum possible length of the toy.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 50\n\n1 \\leq l_i \\leq 50\n\nl_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nl_1 l_2 l_3 ... l_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5 3\n1 2 3 4 5\n\nSample Output 1\n\n12\n\nYou can make a toy of length 12 by joining the sticks of lengths 3, 4 and 5, which is the maximum possible length.\n\nSample Input 2\n\n15 14\n50 26 27 21 41 7 42 35 7 5 5 36 39 1 45\n\nSample Output 2\n\n386", "sample_input": "5 3\n1 2 3 4 5\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03658", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke has N sticks.\nThe length of the i-th stick is l_i.\n\nSnuke is making a snake toy by joining K of the sticks together.\n\nThe length of the toy is represented by the sum of the individual sticks that compose it.\nFind the maximum possible length of the toy.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 50\n\n1 \\leq l_i \\leq 50\n\nl_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nl_1 l_2 l_3 ... l_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5 3\n1 2 3 4 5\n\nSample Output 1\n\n12\n\nYou can make a toy of length 12 by joining the sticks of lengths 3, 4 and 5, which is the maximum possible length.\n\nSample Input 2\n\n15 14\n50 26 27 21 41 7 42 35 7 5 5 36 39 1 45\n\nSample Output 2\n\n386", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 138, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s005010305", "group_id": "codeNet:p03658", "input_text": "n,k = gets.split.map(&:to_i)\nlen = gets.chomp.split.map(&:to_i)\nmax = len[0]\nindex = 0\nans = 0\nk.times do |i|\n n.times do |j|\n if maxb\n\t\t\ta = b\n\t\telse\n\t\t\tbreak if arr.any?.with_index(i+1){|n| n<0}\n\t\tend\n\tend\nend\nputs a", "language": "Ruby", "metadata": {"date": 1500171024, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03659.html", "problem_id": "p03659", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03659/input.txt", "sample_output_relpath": "derived/input_output/data/p03659/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03659/Ruby/s309440206.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s309440206", "user_id": "u680963280"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n = gets\narr = gets.chomp.split(' ').map(&:to_i)\nif arr.length==2\n\ta = (arr.first-arr.last).abs\nelse\n\tlast = arr.length-1\n\ta = 0\n\tb = 0\n\tarr.each_with_index do |n,i|\n\t\tleft = 0\n\t\tright = 0\n\t\tfor h in 0..i\n\t\t\tleft += arr[h]\n\t\tend\n\t\tfor h in (i+1)..last\n\t\t\tright += arr[h]\n\t\tend\n\t\ta = (left-right).abs and next if i==0\n\t\tb = (left-right).abs\n\t\tif a>b\n\t\t\ta = b\n\t\telse\n\t\t\tbreak if arr.any?.with_index(i+1){|n| n<0}\n\t\tend\n\tend\nend\nputs a", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.\n\nThey will share these cards.\nFirst, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards.\nHere, both Snuke and Raccoon have to take at least one card.\n\nLet the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively.\nThey would like to minimize |x-y|.\nFind the minimum possible value of |x-y|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n-10^{9} \\leq a_i \\leq 10^{9}\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6\n1 2 3 4 5 6\n\nSample Output 1\n\n1\n\nIf Snuke takes four cards from the top, and Raccoon takes the remaining two cards, x=10, y=11, and thus |x-y|=1. This is the minimum possible value.\n\nSample Input 2\n\n2\n10 -10\n\nSample Output 2\n\n20\n\nSnuke can only take one card from the top, and Raccoon can only take the remaining one card. In this case, x=10, y=-10, and thus |x-y|=20.", "sample_input": "6\n1 2 3 4 5 6\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03659", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.\n\nThey will share these cards.\nFirst, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards.\nHere, both Snuke and Raccoon have to take at least one card.\n\nLet the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively.\nThey would like to minimize |x-y|.\nFind the minimum possible value of |x-y|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n-10^{9} \\leq a_i \\leq 10^{9}\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6\n1 2 3 4 5 6\n\nSample Output 1\n\n1\n\nIf Snuke takes four cards from the top, and Raccoon takes the remaining two cards, x=10, y=11, and thus |x-y|=1. This is the minimum possible value.\n\nSample Input 2\n\n2\n10 -10\n\nSample Output 2\n\n20\n\nSnuke can only take one card from the top, and Raccoon can only take the remaining one card. In this case, x=10, y=-10, and thus |x-y|=20.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 432, "cpu_time_ms": 142, "memory_kb": 16524}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s225328940", "group_id": "codeNet:p03662", "input_text": "def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end\ndef inpf() a=gets.chomp.split(\" \").map(&:to_f)end\ndef inps() a=gets.chomp.split(\" \")end \ndef copy(a) Marshal.load(Marshal.dump(a)) end\ndef kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end\ndef scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end\ndef na(n,d=0) Array.new(n,d)end\ndef na2(n,m,d=0) Array.new(n){Array.new(m,d)}end\ndef na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end\ndef bit(n) n.to_s(2).split(\"\").map(&:to_i) end\ndef inp() a=gets.chomp.split(\" \").map(&:to_i)end\nn = inp[0]\ntab = na2(n+1,0)\nlis = na(n+1,0)\n(n-1).times do\n dat = inp\n tab[dat[0]].push(dat[1])\n tab[dat[1]].push(dat[0])\nend\nfn = 1\nff = 1\nlis[1] = 1\nlis[n] = 1\nque1 = []\nque2 = []\ntab[1].each do |d|\n que1.push(d) \nend\ntab[n].each do |d|\n que2.push(d)\nend\nwhile (que1.size > 0 and que2.size > 0)\n if(que1.size > 0)\n now = que1.shift\n if(lis[now] != 1)\n fn += 1\n lis[now] = 1\n tab[now].each do |d|\n que1.push(d) \n end\n end\n else\n end\n if(que2.size > 0)\n now = que2.shift\n if(lis[now] != 1)\n lis[now] = 1\n ff += 1\n tab[now].each do |d|\n que2.push(d)\n end\n end\n end\nend\nputs (fn > n/2)? \"Fennec\" : \"Snuke\"\n", "language": "Ruby", "metadata": {"date": 1500170530, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03662.html", "problem_id": "p03662", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03662/input.txt", "sample_output_relpath": "derived/input_output/data/p03662/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03662/Ruby/s225328940.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s225328940", "user_id": "u145123922"}, "prompt_components": {"gold_output": "Fennec\n", "input_to_evaluate": "def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end\ndef inpf() a=gets.chomp.split(\" \").map(&:to_f)end\ndef inps() a=gets.chomp.split(\" \")end \ndef copy(a) Marshal.load(Marshal.dump(a)) end\ndef kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end\ndef scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end\ndef na(n,d=0) Array.new(n,d)end\ndef na2(n,m,d=0) Array.new(n){Array.new(m,d)}end\ndef na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end\ndef bit(n) n.to_s(2).split(\"\").map(&:to_i) end\ndef inp() a=gets.chomp.split(\" \").map(&:to_i)end\nn = inp[0]\ntab = na2(n+1,0)\nlis = na(n+1,0)\n(n-1).times do\n dat = inp\n tab[dat[0]].push(dat[1])\n tab[dat[1]].push(dat[0])\nend\nfn = 1\nff = 1\nlis[1] = 1\nlis[n] = 1\nque1 = []\nque2 = []\ntab[1].each do |d|\n que1.push(d) \nend\ntab[n].each do |d|\n que2.push(d)\nend\nwhile (que1.size > 0 and que2.size > 0)\n if(que1.size > 0)\n now = que1.shift\n if(lis[now] != 1)\n fn += 1\n lis[now] = 1\n tab[now].each do |d|\n que1.push(d) \n end\n end\n else\n end\n if(que2.size > 0)\n now = que2.shift\n if(lis[now] != 1)\n lis[now] = 1\n ff += 1\n tab[now].each do |d|\n que2.push(d)\n end\n end\n end\nend\nputs (fn > n/2)? \"Fennec\" : \"Snuke\"\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFennec and Snuke are playing a board game.\n\nOn the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree.\n\nInitially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored.\nFennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell.\nMore specifically, each player performs the following action in her/his turn:\n\nFennec: selects an uncolored cell that is adjacent to a black cell, and paints it black.\n\nSnuke: selects an uncolored cell that is adjacent to a white cell, and paints it white.\n\nA player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nIf Fennec wins, print Fennec; if Snuke wins, print Snuke.\n\nSample Input 1\n\n7\n3 6\n1 2\n3 1\n7 4\n5 7\n1 4\n\nSample Output 1\n\nFennec\n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of Snuke's moves.\n\nSample Input 2\n\n4\n1 4\n4 2\n2 3\n\nSample Output 2\n\nSnuke", "sample_input": "7\n3 6\n1 2\n3 1\n7 4\n5 7\n1 4\n"}, "reference_outputs": ["Fennec\n"], "source_document_id": "p03662", "source_text": "Score : 400 points\n\nProblem Statement\n\nFennec and Snuke are playing a board game.\n\nOn the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree.\n\nInitially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored.\nFennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell.\nMore specifically, each player performs the following action in her/his turn:\n\nFennec: selects an uncolored cell that is adjacent to a black cell, and paints it black.\n\nSnuke: selects an uncolored cell that is adjacent to a white cell, and paints it white.\n\nA player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nIf Fennec wins, print Fennec; if Snuke wins, print Snuke.\n\nSample Input 1\n\n7\n3 6\n1 2\n3 1\n7 4\n5 7\n1 4\n\nSample Output 1\n\nFennec\n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of Snuke's moves.\n\nSample Input 2\n\n4\n1 4\n4 2\n2 3\n\nSample Output 2\n\nSnuke", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1237, "cpu_time_ms": 257, "memory_kb": 12796}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s286519774", "group_id": "codeNet:p03672", "input_text": "s = gets.chomp\n(s.length - 2).step(2, -2) do |i|\n if (0..(i / 2 - 1)).all? { |j| s[j] == s[i/2+j] }\n puts i \n exit\n end\nend", "language": "Ruby", "metadata": {"date": 1498961062, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s286519774.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s286519774", "user_id": "u286149069"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "s = gets.chomp\n(s.length - 2).step(2, -2) do |i|\n if (0..(i / 2 - 1)).all? { |j| s[j] == s[i/2+j] }\n puts i \n exit\n end\nend", "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": 143, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s752227239", "group_id": "codeNet:p03673", "input_text": "lines = $stdin.read\narray = lines.split(\"\\n\")\n\nn = array[0].to_i\na = array[1].split(\" \").map(&:to_i)\nb = []\n\nfor i in 0...(a.length)\n\n if n % 2 == 0\n if i % 2 == 0\n b.push a[i]\n else\n b.unshift a[i]\n end\n else\n if i % 2 == 1\n b.push a[i]\n else\n b.unshift a[i]\n end\n end\n\n #b.push(a[i])\n #b.reverse!\nend\n\nputs b.join(\" \")\n", "language": "Ruby", "metadata": {"date": 1498961250, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03673.html", "problem_id": "p03673", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03673/input.txt", "sample_output_relpath": "derived/input_output/data/p03673/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03673/Ruby/s752227239.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s752227239", "user_id": "u108333452"}, "prompt_components": {"gold_output": "4 2 1 3\n", "input_to_evaluate": "lines = $stdin.read\narray = lines.split(\"\\n\")\n\nn = array[0].to_i\na = array[1].split(\" \").map(&:to_i)\nb = []\n\nfor i in 0...(a.length)\n\n if n % 2 == 0\n if i % 2 == 0\n b.push a[i]\n else\n b.unshift a[i]\n end\n else\n if i % 2 == 1\n b.push a[i]\n else\n b.unshift a[i]\n end\n end\n\n #b.push(a[i])\n #b.reverse!\nend\n\nputs b.join(\" \")\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length n, a_1, ..., a_n.\nLet us consider performing the following n operations on an empty sequence b.\n\nThe i-th operation is as follows:\n\nAppend a_i to the end of b.\n\nReverse the order of the elements in b.\n\nFind the sequence b obtained after these n operations.\n\nConstraints\n\n1 \\leq n \\leq 2\\times 10^5\n\n0 \\leq a_i \\leq 10^9\n\nn and a_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint n integers in a line with spaces in between.\nThe i-th integer should be b_i.\n\nSample Input 1\n\n4\n1 2 3 4\n\nSample Output 1\n\n4 2 1 3\n\nAfter step 1 of the first operation, b becomes: 1.\n\nAfter step 2 of the first operation, b becomes: 1.\n\nAfter step 1 of the second operation, b becomes: 1, 2.\n\nAfter step 2 of the second operation, b becomes: 2, 1.\n\nAfter step 1 of the third operation, b becomes: 2, 1, 3.\n\nAfter step 2 of the third operation, b becomes: 3, 1, 2.\n\nAfter step 1 of the fourth operation, b becomes: 3, 1, 2, 4.\n\nAfter step 2 of the fourth operation, b becomes: 4, 2, 1, 3.\n\nThus, the answer is 4 2 1 3.\n\nSample Input 2\n\n3\n1 2 3\n\nSample Output 2\n\n3 1 2\n\nAs shown above in Sample Output 1, b becomes 3, 1, 2 after step 2 of the third operation. Thus, the answer is 3 1 2.\n\nSample Input 3\n\n1\n1000000000\n\nSample Output 3\n\n1000000000\n\nSample Input 4\n\n6\n0 6 7 6 7 0\n\nSample Output 4\n\n0 6 6 0 7 7", "sample_input": "4\n1 2 3 4\n"}, "reference_outputs": ["4 2 1 3\n"], "source_document_id": "p03673", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length n, a_1, ..., a_n.\nLet us consider performing the following n operations on an empty sequence b.\n\nThe i-th operation is as follows:\n\nAppend a_i to the end of b.\n\nReverse the order of the elements in b.\n\nFind the sequence b obtained after these n operations.\n\nConstraints\n\n1 \\leq n \\leq 2\\times 10^5\n\n0 \\leq a_i \\leq 10^9\n\nn and a_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint n integers in a line with spaces in between.\nThe i-th integer should be b_i.\n\nSample Input 1\n\n4\n1 2 3 4\n\nSample Output 1\n\n4 2 1 3\n\nAfter step 1 of the first operation, b becomes: 1.\n\nAfter step 2 of the first operation, b becomes: 1.\n\nAfter step 1 of the second operation, b becomes: 1, 2.\n\nAfter step 2 of the second operation, b becomes: 2, 1.\n\nAfter step 1 of the third operation, b becomes: 2, 1, 3.\n\nAfter step 2 of the third operation, b becomes: 3, 1, 2.\n\nAfter step 1 of the fourth operation, b becomes: 3, 1, 2, 4.\n\nAfter step 2 of the fourth operation, b becomes: 4, 2, 1, 3.\n\nThus, the answer is 4 2 1 3.\n\nSample Input 2\n\n3\n1 2 3\n\nSample Output 2\n\n3 1 2\n\nAs shown above in Sample Output 1, b becomes 3, 1, 2 after step 2 of the third operation. Thus, the answer is 3 1 2.\n\nSample Input 3\n\n1\n1000000000\n\nSample Output 3\n\n1000000000\n\nSample Input 4\n\n6\n0 6 7 6 7 0\n\nSample Output 4\n\n0 6 6 0 7 7", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 364, "cpu_time_ms": 242, "memory_kb": 27612}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s811633140", "group_id": "codeNet:p03679", "input_text": "X, A, B = gets.split.map(&:to_i)\n\nif A-B >= 0\n\tprint \"delicious\"\nelsif A+X >= B\n\tprint \"safe\"\nelse\n\tprint \"dangerous\"\nend\n\n", "language": "Ruby", "metadata": {"date": 1533788426, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s811633140.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s811633140", "user_id": "u118284895"}, "prompt_components": {"gold_output": "safe\n", "input_to_evaluate": "X, A, B = gets.split.map(&:to_i)\n\nif A-B >= 0\n\tprint \"delicious\"\nelsif A+X >= B\n\tprint \"safe\"\nelse\n\tprint \"dangerous\"\nend\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": 123, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s275501886", "group_id": "codeNet:p03694", "input_text": "n = gets.to_i\na = gets.split.map(&:to_i)\na.sort!\nans = a[n-1] - a[0]\nputs ans\n", "language": "Ruby", "metadata": {"date": 1497143380, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03694.html", "problem_id": "p03694", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03694/input.txt", "sample_output_relpath": "derived/input_output/data/p03694/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03694/Ruby/s275501886.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s275501886", "user_id": "u123276241"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "n = gets.to_i\na = gets.split.map(&:to_i)\na.sort!\nans = a[n-1] - a[0]\nputs ans\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIt is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts.\n\nThere are N houses along TopCoDeer street. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses.\n\nFind the minimum distance to be traveled when AtCoDeer can start and end his travel at any positions.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n0 ≤ a_i ≤ 1000\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 distance to be traveled.\n\nSample Input 1\n\n4\n2 3 7 9\n\nSample Output 1\n\n7\n\nThe travel distance of 7 can be achieved by starting at coordinate 9 and traveling straight to coordinate 2.\n\nIt is not possible to do with a travel distance of less than 7, and thus 7 is the minimum distance to be traveled.\n\nSample Input 2\n\n8\n3 1 4 1 5 9 2 6\n\nSample Output 2\n\n8\n\nThere may be more than one house at a position.", "sample_input": "4\n2 3 7 9\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03694", "source_text": "Score : 200 points\n\nProblem Statement\n\nIt is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts.\n\nThere are N houses along TopCoDeer street. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses.\n\nFind the minimum distance to be traveled when AtCoDeer can start and end his travel at any positions.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n0 ≤ a_i ≤ 1000\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 distance to be traveled.\n\nSample Input 1\n\n4\n2 3 7 9\n\nSample Output 1\n\n7\n\nThe travel distance of 7 can be achieved by starting at coordinate 9 and traveling straight to coordinate 2.\n\nIt is not possible to do with a travel distance of less than 7, and thus 7 is the minimum distance to be traveled.\n\nSample Input 2\n\n8\n3 1 4 1 5 9 2 6\n\nSample Output 2\n\n8\n\nThere may be more than one house at a position.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 78, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s604588464", "group_id": "codeNet:p03695", "input_text": "N = gets.to_i\nscores = gets.split.map(&:to_i)\n\n# 灰, 茶, 緑, 水, 青, 黄, 橙, 赤, 自由\ncolor = Array.new(9, 0)\n\nscores.each do |i|\n\tif i < 400\n\t\tcolor[0] += 1\n\telsif i < 800\n\t\tcolor[1] += 1\n\telsif i < 1200\n\t\tcolor[2] += 1\n\telsif i < 1600\n\t\tcolor[3] += 1\n\telsif i < 2000\n\t\tcolor[4] += 1\n\telsif i < 2400\n\t\tcolor[5] += 1\n\telsif i < 2800\n\t\tcolor[6] += 1\n\telsif i < 3200\n\t\tcolor[7] += 1\n\telse\n\t\tcolor[8] += 1\n\tend\nend\n\nans_min = color[0..7].count {|i| 0 < i}\n\nif 8-ans_min <= color[8]\n\tans_max = 8\nelse\n\tans_max = ans_min + color[8]\nend\n\np \"#{ans_min} #{ans_max}\"\n", "language": "Ruby", "metadata": {"date": 1535930675, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s604588464.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s604588464", "user_id": "u118284895"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "N = gets.to_i\nscores = gets.split.map(&:to_i)\n\n# 灰, 茶, 緑, 水, 青, 黄, 橙, 赤, 自由\ncolor = Array.new(9, 0)\n\nscores.each do |i|\n\tif i < 400\n\t\tcolor[0] += 1\n\telsif i < 800\n\t\tcolor[1] += 1\n\telsif i < 1200\n\t\tcolor[2] += 1\n\telsif i < 1600\n\t\tcolor[3] += 1\n\telsif i < 2000\n\t\tcolor[4] += 1\n\telsif i < 2400\n\t\tcolor[5] += 1\n\telsif i < 2800\n\t\tcolor[6] += 1\n\telsif i < 3200\n\t\tcolor[7] += 1\n\telse\n\t\tcolor[8] += 1\n\tend\nend\n\nans_min = color[0..7].count {|i| 0 < i}\n\nif 8-ans_min <= color[8]\n\tans_max = 8\nelse\n\tans_max = ans_min + color[8]\nend\n\np \"#{ans_min} #{ans_max}\"\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn AtCoder, a person who has participated in a contest receives a color, which corresponds to the person's rating as follows:\n\nRating 1-399 : gray\n\nRating 400-799 : brown\n\nRating 800-1199 : green\n\nRating 1200-1599 : cyan\n\nRating 1600-1999 : blue\n\nRating 2000-2399 : yellow\n\nRating 2400-2799 : orange\n\nRating 2800-3199 : red\n\nOther than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not.\n\nCurrently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i.\n\nFind the minimum and maximum possible numbers of different colors of the users.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ a_i ≤ 4800\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum possible number of different colors of the users, and the maximum possible number of different colors, with a space in between.\n\nSample Input 1\n\n4\n2100 2500 2700 2700\n\nSample Output 1\n\n2 2\n\nThe user with rating 2100 is \"yellow\", and the others are \"orange\". There are two different colors.\n\nSample Input 2\n\n5\n1100 1900 2800 3200 3200\n\nSample Output 2\n\n3 5\n\nThe user with rating 1100 is \"green\", the user with rating 1900 is blue and the user with rating 2800 is \"red\".\n\nIf the fourth user picks \"red\", and the fifth user picks \"blue\", there are three different colors. This is one possible scenario for the minimum number of colors.\n\nIf the fourth user picks \"purple\", and the fifth user picks \"black\", there are five different colors. This is one possible scenario for the maximum number of colors.\n\nSample Input 3\n\n20\n800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990\n\nSample Output 3\n\n1 1\n\nAll the users are \"green\", and thus there is one color.", "sample_input": "4\n2100 2500 2700 2700\n"}, "reference_outputs": ["2 2\n"], "source_document_id": "p03695", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn AtCoder, a person who has participated in a contest receives a color, which corresponds to the person's rating as follows:\n\nRating 1-399 : gray\n\nRating 400-799 : brown\n\nRating 800-1199 : green\n\nRating 1200-1599 : cyan\n\nRating 1600-1999 : blue\n\nRating 2000-2399 : yellow\n\nRating 2400-2799 : orange\n\nRating 2800-3199 : red\n\nOther than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not.\n\nCurrently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i.\n\nFind the minimum and maximum possible numbers of different colors of the users.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ a_i ≤ 4800\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum possible number of different colors of the users, and the maximum possible number of different colors, with a space in between.\n\nSample Input 1\n\n4\n2100 2500 2700 2700\n\nSample Output 1\n\n2 2\n\nThe user with rating 2100 is \"yellow\", and the others are \"orange\". There are two different colors.\n\nSample Input 2\n\n5\n1100 1900 2800 3200 3200\n\nSample Output 2\n\n3 5\n\nThe user with rating 1100 is \"green\", the user with rating 1900 is blue and the user with rating 2800 is \"red\".\n\nIf the fourth user picks \"red\", and the fifth user picks \"blue\", there are three different colors. This is one possible scenario for the minimum number of colors.\n\nIf the fourth user picks \"purple\", and the fifth user picks \"black\", there are five different colors. This is one possible scenario for the maximum number of colors.\n\nSample Input 3\n\n20\n800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990\n\nSample Output 3\n\n1 1\n\nAll the users are \"green\", and thus there is one color.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 568, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s727171135", "group_id": "codeNet:p03695", "input_text": "n = gets.to_i\na = gets.split.map{|m|m.to_i}\ntemp_color = [\"hai\",\"cha\",\"midori\",\"mizu\",\"ao\",\"ki\",\"daidai\",\"aka\"]\ncolor = Array.new\nextra_color = Array.new\na.each do |rate|\n if rate < 400\n color.push(\"hai\") if !(color.include?(\"hai\"))\n elsif rate < 800\n color.push(\"cha\") if !(color.include?(\"cha\")) \n elsif rate < 1200\n color.push(\"midori\") if !(color.include?(\"midori\")) \n elsif rate < 1600\n color.push(\"mizu\") if !(color.include?(\"mizu\")) \n elsif rate < 2000\n color.push(\"ao\") if !(color.include?(\"ao\")) \n elsif rate < 2400\n color.push(\"ki\") if !(color.include?(\"ki\")) \n elsif rate < 2800\n color.push(\"daidai\") if !(color.include?(\"daidai\"))\n elsif rate < 3200\n color.push(\"aka\") if !(color.include?(\"aka\")) \n else\n if color.length+extra_color.length != temp_color.length\n temp_color.each do |c|\n if !(extra_color.include?(c))\n extra_color.push(c)\n break\n end\n end\n end\n end \nend\ncolor.push(\"aka\") if color.length == 0\nprint color.length.to_s+\" \"+(color.length+extra_color.length).to_s+\"\\n\"", "language": "Ruby", "metadata": {"date": 1511759775, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s727171135.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s727171135", "user_id": "u273927571"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "n = gets.to_i\na = gets.split.map{|m|m.to_i}\ntemp_color = [\"hai\",\"cha\",\"midori\",\"mizu\",\"ao\",\"ki\",\"daidai\",\"aka\"]\ncolor = Array.new\nextra_color = Array.new\na.each do |rate|\n if rate < 400\n color.push(\"hai\") if !(color.include?(\"hai\"))\n elsif rate < 800\n color.push(\"cha\") if !(color.include?(\"cha\")) \n elsif rate < 1200\n color.push(\"midori\") if !(color.include?(\"midori\")) \n elsif rate < 1600\n color.push(\"mizu\") if !(color.include?(\"mizu\")) \n elsif rate < 2000\n color.push(\"ao\") if !(color.include?(\"ao\")) \n elsif rate < 2400\n color.push(\"ki\") if !(color.include?(\"ki\")) \n elsif rate < 2800\n color.push(\"daidai\") if !(color.include?(\"daidai\"))\n elsif rate < 3200\n color.push(\"aka\") if !(color.include?(\"aka\")) \n else\n if color.length+extra_color.length != temp_color.length\n temp_color.each do |c|\n if !(extra_color.include?(c))\n extra_color.push(c)\n break\n end\n end\n end\n end \nend\ncolor.push(\"aka\") if color.length == 0\nprint color.length.to_s+\" \"+(color.length+extra_color.length).to_s+\"\\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": 1219, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s871026595", "group_id": "codeNet:p03695", "input_text": "n = gets.to_i\nh = gets.split.map(&:to_i)\n\ncount = 0\n\nif h.any?{|x| 1<=x && x<=399}\n count += 1\nend\nif h.any?{|x| 400<=x && x<=799}\n count += 1\nend\nif h.any?{|x| 800<=x && x<=1199}\n count += 1\nend\nif h.any?{|x| 1200<=x && x<=1599}\n count += 1\nend\nif h.any?{|x| 1600<=x && x<=1999}\n count += 1\nend\nif h.any?{|x| 2000<=x && x<=2399}\n count += 1\nend\nif h.any?{|x| 2400<=x && x<=2799}\n count += 1\nend\nif h.any?{|x| 2800<=x && x<=3199}\n count += 1\nend\n\ncount_stop = h.count{|x| x>=3200}\n\nif n > 0\n min = 1\nend\n\nif count > 1\n min = count\nend\n\nmax = count + count_stop\n\nputs min.to_s + \" \" + max.to_s", "language": "Ruby", "metadata": {"date": 1497147082, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s871026595.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s871026595", "user_id": "u688750709"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "n = gets.to_i\nh = gets.split.map(&:to_i)\n\ncount = 0\n\nif h.any?{|x| 1<=x && x<=399}\n count += 1\nend\nif h.any?{|x| 400<=x && x<=799}\n count += 1\nend\nif h.any?{|x| 800<=x && x<=1199}\n count += 1\nend\nif h.any?{|x| 1200<=x && x<=1599}\n count += 1\nend\nif h.any?{|x| 1600<=x && x<=1999}\n count += 1\nend\nif h.any?{|x| 2000<=x && x<=2399}\n count += 1\nend\nif h.any?{|x| 2400<=x && x<=2799}\n count += 1\nend\nif h.any?{|x| 2800<=x && x<=3199}\n count += 1\nend\n\ncount_stop = h.count{|x| x>=3200}\n\nif n > 0\n min = 1\nend\n\nif count > 1\n min = count\nend\n\nmax = count + count_stop\n\nputs min.to_s + \" \" + max.to_s", "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": 602, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s470589277", "group_id": "codeNet:p03696", "input_text": "N = $stdin.gets.chomp.to_i\nS = $stdin.gets.chomp\n\ndef t(s)\n $stderr.puts s\n balance = 0\n cnt = 0\n s.split(\"\").each{ |a| \n case a\n when '('; balance += 1\n when ')'; \n balance -= 1\n end\n if balance < 0\n cnt += 1\n balance = 0\n end\n $stderr.puts \"#{a},#{balance},#{cnt}\"\n }\n cnt\nend\n\nopen = t(S)\nclose = t(S.reverse.tr(\"()\",\")(\"))\nputs \"#{'('*open}#{S}#{')'*close}\"\n", "language": "Ruby", "metadata": {"date": 1532843495, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03696.html", "problem_id": "p03696", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03696/input.txt", "sample_output_relpath": "derived/input_output/data/p03696/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03696/Ruby/s470589277.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s470589277", "user_id": "u670503797"}, "prompt_components": {"gold_output": "(())\n", "input_to_evaluate": "N = $stdin.gets.chomp.to_i\nS = $stdin.gets.chomp\n\ndef t(s)\n $stderr.puts s\n balance = 0\n cnt = 0\n s.split(\"\").each{ |a| \n case a\n when '('; balance += 1\n when ')'; \n balance -= 1\n end\n if balance < 0\n cnt += 1\n balance = 0\n end\n $stderr.puts \"#{a},#{balance},#{cnt}\"\n }\n cnt\nend\n\nopen = t(S)\nclose = t(S.reverse.tr(\"()\",\")(\"))\nputs \"#{'('*open}#{S}#{')'*close}\"\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of ( and ). Your task is to insert some number of ( and ) into S to obtain a correct bracket sequence.\n\nHere, a correct bracket sequence is defined as follows:\n\n() is a correct bracket sequence.\n\nIf X is a correct bracket sequence, the concatenation of (, X and ) in this order is also a correct bracket sequence.\n\nIf X and Y are correct bracket sequences, the concatenation of X and Y in this order is also a correct bracket sequence.\n\nEvery correct bracket sequence can be derived from the rules above.\n\nFind the shortest correct bracket sequence that can be obtained. If there is more than one such sequence, find the lexicographically smallest one.\n\nConstraints\n\nThe length of S is N.\n\n1 ≤ N ≤ 100\n\nS consists of ( and ).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the lexicographically smallest string among the shortest correct bracket sequences that can be obtained by inserting some number of ( and ) into S.\n\nSample Input 1\n\n3\n())\n\nSample Output 1\n\n(())\n\nSample Input 2\n\n6\n)))())\n\nSample Output 2\n\n(((()))())\n\nSample Input 3\n\n8\n))))((((\n\nSample Output 3\n\n(((())))(((())))", "sample_input": "3\n())\n"}, "reference_outputs": ["(())\n"], "source_document_id": "p03696", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of ( and ). Your task is to insert some number of ( and ) into S to obtain a correct bracket sequence.\n\nHere, a correct bracket sequence is defined as follows:\n\n() is a correct bracket sequence.\n\nIf X is a correct bracket sequence, the concatenation of (, X and ) in this order is also a correct bracket sequence.\n\nIf X and Y are correct bracket sequences, the concatenation of X and Y in this order is also a correct bracket sequence.\n\nEvery correct bracket sequence can be derived from the rules above.\n\nFind the shortest correct bracket sequence that can be obtained. If there is more than one such sequence, find the lexicographically smallest one.\n\nConstraints\n\nThe length of S is N.\n\n1 ≤ N ≤ 100\n\nS consists of ( and ).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the lexicographically smallest string among the shortest correct bracket sequences that can be obtained by inserting some number of ( and ) into S.\n\nSample Input 1\n\n3\n())\n\nSample Output 1\n\n(())\n\nSample Input 2\n\n6\n)))())\n\nSample Output 2\n\n(((()))())\n\nSample Input 3\n\n8\n))))((((\n\nSample Output 3\n\n(((())))(((())))", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 404, "cpu_time_ms": 8, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s340779345", "group_id": "codeNet:p03698", "input_text": "s=gets.chomp.split(\"\")\nu= s.uniq\nif s == u then\n\tputs \"yes\"\nelse\n\tputs \"no\"\nend", "language": "Ruby", "metadata": {"date": 1537169658, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03698.html", "problem_id": "p03698", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03698/input.txt", "sample_output_relpath": "derived/input_output/data/p03698/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03698/Ruby/s340779345.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s340779345", "user_id": "u802942094"}, "prompt_components": {"gold_output": "yes\n", "input_to_evaluate": "s=gets.chomp.split(\"\")\nu= s.uniq\nif s == u then\n\tputs \"yes\"\nelse\n\tputs \"no\"\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.\n\nConstraints\n\n2 ≤ |S| ≤ 26, where |S| denotes the length of S.\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf all the characters in S are different, print yes (case-sensitive); otherwise, print no.\n\nSample Input 1\n\nuncopyrightable\n\nSample Output 1\n\nyes\n\nSample Input 2\n\ndifferent\n\nSample Output 2\n\nno\n\nSample Input 3\n\nno\n\nSample Output 3\n\nyes", "sample_input": "uncopyrightable\n"}, "reference_outputs": ["yes\n"], "source_document_id": "p03698", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.\n\nConstraints\n\n2 ≤ |S| ≤ 26, where |S| denotes the length of S.\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf all the characters in S are different, print yes (case-sensitive); otherwise, print no.\n\nSample Input 1\n\nuncopyrightable\n\nSample Output 1\n\nyes\n\nSample Input 2\n\ndifferent\n\nSample Output 2\n\nno\n\nSample Input 3\n\nno\n\nSample Output 3\n\nyes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 79, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s671963277", "group_id": "codeNet:p03698", "input_text": "s = gets.chomp\nputs s.size == s.split(\"\").uniq.size ? \"yes\" : \"no\"", "language": "Ruby", "metadata": {"date": 1509269306, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03698.html", "problem_id": "p03698", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03698/input.txt", "sample_output_relpath": "derived/input_output/data/p03698/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03698/Ruby/s671963277.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s671963277", "user_id": "u693378622"}, "prompt_components": {"gold_output": "yes\n", "input_to_evaluate": "s = gets.chomp\nputs s.size == s.split(\"\").uniq.size ? \"yes\" : \"no\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.\n\nConstraints\n\n2 ≤ |S| ≤ 26, where |S| denotes the length of S.\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf all the characters in S are different, print yes (case-sensitive); otherwise, print no.\n\nSample Input 1\n\nuncopyrightable\n\nSample Output 1\n\nyes\n\nSample Input 2\n\ndifferent\n\nSample Output 2\n\nno\n\nSample Input 3\n\nno\n\nSample Output 3\n\nyes", "sample_input": "uncopyrightable\n"}, "reference_outputs": ["yes\n"], "source_document_id": "p03698", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.\n\nConstraints\n\n2 ≤ |S| ≤ 26, where |S| denotes the length of S.\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf all the characters in S are different, print yes (case-sensitive); otherwise, print no.\n\nSample Input 1\n\nuncopyrightable\n\nSample Output 1\n\nyes\n\nSample Input 2\n\ndifferent\n\nSample Output 2\n\nno\n\nSample Input 3\n\nno\n\nSample Output 3\n\nyes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 66, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s436359018", "group_id": "codeNet:p03699", "input_text": "N=gets.strip.to_i\ns = readlines.map {|x| x.strip.to_i }.sort\n\nsum = s.reduce(:+)\n\nif sum%10!=0\n p sum\n exit\nend\n\nwithout_10_times_s = s.reject {|x| x%10==0 }\nsmallest_no_10_times = without_10_times_s.first\n\nif smallest_no_10_times.nil?\n p 0\n exit\nend\n\nresult = sum - smallest_no_10_times\np result\n", "language": "Ruby", "metadata": {"date": 1561942564, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03699.html", "problem_id": "p03699", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03699/input.txt", "sample_output_relpath": "derived/input_output/data/p03699/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03699/Ruby/s436359018.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s436359018", "user_id": "u021358975"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "N=gets.strip.to_i\ns = readlines.map {|x| x.strip.to_i }.sort\n\nsum = s.reduce(:+)\n\nif sum%10!=0\n p sum\n exit\nend\n\nwithout_10_times_s = s.reject {|x| x%10==0 }\nsmallest_no_10_times = without_10_times_s.first\n\nif smallest_no_10_times.nil?\n p 0\n exit\nend\n\nresult = sum - smallest_no_10_times\np result\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either \"correct\" or \"incorrect\", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.\n\nHowever, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 100\n\n1 ≤ s_i ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the maximum value that can be displayed as your grade.\n\nSample Input 1\n\n3\n5\n10\n15\n\nSample Output 1\n\n25\n\nYour grade will be 25 if the 10-point and 15-point questions are answered correctly and the 5-point question is not, and this grade will be displayed correctly. Your grade will become 30 if the 5-point question is also answered correctly, but this grade will be incorrectly displayed as 0.\n\nSample Input 2\n\n3\n10\n10\n15\n\nSample Output 2\n\n35\n\nYour grade will be 35 if all the questions are answered correctly, and this grade will be displayed correctly.\n\nSample Input 3\n\n3\n10\n20\n30\n\nSample Output 3\n\n0\n\nRegardless of whether each question is answered correctly or not, your grade will be a multiple of 10 and displayed as 0.", "sample_input": "3\n5\n10\n15\n"}, "reference_outputs": ["25\n"], "source_document_id": "p03699", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either \"correct\" or \"incorrect\", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.\n\nHowever, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 100\n\n1 ≤ s_i ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the maximum value that can be displayed as your grade.\n\nSample Input 1\n\n3\n5\n10\n15\n\nSample Output 1\n\n25\n\nYour grade will be 25 if the 10-point and 15-point questions are answered correctly and the 5-point question is not, and this grade will be displayed correctly. Your grade will become 30 if the 5-point question is also answered correctly, but this grade will be incorrectly displayed as 0.\n\nSample Input 2\n\n3\n10\n10\n15\n\nSample Output 2\n\n35\n\nYour grade will be 35 if all the questions are answered correctly, and this grade will be displayed correctly.\n\nSample Input 3\n\n3\n10\n20\n30\n\nSample Output 3\n\n0\n\nRegardless of whether each question is answered correctly or not, your grade will be a multiple of 10 and displayed as 0.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 301, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s526578714", "group_id": "codeNet:p03699", "input_text": "n = gets.to_i\nas = []\nmin = Float::INFINITY\nn.times do\n a = gets.to_i\n if a % 10 != 0\n min = [min, a].min\n end\n as << a\nend\nsum = as.reduce(0){|a,e|a+=e}\n\nif sum % 10 == 0 && min != Float::INFINITY\n puts sum - min\nelsif sum % 10 == 0\n puts 0\nelse\n puts sum\nend", "language": "Ruby", "metadata": {"date": 1551041051, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03699.html", "problem_id": "p03699", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03699/input.txt", "sample_output_relpath": "derived/input_output/data/p03699/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03699/Ruby/s526578714.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s526578714", "user_id": "u298628832"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "n = gets.to_i\nas = []\nmin = Float::INFINITY\nn.times do\n a = gets.to_i\n if a % 10 != 0\n min = [min, a].min\n end\n as << a\nend\nsum = as.reduce(0){|a,e|a+=e}\n\nif sum % 10 == 0 && min != Float::INFINITY\n puts sum - min\nelsif sum % 10 == 0\n puts 0\nelse\n puts sum\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either \"correct\" or \"incorrect\", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.\n\nHowever, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 100\n\n1 ≤ s_i ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the maximum value that can be displayed as your grade.\n\nSample Input 1\n\n3\n5\n10\n15\n\nSample Output 1\n\n25\n\nYour grade will be 25 if the 10-point and 15-point questions are answered correctly and the 5-point question is not, and this grade will be displayed correctly. Your grade will become 30 if the 5-point question is also answered correctly, but this grade will be incorrectly displayed as 0.\n\nSample Input 2\n\n3\n10\n10\n15\n\nSample Output 2\n\n35\n\nYour grade will be 35 if all the questions are answered correctly, and this grade will be displayed correctly.\n\nSample Input 3\n\n3\n10\n20\n30\n\nSample Output 3\n\n0\n\nRegardless of whether each question is answered correctly or not, your grade will be a multiple of 10 and displayed as 0.", "sample_input": "3\n5\n10\n15\n"}, "reference_outputs": ["25\n"], "source_document_id": "p03699", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either \"correct\" or \"incorrect\", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.\n\nHowever, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 100\n\n1 ≤ s_i ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\n\nOutput\n\nPrint the maximum value that can be displayed as your grade.\n\nSample Input 1\n\n3\n5\n10\n15\n\nSample Output 1\n\n25\n\nYour grade will be 25 if the 10-point and 15-point questions are answered correctly and the 5-point question is not, and this grade will be displayed correctly. Your grade will become 30 if the 5-point question is also answered correctly, but this grade will be incorrectly displayed as 0.\n\nSample Input 2\n\n3\n10\n10\n15\n\nSample Output 2\n\n35\n\nYour grade will be 35 if all the questions are answered correctly, and this grade will be displayed correctly.\n\nSample Input 3\n\n3\n10\n20\n30\n\nSample Output 3\n\n0\n\nRegardless of whether each question is answered correctly or not, your grade will be a multiple of 10 and displayed as 0.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s056523171", "group_id": "codeNet:p03699", "input_text": "N = gets.to_i\ns = N.times.map{ gets.to_i }\na = []\n[3,N].min.times{|i| s.combination(N-i).map{|t| a< 1\n#p [ok,ng]\n mid = (ok+ng)/2\n remains = h.map {|e| e-b*mid }.select {|e| e>0 }\n if remains.length.zero?\n ok=mid\n next\n end\n if mid >= remains.map {|e| (e/c.to_f).ceil }.inject(:+)\n ok=mid\n else\n ng=mid\n end\nend\n\np ok\n", "language": "Ruby", "metadata": {"date": 1566874749, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03700.html", "problem_id": "p03700", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03700/input.txt", "sample_output_relpath": "derived/input_output/data/p03700/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03700/Ruby/s005241151.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s005241151", "user_id": "u021358975"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n, a, b=gets.strip.split.map(&:to_i)\nh = readlines.map {|line| line.strip.to_i }\nc=a-b\n\nok=(h.max/b.to_f).ceil\nng=1\nwhile ok-ng > 1\n#p [ok,ng]\n mid = (ok+ng)/2\n remains = h.map {|e| e-b*mid }.select {|e| e>0 }\n if remains.length.zero?\n ok=mid\n next\n end\n if mid >= remains.map {|e| (e/c.to_f).ceil }.inject(:+)\n ok=mid\n else\n ng=mid\n end\nend\n\np ok\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called health, and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.\n\nFortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows:\n\nSelect an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds.\n\nAt least how many explosions do you need to cause in order to vanish all the monsters?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 10^5\n\n1 ≤ B < A ≤ 10^9\n\n1 ≤ h_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum number of explosions that needs to be caused in order to vanish all the monsters.\n\nSample Input 1\n\n4 5 3\n8\n7\n4\n2\n\nSample Output 1\n\n2\n\nYou can vanish all the monsters in two explosion, as follows:\n\nFirst, cause an explosion centered at the monster with 8 health. The healths of the four monsters become 3, 4, 1 and -1, respectively, and the last monster vanishes.\n\nSecond, cause an explosion centered at the monster with 4 health remaining. The healths of the three remaining monsters become 0, -1 and -2, respectively, and all the monsters are now vanished.\n\nSample Input 2\n\n2 10 4\n20\n20\n\nSample Output 2\n\n4\n\nYou need to cause two explosions centered at each monster, for a total of four.\n\nSample Input 3\n\n5 2 1\n900000000\n900000000\n1000000000\n1000000000\n1000000000\n\nSample Output 3\n\n800000000", "sample_input": "4 5 3\n8\n7\n4\n2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03700", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called health, and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.\n\nFortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows:\n\nSelect an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds.\n\nAt least how many explosions do you need to cause in order to vanish all the monsters?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 10^5\n\n1 ≤ B < A ≤ 10^9\n\n1 ≤ h_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum number of explosions that needs to be caused in order to vanish all the monsters.\n\nSample Input 1\n\n4 5 3\n8\n7\n4\n2\n\nSample Output 1\n\n2\n\nYou can vanish all the monsters in two explosion, as follows:\n\nFirst, cause an explosion centered at the monster with 8 health. The healths of the four monsters become 3, 4, 1 and -1, respectively, and the last monster vanishes.\n\nSecond, cause an explosion centered at the monster with 4 health remaining. The healths of the three remaining monsters become 0, -1 and -2, respectively, and all the monsters are now vanished.\n\nSample Input 2\n\n2 10 4\n20\n20\n\nSample Output 2\n\n4\n\nYou need to cause two explosions centered at each monster, for a total of four.\n\nSample Input 3\n\n5 2 1\n900000000\n900000000\n1000000000\n1000000000\n1000000000\n\nSample Output 3\n\n800000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 367, "cpu_time_ms": 1024, "memory_kb": 67164}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s017606462", "group_id": "codeNet:p03703", "input_text": "class BIT\n attr_reader :bit\n def initialize(n)\n @n = n\n @bit = Array.new(@n + 1, 0)\n end\n def sum(i)\n s = 0\n while i > 0\n s += @bit[i]\n i -= i & -i\n end\n return s\n end\n def add(i, x)\n i += 1\n while i <= @n\n @bit[i] += x\n i += i & -i\n end\n end\nend\n\nn, k = gets.chomp.split(\" \").map(&:to_i)\na = [0]\na += readlines.map{|x| x.chomp.to_i - k}\n\nb = [0]\nn.times do |i|\n b << b[i] + a[i+1]\nend\n\nb_s = b.sort\nc = b.map{|e| b_s.bsearch_index{|x| x >= e}}\n\nbit = BIT.new(n+1)\n\nans = 0\nc.each do |i|\n ans += bit.sum(i+1)\n bit.add(i, 1)\nend\nputs ans", "language": "Ruby", "metadata": {"date": 1496609120, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s017606462.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s017606462", "user_id": "u910756197"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "class BIT\n attr_reader :bit\n def initialize(n)\n @n = n\n @bit = Array.new(@n + 1, 0)\n end\n def sum(i)\n s = 0\n while i > 0\n s += @bit[i]\n i -= i & -i\n end\n return s\n end\n def add(i, x)\n i += 1\n while i <= @n\n @bit[i] += x\n i += i & -i\n end\n end\nend\n\nn, k = gets.chomp.split(\" \").map(&:to_i)\na = [0]\na += readlines.map{|x| x.chomp.to_i - k}\n\nb = [0]\nn.times do |i|\n b << b[i] + a[i+1]\nend\n\nb_s = b.sort\nc = b.map{|e| b_s.bsearch_index{|x| x >= e}}\n\nbit = BIT.new(n+1)\n\nans = 0\nc.each do |i|\n ans += bit.sum(i+1)\n bit.add(i, 1)\nend\nputs ans", "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": 594, "cpu_time_ms": 774, "memory_kb": 29416}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s859159262", "group_id": "codeNet:p03711", "input_text": "x, y = gets.split.map(&:to_i)\nary = [4, 6, 9, 11]\nary2 = [1, 3, 5, 7, 8, 10, 12]\n\nif ary.include?(x) && ary.include?(y)\n puts \"Yes\"\nelsif ary2.include?(x) && ary2.include?(y)\n puts \"Yes\"\nelse\n puts \"No\"\nend", "language": "Ruby", "metadata": {"date": 1593205360, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p03711.html", "problem_id": "p03711", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03711/input.txt", "sample_output_relpath": "derived/input_output/data/p03711/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03711/Ruby/s859159262.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s859159262", "user_id": "u462163804"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "x, y = gets.split.map(&:to_i)\nary = [4, 6, 9, 11]\nary2 = [1, 3, 5, 7, 8, 10, 12]\n\nif ary.include?(x) && ary.include?(y)\n puts \"Yes\"\nelsif ary2.include?(x) && ary2.include?(y)\n puts \"Yes\"\nelse\n puts \"No\"\nend", "problem_context": "Score : 100 points\n\nProblem Statement\n\nBased on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below.\nGiven two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.\n\nConstraints\n\nx and y are integers.\n\n1 ≤ x < y ≤ 12\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx y\n\nOutput\n\nIf x and y belong to the same group, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n2 4\n\nSample Output 2\n\nNo", "sample_input": "1 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03711", "source_text": "Score : 100 points\n\nProblem Statement\n\nBased on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below.\nGiven two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.\n\nConstraints\n\nx and y are integers.\n\n1 ≤ x < y ≤ 12\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx y\n\nOutput\n\nIf x and y belong to the same group, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n2 4\n\nSample Output 2\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 209, "cpu_time_ms": 65, "memory_kb": 14244}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s570005483", "group_id": "codeNet:p03711", "input_text": "require 'date'\ndef f(a)\n a += 1\n a = 1 if a > 12\n (Date.new(0, a, 1)-1).day\nend\na, b = gets.split.map &:to_i\nputs (f(a)==f(b) ? \"Yes\" : \"No\")", "language": "Ruby", "metadata": {"date": 1554793025, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03711.html", "problem_id": "p03711", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03711/input.txt", "sample_output_relpath": "derived/input_output/data/p03711/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03711/Ruby/s570005483.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s570005483", "user_id": "u976045235"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "require 'date'\ndef f(a)\n a += 1\n a = 1 if a > 12\n (Date.new(0, a, 1)-1).day\nend\na, b = gets.split.map &:to_i\nputs (f(a)==f(b) ? \"Yes\" : \"No\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nBased on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below.\nGiven two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.\n\nConstraints\n\nx and y are integers.\n\n1 ≤ x < y ≤ 12\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx y\n\nOutput\n\nIf x and y belong to the same group, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n2 4\n\nSample Output 2\n\nNo", "sample_input": "1 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03711", "source_text": "Score : 100 points\n\nProblem Statement\n\nBased on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below.\nGiven two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.\n\nConstraints\n\nx and y are integers.\n\n1 ≤ x < y ≤ 12\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx y\n\nOutput\n\nIf x and y belong to the same group, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n2 4\n\nSample Output 2\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 144, "cpu_time_ms": 12, "memory_kb": 2040}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s415686206", "group_id": "codeNet:p03711", "input_text": "x, y = gets.split.map(&:to_i)\n\nif [1, 3, 5, 7, 8, 10, 12].find {|n| n == x} != nil\n if [1, 3, 5, 7, 8, 10, 12].find {|n| n == y} != nil\n puts 'Yes'\n else\n puts 'No'\n end\nelsif [4, 6, 9, 11].find {|n| n == x} != nil\n if [4, 6, 9, 11].find {|n| n == y} != nil\n puts 'Yes'\n elsif\n puts 'No'\n end\nelse\n puts 'No'\nend\n", "language": "Ruby", "metadata": {"date": 1543074813, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03711.html", "problem_id": "p03711", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03711/input.txt", "sample_output_relpath": "derived/input_output/data/p03711/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03711/Ruby/s415686206.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s415686206", "user_id": "u163340796"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "x, y = gets.split.map(&:to_i)\n\nif [1, 3, 5, 7, 8, 10, 12].find {|n| n == x} != nil\n if [1, 3, 5, 7, 8, 10, 12].find {|n| n == y} != nil\n puts 'Yes'\n else\n puts 'No'\n end\nelsif [4, 6, 9, 11].find {|n| n == x} != nil\n if [4, 6, 9, 11].find {|n| n == y} != nil\n puts 'Yes'\n elsif\n puts 'No'\n end\nelse\n puts 'No'\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nBased on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below.\nGiven two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.\n\nConstraints\n\nx and y are integers.\n\n1 ≤ x < y ≤ 12\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx y\n\nOutput\n\nIf x and y belong to the same group, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n2 4\n\nSample Output 2\n\nNo", "sample_input": "1 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03711", "source_text": "Score : 100 points\n\nProblem Statement\n\nBased on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below.\nGiven two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.\n\nConstraints\n\nx and y are integers.\n\n1 ≤ x < y ≤ 12\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx y\n\nOutput\n\nIf x and y belong to the same group, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n2 4\n\nSample Output 2\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 332, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s079372271", "group_id": "codeNet:p03712", "input_text": "h, w = gets.split.map(&:to_i)\na = h.times.map { gets.chomp }\nputs \"#\" * (w + 2)\na.each { |s| puts \"#\" + s + \"#\" }\nputs \"#\" * (w + 2)\n", "language": "Ruby", "metadata": {"date": 1572155737, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03712.html", "problem_id": "p03712", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03712/input.txt", "sample_output_relpath": "derived/input_output/data/p03712/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03712/Ruby/s079372271.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s079372271", "user_id": "u726523100"}, "prompt_components": {"gold_output": "#####\n#abc#\n#arc#\n#####\n", "input_to_evaluate": "h, w = gets.split.map(&:to_i)\na = h.times.map { gets.chomp }\nputs \"#\" * (w + 2)\na.each { |s| puts \"#\" + s + \"#\" }\nputs \"#\" * (w + 2)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a image with a height of H pixels and a width of W pixels.\nEach pixel is represented by a lowercase English letter.\nThe pixel at the i-th row from the top and j-th column from the left is a_{ij}.\n\nPut a box around this image and output the result. The box should consist of # and have a thickness of 1.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\na_{ij} is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{11} ... a_{1W}\n:\na_{H1} ... a_{HW}\n\nOutput\n\nPrint the image surrounded by a box that consists of # and has a thickness of 1.\n\nSample Input 1\n\n2 3\nabc\narc\n\nSample Output 1\n\n#####\n#abc#\n#arc#\n#####\n\nSample Input 2\n\n1 1\nz\n\nSample Output 2\n\n###\n#z#\n###", "sample_input": "2 3\nabc\narc\n"}, "reference_outputs": ["#####\n#abc#\n#arc#\n#####\n"], "source_document_id": "p03712", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a image with a height of H pixels and a width of W pixels.\nEach pixel is represented by a lowercase English letter.\nThe pixel at the i-th row from the top and j-th column from the left is a_{ij}.\n\nPut a box around this image and output the result. The box should consist of # and have a thickness of 1.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\na_{ij} is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{11} ... a_{1W}\n:\na_{H1} ... a_{HW}\n\nOutput\n\nPrint the image surrounded by a box that consists of # and has a thickness of 1.\n\nSample Input 1\n\n2 3\nabc\narc\n\nSample Output 1\n\n#####\n#abc#\n#arc#\n#####\n\nSample Input 2\n\n1 1\nz\n\nSample Output 2\n\n###\n#z#\n###", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 133, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s226479880", "group_id": "codeNet:p03715", "input_text": "h,w=gets.split.map(&:to_i)\nans=Array.new(6)\nif h%3==0 || w%3==0\n\tanswer=0\nelse\n\tk=h#とする\n\tmul=h*w\n\ttrip=mul/3 #6\n\tfor i in 0..2\n\t\tgreen=(trip/h+i)*h\n\t\t\n\t\tblue=(w-(trip/h+i))*(h/2) \n\t\t\n\t\tred=mul-green-blue\n\t\tif green==0 || blue==0 || red==0\n\t\t\tnext\n\t\tend\n\t\tnum= (green-blue).abs > (green-red).abs ? blue : red\n\t\t\n\t\tans[i]=(green-num).abs\n\tend\n\tfor i in 0..2\n\t\tgreen=(trip/w+i)*w\n\t\t\n\t\tblue=(h-(trip/w+i))*(w/2)\n\t\t\n\t\tred=mul-green-blue\n\t\tif green==0 || blue==0 || red==0\n\t\t\tnext\n\t\tend\n\t\tnum= (green-blue).abs > (green-red).abs ? blue : red\n\t\tans[3+i]=(green-num).abs\n\tend\n\tans.compact!\n\tanswer=ans.min\nend\n\nputs answer\n\n\n", "language": "Ruby", "metadata": {"date": 1496457453, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03715.html", "problem_id": "p03715", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03715/input.txt", "sample_output_relpath": "derived/input_output/data/p03715/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03715/Ruby/s226479880.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s226479880", "user_id": "u922018373"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "h,w=gets.split.map(&:to_i)\nans=Array.new(6)\nif h%3==0 || w%3==0\n\tanswer=0\nelse\n\tk=h#とする\n\tmul=h*w\n\ttrip=mul/3 #6\n\tfor i in 0..2\n\t\tgreen=(trip/h+i)*h\n\t\t\n\t\tblue=(w-(trip/h+i))*(h/2) \n\t\t\n\t\tred=mul-green-blue\n\t\tif green==0 || blue==0 || red==0\n\t\t\tnext\n\t\tend\n\t\tnum= (green-blue).abs > (green-red).abs ? blue : red\n\t\t\n\t\tans[i]=(green-num).abs\n\tend\n\tfor i in 0..2\n\t\tgreen=(trip/w+i)*w\n\t\t\n\t\tblue=(h-(trip/w+i))*(w/2)\n\t\t\n\t\tred=mul-green-blue\n\t\tif green==0 || blue==0 || red==0\n\t\t\tnext\n\t\tend\n\t\tnum= (green-blue).abs > (green-red).abs ? blue : red\n\t\tans[3+i]=(green-num).abs\n\tend\n\tans.compact!\n\tanswer=ans.min\nend\n\nputs answer\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": "p03715", "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": 623, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s083522892", "group_id": "codeNet:p03719", "input_text": "io = STDIN\na,b,c=io.gets.chomp.split.map(&:to_i)\nputs (c>=a)&&(c<=b) ? 'Yes' : 'No'", "language": "Ruby", "metadata": {"date": 1494724199, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s083522892.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s083522892", "user_id": "u132360211"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "io = STDIN\na,b,c=io.gets.chomp.split.map(&:to_i)\nputs (c>=a)&&(c<=b) ? 'Yes' : 'No'", "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": 83, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s859087641", "group_id": "codeNet:p03721", "input_text": "inf = 99\n\nn,k = gets.to_s.split.map{|t|t.to_i}\n\nary = []\nn.times do\n \n a, b = gets.to_s.split\n a, b = a.to_i, b.to_i\n \n ary.concat([a]*b)\n \nend\n\nputs ary[k-1]", "language": "Ruby", "metadata": {"date": 1588714504, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s859087641.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s859087641", "user_id": "u693378622"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "inf = 99\n\nn,k = gets.to_s.split.map{|t|t.to_i}\n\nary = []\nn.times do\n \n a, b = gets.to_s.split\n a, b = a.to_i, b.to_i\n \n ary.concat([a]*b)\n \nend\n\nputs ary[k-1]", "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": 164, "cpu_time_ms": 2147, "memory_kb": 700656}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s917102558", "group_id": "codeNet:p03721", "input_text": "n,k=gets.split.map &:to_i\nar=(1..n).map{gets.split.map &:to_i}\np ar.sort.find{|a,b|k-=b;k<=0}[0]\n", "language": "Ruby", "metadata": {"date": 1494776084, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "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/Ruby/s917102558.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s917102558", "user_id": "u353917577"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "n,k=gets.split.map &:to_i\nar=(1..n).map{gets.split.map &:to_i}\np ar.sort.find{|a,b|k-=b;k<=0}[0]\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is an empty array.\nThe following N operations will be performed to insert integers into the array.\nIn the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.\nFind the K-th smallest integer in the array after the N operations.\nFor example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.\n\nConstraints\n\n1≤N≤10^5\n\n1≤a_i,b_i≤10^5\n\n1≤K≤b_1…+…b_n\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint the K-th smallest integer in the array after the N operations.\n\nSample Input 1\n\n3 4\n1 1\n2 2\n3 3\n\nSample Output 1\n\n3\n\nThe resulting array is the same as the one in the problem statement.\n\nSample Input 2\n\n10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n\nSample Output 2\n\n1", "sample_input": "3 4\n1 1\n2 2\n3 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03721", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is an empty array.\nThe following N operations will be performed to insert integers into the array.\nIn the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.\nFind the K-th smallest integer in the array after the N operations.\nFor example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.\n\nConstraints\n\n1≤N≤10^5\n\n1≤a_i,b_i≤10^5\n\n1≤K≤b_1…+…b_n\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint the K-th smallest integer in the array after the N operations.\n\nSample Input 1\n\n3 4\n1 1\n2 2\n3 3\n\nSample Output 1\n\n3\n\nThe resulting array is the same as the one in the problem statement.\n\nSample Input 2\n\n10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n\nSample Output 2\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 97, "cpu_time_ms": 598, "memory_kb": 11152}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s240070407", "group_id": "codeNet:p03722", "input_text": "n, m = gets.strip.split.map(&:to_i)\nabc = readlines.map {|line| line.strip.split.map(&:to_i) }\n\ngraph = Array.new(n+1){ [] }\nr_graph = Array.new(n+1){ [] }\nedges = []\nabc.each do |a, b, c|\n edges << [a,b,-c]\n graph[a] << [b, -c]\n r_graph[b] << [a, -c]\nend\n\ndef reachable(s, g, graph)\n result = []\n q = [s]\n result = [s]\n until q.empty?\n c=q.shift\n graph[c].each do |nex, _|\n next if result.include?(nex)\n q << nex\n result << nex\n end\n end\n result\nend\n\nfrom_1 = reachable(1, n, graph)\nfrom_n = reachable(n, 1, r_graph)\navailable = from_1 & from_n\n\nINF=10**14\ndist = [INF]*(n+1)\ndist[1]=0\nupdated=false\n(n).times do\n updated=false\n\n edges.each do |from, to, cost|\n next if !available.include?(from) || !available.include?(to)\n if dist[from] != INF && dist[to] > dist[from] + cost\n dist[to] = dist[from] + cost\n updated = true\n end\n end\nend\n\nif updated\n puts 'inf'\n exit\nend\n\n#p [from_1, from_n, available]\np dist[n]*-1\n", "language": "Ruby", "metadata": {"date": 1567659637, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03722.html", "problem_id": "p03722", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03722/input.txt", "sample_output_relpath": "derived/input_output/data/p03722/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03722/Ruby/s240070407.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s240070407", "user_id": "u021358975"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "n, m = gets.strip.split.map(&:to_i)\nabc = readlines.map {|line| line.strip.split.map(&:to_i) }\n\ngraph = Array.new(n+1){ [] }\nr_graph = Array.new(n+1){ [] }\nedges = []\nabc.each do |a, b, c|\n edges << [a,b,-c]\n graph[a] << [b, -c]\n r_graph[b] << [a, -c]\nend\n\ndef reachable(s, g, graph)\n result = []\n q = [s]\n result = [s]\n until q.empty?\n c=q.shift\n graph[c].each do |nex, _|\n next if result.include?(nex)\n q << nex\n result << nex\n end\n end\n result\nend\n\nfrom_1 = reachable(1, n, graph)\nfrom_n = reachable(n, 1, r_graph)\navailable = from_1 & from_n\n\nINF=10**14\ndist = [INF]*(n+1)\ndist[1]=0\nupdated=false\n(n).times do\n updated=false\n\n edges.each do |from, to, cost|\n next if !available.include?(from) || !available.include?(to)\n if dist[from] != INF && dist[to] > dist[from] + cost\n dist[to] = dist[from] + cost\n updated = true\n end\n end\nend\n\nif updated\n puts 'inf'\n exit\nend\n\n#p [from_1, from_n, available]\np dist[n]*-1\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a directed graph with N vertices and M edges.\nThe i-th edge (1≤i≤M) points from vertex a_i to vertex b_i, and has a weight c_i.\nWe will play the following single-player game using this graph and a piece.\n\nInitially, the piece is placed at vertex 1, and the score of the player is set to 0.\nThe player can move the piece as follows:\n\nWhen the piece is placed at vertex a_i, move the piece along the i-th edge to vertex b_i. After this move, the score of the player is increased by c_i.\n\nThe player can end the game only when the piece is placed at vertex N.\nThe given graph guarantees that it is possible to traverse from vertex 1 to vertex N.\n\nWhen the player acts optimally to maximize the score at the end of the game, what will the score be?\nIf it is possible to increase the score indefinitely, print inf.\n\nConstraints\n\n2≤N≤1000\n\n1≤M≤min(N(N-1),2000)\n\n1≤a_i,b_i≤N (1≤i≤M)\n\na_i≠b_i (1≤i≤M)\n\na_i≠a_j or b_i≠b_j (1≤ib)then\n puts(\"GREATER\")\nelsif ab)then\n puts(\"GREATER\")\nelsif aB, LESS if A24, print GREATER.\n\nSample Input 2\n\n850\n3777\n\nSample Output 2\n\nLESS\n\nSample Input 3\n\n9720246\n22516266\n\nSample Output 3\n\nLESS\n\nSample Input 4\n\n123456789012345678901234567890\n234567890123456789012345678901\n\nSample Output 4\n\nLESS", "sample_input": "36\n24\n"}, "reference_outputs": ["GREATER\n"], "source_document_id": "p03738", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given two positive integers A and B. Compare the magnitudes of these numbers.\n\nConstraints\n\n1 ≤ A, B ≤ 10^{100}\n\nNeither A nor B begins with a 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\n\nOutput\n\nPrint GREATER if A>B, LESS if A24, print GREATER.\n\nSample Input 2\n\n850\n3777\n\nSample Output 2\n\nLESS\n\nSample Input 3\n\n9720246\n22516266\n\nSample Output 3\n\nLESS\n\nSample Input 4\n\n123456789012345678901234567890\n234567890123456789012345678901\n\nSample Output 4\n\nLESS", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 109, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s757947985", "group_id": "codeNet:p03738", "input_text": "a, b = gets.chomp.split(' ').map(&:to_i)\nif a > b\n puts 'GREATER'\nelsif a < b\n puts 'LESS'\nelse\n puts 'EQUAL'\nend\n", "language": "Ruby", "metadata": {"date": 1502054912, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03738.html", "problem_id": "p03738", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03738/input.txt", "sample_output_relpath": "derived/input_output/data/p03738/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03738/Ruby/s757947985.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s757947985", "user_id": "u253759478"}, "prompt_components": {"gold_output": "GREATER\n", "input_to_evaluate": "a, b = gets.chomp.split(' ').map(&:to_i)\nif a > b\n puts 'GREATER'\nelsif a < b\n puts 'LESS'\nelse\n puts 'EQUAL'\nend\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given two positive integers A and B. Compare the magnitudes of these numbers.\n\nConstraints\n\n1 ≤ A, B ≤ 10^{100}\n\nNeither A nor B begins with a 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\n\nOutput\n\nPrint GREATER if A>B, LESS if A24, print GREATER.\n\nSample Input 2\n\n850\n3777\n\nSample Output 2\n\nLESS\n\nSample Input 3\n\n9720246\n22516266\n\nSample Output 3\n\nLESS\n\nSample Input 4\n\n123456789012345678901234567890\n234567890123456789012345678901\n\nSample Output 4\n\nLESS", "sample_input": "36\n24\n"}, "reference_outputs": ["GREATER\n"], "source_document_id": "p03738", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given two positive integers A and B. Compare the magnitudes of these numbers.\n\nConstraints\n\n1 ≤ A, B ≤ 10^{100}\n\nNeither A nor B begins with a 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\n\nOutput\n\nPrint GREATER if A>B, LESS if A24, print GREATER.\n\nSample Input 2\n\n850\n3777\n\nSample Output 2\n\nLESS\n\nSample Input 3\n\n9720246\n22516266\n\nSample Output 3\n\nLESS\n\nSample Input 4\n\n123456789012345678901234567890\n234567890123456789012345678901\n\nSample Output 4\n\nLESS", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 117, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s420165810", "group_id": "codeNet:p03739", "input_text": "n = gets.to_i\nary = gets.split.map(&:to_i)\n#even > 0\nsumE = ary[0]\nsumO = ary[0] > 0 ? -1 : 1\nansE = 0\nansO = ary[0].abs + 1\n\nfor i in 1 .. n - 1\n if sumE * (sumE + ary[i]) >= 0\n if sumE > 0\n ansE += (- sumE - 1 - ary[i]).abs\n sumE = -1\n else\n ansE += (- sumE + 1 - ary[i]).abs\n sumE = 1\n end\n else\n sumE += ary[i]\n end\n if sumO * (sumO + ary[i]) >= 0\n if sumO > 0\n ansO += (- sumO - 1 - ary[i]).abs\n sumO = -1\n else\n ansO += (- sumO + 1 - ary[i]).abs\n sumO = 1\n end\n else\n sumO += ary[i]\n end\nend\n\nputs [ansE, ansO].min\n", "language": "Ruby", "metadata": {"date": 1554660417, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03739.html", "problem_id": "p03739", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03739/input.txt", "sample_output_relpath": "derived/input_output/data/p03739/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03739/Ruby/s420165810.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s420165810", "user_id": "u785521224"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "n = gets.to_i\nary = gets.split.map(&:to_i)\n#even > 0\nsumE = ary[0]\nsumO = ary[0] > 0 ? -1 : 1\nansE = 0\nansO = ary[0].abs + 1\n\nfor i in 1 .. n - 1\n if sumE * (sumE + ary[i]) >= 0\n if sumE > 0\n ansE += (- sumE - 1 - ary[i]).abs\n sumE = -1\n else\n ansE += (- sumE + 1 - ary[i]).abs\n sumE = 1\n end\n else\n sumE += ary[i]\n end\n if sumO * (sumO + ary[i]) >= 0\n if sumO > 0\n ansO += (- sumO - 1 - ary[i]).abs\n sumO = -1\n else\n ansO += (- sumO + 1 - ary[i]).abs\n sumO = 1\n end\n else\n sumO += ary[i]\n end\nend\n\nputs [ansE, ansO].min\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length N. The i-th term in the sequence is a_i.\nIn one operation, you can select a term and either increment or decrement it by one.\n\nAt least how many operations are necessary to satisfy the following conditions?\n\nFor every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero.\n\nFor every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.\n\nConstraints\n\n2 ≤ n ≤ 10^5\n\n|a_i| ≤ 10^9\n\nEach a_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint the minimum necessary count of operations.\n\nSample Input 1\n\n4\n1 -3 1 0\n\nSample Output 1\n\n4\n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four operations. The sums of the first one, two, three and four terms are 1, -1, 1 and -1, respectively, which satisfy the conditions.\n\nSample Input 2\n\n5\n3 -6 4 -5 7\n\nSample Output 2\n\n0\n\nThe given sequence already satisfies the conditions.\n\nSample Input 3\n\n6\n-1 4 3 2 -5 4\n\nSample Output 3\n\n8", "sample_input": "4\n1 -3 1 0\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03739", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length N. The i-th term in the sequence is a_i.\nIn one operation, you can select a term and either increment or decrement it by one.\n\nAt least how many operations are necessary to satisfy the following conditions?\n\nFor every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero.\n\nFor every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.\n\nConstraints\n\n2 ≤ n ≤ 10^5\n\n|a_i| ≤ 10^9\n\nEach a_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint the minimum necessary count of operations.\n\nSample Input 1\n\n4\n1 -3 1 0\n\nSample Output 1\n\n4\n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four operations. The sums of the first one, two, three and four terms are 1, -1, 1 and -1, respectively, which satisfy the conditions.\n\nSample Input 2\n\n5\n3 -6 4 -5 7\n\nSample Output 2\n\n0\n\nThe given sequence already satisfies the conditions.\n\nSample Input 3\n\n6\n-1 4 3 2 -5 4\n\nSample Output 3\n\n8", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 597, "cpu_time_ms": 80, "memory_kb": 8580}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s841266974", "group_id": "codeNet:p03745", "input_text": "a,k='';`tac`.split.map{|x|k&&a<<(k>x ??>:?<);k=x};p\"#{a}!\".gsub(/<+.|>+./,?a).size", "language": "Ruby", "metadata": {"date": 1492316730, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03745.html", "problem_id": "p03745", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03745/input.txt", "sample_output_relpath": "derived/input_output/data/p03745/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03745/Ruby/s841266974.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s841266974", "user_id": "u032223772"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "a,k='';`tac`.split.map{|x|k&&a<<(k>x ??>:?<);k=x};p\"#{a}!\".gsub(/<+.|>+./,?a).size", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an array A of length N.\nYour task is to divide it into several contiguous subarrays.\nHere, all subarrays obtained must be sorted in either non-decreasing or non-increasing order.\nAt least how many subarrays do you need to divide A into?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nEach A_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible number of subarrays after division of A.\n\nSample Input 1\n\n6\n1 2 3 2 2 1\n\nSample Output 1\n\n2\n\nOne optimal solution is to divide the array into [1,2,3] and [2,2,1].\n\nSample Input 2\n\n9\n1 2 1 2 1 2 1 2 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n7\n1 2 3 2 1 999999999 1000000000\n\nSample Output 3\n\n3", "sample_input": "6\n1 2 3 2 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03745", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an array A of length N.\nYour task is to divide it into several contiguous subarrays.\nHere, all subarrays obtained must be sorted in either non-decreasing or non-increasing order.\nAt least how many subarrays do you need to divide A into?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nEach A_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible number of subarrays after division of A.\n\nSample Input 1\n\n6\n1 2 3 2 2 1\n\nSample Output 1\n\n2\n\nOne optimal solution is to divide the array into [1,2,3] and [2,2,1].\n\nSample Input 2\n\n9\n1 2 1 2 1 2 1 2 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n7\n1 2 3 2 1 999999999 1000000000\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 82, "cpu_time_ms": 70, "memory_kb": 17388}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s876045754", "group_id": "codeNet:p03760", "input_text": "o=gets.chomp\ne=gets.chomp\nans=\"\"\ne.size.times do |i|\n ans+=o[i]+e[i]\nend\nans+=e[-1] if o.size-e.size==1\nputs ans\n", "language": "Ruby", "metadata": {"date": 1555518091, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03760.html", "problem_id": "p03760", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03760/input.txt", "sample_output_relpath": "derived/input_output/data/p03760/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03760/Ruby/s876045754.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s876045754", "user_id": "u602591412"}, "prompt_components": {"gold_output": "xaybzc\n", "input_to_evaluate": "o=gets.chomp\ne=gets.chomp\nans=\"\"\ne.size.times do |i|\n ans+=o[i]+e[i]\nend\nans+=e[-1] if o.size-e.size==1\nputs ans\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke signed up for a new website which holds programming competitions.\nHe worried that he might forget his password, and he took notes of it.\nSince directly recording his password would cause him trouble if stolen,\nhe took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions.\n\nYou are given two strings O and E. O contains the characters at the odd-numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order.\nRestore the original password.\n\nConstraints\n\nO and E consists of lowercase English letters (a - z).\n\n1 \\leq |O|,|E| \\leq 50\n\n|O| - |E| is either 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nO\nE\n\nOutput\n\nPrint the original password.\n\nSample Input 1\n\nxyz\nabc\n\nSample Output 1\n\nxaybzc\n\nThe original password is xaybzc. Extracting the characters at the odd-numbered positions results in xyz, and extracting the characters at the even-numbered positions results in abc.\n\nSample Input 2\n\natcoderbeginnercontest\natcoderregularcontest\n\nSample Output 2\n\naattccooddeerrbreeggiunlnaerrccoonntteesstt", "sample_input": "xyz\nabc\n"}, "reference_outputs": ["xaybzc\n"], "source_document_id": "p03760", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke signed up for a new website which holds programming competitions.\nHe worried that he might forget his password, and he took notes of it.\nSince directly recording his password would cause him trouble if stolen,\nhe took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions.\n\nYou are given two strings O and E. O contains the characters at the odd-numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order.\nRestore the original password.\n\nConstraints\n\nO and E consists of lowercase English letters (a - z).\n\n1 \\leq |O|,|E| \\leq 50\n\n|O| - |E| is either 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nO\nE\n\nOutput\n\nPrint the original password.\n\nSample Input 1\n\nxyz\nabc\n\nSample Output 1\n\nxaybzc\n\nThe original password is xaybzc. Extracting the characters at the odd-numbered positions results in xyz, and extracting the characters at the even-numbered positions results in abc.\n\nSample Input 2\n\natcoderbeginnercontest\natcoderregularcontest\n\nSample Output 2\n\naattccooddeerrbreeggiunlnaerrccoonntteesstt", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 114, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s548000991", "group_id": "codeNet:p03761", "input_text": "require 'pp'\n$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}\n\n# 入力値を数値で返却する\ndef gets_i()\n gets.chomp.to_i\nend\n\n# 入力値を文字の配列で返却する\ndef gets_nsp_list()\n gets.chomp.split(\"\")\nend\n\nN = gets_i\n\ns = gets_nsp_list\nans = s.group_by(&:itself).map{|k,v| [k,v.count]}.to_h\n\n(N - 1).times do\n s = gets_nsp_list\n count_hash = s.group_by(&:itself).map{|k,v| [k,v.count]}.to_h\n ans = (ans.keys & s).map do |k|\n [k, [ans[k], count_hash[k]].min]\n end.to_h\nend\n\nputs ans.map{|k,v| k * v}.join.chars.sort.join\n", "language": "Ruby", "metadata": {"date": 1589046525, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03761.html", "problem_id": "p03761", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03761/input.txt", "sample_output_relpath": "derived/input_output/data/p03761/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03761/Ruby/s548000991.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s548000991", "user_id": "u370977023"}, "prompt_components": {"gold_output": "aac\n", "input_to_evaluate": "require 'pp'\n$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}\n\n# 入力値を数値で返却する\ndef gets_i()\n gets.chomp.to_i\nend\n\n# 入力値を文字の配列で返却する\ndef gets_nsp_list()\n gets.chomp.split(\"\")\nend\n\nN = gets_i\n\ns = gets_nsp_list\nans = s.group_by(&:itself).map{|k,v| [k,v.count]}.to_h\n\n(N - 1).times do\n s = gets_nsp_list\n count_hash = s.group_by(&:itself).map{|k,v| [k,v.count]}.to_h\n ans = (ans.keys & s).map do |k|\n [k, [ans[k], count_hash[k]].min]\n end.to_h\nend\n\nputs ans.map{|k,v| k * v}.join.chars.sort.join\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke loves \"paper cutting\": he cuts out characters from a newspaper headline and rearranges them to form another string.\n\nHe will receive a headline which contains one of the strings S_1,...,S_n tomorrow.\nHe is excited and already thinking of what string he will create.\nSince he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains.\n\nFind the longest string that can be created regardless of which string among S_1,...,S_n the headline contains.\nIf there are multiple such strings, find the lexicographically smallest one among them.\n\nConstraints\n\n1 \\leq n \\leq 50\n\n1 \\leq |S_i| \\leq 50 for every i = 1, ..., n.\n\nS_i consists of lowercase English letters (a - z) for every i = 1, ..., n.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nS_1\n...\nS_n\n\nOutput\n\nPrint the lexicographically smallest string among the longest strings that satisfy the condition.\nIf the answer is an empty string, print an empty line.\n\nSample Input 1\n\n3\ncbaa\ndaacc\nacacac\n\nSample Output 1\n\naac\n\nThe strings that can be created from each of cbaa, daacc and acacac, are aa, aac, aca, caa and so forth.\nAmong them, aac, aca and caa are the longest, and the lexicographically smallest of these three is aac.\n\nSample Input 2\n\n3\na\naa\nb\n\nSample Output 2\n\nThe answer is an empty string.", "sample_input": "3\ncbaa\ndaacc\nacacac\n"}, "reference_outputs": ["aac\n"], "source_document_id": "p03761", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke loves \"paper cutting\": he cuts out characters from a newspaper headline and rearranges them to form another string.\n\nHe will receive a headline which contains one of the strings S_1,...,S_n tomorrow.\nHe is excited and already thinking of what string he will create.\nSince he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains.\n\nFind the longest string that can be created regardless of which string among S_1,...,S_n the headline contains.\nIf there are multiple such strings, find the lexicographically smallest one among them.\n\nConstraints\n\n1 \\leq n \\leq 50\n\n1 \\leq |S_i| \\leq 50 for every i = 1, ..., n.\n\nS_i consists of lowercase English letters (a - z) for every i = 1, ..., n.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nS_1\n...\nS_n\n\nOutput\n\nPrint the lexicographically smallest string among the longest strings that satisfy the condition.\nIf the answer is an empty string, print an empty line.\n\nSample Input 1\n\n3\ncbaa\ndaacc\nacacac\n\nSample Output 1\n\naac\n\nThe strings that can be created from each of cbaa, daacc and acacac, are aa, aac, aca, caa and so forth.\nAmong them, aac, aca and caa are the longest, and the lexicographically smallest of these three is aac.\n\nSample Input 2\n\n3\na\naa\nb\n\nSample Output 2\n\nThe answer is an empty string.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 565, "cpu_time_ms": 17, "memory_kb": 2556}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s199039441", "group_id": "codeNet:p03775", "input_text": "N = gets.to_i\nn = Math.sqrt(N).ceil;\n\nwhile n <= N do\n\tif (N % n == 0)\n\t\tprint i.to_s.size, \"\\n\"\n\t\tbreak\n\tend\n\tn += 1\nend\n", "language": "Ruby", "metadata": {"date": 1530426767, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03775.html", "problem_id": "p03775", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03775/input.txt", "sample_output_relpath": "derived/input_output/data/p03775/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03775/Ruby/s199039441.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s199039441", "user_id": "u576106056"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "N = gets.to_i\nn = Math.sqrt(N).ceil;\n\nwhile n <= N do\n\tif (N % n == 0)\n\t\tprint i.to_s.size, \"\\n\"\n\t\tbreak\n\tend\n\tn += 1\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFor two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.\n\nFor example, F(3,11) = 2 since 3 has one digit and 11 has two digits.\n\nFind the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nConstraints\n\n1 \\leq N \\leq 10^{10}\n\nN is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nSample Input 1\n\n10000\n\nSample Output 1\n\n3\n\nF(A,B) has a minimum value of 3 at (A,B)=(100,100).\n\nSample Input 2\n\n1000003\n\nSample Output 2\n\n7\n\nThere are two pairs (A,B) that satisfy the condition: (1,1000003) and (1000003,1). For these pairs, F(1,1000003)=F(1000003,1)=7.\n\nSample Input 3\n\n9876543210\n\nSample Output 3\n\n6", "sample_input": "10000\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03775", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFor two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.\n\nFor example, F(3,11) = 2 since 3 has one digit and 11 has two digits.\n\nFind the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nConstraints\n\n1 \\leq N \\leq 10^{10}\n\nN is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nSample Input 1\n\n10000\n\nSample Output 1\n\n3\n\nF(A,B) has a minimum value of 3 at (A,B)=(100,100).\n\nSample Input 2\n\n1000003\n\nSample Output 2\n\n7\n\nThere are two pairs (A,B) that satisfy the condition: (1,1000003) and (1000003,1). For these pairs, F(1,1000003)=F(1000003,1)=7.\n\nSample Input 3\n\n9876543210\n\nSample Output 3\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 122, "cpu_time_ms": 2107, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s611745502", "group_id": "codeNet:p03776", "input_text": "def comb(a, b)\n res = 1\n for i in 1..b do\n res = res * (a-i+1) / i\n end\n res\nend\n\nnab = gets.chomp.split.map { |s| s.to_i }\nv = gets.chomp.split.map { |s| s.to_i }.sort{|a, b| b <=> a }\ns = v[0...nab[1]]\nsum = s.reduce(:+)\navg = sum.to_f / s.length\nputs avg\n\nas = s.count(s.last)\nmx = v.count(s.last)\nif s.uniq.length == 1\n u = nab[2]\nelse\n u = nab[1]\nend\nad = [u-s.length+as, mx].min\nres = 0\nfor i in as..ad do\n res += comb(mx, i)\nend\n\nputs res", "language": "Ruby", "metadata": {"date": 1490587995, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03776.html", "problem_id": "p03776", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03776/input.txt", "sample_output_relpath": "derived/input_output/data/p03776/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03776/Ruby/s611745502.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s611745502", "user_id": "u664737319"}, "prompt_components": {"gold_output": "4.500000\n1\n", "input_to_evaluate": "def comb(a, b)\n res = 1\n for i in 1..b do\n res = res * (a-i+1) / i\n end\n res\nend\n\nnab = gets.chomp.split.map { |s| s.to_i }\nv = gets.chomp.split.map { |s| s.to_i }.sort{|a, b| b <=> a }\ns = v[0...nab[1]]\nsum = s.reduce(:+)\navg = sum.to_f / s.length\nputs avg\n\nas = s.count(s.last)\nmx = v.count(s.last)\nif s.uniq.length == 1\n u = nab[2]\nelse\n u = nab[1]\nend\nad = [u-s.length+as, mx].min\nres = 0\nfor i in as..ad do\n res += comb(mx, i)\nend\n\nputs res", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given N items.\n\nThe value of the i-th item (1 \\leq i \\leq N) is v_i.\n\nYour have to select at least A and at most B of these items.\n\nUnder this condition, find the maximum possible arithmetic mean of the values of selected items.\n\nAdditionally, find the number of ways to select items so that the mean of the values of selected items is maximized.\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq A,B \\leq N\n\n1 \\leq v_i \\leq 10^{15}\n\nEach v_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN A B\nv_1\nv_2\n...\nv_N\n\nOutput\n\nPrint two lines.\n\nThe first line should contain the maximum possible arithmetic mean of the values of selected items. The output should be considered correct if the absolute or relative error is at most 10^{-6}.\n\nThe second line should contain the number of ways to select items so that the mean of the values of selected items is maximized.\n\nSample Input 1\n\n5 2 2\n1 2 3 4 5\n\nSample Output 1\n\n4.500000\n1\n\nThe mean of the values of selected items will be maximized when selecting the fourth and fifth items. Hence, the first line of the output should contain 4.5.\n\nThere is no other way to select items so that the mean of the values will be 4.5, and thus the second line of the output should contain 1.\n\nSample Input 2\n\n4 2 3\n10 20 10 10\n\nSample Output 2\n\n15.000000\n3\n\nThere can be multiple ways to select items so that the mean of the values will be maximized.\n\nSample Input 3\n\n5 1 5\n1000000000000000 999999999999999 999999999999998 999999999999997 999999999999996\n\nSample Output 3\n\n1000000000000000.000000\n1", "sample_input": "5 2 2\n1 2 3 4 5\n"}, "reference_outputs": ["4.500000\n1\n"], "source_document_id": "p03776", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given N items.\n\nThe value of the i-th item (1 \\leq i \\leq N) is v_i.\n\nYour have to select at least A and at most B of these items.\n\nUnder this condition, find the maximum possible arithmetic mean of the values of selected items.\n\nAdditionally, find the number of ways to select items so that the mean of the values of selected items is maximized.\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq A,B \\leq N\n\n1 \\leq v_i \\leq 10^{15}\n\nEach v_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN A B\nv_1\nv_2\n...\nv_N\n\nOutput\n\nPrint two lines.\n\nThe first line should contain the maximum possible arithmetic mean of the values of selected items. The output should be considered correct if the absolute or relative error is at most 10^{-6}.\n\nThe second line should contain the number of ways to select items so that the mean of the values of selected items is maximized.\n\nSample Input 1\n\n5 2 2\n1 2 3 4 5\n\nSample Output 1\n\n4.500000\n1\n\nThe mean of the values of selected items will be maximized when selecting the fourth and fifth items. Hence, the first line of the output should contain 4.5.\n\nThere is no other way to select items so that the mean of the values will be 4.5, and thus the second line of the output should contain 1.\n\nSample Input 2\n\n4 2 3\n10 20 10 10\n\nSample Output 2\n\n15.000000\n3\n\nThere can be multiple ways to select items so that the mean of the values will be maximized.\n\nSample Input 3\n\n5 1 5\n1000000000000000 999999999999999 999999999999998 999999999999997 999999999999996\n\nSample Output 3\n\n1000000000000000.000000\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 455, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s931795423", "group_id": "codeNet:p03777", "input_text": "a, b = gets.chomp.split\n\nputs a == b ? 'H' : 'D'\n", "language": "Ruby", "metadata": {"date": 1566100203, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03777.html", "problem_id": "p03777", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03777/input.txt", "sample_output_relpath": "derived/input_output/data/p03777/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03777/Ruby/s931795423.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s931795423", "user_id": "u457499130"}, "prompt_components": {"gold_output": "H\n", "input_to_evaluate": "a, b = gets.chomp.split\n\nputs a == b ? 'H' : 'D'\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTwo deer, AtCoDeer and TopCoDeer, are playing a game called Honest or Dishonest.\nIn this game, an honest player always tells the truth, and an dishonest player always tell lies.\nYou are given two characters a and b as the input. Each of them is either H or D, and carries the following information:\n\nIf a=H, AtCoDeer is honest; if a=D, AtCoDeer is dishonest.\nIf b=H, AtCoDeer is saying that TopCoDeer is honest; if b=D, AtCoDeer is saying that TopCoDeer is dishonest.\n\nGiven this information, determine whether TopCoDeer is honest.\n\nConstraints\n\na=H or a=D.\n\nb=H or b=D.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf TopCoDeer is honest, print H. If he is dishonest, print D.\n\nSample Input 1\n\nH H\n\nSample Output 1\n\nH\n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\nSample Input 2\n\nD H\n\nSample Output 2\n\nD\n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says, TopCoDeer is dishonest.\n\nSample Input 3\n\nD D\n\nSample Output 3\n\nH", "sample_input": "H H\n"}, "reference_outputs": ["H\n"], "source_document_id": "p03777", "source_text": "Score : 100 points\n\nProblem Statement\n\nTwo deer, AtCoDeer and TopCoDeer, are playing a game called Honest or Dishonest.\nIn this game, an honest player always tells the truth, and an dishonest player always tell lies.\nYou are given two characters a and b as the input. Each of them is either H or D, and carries the following information:\n\nIf a=H, AtCoDeer is honest; if a=D, AtCoDeer is dishonest.\nIf b=H, AtCoDeer is saying that TopCoDeer is honest; if b=D, AtCoDeer is saying that TopCoDeer is dishonest.\n\nGiven this information, determine whether TopCoDeer is honest.\n\nConstraints\n\na=H or a=D.\n\nb=H or b=D.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf TopCoDeer is honest, print H. If he is dishonest, print D.\n\nSample Input 1\n\nH H\n\nSample Output 1\n\nH\n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\nSample Input 2\n\nD H\n\nSample Output 2\n\nD\n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says, TopCoDeer is dishonest.\n\nSample Input 3\n\nD D\n\nSample Output 3\n\nH", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 49, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s808289890", "group_id": "codeNet:p03779", "input_text": "x = gets.to_i\n\ns = t = 0\nwhile s < x\n t += 1\n s += t\nend\np t\n", "language": "Ruby", "metadata": {"date": 1489888679, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03779.html", "problem_id": "p03779", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03779/input.txt", "sample_output_relpath": "derived/input_output/data/p03779/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03779/Ruby/s808289890.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s808289890", "user_id": "u113091201"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "x = gets.to_i\n\ns = t = 0\nwhile s < x\n t += 1\n s += t\nend\np t\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0.\nDuring the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right.\nThat is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i.\nThe kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible.\nFind the earliest possible time to reach coordinate X.\n\nConstraints\n\nX is an integer.\n\n1≤X≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the earliest possible time for the kangaroo to reach coordinate X.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\nThe kangaroo can reach his nest at time 3 by jumping to the right three times, which is the earliest possible time.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n2\n\nHe can reach his nest at time 2 by staying at his position during the first second, and jumping to the right at the next second.\n\nSample Input 3\n\n11\n\nSample Output 3\n\n5", "sample_input": "6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03779", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0.\nDuring the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right.\nThat is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i.\nThe kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible.\nFind the earliest possible time to reach coordinate X.\n\nConstraints\n\nX is an integer.\n\n1≤X≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the earliest possible time for the kangaroo to reach coordinate X.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\nThe kangaroo can reach his nest at time 3 by jumping to the right three times, which is the earliest possible time.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n2\n\nHe can reach his nest at time 2 by staying at his position during the first second, and jumping to the right at the next second.\n\nSample Input 3\n\n11\n\nSample Output 3\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 63, "cpu_time_ms": 8, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s633420357", "group_id": "codeNet:p03795", "input_text": "n = gets.to_i\na = n * 800\nb = n / 15 * 200\nputs a - b", "language": "Ruby", "metadata": {"date": 1591820840, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03795.html", "problem_id": "p03795", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03795/input.txt", "sample_output_relpath": "derived/input_output/data/p03795/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03795/Ruby/s633420357.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s633420357", "user_id": "u462163804"}, "prompt_components": {"gold_output": "15800\n", "input_to_evaluate": "n = gets.to_i\na = n * 800\nb = n / 15 * 200\nputs a - b", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke has a favorite restaurant.\n\nThe price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.\n\nSo far, Snuke has ordered N meals at the restaurant.\nLet the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen.\nFind x-y.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n15800\n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen. Thus, the answer is 15800.\n\nSample Input 2\n\n60\n\nSample Output 2\n\n47200\n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800 yen.", "sample_input": "20\n"}, "reference_outputs": ["15800\n"], "source_document_id": "p03795", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke has a favorite restaurant.\n\nThe price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.\n\nSo far, Snuke has ordered N meals at the restaurant.\nLet the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen.\nFind x-y.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n15800\n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen. Thus, the answer is 15800.\n\nSample Input 2\n\n60\n\nSample Output 2\n\n47200\n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800 yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 53, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s043298599", "group_id": "codeNet:p03795", "input_text": "require 'pp'\n\ndef gets; ARGF.gets; end\n\nclass Solver\n\n def main\n n = gets.chomp.to_i\n\n puts 800 * n - 200 * (n / 15)\n end\nend\n\nif __FILE__ == $0\n Solver.new.main\nend\n", "language": "Ruby", "metadata": {"date": 1575093865, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03795.html", "problem_id": "p03795", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03795/input.txt", "sample_output_relpath": "derived/input_output/data/p03795/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03795/Ruby/s043298599.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s043298599", "user_id": "u657749689"}, "prompt_components": {"gold_output": "15800\n", "input_to_evaluate": "require 'pp'\n\ndef gets; ARGF.gets; end\n\nclass Solver\n\n def main\n n = gets.chomp.to_i\n\n puts 800 * n - 200 * (n / 15)\n end\nend\n\nif __FILE__ == $0\n Solver.new.main\nend\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke has a favorite restaurant.\n\nThe price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.\n\nSo far, Snuke has ordered N meals at the restaurant.\nLet the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen.\nFind x-y.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n15800\n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen. Thus, the answer is 15800.\n\nSample Input 2\n\n60\n\nSample Output 2\n\n47200\n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800 yen.", "sample_input": "20\n"}, "reference_outputs": ["15800\n"], "source_document_id": "p03795", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke has a favorite restaurant.\n\nThe price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.\n\nSo far, Snuke has ordered N meals at the restaurant.\nLet the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen.\nFind x-y.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n15800\n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen. Thus, the answer is 15800.\n\nSample Input 2\n\n60\n\nSample Output 2\n\n47200\n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800 yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 175, "cpu_time_ms": 14, "memory_kb": 2172}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s612354650", "group_id": "codeNet:p03795", "input_text": "N = gets.chomp.to_i\nsum = 800 * N\nback = N / 15 * 200\np sum - back", "language": "Ruby", "metadata": {"date": 1550370101, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03795.html", "problem_id": "p03795", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03795/input.txt", "sample_output_relpath": "derived/input_output/data/p03795/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03795/Ruby/s612354650.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s612354650", "user_id": "u502774641"}, "prompt_components": {"gold_output": "15800\n", "input_to_evaluate": "N = gets.chomp.to_i\nsum = 800 * N\nback = N / 15 * 200\np sum - back", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke has a favorite restaurant.\n\nThe price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.\n\nSo far, Snuke has ordered N meals at the restaurant.\nLet the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen.\nFind x-y.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n15800\n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen. Thus, the answer is 15800.\n\nSample Input 2\n\n60\n\nSample Output 2\n\n47200\n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800 yen.", "sample_input": "20\n"}, "reference_outputs": ["15800\n"], "source_document_id": "p03795", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke has a favorite restaurant.\n\nThe price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.\n\nSo far, Snuke has ordered N meals at the restaurant.\nLet the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen.\nFind x-y.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n15800\n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen. Thus, the answer is 15800.\n\nSample Input 2\n\n60\n\nSample Output 2\n\n47200\n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800 yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 66, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s722577269", "group_id": "codeNet:p03796", "input_text": "N = gets.chomp.to_i\n\n@ary = {\"0\" => 1}\ndef factorial n\n @ary[n.to_s] ||= n * factorial(n-1) % (10 ** 9 + 7)\nend\n\nputs factorial(N)\n\n# puts (1..N).inject(&:*) % (10 ** 9 + 7)\n", "language": "Ruby", "metadata": {"date": 1585887083, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03796.html", "problem_id": "p03796", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03796/input.txt", "sample_output_relpath": "derived/input_output/data/p03796/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03796/Ruby/s722577269.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s722577269", "user_id": "u792512290"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "N = gets.chomp.to_i\n\n@ary = {\"0\" => 1}\ndef factorial n\n @ary[n.to_s] ||= n * factorial(n-1) % (10 ** 9 + 7)\nend\n\nputs factorial(N)\n\n# puts (1..N).inject(&:*) % (10 ** 9 + 7)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke loves working out. He is now exercising N times.\n\nBefore he starts exercising, his power is 1. After he exercises for the i-th time, his power gets multiplied by i.\n\nFind Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.\n\nConstraints\n\n1 ≤ N ≤ 10^{5}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer modulo 10^{9}+7.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\nAfter Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n\nAfter Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n\nAfter Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n3628800\n\nSample Input 3\n\n100000\n\nSample Output 3\n\n457992974\n\nPrint the answer modulo 10^{9}+7.", "sample_input": "3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03796", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke loves working out. He is now exercising N times.\n\nBefore he starts exercising, his power is 1. After he exercises for the i-th time, his power gets multiplied by i.\n\nFind Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.\n\nConstraints\n\n1 ≤ N ≤ 10^{5}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer modulo 10^{9}+7.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\nAfter Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n\nAfter Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n\nAfter Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n3628800\n\nSample Input 3\n\n100000\n\nSample Output 3\n\n457992974\n\nPrint the answer modulo 10^{9}+7.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 175, "cpu_time_ms": 17, "memory_kb": 3836}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s460262654", "group_id": "codeNet:p03797", "input_text": "s,c = gets.split.map(&:to_i)\ncount = 0\nr = c.to_f / (s*2)\nr <= 1 ? count += s*r : count += s\nc -= s*2\ncount += c / 4\nputs count", "language": "Ruby", "metadata": {"date": 1489548868, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03797.html", "problem_id": "p03797", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03797/input.txt", "sample_output_relpath": "derived/input_output/data/p03797/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03797/Ruby/s460262654.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s460262654", "user_id": "u302480297"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "s,c = gets.split.map(&:to_i)\ncount = 0\nr = c.to_f / (s*2)\nr <= 1 ? count += s*r : count += s\nc -= s*2\ncount += c / 4\nputs count", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke loves puzzles.\n\nToday, he is working on a puzzle using S- and c-shaped pieces.\nIn this puzzle, you can combine two c-shaped pieces into one S-shaped piece, as shown in the figure below:\n\nSnuke decided to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces.\n\nFind the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\n\nConstraints\n\n1 ≤ N,M ≤ 10^{12}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 6\n\nSample Output 1\n\n2\n\nTwo Scc groups can be created as follows:\n\nCombine two c-shaped pieces into one S-shaped piece\n\nCreate two Scc groups, each from one S-shaped piece and two c-shaped pieces\n\nSample Input 2\n\n12345 678901\n\nSample Output 2\n\n175897", "sample_input": "1 6\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03797", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke loves puzzles.\n\nToday, he is working on a puzzle using S- and c-shaped pieces.\nIn this puzzle, you can combine two c-shaped pieces into one S-shaped piece, as shown in the figure below:\n\nSnuke decided to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces.\n\nFind the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\n\nConstraints\n\n1 ≤ N,M ≤ 10^{12}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 6\n\nSample Output 1\n\n2\n\nTwo Scc groups can be created as follows:\n\nCombine two c-shaped pieces into one S-shaped piece\n\nCreate two Scc groups, each from one S-shaped piece and two c-shaped pieces\n\nSample Input 2\n\n12345 678901\n\nSample Output 2\n\n175897", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 127, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s713714123", "group_id": "codeNet:p03804", "input_text": "require 'matrix'\n\nn, m = gets.split.map(&:to_i)\na = Matrix.zero(n)\nb = Matrix.zero(m)\nn.times do |i|\n s = gets.chomp.chars\n n.times do |j|\n if s[j] == '#'\n a[i, j] = 1\n end\n end\nend\nm.times do |i|\n s = gets.chomp.chars\n m.times do |j|\n if s[j] == '#'\n b[i, j] = 1\n end\n end\nend\n(n - m).times do |i|\n (n - m).times do |j|\n if a.minor(i, m, j, m) == b\n puts \"Yes\"\n exit\n end\n end\nend\nputs \"No\"", "language": "Ruby", "metadata": {"date": 1589931225, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03804.html", "problem_id": "p03804", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03804/input.txt", "sample_output_relpath": "derived/input_output/data/p03804/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03804/Ruby/s713714123.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s713714123", "user_id": "u979552932"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "require 'matrix'\n\nn, m = gets.split.map(&:to_i)\na = Matrix.zero(n)\nb = Matrix.zero(m)\nn.times do |i|\n s = gets.chomp.chars\n n.times do |j|\n if s[j] == '#'\n a[i, j] = 1\n end\n end\nend\nm.times do |i|\n s = gets.chomp.chars\n m.times do |j|\n if s[j] == '#'\n b[i, j] = 1\n end\n end\nend\n(n - m).times do |i|\n (n - m).times do |j|\n if a.minor(i, m, j, m) == b\n puts \"Yes\"\n exit\n end\n end\nend\nputs \"No\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.\n\nA pixel is the smallest element of an image, and in this problem it is a square of size 1×1.\n\nAlso, the given images are binary images, and the color of each pixel is either white or black.\n\nIn the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.\n\nThe image A is given as N strings A_1,...,A_N.\n\nThe j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).\n\nSimilarly, the template image B is given as M strings B_1,...,B_M.\n\nThe j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).\n\nDetermine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.\n\nConstraints\n\n1≦M≦N≦50\n\nA_i is a string of length N consisting of # and ..\n\nB_i is a string of length M consisting of # and ..\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nA_1\nA_2\n:\nA_N\nB_1\nB_2\n:\nB_M\n\nOutput\n\nPrint Yes if the template image B is contained in the image A. Print No otherwise.\n\nSample Input 1\n\n3 2\n#.#\n.#.\n#.#\n#.\n.#\n\nSample Output 1\n\nYes\n\nThe template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.\n\nSample Input 2\n\n4 1\n....\n....\n....\n....\n#\n\nSample Output 2\n\nNo\n\nThe template image B, composed of a black pixel, is not contained in the image A composed of white pixels.", "sample_input": "3 2\n#.#\n.#.\n#.#\n#.\n.#\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03804", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.\n\nA pixel is the smallest element of an image, and in this problem it is a square of size 1×1.\n\nAlso, the given images are binary images, and the color of each pixel is either white or black.\n\nIn the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.\n\nThe image A is given as N strings A_1,...,A_N.\n\nThe j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).\n\nSimilarly, the template image B is given as M strings B_1,...,B_M.\n\nThe j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).\n\nDetermine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.\n\nConstraints\n\n1≦M≦N≦50\n\nA_i is a string of length N consisting of # and ..\n\nB_i is a string of length M consisting of # and ..\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nA_1\nA_2\n:\nA_N\nB_1\nB_2\n:\nB_M\n\nOutput\n\nPrint Yes if the template image B is contained in the image A. Print No otherwise.\n\nSample Input 1\n\n3 2\n#.#\n.#.\n#.#\n#.\n.#\n\nSample Output 1\n\nYes\n\nThe template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.\n\nSample Input 2\n\n4 1\n....\n....\n....\n....\n#\n\nSample Output 2\n\nNo\n\nThe template image B, composed of a black pixel, is not contained in the image A composed of white pixels.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 437, "cpu_time_ms": 21, "memory_kb": 2940}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s206104100", "group_id": "codeNet:p03804", "input_text": "n,m=gets.chomp.split.map(&:to_i)\nnStrings=n.times.map{gets.chomp.split(\" \").join}\nmStrings=m.times.map{gets.chomp.split(\" \").join}\nresult = \"No\"\n(0..(n-m)).each do |yIndex|\n (0..(n-m)).each do |xIndex|\n if nStrings[yIndex].index(mStrings[0],xIndex) != nil\n result = \"Yes\"\n mStrings.each_with_index do |mString,tempIndex|\n next if tempIndex == 0\n findNumber = nStrings[tempIndex+yIndex].index(mString,xIndex)\n if findNumber == nil || findNumber != xIndex\n result = \"No\"\n break\n end\n end\n end\n break if result == \"Yes\"\n end\n break if result == \"Yes\"\nend\nputs result", "language": "Ruby", "metadata": {"date": 1551113296, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03804.html", "problem_id": "p03804", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03804/input.txt", "sample_output_relpath": "derived/input_output/data/p03804/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03804/Ruby/s206104100.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s206104100", "user_id": "u802371628"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "n,m=gets.chomp.split.map(&:to_i)\nnStrings=n.times.map{gets.chomp.split(\" \").join}\nmStrings=m.times.map{gets.chomp.split(\" \").join}\nresult = \"No\"\n(0..(n-m)).each do |yIndex|\n (0..(n-m)).each do |xIndex|\n if nStrings[yIndex].index(mStrings[0],xIndex) != nil\n result = \"Yes\"\n mStrings.each_with_index do |mString,tempIndex|\n next if tempIndex == 0\n findNumber = nStrings[tempIndex+yIndex].index(mString,xIndex)\n if findNumber == nil || findNumber != xIndex\n result = \"No\"\n break\n end\n end\n end\n break if result == \"Yes\"\n end\n break if result == \"Yes\"\nend\nputs result", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.\n\nA pixel is the smallest element of an image, and in this problem it is a square of size 1×1.\n\nAlso, the given images are binary images, and the color of each pixel is either white or black.\n\nIn the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.\n\nThe image A is given as N strings A_1,...,A_N.\n\nThe j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).\n\nSimilarly, the template image B is given as M strings B_1,...,B_M.\n\nThe j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).\n\nDetermine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.\n\nConstraints\n\n1≦M≦N≦50\n\nA_i is a string of length N consisting of # and ..\n\nB_i is a string of length M consisting of # and ..\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nA_1\nA_2\n:\nA_N\nB_1\nB_2\n:\nB_M\n\nOutput\n\nPrint Yes if the template image B is contained in the image A. Print No otherwise.\n\nSample Input 1\n\n3 2\n#.#\n.#.\n#.#\n#.\n.#\n\nSample Output 1\n\nYes\n\nThe template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.\n\nSample Input 2\n\n4 1\n....\n....\n....\n....\n#\n\nSample Output 2\n\nNo\n\nThe template image B, composed of a black pixel, is not contained in the image A composed of white pixels.", "sample_input": "3 2\n#.#\n.#.\n#.#\n#.\n.#\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03804", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.\n\nA pixel is the smallest element of an image, and in this problem it is a square of size 1×1.\n\nAlso, the given images are binary images, and the color of each pixel is either white or black.\n\nIn the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.\n\nThe image A is given as N strings A_1,...,A_N.\n\nThe j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).\n\nSimilarly, the template image B is given as M strings B_1,...,B_M.\n\nThe j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).\n\nDetermine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.\n\nConstraints\n\n1≦M≦N≦50\n\nA_i is a string of length N consisting of # and ..\n\nB_i is a string of length M consisting of # and ..\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nA_1\nA_2\n:\nA_N\nB_1\nB_2\n:\nB_M\n\nOutput\n\nPrint Yes if the template image B is contained in the image A. Print No otherwise.\n\nSample Input 1\n\n3 2\n#.#\n.#.\n#.#\n#.\n.#\n\nSample Output 1\n\nYes\n\nThe template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.\n\nSample Input 2\n\n4 1\n....\n....\n....\n....\n#\n\nSample Output 2\n\nNo\n\nThe template image B, composed of a black pixel, is not contained in the image A composed of white pixels.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 635, "cpu_time_ms": 8, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s731595420", "group_id": "codeNet:p03804", "input_text": "N, M = gets.split.map(&:to_i)\n\nas = []\nN.times do\n as << gets.chomp\nend\nbs = []\nM.times do\n bs << gets.chomp\nend\n\n(0..(N-M)).each do |n|\n (0..(N-M)).each do |m|\n tmp = []\n M.times do |dn|\n tmp << (as[n + dn][m, M] == bs[dn])\n end\n if tmp.all? { |e| e == true }\n puts('Yes')\n exit\n end\n end\nend\nputs('No')", "language": "Ruby", "metadata": {"date": 1529444888, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03804.html", "problem_id": "p03804", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03804/input.txt", "sample_output_relpath": "derived/input_output/data/p03804/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03804/Ruby/s731595420.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s731595420", "user_id": "u083707708"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "N, M = gets.split.map(&:to_i)\n\nas = []\nN.times do\n as << gets.chomp\nend\nbs = []\nM.times do\n bs << gets.chomp\nend\n\n(0..(N-M)).each do |n|\n (0..(N-M)).each do |m|\n tmp = []\n M.times do |dn|\n tmp << (as[n + dn][m, M] == bs[dn])\n end\n if tmp.all? { |e| e == true }\n puts('Yes')\n exit\n end\n end\nend\nputs('No')", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.\n\nA pixel is the smallest element of an image, and in this problem it is a square of size 1×1.\n\nAlso, the given images are binary images, and the color of each pixel is either white or black.\n\nIn the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.\n\nThe image A is given as N strings A_1,...,A_N.\n\nThe j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).\n\nSimilarly, the template image B is given as M strings B_1,...,B_M.\n\nThe j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).\n\nDetermine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.\n\nConstraints\n\n1≦M≦N≦50\n\nA_i is a string of length N consisting of # and ..\n\nB_i is a string of length M consisting of # and ..\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nA_1\nA_2\n:\nA_N\nB_1\nB_2\n:\nB_M\n\nOutput\n\nPrint Yes if the template image B is contained in the image A. Print No otherwise.\n\nSample Input 1\n\n3 2\n#.#\n.#.\n#.#\n#.\n.#\n\nSample Output 1\n\nYes\n\nThe template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.\n\nSample Input 2\n\n4 1\n....\n....\n....\n....\n#\n\nSample Output 2\n\nNo\n\nThe template image B, composed of a black pixel, is not contained in the image A composed of white pixels.", "sample_input": "3 2\n#.#\n.#.\n#.#\n#.\n.#\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03804", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.\n\nA pixel is the smallest element of an image, and in this problem it is a square of size 1×1.\n\nAlso, the given images are binary images, and the color of each pixel is either white or black.\n\nIn the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.\n\nThe image A is given as N strings A_1,...,A_N.\n\nThe j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).\n\nSimilarly, the template image B is given as M strings B_1,...,B_M.\n\nThe j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).\n\nDetermine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.\n\nConstraints\n\n1≦M≦N≦50\n\nA_i is a string of length N consisting of # and ..\n\nB_i is a string of length M consisting of # and ..\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nA_1\nA_2\n:\nA_N\nB_1\nB_2\n:\nB_M\n\nOutput\n\nPrint Yes if the template image B is contained in the image A. Print No otherwise.\n\nSample Input 1\n\n3 2\n#.#\n.#.\n#.#\n#.\n.#\n\nSample Output 1\n\nYes\n\nThe template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.\n\nSample Input 2\n\n4 1\n....\n....\n....\n....\n#\n\nSample Output 2\n\nNo\n\nThe template image B, composed of a black pixel, is not contained in the image A composed of white pixels.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 14, "memory_kb": 2044}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s783396191", "group_id": "codeNet:p03804", "input_text": "n, m = gets.chomp.split(\" \").map(&:to_i)\na = []\nn.times do\n a << gets.chomp.split(\"\")\nend\n\nb = []\nm.times do\n b << gets.chomp\nend\nb = b.join(\"\")\n(n - m + 1).times do |py|\n (n - m + 1).times do |px|\n a_sub = []\n (py...(py+m)).each do |y| \n a_sub += a[y][px...(px+m)]\n end\n a_sub = a_sub.join(\"\")\n if b == a_sub then\n puts \"Yes\"\n exit\n end\n end\nend\n\nputs \"No\"", "language": "Ruby", "metadata": {"date": 1486866710, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03804.html", "problem_id": "p03804", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03804/input.txt", "sample_output_relpath": "derived/input_output/data/p03804/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03804/Ruby/s783396191.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s783396191", "user_id": "u910756197"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "n, m = gets.chomp.split(\" \").map(&:to_i)\na = []\nn.times do\n a << gets.chomp.split(\"\")\nend\n\nb = []\nm.times do\n b << gets.chomp\nend\nb = b.join(\"\")\n(n - m + 1).times do |py|\n (n - m + 1).times do |px|\n a_sub = []\n (py...(py+m)).each do |y| \n a_sub += a[y][px...(px+m)]\n end\n a_sub = a_sub.join(\"\")\n if b == a_sub then\n puts \"Yes\"\n exit\n end\n end\nend\n\nputs \"No\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.\n\nA pixel is the smallest element of an image, and in this problem it is a square of size 1×1.\n\nAlso, the given images are binary images, and the color of each pixel is either white or black.\n\nIn the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.\n\nThe image A is given as N strings A_1,...,A_N.\n\nThe j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).\n\nSimilarly, the template image B is given as M strings B_1,...,B_M.\n\nThe j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).\n\nDetermine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.\n\nConstraints\n\n1≦M≦N≦50\n\nA_i is a string of length N consisting of # and ..\n\nB_i is a string of length M consisting of # and ..\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nA_1\nA_2\n:\nA_N\nB_1\nB_2\n:\nB_M\n\nOutput\n\nPrint Yes if the template image B is contained in the image A. Print No otherwise.\n\nSample Input 1\n\n3 2\n#.#\n.#.\n#.#\n#.\n.#\n\nSample Output 1\n\nYes\n\nThe template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.\n\nSample Input 2\n\n4 1\n....\n....\n....\n....\n#\n\nSample Output 2\n\nNo\n\nThe template image B, composed of a black pixel, is not contained in the image A composed of white pixels.", "sample_input": "3 2\n#.#\n.#.\n#.#\n#.\n.#\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03804", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.\n\nA pixel is the smallest element of an image, and in this problem it is a square of size 1×1.\n\nAlso, the given images are binary images, and the color of each pixel is either white or black.\n\nIn the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.\n\nThe image A is given as N strings A_1,...,A_N.\n\nThe j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).\n\nSimilarly, the template image B is given as M strings B_1,...,B_M.\n\nThe j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).\n\nDetermine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.\n\nConstraints\n\n1≦M≦N≦50\n\nA_i is a string of length N consisting of # and ..\n\nB_i is a string of length M consisting of # and ..\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nA_1\nA_2\n:\nA_N\nB_1\nB_2\n:\nB_M\n\nOutput\n\nPrint Yes if the template image B is contained in the image A. Print No otherwise.\n\nSample Input 1\n\n3 2\n#.#\n.#.\n#.#\n#.\n.#\n\nSample Output 1\n\nYes\n\nThe template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.\n\nSample Input 2\n\n4 1\n....\n....\n....\n....\n#\n\nSample Output 2\n\nNo\n\nThe template image B, composed of a black pixel, is not contained in the image A composed of white pixels.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 396, "cpu_time_ms": 67, "memory_kb": 9888}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s922419862", "group_id": "codeNet:p03807", "input_text": "n = gets.chomp.to_i\naa = gets.chomp.split.map(&:to_i)\n\nodd = 0\n(0...n).each do |i|\n odd += 1 if aa[i] % 2 == 1\nend\n\nif odd % 2 == 0\n puts(\"YES\")\nelse\n puts(\"NO\")\nend", "language": "Ruby", "metadata": {"date": 1527821788, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03807.html", "problem_id": "p03807", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03807/input.txt", "sample_output_relpath": "derived/input_output/data/p03807/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03807/Ruby/s922419862.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s922419862", "user_id": "u776725702"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "n = gets.chomp.to_i\naa = gets.chomp.split.map(&:to_i)\n\nodd = 0\n(0...n).each do |i|\n odd += 1 if aa[i] % 2 == 1\nend\n\nif odd % 2 == 0\n puts(\"YES\")\nelse\n puts(\"NO\")\nend", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N integers written on a blackboard. The i-th integer is A_i.\n\nTakahashi will repeatedly perform the following operation on these numbers:\n\nSelect a pair of integers, A_i and A_j, that have the same parity (that is, both are even or both are odd) and erase them.\n\nThen, write a new integer on the blackboard that is equal to the sum of those integers, A_i+A_j.\n\nDetermine whether it is possible to have only one integer on the blackboard.\n\nConstraints\n\n2 ≦ N ≦ 10^5\n\n1 ≦ A_i ≦ 10^9\n\nA_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 … A_N\n\nOutput\n\nIf it is possible to have only one integer on the blackboard, print YES. Otherwise, print NO.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\nYES\n\nIt is possible to have only one integer on the blackboard, as follows:\n\nErase 1 and 3 from the blackboard, then write 4. Now, there are two integers on the blackboard: 2 and 4.\n\nErase 2 and 4 from the blackboard, then write 6. Now, there is only one integer on the blackboard: 6.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\nNO", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03807", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N integers written on a blackboard. The i-th integer is A_i.\n\nTakahashi will repeatedly perform the following operation on these numbers:\n\nSelect a pair of integers, A_i and A_j, that have the same parity (that is, both are even or both are odd) and erase them.\n\nThen, write a new integer on the blackboard that is equal to the sum of those integers, A_i+A_j.\n\nDetermine whether it is possible to have only one integer on the blackboard.\n\nConstraints\n\n2 ≦ N ≦ 10^5\n\n1 ≦ A_i ≦ 10^9\n\nA_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 … A_N\n\nOutput\n\nIf it is possible to have only one integer on the blackboard, print YES. Otherwise, print NO.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\nYES\n\nIt is possible to have only one integer on the blackboard, as follows:\n\nErase 1 and 3 from the blackboard, then write 4. Now, there are two integers on the blackboard: 2 and 4.\n\nErase 2 and 4 from the blackboard, then write 6. Now, there is only one integer on the blackboard: 6.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 168, "cpu_time_ms": 57, "memory_kb": 9476}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s305527130", "group_id": "codeNet:p03807", "input_text": "k = gets.to_i\na = \"\"\na = gets.chomp.split(\" \").map(&:to_i)\n\ncount_kisu = 0\ncount_gusu = 0\nlen = 0\n\nif(k%2 == 0)\n len = (k / 2) - 1\nelse \n len = k / 2\nend\n\nfor i in 0..len\n if(a[i]%2 != 0)\n count_kisu += 1\n else\n count_gusu += 1\n end\n \n if(i != k-1-i)\n if(a[k-1-i]%2 != 0)\n count_kisu += 1\n else\n count_gusu += 1\n end\n end\nend\n\nwhile count_gusu%2 == 0\n count_gusu = count_gusu / 2\n if(count_gusu == 1)\n flg = 1\n break\n end\nend\n\nif(count_kisu%2 != 0)\n print(\"NO\")\nelsif((count_kisu%2 == 0) && (k%2 == 0) && (flg == 1))\n print(\"NO\")\nelse\n print(\"YES\")\nend\n", "language": "Ruby", "metadata": {"date": 1486263727, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03807.html", "problem_id": "p03807", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03807/input.txt", "sample_output_relpath": "derived/input_output/data/p03807/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03807/Ruby/s305527130.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s305527130", "user_id": "u573474386"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "k = gets.to_i\na = \"\"\na = gets.chomp.split(\" \").map(&:to_i)\n\ncount_kisu = 0\ncount_gusu = 0\nlen = 0\n\nif(k%2 == 0)\n len = (k / 2) - 1\nelse \n len = k / 2\nend\n\nfor i in 0..len\n if(a[i]%2 != 0)\n count_kisu += 1\n else\n count_gusu += 1\n end\n \n if(i != k-1-i)\n if(a[k-1-i]%2 != 0)\n count_kisu += 1\n else\n count_gusu += 1\n end\n end\nend\n\nwhile count_gusu%2 == 0\n count_gusu = count_gusu / 2\n if(count_gusu == 1)\n flg = 1\n break\n end\nend\n\nif(count_kisu%2 != 0)\n print(\"NO\")\nelsif((count_kisu%2 == 0) && (k%2 == 0) && (flg == 1))\n print(\"NO\")\nelse\n print(\"YES\")\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N integers written on a blackboard. The i-th integer is A_i.\n\nTakahashi will repeatedly perform the following operation on these numbers:\n\nSelect a pair of integers, A_i and A_j, that have the same parity (that is, both are even or both are odd) and erase them.\n\nThen, write a new integer on the blackboard that is equal to the sum of those integers, A_i+A_j.\n\nDetermine whether it is possible to have only one integer on the blackboard.\n\nConstraints\n\n2 ≦ N ≦ 10^5\n\n1 ≦ A_i ≦ 10^9\n\nA_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 … A_N\n\nOutput\n\nIf it is possible to have only one integer on the blackboard, print YES. Otherwise, print NO.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\nYES\n\nIt is possible to have only one integer on the blackboard, as follows:\n\nErase 1 and 3 from the blackboard, then write 4. Now, there are two integers on the blackboard: 2 and 4.\n\nErase 2 and 4 from the blackboard, then write 6. Now, there is only one integer on the blackboard: 6.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\nNO", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03807", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N integers written on a blackboard. The i-th integer is A_i.\n\nTakahashi will repeatedly perform the following operation on these numbers:\n\nSelect a pair of integers, A_i and A_j, that have the same parity (that is, both are even or both are odd) and erase them.\n\nThen, write a new integer on the blackboard that is equal to the sum of those integers, A_i+A_j.\n\nDetermine whether it is possible to have only one integer on the blackboard.\n\nConstraints\n\n2 ≦ N ≦ 10^5\n\n1 ≦ A_i ≦ 10^9\n\nA_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 … A_N\n\nOutput\n\nIf it is possible to have only one integer on the blackboard, print YES. Otherwise, print NO.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\nYES\n\nIt is possible to have only one integer on the blackboard, as follows:\n\nErase 1 and 3 from the blackboard, then write 4. Now, there are two integers on the blackboard: 2 and 4.\n\nErase 2 and 4 from the blackboard, then write 6. Now, there is only one integer on the blackboard: 6.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 672, "cpu_time_ms": 2102, "memory_kb": 9492}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s141357186", "group_id": "codeNet:p03808", "input_text": "N = gets.to_i\nM = N * (N + 1) / 2\n\na_list = gets.strip.split(/ /).collect{|num| num.to_i}\n\nsum = a_list.inject(:+)\n\nif sum % M == 0\n\tL = sum / M\n\t\n\tstart_points = 0\n\t\n\tprev_a = a_list[N - 1]\n\t(0...N).each{|i|\n\t\ta = a_list[i]\n\t\tdiff = a - prev_a\n\t\tif diff > L\n\t\t\tputs \"NO1\"\n\t\t\texit\n\t\telsif diff != L\n\t\t\t# x - (N - 1)(L - x) = diff\n\t\t\t# x = (diff + NL - L) / N\n\t\t\tif (diff + N * L - L) % N != 0\n\t\t\t\tputs \"NO2\"\n\t\t\t\texit\n\t\t\telse\n\t\t\t\tstart_points += L - (diff + N * L - L) / N\n\t\t\t\tif start_points > L\n\t\t\t\t\tputs \"NO3\"\n\t\t\t\t\texit\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tprev_a = a\n\t}\n\n\tif (L - start_points) % L == 0\n\t\tputs \"YES\"\n\telse\n\t\tputs \"NO\"\n\tend\n\t\nelse\n\tputs \"NO\"\nend\n", "language": "Ruby", "metadata": {"date": 1486263080, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03808.html", "problem_id": "p03808", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03808/input.txt", "sample_output_relpath": "derived/input_output/data/p03808/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03808/Ruby/s141357186.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s141357186", "user_id": "u751724075"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "N = gets.to_i\nM = N * (N + 1) / 2\n\na_list = gets.strip.split(/ /).collect{|num| num.to_i}\n\nsum = a_list.inject(:+)\n\nif sum % M == 0\n\tL = sum / M\n\t\n\tstart_points = 0\n\t\n\tprev_a = a_list[N - 1]\n\t(0...N).each{|i|\n\t\ta = a_list[i]\n\t\tdiff = a - prev_a\n\t\tif diff > L\n\t\t\tputs \"NO1\"\n\t\t\texit\n\t\telsif diff != L\n\t\t\t# x - (N - 1)(L - x) = diff\n\t\t\t# x = (diff + NL - L) / N\n\t\t\tif (diff + N * L - L) % N != 0\n\t\t\t\tputs \"NO2\"\n\t\t\t\texit\n\t\t\telse\n\t\t\t\tstart_points += L - (diff + N * L - L) / N\n\t\t\t\tif start_points > L\n\t\t\t\t\tputs \"NO3\"\n\t\t\t\t\texit\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tprev_a = a\n\t}\n\n\tif (L - start_points) % L == 0\n\t\tputs \"YES\"\n\telse\n\t\tputs \"NO\"\n\tend\n\t\nelse\n\tputs \"NO\"\nend\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N boxes arranged in a circle. The i-th box contains A_i stones.\n\nDetermine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:\n\nSelect one box. Let the box be the i-th box. Then, for each j from 1 through N, remove exactly j stones from the (i+j)-th box. Here, the (N+k)-th box is identified with the k-th box.\n\nNote that the operation cannot be performed if there is a box that does not contain enough number of stones to be removed.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n1 ≦ A_i ≦ 10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 … A_N\n\nOutput\n\nIf it is possible to remove all the stones from the boxes, print YES. Otherwise, print NO.\n\nSample Input 1\n\n5\n4 5 1 2 3\n\nSample Output 1\n\nYES\n\nAll the stones can be removed in one operation by selecting the second box.\n\nSample Input 2\n\n5\n6 9 12 10 8\n\nSample Output 2\n\nYES\n\nSample Input 3\n\n4\n1 2 3 1\n\nSample Output 3\n\nNO", "sample_input": "5\n4 5 1 2 3\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03808", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N boxes arranged in a circle. The i-th box contains A_i stones.\n\nDetermine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:\n\nSelect one box. Let the box be the i-th box. Then, for each j from 1 through N, remove exactly j stones from the (i+j)-th box. Here, the (N+k)-th box is identified with the k-th box.\n\nNote that the operation cannot be performed if there is a box that does not contain enough number of stones to be removed.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n1 ≦ A_i ≦ 10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 … A_N\n\nOutput\n\nIf it is possible to remove all the stones from the boxes, print YES. Otherwise, print NO.\n\nSample Input 1\n\n5\n4 5 1 2 3\n\nSample Output 1\n\nYES\n\nAll the stones can be removed in one operation by selecting the second box.\n\nSample Input 2\n\n5\n6 9 12 10 8\n\nSample Output 2\n\nYES\n\nSample Input 3\n\n4\n1 2 3 1\n\nSample Output 3\n\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 650, "cpu_time_ms": 107, "memory_kb": 9492}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s204763030", "group_id": "codeNet:p03813", "input_text": "x = gets.to_i\nputs x < 1200 ? \"ABC\" : \"ARC\"\n", "language": "Ruby", "metadata": {"date": 1590548306, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03813.html", "problem_id": "p03813", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03813/input.txt", "sample_output_relpath": "derived/input_output/data/p03813/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03813/Ruby/s204763030.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s204763030", "user_id": "u122428774"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "x = gets.to_i\nputs x < 1200 ? \"ABC\" : \"ARC\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSmeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.\n\nYou are given Smeke's current rating, x. Print ABC if Smeke will participate in ABC, and print ARC otherwise.\n\nConstraints\n\n1 ≦ x ≦ 3{,}000\n\nx is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1000\n\nSample Output 1\n\nABC\n\nSmeke's current rating is less than 1200, thus the output should be ABC.\n\nSample Input 2\n\n2000\n\nSample Output 2\n\nARC\n\nSmeke's current rating is not less than 1200, thus the output should be ARC.", "sample_input": "1000\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03813", "source_text": "Score : 100 points\n\nProblem Statement\n\nSmeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.\n\nYou are given Smeke's current rating, x. Print ABC if Smeke will participate in ABC, and print ARC otherwise.\n\nConstraints\n\n1 ≦ x ≦ 3{,}000\n\nx is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1000\n\nSample Output 1\n\nABC\n\nSmeke's current rating is less than 1200, thus the output should be ABC.\n\nSample Input 2\n\n2000\n\nSample Output 2\n\nARC\n\nSmeke's current rating is not less than 1200, thus the output should be ARC.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 44, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s536600428", "group_id": "codeNet:p03815", "input_text": "x = gets.to_i\nn = x / 11 * 2\n\nif (x % 11).between?(1, 6)\n n += 1\nelsif (x % 11).between?(7, 10)\n n += 2\nend\n\np n \n", "language": "Ruby", "metadata": {"date": 1485670351, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03815.html", "problem_id": "p03815", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03815/input.txt", "sample_output_relpath": "derived/input_output/data/p03815/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03815/Ruby/s536600428.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s536600428", "user_id": "u113091201"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "x = gets.to_i\nn = x / 11 * 2\n\nif (x % 11).between?(1, 6)\n n += 1\nelsif (x % 11).between?(7, 10)\n n += 2\nend\n\np n \n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.\n\nSnuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:\n\nOperation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.\n\nFor example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure.\nIf the die is rotated toward the right as shown in the figure, the side showing 3 will face upward.\nBesides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.\n\nFind the minimum number of operation Snuke needs to perform in order to score at least x points in total.\n\nConstraints\n\n1 ≦ x ≦ 10^{15}\n\nx is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n2\n\nSample Input 2\n\n149696127901\n\nSample Output 2\n\n27217477801", "sample_input": "7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03815", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.\n\nSnuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:\n\nOperation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.\n\nFor example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure.\nIf the die is rotated toward the right as shown in the figure, the side showing 3 will face upward.\nBesides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.\n\nFind the minimum number of operation Snuke needs to perform in order to score at least x points in total.\n\nConstraints\n\n1 ≦ x ≦ 10^{15}\n\nx is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n2\n\nSample Input 2\n\n149696127901\n\nSample Output 2\n\n27217477801", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 116, "cpu_time_ms": 11, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s968339895", "group_id": "codeNet:p03826", "input_text": "a,b,c,d=gets.chomp.split(\" \").map(&:to_i)\n\nfirst = a * b\nsecond = c * d\n\nfirst >= second ? print first : print second", "language": "Ruby", "metadata": {"date": 1485557136, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03826.html", "problem_id": "p03826", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03826/input.txt", "sample_output_relpath": "derived/input_output/data/p03826/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03826/Ruby/s968339895.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s968339895", "user_id": "u252403327"}, "prompt_components": {"gold_output": "15\n", "input_to_evaluate": "a,b,c,d=gets.chomp.split(\" \").map(&:to_i)\n\nfirst = a * b\nsecond = c * d\n\nfirst >= second ? print first : print second", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are two rectangles.\nThe lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B.\nThe lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D.\n\nPrint the area of the rectangle with the larger area.\nIf the two rectangles have equal areas, print that area.\n\nConstraints\n\nAll input values are integers.\n\n1≤A≤10^4\n\n1≤B≤10^4\n\n1≤C≤10^4\n\n1≤D≤10^4\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C D\n\nOutput\n\nPrint the area of the rectangle with the larger area.\nIf the two rectangles have equal areas, print that area.\n\nSample Input 1\n\n3 5 2 7\n\nSample Output 1\n\n15\n\nThe first rectangle has an area of 3×5=15, and the second rectangle has an area of 2×7=14.\nThus, the output should be 15, the larger area.\n\nSample Input 2\n\n100 600 200 300\n\nSample Output 2\n\n60000", "sample_input": "3 5 2 7\n"}, "reference_outputs": ["15\n"], "source_document_id": "p03826", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are two rectangles.\nThe lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B.\nThe lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D.\n\nPrint the area of the rectangle with the larger area.\nIf the two rectangles have equal areas, print that area.\n\nConstraints\n\nAll input values are integers.\n\n1≤A≤10^4\n\n1≤B≤10^4\n\n1≤C≤10^4\n\n1≤D≤10^4\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C D\n\nOutput\n\nPrint the area of the rectangle with the larger area.\nIf the two rectangles have equal areas, print that area.\n\nSample Input 1\n\n3 5 2 7\n\nSample Output 1\n\n15\n\nThe first rectangle has an area of 3×5=15, and the second rectangle has an area of 2×7=14.\nThus, the output should be 15, the larger area.\n\nSample Input 2\n\n100 600 200 300\n\nSample Output 2\n\n60000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 117, "cpu_time_ms": 10, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s975509444", "group_id": "codeNet:p03827", "input_text": "n = gets.to_i\ns = gets.strip.split(\"\")\n\nx = 0\nresult = 0\n\nfor var in s\n x += 1 if var == \"I\"\n x -= 1 if var == \"D\"\n result = x if result < x\nend\n\nputs result\n", "language": "Ruby", "metadata": {"date": 1560694552, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03827.html", "problem_id": "p03827", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03827/input.txt", "sample_output_relpath": "derived/input_output/data/p03827/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03827/Ruby/s975509444.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s975509444", "user_id": "u561391668"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n = gets.to_i\ns = gets.strip.split(\"\")\n\nx = 0\nresult = 0\n\nfor var in s\n x += 1 if var == \"I\"\n x -= 1 if var == \"D\"\n result = x if result < x\nend\n\nputs result\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have an integer variable x.\nInitially, x=0.\n\nSome person gave you a string S of length N, and using the string you performed the following operation N times.\nIn the i-th operation, you incremented the value of x by 1 if S_i=I, and decremented the value of x by 1 if S_i=D.\n\nFind the maximum value taken by x during the operations (including before the first operation, and after the last operation).\n\nConstraints\n\n1≤N≤100\n\n|S|=N\n\nNo characters except I and D occur in S.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the maximum value taken by x during the operations.\n\nSample Input 1\n\n5\nIIDID\n\nSample Output 1\n\n2\n\nAfter each operation, the value of x becomes 1, 2, 1, 2 and 1, respectively. Thus, the output should be 2, the maximum value.\n\nSample Input 2\n\n7\nDDIDDII\n\nSample Output 2\n\n0\n\nThe initial value x=0 is the maximum value taken by x, thus the output should be 0.", "sample_input": "5\nIIDID\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03827", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have an integer variable x.\nInitially, x=0.\n\nSome person gave you a string S of length N, and using the string you performed the following operation N times.\nIn the i-th operation, you incremented the value of x by 1 if S_i=I, and decremented the value of x by 1 if S_i=D.\n\nFind the maximum value taken by x during the operations (including before the first operation, and after the last operation).\n\nConstraints\n\n1≤N≤100\n\n|S|=N\n\nNo characters except I and D occur in S.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the maximum value taken by x during the operations.\n\nSample Input 1\n\n5\nIIDID\n\nSample Output 1\n\n2\n\nAfter each operation, the value of x becomes 1, 2, 1, 2 and 1, respectively. Thus, the output should be 2, the maximum value.\n\nSample Input 2\n\n7\nDDIDDII\n\nSample Output 2\n\n0\n\nThe initial value x=0 is the maximum value taken by x, thus the output should be 0.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 167, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s866817068", "group_id": "codeNet:p03828", "input_text": "n = gets.chomp.to_i\nnbang = 1\nn.downto(1){ |v| nbang *= v }\n\nfactors = []\np = 2\n while nbang >= p \n if nbang % p == 0\n nbang /= p\n factors[p] ||= 0\n factors[p] += 1\n else\n p += 1\n end\n end\n\nresult = 1\nfactors.each_with_index do |fac|\n result *= fac + 1 if fac\nend\n\nputs result", "language": "Ruby", "metadata": {"date": 1486687858, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03828.html", "problem_id": "p03828", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03828/input.txt", "sample_output_relpath": "derived/input_output/data/p03828/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03828/Ruby/s866817068.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s866817068", "user_id": "u406810545"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "n = gets.chomp.to_i\nnbang = 1\nn.downto(1){ |v| nbang *= v }\n\nfactors = []\np = 2\n while nbang >= p \n if nbang % p == 0\n nbang /= p\n factors[p] ||= 0\n factors[p] += 1\n else\n p += 1\n end\n end\n\nresult = 1\nfactors.each_with_index do |fac|\n result *= fac + 1 if fac\nend\n\nputs result", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\nFind the number of the positive divisors of N!, modulo 10^9+7.\n\nConstraints\n\n1≤N≤10^3\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the positive divisors of N!, modulo 10^9+7.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n4\n\nThere are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.\n\nSample Input 2\n\n6\n\nSample Output 2\n\n30\n\nSample Input 3\n\n1000\n\nSample Output 3\n\n972926972", "sample_input": "3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03828", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\nFind the number of the positive divisors of N!, modulo 10^9+7.\n\nConstraints\n\n1≤N≤10^3\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the positive divisors of N!, modulo 10^9+7.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n4\n\nThere are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.\n\nSample Input 2\n\n6\n\nSample Output 2\n\n30\n\nSample Input 3\n\n1000\n\nSample Output 3\n\n972926972", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 307, "cpu_time_ms": 24, "memory_kb": 3324}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s081152242", "group_id": "codeNet:p03830", "input_text": "require'prime';s=1;eval(`seq -s* $(dd)`).prime_division.map{s*=_2+1};p s.%10**9+7", "language": "Ruby", "metadata": {"date": 1592655833, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p03830.html", "problem_id": "p03830", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03830/input.txt", "sample_output_relpath": "derived/input_output/data/p03830/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03830/Ruby/s081152242.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s081152242", "user_id": "u657913472"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "require'prime';s=1;eval(`seq -s* $(dd)`).prime_division.map{s*=_2+1};p s.%10**9+7", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\nFind the number of the positive divisors of N!, modulo 10^9+7.\n\nConstraints\n\n1≤N≤10^3\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the positive divisors of N!, modulo 10^9+7.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n4\n\nThere are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.\n\nSample Input 2\n\n6\n\nSample Output 2\n\n30\n\nSample Input 3\n\n1000\n\nSample Output 3\n\n972926972", "sample_input": "3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03830", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\nFind the number of the positive divisors of N!, modulo 10^9+7.\n\nConstraints\n\n1≤N≤10^3\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the positive divisors of N!, modulo 10^9+7.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n4\n\nThere are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.\n\nSample Input 2\n\n6\n\nSample Output 2\n\n30\n\nSample Input 3\n\n1000\n\nSample Output 3\n\n972926972", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 81, "cpu_time_ms": 81, "memory_kb": 16232}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s779657553", "group_id": "codeNet:p03836", "input_text": "$/=' ';a,b,c,d=$<.map &:to_i;x=c-a;y=d-b;puts ?U*y+?R*x+?D*(y+=1)+?L*(x+=1)+?U*y+?R*x+?D+?R+?D*y+?L*x+?U", "language": "Ruby", "metadata": {"date": 1483842382, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03836.html", "problem_id": "p03836", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03836/input.txt", "sample_output_relpath": "derived/input_output/data/p03836/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03836/Ruby/s779657553.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s779657553", "user_id": "u503549962"}, "prompt_components": {"gold_output": "UURDDLLUUURRDRDDDLLU\n", "input_to_evaluate": "$/=' ';a,b,c,d=$<.map &:to_i;x=c-a;y=d-b;puts ?U*y+?R*x+?D*(y+=1)+?L*(x+=1)+?U*y+?R*x+?D+?R+?D*y+?L*x+?U", "problem_context": "Score : 300 points\n\nProblem Statement\n\nDolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.\n\nCurrently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.\n\nHere, both the x- and y-coordinates before and after each movement must be integers.\n\nHe will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).\n\nHere, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).\n\nUnder this condition, find a shortest path for him.\n\nConstraints\n\n-1000 ≤ sx < tx ≤ 1000\n\n-1000 ≤ sy < ty ≤ 1000\n\nsx,sy,tx and ty are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nsx sy tx ty\n\nOutput\n\nPrint a string S that represents a shortest path for Dolphin.\n\nThe i-th character in S should correspond to his i-th movement.\n\nThe directions of the movements should be indicated by the following characters:\n\nU: Up\n\nD: Down\n\nL: Left\n\nR: Right\n\nIf there exist multiple shortest paths under the condition, print any of them.\n\nSample Input 1\n\n0 0 1 2\n\nSample Output 1\n\nUURDDLLUUURRDRDDDLLU\n\nOne possible shortest path is:\n\nGoing from (sx,sy) to (tx,ty) for the first time: (0,0) → (0,1) → (0,2) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the first time: (1,2) → (1,1) → (1,0) → (0,0)\n\nGoing from (sx,sy) to (tx,ty) for the second time: (0,0) → (-1,0) → (-1,1) → (-1,2) → (-1,3) → (0,3) → (1,3) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the second time: (1,2) → (2,2) → (2,1) → (2,0) → (2,-1) → (1,-1) → (0,-1) → (0,0)\n\nSample Input 2\n\n-2 -2 1 1\n\nSample Output 2\n\nUURRURRDDDLLDLLULUUURRURRDDDLLDL", "sample_input": "0 0 1 2\n"}, "reference_outputs": ["UURDDLLUUURRDRDDDLLU\n"], "source_document_id": "p03836", "source_text": "Score : 300 points\n\nProblem Statement\n\nDolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.\n\nCurrently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.\n\nHere, both the x- and y-coordinates before and after each movement must be integers.\n\nHe will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).\n\nHere, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).\n\nUnder this condition, find a shortest path for him.\n\nConstraints\n\n-1000 ≤ sx < tx ≤ 1000\n\n-1000 ≤ sy < ty ≤ 1000\n\nsx,sy,tx and ty are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nsx sy tx ty\n\nOutput\n\nPrint a string S that represents a shortest path for Dolphin.\n\nThe i-th character in S should correspond to his i-th movement.\n\nThe directions of the movements should be indicated by the following characters:\n\nU: Up\n\nD: Down\n\nL: Left\n\nR: Right\n\nIf there exist multiple shortest paths under the condition, print any of them.\n\nSample Input 1\n\n0 0 1 2\n\nSample Output 1\n\nUURDDLLUUURRDRDDDLLU\n\nOne possible shortest path is:\n\nGoing from (sx,sy) to (tx,ty) for the first time: (0,0) → (0,1) → (0,2) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the first time: (1,2) → (1,1) → (1,0) → (0,0)\n\nGoing from (sx,sy) to (tx,ty) for the second time: (0,0) → (-1,0) → (-1,1) → (-1,2) → (-1,3) → (0,3) → (1,3) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the second time: (1,2) → (2,2) → (2,1) → (2,0) → (2,-1) → (1,-1) → (0,-1) → (0,0)\n\nSample Input 2\n\n-2 -2 1 1\n\nSample Output 2\n\nUURRURRDDDLLDLLULUUURRURRDDDLLDL", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 104, "cpu_time_ms": 11, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s143864055", "group_id": "codeNet:p03837", "input_text": "N, M = gets.split.map(&:to_i)\nMAX = 1 << 30\ndist = Array.new(N) { Array.new(N, MAX) }\ngraph = []\nM.times do\n a, b, c = gets.split.map(&:to_i)\n graph << [a-1, b-1, c]\n dist[a - 1][b - 1] = dist[b - 1][a - 1] = c\nend\n\nN.times do |k|\n N.times do |i|\n N.times do |j|\n dist[i][j] = dist[i][k] + dist[k][j] if dist[i][j] > dist[i][k] + dist[k][j]\n end\n end\nend\nans = 0\ngraph.each do |(a,b,c)|\n ans += 1 if dist[a][b] < c\nend\np ans", "language": "Ruby", "metadata": {"date": 1560841653, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03837.html", "problem_id": "p03837", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03837/input.txt", "sample_output_relpath": "derived/input_output/data/p03837/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03837/Ruby/s143864055.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s143864055", "user_id": "u706695185"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N, M = gets.split.map(&:to_i)\nMAX = 1 << 30\ndist = Array.new(N) { Array.new(N, MAX) }\ngraph = []\nM.times do\n a, b, c = gets.split.map(&:to_i)\n graph << [a-1, b-1, c]\n dist[a - 1][b - 1] = dist[b - 1][a - 1] = c\nend\n\nN.times do |k|\n N.times do |i|\n N.times do |j|\n dist[i][j] = dist[i][k] + dist[k][j] if dist[i][j] > dist[i][k] + dist[k][j]\n end\n end\nend\nans = 0\ngraph.each do |(a,b,c)|\n ans += 1 if dist[a][b] < c\nend\np ans", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges.\n\nThe i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i.\n\nHere, a self-loop is an edge where a_i = b_i (1≤i≤M), and double edges are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i= max\n return nil\n end\n\n if head.node_seq[-1]==dest\n return head.node_seq\n end\n\n new_paths = []\n Edges[head.node_seq[-1]].each do |dest2, edge|\n distance, = *edge\n p = Path.new(head.distance + distance, head.node_seq+[dest2])\n new_paths.push(p)\n end\n\n sorted_paths.push(*new_paths)\n sorted_paths.sort_by!(&:distance)\n end\nend\n\n\ncount=0\nEdges.keys.sort.each do |src|\n Edges[src].keys.sort.each do |dst|\n if src<=dst then\n break\n end\n\n e = Edges[src][dst]\n if find_a_path_leq(src, dst, e[0])\n count += 1\n end\n end\nend\n\nputs count\n\n\n", "language": "Ruby", "metadata": {"date": 1559833771, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03837.html", "problem_id": "p03837", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03837/input.txt", "sample_output_relpath": "derived/input_output/data/p03837/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03837/Ruby/s799976273.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s799976273", "user_id": "u565487528"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "N, M = readline.split(' ').map(&:to_i)\nEdges = Hash.new {|h,k| h[k]=Hash.new }\n\nM.times do |idx|\n n1, n2, dist = readline.split(' ').map(&:to_i)\n Edges[n1-1][n2-1] = [dist, idx]\n Edges[n2-1][n1-1] = [dist, idx]\nend\n\nclass Path\n attr_reader :distance, :node_seq\n def initialize(distance, node_seq)\n @distance = distance\n @node_seq = node_seq\n end\nend\n\ndef find_a_path_leq(src, dest, max)\n sorted_paths = [Path.new(0, [src])] # sorted_paths: [Path] sorted by Path.distance\n\n while head = sorted_paths.shift\n if head.distance >= max\n return nil\n end\n\n if head.node_seq[-1]==dest\n return head.node_seq\n end\n\n new_paths = []\n Edges[head.node_seq[-1]].each do |dest2, edge|\n distance, = *edge\n p = Path.new(head.distance + distance, head.node_seq+[dest2])\n new_paths.push(p)\n end\n\n sorted_paths.push(*new_paths)\n sorted_paths.sort_by!(&:distance)\n end\nend\n\n\ncount=0\nEdges.keys.sort.each do |src|\n Edges[src].keys.sort.each do |dst|\n if src<=dst then\n break\n end\n\n e = Edges[src][dst]\n if find_a_path_leq(src, dst, e[0])\n count += 1\n end\n end\nend\n\nputs count\n\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges.\n\nThe i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i.\n\nHere, a self-loop is an edge where a_i = b_i (1≤i≤M), and double edges are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i cost\n used[i][k] = used[k][i] = true\n used[j][k] = used[k][j] = true\n used[i][j] = used[j][i] = false\n dist[i][j] = cost\n end\n end\n end\n end\n\n used\n end\nend\n\nN, M = gets.split.map(&:to_i)\ngraph = Array.new(N) { Array.new(N, Float::INFINITY) }\n\nN.times do |i|\n graph[i][i] = 0\nend\n\nedges = M.times.map { gets.split.map(&:to_i) }\n\nedges.each do |a, b, c|\n graph[a - 1][b - 1] = c\n graph[b - 1][a - 1] = c\nend\n\nused = graph.warshall_floyd\n\nans = 0\n\nputs edges.count { |a, b, _| !used[a - 1][b - 1] }\n\n", "language": "Ruby", "metadata": {"date": 1553674013, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03837.html", "problem_id": "p03837", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03837/input.txt", "sample_output_relpath": "derived/input_output/data/p03837/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03837/Ruby/s142766259.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s142766259", "user_id": "u740836226"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "class Array\n def warshall_floyd\n v = size\n\n used = Array.new(v) { Array.new(v, false) }\n dist = map(&:dup)\n\n v.times do |k|\n v.times do |i|\n v.times do |j|\n cost = dist[i][k] + dist[k][j]\n\n if dist[i][j] > cost\n used[i][k] = used[k][i] = true\n used[j][k] = used[k][j] = true\n used[i][j] = used[j][i] = false\n dist[i][j] = cost\n end\n end\n end\n end\n\n used\n end\nend\n\nN, M = gets.split.map(&:to_i)\ngraph = Array.new(N) { Array.new(N, Float::INFINITY) }\n\nN.times do |i|\n graph[i][i] = 0\nend\n\nedges = M.times.map { gets.split.map(&:to_i) }\n\nedges.each do |a, b, c|\n graph[a - 1][b - 1] = c\n graph[b - 1][a - 1] = c\nend\n\nused = graph.warshall_floyd\n\nans = 0\n\nputs edges.count { |a, b, _| !used[a - 1][b - 1] }\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges.\n\nThe i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i.\n\nHere, a self-loop is an edge where a_i = b_i (1≤i≤M), and double edges are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i x.to_i\n a_arr[i + 1] -= 1\n count += 1\n end\nend\n\nputs count\n", "language": "Ruby", "metadata": {"date": 1480905758, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03862.html", "problem_id": "p03862", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03862/input.txt", "sample_output_relpath": "derived/input_output/data/p03862/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03862/Ruby/s467194321.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s467194321", "user_id": "u083761263"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "n, x = gets.chomp.split\na_arr = gets.chomp.split.map {|i| i.to_i}.insert(0, 0)\n\nif x.to_i == 0\n puts a_arr.inject {|mem, i| mem + i.to_i}\n return\nend\n\ncount = 0\n\na_arr.each_with_index do |item, i|\n next if i == 0 || i == a_arr.size - 1\n while item + a_arr[i + 1] > x.to_i\n a_arr[i + 1] -= 1\n count += 1\n end\nend\n\nputs count\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N boxes arranged in a row.\nInitially, the i-th box from the left contains a_i candies.\n\nSnuke can perform the following operation any number of times:\n\nChoose a box containing at least one candy, and eat one of the candies in the chosen box.\n\nHis objective is as follows:\n\nAny two neighboring boxes contain at most x candies in total.\n\nFind the minimum number of operations required to achieve the objective.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n0 ≤ a_i ≤ 10^9\n\n0 ≤ x ≤ 10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of operations required to achieve the objective.\n\nSample Input 1\n\n3 3\n2 2 2\n\nSample Output 1\n\n1\n\nEat one candy in the second box.\nThen, the number of candies in each box becomes (2, 1, 2).\n\nSample Input 2\n\n6 1\n1 6 1 2 0 4\n\nSample Output 2\n\n11\n\nFor example, eat six candies in the second box, two in the fourth box, and three in the sixth box.\nThen, the number of candies in each box becomes (1, 0, 1, 0, 0, 1).\n\nSample Input 3\n\n5 9\n3 1 4 1 5\n\nSample Output 3\n\n0\n\nThe objective is already achieved without performing operations.\n\nSample Input 4\n\n2 0\n5 5\n\nSample Output 4\n\n10\n\nAll the candies need to be eaten.", "sample_input": "3 3\n2 2 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03862", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N boxes arranged in a row.\nInitially, the i-th box from the left contains a_i candies.\n\nSnuke can perform the following operation any number of times:\n\nChoose a box containing at least one candy, and eat one of the candies in the chosen box.\n\nHis objective is as follows:\n\nAny two neighboring boxes contain at most x candies in total.\n\nFind the minimum number of operations required to achieve the objective.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n0 ≤ a_i ≤ 10^9\n\n0 ≤ x ≤ 10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of operations required to achieve the objective.\n\nSample Input 1\n\n3 3\n2 2 2\n\nSample Output 1\n\n1\n\nEat one candy in the second box.\nThen, the number of candies in each box becomes (2, 1, 2).\n\nSample Input 2\n\n6 1\n1 6 1 2 0 4\n\nSample Output 2\n\n11\n\nFor example, eat six candies in the second box, two in the fourth box, and three in the sixth box.\nThen, the number of candies in each box becomes (1, 0, 1, 0, 0, 1).\n\nSample Input 3\n\n5 9\n3 1 4 1 5\n\nSample Output 3\n\n0\n\nThe objective is already achieved without performing operations.\n\nSample Input 4\n\n2 0\n5 5\n\nSample Output 4\n\n10\n\nAll the candies need to be eaten.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 335, "cpu_time_ms": 2103, "memory_kb": 9612}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s585793810", "group_id": "codeNet:p03897", "input_text": "M=eval *$<\n(M%2.step(M-=1,3){|i|(i%2).step(M-1,2){$*<= xl\n elsif a == 2\n xr = x if x <= xr\n elsif a == 3\n yl = y if y > yl\n else\n yh = y if y < yh\n end\nend\n\nans = (yh-yl) * (xr - xl)\nif yh -yl > 0 && xr - xl > 0\n puts ans\nelse\n puts 0\nend", "language": "Ruby", "metadata": {"date": 1589347145, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03944.html", "problem_id": "p03944", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03944/input.txt", "sample_output_relpath": "derived/input_output/data/p03944/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03944/Ruby/s598601835.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s598601835", "user_id": "u437368899"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "w,h,n = gets.split.map(&:to_i)\nxl = 0\nxr = w\nyl = 0\nyh = h\nn.times do\n x,y,a = gets.split.map(&:to_i)\n if a == 1\n xl = x if x >= xl\n elsif a == 2\n xr = x if x <= xr\n elsif a == 3\n yl = y if y > yl\n else\n yh = y if y < yh\n end\nend\n\nans = (yh-yl) * (xr - xl)\nif yh -yl > 0 && xr - xl > 0\n puts ans\nelse\n puts 0\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.\n\nSnuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).\n\nThen, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:\n\nIf a_i = 1, he painted the region satisfying x < x_i within the rectangle.\n\nIf a_i = 2, he painted the region satisfying x > x_i within the rectangle.\n\nIf a_i = 3, he painted the region satisfying y < y_i within the rectangle.\n\nIf a_i = 4, he painted the region satisfying y > y_i within the rectangle.\n\nFind the area of the white region within the rectangle after he finished painting.\n\nConstraints\n\n1 ≦ W, H ≦ 100\n\n1 ≦ N ≦ 100\n\n0 ≦ x_i ≦ W (1 ≦ i ≦ N)\n\n0 ≦ y_i ≦ H (1 ≦ i ≦ N)\n\nW, H (21:32, added), x_i and y_i are integers.\n\na_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nW H N\nx_1 y_1 a_1\nx_2 y_2 a_2\n:\nx_N y_N a_N\n\nOutput\n\nPrint the area of the white region within the rectangle after Snuke finished painting.\n\nSample Input 1\n\n5 4 2\n2 1 1\n3 3 4\n\nSample Output 1\n\n9\n\nThe figure below shows the rectangle before Snuke starts painting.\n\nFirst, as (x_1, y_1) = (2, 1) and a_1 = 1, he paints the region satisfying x < 2 within the rectangle:\n\nThen, as (x_2, y_2) = (3, 3) and a_2 = 4, he paints the region satisfying y > 3 within the rectangle:\n\nNow, the area of the white region within the rectangle is 9.\n\nSample Input 2\n\n5 4 3\n2 1 1\n3 3 4\n1 4 2\n\nSample Output 2\n\n0\n\nIt is possible that the whole region within the rectangle is painted black.\n\nSample Input 3\n\n10 10 5\n1 6 1\n4 1 3\n6 9 4\n9 4 2\n3 1 3\n\nSample Output 3\n\n64", "sample_input": "5 4 2\n2 1 1\n3 3 4\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03944", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.\n\nSnuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).\n\nThen, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:\n\nIf a_i = 1, he painted the region satisfying x < x_i within the rectangle.\n\nIf a_i = 2, he painted the region satisfying x > x_i within the rectangle.\n\nIf a_i = 3, he painted the region satisfying y < y_i within the rectangle.\n\nIf a_i = 4, he painted the region satisfying y > y_i within the rectangle.\n\nFind the area of the white region within the rectangle after he finished painting.\n\nConstraints\n\n1 ≦ W, H ≦ 100\n\n1 ≦ N ≦ 100\n\n0 ≦ x_i ≦ W (1 ≦ i ≦ N)\n\n0 ≦ y_i ≦ H (1 ≦ i ≦ N)\n\nW, H (21:32, added), x_i and y_i are integers.\n\na_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nW H N\nx_1 y_1 a_1\nx_2 y_2 a_2\n:\nx_N y_N a_N\n\nOutput\n\nPrint the area of the white region within the rectangle after Snuke finished painting.\n\nSample Input 1\n\n5 4 2\n2 1 1\n3 3 4\n\nSample Output 1\n\n9\n\nThe figure below shows the rectangle before Snuke starts painting.\n\nFirst, as (x_1, y_1) = (2, 1) and a_1 = 1, he paints the region satisfying x < 2 within the rectangle:\n\nThen, as (x_2, y_2) = (3, 3) and a_2 = 4, he paints the region satisfying y > 3 within the rectangle:\n\nNow, the area of the white region within the rectangle is 9.\n\nSample Input 2\n\n5 4 3\n2 1 1\n3 3 4\n1 4 2\n\nSample Output 2\n\n0\n\nIt is possible that the whole region within the rectangle is painted black.\n\nSample Input 3\n\n10 10 5\n1 6 1\n4 1 3\n6 9 4\n9 4 2\n3 1 3\n\nSample Output 3\n\n64", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 332, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s732536343", "group_id": "codeNet:p03947", "input_text": "S=gets.chomp.chars\nputs S.chunk{ |e| e }.to_a.length - 1\n\n\n\n", "language": "Ruby", "metadata": {"date": 1591139586, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03947.html", "problem_id": "p03947", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03947/input.txt", "sample_output_relpath": "derived/input_output/data/p03947/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03947/Ruby/s732536343.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s732536343", "user_id": "u852974293"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "S=gets.chomp.chars\nputs S.chunk{ |e| e }.to_a.length - 1\n\n\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTwo foxes Jiro and Saburo are playing a game called 1D Reversi. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones between the new white stone and another white stone, turn into white stones, and vice versa.\n\nIn the middle of a game, something came up and Saburo has to leave the game. The state of the board at this point is described by a string S. There are |S| (the length of S) stones on the board, and each character in S represents the color of the i-th (1 ≦ i ≦ |S|) stone from the left. If the i-th character in S is B, it means that the color of the corresponding stone on the board is black. Similarly, if the i-th character in S is W, it means that the color of the corresponding stone is white.\n\nJiro wants all stones on the board to be of the same color. For this purpose, he will place new stones on the board according to the rules. Find the minimum number of new stones that he needs to place.\n\nConstraints\n\n1 ≦ |S| ≦ 10^5\n\nEach character in S is B or W.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of new stones that Jiro needs to place for his purpose.\n\nSample Input 1\n\nBBBWW\n\nSample Output 1\n\n1\n\nBy placing a new black stone to the right end of the row of stones, all white stones will become black. Also, by placing a new white stone to the left end of the row of stones, all black stones will become white.\n\nIn either way, Jiro's purpose can be achieved by placing one stone.\n\nSample Input 2\n\nWWWWWW\n\nSample Output 2\n\n0\n\nIf all stones are already of the same color, no new stone is necessary.\n\nSample Input 3\n\nWBWBWBWBWB\n\nSample Output 3\n\n9", "sample_input": "BBBWW\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03947", "source_text": "Score : 300 points\n\nProblem Statement\n\nTwo foxes Jiro and Saburo are playing a game called 1D Reversi. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones between the new white stone and another white stone, turn into white stones, and vice versa.\n\nIn the middle of a game, something came up and Saburo has to leave the game. The state of the board at this point is described by a string S. There are |S| (the length of S) stones on the board, and each character in S represents the color of the i-th (1 ≦ i ≦ |S|) stone from the left. If the i-th character in S is B, it means that the color of the corresponding stone on the board is black. Similarly, if the i-th character in S is W, it means that the color of the corresponding stone is white.\n\nJiro wants all stones on the board to be of the same color. For this purpose, he will place new stones on the board according to the rules. Find the minimum number of new stones that he needs to place.\n\nConstraints\n\n1 ≦ |S| ≦ 10^5\n\nEach character in S is B or W.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of new stones that Jiro needs to place for his purpose.\n\nSample Input 1\n\nBBBWW\n\nSample Output 1\n\n1\n\nBy placing a new black stone to the right end of the row of stones, all white stones will become black. Also, by placing a new white stone to the left end of the row of stones, all black stones will become white.\n\nIn either way, Jiro's purpose can be achieved by placing one stone.\n\nSample Input 2\n\nWWWWWW\n\nSample Output 2\n\n0\n\nIf all stones are already of the same color, no new stone is necessary.\n\nSample Input 3\n\nWBWBWBWBWB\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": 60, "cpu_time_ms": 108, "memory_kb": 16380}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s372992598", "group_id": "codeNet:p03949", "input_text": "n=gets.to_i\nha=[[]]*n\n(n-1).times do\n g=gets.split.map{|i|i.to_i-1}\n 2.times do |i|\n ha[g[i]]+=[g[(i+1)%2]]\n end\nend\nm=gets.to_i\nhb=[]\nhc=[nil]*n\nm.times do\n x,y=gets.split.map(&:to_i)\n hb<< [x-1,y]\n hc[x-1]=y\nend\nhb=hb.sort{|x,y|x[1]<=>y[1]}\nst=[]\nnow=hb[-1][1]\nj=true\nwhile hb!=[] || st!=[] do\n if st==[]\n g=hb.pop\n else\n g=st.pop\n end\n ha[g[0]].each do |e|\n if hc[e]\n if hc[e]!=now+1\n j=false\n break\n end\n else\n hc[e]=now-1\n st<< [e,now-1]\n end\n end\nend\nputs j ? :Yes : :No\nputs hc.*(\"\\n\") if j", "language": "Ruby", "metadata": {"date": 1478492410, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03949.html", "problem_id": "p03949", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03949/input.txt", "sample_output_relpath": "derived/input_output/data/p03949/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03949/Ruby/s372992598.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s372992598", "user_id": "u554838392"}, "prompt_components": {"gold_output": "Yes\n5\n6\n6\n5\n7\n", "input_to_evaluate": "n=gets.to_i\nha=[[]]*n\n(n-1).times do\n g=gets.split.map{|i|i.to_i-1}\n 2.times do |i|\n ha[g[i]]+=[g[(i+1)%2]]\n end\nend\nm=gets.to_i\nhb=[]\nhc=[nil]*n\nm.times do\n x,y=gets.split.map(&:to_i)\n hb<< [x-1,y]\n hc[x-1]=y\nend\nhb=hb.sort{|x,y|x[1]<=>y[1]}\nst=[]\nnow=hb[-1][1]\nj=true\nwhile hb!=[] || st!=[] do\n if st==[]\n g=hb.pop\n else\n g=st.pop\n end\n ha[g[0]].each do |e|\n if hc[e]\n if hc[e]!=now+1\n j=false\n break\n end\n else\n hc[e]=now-1\n st<< [e,now-1]\n end\n end\nend\nputs j ? :Yes : :No\nputs hc.*(\"\\n\") if j", "problem_context": "Score : 800 points\n\nProblem Statement\n\nWe have a tree with N vertices. The vertices are numbered 1, 2, ..., N. The i-th (1 ≦ i ≦ N - 1) edge connects the two vertices A_i and B_i.\n\nTakahashi wrote integers into K of the vertices. Specifically, for each 1 ≦ j ≦ K, he wrote the integer P_j into vertex V_j. The remaining vertices are left empty. After that, he got tired and fell asleep.\n\nThen, Aoki appeared. He is trying to surprise Takahashi by writing integers into all empty vertices so that the following condition is satisfied:\n\nCondition: For any two vertices directly connected by an edge, the integers written into these vertices differ by exactly 1.\n\nDetermine if it is possible to write integers into all empty vertices so that the condition is satisfied. If the answer is positive, find one specific way to satisfy the condition.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n1 ≦ K ≦ N\n\n1 ≦ A_i, B_i ≦ N (1 ≦ i ≦ N - 1)\n\n1 ≦ V_j ≦ N (1 ≦ j ≦ K) (21:18, a mistake in this constraint was corrected)\n\n0 ≦ P_j ≦ 10^5 (1 ≦ j ≦ K)\n\nThe given graph is a tree.\n\nAll v_j are distinct.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 B_1\nA_2 B_2\n:\nA_{N-1} B_{N-1}\nK\nV_1 P_1\nV_2 P_2\n:\nV_K P_K\n\nOutput\n\nIf it is possible to write integers into all empty vertices so that the condition is satisfied, print Yes. Otherwise, print No.\n\nIf it is possible to satisfy the condition, print N lines in addition. The v-th (1 ≦ v ≦ N) of these N lines should contain the integer that should be written into vertex v. If there are multiple ways to satisfy the condition, any of those is accepted.\n\nSample Input 1\n\n5\n1 2\n3 1\n4 3\n3 5\n2\n2 6\n5 7\n\nSample Output 1\n\nYes\n5\n6\n6\n5\n7\n\nThe figure below shows the tree when Takahashi fell asleep. For each vertex, the integer written beside it represents the index of the vertex, and the integer written into the vertex is the integer written by Takahashi.\n\nAoki can, for example, satisfy the condition by writing integers into the remaining vertices as follows:\n\nThis corresponds to Sample Output 1. Note that other outputs that satisfy the condition will also be accepted, such as:\n\nYes\n7\n6\n8\n7\n7\n\nSample Input 2\n\n5\n1 2\n3 1\n4 3\n3 5\n3\n2 6\n4 3\n5 7\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n4\n1 2\n2 3\n3 4\n1\n1 0\n\nSample Output 3\n\nYes\n0\n-1\n-2\n-3\n\nThe integers written by Aoki may be negative or exceed 10^6.", "sample_input": "5\n1 2\n3 1\n4 3\n3 5\n2\n2 6\n5 7\n"}, "reference_outputs": ["Yes\n5\n6\n6\n5\n7\n"], "source_document_id": "p03949", "source_text": "Score : 800 points\n\nProblem Statement\n\nWe have a tree with N vertices. The vertices are numbered 1, 2, ..., N. The i-th (1 ≦ i ≦ N - 1) edge connects the two vertices A_i and B_i.\n\nTakahashi wrote integers into K of the vertices. Specifically, for each 1 ≦ j ≦ K, he wrote the integer P_j into vertex V_j. The remaining vertices are left empty. After that, he got tired and fell asleep.\n\nThen, Aoki appeared. He is trying to surprise Takahashi by writing integers into all empty vertices so that the following condition is satisfied:\n\nCondition: For any two vertices directly connected by an edge, the integers written into these vertices differ by exactly 1.\n\nDetermine if it is possible to write integers into all empty vertices so that the condition is satisfied. If the answer is positive, find one specific way to satisfy the condition.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n1 ≦ K ≦ N\n\n1 ≦ A_i, B_i ≦ N (1 ≦ i ≦ N - 1)\n\n1 ≦ V_j ≦ N (1 ≦ j ≦ K) (21:18, a mistake in this constraint was corrected)\n\n0 ≦ P_j ≦ 10^5 (1 ≦ j ≦ K)\n\nThe given graph is a tree.\n\nAll v_j are distinct.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 B_1\nA_2 B_2\n:\nA_{N-1} B_{N-1}\nK\nV_1 P_1\nV_2 P_2\n:\nV_K P_K\n\nOutput\n\nIf it is possible to write integers into all empty vertices so that the condition is satisfied, print Yes. Otherwise, print No.\n\nIf it is possible to satisfy the condition, print N lines in addition. The v-th (1 ≦ v ≦ N) of these N lines should contain the integer that should be written into vertex v. If there are multiple ways to satisfy the condition, any of those is accepted.\n\nSample Input 1\n\n5\n1 2\n3 1\n4 3\n3 5\n2\n2 6\n5 7\n\nSample Output 1\n\nYes\n5\n6\n6\n5\n7\n\nThe figure below shows the tree when Takahashi fell asleep. For each vertex, the integer written beside it represents the index of the vertex, and the integer written into the vertex is the integer written by Takahashi.\n\nAoki can, for example, satisfy the condition by writing integers into the remaining vertices as follows:\n\nThis corresponds to Sample Output 1. Note that other outputs that satisfy the condition will also be accepted, such as:\n\nYes\n7\n6\n8\n7\n7\n\nSample Input 2\n\n5\n1 2\n3 1\n4 3\n3 5\n3\n2 6\n4 3\n5 7\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n4\n1 2\n2 3\n3 4\n1\n1 0\n\nSample Output 3\n\nYes\n0\n-1\n-2\n-3\n\nThe integers written by Aoki may be negative or exceed 10^6.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 562, "cpu_time_ms": 2110, "memory_kb": 148468}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s482623562", "group_id": "codeNet:p03962", "input_text": "p gets.split(\" \").uniq.length", "language": "Ruby", "metadata": {"date": 1590547361, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03962.html", "problem_id": "p03962", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03962/input.txt", "sample_output_relpath": "derived/input_output/data/p03962/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03962/Ruby/s482623562.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s482623562", "user_id": "u122428774"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "p gets.split(\" \").uniq.length", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer the deer recently bought three paint cans.\nThe color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c.\nHere, the color of each paint can is represented by an integer between 1 and 100, inclusive.\n\nSince he is forgetful, he might have bought more than one paint can in the same color.\nCount the number of different kinds of colors of these paint cans and tell him.\n\nConstraints\n\n1≦a,b,c≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the number of different kinds of colors of the paint cans.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n3\n\nThree different colors: 1, 3, and 4.\n\nSample Input 2\n\n3 3 33\n\nSample Output 2\n\n2\n\nTwo different colors: 3 and 33.", "sample_input": "3 1 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03962", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer the deer recently bought three paint cans.\nThe color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c.\nHere, the color of each paint can is represented by an integer between 1 and 100, inclusive.\n\nSince he is forgetful, he might have bought more than one paint can in the same color.\nCount the number of different kinds of colors of these paint cans and tell him.\n\nConstraints\n\n1≦a,b,c≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the number of different kinds of colors of the paint cans.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n3\n\nThree different colors: 1, 3, and 4.\n\nSample Input 2\n\n3 3 33\n\nSample Output 2\n\n2\n\nTwo different colors: 3 and 33.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 29, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s842783607", "group_id": "codeNet:p03962", "input_text": "p gets.split.map(&:to_i).uniq.length", "language": "Ruby", "metadata": {"date": 1517440265, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03962.html", "problem_id": "p03962", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03962/input.txt", "sample_output_relpath": "derived/input_output/data/p03962/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03962/Ruby/s842783607.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s842783607", "user_id": "u083707708"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "p gets.split.map(&:to_i).uniq.length", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer the deer recently bought three paint cans.\nThe color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c.\nHere, the color of each paint can is represented by an integer between 1 and 100, inclusive.\n\nSince he is forgetful, he might have bought more than one paint can in the same color.\nCount the number of different kinds of colors of these paint cans and tell him.\n\nConstraints\n\n1≦a,b,c≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the number of different kinds of colors of the paint cans.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n3\n\nThree different colors: 1, 3, and 4.\n\nSample Input 2\n\n3 3 33\n\nSample Output 2\n\n2\n\nTwo different colors: 3 and 33.", "sample_input": "3 1 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03962", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer the deer recently bought three paint cans.\nThe color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c.\nHere, the color of each paint can is represented by an integer between 1 and 100, inclusive.\n\nSince he is forgetful, he might have bought more than one paint can in the same color.\nCount the number of different kinds of colors of these paint cans and tell him.\n\nConstraints\n\n1≦a,b,c≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the number of different kinds of colors of the paint cans.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n3\n\nThree different colors: 1, 3, and 4.\n\nSample Input 2\n\n3 3 33\n\nSample Output 2\n\n2\n\nTwo different colors: 3 and 33.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 36, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s027172039", "group_id": "codeNet:p03964", "input_text": "n = gets.to_i\ntakahashi = 1\naoki = 1\n\nn.times do\n t, a = gets.split.map(&:to_i)\n i = [takahashi.to_f / t, aoki.to_f / a].max.ceil\n takahashi = t * i\n aoki = a * i\nend\n\nputs takahashi + aoki", "language": "Ruby", "metadata": {"date": 1566772611, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03964.html", "problem_id": "p03964", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03964/input.txt", "sample_output_relpath": "derived/input_output/data/p03964/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03964/Ruby/s027172039.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s027172039", "user_id": "u738725371"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "n = gets.to_i\ntakahashi = 1\naoki = 1\n\nn.times do\n t, a = gets.split.map(&:to_i)\n i = [takahashi.to_f / t, aoki.to_f / a].max.ceil\n takahashi = t * i\n aoki = a * i\nend\n\nputs takahashi + aoki", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is seeing a quick report of election results on TV.\nTwo candidates are standing for the election: Takahashi and Aoki.\nThe report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes.\nAtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i.\nIt is known that each candidate had at least one vote when he checked the report for the first time.\n\nFind the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time.\nIt can be assumed that the number of votes obtained by each candidate never decreases.\n\nConstraints\n\n1≦N≦1000\n\n1≦T_i,A_i≦1000 (1≦i≦N)\n\nT_i and A_i (1≦i≦N) are coprime.\n\nIt is guaranteed that the correct answer is at most 10^{18}.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 A_1\nT_2 A_2\n:\nT_N A_N\n\nOutput\n\nPrint the minimum possible total number of votes obtained by Takahashi and Aoki when AtCoDeer checked the report for the N-th time.\n\nSample Input 1\n\n3\n2 3\n1 1\n3 2\n\nSample Output 1\n\n10\n\nWhen the numbers of votes obtained by the two candidates change as 2,3 → 3,3 → 6,4, the total number of votes at the end is 10, which is the minimum possible number.\n\nSample Input 2\n\n4\n1 1\n1 1\n1 5\n1 100\n\nSample Output 2\n\n101\n\nIt is possible that neither candidate obtained a vote between the moment when he checked the report, and the moment when he checked it for the next time.\n\nSample Input 3\n\n5\n3 10\n48 17\n31 199\n231 23\n3 2\n\nSample Output 3\n\n6930", "sample_input": "3\n2 3\n1 1\n3 2\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03964", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is seeing a quick report of election results on TV.\nTwo candidates are standing for the election: Takahashi and Aoki.\nThe report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes.\nAtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i.\nIt is known that each candidate had at least one vote when he checked the report for the first time.\n\nFind the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time.\nIt can be assumed that the number of votes obtained by each candidate never decreases.\n\nConstraints\n\n1≦N≦1000\n\n1≦T_i,A_i≦1000 (1≦i≦N)\n\nT_i and A_i (1≦i≦N) are coprime.\n\nIt is guaranteed that the correct answer is at most 10^{18}.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 A_1\nT_2 A_2\n:\nT_N A_N\n\nOutput\n\nPrint the minimum possible total number of votes obtained by Takahashi and Aoki when AtCoDeer checked the report for the N-th time.\n\nSample Input 1\n\n3\n2 3\n1 1\n3 2\n\nSample Output 1\n\n10\n\nWhen the numbers of votes obtained by the two candidates change as 2,3 → 3,3 → 6,4, the total number of votes at the end is 10, which is the minimum possible number.\n\nSample Input 2\n\n4\n1 1\n1 1\n1 5\n1 100\n\nSample Output 2\n\n101\n\nIt is possible that neither candidate obtained a vote between the moment when he checked the report, and the moment when he checked it for the next time.\n\nSample Input 3\n\n5\n3 10\n48 17\n31 199\n231 23\n3 2\n\nSample Output 3\n\n6930", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 193, "cpu_time_ms": 10, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s732901074", "group_id": "codeNet:p03964", "input_text": " n = gets.chomp.to_i\n a = Array.new(n)\n b = Array.new(n)\n \n n.times{|i|\n a[i],b[i] = gets.chomp.split(\" \").map!(&:to_f)\n }\n am = a[0]\n bm = b[0]\n n.times{|i|\n j = (am /a[i]).ceil\n w = (bm /b[i]).ceil\n am = a[i]*([j, w].max)\n bm = b[i]*([j, w].max)\n puts w ,j\n }\n puts (am + bm).to_i", "language": "Ruby", "metadata": {"date": 1480462964, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03964.html", "problem_id": "p03964", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03964/input.txt", "sample_output_relpath": "derived/input_output/data/p03964/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03964/Ruby/s732901074.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s732901074", "user_id": "u145123922"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": " n = gets.chomp.to_i\n a = Array.new(n)\n b = Array.new(n)\n \n n.times{|i|\n a[i],b[i] = gets.chomp.split(\" \").map!(&:to_f)\n }\n am = a[0]\n bm = b[0]\n n.times{|i|\n j = (am /a[i]).ceil\n w = (bm /b[i]).ceil\n am = a[i]*([j, w].max)\n bm = b[i]*([j, w].max)\n puts w ,j\n }\n puts (am + bm).to_i", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is seeing a quick report of election results on TV.\nTwo candidates are standing for the election: Takahashi and Aoki.\nThe report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes.\nAtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i.\nIt is known that each candidate had at least one vote when he checked the report for the first time.\n\nFind the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time.\nIt can be assumed that the number of votes obtained by each candidate never decreases.\n\nConstraints\n\n1≦N≦1000\n\n1≦T_i,A_i≦1000 (1≦i≦N)\n\nT_i and A_i (1≦i≦N) are coprime.\n\nIt is guaranteed that the correct answer is at most 10^{18}.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 A_1\nT_2 A_2\n:\nT_N A_N\n\nOutput\n\nPrint the minimum possible total number of votes obtained by Takahashi and Aoki when AtCoDeer checked the report for the N-th time.\n\nSample Input 1\n\n3\n2 3\n1 1\n3 2\n\nSample Output 1\n\n10\n\nWhen the numbers of votes obtained by the two candidates change as 2,3 → 3,3 → 6,4, the total number of votes at the end is 10, which is the minimum possible number.\n\nSample Input 2\n\n4\n1 1\n1 1\n1 5\n1 100\n\nSample Output 2\n\n101\n\nIt is possible that neither candidate obtained a vote between the moment when he checked the report, and the moment when he checked it for the next time.\n\nSample Input 3\n\n5\n3 10\n48 17\n31 199\n231 23\n3 2\n\nSample Output 3\n\n6930", "sample_input": "3\n2 3\n1 1\n3 2\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03964", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is seeing a quick report of election results on TV.\nTwo candidates are standing for the election: Takahashi and Aoki.\nThe report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes.\nAtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i.\nIt is known that each candidate had at least one vote when he checked the report for the first time.\n\nFind the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time.\nIt can be assumed that the number of votes obtained by each candidate never decreases.\n\nConstraints\n\n1≦N≦1000\n\n1≦T_i,A_i≦1000 (1≦i≦N)\n\nT_i and A_i (1≦i≦N) are coprime.\n\nIt is guaranteed that the correct answer is at most 10^{18}.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 A_1\nT_2 A_2\n:\nT_N A_N\n\nOutput\n\nPrint the minimum possible total number of votes obtained by Takahashi and Aoki when AtCoDeer checked the report for the N-th time.\n\nSample Input 1\n\n3\n2 3\n1 1\n3 2\n\nSample Output 1\n\n10\n\nWhen the numbers of votes obtained by the two candidates change as 2,3 → 3,3 → 6,4, the total number of votes at the end is 10, which is the minimum possible number.\n\nSample Input 2\n\n4\n1 1\n1 1\n1 5\n1 100\n\nSample Output 2\n\n101\n\nIt is possible that neither candidate obtained a vote between the moment when he checked the report, and the moment when he checked it for the next time.\n\nSample Input 3\n\n5\n3 10\n48 17\n31 199\n231 23\n3 2\n\nSample Output 3\n\n6930", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 359, "cpu_time_ms": 16, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s926574725", "group_id": "codeNet:p03965", "input_text": "a = gets.chomp\nans = 0\ngu = 0\na.size.times do |i|\n if (gu == 0)\n gu += 1\n ans -= 1 if a[i] == \"p\"\n else\n if(a[i] == \"g\")\n ans += 1\n gu -= 1\n else\n gu -= 1\n end\n end \nend\nputs ans", "language": "Ruby", "metadata": {"date": 1483675909, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03965.html", "problem_id": "p03965", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03965/input.txt", "sample_output_relpath": "derived/input_output/data/p03965/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03965/Ruby/s926574725.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s926574725", "user_id": "u145123922"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "a = gets.chomp\nans = 0\ngu = 0\na.size.times do |i|\n if (gu == 0)\n gu += 1\n ans -= 1 if a[i] == \"p\"\n else\n if(a[i] == \"g\")\n ans += 1\n gu -= 1\n else\n gu -= 1\n end\n end \nend\nputs ans", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer and his friend TopCoDeer is playing a game.\nThe game consists of N turns.\nIn each turn, each player plays one of the two gestures, Rock and Paper, as in Rock-paper-scissors, under the following condition:\n\n(※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock).\n\nEach player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors.\n\n(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)\n\nWith his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts.\nPlan AtCoDeer's gesture in each turn to maximize AtCoDeer's score.\n\nThe gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is g, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in p, TopCoDeer will play Paper in the i-th turn.\n\nConstraints\n\n1≦N≦10^5\n\nN=|s|\n\nEach character in s is g or p.\n\nThe gestures represented by s satisfy the condition (※).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the AtCoDeer's maximum possible score.\n\nSample Input 1\n\ngpg\n\nSample Output 1\n\n0\n\nPlaying the same gesture as the opponent in each turn results in the score of 0, which is the maximum possible score.\n\nSample Input 2\n\nggppgggpgg\n\nSample Output 2\n\n2\n\nFor example, consider playing gestures in the following order: Rock, Paper, Rock, Paper, Rock, Rock, Paper, Paper, Rock, Paper. This strategy earns three victories and suffers one defeat, resulting in the score of 2, which is the maximum possible score.", "sample_input": "gpg\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03965", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer and his friend TopCoDeer is playing a game.\nThe game consists of N turns.\nIn each turn, each player plays one of the two gestures, Rock and Paper, as in Rock-paper-scissors, under the following condition:\n\n(※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock).\n\nEach player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors.\n\n(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)\n\nWith his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts.\nPlan AtCoDeer's gesture in each turn to maximize AtCoDeer's score.\n\nThe gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is g, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in p, TopCoDeer will play Paper in the i-th turn.\n\nConstraints\n\n1≦N≦10^5\n\nN=|s|\n\nEach character in s is g or p.\n\nThe gestures represented by s satisfy the condition (※).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the AtCoDeer's maximum possible score.\n\nSample Input 1\n\ngpg\n\nSample Output 1\n\n0\n\nPlaying the same gesture as the opponent in each turn results in the score of 0, which is the maximum possible score.\n\nSample Input 2\n\nggppgggpgg\n\nSample Output 2\n\n2\n\nFor example, consider playing gestures in the following order: Rock, Paper, Rock, Paper, Rock, Rock, Paper, Paper, Rock, Paper. This strategy earns three victories and suffers one defeat, resulting in the score of 2, which is the maximum possible score.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 212, "cpu_time_ms": 36, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s606563432", "group_id": "codeNet:p03967", "input_text": "s = gets.chomp\nn = s.size\nchart = {\n g: { g: 0, p: -1},\n p: { g: 1, p: 0 } \n}\n\nans = 0\nn.times do |i|\n me = i.even? ? :g : :p\n you = s[i].to_sym\n ans += chart[me][you]\nend\n\nputs ans", "language": "Ruby", "metadata": {"date": 1583777162, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03967.html", "problem_id": "p03967", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03967/input.txt", "sample_output_relpath": "derived/input_output/data/p03967/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03967/Ruby/s606563432.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s606563432", "user_id": "u106964380"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "s = gets.chomp\nn = s.size\nchart = {\n g: { g: 0, p: -1},\n p: { g: 1, p: 0 } \n}\n\nans = 0\nn.times do |i|\n me = i.even? ? :g : :p\n you = s[i].to_sym\n ans += chart[me][you]\nend\n\nputs ans", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer and his friend TopCoDeer is playing a game.\nThe game consists of N turns.\nIn each turn, each player plays one of the two gestures, Rock and Paper, as in Rock-paper-scissors, under the following condition:\n\n(※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock).\n\nEach player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors.\n\n(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)\n\nWith his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts.\nPlan AtCoDeer's gesture in each turn to maximize AtCoDeer's score.\n\nThe gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is g, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in p, TopCoDeer will play Paper in the i-th turn.\n\nConstraints\n\n1≦N≦10^5\n\nN=|s|\n\nEach character in s is g or p.\n\nThe gestures represented by s satisfy the condition (※).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the AtCoDeer's maximum possible score.\n\nSample Input 1\n\ngpg\n\nSample Output 1\n\n0\n\nPlaying the same gesture as the opponent in each turn results in the score of 0, which is the maximum possible score.\n\nSample Input 2\n\nggppgggpgg\n\nSample Output 2\n\n2\n\nFor example, consider playing gestures in the following order: Rock, Paper, Rock, Paper, Rock, Rock, Paper, Paper, Rock, Paper. This strategy earns three victories and suffers one defeat, resulting in the score of 2, which is the maximum possible score.", "sample_input": "gpg\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03967", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer and his friend TopCoDeer is playing a game.\nThe game consists of N turns.\nIn each turn, each player plays one of the two gestures, Rock and Paper, as in Rock-paper-scissors, under the following condition:\n\n(※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock).\n\nEach player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors.\n\n(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)\n\nWith his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts.\nPlan AtCoDeer's gesture in each turn to maximize AtCoDeer's score.\n\nThe gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is g, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in p, TopCoDeer will play Paper in the i-th turn.\n\nConstraints\n\n1≦N≦10^5\n\nN=|s|\n\nEach character in s is g or p.\n\nThe gestures represented by s satisfy the condition (※).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the AtCoDeer's maximum possible score.\n\nSample Input 1\n\ngpg\n\nSample Output 1\n\n0\n\nPlaying the same gesture as the opponent in each turn results in the score of 0, which is the maximum possible score.\n\nSample Input 2\n\nggppgggpgg\n\nSample Output 2\n\n2\n\nFor example, consider playing gestures in the following order: Rock, Paper, Rock, Paper, Rock, Rock, Paper, Paper, Rock, Paper. This strategy earns three victories and suffers one defeat, resulting in the score of 2, which is the maximum possible score.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 186, "cpu_time_ms": 41, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s233853224", "group_id": "codeNet:p03971", "input_text": "nab = gets.chomp.split(\" \").map(&:to_i)\ns = gets.chomp.split(\"\")\n\nkakutei = 0\nkaigai = 0\n\nnab[0].times do |i|\n if s[i] == 'a'\n if kakutei < nab[1]+nab[2]\n puts \"Yes\"\n kakutei +=1\n else\n puts \"No\"\n end\n elsif s[i] == 'b'\n if kaigai < nab[2] && kakutei < nab[1]+nab[2]\n puts \"Yes\"\n kaigai += 1# if kaigai < n\n kakutei +=1\n else\n puts \"No\"\n end\n else\n puts \"No\"\n end\nend\n", "language": "Ruby", "metadata": {"date": 1476119102, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03971.html", "problem_id": "p03971", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03971/input.txt", "sample_output_relpath": "derived/input_output/data/p03971/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03971/Ruby/s233853224.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s233853224", "user_id": "u278896584"}, "prompt_components": {"gold_output": "Yes\nYes\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\n", "input_to_evaluate": "nab = gets.chomp.split(\" \").map(&:to_i)\ns = gets.chomp.split(\"\")\n\nkakutei = 0\nkaigai = 0\n\nnab[0].times do |i|\n if s[i] == 'a'\n if kakutei < nab[1]+nab[2]\n puts \"Yes\"\n kakutei +=1\n else\n puts \"No\"\n end\n elsif s[i] == 'b'\n if kaigai < nab[2] && kakutei < nab[1]+nab[2]\n puts \"Yes\"\n kaigai += 1# if kaigai < n\n kakutei +=1\n else\n puts \"No\"\n end\n else\n puts \"No\"\n end\nend\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these.\n\nOnly Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests.\n\nA Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.\n\nAn overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.\n\nA string S is assigned indicating attributes of all participants. If the i-th character of string S is a, this means the participant ranked i-th in the Qualification contests is a Japanese student; b means the participant ranked i-th is an overseas student; and c means the participant ranked i-th is neither of these.\n\nWrite a program that outputs for all the participants in descending rank either Yes if they passed the Qualification contests or No if they did not pass.\n\nConstraints\n\n1≦N,A,B≦100000\n\nA+B≦N\n\nS is N characters long.\n\nS consists only of the letters a, b and c.\n\nInput\n\nInputs are provided from Standard Input in the following form.\n\nN A B\nS\n\nOutput\n\nOutput N lines. On the i-th line, output Yes if the i-th participant passed the Qualification contests or No if that participant did not pass.\n\nSample Input 1\n\n10 2 3\nabccabaabb\n\nSample Output 1\n\nYes\nYes\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\n\nThe first, second, fifth, sixth, and seventh participants pass the Qualification contests.\n\nSample Input 2\n\n12 5 2\ncabbabaacaba\n\nSample Output 2\n\nNo\nYes\nYes\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nNo\nNo\n\nThe sixth participant is third among overseas students and thus does not pass the Qualification contests.\n\nSample Input 3\n\n5 2 2\nccccc\n\nSample Output 3\n\nNo\nNo\nNo\nNo\nNo", "sample_input": "10 2 3\nabccabaabb\n"}, "reference_outputs": ["Yes\nYes\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\n"], "source_document_id": "p03971", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these.\n\nOnly Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests.\n\nA Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.\n\nAn overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.\n\nA string S is assigned indicating attributes of all participants. If the i-th character of string S is a, this means the participant ranked i-th in the Qualification contests is a Japanese student; b means the participant ranked i-th is an overseas student; and c means the participant ranked i-th is neither of these.\n\nWrite a program that outputs for all the participants in descending rank either Yes if they passed the Qualification contests or No if they did not pass.\n\nConstraints\n\n1≦N,A,B≦100000\n\nA+B≦N\n\nS is N characters long.\n\nS consists only of the letters a, b and c.\n\nInput\n\nInputs are provided from Standard Input in the following form.\n\nN A B\nS\n\nOutput\n\nOutput N lines. On the i-th line, output Yes if the i-th participant passed the Qualification contests or No if that participant did not pass.\n\nSample Input 1\n\n10 2 3\nabccabaabb\n\nSample Output 1\n\nYes\nYes\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\n\nThe first, second, fifth, sixth, and seventh participants pass the Qualification contests.\n\nSample Input 2\n\n12 5 2\ncabbabaacaba\n\nSample Output 2\n\nNo\nYes\nYes\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nNo\nNo\n\nThe sixth participant is third among overseas students and thus does not pass the Qualification contests.\n\nSample Input 3\n\n5 2 2\nccccc\n\nSample Output 3\n\nNo\nNo\nNo\nNo\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 428, "cpu_time_ms": 130, "memory_kb": 9852}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s143808595", "group_id": "codeNet:p03986", "input_text": "io = STDIN\nx=io.gets.chomp\ny=0\nx.gsub!(/(ST)+/,\"\")\nx.gsub!(/(S+)(T+)/) do |str|\n ssize = str.index(\"T\")\n tsize = str.size - ssize\n if (ssize>tsize)\n \"S\" * (ssize-tsize)\n else\n \"T\" * (tsize-ssize)\n end\nend\nx.gsub!(/(ST)+/,\"\")\nx.gsub!(/(S+)(T+)/) do |str|\n ssize = str.index(\"T\")\n tsize = str.size - ssize\n if (ssize>tsize)\n \"S\" * (ssize-tsize)\n else\n \"T\" * (tsize-ssize)\n end\nend\nputs x.size", "language": "Ruby", "metadata": {"date": 1475374513, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03986.html", "problem_id": "p03986", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03986/input.txt", "sample_output_relpath": "derived/input_output/data/p03986/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03986/Ruby/s143808595.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s143808595", "user_id": "u132360211"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "io = STDIN\nx=io.gets.chomp\ny=0\nx.gsub!(/(ST)+/,\"\")\nx.gsub!(/(S+)(T+)/) do |str|\n ssize = str.index(\"T\")\n tsize = str.size - ssize\n if (ssize>tsize)\n \"S\" * (ssize-tsize)\n else\n \"T\" * (tsize-ssize)\n end\nend\nx.gsub!(/(ST)+/,\"\")\nx.gsub!(/(S+)(T+)/) do |str|\n ssize = str.index(\"T\")\n tsize = str.size - ssize\n if (ssize>tsize)\n \"S\" * (ssize-tsize)\n else\n \"T\" * (tsize-ssize)\n end\nend\nputs x.size", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a string X, which has an even number of characters. Half the characters are S, and the other half are T.\n\nTakahashi, who hates the string ST, will perform the following operation 10^{10000} times:\n\nAmong the occurrences of ST in X as (contiguous) substrings, remove the leftmost one. If there is no occurrence, do nothing.\n\nFind the eventual length of X.\n\nConstraints\n\n2 ≦ |X| ≦ 200,000\n\nThe length of X is even.\n\nHalf the characters in X are S, and the other half are T.\n\nPartial Scores\n\nIn test cases worth 200 points, |X| ≦ 200.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the eventual length of X.\n\nSample Input 1\n\nTSTTSS\n\nSample Output 1\n\n4\n\nIn the 1-st operation, the 2-nd and 3-rd characters of TSTTSS are removed.\nX becomes TTSS, and since it does not contain ST anymore, nothing is done in the remaining 10^{10000}-1 operations.\nThus, the answer is 4.\n\nSample Input 2\n\nSSTTST\n\nSample Output 2\n\n0\n\nX will eventually become an empty string: SSTTST ⇒ STST ⇒ ST ⇒ ``.\n\nSample Input 3\n\nTSSTTTSS\n\nSample Output 3\n\n4\n\nX will become: TSSTTTSS ⇒ TSTTSS ⇒ TTSS.", "sample_input": "TSTTSS\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03986", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a string X, which has an even number of characters. Half the characters are S, and the other half are T.\n\nTakahashi, who hates the string ST, will perform the following operation 10^{10000} times:\n\nAmong the occurrences of ST in X as (contiguous) substrings, remove the leftmost one. If there is no occurrence, do nothing.\n\nFind the eventual length of X.\n\nConstraints\n\n2 ≦ |X| ≦ 200,000\n\nThe length of X is even.\n\nHalf the characters in X are S, and the other half are T.\n\nPartial Scores\n\nIn test cases worth 200 points, |X| ≦ 200.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the eventual length of X.\n\nSample Input 1\n\nTSTTSS\n\nSample Output 1\n\n4\n\nIn the 1-st operation, the 2-nd and 3-rd characters of TSTTSS are removed.\nX becomes TTSS, and since it does not contain ST anymore, nothing is done in the remaining 10^{10000}-1 operations.\nThus, the answer is 4.\n\nSample Input 2\n\nSSTTST\n\nSample Output 2\n\n0\n\nX will eventually become an empty string: SSTTST ⇒ STST ⇒ ST ⇒ ``.\n\nSample Input 3\n\nTSSTTTSS\n\nSample Output 3\n\n4\n\nX will become: TSSTTTSS ⇒ TSTTSS ⇒ TTSS.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 412, "cpu_time_ms": 1054, "memory_kb": 6464}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s805869604", "group_id": "codeNet:p03992", "input_text": "#coding: utf-8\n 2 a=gets().chomp\n 3 a.insert(4,\" \")\n 4 puts(a)", "language": "Ruby", "metadata": {"date": 1474911853, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03992.html", "problem_id": "p03992", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03992/input.txt", "sample_output_relpath": "derived/input_output/data/p03992/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03992/Ruby/s805869604.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s805869604", "user_id": "u404419997"}, "prompt_components": {"gold_output": "CODE FESTIVAL\n", "input_to_evaluate": "#coding: utf-8\n 2 a=gets().chomp\n 3 a.insert(4,\" \")\n 4 puts(a)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThis contest is CODE FESTIVAL.\nHowever, Mr. Takahashi always writes it CODEFESTIVAL, omitting the single space between CODE and FESTIVAL.\n\nSo he has decided to make a program that puts the single space he omitted.\n\nYou are given a string s with 12 letters.\nOutput the string putting a single space between the first 4 letters and last 8 letters in the string s.\n\nConstraints\n\ns contains exactly 12 letters.\n\nAll letters in s are uppercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string putting a single space between the first 4 letters and last 8 letters in the string s.\nPut a line break at the end.\n\nSample Input 1\n\nCODEFESTIVAL\n\nSample Output 1\n\nCODE FESTIVAL\n\nPutting a single space between the first 4 letters and last 8 letters in CODEFESTIVAL makes it CODE FESTIVAL.\n\nSample Input 2\n\nPOSTGRADUATE\n\nSample Output 2\n\nPOST GRADUATE\n\nSample Input 3\n\nABCDEFGHIJKL\n\nSample Output 3\n\nABCD EFGHIJKL", "sample_input": "CODEFESTIVAL\n"}, "reference_outputs": ["CODE FESTIVAL\n"], "source_document_id": "p03992", "source_text": "Score : 100 points\n\nProblem Statement\n\nThis contest is CODE FESTIVAL.\nHowever, Mr. Takahashi always writes it CODEFESTIVAL, omitting the single space between CODE and FESTIVAL.\n\nSo he has decided to make a program that puts the single space he omitted.\n\nYou are given a string s with 12 letters.\nOutput the string putting a single space between the first 4 letters and last 8 letters in the string s.\n\nConstraints\n\ns contains exactly 12 letters.\n\nAll letters in s are uppercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string putting a single space between the first 4 letters and last 8 letters in the string s.\nPut a line break at the end.\n\nSample Input 1\n\nCODEFESTIVAL\n\nSample Output 1\n\nCODE FESTIVAL\n\nPutting a single space between the first 4 letters and last 8 letters in CODEFESTIVAL makes it CODE FESTIVAL.\n\nSample Input 2\n\nPOSTGRADUATE\n\nSample Output 2\n\nPOST GRADUATE\n\nSample Input 3\n\nABCDEFGHIJKL\n\nSample Output 3\n\nABCD EFGHIJKL", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 65, "cpu_time_ms": 11, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s375635061", "group_id": "codeNet:p03993", "input_text": "n = gets.to_i\na = gets.split(\" \").map(&:to_i)\n\ncount = 0\nn.times do |i|\n if a[a[i] - 1] - 1 == i\n count += 1\n end\nend\nputs count / 2\n", "language": "Ruby", "metadata": {"date": 1474766937, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03993.html", "problem_id": "p03993", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03993/input.txt", "sample_output_relpath": "derived/input_output/data/p03993/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03993/Ruby/s375635061.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s375635061", "user_id": "u379601169"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "n = gets.to_i\na = gets.split(\" \").map(&:to_i)\n\ncount = 0\nn.times do |i|\n if a[a[i] - 1] - 1 == i\n count += 1\n end\nend\nputs count / 2\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N rabbits, numbered 1 through N.\n\nThe i-th (1≤i≤N) rabbit likes rabbit a_i.\nNote that no rabbit can like itself, that is, a_i≠i.\n\nFor a pair of rabbits i and j (i<j), we call the pair (i,j) a friendly pair if the following condition is met.\n\nRabbit i likes rabbit j and rabbit j likes rabbit i.\n\nCalculate the number of the friendly pairs.\n\nConstraints\n\n2≤N≤10^5\n\n1≤a_i≤N\n\na_i≠i\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of the friendly pairs.\n\nSample Input 1\n\n4\n2 1 4 3\n\nSample Output 1\n\n2\n\nThere are two friendly pairs: (1,2) and (3,4).\n\nSample Input 2\n\n3\n2 3 1\n\nSample Output 2\n\n0\n\nThere are no friendly pairs.\n\nSample Input 3\n\n5\n5 5 5 5 1\n\nSample Output 3\n\n1\n\nThere is one friendly pair: (1,5).", "sample_input": "4\n2 1 4 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03993", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N rabbits, numbered 1 through N.\n\nThe i-th (1≤i≤N) rabbit likes rabbit a_i.\nNote that no rabbit can like itself, that is, a_i≠i.\n\nFor a pair of rabbits i and j (i<j), we call the pair (i,j) a friendly pair if the following condition is met.\n\nRabbit i likes rabbit j and rabbit j likes rabbit i.\n\nCalculate the number of the friendly pairs.\n\nConstraints\n\n2≤N≤10^5\n\n1≤a_i≤N\n\na_i≠i\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of the friendly pairs.\n\nSample Input 1\n\n4\n2 1 4 3\n\nSample Output 1\n\n2\n\nThere are two friendly pairs: (1,2) and (3,4).\n\nSample Input 2\n\n3\n2 3 1\n\nSample Output 2\n\n0\n\nThere are no friendly pairs.\n\nSample Input 3\n\n5\n5 5 5 5 1\n\nSample Output 3\n\n1\n\nThere is one friendly pair: (1,5).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 138, "cpu_time_ms": 61, "memory_kb": 8068}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s243702963", "group_id": "codeNet:p03994", "input_text": "s=gets.chomp\nk=gets.to_i\ns.each_char.with_index do |c,i|\n l=122-c.ord+1\n if c!=\"a\"&&l<=k\n k-=l\n s[i]=\"a\"\n end\nend\ns[-1]=((s[-1].ord-97+k)%26+97).chr\nputs s\n", "language": "Ruby", "metadata": {"date": 1592150767, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03994.html", "problem_id": "p03994", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03994/input.txt", "sample_output_relpath": "derived/input_output/data/p03994/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03994/Ruby/s243702963.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s243702963", "user_id": "u744908753"}, "prompt_components": {"gold_output": "aya\n", "input_to_evaluate": "s=gets.chomp\nk=gets.to_i\ns.each_char.with_index do |c,i|\n l=122-c.ord+1\n if c!=\"a\"&&l<=k\n k-=l\n s[i]=\"a\"\n end\nend\ns[-1]=((s[-1].ord-97+k)%26+97).chr\nputs s\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nMr. Takahashi has a string s consisting of lowercase English letters.\nHe repeats the following operation on s exactly K times.\n\nChoose an arbitrary letter on s and change that letter to the next alphabet. Note that the next letter of z is a.\n\nFor example, if you perform an operation for the second letter on aaz, aaz becomes abz.\nIf you then perform an operation for the third letter on abz, abz becomes aba.\n\nMr. Takahashi wants to have the lexicographically smallest string after performing exactly K operations on s.\nFind the such string.\n\nConstraints\n\n1≤|s|≤10^5\n\nAll letters in s are lowercase English letters.\n\n1≤K≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\nK\n\nOutput\n\nPrint the lexicographically smallest string after performing exactly K operations on s.\n\nSample Input 1\n\nxyz\n4\n\nSample Output 1\n\naya\n\nFor example, you can perform the following operations: xyz, yyz, zyz, ayz, aya.\n\nSample Input 2\n\na\n25\n\nSample Output 2\n\nz\n\nYou have to perform exactly K operations.\n\nSample Input 3\n\ncodefestival\n100\n\nSample Output 3\n\naaaafeaaivap", "sample_input": "xyz\n4\n"}, "reference_outputs": ["aya\n"], "source_document_id": "p03994", "source_text": "Score : 400 points\n\nProblem Statement\n\nMr. Takahashi has a string s consisting of lowercase English letters.\nHe repeats the following operation on s exactly K times.\n\nChoose an arbitrary letter on s and change that letter to the next alphabet. Note that the next letter of z is a.\n\nFor example, if you perform an operation for the second letter on aaz, aaz becomes abz.\nIf you then perform an operation for the third letter on abz, abz becomes aba.\n\nMr. Takahashi wants to have the lexicographically smallest string after performing exactly K operations on s.\nFind the such string.\n\nConstraints\n\n1≤|s|≤10^5\n\nAll letters in s are lowercase English letters.\n\n1≤K≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\nK\n\nOutput\n\nPrint the lexicographically smallest string after performing exactly K operations on s.\n\nSample Input 1\n\nxyz\n4\n\nSample Output 1\n\naya\n\nFor example, you can perform the following operations: xyz, yyz, zyz, ayz, aya.\n\nSample Input 2\n\na\n25\n\nSample Output 2\n\nz\n\nYou have to perform exactly K operations.\n\nSample Input 3\n\ncodefestival\n100\n\nSample Output 3\n\naaaafeaaivap", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 165, "cpu_time_ms": 1276, "memory_kb": 2172}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s110310073", "group_id": "codeNet:p03997", "input_text": "a,b,h = 3.times.map{gets.to_i}\nputs (a+b)*h/2\n", "language": "Ruby", "metadata": {"date": 1548718337, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03997.html", "problem_id": "p03997", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03997/input.txt", "sample_output_relpath": "derived/input_output/data/p03997/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03997/Ruby/s110310073.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s110310073", "user_id": "u191196346"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "a,b,h = 3.times.map{gets.to_i}\nputs (a+b)*h/2\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.\n\nAn example of a trapezoid\n\nFind the area of this trapezoid.\n\nConstraints\n\n1≦a≦100\n\n1≦b≦100\n\n1≦h≦100\n\nAll input values are integers.\n\nh is even.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na\nb\nh\n\nOutput\n\nPrint the area of the given trapezoid. It is guaranteed that the area is an integer.\n\nSample Input 1\n\n3\n4\n2\n\nSample Output 1\n\n7\n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2, respectively, the area of the trapezoid is (3+4)×2/2 = 7.\n\nSample Input 2\n\n4\n4\n4\n\nSample Output 2\n\n16\n\nIn this case, a parallelogram is given, which is also a trapezoid.", "sample_input": "3\n4\n2\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03997", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.\n\nAn example of a trapezoid\n\nFind the area of this trapezoid.\n\nConstraints\n\n1≦a≦100\n\n1≦b≦100\n\n1≦h≦100\n\nAll input values are integers.\n\nh is even.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na\nb\nh\n\nOutput\n\nPrint the area of the given trapezoid. It is guaranteed that the area is an integer.\n\nSample Input 1\n\n3\n4\n2\n\nSample Output 1\n\n7\n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2, respectively, the area of the trapezoid is (3+4)×2/2 = 7.\n\nSample Input 2\n\n4\n4\n4\n\nSample Output 2\n\n16\n\nIn this case, a parallelogram is given, which is also a trapezoid.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 46, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s064448472", "group_id": "codeNet:p03999", "input_text": "S = gets.chomp.split(\"\")\n$debug = false\n\n### DFS: Depth-First Search = 深さ優先探索\n# スタックによる実装\ndef iterative_dfs(patterns, limit)\n # スタックとなる配列を用意し、初期状態である空文字列を格納する\n stack = [\"\"]\n until stack.empty?\n # スタックから1つ取り出す(末尾から取り出すのでpopを使う)\n string = stack.pop\n\n if string.length == limit\n # 頂点に達した際、文字列を配列に格納する\n patterns << string.split(\"\").to_a.unshift(nil) unless string.empty?\n else\n # 分岐処理\n stack << string + \" \"\n stack << string + \"+\"\n end\n end\nend\n\npatterns = [] # 結果を格納する配列を用意しておく\niterative_dfs(patterns, S.size - 1)\np patterns if $debug # 組み合わせの表示\n\nanswer = 0\npatterns.each do |pattern|\n expression = S[0]\n (1...S.length).each do |i|\n expression += \"+\" if pattern[i] == \"+\"\n expression += S[i]\n end\n p expression if $debug\n p eval expression if $debug\n answer += eval expression\nend\n\n# 入力が1桁の場合の考慮を忘れていた……。\nif S.size == 1\n answer = S[0].to_i\nend\n\nputs answer\n", "language": "Ruby", "metadata": {"date": 1563720143, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p03999.html", "problem_id": "p03999", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03999/input.txt", "sample_output_relpath": "derived/input_output/data/p03999/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03999/Ruby/s064448472.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s064448472", "user_id": "u627764960"}, "prompt_components": {"gold_output": "176\n", "input_to_evaluate": "S = gets.chomp.split(\"\")\n$debug = false\n\n### DFS: Depth-First Search = 深さ優先探索\n# スタックによる実装\ndef iterative_dfs(patterns, limit)\n # スタックとなる配列を用意し、初期状態である空文字列を格納する\n stack = [\"\"]\n until stack.empty?\n # スタックから1つ取り出す(末尾から取り出すのでpopを使う)\n string = stack.pop\n\n if string.length == limit\n # 頂点に達した際、文字列を配列に格納する\n patterns << string.split(\"\").to_a.unshift(nil) unless string.empty?\n else\n # 分岐処理\n stack << string + \" \"\n stack << string + \"+\"\n end\n end\nend\n\npatterns = [] # 結果を格納する配列を用意しておく\niterative_dfs(patterns, S.size - 1)\np patterns if $debug # 組み合わせの表示\n\nanswer = 0\npatterns.each do |pattern|\n expression = S[0]\n (1...S.length).each do |i|\n expression += \"+\" if pattern[i] == \"+\"\n expression += S[i]\n end\n p expression if $debug\n p eval expression if $debug\n answer += eval expression\nend\n\n# 入力が1桁の場合の考慮を忘れていた……。\nif S.size == 1\n answer = S[0].to_i\nend\n\nputs answer\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S consisting of digits between 1 and 9, inclusive.\nYou can insert the letter + into some of the positions (possibly none) between two letters in this string.\nHere, + must not occur consecutively after insertion.\n\nAll strings that can be obtained in this way can be evaluated as formulas.\n\nEvaluate all possible formulas, and print the sum of the results.\n\nConstraints\n\n1 \\leq |S| \\leq 10\n\nAll letters in S are digits between 1 and 9, inclusive.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the evaluated value over all possible formulas.\n\nSample Input 1\n\n125\n\nSample Output 1\n\n176\n\nThere are 4 formulas that can be obtained: 125, 1+25, 12+5 and 1+2+5. When each formula is evaluated,\n\n125\n\n1+25=26\n\n12+5=17\n\n1+2+5=8\n\nThus, the sum is 125+26+17+8=176.\n\nSample Input 2\n\n9999999999\n\nSample Output 2\n\n12656242944", "sample_input": "125\n"}, "reference_outputs": ["176\n"], "source_document_id": "p03999", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S consisting of digits between 1 and 9, inclusive.\nYou can insert the letter + into some of the positions (possibly none) between two letters in this string.\nHere, + must not occur consecutively after insertion.\n\nAll strings that can be obtained in this way can be evaluated as formulas.\n\nEvaluate all possible formulas, and print the sum of the results.\n\nConstraints\n\n1 \\leq |S| \\leq 10\n\nAll letters in S are digits between 1 and 9, inclusive.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the evaluated value over all possible formulas.\n\nSample Input 1\n\n125\n\nSample Output 1\n\n176\n\nThere are 4 formulas that can be obtained: 125, 1+25, 12+5 and 1+2+5. When each formula is evaluated,\n\n125\n\n1+25=26\n\n12+5=17\n\n1+2+5=8\n\nThus, the sum is 125+26+17+8=176.\n\nSample Input 2\n\n9999999999\n\nSample Output 2\n\n12656242944", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1185, "cpu_time_ms": 19, "memory_kb": 2428}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s162660001", "group_id": "codeNet:p03999", "input_text": "# 愚直にやる以外の方法がまっっっっったく浮かばないのだが???\n# いくつ入れるか+どこにいれるか\n\n# 実装が頭ハゲるかと思った...1時間くらいかかったのでは...\n\ns = gets.chomp.chars.map(&:to_i)\nans = s.map(&:to_s).join.to_i\ndef perm(i, current_arr, source_arr, limit)\n length = source_arr.size\n # return if length < limit\n if current_arr.size == limit\n @res_arr << current_arr\n else\n i.upto(length) do |j|\n next if i==j\n perm(j, current_arr.clone< 0)\n puts \"true\"\n stock += now_s*10 + S[i].to_i\n now_s = 0\n else\n now_s = now_s*10 + S[i].to_i\n end\n puts now_s\n end\n stock += now_s * 10 + S[N].to_i\n s += stock\nend\nputs s\n", "language": "Ruby", "metadata": {"date": 1564940148, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p04001.html", "problem_id": "p04001", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p04001/input.txt", "sample_output_relpath": "derived/input_output/data/p04001/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04001/Ruby/s316792975.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s316792975", "user_id": "u561491193"}, "prompt_components": {"gold_output": "176\n", "input_to_evaluate": "S = gets.to_i.to_s\nN = S.length - 1\n\ns = 0\n(1< 0)\n puts \"true\"\n stock += now_s*10 + S[i].to_i\n now_s = 0\n else\n now_s = now_s*10 + S[i].to_i\n end\n puts now_s\n end\n stock += now_s * 10 + S[N].to_i\n s += stock\nend\nputs s\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S consisting of digits between 1 and 9, inclusive.\nYou can insert the letter + into some of the positions (possibly none) between two letters in this string.\nHere, + must not occur consecutively after insertion.\n\nAll strings that can be obtained in this way can be evaluated as formulas.\n\nEvaluate all possible formulas, and print the sum of the results.\n\nConstraints\n\n1 \\leq |S| \\leq 10\n\nAll letters in S are digits between 1 and 9, inclusive.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the evaluated value over all possible formulas.\n\nSample Input 1\n\n125\n\nSample Output 1\n\n176\n\nThere are 4 formulas that can be obtained: 125, 1+25, 12+5 and 1+2+5. When each formula is evaluated,\n\n125\n\n1+25=26\n\n12+5=17\n\n1+2+5=8\n\nThus, the sum is 125+26+17+8=176.\n\nSample Input 2\n\n9999999999\n\nSample Output 2\n\n12656242944", "sample_input": "125\n"}, "reference_outputs": ["176\n"], "source_document_id": "p04001", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S consisting of digits between 1 and 9, inclusive.\nYou can insert the letter + into some of the positions (possibly none) between two letters in this string.\nHere, + must not occur consecutively after insertion.\n\nAll strings that can be obtained in this way can be evaluated as formulas.\n\nEvaluate all possible formulas, and print the sum of the results.\n\nConstraints\n\n1 \\leq |S| \\leq 10\n\nAll letters in S are digits between 1 and 9, inclusive.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the evaluated value over all possible formulas.\n\nSample Input 1\n\n125\n\nSample Output 1\n\n176\n\nThere are 4 formulas that can be obtained: 125, 1+25, 12+5 and 1+2+5. When each formula is evaluated,\n\n125\n\n1+25=26\n\n12+5=17\n\n1+2+5=8\n\nThus, the sum is 125+26+17+8=176.\n\nSample Input 2\n\n9999999999\n\nSample Output 2\n\n12656242944", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 366, "cpu_time_ms": 19, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s909083190", "group_id": "codeNet:p04001", "input_text": "S = gets.chomp\nn = S.size\n\ndef f(s, i)\n return if i <= 0\n $ans << s\n a = String.new(s)\n a[i,0] = \"+\"\n $ans << a\n f(s, i-1)\n f(a, i-1)\nend\n\n$ans = []\n(n-1).downto(1) do |i|\n f(S, i)\nend\nputs $ans.uniq.map { |a| eval(a) }.inject(:+)", "language": "Ruby", "metadata": {"date": 1550949705, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p04001.html", "problem_id": "p04001", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p04001/input.txt", "sample_output_relpath": "derived/input_output/data/p04001/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04001/Ruby/s909083190.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s909083190", "user_id": "u729246375"}, "prompt_components": {"gold_output": "176\n", "input_to_evaluate": "S = gets.chomp\nn = S.size\n\ndef f(s, i)\n return if i <= 0\n $ans << s\n a = String.new(s)\n a[i,0] = \"+\"\n $ans << a\n f(s, i-1)\n f(a, i-1)\nend\n\n$ans = []\n(n-1).downto(1) do |i|\n f(S, i)\nend\nputs $ans.uniq.map { |a| eval(a) }.inject(:+)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S consisting of digits between 1 and 9, inclusive.\nYou can insert the letter + into some of the positions (possibly none) between two letters in this string.\nHere, + must not occur consecutively after insertion.\n\nAll strings that can be obtained in this way can be evaluated as formulas.\n\nEvaluate all possible formulas, and print the sum of the results.\n\nConstraints\n\n1 \\leq |S| \\leq 10\n\nAll letters in S are digits between 1 and 9, inclusive.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the evaluated value over all possible formulas.\n\nSample Input 1\n\n125\n\nSample Output 1\n\n176\n\nThere are 4 formulas that can be obtained: 125, 1+25, 12+5 and 1+2+5. When each formula is evaluated,\n\n125\n\n1+25=26\n\n12+5=17\n\n1+2+5=8\n\nThus, the sum is 125+26+17+8=176.\n\nSample Input 2\n\n9999999999\n\nSample Output 2\n\n12656242944", "sample_input": "125\n"}, "reference_outputs": ["176\n"], "source_document_id": "p04001", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S consisting of digits between 1 and 9, inclusive.\nYou can insert the letter + into some of the positions (possibly none) between two letters in this string.\nHere, + must not occur consecutively after insertion.\n\nAll strings that can be obtained in this way can be evaluated as formulas.\n\nEvaluate all possible formulas, and print the sum of the results.\n\nConstraints\n\n1 \\leq |S| \\leq 10\n\nAll letters in S are digits between 1 and 9, inclusive.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the evaluated value over all possible formulas.\n\nSample Input 1\n\n125\n\nSample Output 1\n\n176\n\nThere are 4 formulas that can be obtained: 125, 1+25, 12+5 and 1+2+5. When each formula is evaluated,\n\n125\n\n1+25=26\n\n12+5=17\n\n1+2+5=8\n\nThus, the sum is 125+26+17+8=176.\n\nSample Input 2\n\n9999999999\n\nSample Output 2\n\n12656242944", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 238, "cpu_time_ms": 13, "memory_kb": 2556}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s785582469", "group_id": "codeNet:p04002", "input_text": "#!ruby -E Windows-31J:utf-8\n\ndef f_hs a,b\n a*1000000000+b\nend\ndef i_hs k\n return k.div(1000000000),k%1000000000\nend\n\nblacks = {} \nwell_known = {}\nresult = [0,0,0,0,0,0,0,0,0,0]\n\nh,w,n = $stdin.gets.chomp.split(/\\s+/).map{|str|str.to_i}\n#storage\n(0...n).each{|ln|\n ia,ib = $stdin.gets.chomp.split(/\\s+/).map{|str|str.to_i-1}\n blacks[ f_hs ia,ib ] = true\n}\n\n#calc\nblacks.each{|k,v|\n ia,ib = i_hs k\n\n ca=ia-1\n while ca<=ia+1 do\n if ca+1>=h || ca-1<0\n ca += 1\n next\n end\n (ib-1..ib+1).each{|cb|\n next if cb+1>=w || cb-1<0\n next if well_known[ f_hs ca,cb ]!=nil\n \n # counts\n cnt = 0\n (ca-1..ca+1).each{|fa|\n cnt +=1 if blacks.has_key? f_hs(fa,cb+1)\n cnt +=1 if blacks.has_key? f_hs(fa,cb)\n cnt +=1 if blacks.has_key? f_hs(fa,cb-1)\n }\n result[cnt]+=1\n\n # checker\n well_known[ f_hs ca,cb ] = true\n }\n ca+=1\n end\n}\n\n#possible all\nresult[0] = (h-2)*(w-2)\n(1..9).each{|i| result[0]-=result[i]}\n\n#output\nresult.each{|r| puts r}", "language": "Ruby", "metadata": {"date": 1473650313, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p04002.html", "problem_id": "p04002", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p04002/input.txt", "sample_output_relpath": "derived/input_output/data/p04002/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04002/Ruby/s785582469.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s785582469", "user_id": "u298885272"}, "prompt_components": {"gold_output": "0\n0\n0\n2\n4\n0\n0\n0\n0\n0\n", "input_to_evaluate": "#!ruby -E Windows-31J:utf-8\n\ndef f_hs a,b\n a*1000000000+b\nend\ndef i_hs k\n return k.div(1000000000),k%1000000000\nend\n\nblacks = {} \nwell_known = {}\nresult = [0,0,0,0,0,0,0,0,0,0]\n\nh,w,n = $stdin.gets.chomp.split(/\\s+/).map{|str|str.to_i}\n#storage\n(0...n).each{|ln|\n ia,ib = $stdin.gets.chomp.split(/\\s+/).map{|str|str.to_i-1}\n blacks[ f_hs ia,ib ] = true\n}\n\n#calc\nblacks.each{|k,v|\n ia,ib = i_hs k\n\n ca=ia-1\n while ca<=ia+1 do\n if ca+1>=h || ca-1<0\n ca += 1\n next\n end\n (ib-1..ib+1).each{|cb|\n next if cb+1>=w || cb-1<0\n next if well_known[ f_hs ca,cb ]!=nil\n \n # counts\n cnt = 0\n (ca-1..ca+1).each{|fa|\n cnt +=1 if blacks.has_key? f_hs(fa,cb+1)\n cnt +=1 if blacks.has_key? f_hs(fa,cb)\n cnt +=1 if blacks.has_key? f_hs(fa,cb-1)\n }\n result[cnt]+=1\n\n # checker\n well_known[ f_hs ca,cb ] = true\n }\n ca+=1\n end\n}\n\n#possible all\nresult[0] = (h-2)*(w-2)\n(1..9).each{|i| result[0]-=result[i]}\n\n#output\nresult.each{|r| puts r}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns. At first, all cells were painted white.\n\nSnuke painted N of these cells. The i-th ( 1 \\leq i \\leq N ) cell he painted is the cell at the a_i-th row and b_i-th column.\n\nCompute the following:\n\nFor each integer j ( 0 \\leq j \\leq 9 ), how many subrectangles of size 3×3 of the grid contains exactly j black cells, after Snuke painted N cells?\n\nConstraints\n\n3 \\leq H \\leq 10^9\n\n3 \\leq W \\leq 10^9\n\n0 \\leq N \\leq min(10^5,H×W)\n\n1 \\leq a_i \\leq H (1 \\leq i \\leq N)\n\n1 \\leq b_i \\leq W (1 \\leq i \\leq N)\n\n(a_i, b_i) \\neq (a_j, b_j) (i \\neq j)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W N\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint 10 lines.\nThe (j+1)-th ( 0 \\leq j \\leq 9 ) line should contain the number of the subrectangles of size 3×3 of the grid that contains exactly j black cells.\n\nSample Input 1\n\n4 5 8\n1 1\n1 4\n1 5\n2 3\n3 1\n3 2\n3 4\n4 4\n\nSample Output 1\n\n0\n0\n0\n2\n4\n0\n0\n0\n0\n0\n\nThere are six subrectangles of size 3×3. Two of them contain three black cells each, and the remaining four contain four black cells each.\n\nSample Input 2\n\n10 10 20\n1 1\n1 4\n1 9\n2 5\n3 10\n4 2\n4 7\n5 9\n6 4\n6 6\n6 7\n7 1\n7 3\n7 7\n8 1\n8 5\n8 10\n9 2\n10 4\n10 9\n\nSample Output 2\n\n4\n26\n22\n10\n2\n0\n0\n0\n0\n0\n\nSample Input 3\n\n1000000000 1000000000 0\n\nSample Output 3\n\n999999996000000004\n0\n0\n0\n0\n0\n0\n0\n0\n0", "sample_input": "4 5 8\n1 1\n1 4\n1 5\n2 3\n3 1\n3 2\n3 4\n4 4\n"}, "reference_outputs": ["0\n0\n0\n2\n4\n0\n0\n0\n0\n0\n"], "source_document_id": "p04002", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns. At first, all cells were painted white.\n\nSnuke painted N of these cells. The i-th ( 1 \\leq i \\leq N ) cell he painted is the cell at the a_i-th row and b_i-th column.\n\nCompute the following:\n\nFor each integer j ( 0 \\leq j \\leq 9 ), how many subrectangles of size 3×3 of the grid contains exactly j black cells, after Snuke painted N cells?\n\nConstraints\n\n3 \\leq H \\leq 10^9\n\n3 \\leq W \\leq 10^9\n\n0 \\leq N \\leq min(10^5,H×W)\n\n1 \\leq a_i \\leq H (1 \\leq i \\leq N)\n\n1 \\leq b_i \\leq W (1 \\leq i \\leq N)\n\n(a_i, b_i) \\neq (a_j, b_j) (i \\neq j)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W N\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint 10 lines.\nThe (j+1)-th ( 0 \\leq j \\leq 9 ) line should contain the number of the subrectangles of size 3×3 of the grid that contains exactly j black cells.\n\nSample Input 1\n\n4 5 8\n1 1\n1 4\n1 5\n2 3\n3 1\n3 2\n3 4\n4 4\n\nSample Output 1\n\n0\n0\n0\n2\n4\n0\n0\n0\n0\n0\n\nThere are six subrectangles of size 3×3. Two of them contain three black cells each, and the remaining four contain four black cells each.\n\nSample Input 2\n\n10 10 20\n1 1\n1 4\n1 9\n2 5\n3 10\n4 2\n4 7\n5 9\n6 4\n6 6\n6 7\n7 1\n7 3\n7 7\n8 1\n8 5\n8 10\n9 2\n10 4\n10 9\n\nSample Output 2\n\n4\n26\n22\n10\n2\n0\n0\n0\n0\n0\n\nSample Input 3\n\n1000000000 1000000000 0\n\nSample Output 3\n\n999999996000000004\n0\n0\n0\n0\n0\n0\n0\n0\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1152, "cpu_time_ms": 3162, "memory_kb": 43388}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s265120769", "group_id": "codeNet:p04005", "input_text": "a = gets.chomp.split(\" \").map(&:to_i).sort\nif a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0\n puts 0\nelse\n puts a[0] * a[1]\nend", "language": "Ruby", "metadata": {"date": 1595466198, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p04005.html", "problem_id": "p04005", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p04005/input.txt", "sample_output_relpath": "derived/input_output/data/p04005/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04005/Ruby/s265120769.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s265120769", "user_id": "u265679940"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "a = gets.chomp.split(\" \").map(&:to_i).sort\nif a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0\n puts 0\nelse\n puts a[0] * a[1]\nend", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that:\n\nThere is at least one red block and at least one blue block.\n\nThe union of all red blocks forms a rectangular parallelepiped.\n\nThe union of all blue blocks forms a rectangular parallelepiped.\n\nSnuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.\n\nConstraints\n\n2≤A,B,C≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the minimum possible difference between the number of red blocks and the number of blue blocks.\n\nSample Input 1\n\n3 3 3\n\nSample Output 1\n\n9\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 9 red blocks and 18 blue blocks, thus the difference is 9.\n\nSample Input 2\n\n2 2 4\n\nSample Output 2\n\n0\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 8 red blocks and 8 blue blocks, thus the difference is 0.\n\nSample Input 3\n\n5 3 5\n\nSample Output 3\n\n15\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 45 red blocks and 30 blue blocks, thus the difference is 9.", "sample_input": "3 3 3\n"}, "reference_outputs": ["9\n"], "source_document_id": "p04005", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that:\n\nThere is at least one red block and at least one blue block.\n\nThe union of all red blocks forms a rectangular parallelepiped.\n\nThe union of all blue blocks forms a rectangular parallelepiped.\n\nSnuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.\n\nConstraints\n\n2≤A,B,C≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the minimum possible difference between the number of red blocks and the number of blue blocks.\n\nSample Input 1\n\n3 3 3\n\nSample Output 1\n\n9\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 9 red blocks and 18 blue blocks, thus the difference is 9.\n\nSample Input 2\n\n2 2 4\n\nSample Output 2\n\n0\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 8 red blocks and 8 blue blocks, thus the difference is 0.\n\nSample Input 3\n\n5 3 5\n\nSample Output 3\n\n15\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 45 red blocks and 30 blue blocks, thus the difference is 9.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 130, "cpu_time_ms": 67, "memory_kb": 14296}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s891484207", "group_id": "codeNet:p04011", "input_text": "n = gets.to_i\nboder = gets.to_i - 1\nfir = gets.to_i\nfin = gets.to_i\narr = Array.new(n)\nboder.times do |i|\n arr[i] = fir\nend\nputs arr.inject(0){|sum,i|sum += !i.nil? ? i : fin}", "language": "Ruby", "metadata": {"date": 1534465844, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p04011.html", "problem_id": "p04011", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p04011/input.txt", "sample_output_relpath": "derived/input_output/data/p04011/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04011/Ruby/s891484207.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s891484207", "user_id": "u441320643"}, "prompt_components": {"gold_output": "48000\n", "input_to_evaluate": "n = gets.to_i\nboder = gets.to_i - 1\nfir = gets.to_i\nfin = gets.to_i\narr = Array.new(n)\nboder.times do |i|\n arr[i] = fir\nend\nputs arr.inject(0){|sum,i|sum += !i.nil? ? i : fin}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a hotel with the following accommodation fee:\n\nX yen (the currency of Japan) per night, for the first K nights\n\nY yen per night, for the (K+1)-th and subsequent nights\n\nTak is staying at this hotel for N consecutive nights.\nFind his total accommodation fee.\n\nConstraints\n\n1 \\leq N, K \\leq 10000\n\n1 \\leq Y < X \\leq 10000\n\nN,\\,K,\\,X,\\,Y are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nK\nX\nY\n\nOutput\n\nPrint Tak's total accommodation fee.\n\nSample Input 1\n\n5\n3\n10000\n9000\n\nSample Output 1\n\n48000\n\nThe accommodation fee is as follows:\n\n10000 yen for the 1-st night\n\n10000 yen for the 2-nd night\n\n10000 yen for the 3-rd night\n\n9000 yen for the 4-th night\n\n9000 yen for the 5-th night\n\nThus, the total is 48000 yen.\n\nSample Input 2\n\n2\n3\n10000\n9000\n\nSample Output 2\n\n20000", "sample_input": "5\n3\n10000\n9000\n"}, "reference_outputs": ["48000\n"], "source_document_id": "p04011", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a hotel with the following accommodation fee:\n\nX yen (the currency of Japan) per night, for the first K nights\n\nY yen per night, for the (K+1)-th and subsequent nights\n\nTak is staying at this hotel for N consecutive nights.\nFind his total accommodation fee.\n\nConstraints\n\n1 \\leq N, K \\leq 10000\n\n1 \\leq Y < X \\leq 10000\n\nN,\\,K,\\,X,\\,Y are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nK\nX\nY\n\nOutput\n\nPrint Tak's total accommodation fee.\n\nSample Input 1\n\n5\n3\n10000\n9000\n\nSample Output 1\n\n48000\n\nThe accommodation fee is as follows:\n\n10000 yen for the 1-st night\n\n10000 yen for the 2-nd night\n\n10000 yen for the 3-rd night\n\n9000 yen for the 4-th night\n\n9000 yen for the 5-th night\n\nThus, the total is 48000 yen.\n\nSample Input 2\n\n2\n3\n10000\n9000\n\nSample Output 2\n\n20000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 176, "cpu_time_ms": 9, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s236615676", "group_id": "codeNet:p04012", "input_text": "words = gets.chomp.split('')\n\nuntil words.empty?\n if words.count(words[0]).odd?\n puts 'No'\n exit 0\n else\n words -= words[0..words.count(words[0])]\n end\nend\n\nputs 'Yes'\n", "language": "Ruby", "metadata": {"date": 1583363671, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p04012.html", "problem_id": "p04012", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p04012/input.txt", "sample_output_relpath": "derived/input_output/data/p04012/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04012/Ruby/s236615676.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s236615676", "user_id": "u896803757"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "words = gets.chomp.split('')\n\nuntil words.empty?\n if words.count(words[0]).odd?\n puts 'No'\n exit 0\n else\n words -= words[0..words.count(words[0])]\n end\nend\n\nputs 'Yes'\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLet w be a string consisting of lowercase letters.\nWe will call w beautiful if the following condition is satisfied:\n\nEach lowercase letter of the English alphabet occurs even number of times in w.\n\nYou are given the string w. Determine if w is beautiful.\n\nConstraints\n\n1 \\leq |w| \\leq 100\n\nw consists of lowercase letters (a-z).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nw\n\nOutput\n\nPrint Yes if w is beautiful. Print No otherwise.\n\nSample Input 1\n\nabaccaba\n\nSample Output 1\n\nYes\n\na occurs four times, b occurs twice, c occurs twice and the other letters occur zero times.\n\nSample Input 2\n\nhthth\n\nSample Output 2\n\nNo", "sample_input": "abaccaba\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p04012", "source_text": "Score : 200 points\n\nProblem Statement\n\nLet w be a string consisting of lowercase letters.\nWe will call w beautiful if the following condition is satisfied:\n\nEach lowercase letter of the English alphabet occurs even number of times in w.\n\nYou are given the string w. Determine if w is beautiful.\n\nConstraints\n\n1 \\leq |w| \\leq 100\n\nw consists of lowercase letters (a-z).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nw\n\nOutput\n\nPrint Yes if w is beautiful. Print No otherwise.\n\nSample Input 1\n\nabaccaba\n\nSample Output 1\n\nYes\n\na occurs four times, b occurs twice, c occurs twice and the other letters occur zero times.\n\nSample Input 2\n\nhthth\n\nSample Output 2\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 180, "cpu_time_ms": 10, "memory_kb": 2044}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s226837926", "group_id": "codeNet:p04012", "input_text": "puts gets.chomp.chars.group_by{|e|e}.all?{|k,v|v.size%2==0}?:Yes: :No", "language": "Ruby", "metadata": {"date": 1472443538, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p04012.html", "problem_id": "p04012", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p04012/input.txt", "sample_output_relpath": "derived/input_output/data/p04012/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04012/Ruby/s226837926.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s226837926", "user_id": "u280667879"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "puts gets.chomp.chars.group_by{|e|e}.all?{|k,v|v.size%2==0}?:Yes: :No", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLet w be a string consisting of lowercase letters.\nWe will call w beautiful if the following condition is satisfied:\n\nEach lowercase letter of the English alphabet occurs even number of times in w.\n\nYou are given the string w. Determine if w is beautiful.\n\nConstraints\n\n1 \\leq |w| \\leq 100\n\nw consists of lowercase letters (a-z).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nw\n\nOutput\n\nPrint Yes if w is beautiful. Print No otherwise.\n\nSample Input 1\n\nabaccaba\n\nSample Output 1\n\nYes\n\na occurs four times, b occurs twice, c occurs twice and the other letters occur zero times.\n\nSample Input 2\n\nhthth\n\nSample Output 2\n\nNo", "sample_input": "abaccaba\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p04012", "source_text": "Score : 200 points\n\nProblem Statement\n\nLet w be a string consisting of lowercase letters.\nWe will call w beautiful if the following condition is satisfied:\n\nEach lowercase letter of the English alphabet occurs even number of times in w.\n\nYou are given the string w. Determine if w is beautiful.\n\nConstraints\n\n1 \\leq |w| \\leq 100\n\nw consists of lowercase letters (a-z).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nw\n\nOutput\n\nPrint Yes if w is beautiful. Print No otherwise.\n\nSample Input 1\n\nabaccaba\n\nSample Output 1\n\nYes\n\na occurs four times, b occurs twice, c occurs twice and the other letters occur zero times.\n\nSample Input 2\n\nhthth\n\nSample Output 2\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 69, "cpu_time_ms": 18, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s676023456", "group_id": "codeNet:p04020", "input_text": "N,*as=$<.read.split.map(&:to_i)\nas << 0\n\ni = 0\nret = 0\nwhile i < N\n ret += as[i]/2\n if as[i].odd? && 0 < as[i+1]\n ret += 1\n as[i+1] -= 1\n end\n i += 1\nend\n\nputs ret", "language": "Ruby", "metadata": {"date": 1593577334, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p04020.html", "problem_id": "p04020", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p04020/input.txt", "sample_output_relpath": "derived/input_output/data/p04020/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04020/Ruby/s676023456.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s676023456", "user_id": "u852974293"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "N,*as=$<.read.split.map(&:to_i)\nas << 0\n\ni = 0\nret = 0\nwhile i < N\n ret += as[i]/2\n if as[i].odd? && 0 < as[i+1]\n ret += 1\n as[i+1] -= 1\n end\n i += 1\nend\n\nputs ret", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it.\nHe has A_i cards with an integer i.\n\nTwo cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.\n\nSnuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n0 ≦ A_i ≦ 10^9 (1 ≦ i ≦ N)\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint the maximum number of pairs that Snuke can create.\n\nSample Input 1\n\n4\n4\n0\n3\n2\n\nSample Output 1\n\n4\n\nFor example, Snuke can create the following four pairs: (1,1),(1,1),(3,4),(3,4).\n\nSample Input 2\n\n8\n2\n0\n1\n6\n0\n8\n2\n1\n\nSample Output 2\n\n9", "sample_input": "4\n4\n0\n3\n2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p04020", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it.\nHe has A_i cards with an integer i.\n\nTwo cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.\n\nSnuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n0 ≦ A_i ≦ 10^9 (1 ≦ i ≦ N)\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint the maximum number of pairs that Snuke can create.\n\nSample Input 1\n\n4\n4\n0\n3\n2\n\nSample Output 1\n\n4\n\nFor example, Snuke can create the following four pairs: (1,1),(1,1),(3,4),(3,4).\n\nSample Input 2\n\n8\n2\n0\n1\n6\n0\n8\n2\n1\n\nSample Output 2\n\n9", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 189, "cpu_time_ms": 96, "memory_kb": 21528}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s789929026", "group_id": "codeNet:p04022", "input_text": "require 'prime'\nP=Prime.each(2155).map{|x|x**3}\nh=Hash.new(0)\ngets\n$<.each{|_|\n\tn=_.to_i\n\tP.each{|x|n/=x while n%x==0}\n\th[n]+=1\n}\nr=0\nh.each{|k,v|\n\tif k==1\n\t\tr+=[1,v].min\n\telse\n\t\tn=k*k\n\t\tP.each{|x|n/=x while n%x==0}\n\t\tr+=[v,h[n]].max\n\t\th[k]=h[n]=0\n\tend\n}\np r", "language": "Ruby", "metadata": {"date": 1471891488, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p04022.html", "problem_id": "p04022", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p04022/input.txt", "sample_output_relpath": "derived/input_output/data/p04022/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04022/Ruby/s789929026.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s789929026", "user_id": "u280667879"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "require 'prime'\nP=Prime.each(2155).map{|x|x**3}\nh=Hash.new(0)\ngets\n$<.each{|_|\n\tn=_.to_i\n\tP.each{|x|n/=x while n%x==0}\n\th[n]+=1\n}\nr=0\nh.each{|k,v|\n\tif k==1\n\t\tr+=[1,v].min\n\telse\n\t\tn=k*k\n\t\tP.each{|x|n/=x while n%x==0}\n\t\tr+=[v,h[n]].max\n\t\th[k]=h[n]=0\n\tend\n}\np r", "problem_context": "Score : 1100 points\n\nProblem Statement\n\nSnuke got positive integers s_1,...,s_N from his mother, as a birthday present. There may be duplicate elements.\n\nHe will circle some of these N integers. Since he dislikes cubic numbers, he wants to ensure that if both s_i and s_j (i ≠ j) are circled, the product s_is_j is not cubic. For example, when s_1=1,s_2=1,s_3=2,s_4=4, it is not possible to circle both s_1 and s_2 at the same time. It is not possible to circle both s_3 and s_4 at the same time, either.\n\nFind the maximum number of integers that Snuke can circle.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n1 ≦ s_i ≦ 10^{10}\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\ns_1\n:\ns_N\n\nOutput\n\nPrint the maximum number of integers that Snuke can circle.\n\nSample Input 1\n\n8\n1\n2\n3\n4\n5\n6\n7\n8\n\nSample Output 1\n\n6\n\nSnuke can circle 1,2,3,5,6,7.\n\nSample Input 2\n\n6\n2\n4\n8\n16\n32\n64\n\nSample Output 2\n\n3\n\nSample Input 3\n\n10\n1\n10\n100\n1000000007\n10000000000\n1000000009\n999999999\n999\n999\n999\n\nSample Output 3\n\n9", "sample_input": "8\n1\n2\n3\n4\n5\n6\n7\n8\n"}, "reference_outputs": ["6\n"], "source_document_id": "p04022", "source_text": "Score : 1100 points\n\nProblem Statement\n\nSnuke got positive integers s_1,...,s_N from his mother, as a birthday present. There may be duplicate elements.\n\nHe will circle some of these N integers. Since he dislikes cubic numbers, he wants to ensure that if both s_i and s_j (i ≠ j) are circled, the product s_is_j is not cubic. For example, when s_1=1,s_2=1,s_3=2,s_4=4, it is not possible to circle both s_1 and s_2 at the same time. It is not possible to circle both s_3 and s_4 at the same time, either.\n\nFind the maximum number of integers that Snuke can circle.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n1 ≦ s_i ≦ 10^{10}\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\ns_1\n:\ns_N\n\nOutput\n\nPrint the maximum number of integers that Snuke can circle.\n\nSample Input 1\n\n8\n1\n2\n3\n4\n5\n6\n7\n8\n\nSample Output 1\n\n6\n\nSnuke can circle 1,2,3,5,6,7.\n\nSample Input 2\n\n6\n2\n4\n8\n16\n32\n64\n\nSample Output 2\n\n3\n\nSample Input 3\n\n10\n1\n10\n100\n1000000007\n10000000000\n1000000009\n999999999\n999\n999\n999\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": 258, "cpu_time_ms": 4334, "memory_kb": 8956}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s869431438", "group_id": "codeNet:p04029", "input_text": "p (1..gets.to_i).inject :+", "language": "Ruby", "metadata": {"date": 1471198299, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p04029.html", "problem_id": "p04029", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p04029/input.txt", "sample_output_relpath": "derived/input_output/data/p04029/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04029/Ruby/s869431438.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s869431438", "user_id": "u578697635"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "p (1..gets.to_i).inject :+", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?\n\nConstraints\n\n1≦N≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the necessary number of candies in total.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\nThe answer is 1+2+3=6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n55\n\nThe sum of the integers from 1 to 10 is 55.\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nOnly one child. The answer is 1 in this case.", "sample_input": "3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p04029", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?\n\nConstraints\n\n1≦N≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the necessary number of candies in total.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\nThe answer is 1+2+3=6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n55\n\nThe sum of the integers from 1 to 10 is 55.\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nOnly one child. The answer is 1 in this case.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 26, "cpu_time_ms": 17, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s712294581", "group_id": "codeNet:p04030", "input_text": "a = []\na = gets.split(\"\")\nb =[]\nc = 0\nfor i in 0..a.length-1\n if a[i] == \"B\"\n c = b.pop\n else\n b.push(a[i].to_i)\n end\nend\nputs b.join(\"\")", "language": "Ruby", "metadata": {"date": 1526427830, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p04030.html", "problem_id": "p04030", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p04030/input.txt", "sample_output_relpath": "derived/input_output/data/p04030/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04030/Ruby/s712294581.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s712294581", "user_id": "u614043796"}, "prompt_components": {"gold_output": "00\n", "input_to_evaluate": "a = []\na = gets.split(\"\")\nb =[]\nc = 0\nfor i in 0..a.length-1\n if a[i] == \"B\"\n c = b.pop\n else\n b.push(a[i].to_i)\n end\nend\nputs b.join(\"\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the 0 key, the 1 key and the backspace key.\n\nTo begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string:\n\nThe 0 key: a letter 0 will be inserted to the right of the string.\n\nThe 1 key: a letter 1 will be inserted to the right of the string.\n\nThe backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.\n\nSig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter 0 stands for the 0 key, the letter 1 stands for the 1 key and the letter B stands for the backspace key. What string is displayed in the editor now?\n\nConstraints\n\n1 ≦ |s| ≦ 10 (|s| denotes the length of s)\n\ns consists of the letters 0, 1 and B.\n\nThe correct answer is not an empty string.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string displayed in the editor in the end.\n\nSample Input 1\n\n01B0\n\nSample Output 1\n\n00\n\nEach time the key is pressed, the string in the editor will change as follows: 0, 01, 0, 00.\n\nSample Input 2\n\n0BB1\n\nSample Output 2\n\n1\n\nEach time the key is pressed, the string in the editor will change as follows: 0, (empty), (empty), 1.", "sample_input": "01B0\n"}, "reference_outputs": ["00\n"], "source_document_id": "p04030", "source_text": "Score : 200 points\n\nProblem Statement\n\nSig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the 0 key, the 1 key and the backspace key.\n\nTo begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string:\n\nThe 0 key: a letter 0 will be inserted to the right of the string.\n\nThe 1 key: a letter 1 will be inserted to the right of the string.\n\nThe backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.\n\nSig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter 0 stands for the 0 key, the letter 1 stands for the 1 key and the letter B stands for the backspace key. What string is displayed in the editor now?\n\nConstraints\n\n1 ≦ |s| ≦ 10 (|s| denotes the length of s)\n\ns consists of the letters 0, 1 and B.\n\nThe correct answer is not an empty string.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string displayed in the editor in the end.\n\nSample Input 1\n\n01B0\n\nSample Output 1\n\n00\n\nEach time the key is pressed, the string in the editor will change as follows: 0, 01, 0, 00.\n\nSample Input 2\n\n0BB1\n\nSample Output 2\n\n1\n\nEach time the key is pressed, the string in the editor will change as follows: 0, (empty), (empty), 1.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 146, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s122738255", "group_id": "codeNet:p04030", "input_text": "\narr = []\nSTDIN.gets.chomp.split(//).each do |char|\n\tif char == \"B\"\n\t\tarr.pop\n\telse\n\t\tarr.push char\n\tend\nend\n\nSTDOUT.print arr.join\nSTDOUT.print \"\\n\"", "language": "Ruby", "metadata": {"date": 1472261080, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p04030.html", "problem_id": "p04030", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p04030/input.txt", "sample_output_relpath": "derived/input_output/data/p04030/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04030/Ruby/s122738255.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s122738255", "user_id": "u068430381"}, "prompt_components": {"gold_output": "00\n", "input_to_evaluate": "\narr = []\nSTDIN.gets.chomp.split(//).each do |char|\n\tif char == \"B\"\n\t\tarr.pop\n\telse\n\t\tarr.push char\n\tend\nend\n\nSTDOUT.print arr.join\nSTDOUT.print \"\\n\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the 0 key, the 1 key and the backspace key.\n\nTo begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string:\n\nThe 0 key: a letter 0 will be inserted to the right of the string.\n\nThe 1 key: a letter 1 will be inserted to the right of the string.\n\nThe backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.\n\nSig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter 0 stands for the 0 key, the letter 1 stands for the 1 key and the letter B stands for the backspace key. What string is displayed in the editor now?\n\nConstraints\n\n1 ≦ |s| ≦ 10 (|s| denotes the length of s)\n\ns consists of the letters 0, 1 and B.\n\nThe correct answer is not an empty string.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string displayed in the editor in the end.\n\nSample Input 1\n\n01B0\n\nSample Output 1\n\n00\n\nEach time the key is pressed, the string in the editor will change as follows: 0, 01, 0, 00.\n\nSample Input 2\n\n0BB1\n\nSample Output 2\n\n1\n\nEach time the key is pressed, the string in the editor will change as follows: 0, (empty), (empty), 1.", "sample_input": "01B0\n"}, "reference_outputs": ["00\n"], "source_document_id": "p04030", "source_text": "Score : 200 points\n\nProblem Statement\n\nSig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the 0 key, the 1 key and the backspace key.\n\nTo begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string:\n\nThe 0 key: a letter 0 will be inserted to the right of the string.\n\nThe 1 key: a letter 1 will be inserted to the right of the string.\n\nThe backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.\n\nSig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter 0 stands for the 0 key, the letter 1 stands for the 1 key and the letter B stands for the backspace key. What string is displayed in the editor now?\n\nConstraints\n\n1 ≦ |s| ≦ 10 (|s| denotes the length of s)\n\ns consists of the letters 0, 1 and B.\n\nThe correct answer is not an empty string.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string displayed in the editor in the end.\n\nSample Input 1\n\n01B0\n\nSample Output 1\n\n00\n\nEach time the key is pressed, the string in the editor will change as follows: 0, 01, 0, 00.\n\nSample Input 2\n\n0BB1\n\nSample Output 2\n\n1\n\nEach time the key is pressed, the string in the editor will change as follows: 0, (empty), (empty), 1.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 149, "cpu_time_ms": 18, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s801311255", "group_id": "codeNet:p04031", "input_text": "n = gets.to_i\na = gets.chomp.split.map(&:to_i)\nava = a.inject(:+) / n\nputs [ava, ava + 1].map {|x| a.map {|y| (x - y) ** 2 }.inject(:+) }.min", "language": "Ruby", "metadata": {"date": 1590382103, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p04031.html", "problem_id": "p04031", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p04031/input.txt", "sample_output_relpath": "derived/input_output/data/p04031/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04031/Ruby/s801311255.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s801311255", "user_id": "u482840940"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "n = gets.to_i\na = gets.chomp.split.map(&:to_i)\nava = a.inject(:+) / n\nputs [ava, ava + 1].map {|x| a.map {|y| (x - y) ** 2 }.inject(:+) }.min", "problem_context": "Score : 200 points\n\nProblem Statement\n\nEvi has N integers a_1,a_2,..,a_N. His objective is to have N equal integers by transforming some of them.\n\nHe may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2).\n\nFind the minimum total cost to achieve his objective.\n\nConstraints\n\n1≦N≦100\n\n-100≦a_i≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum total cost to achieve Evi's objective.\n\nSample Input 1\n\n2\n4 8\n\nSample Output 1\n\n8\n\nTransforming the both into 6s will cost (4-6)^2+(8-6)^2=8 dollars, which is the minimum.\n\nSample Input 2\n\n3\n1 1 3\n\nSample Output 2\n\n3\n\nTransforming the all into 2s will cost (1-2)^2+(1-2)^2+(3-2)^2=3 dollars. Note that Evi has to pay (1-2)^2 dollar separately for transforming each of the two 1s.\n\nSample Input 3\n\n3\n4 2 5\n\nSample Output 3\n\n5\n\nLeaving the 4 as it is and transforming the 2 and the 5 into 4s will achieve the total cost of (2-4)^2+(5-4)^2=5 dollars, which is the minimum.\n\nSample Input 4\n\n4\n-100 -100 -100 -100\n\nSample Output 4\n\n0\n\nWithout transforming anything, Evi's objective is already achieved. Thus, the necessary cost is 0.", "sample_input": "2\n4 8\n"}, "reference_outputs": ["8\n"], "source_document_id": "p04031", "source_text": "Score : 200 points\n\nProblem Statement\n\nEvi has N integers a_1,a_2,..,a_N. His objective is to have N equal integers by transforming some of them.\n\nHe may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2).\n\nFind the minimum total cost to achieve his objective.\n\nConstraints\n\n1≦N≦100\n\n-100≦a_i≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum total cost to achieve Evi's objective.\n\nSample Input 1\n\n2\n4 8\n\nSample Output 1\n\n8\n\nTransforming the both into 6s will cost (4-6)^2+(8-6)^2=8 dollars, which is the minimum.\n\nSample Input 2\n\n3\n1 1 3\n\nSample Output 2\n\n3\n\nTransforming the all into 2s will cost (1-2)^2+(1-2)^2+(3-2)^2=3 dollars. Note that Evi has to pay (1-2)^2 dollar separately for transforming each of the two 1s.\n\nSample Input 3\n\n3\n4 2 5\n\nSample Output 3\n\n5\n\nLeaving the 4 as it is and transforming the 2 and the 5 into 4s will achieve the total cost of (2-4)^2+(5-4)^2=5 dollars, which is the minimum.\n\nSample Input 4\n\n4\n-100 -100 -100 -100\n\nSample Output 4\n\n0\n\nWithout transforming anything, Evi's objective is already achieved. Thus, the necessary cost is 0.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 141, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s486257719", "group_id": "codeNet:p04032", "input_text": "s=gets.chomp\nm=s.size\nans = false\nif s.size <= 100\n0.upto(m-3) do |i|\n break if ans\n (i+2).upto(m-1) do |j|\n c=Array.new(26,0)\n b = s[i..j]\n b.chars do |d|\n c[d.ord-97] += 1\n end\n c.sort!.reverse!\n if c[0] > b.size / 2 && b.size >= 3\n puts \"#{i+1} #{j+1}\"\n ans = true\n break\n end\n end\n\nend\nputs \"-1 -1\" unless ans\nend\n", "language": "Ruby", "metadata": {"date": 1471142385, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p04032.html", "problem_id": "p04032", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p04032/input.txt", "sample_output_relpath": "derived/input_output/data/p04032/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04032/Ruby/s486257719.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s486257719", "user_id": "u498700239"}, "prompt_components": {"gold_output": "2 5\n", "input_to_evaluate": "s=gets.chomp\nm=s.size\nans = false\nif s.size <= 100\n0.upto(m-3) do |i|\n break if ans\n (i+2).upto(m-1) do |j|\n c=Array.new(26,0)\n b = s[i..j]\n b.chars do |d|\n c[d.ord-97] += 1\n end\n c.sort!.reverse!\n if c[0] > b.size / 2 && b.size >= 3\n puts \"#{i+1} #{j+1}\"\n ans = true\n break\n end\n end\n\nend\nputs \"-1 -1\" unless ans\nend\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven a string t, we will call it unbalanced if and only if the length of t is at least 2, and more than half of the letters in t are the same. For example, both voodoo and melee are unbalanced, while neither noon nor a is.\n\nYou are given a string s consisting of lowercase letters. Determine if there exists a (contiguous) substring of s that is unbalanced. If the answer is positive, show a position where such a substring occurs in s.\n\nConstraints\n\n2 ≦ |s| ≦ 10^5\n\ns consists of lowercase letters.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 2 ≦ N ≦ 100.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf there exists no unbalanced substring of s, print -1 -1.\n\nIf there exists an unbalanced substring of s, let one such substring be s_a s_{a+1} ... s_{b} (1 ≦ a < b ≦ |s|), and print a b. If there exists more than one such substring, any of them will be accepted.\n\nSample Input 1\n\nneeded\n\nSample Output 1\n\n2 5\n\nThe string s_2 s_3 s_4 s_5 = eede is unbalanced. There are also other unbalanced substrings. For example, the output 2 6 will also be accepted.\n\nSample Input 2\n\natcoder\n\nSample Output 2\n\n-1 -1\n\nThe string atcoder contains no unbalanced substring.", "sample_input": "needed\n"}, "reference_outputs": ["2 5\n"], "source_document_id": "p04032", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven a string t, we will call it unbalanced if and only if the length of t is at least 2, and more than half of the letters in t are the same. For example, both voodoo and melee are unbalanced, while neither noon nor a is.\n\nYou are given a string s consisting of lowercase letters. Determine if there exists a (contiguous) substring of s that is unbalanced. If the answer is positive, show a position where such a substring occurs in s.\n\nConstraints\n\n2 ≦ |s| ≦ 10^5\n\ns consists of lowercase letters.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 2 ≦ N ≦ 100.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf there exists no unbalanced substring of s, print -1 -1.\n\nIf there exists an unbalanced substring of s, let one such substring be s_a s_{a+1} ... s_{b} (1 ≦ a < b ≦ |s|), and print a b. If there exists more than one such substring, any of them will be accepted.\n\nSample Input 1\n\nneeded\n\nSample Output 1\n\n2 5\n\nThe string s_2 s_3 s_4 s_5 = eede is unbalanced. There are also other unbalanced substrings. For example, the output 2 6 will also be accepted.\n\nSample Input 2\n\natcoder\n\nSample Output 2\n\n-1 -1\n\nThe string atcoder contains no unbalanced substring.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 362, "cpu_time_ms": 94, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s491741870", "group_id": "codeNet:p04035", "input_text": "n,l,*a=`dd`.split.map &:to_i;puts (z=(1...n).find{|i|a[i-1]+a[i]>=l})?[:Possible,*1...z,[*z...n].reverse]: :Impossible", "language": "Ruby", "metadata": {"date": 1473110557, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p04035.html", "problem_id": "p04035", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p04035/input.txt", "sample_output_relpath": "derived/input_output/data/p04035/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04035/Ruby/s491741870.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s491741870", "user_id": "u280667879"}, "prompt_components": {"gold_output": "Possible\n2\n1\n", "input_to_evaluate": "n,l,*a=`dd`.split.map &:to_i;puts (z=(1...n).find{|i|a[i-1]+a[i]>=l})?[:Possible,*1...z,[*z...n].reverse]: :Impossible", "problem_context": "Problem Statement\n\nWe have N pieces of ropes, numbered 1 through N. The length of piece i is a_i.\n\nAt first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly:\n\nChoose a (connected) rope with a total length of at least L, then untie one of its knots.\n\nIs it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.\n\nConstraints\n\n2≤N≤10^5\n\n1≤L≤10^9\n\n1≤a_i≤10^9\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN L\na_1 a_2 ... a_n\n\nOutput\n\nIf it is not possible to untie all of the N-1 knots, print Impossible.\n\nIf it is possible to untie all of the knots, print Possible, then print another N-1 lines that describe a possible order to untie the knots. The j-th of those N-1 lines should contain the index of the knot that is untied in the j-th operation. Here, the index of the knot connecting piece i and piece i+1 is i.\n\nIf there is more than one solution, output any.\n\nSample Input 1\n\n3 50\n30 20 10\n\nSample Output 1\n\nPossible\n2\n1\n\nIf the knot 1 is untied first, the knot 2 will become impossible to untie.\n\nSample Input 2\n\n2 21\n10 10\n\nSample Output 2\n\nImpossible\n\nSample Input 3\n\n5 50\n10 20 30 40 50\n\nSample Output 3\n\nPossible\n1\n2\n3\n4\n\nAnother example of a possible solution is 3, 4, 1, 2.", "sample_input": "3 50\n30 20 10\n"}, "reference_outputs": ["Possible\n2\n1\n"], "source_document_id": "p04035", "source_text": "Problem Statement\n\nWe have N pieces of ropes, numbered 1 through N. The length of piece i is a_i.\n\nAt first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly:\n\nChoose a (connected) rope with a total length of at least L, then untie one of its knots.\n\nIs it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.\n\nConstraints\n\n2≤N≤10^5\n\n1≤L≤10^9\n\n1≤a_i≤10^9\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN L\na_1 a_2 ... a_n\n\nOutput\n\nIf it is not possible to untie all of the N-1 knots, print Impossible.\n\nIf it is possible to untie all of the knots, print Possible, then print another N-1 lines that describe a possible order to untie the knots. The j-th of those N-1 lines should contain the index of the knot that is untied in the j-th operation. Here, the index of the knot connecting piece i and piece i+1 is i.\n\nIf there is more than one solution, output any.\n\nSample Input 1\n\n3 50\n30 20 10\n\nSample Output 1\n\nPossible\n2\n1\n\nIf the knot 1 is untied first, the knot 2 will become impossible to untie.\n\nSample Input 2\n\n2 21\n10 10\n\nSample Output 2\n\nImpossible\n\nSample Input 3\n\n5 50\n10 20 30 40 50\n\nSample Output 3\n\nPossible\n1\n2\n3\n4\n\nAnother example of a possible solution is 3, 4, 1, 2.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 118, "cpu_time_ms": 251, "memory_kb": 14592}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s986248412", "group_id": "codeNet:p04043", "input_text": " A,B,C= gets.split\nif (A==7 && B==5 && C==5) || (A==5 && B==7 && C==5) || (A==5 && B==5 && C==7)\n puts\"Yes\"\nelse\n puts\"No\"\nend\n \n ", "language": "Ruby", "metadata": {"date": 1561946238, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p04043.html", "problem_id": "p04043", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p04043/input.txt", "sample_output_relpath": "derived/input_output/data/p04043/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04043/Ruby/s986248412.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s986248412", "user_id": "u403385724"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": " A,B,C= gets.split\nif (A==7 && B==5 && C==5) || (A==5 && B==7 && C==5) || (A==5 && B==5 && C==7)\n puts\"Yes\"\nelse\n puts\"No\"\nend\n \n ", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIroha loves Haiku. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.\n\nTo create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.\n\nConstraints\n\n1≦A,B,C≦10\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf it is possible to construct a Haiku by using each of the phrases once, print YES (case-sensitive). Otherwise, print NO.\n\nSample Input 1\n\n5 5 7\n\nSample Output 1\n\nYES\n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\nSample Input 2\n\n7 7 5\n\nSample Output 2\n\nNO", "sample_input": "5 5 7\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p04043", "source_text": "Score : 100 points\n\nProblem Statement\n\nIroha loves Haiku. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.\n\nTo create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.\n\nConstraints\n\n1≦A,B,C≦10\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf it is possible to construct a Haiku by using each of the phrases once, print YES (case-sensitive). Otherwise, print NO.\n\nSample Input 1\n\n5 5 7\n\nSample Output 1\n\nYES\n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\nSample Input 2\n\n7 7 5\n\nSample Output 2\n\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 133, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s893214311", "group_id": "codeNet:p04043", "input_text": "count5 = 0\ncount7 = 0\n\narr = $stdin.gets.chomp.split(/\\s+/).map(&:to_i)\n\narr.map do |str|\n if str == 5\n count5 += 1\n end\n if str == 7\n count7 += 1\n end\nend\n\nanswer = (count5 == 2 && count7 == 1) ? \"YES\" : \"NO\"\n\nputs answer\n", "language": "Ruby", "metadata": {"date": 1473007823, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p04043.html", "problem_id": "p04043", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p04043/input.txt", "sample_output_relpath": "derived/input_output/data/p04043/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04043/Ruby/s893214311.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s893214311", "user_id": "u451787864"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "count5 = 0\ncount7 = 0\n\narr = $stdin.gets.chomp.split(/\\s+/).map(&:to_i)\n\narr.map do |str|\n if str == 5\n count5 += 1\n end\n if str == 7\n count7 += 1\n end\nend\n\nanswer = (count5 == 2 && count7 == 1) ? \"YES\" : \"NO\"\n\nputs answer\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIroha loves Haiku. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.\n\nTo create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.\n\nConstraints\n\n1≦A,B,C≦10\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf it is possible to construct a Haiku by using each of the phrases once, print YES (case-sensitive). Otherwise, print NO.\n\nSample Input 1\n\n5 5 7\n\nSample Output 1\n\nYES\n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\nSample Input 2\n\n7 7 5\n\nSample Output 2\n\nNO", "sample_input": "5 5 7\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p04043", "source_text": "Score : 100 points\n\nProblem Statement\n\nIroha loves Haiku. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.\n\nTo create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.\n\nConstraints\n\n1≦A,B,C≦10\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf it is possible to construct a Haiku by using each of the phrases once, print YES (case-sensitive). Otherwise, print NO.\n\nSample Input 1\n\n5 5 7\n\nSample Output 1\n\nYES\n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\nSample Input 2\n\n7 7 5\n\nSample Output 2\n\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 233, "cpu_time_ms": 20, "memory_kb": 1916}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s874323756", "group_id": "codeNet:p04045", "input_text": "N,k=gets.chomp.split(\" \")\nN_i = N.to_i\nK = k.to_i\nd_array=gets.chomp.split(\" \").map(&:to_i)\nE_array= (0..9).to_a - d_array\n\nif 10-K == 1\n ret = E_array[0]\n while ret < N_i\n ret = ret*10 + E_array[0]\n end\n puts ret\n exit\nend\n\n# 使える数字を元にn進数を10進数にする\ndef to_i10(n)\n n_s = n.to_s(10-K)\n ret = 0\n\n start = 0\n diff = 0\n if E_array[0]!=0 && n_s.length>1\n if n_s[0]==\"1\" && n_s[1]==\"0\"\n\t diff = E_array[-1] - E_array[0]\n else\n ret = E_array[n_s[0].to_i-1]\n diff = -1 if n_s.length==2 \n end\n start=1\n end\n\n (start..(n_s.length-1)).each do |i|\n ret = ret*10 + E_array[n_s[i].to_i] + diff\n diff = 0\n end\n ret\nend\n\nsup = (10**N.length).to_s(10-K).to_i\ninf = 0\nloop do\n mid = (sup + inf)/2\n if inf == mid\n puts to_i10(sup)\n break\n end\n\n mid_i10 = to_i10(mid)\n if mid_i10 < N_i\n inf = mid\n else\n sup = mid\n end\nend\n", "language": "Ruby", "metadata": {"date": 1593338128, "filename_ext": "rb", "original_language": "Ruby (2.7.1)", "problem_description_relpath": "problem_descriptions/p04045.html", "problem_id": "p04045", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p04045/input.txt", "sample_output_relpath": "derived/input_output/data/p04045/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04045/Ruby/s874323756.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s874323756", "user_id": "u058568575"}, "prompt_components": {"gold_output": "2000\n", "input_to_evaluate": "N,k=gets.chomp.split(\" \")\nN_i = N.to_i\nK = k.to_i\nd_array=gets.chomp.split(\" \").map(&:to_i)\nE_array= (0..9).to_a - d_array\n\nif 10-K == 1\n ret = E_array[0]\n while ret < N_i\n ret = ret*10 + E_array[0]\n end\n puts ret\n exit\nend\n\n# 使える数字を元にn進数を10進数にする\ndef to_i10(n)\n n_s = n.to_s(10-K)\n ret = 0\n\n start = 0\n diff = 0\n if E_array[0]!=0 && n_s.length>1\n if n_s[0]==\"1\" && n_s[1]==\"0\"\n\t diff = E_array[-1] - E_array[0]\n else\n ret = E_array[n_s[0].to_i-1]\n diff = -1 if n_s.length==2 \n end\n start=1\n end\n\n (start..(n_s.length-1)).each do |i|\n ret = ret*10 + E_array[n_s[i].to_i] + diff\n diff = 0\n end\n ret\nend\n\nsup = (10**N.length).to_s(10-K).to_i\ninf = 0\nloop do\n mid = (sup + inf)/2\n if inf == mid\n puts to_i10(sup)\n break\n end\n\n mid_i10 = to_i10(mid)\n if mid_i10 < N_i\n inf = mid\n else\n sup = mid\n end\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier.\nHer total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).\n\nHowever, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.\n\nFind the amount of money that she will hand to the cashier.\n\nConstraints\n\n1 ≦ N < 10000\n\n1 ≦ K < 10\n\n0 ≦ D_1 < D_2 < … < D_K≦9\n\n\\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nD_1 D_2 … D_K\n\nOutput\n\nPrint the amount of money that Iroha will hand to the cashier.\n\nSample Input 1\n\n1000 8\n1 3 4 5 6 7 8 9\n\nSample Output 1\n\n2000\n\nShe dislikes all digits except 0 and 2.\n\nThe smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.\n\nSample Input 2\n\n9999 1\n0\n\nSample Output 2\n\n9999", "sample_input": "1000 8\n1 3 4 5 6 7 8 9\n"}, "reference_outputs": ["2000\n"], "source_document_id": "p04045", "source_text": "Score : 300 points\n\nProblem Statement\n\nIroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier.\nHer total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).\n\nHowever, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.\n\nFind the amount of money that she will hand to the cashier.\n\nConstraints\n\n1 ≦ N < 10000\n\n1 ≦ K < 10\n\n0 ≦ D_1 < D_2 < … < D_K≦9\n\n\\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nD_1 D_2 … D_K\n\nOutput\n\nPrint the amount of money that Iroha will hand to the cashier.\n\nSample Input 1\n\n1000 8\n1 3 4 5 6 7 8 9\n\nSample Output 1\n\n2000\n\nShe dislikes all digits except 0 and 2.\n\nThe smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.\n\nSample Input 2\n\n9999 1\n0\n\nSample Output 2\n\n9999", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1001, "cpu_time_ms": 65, "memory_kb": 14376}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s043474433", "group_id": "codeNet:p04045", "input_text": "n,k = gets.chomp.split().map(&:to_i)\nd = gets.chomp.split\n\nwhile true\n if d.any?{|e| n.to_s.include?(e)}\n n += 1\n else\n puts n\n exit\n end\nend\n", "language": "Ruby", "metadata": {"date": 1578967656, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p04045.html", "problem_id": "p04045", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p04045/input.txt", "sample_output_relpath": "derived/input_output/data/p04045/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04045/Ruby/s043474433.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s043474433", "user_id": "u524019694"}, "prompt_components": {"gold_output": "2000\n", "input_to_evaluate": "n,k = gets.chomp.split().map(&:to_i)\nd = gets.chomp.split\n\nwhile true\n if d.any?{|e| n.to_s.include?(e)}\n n += 1\n else\n puts n\n exit\n end\nend\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier.\nHer total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).\n\nHowever, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.\n\nFind the amount of money that she will hand to the cashier.\n\nConstraints\n\n1 ≦ N < 10000\n\n1 ≦ K < 10\n\n0 ≦ D_1 < D_2 < … < D_K≦9\n\n\\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nD_1 D_2 … D_K\n\nOutput\n\nPrint the amount of money that Iroha will hand to the cashier.\n\nSample Input 1\n\n1000 8\n1 3 4 5 6 7 8 9\n\nSample Output 1\n\n2000\n\nShe dislikes all digits except 0 and 2.\n\nThe smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.\n\nSample Input 2\n\n9999 1\n0\n\nSample Output 2\n\n9999", "sample_input": "1000 8\n1 3 4 5 6 7 8 9\n"}, "reference_outputs": ["2000\n"], "source_document_id": "p04045", "source_text": "Score : 300 points\n\nProblem Statement\n\nIroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier.\nHer total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).\n\nHowever, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.\n\nFind the amount of money that she will hand to the cashier.\n\nConstraints\n\n1 ≦ N < 10000\n\n1 ≦ K < 10\n\n0 ≦ D_1 < D_2 < … < D_K≦9\n\n\\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nD_1 D_2 … D_K\n\nOutput\n\nPrint the amount of money that Iroha will hand to the cashier.\n\nSample Input 1\n\n1000 8\n1 3 4 5 6 7 8 9\n\nSample Output 1\n\n2000\n\nShe dislikes all digits except 0 and 2.\n\nThe smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.\n\nSample Input 2\n\n9999 1\n0\n\nSample Output 2\n\n9999", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 154, "cpu_time_ms": 59, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s082604208", "group_id": "codeNet:p04047", "input_text": "N = gets.to_i\nL = gets.split.map(&:to_i).sort\n\nans = 0\nN.times{ |i| ans += L[i*2]}\nputs ans", "language": "Ruby", "metadata": {"date": 1511041392, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p04047.html", "problem_id": "p04047", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p04047/input.txt", "sample_output_relpath": "derived/input_output/data/p04047/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04047/Ruby/s082604208.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s082604208", "user_id": "u693378622"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "N = gets.to_i\nL = gets.split.map(&:to_i).sort\n\nans = 0\nN.times{ |i| ans += L[i*2]}\nputs ans", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke is having a barbeque party.\n\nAt the party, he will make N servings of Skewer Meal.\n\nExample of a serving of Skewer Meal\n\nHe has a stock of 2N skewers, all of which will be used in Skewer Meal. The length of the i-th skewer is L_i.\nAlso, he has an infinite supply of ingredients.\n\nTo make a serving of Skewer Meal, he picks 2 skewers and threads ingredients onto those skewers.\nLet the length of the shorter skewer be x, then the serving can hold the maximum of x ingredients.\n\nWhat is the maximum total number of ingredients that his N servings of Skewer Meal can hold, if he uses the skewers optimally?\n\nConstraints\n\n1≦N≦100\n\n1≦L_i≦100\n\nFor each i, L_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_{2N}\n\nOutput\n\nPrint the maximum total number of ingredients that Snuke's N servings of Skewer Meal can hold.\n\nSample Input 1\n\n2\n1 3 1 2\n\nSample Output 1\n\n3\n\nIf he makes a serving using the first and third skewers, and another using the second and fourth skewers, each serving will hold 1 and 2 ingredients, for the total of 3.\n\nSample Input 2\n\n5\n100 1 2 3 14 15 58 58 58 29\n\nSample Output 2\n\n135", "sample_input": "2\n1 3 1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p04047", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke is having a barbeque party.\n\nAt the party, he will make N servings of Skewer Meal.\n\nExample of a serving of Skewer Meal\n\nHe has a stock of 2N skewers, all of which will be used in Skewer Meal. The length of the i-th skewer is L_i.\nAlso, he has an infinite supply of ingredients.\n\nTo make a serving of Skewer Meal, he picks 2 skewers and threads ingredients onto those skewers.\nLet the length of the shorter skewer be x, then the serving can hold the maximum of x ingredients.\n\nWhat is the maximum total number of ingredients that his N servings of Skewer Meal can hold, if he uses the skewers optimally?\n\nConstraints\n\n1≦N≦100\n\n1≦L_i≦100\n\nFor each i, L_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_{2N}\n\nOutput\n\nPrint the maximum total number of ingredients that Snuke's N servings of Skewer Meal can hold.\n\nSample Input 1\n\n2\n1 3 1 2\n\nSample Output 1\n\n3\n\nIf he makes a serving using the first and third skewers, and another using the second and fourth skewers, each serving will hold 1 and 2 ingredients, for the total of 3.\n\nSample Input 2\n\n5\n100 1 2 3 14 15 58 58 58 29\n\nSample Output 2\n\n135", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 91, "cpu_time_ms": 7, "memory_kb": 1788}, "variant": "high_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Ruby:s816967548", "group_id": "codeNet:p04047", "input_text": "_ = gets.to_i\nsum = 0\ngets.split(' ').map{|e|e.to_i}.sort.each_with_index{|e, i| sum += e if i.even?}\nputs sum\n", "language": "Ruby", "metadata": {"date": 1468717693, "filename_ext": "rb", "original_language": "Ruby (2.3.3)", "problem_description_relpath": "problem_descriptions/p04047.html", "problem_id": "p04047", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p04047/input.txt", "sample_output_relpath": "derived/input_output/data/p04047/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04047/Ruby/s816967548.rb", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s816967548", "user_id": "u376266842"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "_ = gets.to_i\nsum = 0\ngets.split(' ').map{|e|e.to_i}.sort.each_with_index{|e, i| sum += e if i.even?}\nputs sum\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke is having a barbeque party.\n\nAt the party, he will make N servings of Skewer Meal.\n\nExample of a serving of Skewer Meal\n\nHe has a stock of 2N skewers, all of which will be used in Skewer Meal. The length of the i-th skewer is L_i.\nAlso, he has an infinite supply of ingredients.\n\nTo make a serving of Skewer Meal, he picks 2 skewers and threads ingredients onto those skewers.\nLet the length of the shorter skewer be x, then the serving can hold the maximum of x ingredients.\n\nWhat is the maximum total number of ingredients that his N servings of Skewer Meal can hold, if he uses the skewers optimally?\n\nConstraints\n\n1≦N≦100\n\n1≦L_i≦100\n\nFor each i, L_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_{2N}\n\nOutput\n\nPrint the maximum total number of ingredients that Snuke's N servings of Skewer Meal can hold.\n\nSample Input 1\n\n2\n1 3 1 2\n\nSample Output 1\n\n3\n\nIf he makes a serving using the first and third skewers, and another using the second and fourth skewers, each serving will hold 1 and 2 ingredients, for the total of 3.\n\nSample Input 2\n\n5\n100 1 2 3 14 15 58 58 58 29\n\nSample Output 2\n\n135", "sample_input": "2\n1 3 1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p04047", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke is having a barbeque party.\n\nAt the party, he will make N servings of Skewer Meal.\n\nExample of a serving of Skewer Meal\n\nHe has a stock of 2N skewers, all of which will be used in Skewer Meal. The length of the i-th skewer is L_i.\nAlso, he has an infinite supply of ingredients.\n\nTo make a serving of Skewer Meal, he picks 2 skewers and threads ingredients onto those skewers.\nLet the length of the shorter skewer be x, then the serving can hold the maximum of x ingredients.\n\nWhat is the maximum total number of ingredients that his N servings of Skewer Meal can hold, if he uses the skewers optimally?\n\nConstraints\n\n1≦N≦100\n\n1≦L_i≦100\n\nFor each i, L_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_{2N}\n\nOutput\n\nPrint the maximum total number of ingredients that Snuke's N servings of Skewer Meal can hold.\n\nSample Input 1\n\n2\n1 3 1 2\n\nSample Output 1\n\n3\n\nIf he makes a serving using the first and third skewers, and another using the second and fourth skewers, each serving will hold 1 and 2 ingredients, for the total of 3.\n\nSample Input 2\n\n5\n100 1 2 3 14 15 58 58 58 29\n\nSample Output 2\n\n135", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 111, "cpu_time_ms": 17, "memory_kb": 1788}, "variant": "high_resource"}